Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / tile / sysconf.c
blob6aaef6307b112991dd839966d973eba237a5d29c
1 /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <unistd.h>
19 #include <sys/sysinfo.h>
20 #include <arch/chip.h>
22 static long int linux_sysconf (int name);
24 /* Get the value of the system variable NAME. */
25 long int
26 __sysconf (int name)
28 /* Currently we support only tilepro and tilegx, which have
29 statically-known cache sizes. */
30 switch (name)
32 /* Level 1 cache. */
33 case _SC_LEVEL1_ICACHE_SIZE:
34 return CHIP_L1I_CACHE_SIZE();
35 case _SC_LEVEL1_ICACHE_ASSOC:
36 return CHIP_L1I_ASSOC();
37 case _SC_LEVEL1_ICACHE_LINESIZE:
38 return CHIP_L1I_LINE_SIZE();
39 case _SC_LEVEL1_DCACHE_SIZE:
40 return CHIP_L1D_CACHE_SIZE();
41 case _SC_LEVEL1_DCACHE_ASSOC:
42 return CHIP_L1D_ASSOC();
43 case _SC_LEVEL1_DCACHE_LINESIZE:
44 return CHIP_L1D_LINE_SIZE();
46 /* Level 2 cache. */
47 case _SC_LEVEL2_CACHE_SIZE:
48 return CHIP_L2_CACHE_SIZE();
49 case _SC_LEVEL2_CACHE_ASSOC:
50 return CHIP_L2_ASSOC();
51 case _SC_LEVEL2_CACHE_LINESIZE:
52 return CHIP_L2_LINE_SIZE();
54 /* Level 3 cache is layered on level 2 cache. */
55 case _SC_LEVEL3_CACHE_SIZE:
56 return CHIP_L2_CACHE_SIZE() * __get_nprocs();
57 case _SC_LEVEL3_CACHE_ASSOC:
58 return CHIP_L2_ASSOC();
59 case _SC_LEVEL3_CACHE_LINESIZE:
60 return CHIP_L2_LINE_SIZE();
62 /* No level 4 cache. */
63 case _SC_LEVEL4_CACHE_SIZE:
64 case _SC_LEVEL4_CACHE_ASSOC:
65 case _SC_LEVEL4_CACHE_LINESIZE:
66 return -1;
69 return linux_sysconf (name);
72 /* Now the generic Linux version. */
73 #undef __sysconf
74 #define __sysconf static linux_sysconf
75 #include <sysdeps/unix/sysv/linux/sysconf.c>