diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-14 12:19:48 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-21 16:23:54 -0400 |
commit | d40a598970b04bfe3a867a5e12debc45c149b46b (patch) | |
tree | 26e974f910f7d3047adfbc536d8e10c2d973b7e9 /apps/plugins/imageviewer | |
parent | 2fb2364686e5470437f0ee3d214662d51067eb90 (diff) | |
download | rockbox-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/imageviewer')
-rw-r--r-- | apps/plugins/imageviewer/image_decoder.c | 5 | ||||
-rw-r--r-- | apps/plugins/imageviewer/imageviewer.h | 14 |
2 files changed, 14 insertions, 5 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 */ |
142 | struct imgdec_header { | 142 | struct 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 | ||