[02/20] libcpu-rt-c/x86: Add cacheinfo
Commit Message
Add cacheinfo to libcpu-rt-c, excluding __cache_sysconf. Don't drag
in <assert.h> in libcpu-rt-c. We want to keep libcpu-rt-c as lean as
possible and still have access to CPU cache information.
* sysdeps/x86/Makefile (libcpu-rt-c-sysdep_routines): Add
cacheinfo.
* sysdeps/x86/cacheinfo.c: Include <assert.h> only for libc.
(assert): [IS_IN (libcpu_rt_c)]: New function.
(__cache_sysconf): Make it libc only.
---
sysdeps/x86/Makefile | 4 ++++
sysdeps/x86/cacheinfo.c | 19 +++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
@@ -1,3 +1,7 @@
+ifeq ($(subdir),cpu-rt-c)
+libcpu-rt-c-sysdep_routines += cacheinfo
+endif
+
ifeq ($(subdir),csu)
gen-as-const-headers += cpu-features-offsets.sym
endif
@@ -16,9 +16,22 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
+#if IS_IN (libc) || IS_IN (libcpu_rt_c)
-#include <assert.h>
+#if IS_IN (libcpu_rt_c)
+# include <abort-instr.h>
+
+__attribute__ ((__noreturn__))
+static inline void
+assert (int expr __attribute__ ((unused)))
+{
+ /* This shouldn't happen in the CPU run-time library. */
+ ABORT_INSTRUCTION;
+ __builtin_unreachable ();
+}
+#else
+# include <assert.h>
+#endif
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
@@ -436,6 +449,7 @@ handle_amd (int name)
}
+# if IS_IN (libc)
/* Get the value of the system variable NAME. */
long int
attribute_hidden
@@ -454,6 +468,7 @@ __cache_sysconf (int name)
/* CPU not known, we have no information. */
return 0;
}
+# endif
/* Data cache size for use in memory and string routines, typically