From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14942 invoked by alias); 17 May 2019 22:10:29 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 14853 invoked by uid 89); 17 May 2019 22:10:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=presently, HX-Languages-Length:2725 X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 May 2019 22:10:25 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4HM8hL8058379 for ; Fri, 17 May 2019 22:10:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=k9Nr3LgXoToCyqX2bIOZLRXHCrwVvqfELAH94aIeepY=; b=eDvyQB1Rqt498yxpKfIedl83POGsI21ZJa5OGtoaVlS1s9+AA4IvoRcqTSndgyjQn/Hq zvKb9U8wuS1AWGBHC27nNJsnlDUhkZ7XhF/gpFEgrGkcytHJOz1YPPZxTj1lba2NOwZ0 IJPlcdwcYL1MrIgwknywXk7sZGEni4iD6G0L/n+IBWzrJ5zLwxf3cBsVsin0I+vbP5Cn Nj9eXNlJ+65WsS2KT3Ia76W99lbAPg2g4zKentSaf8pZZi8mjkPt/DKOox3DADa7ilrE 9+u9n6WhKMIYk5KaOLmrBUyrW1aw0E/BohfzOKV858jEtrdtp86D73/g0t50rRPUVFeN FA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2sdq1r477y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 17 May 2019 22:10:23 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4HM9QTP031741 for ; Fri, 17 May 2019 22:10:23 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2sggeuhfrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 17 May 2019 22:10:22 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4HMAMTR015116 for ; Fri, 17 May 2019 22:10:22 GMT Received: from loom.srvr.nix (/81.187.191.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 17 May 2019 15:10:21 -0700 From: Nick Alcock To: binutils@sourceware.org Subject: [PATCH v2 14/19] libctf: library version enforcement Date: Fri, 17 May 2019 22:10:00 -0000 Message-Id: <20190517221002.408822-15-nick.alcock@oracle.com> In-Reply-To: <20190517221002.408822-1-nick.alcock@oracle.com> References: <20190517221002.408822-1-nick.alcock@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-05/txt/msg00216.txt.bz2 This old Solaris standard allows callers to specify that they are expecting one particular API and/or CTF file format from the library. It is basically vestigial and I would be amenable to dropping it. Changes from v1: - Correct erroneous license (GPLv2+ -> v3+) and reset copyright years. - Adjust to ctf_free() prototype changes - Migrate into ctf-subr.c, since ctf-lib.c is gone 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. --- include/ctf-api.h | 1 + libctf/ctf-impl.h | 1 + libctf/ctf-subr.c | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/include/ctf-api.h b/include/ctf-api.h index 049062ea80..81f790dafd 100644 --- a/include/ctf-api.h +++ b/include/ctf-api.h @@ -239,6 +239,7 @@ extern void *ctf_getspecific (ctf_file_t *); extern int ctf_errno (ctf_file_t *); extern const char *ctf_errmsg (int); +extern int ctf_version (int); extern int ctf_func_info (ctf_file_t *, unsigned long, ctf_funcinfo_t *); extern int ctf_func_args (ctf_file_t *, unsigned long, uint32_t, ctf_id_t *); diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h index 91c46d5d5a..a067e0f4d0 100644 --- a/libctf/ctf-impl.h +++ b/libctf/ctf-impl.h @@ -364,6 +364,7 @@ extern const char *ctf_lookup_symbol_name (ctf_file_t *fp, unsigned long symidx) extern const char _CTF_SECTION[]; /* name of CTF ELF section */ extern const char _CTF_NULLSTR[]; /* empty string */ +extern int _libctf_version; /* library client version */ extern int _libctf_debug; /* debugging messages enabled */ #ifdef __cplusplus diff --git a/libctf/ctf-subr.c b/libctf/ctf-subr.c index 3103e28a3f..09ec2951e5 100644 --- a/libctf/ctf-subr.c +++ b/libctf/ctf-subr.c @@ -27,6 +27,7 @@ #include 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) { -- 2.21.0.237.gd0cfaa883d