about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2021-12-23 22:27:03 +0000
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2022-01-05 11:03:22 +0000
commit011dcc6569b4cfb40b79033d048695d533e514fb (patch)
tree7e549d9191af3bf751b505bf4ef2ebd5bfba3d33
parent04646910ca0fc5a4b08d9a6cdc3cd8c8ae5419ee (diff)
downloadklee-011dcc6569b4cfb40b79033d048695d533e514fb.tar.gz
Do not use stat64 directly in gen-random-bout
-rw-r--r--tools/gen-random-bout/gen-random-bout.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/tools/gen-random-bout/gen-random-bout.cpp b/tools/gen-random-bout/gen-random-bout.cpp
index dfa121d2..5fb4fe27 100644
--- a/tools/gen-random-bout/gen-random-bout.cpp
+++ b/tools/gen-random-bout/gen-random-bout.cpp
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define _FILE_OFFSET_BITS 64
+
 #include <assert.h>
 #include <fcntl.h>
 #include <limits.h>
@@ -21,10 +23,6 @@
 
 #include "klee/ADT/KTest.h"
 
-#if defined(__FreeBSD__) || defined(__minix)
-#define stat64 stat
-#define fstat64 fstat
-#endif
 
 #define SMALL_BUFFER_SIZE 64 // To hold "arg<N>" string, temporary
                              // filename, etc.
@@ -95,7 +93,7 @@ static void push_range(KTest *b, const char *name, unsigned value) {
   push_obj(b, name, 4, (unsigned char *)&value);
 }
 
-void create_stat(size_t size, struct stat64 *s) {
+void create_stat(size_t size, struct stat *s) {
   char filename_template[] = "/tmp/klee-gen-random-bout-XXXXXX";
   char *filename;
   int fd;
@@ -120,7 +118,7 @@ void create_stat(size_t size, struct stat64 *s) {
     error_exit("%s:%d: Error writing %s\n", __FILE__, __LINE__, filename);
   }
 
-  fstat64(fd, s);
+  fstat(fd, s);
 
   close(fd);
 
@@ -242,7 +240,7 @@ int main(int argc, char *argv[]) {
     char filename[] = "A-data";
     char file_stat[] = "A-data-stat";
     unsigned nbytes;
-    struct stat64 s;
+    struct stat s;
 
     if (i >= MAX_FILE_SIZES) {
       fprintf(stderr, "%s:%d: Maximum number of file sizes exceeded (%d)\n",
@@ -257,26 +255,26 @@ int main(int argc, char *argv[]) {
     create_stat(nbytes, &s);
 
     push_random_obj(&b, filename, nbytes, nbytes);
-    push_obj(&b, file_stat, sizeof(struct stat64), (unsigned char *)&s);
+    push_obj(&b, file_stat, sizeof(struct stat), (unsigned char *)&s);
   }
 
   if (stdin_size) {
-    struct stat64 s;
+    struct stat s;
 
     // Using disk file works well with klee-replay.
     create_stat(stdin_size, &s);
 
     push_random_obj(&b, "stdin", stdin_size, stdin_size);
-    push_obj(&b, "stdin-stat", sizeof(struct stat64), (unsigned char *)&s);
+    push_obj(&b, "stdin-stat", sizeof(struct stat), (unsigned char *)&s);
   }
   if (sym_stdout) {
-    struct stat64 s;
+    struct stat s;
 
     // Using disk file works well with klee-replay.
     create_stat(1024, &s);
 
     push_random_obj(&b, "stdout", 1024, 1024);
-    push_obj(&b, "stdout-stat", sizeof(struct stat64), (unsigned char *)&s);
+    push_obj(&b, "stdout-stat", sizeof(struct stat), (unsigned char *)&s);
   }
   push_range(&b, "model_version", 1);