1 /* Check use of sysconf() for cache geometries.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* Test use of sysconf() to get cache sizes, cache set associativity
20 and cache line sizes. */
27 #include <support/test-driver.h>
29 #define call_str(f, name) f(name, #name)
32 do_sysconf (int name
, const char * str
)
39 if (errno
!= EINVAL
) {
40 printf("error: sysconf(%s): unexpected errno(%d)\n", str
, errno
);
43 printf ("info: sysconf(%s): unsupported\n", str
);
46 printf ("sysconf(%s) = 0x%lx (%ld)\n", str
, val
, val
);
55 rc
+= call_str (do_sysconf
, _SC_LEVEL1_ICACHE_SIZE
);
56 rc
+= call_str (do_sysconf
, _SC_LEVEL1_ICACHE_ASSOC
);
57 rc
+= call_str (do_sysconf
, _SC_LEVEL1_ICACHE_LINESIZE
);
58 rc
+= call_str (do_sysconf
, _SC_LEVEL1_DCACHE_SIZE
);
59 rc
+= call_str (do_sysconf
, _SC_LEVEL1_DCACHE_ASSOC
);
60 rc
+= call_str (do_sysconf
, _SC_LEVEL1_DCACHE_LINESIZE
);
61 rc
+= call_str (do_sysconf
, _SC_LEVEL2_CACHE_SIZE
);
62 rc
+= call_str (do_sysconf
, _SC_LEVEL2_CACHE_ASSOC
);
63 rc
+= call_str (do_sysconf
, _SC_LEVEL2_CACHE_LINESIZE
);
64 rc
+= call_str (do_sysconf
, _SC_LEVEL3_CACHE_SIZE
);
65 rc
+= call_str (do_sysconf
, _SC_LEVEL3_CACHE_ASSOC
);
66 rc
+= call_str (do_sysconf
, _SC_LEVEL3_CACHE_LINESIZE
);
69 return EXIT_UNSUPPORTED
;
73 #include <support/test-driver.c>