You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/07/09 22:14:00 UTC

svn commit: r792657 - in /commons/sandbox/runtime/trunk/src/main/native: configure include/acr.h include/acr_openssl.h include/arch/unix/acr_arch.h include/arch/windows/acr_arch.h include/arch/windows/acr_arch_private.h os/unix/ios.c os/win32/ios.c

Author: mturk
Date: Thu Jul  9 20:13:59 2009
New Revision: 792657

URL: http://svn.apache.org/viewvc?rev=792657&view=rev
Log:
use if defined instead ifdef

Modified:
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/include/acr.h
    commons/sandbox/runtime/trunk/src/main/native/include/acr_openssl.h
    commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=792657&r1=792656&r2=792657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Thu Jul  9 20:13:59 2009
@@ -418,8 +418,14 @@
         as="ml.exe"
         ;;
     windows64-cl )
-        varadds ccflags "-DWIN64 -D_WIN64 -D_AMD64_=1"
-        varadds shflags "/MACHINE:AMD64"
+        varadds ccflags "-DWIN64 -D_WIN64"
+        if [ ".$mach" = ".ia64" ]; then
+            varadds ccflags "-D_IA64_=1"
+            varadds shflags "/MACHINE:IA64"
+        else        
+            varadds ccflags "-D_AMD64_=1"
+            varadds shflags "/MACHINE:AMD64"
+        fi
         as="ml64.exe"
         ;;
     *64-*        )
@@ -428,27 +434,27 @@
         ;;
 esac
 
+# Common defines
+varadds cppopts "-D_REENTRANT -D_LARGEFILE64_SOURCE"
 if [ ".$bits" = ".64" ]; then
-    varadds cppopts  "-D_COMPILE64BIT_SOURCE"
+    varadds cppopts "-D_COMPILE64BIT_SOURCE"
 fi
-
 if [ -d "$topdir/include/arch/$host" ]; then
     varadds includes "-I$topdir/include/arch/$host"
 fi
 if $is_unix; then
     varadds includes "-I$topdir/include/arch/unix"
-    varadds cppopts  "-D_REENTRANT -D_LARGEFILE64_SOURCE"
 fi
 if $has_maintainer_mode; then
-    varadds cppopts  "-DDEBUG -D_DEBUG"
+    varadds cppopts "-DDEBUG -D_DEBUG"
 else
-    varadds cppopts  "-DNDEBUG"
+    varadds cppopts "-DNDEBUG"
 fi
 if $has_memprotect; then
-    varadds cppopts  "-DACR_ENABLE_SEH"
+    varadds cppopts "-DACR_ENABLE_SEH"
 fi
 if $has_test; then
-    varadds cppopts  "-DACR_ENABLE_TEST"
+    varadds cppopts "-DACR_ENABLE_TEST"
     testobjs='$(TEST_OBJS)'
 else
     testobjs=""

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr.h?rev=792657&r1=792656&r2=792657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr.h Thu Jul  9 20:13:59 2009
@@ -19,10 +19,10 @@
 
 #include "ccconfig.h"
 #if HAVE_WINDOWS_H
-#ifndef WIN32_LEAN_AND_MEAN
+#if !defined(WIN32_LEAN_AND_MEAN)
 #define WIN32_LEAN_AND_MEAN
 #endif
-#ifndef _WIN32_WINNT
+#if !defined(_WIN32_WINNT)
 #define _WIN32_WINNT 0x0501
 #endif
 
@@ -53,7 +53,7 @@
  * and the POSIX string handling API
  */
 #if defined(_MSC_VER) && _MSC_VER >= 1400
-#ifndef _CRT_SECURE_NO_DEPRECATE
+#if !defined(_CRT_SECURE_NO_DEPRECATE)
 #define _CRT_SECURE_NO_DEPRECATE
 #endif
 #pragma warning(disable: 4996)
@@ -61,7 +61,7 @@
 
 #include <windows.h>
 
-#ifdef _M_IA64
+#if defined(_M_IA64)
 /* Fix bug in PlatforSDK headers */
 #define TMP_IA64 _M_IA64
 #undef _M_IA64
@@ -355,3 +355,4 @@
 }
 #endif
 #endif /* _ACR_H */
