summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2023-03-14 12:19:48 +0000
committerAidan MacDonald <amachronic@protonmail.com>2023-03-21 16:23:54 -0400
commitd40a598970b04bfe3a867a5e12debc45c149b46b (patch)
tree26e974f910f7d3047adfbc536d8e10c2d973b7e9 /apps/plugins
parent2fb2364686e5470437f0ee3d214662d51067eb90 (diff)
downloadrockbox-d40a598970b04bfe3a867a5e12debc45c149b46b.tar.gz
rockbox-d40a598970b04bfe3a867a5e12debc45c149b46b.zip
plugins: Simplify plugin/codec API versioning
Replace the minimum version bound with a check on the size of the API struct. The version only needs to be incremented for ABI breaking changes. Additions to the API won't need to touch the version number, resulting in fewer merge conflicts. Change-Id: I916a04a7bf5890dcf5d615ce30087643165f8e1f
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/imageviewer/image_decoder.c5
-rw-r--r--apps/plugins/imageviewer/imageviewer.h14
-rw-r--r--apps/plugins/lib/overlay.c5
3 files changed, 16 insertions, 8 deletions
diff --git a/apps/plugins/imageviewer/image_decoder.c b/apps/plugins/imageviewer/image_decoder.c
index eab1c01dbc..0c1776daaa 100644
--- a/apps/plugins/imageviewer/image_decoder.c
+++ b/apps/plugins/imageviewer/image_decoder.c
@@ -155,7 +155,10 @@ const struct image_decoder *load_decoder(struct loader_info *loader_info)
155 goto error_close; 155 goto error_close;
156 } 156 }
157 157
158 if (lc_hdr->api_version != IMGDEC_API_VERSION) 158 if (lc_hdr->api_version != IMGDEC_API_VERSION ||
159 hdr->img_api_size > sizeof(struct imgdec_api) ||
160 hdr->plugin_api_version != PLUGIN_API_VERSION ||
161 hdr->plugin_api_size > sizeof(struct plugin_api))
159 { 162 {
160 rb->splashf(2*HZ, "%s decoder: Incompatible version.", name); 163 rb->splashf(2*HZ, "%s decoder: Incompatible version.", name);
161 goto error_close; 164 goto error_close;
diff --git a/apps/plugins/imageviewer/imageviewer.h b/apps/plugins/imageviewer/imageviewer.h
index 19b5db15bb..ac15df5960 100644
--- a/apps/plugins/imageviewer/imageviewer.h
+++ b/apps/plugins/imageviewer/imageviewer.h
@@ -136,14 +136,17 @@ struct image_decoder {
136 int x, int y, int width, int height); 136 int x, int y, int width, int height);
137}; 137};
138 138
139#define IMGDEC_API_VERSION (PLUGIN_API_VERSION << 4 | 0) 139#define IMGDEC_API_VERSION 1
140 140
141/* image decoder header */ 141/* image decoder header */
142struct imgdec_header { 142struct imgdec_header {
143 struct lc_header lc_hdr; /* must be the first */ 143 struct lc_header lc_hdr; /* must be the first */
144 const struct image_decoder *decoder; 144 const struct image_decoder *decoder;
145 const struct plugin_api **api; 145 const struct plugin_api **api;
146 unsigned short plugin_api_version;
147 size_t plugin_api_size;
146 const struct imgdec_api **img_api; 148 const struct imgdec_api **img_api;
149 size_t img_api_size;
147}; 150};
148 151
149#ifdef IMGDEC 152#ifdef IMGDEC
@@ -157,15 +160,18 @@ extern const struct image_decoder image_decoder;
157 const struct imgdec_header __header \ 160 const struct imgdec_header __header \
158 __attribute__ ((section (".header")))= { \ 161 __attribute__ ((section (".header")))= { \
159 { PLUGIN_MAGIC, TARGET_ID, IMGDEC_API_VERSION, \ 162 { PLUGIN_MAGIC, TARGET_ID, IMGDEC_API_VERSION, \
160 plugin_start_addr, plugin_end_addr }, &image_decoder, &rb, &iv }; 163 plugin_start_addr, plugin_end_addr, }, &image_decoder, \
164 &rb, PLUGIN_API_VERSION, sizeof(struct plugin_api), \
165 &iv, sizeof(struct imgdec_api) };
161#else /* PLATFORM_HOSTED */ 166#else /* PLATFORM_HOSTED */
162#define IMGDEC_HEADER \ 167#define IMGDEC_HEADER \
163 const struct plugin_api *rb DATA_ATTR; \ 168 const struct plugin_api *rb DATA_ATTR; \
164 const struct imgdec_api *iv DATA_ATTR; \ 169 const struct imgdec_api *iv DATA_ATTR; \
165 const struct imgdec_header __header \ 170 const struct imgdec_header __header \
166 __attribute__((visibility("default"))) = { \ 171 __attribute__((visibility("default"))) = { \
167 { PLUGIN_MAGIC, TARGET_ID, IMGDEC_API_VERSION, \ 172 { PLUGIN_MAGIC, TARGET_ID, IMGDEC_API_VERSION, NULL, NULL }, \
168 NULL, NULL }, &image_decoder, &rb, &iv }; 173 &image_decoder, &rb, PLUGIN_API_VERSION, sizeof(struct plugin_api), \
174 &iv, sizeof(struct imgdec_api), };
169#endif /* CONFIG_PLATFORM */ 175#endif /* CONFIG_PLATFORM */
170#endif 176#endif
171 177
diff --git a/apps/plugins/lib/overlay.c b/apps/plugins/lib/overlay.c
index 0ecc1bf3e7..065273534e 100644
--- a/apps/plugins/lib/overlay.c
+++ b/apps/plugins/lib/overlay.c
@@ -83,9 +83,8 @@ enum plugin_status run_overlay(const void* parameter,
83 goto error_close; 83 goto error_close;
84 } 84 }
85 85
86 86 if (hdr->api_version != PLUGIN_API_VERSION ||
87 if (hdr->api_version > PLUGIN_API_VERSION 87 p_hdr->api_size > sizeof(struct plugin_api))
88 || hdr->api_version < PLUGIN_MIN_API_VERSION)
89 { 88 {
90 rb->splashf(2*HZ, "%s overlay: Incompatible version.", name); 89 rb->splashf(2*HZ, "%s overlay: Incompatible version.", name);
91 goto error_close; 90 goto error_close;