forked from Ports/goldeneye-pc-port
linux-build: POSIX branches for time()/bcopy/bzero and Win32-only probes
- pc_protos.h: the vestigial 'long long time()' prototype conflicts with glibc's time_t time(time_t*); no game code calls time(), guard it to _WIN32 (MinGW shadows <time.h> with the N64 stub; POSIX gets the real one). - n64stubs.c: don't redefine bcopy/bzero on POSIX -- glibc exports them (via <strings.h>, size_t sizes); the local int-signature definitions conflict. _WIN32-only now. - libultra.c: #define _GNU_SOURCE on POSIX for clock_gettime(CLOCK_*) and pthread_getattr_np; guard the D60 VirtualQuery committed-memory probe and GetCurrentThreadStackLimits behind PLATFORM_WINDOWS with a pthread_getattr_np-based stack-bounds fallback for the diagnostic path. Windows build verified green.
This commit is contained in:
1 parent
999bca81f5
commit
59751d608c
3 files changed
+39
-3
No files matched your search
@@ -447,7 +447,9 @@ s32 texLoadFromGdl();
|
||||
s32 texReadUncompressed();
|
||||
void texSelect();
|
||||
s32 texShrinkNonPaletted();
|
||||
long long time();
|
||||
#if defined(_WIN32)
|
||||
long long time(); /* MinGW: <time.h> is shadowed by the N64 stub here; POSIX gets the real one */
|
||||
#endif
|
||||
const char * tokenFind();
|
||||
s32 tokenReadIo();
|
||||
void transform3Dto2DWithZScaling();
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/* POSIX: enable clock_gettime(CLOCK_REALTIME/MONOTONIC) and pthread_getattr_np. */
|
||||
#if !defined(_WIN32) && !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* libultra OS shims for the PC port, plus the cooperative thread kernel.
|
||||
*
|
||||
@@ -765,6 +770,7 @@ static int dramHostAddrValid(uintptr_t addr, u32 size)
|
||||
* buffers (e.g. ramrom_data_target), stack compbuffers, sidecar images.
|
||||
* Truncated wild addresses (0x40xxxxxx from s32 pointer math) are not
|
||||
* committed, so VirtualQuery still catches them. */
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
if (VirtualQuery((LPCVOID)addr, &mbi, sizeof(mbi)) == sizeof(mbi) &&
|
||||
@@ -774,6 +780,13 @@ static int dramHostAddrValid(uintptr_t addr, u32 size)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
/* No cheap committed-memory probe on POSIX; this is a TEMP D60 diagnostic.
|
||||
* Be permissive so legitimate .bss/stack/sidecar DMA targets are not
|
||||
* flagged as fatal (a genuinely wild target still faults in the memcpy). */
|
||||
(void)size;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void piServiceDma(s32 direction, u32 srcPA, void *dstVA, u32 size)
|
||||
@@ -817,6 +830,7 @@ static void piServiceDma(s32 direction, u32 srcPA, void *dstVA, u32 size)
|
||||
wp += snprintf(wp, win + sizeof(win) - (wp - win),
|
||||
" %p", (void *)sp[i]);
|
||||
}
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
{
|
||||
PVOID tlow = NULL, thigh = NULL;
|
||||
GetCurrentThreadStackLimits(&tlow, &thigh);
|
||||
@@ -826,6 +840,22 @@ static void piServiceDma(s32 direction, u32 srcPA, void *dstVA, u32 size)
|
||||
((uintptr_t)dstVA >= (uintptr_t)tlow &&
|
||||
(uintptr_t)dstVA < (uintptr_t)thigh));
|
||||
}
|
||||
#else
|
||||
{
|
||||
pthread_attr_t at;
|
||||
void *sbase = NULL;
|
||||
size_t ssize = 0;
|
||||
if (pthread_getattr_np(pthread_self(), &at) == 0) {
|
||||
pthread_attr_getstack(&at, &sbase, &ssize);
|
||||
pthread_attr_destroy(&at);
|
||||
}
|
||||
sysLogPrintf(LOG_ERROR,
|
||||
"D60 thread stack: %p..%p dst-in-stack=%d\n",
|
||||
sbase, (void *)((uintptr_t)sbase + ssize),
|
||||
((uintptr_t)dstVA >= (uintptr_t)sbase &&
|
||||
(uintptr_t)dstVA < (uintptr_t)sbase + ssize));
|
||||
}
|
||||
#endif
|
||||
sysLogPrintf(LOG_ERROR,
|
||||
"D60 BAD DMA TARGET dst=%p src=0x%08X size=0x%X "
|
||||
"stack@rbp:%s\n",
|
||||
|
||||
+6
-2
@@ -106,10 +106,14 @@ u8 (*tlbmanageGetTlbAllocatedBlock(void))[TLB_BLOCK_SIZE]
|
||||
return (u8 (*)[TLB_BLOCK_SIZE])0x70700000;
|
||||
}
|
||||
|
||||
/* --- K&R libc helpers (IDO provided these; the host libc does not) ------- */
|
||||
/* Signatures mirror include/PR/os.h:983 / include/bstring.h exactly. */
|
||||
/* --- K&R libc helpers (IDO provided these; MinGW's libc does not) -------- */
|
||||
/* Signatures mirror include/PR/os.h:983 / include/bstring.h exactly.
|
||||
* glibc still exports bcopy/bzero (declared in <strings.h> with size_t), so
|
||||
* on the POSIX port we use those and must NOT redefine them here. */
|
||||
#if defined(_WIN32)
|
||||
void bcopy(const void *src, void *dst, int n) { memmove(dst, src, (size_t)n); }
|
||||
void bzero(void *s, int n) { memset(s, 0, (size_t)n); }
|
||||
#endif
|
||||
|
||||
/* --- libm internals (IDO's libm exposed these; MinGW's does not) --------- */
|
||||
/* Quiet NaN float, used by gu/cosf.c and game/zlib.c. The VALUE is the same */
|
||||
|
||||
Reference in new issue
Block a user