commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r813678 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_error.h include/arch/windows/acr_arch_private.h shared/error.c
Date Fri, 11 Sep 2009 06:50:12 GMT
Author: mturk
Date: Fri Sep 11 06:50:12 2009
New Revision: 813678

URL: http://svn.apache.org/viewvc?rev=813678&view=rev
Log:
Get rid of wired APR Win32 error handling by not translatin error codes. We only use winerror,
so no need for translations

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h?rev=813678&r1=813677&r2=813678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h Fri Sep 11 06:50:12
2009
@@ -205,7 +205,7 @@
                                      acr_trowclass_e clazz, int err);
 
 /**
- * @defgroup apr_errno Error Codes
+ * @defgroup acr_errno Error Codes
  * @ingroup ACR
  * @{
  */
@@ -219,94 +219,20 @@
 ACR_DECLARE(char *) ACR_GetErrorString(int statcode, char *buf,
                                        acr_size_t bufsize);
 
-#if defined(DOXYGEN)
-/**
- * @def ACR_FROM_OS_ERROR(os_err_type syserr)
- * Fold a platform specific error into an apr_status_t code.
- * @return apr_status_t
- * @param e The platform os error code.
- * @warning  macro implementation; the syserr argument may be evaluated
- *      multiple times.
- */
-#define ACR_FROM_OS_ERROR(e) (e == 0 ? ACR_SUCCESS : e + ACR_OS_START_SYSERR)
-
-/**
- * @def ACR_TO_OS_ERROR(apr_status_t statcode)
- * @return os_err_type
- * Fold an apr_status_t code back to the native platform defined error.
- * @param e The apr_status_t folded platform os error code.
- * @warning  macro implementation; the statcode argument may be evaluated
- *      multiple times.  If the statcode was not created by apr_get_os_error
- *      or ACR_FROM_OS_ERROR, the results are undefined.
- */
-#define ACR_TO_OS_ERROR(e) (e == 0 ? ACR_SUCCESS : e - ACR_OS_START_SYSERR)
-
-/** @def apr_get_os_error()
- * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms
- * @remark This retrieves errno, or calls a GetLastError() style function, and
- *      folds it with ACR_FROM_OS_ERROR.  Some platforms (such as OS2) have no
- *      such mechanism, so this call may be unsupported.  Do NOT use this
- *      call for socket errors from socket, send, recv etc!
- */
-
-/** @def apr_set_os_error(e)
- * Reset the last platform error, unfolded from an apr_status_t, on some platforms
- * @param e The OS error folded in a prior call to ACR_FROM_OS_ERROR()
- * @warning This is a macro implementation; the statcode argument may be evaluated
- *      multiple times.  If the statcode was not created by apr_get_os_error
- *      or ACR_FROM_OS_ERROR, the results are undefined.  This macro sets
- *      errno, or calls a SetLastError() style function, unfolding statcode
- *      with ACR_TO_OS_ERROR.  Some platforms (such as OS2) have no such
- *      mechanism, so this call may be unsupported.
- */
-
-/** @def apr_get_netos_error()
- * Return the last socket error, folded into apr_status_t, on all platforms
- * @remark This retrieves errno or calls a GetLastSocketError() style function,
- *      and folds it with ACR_FROM_OS_ERROR.
- */
-
-/** @def apr_set_netos_error(e)
- * Reset the last socket error, unfolded from an apr_status_t
- * @param e The socket error folded in a prior call to ACR_FROM_OS_ERROR()
- * @warning This is a macro implementation; the statcode argument may be evaluated
- *      multiple times.  If the statcode was not created by apr_get_os_error
- *      or ACR_FROM_OS_ERROR, the results are undefined.  This macro sets
- *      errno, or calls a WSASetLastError() style function, unfolding
- *      socketcode with ACR_TO_OS_ERROR.
- */
-
-#endif /* defined(DOXYGEN) */
-
-/**
- * ACR_OS_START_ERROR is where the ACR specific error values start.
- */
-#define ACR_OS_START_ERROR         20000
 /**
  * ACR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
  *    into one of the error/status ranges below -- except for
  *    ACR_OS_START_USERERR, which see.
  */
