From: Victor Julien Date: Tue, 7 May 2013 12:41:36 +0000 (+0200) Subject: Detect L1 cache line size at build time. Fall back to 64 bytes if detection failed. X-Git-Tag: suricata-2.0beta1~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=724ad9e8e74a72543110f1a9414f10281a08d711;p=thirdparty%2Fsuricata.git Detect L1 cache line size at build time. Fall back to 64 bytes if detection failed. --- diff --git a/configure.ac b/configure.ac index 1d861d9f36..843ab97725 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/suricata-common.h b/src/suricata-common.h index 04543e1539..c3f116854a 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -40,6 +40,11 @@ #include #endif +#ifndef CLS +#warning "L1 cache line size not detected during build. Assuming 64 bytes." +#define CLS 64 +#endif + #if HAVE_STDIO_H #include #endif diff --git a/src/suricata.c b/src/suricata.c index 1bd5151fb7..a5a91b81d8 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -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());