From 54c806c5761b79d749d8b99eea0f79e8308bc4c1 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 17 Sep 2024 15:25:22 +0200 Subject: [PATCH] Another attempt to fix the __st_ino build issue (for #983) --- CMakeLists.txt | 6 ++++++ src/libtools/myalign64.c | 13 +++++-------- tests/test_st_ino.c | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 tests/test_st_ino.c diff --git a/CMakeLists.txt b/CMakeLists.txt index af7f768fb..9dde1fa75 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,6 +243,12 @@ else() set(BOX86 box86) endif() +try_compile(HAVE_ST_INO ${CMAKE_BINARY_DIR}/compile_tests ${CMAKE_SOURCE_DIR}/tests/test_st_ino.c) + +if(HAVE_ST_INO) + message("stat64 has __st_info field") + add_definitions(-DHAVE_ST_INO) +endif() set(BOX86_ELF_ADDRESS "0x62800000") diff --git a/src/libtools/myalign64.c b/src/libtools/myalign64.c index e9eec8b78..ac75c57d2 100755 --- a/src/libtools/myalign64.c +++ b/src/libtools/myalign64.c @@ -23,11 +23,8 @@ void UnalignStat64(const void* source, void* dest) i386st->__pad0 = 0; i386st->__pad3 = 0; i386st->st_dev = st->st_dev; -#ifdef __USE_TIME64_REDIRECTS - i386st->__st_ino = st->st_ino; -#elif defined(POWERPCLE) - i386st->__st_ino = st->st_ino; // Separate __st_ino doesn't - // exist on powerpc +#if defined(__USE_TIME64_REDIRECTS) || defined(POWERPCLE) || !defined(HAVE_ST_INO) + i386st->__st_ino = st->st_ino; #else i386st->__st_ino = st->__st_ino; #endif @@ -39,7 +36,7 @@ void UnalignStat64(const void* source, void* dest) i386st->st_size = st->st_size; i386st->st_blksize = st->st_blksize; i386st->st_blocks = st->st_blocks; -#if defined(__USE_XOPEN2K8) || defined(ANDROID) || defined(PANDORA) || defined(BAD_SIGNAL) +#if defined(__USE_XOPEN2K8) || defined(ANDROID) || defined(PANDORA) i386st->st_atime = st->st_atim.tv_sec; i386st->st_atime_nsec = st->st_atim.tv_nsec; i386st->st_mtime = st->st_mtim.tv_sec; @@ -63,7 +60,7 @@ void AlignStat64(const void* source, void* dest) struct i386_stat64 *i386st = (struct i386_stat64*)source; st->st_dev = i386st->st_dev; -#if defined(__USE_TIME64_REDIRECTS) || defined(POWERPCLE) +#if defined(__USE_TIME64_REDIRECTS) || defined(POWERPCLE)|| !defined(HAVE_ST_INO) // Separate __st_ino doesn't exist #else st->__st_ino = i386st->__st_ino; @@ -76,7 +73,7 @@ void AlignStat64(const void* source, void* dest) st->st_size = i386st->st_size; st->st_blksize = i386st->st_blksize; st->st_blocks = i386st->st_blocks; -#if defined(__USE_XOPEN2K8) || defined(ANDROID) || defined(PANDORA) || defined(BAD_SIGNAL) +#if defined(__USE_XOPEN2K8) || defined(ANDROID) || defined(PANDORA) st->st_atim.tv_sec = i386st->st_atime; st->st_atim.tv_nsec = i386st->st_atime_nsec; st->st_mtim.tv_sec = i386st->st_mtime; diff --git a/tests/test_st_ino.c b/tests/test_st_ino.c new file mode 100644 index 000000000..dd849a3cc --- /dev/null +++ b/tests/test_st_ino.c @@ -0,0 +1,16 @@ +#define _LARGEFILE_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +int main(int argc, char** argv) +{ + struct stat64 st; + st.__st_ino = 0; + return 0; +} \ No newline at end of file