From b639b6a4680fef7595af4c639fcc1bfa91624bf8 Mon Sep 17 00:00:00 2001 From: Robert Nix Date: Tue, 9 Jun 2015 12:44:50 -0500 Subject: [PATCH 1/3] Don't use __asm int 3; on 64-bit platforms --- stb.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stb.h b/stb.h index d78c465..03d891e 100644 --- a/stb.h +++ b/stb.h @@ -1021,9 +1021,15 @@ void stb_fatal(char *s, ...) vfprintf(stderr, s, a); va_end(a); fputs("\n", stderr); - #ifdef _WIN32 #ifdef STB_DEBUG + #ifdef _MSC_VER + #ifndef STB_PTR64 __asm int 3; // trap to debugger! + #else + __debugbreak(); + #endif + #else + __builtin_trap(); #endif #endif exit(1); From 0fbc8bec6f613bd91ec07ffc67ab0dae8a458b50 Mon Sep 17 00:00:00 2001 From: Robert Nix Date: Tue, 9 Jun 2015 12:46:31 -0500 Subject: [PATCH 2/3] Don't truncate pointers to 4 bytes on 64-bit --- stb.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stb.h b/stb.h index 03d891e..bc0114e 100644 --- a/stb.h +++ b/stb.h @@ -5831,14 +5831,19 @@ static char **readdir_raw(char *dir, int return_subdirs, char *mask) { char **results = NULL; char buffer[512], with_slash[512]; - int n; + size_t n; #ifdef _MSC_VER stb__wchar *ws; struct _wfinddata_t data; + #ifdef _WIN64 + const intptr_t none = -1; + intptr_t z; + #else const long none = -1; long z; - #else + #endif + #else // !_MSC_VER const DIR *none = NULL; DIR *z; #endif @@ -6812,7 +6817,11 @@ static void stb__dirtree_scandir(char *path, time_t last_time, stb_dirtree *acti int n; struct _wfinddata_t c_file; + #ifdef STB_PTR64 + intptr_t hFile; + #else long hFile; + #endif stb__wchar full_path[1024]; int has_slash; From 51415dea6e790741076857b03a19532619149abf Mon Sep 17 00:00:00 2001 From: Robert Nix Date: Tue, 9 Jun 2015 12:47:50 -0500 Subject: [PATCH 3/3] Fix 64-bit compile for pointer set --- stb.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stb.h b/stb.h index bc0114e..24cea76 100644 --- a/stb.h +++ b/stb.h @@ -7353,7 +7353,7 @@ STB_EXTERN void ** stb_ps_fastlist(stb_ps *ps, int *count); // but some entries of the list may be invalid; // test with 'stb_ps_fastlist_valid(x)' -#define stb_ps_fastlist_valid(x) ((unsigned int) (x) > 1) +#define stb_ps_fastlist_valid(x) ((stb_uinta) (x) > 1) #ifdef STB_DEFINE @@ -7374,8 +7374,6 @@ typedef struct #define GetBucket(p) ((stb_ps_bucket *) ((char *) (p) - STB_ps_bucket)) #define EncodeBucket(p) ((stb_ps *) ((char *) (p) + STB_ps_bucket)) -typedef char stb__verify_bucket_heap_size[sizeof(stb_ps_bucket) == 16]; - static void stb_bucket_free(stb_ps_bucket *b) { free(b);