libpldm: Explicit deprecated, stable and testing ABI classes

Experimenting with new APIs is important, but ABI stability of the
library is also important. We wish to have the freedom to add APIs
without being burdened by them being immediately set in stone.

We implement this wish by introducing three classes of ABI:

1. deprecated
2. stable
3. testing

These are enforced by corresponding function attributes:

1. LIBPLDM_ABI_DEPRECATED
2. LIBPLDM_ABI_STABLE
3. LIBPLDM_ABI_TESTING

Symbol visibility in the library is flipped to 'hidden' by default, so
one of these annotations must be used for the symbol to be exposed.

With these classes in place there are now clear points in time at which
we update the ABI dumps captured under the abi/ directory: When an API
is migrated from the 'testing' class to the 'stable' class, or when
removed from the 'deprecated' class.

Which classes of functions are exposed by the build is controlled by the
new 'abi' meson option. The option is of array type which contains the
list of ABI classes the build should consider. It defaults to enabling
all classes to provide test coverage in CI. The classes used should be
constrained to deprecated and stable (and not test) in any dependent
projects.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I25402e20c7be9c9f264f9ccd7ac36b384823734c
diff --git a/src/utils.c b/src/utils.c
index 6fe93d1..5547002 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,3 +1,4 @@
+#include "config.h"
 #include "utils.h"
 #include "base.h"
 #include <limits.h>
@@ -83,6 +84,7 @@
 	0xfa, 0xfd, 0xf4, 0xf3
 };
 
+LIBPLDM_ABI_STABLE
 uint32_t crc32(const void *data, size_t size)
 {
 	const uint8_t *p = data;
@@ -93,6 +95,7 @@
 	return crc ^ ~0U;
 }
 
+LIBPLDM_ABI_STABLE
 uint8_t crc8(const void *data, size_t size)
 {
 	const uint8_t *p = data;
@@ -114,6 +117,8 @@
 		}                                                              \
 	}
 #define INSERT_INT(i, b, n) INSERT_CHAR(AS_CHAR(i), (b), (n))
+
+LIBPLDM_ABI_STABLE
 ssize_t ver2str(const ver32_t *version, char *buffer, size_t buffer_size)
 {
 	ssize_t remaining;
@@ -158,37 +163,44 @@
 	return (ssize_t)buffer_size - remaining;
 }
 
+LIBPLDM_ABI_STABLE
 uint8_t bcd2dec8(uint8_t bcd)
 {
 	return (bcd >> 4) * 10 + (bcd & 0x0f);
 }
 
+LIBPLDM_ABI_STABLE
 uint8_t dec2bcd8(uint8_t dec)
 {
 	return ((dec / 10) << 4) + (dec % 10);
 }
 
+LIBPLDM_ABI_STABLE
 uint16_t bcd2dec16(uint16_t bcd)
 {
 	return bcd2dec8(bcd >> 8) * 100 + bcd2dec8(bcd & 0xff);
 }
 
+LIBPLDM_ABI_STABLE
 uint16_t dec2bcd16(uint16_t dec)
 {
 	return dec2bcd8(dec % 100) | ((uint16_t)(dec2bcd8(dec / 100)) << 8);
 }
 
+LIBPLDM_ABI_STABLE
 uint32_t bcd2dec32(uint32_t bcd)
 {
 	return bcd2dec16(bcd >> 16) * 10000 + bcd2dec16(bcd & 0xffff);
 }
 
+LIBPLDM_ABI_STABLE
 uint32_t dec2bcd32(uint32_t dec)
 {
 	return dec2bcd16(dec % 10000) |
 	       ((uint32_t)(dec2bcd16(dec / 10000)) << 16);
 }
 
+LIBPLDM_ABI_STABLE
 bool is_time_legal(uint8_t seconds, uint8_t minutes, uint8_t hours, uint8_t day,
 		   uint8_t month, uint16_t year)
 {
@@ -209,6 +221,7 @@
 	return true;
 }
 
+LIBPLDM_ABI_STABLE
 bool is_transfer_flag_valid(uint8_t transfer_flag)
 {
 	switch (transfer_flag) {