summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2014-09-25 16:41:55 -0400
committerChris Metcalf <cmetcalf@tilera.com>2014-10-06 11:20:30 -0400
commit4b68ea1162f39f62590e49eb5d4371871e071f32 (patch)
tree88ad9ff87d22daae8265cd825b0d4a029fa96af4
parentc86f7b80f43d7336eab1119dae78b0f10b7244ec (diff)
downloadglibc-4b68ea1162f39f62590e49eb5d4371871e071f32.tar.gz
tile: add support for _SC_LEVEL*CACHE* sysconf() queries
-rw-r--r--ChangeLog2
-rw-r--r--sysdeps/unix/sysv/linux/tile/sysconf.c75
2 files changed, 77 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2474b4d7c9..44a45e209a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2014-10-02 Chris Metcalf <cmetcalf@tilera.com>
+ * sysdeps/unix/sysv/linux/tile/sysconf.c: New file.
+
* sysdeps/tile/tilegx/string-endian.h (STRSHIFT): New macro.
* sysdeps/tile/tilegx/strcasestr.c: New file.
* sysdeps/tile/tilegx/strnlen.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 0000000000..5db983c7f5
--- /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
+ <http://www.gnu.org/licenses/>. */
+
+#include <unistd.h>
+#include <sys/sysinfo.h>
+#include <arch/chip.h>
+
+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 <sysdeps/unix/sysv/linux/sysconf.c>