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: 928509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-93107-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="xT6MKzMn"; dkim-atps=neutral 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 41547v0G28z9s0W for ; Wed, 13 Jun 2018 08:20:10 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=QGRJmCKea9b0W1fWsuZCVu12snk5rQL 7Uie/9962Rq3DYWeZ7d5qj3i8SHNsiuYWsERTGn+oNXKVyZMN2/PzNBWQ52XPyea kbko5BUvdwPc4/owo3VdxFl2Xvq934lnmrAAOXVJlWwWJteNiZ88esl0G8JSeAn/ cv5ICw42iYmw= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=2ryi7pKgVFF+/JrrmjBK/1UScgo=; b=xT6MK zMnYw8Nmeeutwi9GP9v3YA4o8CV4dYOADRjueXbN8lmy3WqN+gesSgk3XiN+4Tla dV2gu3d8/ZWTsNWx/9JbaAxA31Fdf9ZPma61S1zJ+GZZ5j/rUn9jcZYmladDls4b 0ezb4jXenM6Iaq0IVx6YgDwPB3BcEp0gkovH5A= 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