From patchwork Thu Sep 25 20:41:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 3071 Received: (qmail 2735 invoked by alias); 2 Oct 2014 15:59:19 -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 2693 invoked by uid 89); 2 Oct 2014 15:59:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_00, DATE_IN_PAST_96_XX, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: USMAMAIL.TILERA.COM Message-ID: <201410021559.s92FxF3Q020866@farm-0002.internal.tilera.com> From: Chris Metcalf Date: Thu, 25 Sep 2014 16:41:55 -0400 To: Subject: [PATCH] tile: add support for _SC_LEVEL*CACHE* sysconf() queries MIME-Version: 1.0 --- sysdeps/unix/sysv/linux/tile/sysconf.c | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/tile/sysconf.c 2014-10-02 Chris Metcalf * sysdeps/unix/sysv/linux/tile/sysconf.c: New file. diff --git a/sysdeps/unix/sysv/linux/tile/sysconf.c b/sysdeps/unix/sysv/linux/tile/sysconf.c new file mode 100644 index 000000000000..06de6ee6602d --- /dev/null +++ b/sysdeps/unix/sysv/linux/tile/sysconf.c @@ -0,0 +1,75 @@ +/* Copyright (C) 2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +static long int linux_sysconf (int name); + +/* Get the value of the system variable NAME. */ +long int +__sysconf (int name) +{ + /* Currently we support only tilepro and tilegx, which have + statically-known cache sizes. */ + switch (name) + { + /* Level 1 cache. */ + case _SC_LEVEL1_ICACHE_SIZE: + return CHIP_L1I_CACHE_SIZE(); + case _SC_LEVEL1_ICACHE_ASSOC: + return CHIP_L1I_ASSOC(); + case _SC_LEVEL1_ICACHE_LINESIZE: + return CHIP_L1I_LINE_SIZE(); + case _SC_LEVEL1_DCACHE_SIZE: + return CHIP_L1D_CACHE_SIZE(); + case _SC_LEVEL1_DCACHE_ASSOC: + return CHIP_L1D_ASSOC(); + case _SC_LEVEL1_DCACHE_LINESIZE: + return CHIP_L1D_LINE_SIZE(); + + /* Level 2 cache. */ + case _SC_LEVEL2_CACHE_SIZE: + return CHIP_L2_CACHE_SIZE(); + case _SC_LEVEL2_CACHE_ASSOC: + return CHIP_L2_ASSOC(); + case _SC_LEVEL2_CACHE_LINESIZE: + return CHIP_L2_LINE_SIZE(); + + /* Level 3 cache is layered on level 2 cache. */ + case _SC_LEVEL3_CACHE_SIZE: + return CHIP_L2_CACHE_SIZE() * __get_nprocs(); + case _SC_LEVEL3_CACHE_ASSOC: + return CHIP_L2_ASSOC(); + case _SC_LEVEL3_CACHE_LINESIZE: + return CHIP_L2_LINE_SIZE(); + + /* No level 4 cache. */ + case _SC_LEVEL4_CACHE_SIZE: + case _SC_LEVEL4_CACHE_ASSOC: + case _SC_LEVEL4_CACHE_LINESIZE: + return -1; + } + + return linux_sysconf (name); +} + +/* Now the generic Linux version. */ +#undef __sysconf +#define __sysconf static linux_sysconf +#include