[BOX32][WRAPPER] Add libogg wrapper for BOX32#3596
[BOX32][WRAPPER] Add libogg wrapper for BOX32#3596runlevel5 wants to merge 1 commit intoptitSeb:mainfrom
Conversation
|
Side note: I know with AI, writting a long PR description is Painless. But for the human reader I am, having redundant informations is just a waste of time. I don't need "Files Changed" chapter. I can see already what's changes in the PR. Same for what changes: I can see the diff already. |
|
Speaking of trust: I double checked the first assertion: "ogg_stream_state doesn't need to be aligned". typedef struct {
unsigned char *body_data; /* bytes from packet bodies */
long body_storage; /* storage elements allocated */
long body_fill; /* elements stored; fill mark */
long body_returned; /* elements of fill returned */
int *lacing_vals; /* The values that will go to the segment table */
ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
this way, but it is simple coupled to the
lacing fifo */
long lacing_storage;
long lacing_fill;
long lacing_packet;
long lacing_returned;
unsigned char header[282]; /* working space for header encode */
int header_fill;
int e_o_s; /* set when we have buffered the last packet in the
logical bitstream */
int b_o_s; /* set after we've written the initial page
of a logical bitstream */
long serialno;
long pageno;
ogg_int64_t packetno; /* sequence number for decode; the framing
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a separate abstraction
layer) also knows about the gap */
ogg_int64_t granulepos;
} ogg_stream_state;The first element structure is a pointer. Pointer are 4 bytes in 32bits, and 8 bytes in 64bits. That's the whole point of 64bits. The structure absolutly needs alignment. In your case, it works because the program doesn't touch the structure elements individual, and use it as an opaque one. But other software might not. |
ptitSeb
left a comment
There was a problem hiding this comment.
ogg_stream_state needs alignement.
Yes. I am looking into it atm. Any guidance on an example how to align raw 32 bit pointer to 64 bit one is greatly appreciated. |
Well, that's all that is done in most wrappers for box32... You can use wrapperhelper to write the core of the functions. (note that converter32 is not yet automaticaly written. That's the plan, but the tools are not there yet so it's written by end. The style is simple with no comments because, one day hopefully, this will be automatic) |
Add 32-bit wrapper for libogg (libogg.so.0) to enable native wrapping
in BOX32 mode. This is a simple pass-through wrapper with no callbacks
or struct conversions needed.
New files:
- src/wrapped32/wrappedlibogg.c
- src/wrapped32/wrappedlibogg_private.h
- src/wrapped32/generated/wrappedlibogg{defs,types,undefs}32.h
New signature added to wrapper32 generated files:
- lFpi (intptr_t fn(void*, int32_t))
631e1c9 to
e1eae77
Compare
|
All 6 ogg structs have fields ( I used two strategies depending on struct lifetime:
I tested this with a 32-bit x86 encode/decode test binary running through box64 on PPC64LE (POWER9) — full cycle (3 packets → 2 pages → decode back) passes with 0 errors. |
| kh_destroy(syncstate, sync_shadows); \ | ||
| sync_shadows = NULL; | ||
|
|
||
| #include "wrappedlib_init32.h" |
There was a problem hiding this comment.
CUSTOM_INIT creates the two khash tables at library load. CUSTOM_FINI frees all shadow structs and destroys the hash tables at library unload, preventing leaks if the app doesn't call ogg_stream_clear/ogg_sync_clear before exit.
|
Re: I added 5 new wrapper signatures: |
|
@ptitSeb I guess that should be it for this work, feel free to review and let me know if it could be improved further |
Summary
libogg.so.0) with full struct alignment conversion between 32-bit and 64-bit layoutsogg_iovec_t,oggpack_buffer,ogg_page,ogg_packet,ogg_stream_state,ogg_sync_stateogg_stream_state,ogg_sync_state) and stack-local conversion for ephemeral structs (ogg_page,ogg_packet,oggpack_buffer)Context
Games running under BOX32 (e.g., Grim Fandango Remastered on PPC64LE) that use libogg currently fall back to emulated mode. This wrapper allows the native host libogg to be used instead.