-#define ACR_OS_ERRSPACE_SIZE       50000
+#define ACR_OS_ERRSPACE_SIZE        50000
 /**
- * ACR_UTIL_ERRSPACE_SIZE is the size of the space that is reserved for
- * use within apr-util. This space is reserved above that used by ACR
- * internally.
- * @note This number MUST be smaller than ACR_OS_ERRSPACE_SIZE by a
- *       large enough amount that ACR has sufficient room for it's
- *       codes.
+ * ACR_OS_START_ERROR is where the ACR specific error values start.
  */
-#define ACR_UTIL_ERRSPACE_SIZE     20000
+#define ACR_OS_START_ERROR         200000
 /**
  * ACR_OS_START_STATUS is where the ACR specific status codes start.
  */
-#define ACR_OS_START_STATUS    (ACR_OS_START_ERROR + ACR_OS_ERRSPACE_SIZE)
-/**
- * ACR_UTIL_START_STATUS is where ACR-Util starts defining it's
- * status codes.
- */
-#define ACR_UTIL_START_STATUS   (ACR_OS_START_STATUS + \
-                           (ACR_OS_ERRSPACE_SIZE - ACR_UTIL_ERRSPACE_SIZE))
+#define ACR_OS_START_STATUS        300000
 /**
  * ACR_OS_START_USERERR are reserved for applications that use ACR that
  *     layer their own error codes along with ACR's.  Note that the
@@ -326,28 +252,22 @@
  *              starting at an offset of 5000, e.g.
  *               +5000 to 5100,  +10000 to 10100
  */
-#define ACR_OS_START_USERERR    (ACR_OS_START_STATUS + ACR_OS_ERRSPACE_SIZE)
-/**
- * ACR_OS_START_USEERR is obsolete, defined for compatibility only.
- * Use ACR_OS_START_USERERR instead.
- */
-#define ACR_OS_START_USEERR     ACR_OS_START_USERERR
+#define ACR_OS_START_USERERR        400000
 /**
  * ACR_OS_START_CANONERR is where ACR versions of errno values are defined
  *     on systems which don't have the corresponding errno.
  */
-#define ACR_OS_START_CANONERR  (ACR_OS_START_USERERR \
-                                 + (ACR_OS_ERRSPACE_SIZE * 10))
+#define ACR_OS_START_CANONERR       500000
 /**
  * ACR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into
  *     apr_status_t values.
  */
-#define ACR_OS_START_EAIERR    (ACR_OS_START_CANONERR + ACR_OS_ERRSPACE_SIZE)
+#define ACR_OS_START_EAIERR         600000
 /**
  * ACR_OS_START_SYSERR folds platform-specific system error values into
  *     apr_status_t values.
  */
-#define ACR_OS_START_SYSERR    (ACR_OS_START_EAIERR + ACR_OS_ERRSPACE_SIZE)
+#define ACR_OS_START_SYSERR         700000
 
 /**
  * @defgroup ACR_ERROR_map ACR Error Space
@@ -357,31 +277,27 @@
  *
  *       0
  *
- *  20,000     ACR_OS_START_ERROR
+ * 100,000      ACR_OS_START_ERROR
  *
  *         + ACR_OS_ERRSPACE_SIZE (50,000)
  *
- *  70,000      ACR_OS_START_STATUS
+ * 200,000      ACR_OS_START_STATUS
  *
- *         + ACR_OS_ERRSPACE_SIZE - ACR_UTIL_ERRSPACE_SIZE (30,000)
- *
- * 100,000      ACR_UTIL_START_STATUS
- *
- *         + ACR_UTIL_ERRSPACE_SIZE (20,000)
+ *         + ACR_OS_ERRSPACE_SIZE (50,000)
  *
- * 120,000      ACR_OS_START_USERERR
+ * 300,000      ACR_OS_START_USERERR
  *
- *         + 10 x ACR_OS_ERRSPACE_SIZE (50,000 * 10)
+ *         + ACR_OS_ERRSPACE_SIZE (50,000)
  *
- * 620,000      ACR_OS_START_CANONERR
+ * 400,000      ACR_OS_START_CANONERR
  *
  *         + ACR_OS_ERRSPACE_SIZE (50,000)
  *
- * 670,000      ACR_OS_START_EAIERR
+ * 500,000      ACR_OS_START_EAIERR
  *
  *         + ACR_OS_ERRSPACE_SIZE (50,000)
  *
- * 720,000      ACR_OS_START_SYSERR
+ * 600,000      ACR_OS_START_SYSERR
  *
  * </PRE>
  */
