Skip to content

Commit

Permalink
Detect L1 cache line size at build time. Fall back to 64 bytes if det…
Browse files Browse the repository at this point in the history
…ection failed.
  • Loading branch information
victorjulien committed May 7, 2013
1 parent 53fe756 commit 724ad9e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions configure.ac
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/suricata-common.h
Expand Up @@ -40,6 +40,11 @@
#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
Expand Down
3 changes: 3 additions & 0 deletions src/suricata.c
Expand Up @@ -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());

Expand Down

0 comments on commit 724ad9e

Please sign in to comment.