diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-10-06 14:27:19 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-10-06 14:27:19 +0200 |
| commit | ad0c08c2de2dde9e60fd4537f3e4b53c89a468eb (patch) | |
| tree | 87b05e60b1194d9b4752f09f46c2d0181129062d /src/wrapped32 | |
| parent | 7b93791c3f428c119e35480bbba1dcec7a413db4 (diff) | |
| download | box64-ad0c08c2de2dde9e60fd4537f3e4b53c89a468eb.tar.gz box64-ad0c08c2de2dde9e60fd4537f3e4b53c89a468eb.zip | |
[BOX32] Proper alignment for x86 structures
Diffstat (limited to 'src/wrapped32')
| -rw-r--r-- | src/wrapped32/wrappedfontconfig.c | 12 | ||||
| -rw-r--r-- | src/wrapped32/wrappedfreetype.c | 46 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedldlinux.c | 2 | ||||
| -rw-r--r-- | src/wrapped32/wrappedlibasound.c | 2 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc.c | 6 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibdl.c | 4 | ||||
| -rw-r--r-- | src/wrapped32/wrappedsdl1.c | 2 | ||||
| -rw-r--r-- | src/wrapped32/wrappedsdl2.c | 14 |
8 files changed, 48 insertions, 40 deletions
diff --git a/src/wrapped32/wrappedfontconfig.c b/src/wrapped32/wrappedfontconfig.c index 69e5c28d..9533b2e5 100644 --- a/src/wrapped32/wrappedfontconfig.c +++ b/src/wrapped32/wrappedfontconfig.c @@ -81,7 +81,7 @@ typedef struct FcConfig_s { // 32bits structures -typedef struct FcValue_32_s { +typedef struct __attribute__((packed, aligned(4))) FcValue_32_s { int type; union { ptr_t s;//const char * @@ -95,33 +95,33 @@ typedef struct FcValue_32_s { } u; } FcValue_32_t; -typedef struct FcPattern_32_s { +typedef struct __attribute__((packed, aligned(4))) FcPattern_32_s { int num; int size; long_t elts_offset; int ref; } FcPattern_32_t; -typedef struct FcFontSet_32_s { +typedef struct __attribute__((packed, aligned(4))) FcFontSet_32_s { int nfont; int sfont; ptr_t fonts;//FcPattern_t ** } FcFontSet_32_t; -typedef struct FcStrSet_32_s { +typedef struct __attribute__((packed, aligned(4))) FcStrSet_32_s { int ref; int num; int size; ptr_t strs; //void ** } FcStrSet_32_t; -typedef struct FcBlanks_32_s { +typedef struct __attribute__((packed, aligned(4))) FcBlanks_32_s { int nblank; int sblank; ptr_t blanks; //void * } FcBlanks_32_t; -typedef struct FcConfig_32_s { +typedef struct __attribute__((packed, aligned(4))) FcConfig_32_s { ptr_t configDirs; //FcStrSet_t* ptr_t blanks; //FcBlanks_t* ptr_t fontDirs; //FcStrSet_t* diff --git a/src/wrapped32/wrappedfreetype.c b/src/wrapped32/wrappedfreetype.c index a1e61b46..ca71c3f7 100644 --- a/src/wrapped32/wrappedfreetype.c +++ b/src/wrapped32/wrappedfreetype.c @@ -331,13 +331,13 @@ typedef struct FT_Matrix_s // 32bits FreeType structures // =============================================== -typedef union FT_StreamDesc_32_s +typedef union __attribute__((packed, aligned(4))) FT_StreamDesc_32_s { long_t value; ptr_t pointer; //void* } FT_StreamDesc_32_t; -typedef struct FT_StreamRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_StreamRec_32_s { ptr_t base; //unsigned char* ulong_t size; @@ -354,29 +354,29 @@ typedef struct FT_StreamRec_32_s } FT_StreamRec_32_t; -typedef struct FT_BBox_32_s +typedef struct __attribute__((packed, aligned(4))) FT_BBox_32_s { long_t xMin, yMin; long_t xMax, yMax; } FT_BBox_32_t; -typedef struct FT_Generic_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Generic_32_s { ptr_t data; //void* ptr_t finalizer; //vFp_t } FT_Generic_32_t; -typedef struct FT_ListRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_ListRec_32_s { ptr_t head; //void* ptr_t tail; //void* } FT_ListRec_32_t; -typedef struct FT_Vector_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Vector_32_s { long_t x; long_t y; } FT_Vector_32_t; -typedef struct FT_Bitmap_Size_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Bitmap_Size_32_s { short height; short width; @@ -385,7 +385,7 @@ typedef struct FT_Bitmap_Size_32_s long_t y_ppem; } FT_Bitmap_Size_32_t; -typedef struct FT_Glyph_Metrics_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Glyph_Metrics_32_s { long_t width; long_t height; @@ -397,7 +397,7 @@ typedef struct FT_Glyph_Metrics_32_s long_t vertAdvance; } FT_Glyph_Metrics_32_t; -typedef struct FT_Outline_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Outline_32_s { unsigned short n_contours; unsigned short n_points; @@ -407,7 +407,7 @@ typedef struct FT_Outline_32_s int flags; } FT_Outline_32_t; -typedef struct FT_Bitmap_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Bitmap_32_s { unsigned int rows; unsigned int width; @@ -419,7 +419,7 @@ typedef struct FT_Bitmap_32_s ptr_t palette; //void* } FT_Bitmap_32_t; -typedef struct FT_GlyphSlotRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_GlyphSlotRec_32_s { ptr_t library; //FT_Library ptr_t face; //FT_Face @@ -445,7 +445,7 @@ typedef struct FT_GlyphSlotRec_32_s ptr_t internal; } FT_GlyphSlotRec_32_t; -typedef struct FT_CharMapRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_CharMapRec_32_s { ptr_t face; //FT_FaceRec_t* int encoding; @@ -453,7 +453,7 @@ typedef struct FT_CharMapRec_32_s uint16_t encoding_id; } FT_CharMapRec_32_t; -typedef struct FT_Size_Metrics_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Size_Metrics_32_s { uint16_t x_ppem; uint16_t y_ppem; @@ -465,7 +465,7 @@ typedef struct FT_Size_Metrics_32_s long_t max_advance; } FT_Size_Metrics_32_t; -typedef struct FT_SizeRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_SizeRec_32_s { ptr_t face; //FT_FaceRec_t* FT_Generic_32_t generic; @@ -473,7 +473,7 @@ typedef struct FT_SizeRec_32_s ptr_t internal; //FT_Size_Internal } FT_SizeRec_32_t; -typedef struct FT_FaceRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_FaceRec_32_s { long_t num_faces; long_t face_index; @@ -509,7 +509,7 @@ typedef struct FT_FaceRec_32_s ptr_t internal; //void* } FT_FaceRec_32_t; -typedef struct FT_MemoryRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_MemoryRec_32_s { ptr_t user; //void* ptr_t alloc; //void* @@ -517,7 +517,7 @@ typedef struct FT_MemoryRec_32_s ptr_t realloc;//void* } FT_MemoryRec_32_t; -typedef struct PS_PrivateRec_32_s +typedef struct __attribute__((packed, aligned(4))) PS_PrivateRec_32_s { int unique_id; int lenIV; @@ -546,7 +546,7 @@ typedef struct PS_PrivateRec_32_s int16_t min_feature[2]; } PS_PrivateRec_32_t; -typedef struct BDF_PropertyRec_32_s +typedef struct __attribute__((packed, aligned(4))) BDF_PropertyRec_32_s { int type; union { @@ -557,7 +557,7 @@ typedef struct BDF_PropertyRec_32_s } u; } BDF_PropertyRec_32_t; -typedef struct FT_Size_RequestRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Size_RequestRec_32_s { int type; long_t width; @@ -566,13 +566,13 @@ typedef struct FT_Size_RequestRec_32_s uint32_t vertResolution; } FT_Size_RequestRec_32_t; -typedef struct FT_Parameter_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Parameter_32_s { ulong_t tag; ptr_t data; //void* } FT_Parameter_32_t; -typedef struct FT_Open_Args_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Open_Args_32_s { uint32_t flags; ptr_t memory_base; //uint8_t* @@ -584,7 +584,7 @@ typedef struct FT_Open_Args_32_s ptr_t params; //FT_Parameter_t* } FT_Open_Args_32_t; -typedef struct FT_WinFNT_HeaderRec_32_s +typedef struct __attribute__((packed, aligned(4))) FT_WinFNT_HeaderRec_32_s { uint16_t version; ulong_t file_size; @@ -624,7 +624,7 @@ typedef struct FT_WinFNT_HeaderRec_32_s ulong_t reserved1[4]; } FT_WinFNT_HeaderRec_32_t; -typedef struct FT_Matrix_32_s +typedef struct __attribute__((packed, aligned(4))) FT_Matrix_32_s { long_t xx, xy; long_t yx, yy; diff --git a/src/wrapped32/wrappedldlinux.c b/src/wrapped32/wrappedldlinux.c index f0c8bf89..b9773d99 100755 --- a/src/wrapped32/wrappedldlinux.c +++ b/src/wrapped32/wrappedldlinux.c @@ -15,7 +15,7 @@ #include "elfloader.h" #include "box32context.h" -typedef struct my32_tls_s { +typedef struct __attribute__((packed, aligned(4))) my32_tls_s { int i; uint32_t o; } my32_tls_t; diff --git a/src/wrapped32/wrappedlibasound.c b/src/wrapped32/wrappedlibasound.c index 02d1bebc..c572ae85 100644 --- a/src/wrapped32/wrappedlibasound.c +++ b/src/wrapped32/wrappedlibasound.c @@ -288,7 +288,7 @@ typedef struct _my_snd_pcm_channel_area_s { unsigned int first; unsigned int step; } my_snd_pcm_channel_area_t; -typedef struct _my_snd_pcm_channel_area_32_s { +typedef struct __attribute__((packed, aligned(4))) _my_snd_pcm_channel_area_32_s { ptr_t addr; unsigned int first; unsigned int step; diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c index 779fb225..ad3478fb 100755 --- a/src/wrapped32/wrappedlibc.c +++ b/src/wrapped32/wrappedlibc.c @@ -1964,7 +1964,7 @@ EXPORT int32_t my32_execvp(x64emu_t* emu, const char* path, ptr_t argv[]) return execv(fullpath, (void*)newargv); } // execvp should use PATH to search for the program first -typedef struct +typedef struct __attribute__((packed, aligned(4))) { int __allocated; int __used; @@ -2662,7 +2662,7 @@ EXPORT void* my32___deregister_frame_info(void* a) EXPORT void* my32____brk_addr = NULL; #endif // longjmp / setjmp -typedef struct jump_buff_i386_s { +typedef struct __attribute__((packed, aligned(4))) jump_buff_i386_s { uint32_t save_ebx; uint32_t save_esi; uint32_t save_edi; @@ -2671,7 +2671,7 @@ typedef struct jump_buff_i386_s { uint32_t save_eip; } jump_buff_i386_t; -typedef struct __jmp_buf_tag_s { +typedef struct __attribute__((packed, aligned(4))) __jmp_buf_tag_s { jump_buff_i386_t __jmpbuf; int __mask_was_saved; sigset_t __saved_mask; diff --git a/src/wrapped32/wrappedlibdl.c b/src/wrapped32/wrappedlibdl.c index c3a79feb..05e7b058 100755 --- a/src/wrapped32/wrappedlibdl.c +++ b/src/wrapped32/wrappedlibdl.c @@ -51,7 +51,7 @@ void dl_set_error(const char*); char* dl_last_error(); library_t* dl_get_library(void* handle); -typedef struct my_dl_info_32_s +typedef struct __attribute__((packed, aligned(4))) my_dl_info_32_s { ptr_t dli_fname; // const char* ptr_t dli_fbase; // void* @@ -120,7 +120,7 @@ int my32_dlinfo(x64emu_t* emu, void* handle, int request, void* info) return -1; } -typedef struct my_dl_find_object_s { +typedef struct __attribute__((packed, aligned(4))) my_dl_find_object_s { uint64_t dlfo_flags; ptr_t dlfo_map_start; ptr_t dlfo_map_end; diff --git a/src/wrapped32/wrappedsdl1.c b/src/wrapped32/wrappedsdl1.c index a3a727c8..7186fc47 100644 --- a/src/wrapped32/wrappedsdl1.c +++ b/src/wrapped32/wrappedsdl1.c @@ -48,7 +48,7 @@ typedef struct { void *userdata; } SDL_AudioSpec; -typedef struct { +typedef struct __attribute__((packed, aligned(4))) { int32_t freq; uint16_t format; uint8_t channels; diff --git a/src/wrapped32/wrappedsdl2.c b/src/wrapped32/wrappedsdl2.c index 13fe4652..64cbaa9d 100644 --- a/src/wrapped32/wrappedsdl2.c +++ b/src/wrapped32/wrappedsdl2.c @@ -48,7 +48,7 @@ typedef struct { void* userdata; } SDL2_AudioSpec; -typedef struct __attribute__((packed)) { +typedef struct __attribute__((packed, aligned(4))) { int32_t freq; uint16_t format; uint8_t channels; @@ -508,6 +508,13 @@ typedef struct SDL_version_s uint8_t patch; } SDL_version_t; +typedef struct __attribute__((packed, aligned(4))) SDL_version_32_s +{ + uint8_t major; + uint8_t minor; + uint8_t patch; +} SDL_version_32_t; + typedef struct SDL_SysWMinfo_s { SDL_version_t version; @@ -523,9 +530,9 @@ typedef struct SDL_SysWMinfo_s } info; } SDL_SysWMinfo_t; -typedef struct SDL_SysWMinfo_32_s +typedef struct __attribute__((packed, aligned(4))) SDL_SysWMinfo_32_s { - SDL_version_t version; + SDL_version_32_t version; int subsystem; // 1=Windows, 2 =X11, 6=Wayland union { @@ -541,6 +548,7 @@ void* FindDisplay(void* d); EXPORT int my32_2_SDL_GetWindowWMInfo(void* w, SDL_SysWMinfo_32_t* i) { // 32bits and 64bits have the same size... + // TODO: Check if it's true int ret = my->SDL_GetWindowWMInfo(w, i); if(i->subsystem==2) { // inplace conversion |