Author: mturk Date: Tue Jul 14 07:49:35 2009 New Revision: 793808 URL: http://svn.apache.org/viewvc?rev=793808&view=rev Log: Some code cleanup
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp commons/sandbox/runtime/trunk/src/main/native/shared/string.c commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=793808&r1=793807&r2=793808&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Tue Jul 14 07:49:35 2009 @@ -343,7 +343,7 @@ if (!acr_winapi_pfn_##fn) \ acr_winapi_pfn_##fn = (acr_winapi_fpt_##fn) \ acr_load_dll_func(lib, #fn, ord); \ - if (acr_winapi_pfn_##fn) return 1; else return 0; }; \ + if (acr_winapi_pfn_##fn) return 1; else return 0; } \ static __inline rettype acr_winapi_##fn args \ { if (acr_winapi_ld_##fn()) \ return (*(acr_winapi_pfn_##fn)) names; \ @@ -361,7 +361,7 @@ if (!acr_winapi_pfn_##fn) \ acr_winapi_pfn_##fn = (acr_winapi_fpt_##fn) \ acr_load_dll_func(lib, #fn, ord); \ - if (acr_winapi_pfn_##fn) return 1; else return 0; }; \ + if (acr_winapi_pfn_##fn) return 1; else return 0; } \ static __inline void acr_winapi_##fn args \ { if (acr_winapi_ld_##fn()) \ (*(acr_winapi_pfn_##fn)) names; \ @@ -499,7 +499,7 @@ ACR_DECLARE_LATE_DLL_VOID(SYSDLL_JVM, JNICALL, JVM_DumpAllStacks, - 8, ( + 8, ( JNIEnv *lpEnv, jclass jClazz), (lpEnv, jClazz)); @@ -514,7 +514,7 @@ IN LPVOID lpFileInformation, IN DWORD dwBufferSize), (hFile, FileInformationClass, lpFileInformation, dwBufferSize)) -#define rGetFileInformationByHandleEx acr_winapi_GetFileInformationByHandleEx +#define GetFileInformationByHandleEx acr_winapi_GetFileInformationByHandleEx #endif #undef ACR_WANT_LATE_DLL Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp?rev=793808&r1=793807&r2=793808&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp Tue Jul 14 07:49:35 2009 @@ -48,7 +48,7 @@ if (!v) return 0; VariantInit(v); - return ACR_PointerCreate(_E, v, 0, variant_callback); + return ACR_NewPointer(_E, v, 0, variant_callback); } extern "C" @@ -64,7 +64,7 @@ VariantInit(v); V_VT(v) = VT_BSTR; V_BSTR(v) = SysAllocString(J2W(str)); - r = ACR_PointerCreate(_E, v, 0, variant_callback); + r = ACR_NewPointer(_E, v, 0, variant_callback); } END_WITH_WSTR(str); return r; Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=793808&r1=793807&r2=793808&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Tue Jul 14 07:49:35 2009 @@ -598,8 +598,6 @@ int negative; char buf[16]; - if (!buf) - return NULL; start = buf + BUFFER_SIZE - 1; if (n < 0) { negative = 1; @@ -626,8 +624,6 @@ int negative; char buf[32]; - if (!buf) - return NULL; start = buf + BUFFER_SIZE - 1; if (n < 0) { negative = 1; Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=793808&r1=793807&r2=793808&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Tue Jul 14 07:49:35 2009 @@ -29,6 +29,13 @@ #include "acr_file.h" #include "acr_xdr.h" +#if defined (WIN32) +#include <io.h> +#include <sys/stat.h> +#define random rand +#define srandom srand +#endif + /** * Test cases */ @@ -221,14 +228,14 @@ static int callback(void *p, size_t s) { - fprintf(stderr, "[native] Pointer callback called: %p - %d\n", p, s); + fprintf(stderr, "[native] Pointer callback called: %p - %d\n", p, (int)s); fflush(stderr); return 0; } static int dbbcallback(void *p, size_t s) { - fprintf(stderr, "[native] DirectBuffer callback called: %p - %d\n", p, s); + fprintf(stderr, "[native] DirectBuffer callback called: %p - %d\n", p, (int)s); fflush(stderr); return 0; } @@ -322,9 +329,9 @@ ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test045)(ACR_JNISTDARGS, jint i) { int x; - int fd; -#ifdef WIN32 - fd = -1; + int fd; +#if defined (WIN32) + fd = open("NUL", O_RDWR); #else fd = open("/dev/null", O_RDWR); #endif @@ -335,9 +342,9 @@ ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test046)(ACR_JNISTDARGS, jlong i) { - if (i <= 0) - return -1; - else { + if (i <= 0) + return -1; + else { int rfd = test_desc_perf[i].f; return rfd; } @@ -345,15 +352,15 @@ ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test047)(ACR_JNISTDARGS, jint i, jint v) { - if (i < 0) - return -1; - else { + if (i < 0) + return -1; + else { int rfd = test_desc_perf[i].f; struct stat s; if (rfd > 0) { -// fstat(rfd, &s); -// return (jint)s.st_dev + v; - return (jint)time(NULL) + v; + fstat(rfd, &s); + return (jint)s.st_dev + v; +/* return (jint)time(NULL) + v;*/ } else return -1; @@ -363,19 +370,19 @@ ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test048)(ACR_JNISTDARGS, jobject d, jint v) { int fd = ACR_DescriptorGetInt(_E, d); - if (fd < 0) - return -1; - else { + if (fd < 0) + return -1; + else { int rfd = test_desc_perf[fd].f; struct stat s; if (rfd > 0) { -// fstat(rfd, &s); -// return (jint)s.st_dev + v; - return (jint)time(NULL) + v; + fstat(rfd, &s); + return (jint)s.st_dev + v; +/* return (jint)time(NULL) + v;*/ } else return -1; - } + } } ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test025)(ACR_JNISTDARGS, jobject d, int v) @@ -587,46 +594,46 @@ ACR_JNI_EXPORT_DECLARE(int, TestPrivate, test050)(ACR_JNISTDARGS, jint d) { int i; - int fd; + int fd; int n; int r = 0; srandom(time(NULL)); - for (n = 0; n < 2; n++) { + for (n = 0; n < 2; n++) { for (i = 0; i < (ACR_IOH_SLOTS - 8); i++) { - fd = acr_ioh_alloc(NULL, ACR_DT_FILE, i); - if (fd == -1) { - r++; - } + fd = acr_ioh_alloc(NULL, ACR_DT_FILE, i); + if (fd == -1) { + r++; + } } for (i = 0; i < ACR_IOH_SLOTS; i++) { fd = random() % ACR_IOH_SLOTS; - acr_ioh_free(i); - } - } - return r; + acr_ioh_free(i); + } + } + return r; } ACR_JNI_EXPORT_DECLARE(int, TestPrivate, test051)(ACR_JNISTDARGS, jint d) { int i; - int fd; + int fd; int n; int r = 0; - + srandom(time(NULL)); - for (n = 0; n < 2; n++) { + for (n = 0; n < 2; n++) { for (i = 0; i < (ACR_IOH_SLOTS - 8); i++) { - fd = acr_ioh_alloc(NULL, ACR_DT_FILE, i); - if (fd == -1) { - r++; - } + fd = acr_ioh_alloc(NULL, ACR_DT_FILE, i); + if (fd == -1) { + r++; + } } for (i = 0; i < ACR_IOH_SLOTS; i++) { fd = random() % ACR_IOH_SLOTS; - acr_ioh_free(fd); - } - } - return r; + acr_ioh_free(fd); + } + } + return r; }