]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Detect L1 cache line size at build time. Fall back to 64 bytes if detection failed.
authorVictor Julien <victor@inliniac.net>
Tue, 7 May 2013 12:41:36 +0000 (14:41 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 7 May 2013 12:41:36 +0000 (14:41 +0200)
configure.ac
src/suricata-common.h
src/suricata.c

index 1d861d9f36ee938f06aa19f1514aeaf15b8d128e..843ab977251236e37ff9246af558fccfc68aa7d9 100644 (file)
@@ -1482,6 +1482,12 @@ AC_INIT(configure.ac)
         fi
     fi
 
+# get cache line size
+    AC_PATH_PROG(HAVE_GETCONF_CMD, getconf, "no")
+    if test "$HAVE_GETCONF_CMD" != "no"; then
+        CLS=$(getconf LEVEL1_DCACHE_LINESIZE)
+        AC_DEFINE_UNQUOTED([CLS],[${CLS}],[L1 cache line size])
+    fi
 
 # get revision
     if test -f ./revision; then
index 04543e15397707ffc88c1f2fefdd42bdd6c66490..c3f116854a47ea73022dfe9268675b2ecfc7d01d 100644 (file)
 #include <config.h>
 #endif
 
+#ifndef CLS
+#warning "L1 cache line size not detected during build. Assuming 64 bytes."
+#define CLS 64
+#endif
+
 #if HAVE_STDIO_H
 #include <stdio.h>
 #endif
index 1bd5151fb709aa29a218fe1856e4147707274de5..a5a91b81d86f8e62c2476294e66730b3176f017a 100644 (file)
@@ -696,6 +696,9 @@ void SCPrintBuildInfo(void) {
 #ifdef _FORTIFY_SOURCE
     printf("compiled with _FORTIFY_SOURCE=%d\n", _FORTIFY_SOURCE);
 #endif
+#ifdef CLS
+    printf("L1 cache line size (CLS)=%d\n", CLS);
+#endif
 
     printf("compiled with libhtp %s, linked against %s\n", HTP_BASE_VERSION_TEXT, htp_get_version());