summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2014-12-05 18:11:53 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-12-05 18:11:53 +0000
commit2421406711e0b2e214234add79c842bbb2c07ca1 (patch)
tree6526f4bb3eee3255e41ce12f9e3b0849a3732768 /libc
parent9e08a7bbb85179da9ef56ee4bdc87078bfe5c30d (diff)
parent1f40be97b16ff895a50f48ae8dd1745f57688b6b (diff)
downloadbionic-2421406711e0b2e214234add79c842bbb2c07ca1.zip
bionic-2421406711e0b2e214234add79c842bbb2c07ca1.tar.gz
bionic-2421406711e0b2e214234add79c842bbb2c07ca1.tar.bz2
Merge "Add cache related sysconf queries"
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/sysconf.cpp18
-rw-r--r--libc/include/sys/sysconf.h16
2 files changed, 34 insertions, 0 deletions
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index 67f48e7..4180721 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -178,6 +178,24 @@ long sysconf(int name) {
case _SC_XOPEN_STREAMS: return -1; // Obsolescent in POSIX.1-2008.
case _SC_XOPEN_UUCP: return -1;
+ // We do not have actual implementations for cache queries.
+ // It's valid to return 0 as the result is unknown.
+ case _SC_LEVEL1_ICACHE_SIZE: return 0;
+ case _SC_LEVEL1_ICACHE_ASSOC: return 0;
+ case _SC_LEVEL1_ICACHE_LINESIZE: return 0;
+ case _SC_LEVEL1_DCACHE_SIZE: return 0;
+ case _SC_LEVEL1_DCACHE_ASSOC: return 0;
+ case _SC_LEVEL1_DCACHE_LINESIZE: return 0;
+ case _SC_LEVEL2_CACHE_SIZE: return 0;
+ case _SC_LEVEL2_CACHE_ASSOC: return 0;
+ case _SC_LEVEL2_CACHE_LINESIZE: return 0;
+ case _SC_LEVEL3_CACHE_SIZE: return 0;
+ case _SC_LEVEL3_CACHE_ASSOC: return 0;
+ case _SC_LEVEL3_CACHE_LINESIZE: return 0;
+ case _SC_LEVEL4_CACHE_SIZE: return 0;
+ case _SC_LEVEL4_CACHE_ASSOC: return 0;
+ case _SC_LEVEL4_CACHE_LINESIZE: return 0;
+
default:
// Posix says EINVAL is the only error that shall be returned,
// but glibc uses ENOSYS.
diff --git a/libc/include/sys/sysconf.h b/libc/include/sys/sysconf.h
index 8aa506e..ca32132 100644
--- a/libc/include/sys/sysconf.h
+++ b/libc/include/sys/sysconf.h
@@ -172,6 +172,22 @@ __BEGIN_DECLS
#define _SC_XOPEN_STREAMS 0x008d
#define _SC_XOPEN_UUCP 0x008e
+#define _SC_LEVEL1_ICACHE_SIZE 0x008f
+#define _SC_LEVEL1_ICACHE_ASSOC 0x0090
+#define _SC_LEVEL1_ICACHE_LINESIZE 0x0091
+#define _SC_LEVEL1_DCACHE_SIZE 0x0092
+#define _SC_LEVEL1_DCACHE_ASSOC 0x0093
+#define _SC_LEVEL1_DCACHE_LINESIZE 0x0094
+#define _SC_LEVEL2_CACHE_SIZE 0x0095
+#define _SC_LEVEL2_CACHE_ASSOC 0x0096
+#define _SC_LEVEL2_CACHE_LINESIZE 0x0097
+#define _SC_LEVEL3_CACHE_SIZE 0x0098
+#define _SC_LEVEL3_CACHE_ASSOC 0x0099
+#define _SC_LEVEL3_CACHE_LINESIZE 0x009a
+#define _SC_LEVEL4_CACHE_SIZE 0x009b
+#define _SC_LEVEL4_CACHE_ASSOC 0x009c
+#define _SC_LEVEL4_CACHE_LINESIZE 0x009d
+
long sysconf(int);
__END_DECLS