Skip to content

Commit

Permalink
Another attempt to fix the __st_ino build issue (for #983)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Sep 17, 2024
1 parent 55e08ab commit 54c806c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
13 changes: 5 additions & 8 deletions src/libtools/myalign64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions tests/test_st_ino.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#define _LARGEFILE_SOURCE 1
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <stddef.h>
int main(int argc, char** argv)
{
struct stat64 st;
st.__st_ino = 0;
return 0;
}

0 comments on commit 54c806c

Please sign in to comment.