From d40a598970b04bfe3a867a5e12debc45c149b46b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Tue, 14 Mar 2023 12:19:48 +0000 Subject: 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 --- lib/rbcodec/codecs/codecs.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lib/rbcodec/codecs') diff --git a/lib/rbcodec/codecs/codecs.h b/lib/rbcodec/codecs/codecs.h index fd19dcb6b5..aa9d2e8a0d 100644 --- a/lib/rbcodec/codecs/codecs.h +++ b/lib/rbcodec/codecs/codecs.h @@ -71,13 +71,12 @@ /* magic for encoder codecs */ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ -/* increase this every time the api struct changes */ -#define CODEC_API_VERSION 49 - -/* update this to latest version if a change to the api struct breaks - backwards compatibility (and please take the opportunity to sort in any - new function which are "waiting" at the end of the function table) */ -#define CODEC_MIN_API_VERSION 49 +/* + * Increment this whenever a change breaks the codec ABI, + * when this happens please take the opportunity to sort in + * any new functions "waiting" at the end of the list. + */ +#define CODEC_API_VERSION 50 /* reasons for calling codec main entrypoint */ enum codec_entry_call_reason { @@ -228,6 +227,7 @@ struct codec_header { enum codec_status(*entry_point)(enum codec_entry_call_reason reason); enum codec_status(*run_proc)(void); struct codec_api **api; + size_t api_size; void * rec_extension[]; /* extension for encoders */ }; @@ -241,15 +241,16 @@ extern unsigned char plugin_end_addr[]; const struct codec_header __header \ __attribute__ ((section (".header")))= { \ { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr }, codec_start, \ - codec_run, &ci }; + plugin_start_addr, plugin_end_addr }, \ + codec_start, codec_run, &ci, sizeof(struct codec_api) }; /* encoders */ #define CODEC_ENC_HEADER \ const struct codec_header __header \ __attribute__ ((section (".header")))= { \ { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr }, codec_start, \ - codec_run, &ci, { enc_callback } }; + plugin_start_addr, plugin_end_addr }, \ + codec_start, codec_run, &ci, sizeof(struct codec_api), \ + { enc_callback } }; #else /* def SIMULATOR */ /* decoders */ @@ -257,13 +258,14 @@ extern unsigned char plugin_end_addr[]; const struct codec_header __header \ __attribute__((visibility("default"))) = { \ { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ - codec_start, codec_run, &ci }; + codec_start, codec_run, &ci, sizeof(struct codec_api) }; /* encoders */ #define CODEC_ENC_HEADER \ const struct codec_header __header \ __attribute__((visibility("default"))) = { \ { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ - codec_start, codec_run, &ci, { enc_callback } }; + codec_start, codec_run, &ci, sizeof(struct codec_api), \ + { enc_callback } }; #endif /* SIMULATOR */ #endif /* CODEC */ -- cgit v1.2.3