From a28a6b126b4917c9ca8f47d2ad27aa6f71cebcef Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Thu, 7 Feb 2019 04:42:32 -0800 Subject: [PATCH] tests: 64-bit fixes, fix typo in image tests --- tests/image_test.c | 2 +- tests/stb.c | 21 +++++++++++++-------- tests/stb_cpp.cpp | 3 ++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/image_test.c b/tests/image_test.c index b449744..7a97822 100644 --- a/tests/image_test.c +++ b/tests/image_test.c @@ -84,7 +84,7 @@ int main(int argc, char **argv) int w2,h2,n2; unsigned char *data; printf("%s\n", argv[i]); - res = stbi_info(argv[1], &w2, &h2, &n2); + res = stbi_info(argv[i], &w2, &h2, &n2); data = stbi_load(argv[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n"); data = stbi_load(argv[i], &w, &h, 0, 1); if (data) free(data); else printf("Failed 1\n"); data = stbi_load(argv[i], &w, &h, 0, 2); if (data) free(data); else printf("Failed 2\n"); diff --git a/tests/stb.c b/tests/stb.c index e0731d6..6a6e7b1 100644 --- a/tests/stb.c +++ b/tests/stb.c @@ -13,12 +13,13 @@ #include #endif -#define STB_STUA //#define STB_FASTMALLOC #ifdef _DEBUG #define STB_MALLOC_WRAPPER_DEBUG #endif +#ifndef _M_AMD64 #define STB_NPTR +#endif #define STB_DEFINE #include "stb.h" @@ -119,7 +120,7 @@ void test_classes(void) return; } - +#ifdef STB_STUA void test_script(void) { stua_run_script( @@ -193,6 +194,7 @@ void test_script(void) " // final comment with no newline" ); } +#endif #ifdef STB_THREADS extern void __stdcall Sleep(unsigned long); @@ -2254,11 +2256,13 @@ void test_packed_floats(void) void do_compressor(int argc,char**argv) { char *p; + size_t slen; int len; int window; if (argc == 2) { - p = stb_file(argv[1], &len); + p = stb_file(argv[1], &slen); + len = (int) slen; if (p) { int dlen, clen = stb_compress_tofile("data/dummy.bin", p, len); char *q = stb_decompress_fromfile("data/dummy.bin", &dlen); @@ -2278,7 +2282,8 @@ void do_compressor(int argc,char**argv) window = atoi(argv[1]); if (window && argc == 4) { - p = stb_file(argv[3], &len); + p = stb_file(argv[3], &slen); + len = (int) slen; if (p) { stb_compress_hashsize(window); stb_compress_tofile(argv[2], p, len); @@ -2506,10 +2511,10 @@ void first_for_prod_plus_sym(stb_bitset **first, stb_bitset *out, short *prod, i stb_bitset_unioneq_changed(out, first[symbol], symset); } -#define Item(p,c,t) ((void *) (((t) << 18) + ((c) << 12) + ((p) << 2))) -#define ItemProd(i) ((((uint32) (i)) >> 2) & 1023) -#define ItemCursor(i) ((((uint32) (i)) >> 12) & 63) -#define ItemLookahead(i) (((uint32) (i)) >> 18) +#define Item(p,c,t) ((void *) (size_t) (((t) << 18) + ((c) << 12) + ((p) << 2))) +#define ItemProd(i) ((((uint32) (size_t) (i)) >> 2) & 1023) +#define ItemCursor(i) ((((uint32) (size_t) (i)) >> 12) & 63) +#define ItemLookahead(i) (((uint32) (size_t) (i)) >> 18) static void pc(stb_ps *p) { diff --git a/tests/stb_cpp.cpp b/tests/stb_cpp.cpp index 57f2cfa..f992108 100644 --- a/tests/stb_cpp.cpp +++ b/tests/stb_cpp.cpp @@ -2,9 +2,10 @@ #define WIN32_LEAN_AND_MEAN //#include #include -#define STB_STUA #define STB_DEFINE +#ifndef _M_AMD64 #define STB_NPTR +#endif #define STB_ONLY #include "stb.h" //#include "stb_file.h"