From patchwork Wed Oct 1 09:17:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 395475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 882EF1400E0 for ; Wed, 1 Oct 2014 19:17:33 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=C7J5 f+DztqsMarCzl1E7ZWxNFKWuwIaEWXHT7YGviVWUo1CFTvV1gJ4Z0qoTZ/PcNdp6 EaM4M6tTaoRBVA8lSqpDJ/UsKJI3No2dJ+Sbi5kELffY+VVNlLSI4THqQY5tnWb9 EMo5a9jFxFSfNKv3qP2+CGP6OVByEKP1nGImPZY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=evr4oEbOfZ 0VPkoWSm+buaPztUk=; b=Iyf/y3m4bGImAACb+rx23dIrov4kThy7CV9KTdTFT7 pKoucyVX/M/5IzyBNXsTeFBtPJ7tF8YWqQeGOt1cvfBEv2w2qP8OPFHmiUvIsERM ftuTsRG8X2Z3LL1OW7okGXYgdh5sCv3jCc9h2TWNR8syeNkH3U4/t/YpeNnYbs1V s= Received: (qmail 6422 invoked by alias); 1 Oct 2014 09:17:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 6412 invoked by uid 89); 1 Oct 2014 09:17:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Wed, 1 Oct 2014 14:47:17 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: roland@hack.frob.com Subject: [PATCH 4/4 v1.1] Use conf.list to generate spec array Message-ID: <20141001091717.GL2217@spoyarek.pnq.redhat.com> References: <1411122007-1461-1-git-send-email-siddhesh@redhat.com> <1411122007-1461-5-git-send-email-siddhesh@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1411122007-1461-5-git-send-email-siddhesh@redhat.com> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) This patch also had to be updated due to 1/4 to update the comment in conf.list. Tested on x86_64. Siddhesh commit 218aad6c5df66ad432b9083db7e3f0cb4da686d6 Author: Siddhesh Poyarekar Date: Wed Oct 1 14:36:03 2014 +0530 Use conf.list to generate spec array This patch adds support to generate the spec array in getconf from the conf.list. The generated code is mostly unchanged. the only changes are due to the change in layout of the spec and val arrays in the ELF. The val array can also be auto-generated from conf.list once the remaining macros are added to it. * posix/conf.list (SPEC:XBS5): Add sysconf prefix. * posix/confstr.c: Define NEED_SPEC_ARRAY to 0. * posix/posix-envs.def: Likewise. * sysdeps/posix/sysconf.c: Likewise. * posix/getconf.c: Define NEED_SPEC_ARRAY to 1. (specs): Remove array. * scripts/gen-conf.awk: Support generation of specs array. diff --git a/posix/conf.list b/posix/conf.list index 000b908..0a17666 100644 --- a/posix/conf.list +++ b/posix/conf.list @@ -1,7 +1,8 @@ # Configuration variables identified by getconf. The heading of each section -# is of the format TYPE:PREFIX with the opening curly brace on the same line. -# TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC. Variable names are -# put one on each line with a curly brace on its own line ending the section. +# is of the format TYPE:PREFIX:SC_PREFIX with the opening curly brace on the +# same line. TYPE can either be SYSCONF, PATHCONF, CONFSTR or SPEC. In the +# absence of SC_PREFIX, _SC is used as the SC_PREFIX. Variable names are put +# one on each line with a curly brace on its own line ending the section. SPEC:POSIX { V6_ILP32_OFF32 @@ -103,7 +104,7 @@ SYSCONF:POSIX { RAW_SOCKETS } -SPEC:XBS5 { +SPEC:XBS5:_SC_XBS5 { ILP32_OFF32 ILP32_OFFBIG LP64_OFF64 diff --git a/posix/confstr.c b/posix/confstr.c index 1accfee..0400d7f 100644 --- a/posix/confstr.c +++ b/posix/confstr.c @@ -21,7 +21,9 @@ #include #include #include "../version.h" -#include "confdefs.h" + +#define NEED_SPEC_ARRAY 0 +#include /* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes of BUF with the value corresponding to NAME and zero-terminate BUF. diff --git a/posix/getconf.c b/posix/getconf.c index 14d51d8..3c08688 100644 --- a/posix/getconf.c +++ b/posix/getconf.c @@ -26,6 +26,9 @@ #include "../version.h" #define PACKAGE _libc_intl_domainname +#define NEED_SPEC_ARRAY 1 +#include + struct conf { const char *name; @@ -387,23 +390,6 @@ static const struct conf vars[] = }; -static const struct { const char *name; int num; } specs[] = - { - { "XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32 }, - { "XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG }, - { "XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64 }, - { "XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG }, - { "POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32 }, - { "POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG }, - { "POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64 }, - { "POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG }, - { "POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32 }, - { "POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG }, - { "POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64 }, - { "POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG }, - }; -static const int nspecs = sizeof (specs) / sizeof (specs[0]); - extern const char *__progname; diff --git a/posix/posix-envs.def b/posix/posix-envs.def index 9047d0c..0b33e02 100644 --- a/posix/posix-envs.def +++ b/posix/posix-envs.def @@ -42,7 +42,8 @@ defined. These are called with arguments V5, V6, V7 before and after the relevant groups of environments. */ -#include "confdefs.h" +#define NEED_SPEC_ARRAY 0 +#include START_ENV_GROUP (V7) diff --git a/scripts/gen-conf.awk b/scripts/gen-conf.awk index 45a4d44..1370646 100644 --- a/scripts/gen-conf.awk +++ b/scripts/gen-conf.awk @@ -17,12 +17,17 @@ $2 == "{" { split ($1, arr, ":") type = arr[1] prefix = arr[2] + if (arr[3] != "") + sc_prefix = arr[3] + else + sc_prefix = "_SC" next } $1 == "}" { prefix = "" type = "" + sc_prefix = "" next } @@ -37,6 +42,7 @@ $1 == "}" { # CONFSTR: A configuration string # SYSCONF: A numeric value # SPEC: A specification + sc_prefixes[prefix][$1] = sc_prefix conf[prefix][$1] = type } @@ -58,6 +64,26 @@ ENDFILE { printf "# endif\n" } printf "#endif\n\n" + + # Build a name -> sysconf number associative array to print a C array at + # the end. + if (conf[p][c] == "SPEC") { + name = sprintf ("%s_%s", p, c) + num = sprintf ("%s_%s", sc_prefixes[p][c], c) + spec[name] = num + } } } + + # Print the specification array. Define the macro NEED_SPEC_ARRAY before + # including confdefs.h to make it available in the compilation unit. + print "#if NEED_SPEC_ARRAY" + print "static const struct { const char *name; int num; } specs[] =" + print " {" + for (s in spec) { + printf " { \"%s\", %s },\n", s, spec[s] + } + print " };" + print "static const int nspecs = sizeof (specs) / sizeof (specs[0]);" + print "#endif" } diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c index c7b748b..bff59f4 100644 --- a/sysdeps/posix/sysconf.c +++ b/sysdeps/posix/sysconf.c @@ -31,6 +31,7 @@ #include #include +#define NEED_SPEC_ARRAY 0 #include