@@ -1376,116 +1292,116 @@
     return err == ERROR_SUCCESS ? WSAEWOULDBLOCK : err;
 }
 
-#define ACR_FROM_OS_ERROR(e) (e == 0 ? ACR_SUCCESS : e + ACR_OS_START_SYSERR)
-#define ACR_TO_OS_ERROR(e)   (e == 0 ? ACR_SUCCESS : e - ACR_OS_START_SYSERR)
+#define ACR_FROM_OS_ERROR(e) (e)
+#define ACR_TO_OS_ERROR(e)   (e)
 
-#define ACR_GET_OS_ERROR()   (ACR_FROM_OS_ERROR(_SysGetLastError()))
-#define ACR_SET_OS_ERROR(e)  (SetLastError(ACR_TO_OS_ERROR(e)))
+#define ACR_GET_OS_ERROR()   (_SysGetLastError())
+#define ACR_SET_OS_ERROR(e)  (SetLastError((e))
 
 /* A special case, only socket calls require this:
  */
-#define ACR_GET_NETOS_ERROR()    (ACR_FROM_OS_ERROR(_NetGetLastError()))
-#define ACR_SET_NETOS_ERROR(e)   (WSASetLastError(ACR_TO_OS_ERROR(e)))
+#define ACR_GET_NETOS_ERROR()    (_NetGetLastError((e))
+#define ACR_SET_NETOS_ERROR(e)   (WSASetLastError((e)))
 
 /* ACR CANONICAL ERROR TESTS */
 #define ACR_STATUS_IS_EACCES(s)         ((s) == ACR_EACCES \
-                || (s) == ACR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
-                || (s) == ACR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_FAIL_I24 \
-                || (s) == ACR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
-                || (s) == ACR_OS_START_SYSERR + ERROR_LOCK_FAILED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NOT_LOCKED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+                || (s) == ERROR_ACCESS_DENIED \
+                || (s) == ERROR_CANNOT_MAKE \
+                || (s) == ERROR_CURRENT_DIRECTORY \
+                || (s) == ERROR_DRIVE_LOCKED \
+                || (s) == ERROR_FAIL_I24 \
+                || (s) == ERROR_LOCK_VIOLATION \
+                || (s) == ERROR_LOCK_FAILED \
+                || (s) == ERROR_NOT_LOCKED \
+                || (s) == ERROR_NETWORK_ACCESS_DENIED \
+                || (s) == ERROR_SHARING_VIOLATION)
 #define ACR_STATUS_IS_EEXIST(s)         ((s) == ACR_EEXIST \
-                || (s) == ACR_OS_START_SYSERR + ERROR_FILE_EXISTS \
-                || (s) == ACR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
+                || (s) == ERROR_FILE_EXISTS \
+                || (s) == ERROR_ALREADY_EXISTS)
 #define ACR_STATUS_IS_ENAMETOOLONG(s)   ((s) == ACR_ENAMETOOLONG \
-                || (s) == ACR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
-                || (s) == ACR_OS_START_SYSERR + WSAENAMETOOLONG)
+                || (s) == ERROR_FILENAME_EXCED_RANGE \
+                || (s) == WSAENAMETOOLONG)
 #define ACR_STATUS_IS_ENOENT(s)         ((s) == ACR_ENOENT \
-                || (s) == ACR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
-                || (s) == ACR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
-                || (s) == ACR_OS_START_SYSERR + ERROR_OPEN_FAILED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
+                || (s) == ERROR_FILE_NOT_FOUND \
+                || (s) == ERROR_PATH_NOT_FOUND \
+                || (s) == ERROR_OPEN_FAILED \
+                || (s) == ERROR_NO_MORE_FILES)
 #define ACR_STATUS_IS_ENOTDIR(s)        ((s) == ACR_ENOTDIR \
-                || (s) == ACR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
-                || (s) == ACR_OS_START_SYSERR + ERROR_BAD_NETPATH \
-                || (s) == ACR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
-                || (s) == ACR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_DRIVE)
+                || (s) == ERROR_PATH_NOT_FOUND \
+                || (s) == ERROR_BAD_NETPATH \
+                || (s) == ERROR_BAD_NET_NAME \
+                || (s) == ERROR_BAD_PATHNAME \
+                || (s) == ERROR_INVALID_DRIVE)
 #define ACR_STATUS_IS_ENOSPC(s)         ((s) == ACR_ENOSPC \
