Another attempt to fix the __st_ino build issue (for #983)

This commit is contained in:
ptitSeb 2024-09-17 15:25:22 +02:00
parent 55e08ab0be
commit 54c806c576
3 changed files with 27 additions and 8 deletions

View File

@ -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")

View File

@ -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;

16
tests/test_st_ino.c Normal file
View File

@ -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;
}