m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
AC_CONFIG_SRCDIR([vbig.cc])
AM_CONFIG_HEADER([config.h])
+AC_CANONICAL_HOST
+case "$host" in
+*-*-darwin* )
+ AC_DEFINE([PURGE_COMMAND],["purge"], [Command to purge filesystem cache])
+ ;;
+*-*-linux* )
+ AC_DEFINE([DROP_CACHE_FILE],["/proc/sys/vm/drop_caches"],
+ [Path to filesystem cache purge interface])
+ ;;
+esac
AC_LANG([C++])
AC_PROG_CXX
AC_PROG_RANLIB
#include <fcntl.h>
#include "Arcfour.h"
-// Path to magic file to drop filesystem caches
-static const char dropCaches[] = "/proc/sys/vm/drop_caches";
-
// Command line options
const struct option opts[] = {
{ "seed", required_argument, 0, 's' },
// synced.
if(fsync(fileno(fp)) < 0)
fatal(errno, "fsync");
+#if defined DROP_CACHE_FILE
int fd;
- if((fd = open(dropCaches, O_WRONLY, 0)) < 0)
- fatal(errno, "%s", dropCaches);
+ if((fd = open(DROP_CACHE_FILE, O_WRONLY, 0)) < 0)
+ fatal(errno, "%s", DROP_CACHE_FILE);
if(write(fd, "3\n", 2) < 0)
- fatal(errno, "%s", dropCaches);
+ fatal(errno, "%s", DROP_CACHE_FILE);
close(fd);
+#elif defined PURGE_COMMAND
+ int rc;
+ if((rc = system(PURGE_COMMAND)) < 0)
+ fatal(errno, "executing %s", PURGE_COMMAND);
+ else if(rc) {
+ if(WIFSIGNALED(rc)) {
+ fprintf(stderr, "%s%s\n",
+ strsignal(WTERMSIG(rc)),
+ WCOREDUMP(rc) ? " (core dumped)" : "");
+ exit(WTERMSIG(rc) + 128);
+ } else
+ exit(WEXITSTATUS(rc));
+ }
+#endif
}
int main(int argc, char **argv) {