From 0781acf196f5c2a1130482e9a7003706b9836de9 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 20 Dec 2024 09:55:49 +0200 Subject: [PATCH 1/2] shell: Add missing sys/time.h include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following build failure: ``` penberg@turing:~/src/penberg/limbo-eval/Mobibench/shell$ make gcc -o mobibench mobibench.c sqlite3.c -lpthread -ldl -DNDEBUG=1 -DHAVE_USLEEP=1 -DSQLITE_HAVE_ISNAN -DSQLITE_THREADSAFE=2 -DSQLITE_TEMP_STORE=3 -DSQLITE_POWERSAFE_OVERWRITE=1 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_DEFAULT_AUTOVACUUM=1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_BACKWARDS -DSQLITE_ENABLE_FTS4 -DSQLITE_OMIT_BUILTIN_TEST -DSQLITE_OMIT_COMPILEOPTION_DIAGS -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_FILE_PERMISSIONS=0666 -DUSE_PREAD64 --static mobibench.c: In function ‘get_current_utime’: mobibench.c:1667:9: error: implicit declaration of function ‘gettimeofday’; did you mean ‘SYS_gettimeofday’? [-Wimplicit-function-declaration] 1667 | gettimeofday(¤t,NULL); | ^~~~~~~~~~~~ | SYS_gettimeofday make: *** [Makefile:40: all] Error 1 ``` --- shell/mobibench.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/mobibench.c b/shell/mobibench.c index 99b2543..1967fe4 100755 --- a/shell/mobibench.c +++ b/shell/mobibench.c @@ -36,6 +36,7 @@ #include #include #include +#include #include From dd72540335e5076b6fd8c10dc7f799fe440bc38c Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 15 Nov 2024 14:06:52 +0200 Subject: [PATCH 2/2] shell: Fix 64-bit stat function usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 64-bit variants of stat functions (stat, lstat, and fstat) are deprecated in modern glibc. The recommended way to use large file support is to specify _FILE_OFFSET_BITS with 64 bits, which makes the stat functions use appropriate types for parameters. This fixes the following build failures: ``` gcc -o mobibench mobibench.c sqlite3.c -lpthread -ldl -DNDEBUG=1 -DHAVE_USLEEP=1 -DSQLITE_HAVE_ISNAN -DSQLITE_THREADSAFE=2 -DSQLITE_TEMP_STORE=3 -DSQLITE_POWERSAFE_OVERWRITE=1 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_DEFAULT_AUTOVACUUM=1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_BACKWARDS -DSQLITE_ENABLE_FTS4 -DSQLITE_OMIT_BUILTIN_TEST -DSQLITE_OMIT_COMPILEOPTION_DIAGS -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_FILE_PERMISSIONS=0666 -DUSE_PREAD64 --static mobibench.c: In function ‘do_script’: mobibench.c:1915:23: error: implicit declaration of function ‘stat64’; did you mean ‘stat’? [-Wimplicit-function-declaration] 1915 | ret = stat64(replay_pathname, &stat_buf); | ^~~~~~ | stat mobibench.c:1926:23: error: implicit declaration of function ‘lstat64’; did you mean ‘lstat’? [-Wimplicit-function-declaration] 1926 | ret = lstat64(replay_pathname, &stat_buf); | ^~~~~~~ | lstat mobibench.c:1938:31: error: implicit declaration of function ‘fstat64’; did you mean ‘fstatat’? [-Wimplicit-function-declaration] 1938 | ret = fstat64(fd_new, &stat_buf); | ^~~~~~~ | fstatat make: *** [Makefile:40: all] Error 1 ``` Note that another option would have been to define _LARGEFILE64_SOURCE, which makes the 64-bit variants visible again. However, that does not build because we pass incompatible types as arguments, so I decided to just do this instead. --- shell/mobibench.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/mobibench.c b/shell/mobibench.c index 1967fe4..bab0df2 100755 --- a/shell/mobibench.c +++ b/shell/mobibench.c @@ -24,6 +24,7 @@ #include #include +#define _FILE_OFFSET_BITS 64 #include #include @@ -1913,9 +1914,9 @@ int do_script(struct script_entry* se, struct script_thread_time* st) replay_pathname[strlen(replay_pathname)-1]='\0'; io_time_start = get_current_utime(); - ret = stat64(replay_pathname, &stat_buf); + ret = stat(replay_pathname, &stat_buf); io_time = get_relative_utime(io_time_start); - SCRIPT_PRINT("stat64 %s --> %d\n", replay_pathname, ret); + SCRIPT_PRINT("stat %s --> %d\n", replay_pathname, ret); } else if( strncmp(se->cmd, "lstat", 5) == 0) { @@ -1924,9 +1925,9 @@ int do_script(struct script_entry* se, struct script_thread_time* st) replay_pathname[strlen(replay_pathname)-1]='\0'; io_time_start = get_current_utime(); - ret = lstat64(replay_pathname, &stat_buf); + ret = lstat(replay_pathname, &stat_buf); io_time = get_relative_utime(io_time_start); - SCRIPT_PRINT("lstat64 %s --> %d\n", replay_pathname, ret); + SCRIPT_PRINT("lstat%s --> %d\n", replay_pathname, ret); } else if( strncmp(se->cmd, "fstat", 5) == 0) { @@ -1936,9 +1937,9 @@ int do_script(struct script_entry* se, struct script_thread_time* st) if(fd_new > 0) { io_time_start = get_current_utime(); - ret = fstat64(fd_new, &stat_buf); + ret = fstat(fd_new, &stat_buf); io_time = get_relative_utime(io_time_start); - SCRIPT_PRINT("fstat64 %d --> %d\n", fd_new, ret); + SCRIPT_PRINT("fstat%d --> %d\n", fd_new, ret); } } else if( strncmp(se->cmd, "unlink", 6) == 0)