aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-subr.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-04-24 11:26:42 +0100
committerNick Alcock <nick.alcock@oracle.com>2019-05-28 17:08:29 +0100
commit6c33b742ce19cc2fd226d84f2991572239199a62 (patch)
treeb6ef5f9c4b2aa6d1c4a716a4e279c9d6a7222c1d /libctf/ctf-subr.c
parentc499eb6896cd803d26da8c719bfac9c03e596c08 (diff)
downloadgdb-6c33b742ce19cc2fd226d84f2991572239199a62.zip
gdb-6c33b742ce19cc2fd226d84f2991572239199a62.tar.gz
gdb-6c33b742ce19cc2fd226d84f2991572239199a62.tar.bz2
libctf: library version enforcement
This old Solaris standard allows callers to specify that they are expecting one particular API and/or CTF file format from the library. libctf/ * ctf-impl.h (_libctf_version): New declaration. * ctf-subr.c (_libctf_version): Define it. (ctf_version): New. include/ * ctf-api.h (ctf_version): New.
Diffstat (limited to 'libctf/ctf-subr.c')
-rw-r--r--libctf/ctf-subr.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libctf/ctf-subr.c b/libctf/ctf-subr.c
index 3103e28..09ec295 100644
--- a/libctf/ctf-subr.c
+++ b/libctf/ctf-subr.c
@@ -27,6 +27,7 @@
#include <unistd.h>
static size_t _PAGESIZE _libctf_unused_;
+int _libctf_version = CTF_VERSION; /* Library client version. */
int _libctf_debug = 0; /* Debugging messages enabled. */
_libctf_malloc_ void *
@@ -190,6 +191,32 @@ ctf_strerror (int err)
return (const char *) (strerror (err));
}
+/* Set the CTF library client version to the specified version. If version is
+ zero, we just return the default library version number. */
+int
+ctf_version (int version)
+{
+ if (version < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (version > 0)
+ {
+ /* Dynamic version switching is not presently supported. */
+ if (version != CTF_VERSION)
+ {
+ errno = ENOTSUP;
+ return -1;
+ }
+ ctf_dprintf ("ctf_version: client using version %d\n", version);
+ _libctf_version = version;
+ }
+
+ return _libctf_version;
+}
+
void
libctf_init_debug (void)
{