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/requester/instance-id.c b/src/requester/instance-id.c
index 82e3ed1..10d5988 100644
--- a/src/requester/instance-id.c
+++ b/src/requester/instance-id.c
@@ -1,5 +1,6 @@
 // NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
 #define _GNU_SOURCE
+#include "config.h"
 #include "libpldm/instance-id.h"
 #include "libpldm/pldm.h"
 #include <errno.h>
@@ -30,6 +31,7 @@
 	return (cur + 1) % PLDM_INST_ID_MAX;
 }
 
+LIBPLDM_ABI_STABLE
 int pldm_instance_db_init(struct pldm_instance_db **ctx, const char *dbpath)
 {
 	struct pldm_instance_db *l_ctx;
@@ -78,12 +80,14 @@
 	return 0;
 }
 
+LIBPLDM_ABI_STABLE
 int pldm_instance_db_init_default(struct pldm_instance_db **ctx)
 {
 	return pldm_instance_db_init(ctx,
 				     "/usr/share/libpldm/instance-db/default");
 }
 
+LIBPLDM_ABI_STABLE
 int pldm_instance_db_destroy(struct pldm_instance_db *ctx)
 {
 	if (!ctx) {
@@ -94,6 +98,7 @@
 	return 0;
 }
 
+LIBPLDM_ABI_STABLE
 int pldm_instance_id_alloc(struct pldm_instance_db *ctx, pldm_tid_t tid,
 			   pldm_instance_id_t *iid)
 {
@@ -182,6 +187,7 @@
 	return -EAGAIN;
 }
 
+LIBPLDM_ABI_STABLE
 int pldm_instance_id_free(struct pldm_instance_db *ctx, pldm_tid_t tid,
 			  pldm_instance_id_t iid)
 {
diff --git a/src/requester/pldm.c b/src/requester/pldm.c
index 21e402e..b50dbbf 100644
--- a/src/requester/pldm.c
+++ b/src/requester/pldm.c
@@ -1,3 +1,4 @@
+#include "config.h"
 #include "libpldm/requester/pldm.h"
 #include "base.h"
 #include "libpldm/transport.h"
@@ -25,6 +26,7 @@
  */
 static struct pldm_transport_mctp_demux *open_transport;
 
+LIBPLDM_ABI_STABLE
 pldm_requester_rc_t pldm_open(void)
 {
 	int fd;
@@ -86,6 +88,7 @@
 		return rc;                                                       \
 	} while (0)
 
+LIBPLDM_ABI_STABLE
 pldm_requester_rc_t pldm_recv_any(mctp_eid_t eid, int mctp_fd,
 				  uint8_t **pldm_resp_msg, size_t *resp_msg_len)
 {
@@ -93,6 +96,7 @@
 		    (void **)pldm_resp_msg, resp_msg_len);
 }
 
+LIBPLDM_ABI_STABLE
 pldm_requester_rc_t pldm_recv(mctp_eid_t eid, int mctp_fd,
 			      __attribute__((unused)) uint8_t instance_id,
 			      uint8_t **pldm_resp_msg, size_t *resp_msg_len)
@@ -108,6 +112,7 @@
 	return rc;
 }
 
+LIBPLDM_ABI_STABLE
 pldm_requester_rc_t pldm_send_recv(mctp_eid_t eid, int mctp_fd,
 				   const uint8_t *pldm_req_msg,
 				   size_t req_msg_len, uint8_t **pldm_resp_msg,
@@ -117,6 +122,7 @@
 		    req_msg_len, (void **)pldm_resp_msg, resp_msg_len);
 }
 
+LIBPLDM_ABI_STABLE
 pldm_requester_rc_t pldm_send(mctp_eid_t eid, int mctp_fd,
 			      const uint8_t *pldm_req_msg, size_t req_msg_len)
 {
@@ -126,6 +132,7 @@
 
 /* Adding this here for completeness in the case we can't smoothly
  * transition apps over to the new api */
+LIBPLDM_ABI_STABLE
 void pldm_close(void)
 {
 	if (open_transport) {