-                || (s) == ACR_OS_START_SYSERR + ERROR_DISK_FULL)
+                || (s) == ERROR_DISK_FULL)
 #define ACR_STATUS_IS_ENOMEM(s)         ((s) == ACR_ENOMEM \
-                || (s) == ACR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
-                || (s) == ACR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
+                || (s) == ERROR_ARENA_TRASHED \
+                || (s) == ERROR_NOT_ENOUGH_MEMORY \
+                || (s) == ERROR_INVALID_BLOCK \
+                || (s) == ERROR_NOT_ENOUGH_QUOTA \
+                || (s) == ERROR_OUTOFMEMORY)
 #define ACR_STATUS_IS_EMFILE(s)         ((s) == ACR_EMFILE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+                || (s) == ERROR_TOO_MANY_OPEN_FILES)
 #define ACR_STATUS_IS_ENFILE(s)         ((s) == ACR_ENFILE)
 #define ACR_STATUS_IS_EBADF(s)          ((s) == ACR_EBADF \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
+                || (s) == ERROR_INVALID_HANDLE \
+                || (s) == ERROR_INVALID_TARGET_HANDLE)
 #define ACR_STATUS_IS_EINVAL(s)         ((s) == ACR_EINVAL \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_DATA \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+                || (s) == ERROR_INVALID_ACCESS \
+                || (s) == ERROR_INVALID_DATA \
+                || (s) == ERROR_INVALID_FUNCTION \
+                || (s) == ERROR_INVALID_HANDLE \
+                || (s) == ERROR_INVALID_PARAMETER \
+                || (s) == ERROR_NEGATIVE_SEEK)
 #define ACR_STATUS_IS_ESPIPE(s)         ((s) == ACR_ESPIPE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+                || (s) == ERROR_SEEK_ON_DEVICE \
+                || (s) == ERROR_NEGATIVE_SEEK)
 #define ACR_STATUS_IS_EAGAIN(s)         ((s) == ACR_EAGAIN \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NO_DATA \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
-                || (s) == ACR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
-                || (s) == ACR_OS_START_SYSERR + ERROR_RETRY \
-                || (s) == ACR_OS_START_SYSERR + WSAEWOULDBLOCK)
+                || (s) == ERROR_NO_DATA \
+                || (s) == ERROR_NO_PROC_SLOTS \
+                || (s) == ERROR_NESTING_NOT_ALLOWED \
+                || (s) == ERROR_MAX_THRDS_REACHED \
+                || (s) == ERROR_LOCK_VIOLATION \
+                || (s) == ERROR_RETRY \
+                || (s) == WSAEWOULDBLOCK)
 #define ACR_STATUS_IS_EINTR(s)          ((s) == ACR_EINTR \
-                || (s) == ACR_OS_START_SYSERR + WSAEINTR)
+                || (s) == WSAEINTR)
 #define ACR_STATUS_IS_ENOTSOCK(s)       ((s) == ACR_ENOTSOCK \
-                || (s) == ACR_OS_START_SYSERR + WSAENOTSOCK)
+                || (s) == WSAENOTSOCK)
 #define ACR_STATUS_IS_ECONNREFUSED(s)   ((s) == ACR_ECONNREFUSED \
-                || (s) == ACR_OS_START_SYSERR + WSAECONNREFUSED)
+                || (s) == WSAECONNREFUSED)
 #define ACR_STATUS_IS_EINPROGRESS(s)    ((s) == ACR_EINPROGRESS \
-                || (s) == ACR_OS_START_SYSERR + WSAEINPROGRESS)
+                || (s) == WSAEINPROGRESS)
 #define ACR_STATUS_IS_ECONNABORTED(s)   ((s) == ACR_ECONNABORTED \
-                || (s) == ACR_OS_START_SYSERR + WSAECONNABORTED)
+                || (s) == WSAECONNABORTED)
 #define ACR_STATUS_IS_ECONNRESET(s)     ((s) == ACR_ECONNRESET \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
