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/09/07 08:38:03 UTC
svn commit: r812006 - in /commons/sandbox/runtime/trunk/src/main/native: ./
include/ os/unix/ os/win32/ shared/ test/
Author: mturk
Date: Mon Sep 7 06:38:02 2009
New Revision: 812006
URL: http://svn.apache.org/viewvc?rev=812006&view=rev
Log:
Some fixes
Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_endian.h (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/configure
commons/sandbox/runtime/trunk/src/main/native/include/acr_crypto.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_xdr.h
commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
commons/sandbox/runtime/trunk/src/main/native/shared/md5.c
commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c
commons/sandbox/runtime/trunk/src/main/native/test/testcase.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=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Mon Sep 7 06:38:02 2009
@@ -891,6 +891,7 @@
#define HAVE_ARPA_INET_H `have_include arpa/inet`
#define HAVE_RESOLV_H `have_include resolv`
#define HAVE_SYS_UN_H `have_include sys/un`
+#define HAVE_UCONTEXT_H `have_include ucontext`
#define HAVE_STRERROR_R $have_strerror_r
#define HAVE_MMAP64 $have_mmap64
#define HAVE_FDATASYNC $have_fdatasync
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_crypto.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_crypto.h?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_crypto.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_crypto.h Mon Sep 7 06:38:02 2009
@@ -231,6 +231,9 @@
* @param clear The plaintext data.
* @param len The length of the plaintext data
* @param out The encrypted/encoded password
+ * @note Required output string length is ACR_SHA512_DIGEST_STRING_LENGTH.
+ * In case out is NULL new string is allocated using malloc and
+ * it must be deallocated when no longer needed.
*/
ACR_DECLARE(wchar_t *) ACR_SHA512EncodeW(const wchar_t *clear, size_t len,
wchar_t *out);
@@ -285,6 +288,9 @@
* @param clear The plaintext data.
* @param len The length of the plaintext data
* @param out The encrypted/encoded password
+ * @note Required output string length is ACR_MD5_DIGEST_STRING_LENGTH.
+ * In case out is NULL new string is allocated using malloc and
+ * it must be deallocated when no longer needed.
*/
ACR_DECLARE(char *) ACR_MD5EncodeA(const char *clear, size_t len, char *out);
@@ -294,10 +300,37 @@
* @param clear The plaintext data.
* @param len The length of the plaintext data
* @param out The encrypted/encoded password
+ * @note Required output string length is ACR_MD5_DIGEST_STRING_LENGTH.
+ * In case out is NULL new string is allocated using malloc and
+ * it must be deallocated when no longer needed.
*/
ACR_DECLARE(wchar_t *) ACR_MD5EncodeW(const wchar_t *clear, size_t len,
wchar_t *out);
+/**
+ * Provide a means to MD5 crypt/encode a plaintext data using
+ * base 16 hexadecimal encoding and UUID like format.
+ * @param clear The plaintext data.
+ * @param len The length of the plaintext data
+ * @param out The encrypted/encoded password
+ * @note Required output string length is ACR_MD5_DIGEST_STRING_LENGTH + 4.
+ * In case out is NULL new string is allocated using malloc and
+ * it must be deallocated when no longer needed.
+ */
+ACR_DECLARE(char *) ACR_MD5EncUuidA(const char *clear, size_t len, char *out);
+
+/**
+ * Provide a means to MD5 crypt/encode a plaintext data using
+ * base 16 hexadecimal encoding and UUID like format.
+ * @param clear The plaintext data.
+ * @param len The length of the plaintext data
+ * @param out The encrypted/encoded password
+ * @note Required output string length is ACR_MD5_DIGEST_STRING_LENGTH + 4.
+ * In case out is NULL new string is allocated using malloc and
+ * it must be deallocated when no longer needed.
+ */
+ACR_DECLARE(wchar_t *) ACR_MD5EncUuidW(const wchar_t *clear, size_t len,
+ wchar_t *out);
/**
* Determine the maximum buffer length required to decode the plain text
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_endian.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_endian.h?rev=812006&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_endian.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_endian.h Mon Sep 7 06:38:02 2009
@@ -0,0 +1,199 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACR_ENDIAN_H
+#define _ACR_ENDIAN_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_endian.h
+ * @brief
+ *
+ * ACR Endian (byte order) conversion macros.
+ *
+ */
+
+/**
+ * Conversion target constants for using with ACR_P_ macros
+ * depending on the machines byte order.
+ */
+#if CC_IS_BIG_ENDIAN
+#define ACR_TO_BE 0
+#define ACR_TO_LE 1
+#else
+#define ACR_TO_BE 1
+#define ACR_TO_LE 0
+#endif
+
+/**
+ * Encode 16 bit value to byte buffer.
+ * If M is non zero byte ordering is swapped.
+ * ACR_P_ macros can be used on both big and little endian
+ * machines. M should be zero if target endian matches the
+ * machine endian.
+ */
+#define ACR_P_16_ENC(M, B, V) \
+ if ((M)) { \
+ *((B)++) = (acr_byte_t)(((V) >> 8) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 0) & 0xFF); \
+ } else { \
+ *((acr_uint16_t *)(void *)(B)) = (acr_uint16_t)(V); \
+ ((B)) += 2; } (void)(0)
+
+#define ACR_P_32_ENC(M, B, V) \
+ if ((M)) { \
+ *((B)++) = (acr_byte_t)(((V) >> 24) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 16) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 8) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 0) & 0xFF); \
+ } else { \
+ *((acr_uint32_t *)(void *)(B)) = (acr_uint32_t)(V); \
+ ((B)) += 4; } (void)(0)
+
+#define ACR_P_64_ENC(M, B, V) \
+ if ((M)) { \
+ *((B)++) = (acr_byte_t)(((V) >> 56) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 48) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 40) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 32) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 24) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 16) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 8) & 0xFF); \
+ *((B)++) = (acr_byte_t)(((V) >> 0) & 0xFF); \
+ } else { \
+ *((acr_uint64_t *)(void *)(B)) = (acr_uint64_t)(V); \
+ ((B)) += 8; } (void)(0)
+
+#define ACR_P_16_DEC(M, B, V) \
+ if ((M)) { \
+ (V) |= (acr_uint16_t)(*((B)++) & 0xFF) << 8; \
+ (V) |= (acr_uint16_t)(*((B)++) & 0xFF); \
+ } else { \
+ (V) = *((acr_uint16_t *)(void *)(B)); \
+ ((B)) += 2; } (void)(0)
+
+#define ACR_P_32_DEC(M, B, V) \
+ if ((M)) { \
+ (V) = (acr_uint32_t)(*((B)++) & 0xFF) << 24; \
+ (V) |= (acr_uint32_t)(*((B)++) & 0xFF) << 16; \
+ (V) |= (acr_uint32_t)(*((B)++) & 0xFF) << 8; \
+ (V) |= (acr_uint32_t)(*((B)++) & 0xFF); \
+ } else { \
+ (V) = *((acr_uint32_t *)(void *)(B)); \
+ ((B)) += 4; } (void)(0)
+
+#define ACR_P_64_DEC(M, B, V) \
+ if ((M)) { \
+ (V) = (acr_uint64_t)(*((B)++) & 0xFF) << 56; \
+ (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 48; \
+ (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 40; \
+ (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 32; \
+ (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 24; \
+ (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 16; \
+ (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 8; \
+ (V) |= (acr_uint64_t)(*( B) & 0xFF); \
+ } else { \
+ (V) = *((acr_uint64_t *)(void *)(B)); \
+ ((B)) += 8; } (void)(0)
+
+/**
+ * Little endian <-> big endian swap macros.
+ * ACR_M_XX_SWAP swap a memory location
+ * ACR_P_XX_SWAP swap a referenced memory location
+ */
+#define ACR_M_16_SWAP(M, A) \
+ ACR_TEST_MACRO(M) \
+ acr_uint32_t _tmp = (A); \
+ ((char *)(void *)&(A))[0] = ((char *)(void *)&_tmp)[1]; \
+ ((char *)(void *)&(A))[1] = ((char *)(void *)&_tmp)[0]; \
+ ACR_END_MACRO
+
+#define ACR_P_16_SWAP(M, A) \
+ ACR_TEST_MACRO(M) \
+ char _tmp[2]; \
+ _tmp[0] = ((char *)(void *)(A))[0]; \
+ _tmp[1] = ((char *)(void *)(A))[1]; \
+ ((char *)(void *)(A))[0] = _tmp[1]; \
+ ((char *)(void *)(A))[1] = _tmp[0]; \
+ ACR_END_MACRO
+
+#define ACR_M_32_SWAP(M, A) \
+ ACR_TEST_MACRO(M) \
+ acr_uint32_t _tmp = (A); \
+ ((char *)(void *)&(A))[0] = ((char *)(void *)&_tmp)[3]; \
+ ((char *)(void *)&(A))[1] = ((char *)(void *)&_tmp)[2]; \
+ ((char *)(void *)&(A))[2] = ((char *)(void *)&_tmp)[1]; \
+ ((char *)(void *)&(A))[3] = ((char *)(void *)&_tmp)[0]; \
+ ACR_END_MACRO
+
+#define ACR_P_32_SWAP(M, A) \
+ ACR_TEST_MACRO(M) \
+ char _tmp[4]; \
+ _tmp[0] = ((char *)(void *)(A))[0]; \
+ _tmp[1] = ((char *)(void *)(A))[1]; \
+ _tmp[2] = ((char *)(void *)(A))[2]; \
+ _tmp[3] = ((char *)(void *)(A))[3]; \
+ ((char *)(void *)(A))[0] = _tmp[3]; \
+ ((char *)(void *)(A))[1] = _tmp[2]; \
+ ((char *)(void *)(A))[2] = _tmp[1]; \
+ ((char *)(void *)(A))[3] = _tmp[0]; \
+ ACR_END_MACRO
+
+#define ACR_M_64_SWAP(M, A) \
+ ACR_TEST_MACRO(M) \
+ acr_uint64_t _tmp = (A); \
+ ((char *)(void *)&(A))[0] = ((char *)(void *)&_tmp)[7]; \
+ ((char *)(void *)&(A))[1] = ((char *)(void *)&_tmp)[6]; \
+ ((char *)(void *)&(A))[2] = ((char *)(void *)&_tmp)[5]; \
+ ((char *)(void *)&(A))[3] = ((char *)(void *)&_tmp)[4]; \
+ ((char *)(void *)&(A))[4] = ((char *)(void *)&_tmp)[3]; \
+ ((char *)(void *)&(A))[5] = ((char *)(void *)&_tmp)[2]; \
+ ((char *)(void *)&(A))[6] = ((char *)(void *)&_tmp)[1]; \
+ ((char *)(void *)&(A))[7] = ((char *)(void *)&_tmp)[0]; \
+ ACR_END_MACRO
+
+#define ACR_P_64_SWAP(M, A) \
+ ACR_TEST_MACRO(M) \
+ char _tmp[8]; \
+ _tmp[0] = ((char *)(void *)(A))[0]; \
+ _tmp[1] = ((char *)(void *)(A))[1]; \
+ _tmp[2] = ((char *)(void *)(A))[2]; \
+ _tmp[3] = ((char *)(void *)(A))[3]; \
+ _tmp[4] = ((char *)(void *)(A))[4]; \
+ _tmp[5] = ((char *)(void *)(A))[5]; \
+ _tmp[6] = ((char *)(void *)(A))[6]; \
+ _tmp[7] = ((char *)(void *)(A))[7]; \
+ ((char *)(void *)(A))[0] = _tmp[7]; \
+ ((char *)(void *)(A))[1] = _tmp[6]; \
+ ((char *)(void *)(A))[2] = _tmp[5]; \
+ ((char *)(void *)(A))[3] = _tmp[4]; \
+ ((char *)(void *)(A))[4] = _tmp[3]; \
+ ((char *)(void *)(A))[5] = _tmp[2]; \
+ ((char *)(void *)(A))[6] = _tmp[1]; \
+ ((char *)(void *)(A))[7] = _tmp[0]; \
+ ACR_END_MACRO
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_ENDIAN_H */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_endian.h
------------------------------------------------------------------------------
svn:eol-style = native
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=812006&r1=812005&r2=812006&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 Mon Sep 7 06:38:02 2009
@@ -69,19 +69,19 @@
#else
#include <signal.h>
#include <setjmp.h>
-
+#if HAVE_UCONTEXT_H
+#include <ucontext.h>
+#endif
#if HAVE_SIGSETJMP
#define SEH_SETJMP(E) sigsetjmp((E), 1)
#define SEH_DOJUMP(E, V) siglongjmp((E), (V))
-#define SEH_JMPBUF sigjmp_buf
#else
#define SEH_SETJMP(E) setjmp((E))
#define SEH_DOJUMP(E, V) longjmp((E), (V))
-#define SEH_JMPBUF jmp_buf
#endif
static void _seh_handler(int val)
{
- acr_thread_local_t *tlsd = ACR_GetTLSD();
+ acr_thread_local_t *tlsd = ACR_TLSD();
if (tlsd && (val == SIGSEGV || val == SIGBUS)) {
SEH_DOJUMP(tlsd->seh_jump, val);
}
@@ -90,7 +90,7 @@
#define ACR_TRY \
int _seh_error = 0; \
{ \
- acr_thread_local_t *_tlsd = ACR_GetTLSD(); \
+ acr_thread_local_t *_tlsd = ACR_TLSD(); \
void* _org_sigseg_handler = signal(SIGSEGV, _seh_handler); \
void* _org_sigbus_handler = signal(SIGBUS, _seh_handler); \
if (_tlsd && (_seh_error = SEH_SETJMP(_tlsd->seh_jump))) \
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h Mon Sep 7 06:38:02 2009
@@ -19,11 +19,12 @@
#include "acr.h"
#include "acr_ring.h"
-#if defined(WIN32)
-
-#else
+#if !defined(WIN32)
#include <signal.h>
#include <setjmp.h>
+#if HAVE_UCONTEXT_H
+#include <ucontext.h>
+#endif
#endif
#ifdef __cplusplus
@@ -48,17 +49,27 @@
struct acr_thread_local_t {
ACR_RING_HEAD(tlsd_data_t, acr_tlsd_data_t) data_ring;
- JNIEnv *env;
- int jvm_attached;
+ JNIEnv *env;
+ int jvm_attached;
+#if defined(DEBUG)
#if defined(WIN32)
-
+ /* SEH requires no special TLSD data
+ * on Windows
+ */
#else
+#if HAVE_UCONTEXT_H
+ /* TODO: Use setcontext instead jump
+ * However it just might be an overhead.
+ */
+ ucontext_t seh_uctx;
+#endif
#if HAVE_SIGSETJMP
sigjmp_buf seh_jump;
#else
jmp_buf seh_jump;
-#endif
-#endif
+#endif /* HAVE_SIGSETJMP */
+#endif /* WIN32 */
+#endif /* DEBUG */
};
/**
@@ -67,7 +78,7 @@
* returned is the static data that will be overwritten by the
* next thread.
*/
-ACR_DECLARE(acr_thread_local_t *) ACR_GetTLSD(void);
+ACR_DECLARE(acr_thread_local_t *) ACR_TLSD(void);
/**
* Add the data to the current thread local storage data.
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_xdr.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_xdr.h?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_xdr.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_xdr.h Mon Sep 7 06:38:02 2009
@@ -43,147 +43,6 @@
#define H2N32(V) (arc_uint32_t)htonl((acr_uint32_t)(V))
#define N2H32(V) (arc_uint32_t)ntohl((acr_uint32_t)(V))
-#define ACR_P_16_ENC(M, B, V) \
- if ((M)) { \
- *((B)++) = (acr_byte_t)(((V) >> 8) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 0) & 0xFF); \
- } else { \
- *((acr_uint16_t *)(void *)(B)) = (acr_uint16_t)(V); \
- ((B)) += 2; } (void)(0)
-
-#define ACR_P_32_ENC(M, B, V) \
- if ((M)) { \
- *((B)++) = (acr_byte_t)(((V) >> 24) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 16) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 8) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 0) & 0xFF); \
- } else { \
- *((acr_uint32_t *)(void *)(B)) = (acr_uint32_t)(V); \
- ((B)) += 4; } (void)(0)
-
-#define ACR_P_64_ENC(M, B, V) \
- if ((M)) { \
- *((B)++) = (acr_byte_t)(((V) >> 56) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 48) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 40) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 32) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 24) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 16) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 8) & 0xFF); \
- *((B)++) = (acr_byte_t)(((V) >> 0) & 0xFF); \
- } else { \
- *((acr_uint64_t *)(void *)(B)) = (acr_uint64_t)(V); \
- ((B)) += 8; } (void)(0)
-
-#define ACR_P_16_DEC(M, B, V) \
- if ((M)) { \
- (V) |= (acr_uint16_t)(*((B)++) & 0xFF) << 8; \
- (V) |= (acr_uint16_t)(*((B)++) & 0xFF); \
- } else { \
- (V) = *((acr_uint16_t *)(void *)(B)); \
- ((B)) += 2; } (void)(0)
-
-#define ACR_P_32_DEC(M, B, V) \
- if ((M)) { \
- (V) = (acr_uint32_t)(*((B)++) & 0xFF) << 24; \
- (V) |= (acr_uint32_t)(*((B)++) & 0xFF) << 16; \
- (V) |= (acr_uint32_t)(*((B)++) & 0xFF) << 8; \
- (V) |= (acr_uint32_t)(*((B)++) & 0xFF); \
- } else { \
- (V) = *((acr_uint32_t *)(void *)(B)); \
- ((B)) += 4; } (void)(0)
-
-#define ACR_P_64_DEC(M, B, V) \
- if ((M)) { \
- (V) = (acr_uint64_t)(*((B)++) & 0xFF) << 56; \
- (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 48; \
- (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 40; \
- (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 32; \
- (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 24; \
- (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 16; \
- (V) |= (acr_uint64_t)(*((B)++) & 0xFF) << 8; \
- (V) |= (acr_uint64_t)(*( B) & 0xFF); \
- } else { \
- (V) = *((acr_uint64_t *)(void *)(B)); \
- ((B)) += 8; } (void)(0)
-
-/**
- * Little endian <==> big endian swap macros.
- * ACR_M_XX_SWAP swap a memory location
- * ACR_P_XX_SWAP swap a referenced memory location
- */
-#define ACR_M_16_SWAP(M, A) \
- ACR_TEST_MACRO(M) \
- acr_uint32_t _tmp = (A); \
- ((char *)(void *)&(A))[0] = ((char *)(void *)&_tmp)[1]; \
- ((char *)(void *)&(A))[1] = ((char *)(void *)&_tmp)[0]; \
- ACR_END_MACRO
-
-#define ACR_P_16_SWAP(M, A) \
- ACR_TEST_MACRO(M) \
- char _tmp[2]; \
- _tmp[0] = ((char *)(void *)(A))[0]; \
- _tmp[1] = ((char *)(void *)(A))[1]; \
- ((char *)(void *)(A))[0] = _tmp[1]; \
- ((char *)(void *)(A))[1] = _tmp[0]; \
- ACR_END_MACRO
-
-#define ACR_M_32_SWAP(M, A) \
- ACR_TEST_MACRO(M) \
- acr_uint32_t _tmp = (A); \
- ((char *)(void *)&(A))[0] = ((char *)(void *)&_tmp)[3]; \
- ((char *)(void *)&(A))[1] = ((char *)(void *)&_tmp)[2]; \
- ((char *)(void *)&(A))[2] = ((char *)(void *)&_tmp)[1]; \
- ((char *)(void *)&(A))[3] = ((char *)(void *)&_tmp)[0]; \
- ACR_END_MACRO
-
-#define ACR_P_32_SWAP(M, A) \
- ACR_TEST_MACRO(M) \
- char _tmp[4]; \
- _tmp[0] = ((char *)(void *)(A))[0]; \
- _tmp[1] = ((char *)(void *)(A))[1]; \
- _tmp[2] = ((char *)(void *)(A))[2]; \
- _tmp[3] = ((char *)(void *)(A))[3]; \
- ((char *)(void *)(A))[0] = _tmp[3]; \
- ((char *)(void *)(A))[1] = _tmp[2]; \
- ((char *)(void *)(A))[2] = _tmp[1]; \
- ((char *)(void *)(A))[3] = _tmp[0]; \
- ACR_END_MACRO
-
-#define ACR_M_64_SWAP(M, A) \
- ACR_TEST_MACRO(M) \
- acr_uint64_t _tmp = (A); \
- ((char *)(void *)&(A))[0] = ((char *)(void *)&_tmp)[7]; \
- ((char *)(void *)&(A))[1] = ((char *)(void *)&_tmp)[6]; \
- ((char *)(void *)&(A))[2] = ((char *)(void *)&_tmp)[5]; \
- ((char *)(void *)&(A))[3] = ((char *)(void *)&_tmp)[4]; \
- ((char *)(void *)&(A))[4] = ((char *)(void *)&_tmp)[3]; \
- ((char *)(void *)&(A))[5] = ((char *)(void *)&_tmp)[2]; \
- ((char *)(void *)&(A))[6] = ((char *)(void *)&_tmp)[1]; \
- ((char *)(void *)&(A))[7] = ((char *)(void *)&_tmp)[0]; \
- ACR_END_MACRO
-
-#define ACR_P_64_SWAP(M, A) \
- ACR_TEST_MACRO(M) \
- char _tmp[8]; \
- _tmp[0] = ((char *)(void *)(A))[0]; \
- _tmp[1] = ((char *)(void *)(A))[1]; \
- _tmp[2] = ((char *)(void *)(A))[2]; \
- _tmp[3] = ((char *)(void *)(A))[3]; \
- _tmp[4] = ((char *)(void *)(A))[4]; \
- _tmp[5] = ((char *)(void *)(A))[5]; \
- _tmp[6] = ((char *)(void *)(A))[6]; \
- _tmp[7] = ((char *)(void *)(A))[7]; \
- ((char *)(void *)(A))[0] = _tmp[7]; \
- ((char *)(void *)(A))[1] = _tmp[6]; \
- ((char *)(void *)(A))[2] = _tmp[5]; \
- ((char *)(void *)(A))[3] = _tmp[4]; \
- ((char *)(void *)(A))[4] = _tmp[3]; \
- ((char *)(void *)(A))[5] = _tmp[2]; \
- ((char *)(void *)(A))[6] = _tmp[1]; \
- ((char *)(void *)(A))[7] = _tmp[0]; \
- ACR_END_MACRO
-
typedef struct acr_xdr_t {
int swap;
size_t size;
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Mon Sep 7 06:38:02 2009
@@ -112,7 +112,7 @@
return JNI_VERSION_1_4;
}
-ACR_DECLARE(acr_thread_local_t *) ACR_GetTLSD()
+ACR_DECLARE(acr_thread_local_t *) ACR_TLSD()
{
acr_thread_local_t *tlsd;
@@ -173,9 +173,10 @@
void *epp = NULL;
if (acr_pvm == NULL) {
+ ACR_SET_OS_ERROR(ACR_INCOMPLETE);
return NULL;
}
- tlsd = ACR_GetTLSD();
+ tlsd = ACR_TLSD();
if (tlsd->env == NULL) {
if ((*acr_pvm)->GetEnv(acr_pvm, &epp,
JNI_VERSION_1_4) == JNI_EDETACHED) {
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c Mon Sep 7 06:38:02 2009
@@ -31,7 +31,7 @@
* Each version of MSVCRT has its own _putenv() call in the runtime
* library.
*
- * If we're in VC 7.0 or later (means != mingw), update in the 6.0
+ * If we're in VC 7.0 or later, update in the 6.0
* MSVCRT.DLL environment as well, to work with third party libraries
* linked against it (such as gnuwin32 libraries).
*/
@@ -58,6 +58,8 @@
*(cp++) = '\0';
if (strlen(cp)) {
/*
+ * ###: CRT should call the SetEnvironmentVariable so this
+ * might be an overhead.
* Only call SetEnvironmentVariable() when we are adding a variable,
* not when removing it. Calling it on both crashes on at least
* certain versions of MingW.
@@ -83,7 +85,7 @@
* Each version of MSVCRT has its own _putenv() call in the runtime
* library.
*
- * If we're in VC 7.0 or later (means != mingw), update in the 6.0
+ * If we're in VC 7.0 or later, update in the 6.0
* MSVCRT.DLL environment as well, to work with third party libraries
* linked against it (such as gnuwin32 libraries).
*/
@@ -130,12 +132,16 @@
char *estr;
if (!var || !*var || !val) {
+ ACR_SET_OS_ERROR(ACR_EINVAL);
errno = EINVAL;
return -1;
}
estr = (char *)malloc(strlen(var) + strlen(val) + 2);
- if (!estr) /* not much we can do if no memory */
+ if (!estr) {
+ /* not much we can do if no memory */
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
return -1;
+ }
/* Override the existing setting by forcibly defining the var */
sprintf(estr, "%s=%s", var, val);
@@ -161,8 +167,11 @@
if (getenv(var) == NULL)
return 0; /* no work */
estr = (char *)malloc(strlen(var) + 2);
- if (!estr) /* not much we can do if no memory */
+ if (!estr) {
+ /* not much we can do if no memory */
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
return -1;
+ }
/* Override the existing setting by forcibly defining the var */
sprintf(estr, "%s=", var);
@@ -193,8 +202,11 @@
}
elen = (wcslen(var) + wcslen(val) + 2) * sizeof(wchar_t);
estr = (wchar_t *)malloc(elen);
- if (!estr) /* not much we can do if no memory */
+ if (!estr) {
+ /* not much we can do if no memory */
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
return -1;
+ }
/* Override the existing setting by forcibly defining the var */
#if _MSC_VER >= 1300
@@ -226,9 +238,11 @@
return 0; /* no work */
elen = (wcslen(var) + 2) * sizeof(wchar_t);
estr = (wchar_t *)malloc(elen);
- if (!estr) /* not much we can do if no memory */
+ if (!estr) {
+ /* not much we can do if no memory */
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
return -1;
-
+ }
/* Override the existing setting by forcibly defining the var */
#if _MSC_VER >= 1300
swprintf(estr, elen, L"%s=", var);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Mon Sep 7 06:38:02 2009
@@ -72,6 +72,7 @@
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
+ ULONG heap_value = 2; /* This enables low fragmentation heap */
acr_thread_local_t *tlsd;
switch (reason) {
@@ -81,11 +82,23 @@
case DLL_PROCESS_ATTACH:
dll_instance = instance;
GetModuleFileNameW(instance, dll_file_name, ACR_HBUFF_LEN);
- dll_heap_handle = GetProcessHeap();
+ dll_heap_handle = HeapCreate(0, 0, 0);
if (!dll_heap_handle) {
/* No point to continue if we are missing the process heap */
return FALSE;
}
+ if (!HeapSetInformation(dll_heap_handle,
+ HeapCompatibilityInformation,
+ &heap_value,
+ sizeof(heap_value))) {
+ /* Failed setting LFH */
+ HeapDestory(dll_heap_handle);
+ return FALSE;
+ }
+ if ((dll_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) {
+ /* No point to continue if we cannot have TLSD */
+ return FALSE;
+ }
break;
/** The attached process creates a new thread.
*/
@@ -105,14 +118,6 @@
* or FreeLibrary.
*/
case DLL_PROCESS_DETACH:
- if (acr_everyone_sid) {
- ACR_HeapFree(acr_everyone_sid);
- acr_everyone_sid = NULL;
- }
- if (acr_adminsgr_sid) {
- ACR_HeapFree(acr_adminsgr_sid);
- acr_adminsgr_sid = NULL;
- }
if (dll_tls_index != TLS_OUT_OF_INDEXES) {
tlsd = (acr_thread_local_t *)TlsGetValue(dll_tls_index);
if (tlsd) {
@@ -120,6 +125,7 @@
}
TlsFree(dll_tls_index);
}
+ HeapDestory(dll_heap_handle);
dll_instance = NULL;
break;
default:
@@ -266,6 +272,15 @@
acr_pvm = vm;
+ /* XXX: Can we come here if the DllMain returned FALSE? */
+ if (dll_tls_index == TLS_OUT_OF_INDEXES) {
+#if defined(DEBUG)
+ fprintf(stderr, "Missing thread local storage (TLS) index.\n"
+ "Cannot continue.\n");
+ fflush(stderr);
+#endif
+ return ACR_ENOMEM;
+ }
GetSystemInfo(acr_osinf);
acr_osver->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
GetVersionExA((LPOSVERSIONINFOA)acr_osver);
@@ -284,10 +299,6 @@
if (initialized++)
return 0;
- /* Allocate a TLS index. */
- if ((dll_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) {
- return ACR_GET_OS_ERROR();
- }
while (sePrivileges[i]) {
if ((rc = ACR_EnablePrivilege(sePrivileges[i])) != ERROR_SUCCESS) {
WCHAR buf[128];
@@ -344,10 +355,12 @@
return JNI_VERSION_1_4;
}
-ACR_DECLARE(acr_thread_local_t *) ACR_GetTLSD()
+ACR_DECLARE(acr_thread_local_t *) ACR_TLSD()
{
acr_thread_local_t *tlsd;
+ if (dll_tls_index == TLS_OUT_OF_INDEXES)
+ return &_null_tlsd;
tlsd = (acr_thread_local_t *)TlsGetValue(dll_tls_index);
if (tlsd == NULL) {
tlsd = ACR_HeapCalloc(sizeof(acr_thread_local_t));
@@ -369,26 +382,34 @@
acr_tlsd_data_t *node;
acr_thread_local_t *tlsd;
+ if (dll_tls_index == TLS_OUT_OF_INDEXES) {
+ /* Adding data whild being destoyed */
+ return ACR_ENOMEM;
+ }
tlsd = (acr_thread_local_t *)TlsGetValue(dll_tls_index);
if (tlsd == NULL) {
tlsd = ACR_HeapCalloc(sizeof(acr_thread_local_t));
if (tlsd == NULL) {
- return ACR_GET_OS_ERROR();
+ return ACR_ENOMEM;
}
else {
ACR_RING_INIT(&tlsd->data_ring, acr_tlsd_data_t, link);
TlsSetValue(dll_tls_index, tlsd);
}
}
- for (node = ACR_RING_FIRST(&(tlsd->data_ring));
- node != ACR_RING_SENTINEL(&(tlsd->data_ring), acr_tlsd_data_t, link);
- node = ACR_RING_NEXT(node, link)) {
- if (node->data == data)
- return ACR_EEXIST;
+ else {
+ /* Check if we have added this pointer already
+ */
+ for (node = ACR_RING_FIRST(&(tlsd->data_ring));
+ node != ACR_RING_SENTINEL(&(tlsd->data_ring), acr_tlsd_data_t, link);
+ node = ACR_RING_NEXT(node, link)) {
+ if (node->data == data)
+ return ACR_EEXIST;
+ }
}
node = ACR_HeapCalloc(sizeof(acr_tlsd_data_t));
if (!node) {
- return ACR_GET_OS_ERROR();
+ return ACR_ENOMEM;
}
node->data = data;
node->size = size;
@@ -404,9 +425,14 @@
void *epp = NULL;
if (acr_pvm == NULL) {
+ ACR_SET_OS_ERROR(ACR_INCOMPLETE);
+ return NULL;
+ }
+ if (dll_tls_index == TLS_OUT_OF_INDEXES) {
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
return NULL;
}
- tlsd = ACR_GetTLSD();
+ tlsd = ACR_TLSD();
if (tlsd->env == NULL) {
if ((*acr_pvm)->GetEnv(acr_pvm, &epp,
JNI_VERSION_1_4) == JNI_EDETACHED) {
@@ -424,4 +450,3 @@
}
return tlsd->env;
}
-
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c Mon Sep 7 06:38:02 2009
@@ -38,8 +38,10 @@
if (sidlen) {
/* Give it back on the second pass with proper sidlen
*/
- if (!(sid = malloc(sidlen)))
+ if (!(sid = malloc(sidlen))) {
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
return NULL;
+ }
domlen = MAX_PATH;
if (!LookupAccountNameW(NULL, name, sid, &sidlen,
domain, &domlen, sidtype)) {
@@ -201,8 +203,7 @@
}
}
else if (_E) {
- ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ENOMEM,
- ACR_GET_OS_ERROR());
+ ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ENOMEM, ACR_ENOMEM);
}
return sid;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Mon Sep 7 06:38:02 2009
@@ -25,38 +25,68 @@
#include "acr_crypto.h"
#include <direct.h>
-/*
- * XXX: Make sure it is synced with ACR_DT_ types
- */
-static const wchar_t *dtnames[] = {
- L"a0x", /* ACR_DT_UNKNOWN */
- L"a1x", /* ACR_DT_FILE */
- L"a2x", /* ACR_DT_USER */
- L"a3x", /* ACR_DT_GROUP */
- L"a4x", /* ACR_DT_MUTEX */
- L"a5x", /* ACR_DT_SHM */
- L"a6x", /* ACR_DT_PIPE */
- L"a7x", /* ACR_DT_SOCKET */
- L"a8x", /* ACR_DT_DSO */
- NULL
-};
-
#define NON_UNC_PATH_LENGTH 248
wchar_t *res_name_from_filenamew(int type, wchar_t *rname,
const wchar_t *fname)
{
- DWORD rc;
- wchar_t pname[ACR_HBUFF_SIZ];
-
- wcscpy(rname, L"Global\\");
- wcscat(rname, dtnames[type]);
+ DWORD rc = 0;
+ wchar_t pname[ACR_SBUFF_SIZ];
- rc = GetFullPathNameW(fname, ACR_HBUFF_LEN, pname, NULL);
- if (rc == 0 || rc > ACR_HBUFF_LEN)
- ACR_SHA1EncodeW(fname, wcslen(fname), rname + 10);
+ /* Always use the Global namespace.
+ * This requires SeCreateGlobalPrivilege which
+ * we try to enable at startup.
+ */
+#if _MSC_VER >= 1300
+ swprintf(rname, 32,
+#else
+ swprintf(rname,
+#endif
+ L"Global\\a%02x:", (type & 0xFF));
+ if (fname == NULL) {
+ /* Use upper 24 bits for object name.
+ */
+#if _MSC_VER >= 1300
+ swprintf(pname, 16,
+#else
+ swprintf(pname,
+#endif
+ L"%08x:", (type >> 8));
+ rc = 1;
+ }
+ else if (*fname == L'\\' || *fname == '/' ||
+ (iswalpha(*fname) && *(fname + 1) == L':')) {
+ /* Get the real path name so we get the same hash
+ * for the same physical file.
+ */
+ rc = GetFullPathNameW(fname, ACR_SBUFF_LEN, pname, NULL);
+ }
+ if (rc == 0 || rc > ACR_SBUFF_LEN)
+ ACR_MD5EncUuidW(fname, wcslen(fname), rname + 11);
else
- ACR_SHA1EncodeW(pname, wcslen(pname), rname + 10);
+ ACR_MD5EncUuidW(pname, wcslen(pname), rname + 11);
+ return rname;
+}
+
+wchar_t *res_name_from_uuid(wchar_t *rname,
+ const wchar_t *prefix)
+{
+ unsigned char d[16];
+
+ if (FAILED(UuidCreate((UUID *)d))) {
+ /* This should never happen */
+ return res_name_from_filenamew((GetCurrentProcessId() << 8) |
+ GetTickCount(), rname, NULL);
+ }
+#if _MSC_VER >= 1300
+ swprintf(rname, 64,
+#else
+ swprintf(rname,
+#endif
+ L"Global\\res:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
+ d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+
return rname;
}
@@ -184,7 +214,7 @@
if (!(len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
str, -1, NULL, 0))) {
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
- errno = EILSEQ;
+ ACR_SET_OS_ERROR(ACR_EILSEQ);
return NULL;
}
res = malloc(len * sizeof(wchar_t));
@@ -212,14 +242,26 @@
int len;
char *res;
+ /*
+ * ###: We could use here the
+ * wcslen * 4 since any wchar can produce at most 4 chars.
+ * This is memory vs speed tradeof, and if
+ * conversion fails we'd need to destroy pre-allocated memory.
+ * Use Windows API to determine the required destination length.
+ *
+ */
if (!(len = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0,
NULL, NULL))) {
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
errno = EILSEQ;
return NULL;
}
- if (!(res = malloc(len)))
+ if (!(res = malloc(len))) {
+ /* Make sure GetLastError returns ENOMEM
+ */
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
return NULL;
+ }
if (!WideCharToMultiByte(CP_UTF8, 0, str, -1, res, len,
NULL, NULL)) {
DWORD saved = GetLastError();
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/md5.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/md5.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/md5.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/md5.c Mon Sep 7 06:38:02 2009
@@ -329,3 +329,50 @@
return out;
}
+ACR_DECLARE(char *) ACR_MD5EncUuidA(const char *clear, size_t len, char *out)
+{
+ int i, x = 0;
+ acr_md5_ctx_t context;
+ acr_byte_t digest[ACR_MD5_DIGEST_LENGTH];
+
+ if (out == NULL && (out = malloc(ACR_MD5_DIGEST_STRING_LENGTH + 4)) == NULL)
+ return NULL;
+
+ ACR_MD5Init(&context);
+ ACR_MD5UpdateA(&context, clear, len);
+ ACR_MD5Final(digest, &context);
+ for (i = 0; i < ACR_MD5_DIGEST_LENGTH; i++) {
+ if (x == 4 || x == 7 || x == 10 || x == 13)
+ out[x++] = '-';
+ out[x++] = HI_NIBBLE_HEX(digest[i]);
+ out[x++] = LO_NIBBLE_HEX(digest[i]);
+ }
+ out[x] = '\0';
+
+ x_memzero(digest, sizeof(digest));
+ return out;
+}
+
+ACR_DECLARE(wchar_t *) ACR_MD5EncUuidW(const wchar_t *clear, size_t len, wchar_t *out)
+{
+ int i, x = 0;
+ acr_md5_ctx_t context;
+ acr_byte_t digest[ACR_MD5_DIGEST_LENGTH];
+
+ if (out == NULL &&
+ (out = malloc((ACR_MD5_DIGEST_STRING_LENGTH + 4) * sizeof(wchar_t))) == NULL)
+ return NULL;
+ ACR_MD5Init(&context);
+ ACR_MD5UpdateW(&context, clear, len);
+ ACR_MD5Final(digest, &context);
+ for (i = 0; i < ACR_MD5_DIGEST_LENGTH; i++) {
+ if (x == 4 || x == 7 || x == 10 || x == 13)
+ out[x++] = L'-';
+ out[x++] = HI_NIBBLE_HEX(digest[i]);
+ out[x++] = LO_NIBBLE_HEX(digest[i]);
+ }
+ out[x] = L'\0';
+
+ x_memzero(digest, sizeof(digest));
+ return out;
+}
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Mon Sep 7 06:38:02 2009
@@ -39,11 +39,10 @@
void *mem = x_malloc(size);
if (!mem) {
- int err = ACR_GET_OS_ERROR();
if (_E == NULL)
_E = ACR_GetJNIEnv();
if (IS_VALID_HANDLE(_E))
- ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err);
+ ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, ACR_ENOMEM);
}
return mem;
}
@@ -54,11 +53,10 @@
void *mem = x_calloc(size);
if (!mem) {
- int err = ACR_GET_OS_ERROR();
if (_E == NULL)
_E = ACR_GetJNIEnv();
if (IS_VALID_HANDLE(_E))
- ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err);
+ ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, ACR_ENOMEM);
}
return mem;
}
@@ -69,11 +67,10 @@
void *mem = realloc(org, size);
if (!mem) {
- int err = ACR_GET_OS_ERROR();
if (_E == NULL)
_E = ACR_GetJNIEnv();
if (IS_VALID_HANDLE(_E))
- ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err);
+ ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, ACR_ENOMEM);
}
return mem;
}
@@ -120,6 +117,7 @@
if (IS_VALID_HANDLE(_E))
ACR_ThrowException(_E, file, line, ACR_EX_EINVAL,
ACR_EINVAL);
+ ACR_SET_OS_ERROR(ACR_EINVAL);
return NULL;
}
size = ACR_ALIGN_DEFAULT(sbhs + size);
@@ -174,12 +172,14 @@
acr_sbh_t *sbh, acr_size_t size)
{
void *mem;
+
if (!sbh) {
if (_E == NULL)
_E = ACR_GetJNIEnv();
if (IS_VALID_HANDLE(_E))
ACR_ThrowException(_E, file, line, ACR_EX_ENULL,
ACR_EISNULL);
+ ACR_SET_OS_ERROR(ACR_EINVAL);
return NULL;
}
if (size > ACR_SIZE_T_MAX) {
@@ -188,6 +188,7 @@
if (IS_VALID_HANDLE(_E))
ACR_ThrowException(_E, file, line, ACR_EX_EINVAL,
ACR_EINVAL);
+ ACR_SET_OS_ERROR(ACR_EINVAL);
return NULL;
}
@@ -264,6 +265,7 @@
_E = ACR_GetJNIEnv();
if (IS_VALID_HANDLE(_E))
ACR_ThrowException(_E, file, line, ACR_EX_ENOMEM, err);
+ ACR_SET_OS_ERROR(ACR_ENOMEM);
}
return arr;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c?rev=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c Mon Sep 7 06:38:02 2009
@@ -29,6 +29,7 @@
#include "acr_arch.h"
#include "acr_clazz.h"
#include "acr_pointer.h"
+#include "acr_endian.h"
#include "acr_xdr.h"
#include "acr_error.h"
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=812006&r1=812005&r2=812006&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Mon Sep 7 06:38:02 2009
@@ -27,6 +27,7 @@
#include "acr_pointer.h"
#include "acr_descriptor.h"
#include "acr_file.h"
+#include "acr_endian.h"
#include "acr_xdr.h"
#include "acr_shm.h"
#include "acr_procmutex.h"