forked from Ports/goldeneye-pc-port
linux-runtime: declare getenv()/realloc() for the strict-host build
The N64 <stdlib.h> stub declares neither. MinGW's other CRT headers leak them; a strict host GCC (Linux/macOS, -std=gnu11) does not, so getenv()'s 64-bit char* return is assumed int and truncated -> configGetFrameDump (GE_PCDUMP path) dereferenced a low-32 pointer and segfaulted. Add K&R decls: pc_protos.h (D38 mechanism -> game TUs via <ultra64.h>) and the port/shim/stdlib.h non-Windows branch (-> port TUs that #include <stdlib.h>). K&R form stays compatible with the real prototypes; malloc/ calloc/free are already covered elsewhere so not repeated.
This commit is contained in:
1 parent
2afc0be700
commit
cee26d46fc
2 files changed
+16
No files matched your search
@@ -201,6 +201,11 @@ void fileUpdateSelectedBondInSave();
|
||||
s32 fogGetPropDistColor();
|
||||
void fogLoadLevelEnvironment();
|
||||
void free();
|
||||
/* D38: the N64 <stdlib.h> stub declares neither, and unlike MinGW a strict
|
||||
* host GCC does not leak them — so getenv()'s 64-bit pointer return is
|
||||
* truncated to int (crashed configGetFrameDump on Linux). */
|
||||
char * getenv();
|
||||
void * realloc();
|
||||
int frontGetPlayersFavoriteWeaponInHand();
|
||||
void generate_player_thrown_grenade();
|
||||
void generate_player_thrown_knife();
|
||||
|
||||
@@ -17,4 +17,15 @@
|
||||
#include "hoststdlib.h"
|
||||
#else
|
||||
#include "include/stdlib.h"
|
||||
#if !defined(_WIN32)
|
||||
/* The N64 stub declares only lldiv_t/ldiv_t + lldiv/ldiv. MinGW's other CRT
|
||||
* headers leak getenv() etc.; a strict host GCC (Linux/macOS) does not, so
|
||||
* getenv()'s 64-bit pointer return is assumed int and truncated (crashed
|
||||
* configGetFrameDump). Declare the pointer-returning stragglers the port +
|
||||
* game code use that nothing else declares. K&R form = compatible with any
|
||||
* real prototype. (malloc/calloc/free are in port/include/pc_protos.h and
|
||||
* a few port TUs' own local decls — not repeated here to avoid conflicts.) */
|
||||
extern char *getenv();
|
||||
extern void *realloc();
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user