-                || (s) == ACR_OS_START_SYSERR + WSAECONNRESET)
+                || (s) == ERROR_NETNAME_DELETED \
+                || (s) == WSAECONNRESET)
 /* Include WSA codes in TIMEUP */
 #undef ACR_STATUS_IS_TIMEUP
 #define ACR_STATUS_IS_TIMEUP(s)         ((s) == ACR_TIMEUP \
-                || (s) == ACR_OS_START_SYSERR + WSAETIMEDOUT \
+                || (s) == WSAETIMEDOUT \
                 || (s) == ACR_OS_START_SYSERR + WAIT_TIMEOUT)
 #define ACR_STATUS_IS_EHOSTUNREACH(s)   ((s) == ACR_EHOSTUNREACH \
-                || (s) == ACR_OS_START_SYSERR + WSAEHOSTUNREACH)
+                || (s) == WSAEHOSTUNREACH)
 #define ACR_STATUS_IS_ENETUNREACH(s)    ((s) == ACR_ENETUNREACH \
-                || (s) == ACR_OS_START_SYSERR + WSAENETUNREACH)
+                || (s) == WSAENETUNREACH)
 #define ACR_STATUS_IS_EFTYPE(s)         ((s) == ACR_EFTYPE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_DLL \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
-                || (s) == ACR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
-                || (s) == ACR_OS_START_SYSERR + ERROR_BAD_FORMAT)
+                || (s) == ERROR_EXE_MACHINE_TYPE_MISMATCH \
+                || (s) == ERROR_INVALID_DLL \
+                || (s) == ERROR_INVALID_MODULETYPE \
+                || (s) == ERROR_BAD_EXE_FORMAT \
+                || (s) == ERROR_INVALID_EXE_SIGNATURE \
+                || (s) == ERROR_FILE_CORRUPT \
+                || (s) == ERROR_BAD_FORMAT)
 #define ACR_STATUS_IS_EPIPE(s)          ((s) == ACR_EPIPE \
-                || (s) == ACR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
+                || (s) == ERROR_BROKEN_PIPE)
 #define ACR_STATUS_IS_EXDEV(s)          ((s) == ACR_EXDEV \
-                || (s) == ACR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+                || (s) == ERROR_NOT_SAME_DEVICE)
 #define ACR_STATUS_IS_ENOTEMPTY(s)      ((s) == ACR_ENOTEMPTY \
-                || (s) == ACR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
+                || (s) == ERROR_DIR_NOT_EMPTY)
 #define ACR_STATUS_IS_EAFNOSUPPORT(s)   ((s) == ACR_EAFNOSUPPORT \
-                || (s) == ACR_OS_START_SYSERR + WSAEAFNOSUPPORT)
+                || (s) == WSAEAFNOSUPPORT)
 
 #else /* !defined(WIN32) */
 

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=813678&r1=813677&r2=813678&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
Fri Sep 11 06:50:12 2009
@@ -64,7 +64,11 @@
 #endif
 
 #define ACR_INLINE      __inline
+#if (_MSC_VER >= 1200)
 #define ACR_FORCEINLINE __forceinline
+#else
+#define ACR_FORCEINLINE __inline
+#endif
 
 #define ACR_INT64_T_FMT          "I64d"
 #define ACR_UINT64_T_FMT         "I64u"

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=813678&r1=813677&r2=813678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Fri Sep 11 06:50:12 2009
@@ -272,7 +272,7 @@
 static char *stuffunknown(char *buf, acr_size_t bufsize, int statcode)
 {
     if (statcode > ACR_OS_START_CANONERR && statcode < ACR_OS_LAST_CANONERR)
{
-        strlcpy(buf,_canon_errlist[statcode - ACR_OS_START_CANONERR], bufsize);
+        strlcpy(buf, _canon_errlist[statcode - ACR_OS_START_CANONERR], bufsize);
     }
     else
         snprintf(buf, bufsize, "Unrecognized ACR error code %d", statcode);
@@ -522,7 +522,7 @@
         }
     }
 
-    SetLastError(oserror - ACR_OS_START_SYSERR);
+    SetLastError(oserror);
 }
 
 int acr_get_os_error()
@@ -530,7 +530,7 @@
     int   i, crt;
     DWORD os;
     if ((os = GetLastError()))
