From patchwork Tue Jun 12 22:19:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 27759 Received: (qmail 91362 invoked by alias); 12 Jun 2018 22:19:47 -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 91241 invoked by uid 89); 12 Jun 2018 22:19:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=lean, UD:sym X-HELO: mga01.intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH 02/20] libcpu-rt-c/x86: Add cacheinfo Date: Tue, 12 Jun 2018 15:19:21 -0700 Message-Id: <20180612221939.19545-3-hjl.tools@gmail.com> In-Reply-To: <20180612221939.19545-1-hjl.tools@gmail.com> References: <20180612221939.19545-1-hjl.tools@gmail.com> Add cacheinfo to libcpu-rt-c, excluding __cache_sysconf. Don't drag in in libcpu-rt-c. We want to keep libcpu-rt-c as lean as possible and still have access to CPU cache information. * sysdeps/x86/Makefile (libcpu-rt-c-sysdep_routines): Add cacheinfo. * sysdeps/x86/cacheinfo.c: Include only for libc. (assert): [IS_IN (libcpu_rt_c)]: New function. (__cache_sysconf): Make it libc only. --- sysdeps/x86/Makefile | 4 ++++ sysdeps/x86/cacheinfo.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index d25d6f0ae4..63ddaf03da 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -1,3 +1,7 @@ +ifeq ($(subdir),cpu-rt-c) +libcpu-rt-c-sysdep_routines += cacheinfo +endif + ifeq ($(subdir),csu) gen-as-const-headers += cpu-features-offsets.sym endif diff --git a/sysdeps/x86/cacheinfo.c b/sysdeps/x86/cacheinfo.c index b9444ddd52..b23d2791b4 100644 --- a/sysdeps/x86/cacheinfo.c +++ b/sysdeps/x86/cacheinfo.c @@ -16,9 +16,22 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) +#if IS_IN (libc) || IS_IN (libcpu_rt_c) -#include +#if IS_IN (libcpu_rt_c) +# include + +__attribute__ ((__noreturn__)) +static inline void +assert (int expr __attribute__ ((unused))) +{ + /* This shouldn't happen in the CPU run-time library. */ + ABORT_INSTRUCTION; + __builtin_unreachable (); +} +#else +# include +#endif #include #include #include @@ -436,6 +449,7 @@ handle_amd (int name) } +# if IS_IN (libc) /* Get the value of the system variable NAME. */ long int attribute_hidden @@ -454,6 +468,7 @@ __cache_sysconf (int name) /* CPU not known, we have no information. */ return 0; } +# endif /* Data cache size for use in memory and string routines, typically