+

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_openssl.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_openssl.h?rev=792657&r1=792656&r2=792657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_openssl.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_openssl.h Thu Jul  9 20:13:59 2009
@@ -51,11 +51,11 @@
 /* Avoid tripping over an engine build installed globally and detected
  * when the user points at an explicit non-engine flavor of OpenSSL
  */
-#ifndef OPENSSL_NO_ENGINE
+#if !defined(OPENSSL_NO_ENGINE)
 #include <openssl/engine.h>
 #endif
 
-#ifndef RAND_MAX
+#if !defined(RAND_MAX)
 #include <limits.h>
 #define RAND_MAX INT_MAX
 #endif
@@ -206,3 +206,4 @@
 
 
 #endif /* ACR_OPENSSL */
+

Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h?rev=792657&r1=792656&r2=792657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h Thu Jul  9 20:13:59 2009
@@ -23,7 +23,7 @@
 extern "C" {
 #endif
 
-#ifdef HPUX11
+#if defined(HPUX11)
 #define ACR_INLINE  __inline
 #else
 #define ACR_INLINE  inline

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=792657&r1=792656&r2=792657&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 Thu Jul  9 20:13:59 2009
@@ -300,7 +300,7 @@
  * ---------------------------------------------------------------------
  */
 
-#ifndef WSA_NOT_ENOUGHT_MEMORY
+#if !defined(WSA_NOT_ENOUGHT_MEMORY)
 #define WSA_NOT_ENOUGHT_MEMORY      8
 #endif
 #define ACR_INLINE                __inline
@@ -326,7 +326,7 @@
 extern UINT64                  acr_vmem;
 
 /* Define ACR_WANT_LATE_DLL before including this file */
-#ifdef ACR_WANT_LATE_DLL
+#if defined(ACR_WANT_LATE_DLL)
 
 FARPROC acr_load_dll_func(acr_dlltoken_e, const char *, int);
 

Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h?rev=792657&r1=792656&r2=792657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h Thu Jul  9 20:13:59 2009
@@ -91,3 +91,4 @@
 #endif
 
 #endif /* ACR_ARCH_PRIVATE_H */
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c?rev=792657&r1=792656&r2=792657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c Thu Jul  9 20:13:59 2009
@@ -28,7 +28,8 @@
 #define __SET_BMP(X, B)    __bitmap[(X)] |= __zero_bit_mask[(B) & 0x07]
 #define __CLR_BMP(X, B)    __bitmap[(X)] &= __ones_bit_mask[(B) & 0x07]
 
-acr_ioh *acr_ioh_tab;
+static acr_ioh nul_ioh_tab = { INVALID_HANDLE_VALUE };
+acr_ioh *acr_ioh_tab = &nul_ioh_tab;
 int      acr_ioh_mask;
 
 static pthread_mutex_t ios_lock;
@@ -37,15 +38,15 @@
 static int              __bmp_size;
 static int              __bmp_hint;
 
-static unsigned char  __zero_bit_mask[] = {
+static const unsigned char __zero_bit_mask[] = {
     0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
 };
 
-static unsigned char  __ones_bit_mask[] = {
+static const unsigned char __ones_bit_mask[] = {
     0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE
 };
 
-static unsigned int   __sbit_mask[] = {
+static const int __sbit_mask[] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -67,14 +68,14 @@
 int acr_ioh_init(int size)
 {
     int rv;
-#ifdef PTHREAD_MUTEX_RECURSIVE
+#if defined(PTHREAD_MUTEX_RECURSIVE)
     pthread_mutexattr_t mattr;
 #endif
 
-    if (acr_ioh_tab)
-        return EEXIST;
+    if (__bitmap)
+        return ACR_EEXIST;
 
-#ifdef PTHREAD_MUTEX_RECURSIVE
+#if defined(PTHREAD_MUTEX_RECURSIVE)
     if ((rv = pthread_mutexattr_init(&mattr)))
         return rv;
     rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
@@ -105,21 +106,24 @@
     else
         __ioh_size = ACR_IOH_SLOTS;
     if (!__ioh_size)
-        return EINVAL;
+        return ACR_EINVAL;
     __bmp_size   = __ioh_size >> 3;
     acr_ioh_mask = __ioh_size - 1;
     acr_ioh_tab  = (acr_ioh *)calloc(sizeof(acr_ioh), __ioh_size);
     if (acr_ioh_tab) {
         acr_ioh_tab[acr_ioh_mask].h = INVALID_HANDLE_VALUE;
     }
-    else
-        return errno;
+    else {
+        acr_ioh_mask = 0;
+        acr_ioh_tab  = &nul_ioh_tab;
+        return ACR_ENOMEM;
+    }
     __bitmap = (unsigned char *)calloc(1, __bmp_size);
     if (!__bitmap) {
-        int rv = errno;
         free(acr_ioh_tab);
-        acr_ioh_tab = NULL;
-        return rv;
+        acr_ioh_mask = 0;
+        acr_ioh_tab  = &nul_ioh_tab;
+        return ACR_ENOMEM;
     }
     /* Allocate slots 0 ... 7 for system use.
      */
@@ -140,7 +144,7 @@
     /* Hardcode the maximum to 2M
      */
     if (ns > (2 * 1024 * 1024)) {
-        return ERANGE;
+        return ACR_ERANGE;
     }
     nb = ns >> 3;
     io = (acr_ioh *)calloc(sizeof(acr_ioh), ns);
@@ -154,10 +158,10 @@
 
     }
     else
-        return errno;
+        return ACR_ENOMEM;
     bm = (unsigned char *)calloc(1, nb);
     if (!bm) {
-        return errno;
+        return ACR_ENOMEM;
     }
     memcpy(bm, __bitmap, __bmp_size);
     free(__bitmap);
@@ -169,10 +173,10 @@
 
 int acr_ioh_alloc(void *h, int type, unsigned int flags)
 {
-    int i, x;
+    int i, x, e;
 
     if (!__bitmap) {
-        errno = ENOMEM;
+        ACR_SET_OS_ERROR(ACR_ENOMEM);
         return -1;
     }
     pthread_mutex_lock(&ios_lock);
@@ -201,10 +205,9 @@
             return x;
         }
     }
-    if ((errno = ioh_extend())) {
-        int e = errno;
+    if ((e = ioh_extend())) {
         pthread_mutex_unlock(&ios_lock);
-        errno = e;
+        ACR_SET_OS_ERROR(e);
         return -1;
     }
     for (; i < __bmp_size; i++) {
@@ -220,16 +223,16 @@
         }
     }
     pthread_mutex_unlock(&ios_lock);
-    errno = ENOSPC;
+    ACR_SET_OS_ERROR(ACR_ENOSPC);
     return -1;
 }
 
 int acr_ioh_free(int i)
 {
     if (i < 0 || i >= acr_ioh_mask)
-        return EINVAL;
+        return ACR_EINVAL;
     if (!__bitmap)
-        return ENOMEM;
+        return ACR_ENOMEM;
 
     pthread_mutex_lock(&ios_lock);
     acr_ioh_tab[i].h      = INVALID_HANDLE_VALUE;
@@ -257,7 +260,7 @@
     free(acr_ioh_tab);
     free(__bitmap);
     __bitmap     = NULL;
-    acr_ioh_tab  = NULL;
+    acr_ioh_tab  = &nul_ioh_tab;
     acr_ioh_mask = 0;
 
     pthread_mutex_destroy(&ios_lock);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c?rev=792657&r1=792656&r2=792657&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c Thu Jul  9 20:13:59 2009
@@ -27,7 +27,8 @@
 #define __SET_BMP(X, B)    __bitmap[(X)] |= __zero_bit_mask[(B) & 0x07]
 #define __CLR_BMP(X, B)    __bitmap[(X)] &= __ones_bit_mask[(B) & 0x07]
 
-acr_ioh *acr_ioh_tab;
+static acr_ioh nul_ioh_tab = { INVALID_HANDLE_VALUE };
+acr_ioh *acr_ioh_tab = &nul_ioh_tab;
 int      acr_ioh_mask;
 
 static CRITICAL_SECTION ios_lock;
@@ -36,15 +37,15 @@
 static int              __bmp_size;
 static int              __bmp_hint;
 
-static unsigned char  __zero_bit_mask[] = {
+static const unsigned char __zero_bit_mask[] = {
     0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
 };
 
-static unsigned char  __ones_bit_mask[] = {
+static const unsigned char __ones_bit_mask[] = {
     0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE
 };
 
-static unsigned int   __sbit_mask[] = {
+static const int __sbit_mask[] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -65,8 +66,8 @@
 
 int acr_ioh_init(int size)
 {
-    if (acr_ioh_tab)
-        return EEXIST;
+    if (__bitmap)
+        return ACR_EEXIST;
     if (size > 0) {
         /* Align the size to the power of 2 */
         int i, s;
@@ -81,21 +82,24 @@
     else
         __ioh_size = ACR_IOH_SLOTS;
     if (!__ioh_size)
-        return EINVAL;
+        return ACR_EINVAL;
     __bmp_size   = __ioh_size >> 3;
     acr_ioh_mask = __ioh_size - 1;
     acr_ioh_tab  = (acr_ioh *)calloc(sizeof(acr_ioh), __ioh_size);
     if (acr_ioh_tab) {
         acr_ioh_tab[acr_ioh_mask].h = INVALID_HANDLE_VALUE;
     }
-    else
-        return errno;
+    else {
+        acr_ioh_mask = 0;
+        acr_ioh_tab  = &nul_ioh_tab;
+        return ACR_ENOMEM;
+    }
     __bitmap = (unsigned char *)calloc(1, __bmp_size);
     if (!__bitmap) {
-        int rv = errno;
         free(acr_ioh_tab);
-        acr_ioh_tab = NULL;
-        return rv;
+        acr_ioh_mask = 0;
+        acr_ioh_tab  = &nul_ioh_tab;
+        return ACR_ENOMEM;
     }
     /* Allocate slots 0 ... 7 for system use.
      */
@@ -117,7 +121,7 @@
     /* Hardcode the maximum to 2M
      */
     if (ns > (2 * 1024 * 1024)) {
-        return ERANGE;
+        return ACR_ERANGE;
     }
     nb = ns >> 3;
     io = (acr_ioh *)calloc(sizeof(acr_ioh), ns);
@@ -131,10 +135,10 @@
 
     }
     else
-        return errno;
+        return ACR_ENOMEM;
     bm = (unsigned char *)calloc(1, nb);
     if (!bm) {
-        return errno;
+        return ACR_ENOMEM;
     }
     memcpy(bm, __bitmap, __bmp_size);
     free(__bitmap);
@@ -146,10 +150,10 @@
 
 int acr_ioh_alloc(void *h, int type, unsigned int flags)
 {
-    int i, x;
+    int i, x, e;
 
     if (!__bitmap) {
-        errno = ENOMEM;
+        ACR_SET_OS_ERROR(ACR_ENOMEM);
         return -1;
     }
     EnterCriticalSection(&ios_lock);
@@ -178,10 +182,9 @@
             return x;
         }
     }
-    if ((errno = ioh_extend())) {
-        int e = errno;
+    if ((e = ioh_extend())) {
         LeaveCriticalSection(&ios_lock);
-        errno = e;
+        ACR_SET_OS_ERROR(e);
         return -1;
     }
     for (; i < __bmp_size; i++) {
@@ -197,16 +200,16 @@
         }
     }
     LeaveCriticalSection(&ios_lock);
-    errno = ENOSPC;
+    ACR_SET_OS_ERROR(ACR_ENOSPC);
     return -1;
 }
 
 int acr_ioh_free(int i)
 {
     if (i < 0 || i >= acr_ioh_mask)
-        return EINVAL;
+        return ACR_EINVAL;
     if (!__bitmap)
-        return ENOMEM;
+        return ACR_ENOMEM;
 
     EnterCriticalSection(&ios_lock);
     acr_ioh_tab[i].h      = INVALID_HANDLE_VALUE;
@@ -233,8 +236,9 @@
     }
     free(acr_ioh_tab);
     free(__bitmap);
-    __bitmap    = NULL;
-    acr_ioh_tab = NULL;
+    __bitmap     = NULL;
+    acr_ioh_mask = 0;
+    acr_ioh_tab  = &nul_ioh_tab;
     DeleteCriticalSection(&ios_lock);
 
 }