-        return os + ACR_OS_START_SYSERR;
+        return os;
     crt = errno;
     for (i = 0; crt, i < ACR_COUNTOF(_psx_errlist); i++) {
         if (crt == _psx_errlist[i].posix_error)
@@ -543,45 +543,7 @@
 
 static char *acr_os_strerror(char *buf, acr_size_t bufsize, int errcode)
 {
-    DWORD len = 0;
-    int i;
-
-    len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
-                         FORMAT_MESSAGE_IGNORE_INSERTS,
-                         NULL,
-                         errcode,
-                         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
-                         buf,
-                         (DWORD)bufsize,
-                         NULL);
-    if (!len) {
-        for (i = 0; _ws2_errlist[i].msg; i++) {
-            if (_ws2_errlist[i].code == errcode) {
-                strlcpy(buf, _ws2_errlist[i].msg, bufsize);
-                return buf;
-            }
-        }
-    }
-
-    if (len) {
-        /* FormatMessage put the message in the buffer, but it may
-         * have embedded a newline (\r\n), and possible more than one.
-         * Remove the newlines replacing them with a space. This is not
-         * as visually perfect as moving all the remaining message over,
-         * but more efficient.
-         */
-        while (len--) {
-            if ((buf[len] == '\r') || (buf[len] == '\n'))
-                buf[len] = ' ';
-        }
-    }
-    else {
-        /* Windows didn't provide us with a message.  Even stuff like
-         * WSAECONNREFUSED won't get a message.
-         */
-        snprintf(buf, bufsize, "Unrecognized Win32 error code %d", errcode);
-    }
-
+    snprintf(buf, bufsize, "Unrecognized Win32 error code %d", errcode);
     return buf;
 }
 
@@ -591,9 +553,9 @@
  */
 static char *acr_os_strerror(char* buf, acr_size_t bufsize, int err)
 {
-#if !defined(WIN32) && !defined(HPUX11)
+#if !defined(HPUX11)
     return stuffbuffer(buf, bufsize, hstrerror(err));
-#else /* WIN32 */
+#else /* HPUX11 */
     const char *msg;
 
     switch(err) {
@@ -620,7 +582,51 @@
 }
 #endif
 
-#if HAVE_STRERROR_R
+#if defined (WIN32)
+static char *native_strerror(int statcode, char *buf,
+                             acr_size_t bufsize)
+{
+    DWORD len = 0;
+    int i;
+
+    if (statcode > WSABASEERR) {
+        for (i = 0; _ws2_errlist[i].msg; i++) {
+            if (_ws2_errlist[i].code == statcode) {
+                strlcpy(buf, _ws2_errlist[i].msg, bufsize);
+                return buf;
+            }
+        }
+    }
+    len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+                         FORMAT_MESSAGE_IGNORE_INSERTS,
+                         NULL,
+                         statcode,
+                         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+                         buf,
+                         (DWORD)bufsize,
+                         NULL);
+    if (len) {
+        /* FormatMessage put the message in the buffer, but it may
+         * have embedded a newline (\r\n), and possible more than one.
+         * Remove the newlines replacing them with a space. This is not
+         * as visually perfect as moving all the remaining message over,
+         * but more efficient.
+         */
+        while (len--) {
+            if ((buf[len] == '\r') || (buf[len] == '\n'))
+                buf[len] = ' ';
+        }
+    }
+    else {
+        /* Windows didn't provide us with a message.  Even stuff like
+         * WSAECONNREFUSED won't get a message.
+         */
+        snprintf(buf, bufsize, "Unrecognized Win32 error code %d", statcode);
+    }
+
+    return buf;
+}
+#elif HAVE_STRERROR_R
 /* glibc style */
 static char *native_strerror(int statcode, char *buf,
                              acr_size_t bufsize)
@@ -661,8 +667,11 @@
 ACR_DECLARE(char *) ACR_GetErrorString(int statcode, char *buf,
                                        acr_size_t bufsize)
 {
-
-    if (statcode < ACR_OS_START_ERROR) {
+    if (statcode == 0) {
+        strlcpy(buf, _canon_errlist[0], bufsize);
+        return buf;
+    }
+    else if (statcode < ACR_OS_START_ERROR) {
         return native_strerror(statcode, buf, bufsize);
     }
     else if (statcode < ACR_OS_START_USERERR) {



Mime
View raw message