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/04/07 16:14:23 UTC
svn commit: r762785 - in /commons/sandbox/runtime/trunk/src/main/native:
include/acr_private.h include/acr_types.h include/acr_version.h
include/arch/ include/arch/windows/ include/arch/windows/acr_arch.h
os/linux/os.c os/win32/os.c
Author: mturk
Date: Tue Apr 7 14:14:22 2009
New Revision: 762785
URL: http://svn.apache.org/viewvc?rev=762785&view=rev
Log:
Initial commit
Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (with props)
commons/sandbox/runtime/trunk/src/main/native/include/acr_types.h (with props)
commons/sandbox/runtime/trunk/src/main/native/include/acr_version.h (with props)
commons/sandbox/runtime/trunk/src/main/native/include/arch/
commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/
commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (with props)
commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c (with props)
commons/sandbox/runtime/trunk/src/main/native/os/win32/os.c (with props)
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h?rev=762785&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Tue Apr 7 14:14:22 2009
@@ -0,0 +1,343 @@
+/* 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_PRIVATE_H
+#define _ACR_PRIVATE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_private.h
+ * @brief
+ *
+ * ACR private macros and defines
+ *
+ */
+
+#define ACR_MIN(a, b) ((a) < (b) ? (a) : (b))
+#define ACR_MAX(a, b) ((a) > (b) ? (a) : (b))
+
+/* Default buffer sizes */
+#define ACR_SBUFFER_SIZ 512
+#define ACR_SBUFFER_LEN (ACR_SBUFFER_SIZ - 1)
+
+#define ACR_MBUFFER_SIZ 1024
+#define ACR_MBUFFER_LEN (ACR_MBUFFER_SIZ - 1)
+
+#define ACR_HBUFFER_SIZ 8192
+#define ACR_HBUFFER_LEN (ACR_HBUFFER_SIZ - 1)
+
+#define ACR_KBS(N) ((N) * 1024)
+#define ACR_KB (1024)
+#define ACR_MB (ACR_KB * ACR_KB)
+#define ACR_GB (ACR_MB * ACR_KB)
+#define ACR_TB (ACR_GB * ACR_KB)
+
+#define CSTR_TO_JSTRING(V) (*_E)->NewStringUTF(_E, (char *)(V))
+#define WSTR_TO_JSTRING(V) (*_E)->NewString(_E, (jchar *)(V), (jsize)wcslen((jchar *)(V)))
+#define ZSTR_TO_JSTRING(V, L) (*_E)->NewString(_E, (jchar *)(V), (L))
+
+
+#define RETURN_JCSTR(V) \
+ if ((V)) return (*_E)->NewStringUTF((_E), (V)); \
+ else return NULL
+
+#define RETURN_JWSTR(V) \
+ if ((V)) return (*_E)->NewString((_E), (V), wcslen((V))); \
+ else return NULL
+
+
+/* Exception throw helper classes */
+#define THROW_FMARK __FILE__, __LINE__
+#define THROW_NMARK NULL, 0
+
+
+#define ACR_LOG_EMERG 1
+#define ACR_LOG_ERROR 2
+#define ACR_LOG_NOTICE 3
+#define ACR_LOG_WARN 4
+#define ACR_LOG_INFO 5
+#define ACR_LOG_DEBUG 6
+
+#define ACR_FS_UNKNOWN 0
+#define ACR_FS_MSDOS 1
+#define ACR_FS_VFAT 2
+#define ACR_FS_NTFS 3
+#define ACR_FS_ISO9660 4
+#define ACR_FS_EXT2 5
+#define ACR_FS_EXT3 6
+#define ACR_FS_XFS 7
+#define ACR_FS_XIAFS 8
+#define ACR_FS_HPFS 9
+#define ACR_FS_HFS 10
+#define ACR_FS_JFS 11
+#define ACR_FS_ROMFS 12
+#define ACR_FS_UDF 13
+#define ACR_FS_FFS 14
+#define ACR_FS_SFS 15
+#define ACR_FS_NFS 16
+#define ACR_FS_RAMFS 17
+#define ACR_FS_RAISERFS 18
+#define ACR_FS_DEV 19
+#define ACR_FS_PROC 20
+#define ACR_FS_SYSFS 21
+#define ACR_FS_TMPFS 22
+#define ACR_FS_RPC 23
+#define ACR_FS_USBFS 24
+#define ACR_FS_VMHGFS 25
+#define ACR_FS_VMBLOCK 26
+#define ACR_FS_SWAP 27
+#define ACR_FS_NONE 99
+
+#define ACR_CASE_SENSITIVE_SEARCH 0x00000001
+#define ACR_CASE_PRESERVED_NAMES 0x00000002
+#define ACR_UNICODE_ON_DISK 0x00000004
+#define ACR_FILE_COMPRESSION 0x00000010
+#define ACR_VOLUME_QUOTAS 0x00000020
+#define ACR_SUPPORTS_SPARSE_FILES 0x00000040
+#define ACR_SUPPORTS_REPARSE_POINTS 0x00000080
+#define ACR_VOLUME_IS_COMPRESSED 0x00008000
+#define ACR_SUPPORTS_ENCRYPTION 0x00020000
+#define ACR_READ_ONLY_VOLUME 0x00080000
+
+/* Unix specific options
+ * XXX: This needs to be revised if Windows changes
+ * the API for FILE_ and FS_
+ */
+#define ACR_READ_WRITE_VOLUME 0x01000000
+#define ACR_SUID_VOLUME 0x02000000
+
+
+#define ACR_DRIVE_UNKNOWN -1
+#define ACR_DRIVE_NONE 0
+#define ACR_DRIVE_INVALID 1
+#define ACR_DRIVE_REMOVABLE 2
+#define ACR_DRIVE_FIXED 3
+#define ACR_DRIVE_REMOTE 4
+#define ACR_DRIVE_CDROM 5
+#define ACR_DRIVE_RAMDISK 6
+#define ACR_DRIVE_SWAP 7
+
+/* Socket TCP states */
+#define ACR_TCP_CLOSED 1
+#define ACR_TCP_LISTENING 2
+#define ACR_TCP_SYN_SENT 3
+#define ACR_TCP_SYN_RCVD 4
+#define ACR_TCP_ESTABLISHED 5
+#define ACR_TCP_FIN_WAIT1 6
+#define ACR_TCP_FIN_WAIT2 7
+#define ACR_TCP_CLOSE_WAIT 8
+#define ACR_TCP_CLOSING 9
+#define ACR_TCP_LAST_ACK 10
+#define ACR_TCP_TIME_WAIT 11
+#define ACR_TCP_DELETE_TCB 12
+
+#define ACR_IFO_UP 1
+#define ACR_IFO_DOWN 2
+#define ACR_IFO_TESTING 3
+#define ACR_IFO_UNKNOWN 4
+#define ACR_IFO_DORMANT 5
+#define ACR_IFO_NOTPRESENT 6
+#define ACR_IFO_LLDOWN 7
+
+/* Misc macros */
+#define LLT(X) ((acr_ssize_t)(X))
+#define UNREFERENCED(P) (P) = (P)
+#define UNREFERENCED_STDARGS _E = _E; _O = _O
+#define UNREFERENCED_O _O = _O
+#define ACR_JNISTDARGS JNIEnv *_E, jobject _O
+#define P2J(P) ((jlong)LLT(P))
+#define J2P(P, T) ((T)LLT((jlong)P))
+#define V2P(T, V) ((T)((T)0 + (V)))
+#define V2Z(V) ((V) ? JNI_TRUE : JNI_FALSE)
+
+
+#define IS_JOBJECT_NULL(E, O) \
+ (!(O) || ((*(E))->IsSameObject((E), (O), NULL) == JNI_TRUE))
+
+#define IS_JOBJECT_VALID(E, O) \
+ ((O) && !((*(E))->IsSameObject((E), (O), NULL) == JNI_TRUE))
+
+
+#define ACR_CLASS_LDEF(CL) \
+ int acr_class_##CL##_load(JNIEnv *_E)
+
+#define ACR_CLASS_UDEF(CL) \
+ void sight_class_##CL##_unload(JNIEnv *_E)
+
+#define ACR_CLASS_LDEC(CL) \
+ extern int acr_class_##CL##_load(JNIEnv *); \
+ extern int acr_class_##CL##_unload(JNIEnv *)
+
+#define ACR_CLASS_LRUN(CL) \
+ if (acr_class_##CL##_load(_E)) return 1;
+
+
+#define ACR_CLASS_URUN(CL) \
+ acr_class_##CL##_unload(_E)
+
+#define J_DECLARE_CLAZZ static JAVA_C_ID _clazzn
+#define J_DECLARE_F_ID(I) static JAVA_F_ID _f##I##n
+#define J_DECLARE_M_ID(I) static JAVA_M_ID _m##I##n
+
+#define J_LOAD_METHOD(I) \
+ if (_m##I##n.i == NULL) { \
+ _m##I##n.i = (*_E)->GetMethodID(_E, _clazzn.i, _m##I##n.n, \
+ _m##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _m##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define J_LOAD_MLOCAL(I) \
+ if (_m##I##n.i == NULL) { \
+ _m##I##n.i = (*_E)->GetStaticMethodID(_E, _clazzn.i, _m##I##n.n, \
+ _m##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _m##I##.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define J_LOAD_IFIELD(I) \
+ if (_f##I##n.i == NULL) { \
+ _f##I##n.i = (*_E)->GetFieldID(_E, _clazzn.i, _f##I##n.n, \
+ _f##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _f##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define J_LOAD_SFIELD(I) \
+ if (_f##I##n.i == NULL) { \
+ _f##I##n.i = (*_E)->GetStaticFieldID(_E, _clazzn.i, _f##I##n.n, \
+ _f##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _f##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+
+#define SET_IFIELD_J(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetLongField(_E, (O), _f##I##n.i, (jlong)(V)); \
+ } else (void)(0)
+
+#define SET_IFIELD_I(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetIntField(_E, (O), _f##I##n.i, (jint)(V)); \
+ } else (void)(0)
+
+#define SET_IFIELD_D(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetDoubleField(_E, (O), _f##I##n.i, (jdouble)(V)); \
+ } else (void)(0)
+
+#define SET_IFIELD_Z(I, O, V) \
+ if (_f##I##n.i) { \
+ if ((V)) (*_E)->SetBooleanField(_E, (O), _f##I##n.i, JNI_TRUE); \
+ else (*_E)->SetBooleanField(_E, (O), _f##I##n.i, JNI_FALSE); \
+ } else (void)(0)
+
+#define SET_IFIELD_S(I, O, V) \
+ if (_f##I##n.i && (V)) { \
+ jstring _str = (*_E)->NewStringUTF(_E, (V)); \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, _str); \
+ (*_E)->DeleteLocalRef(_E, _str); \
+ } else (void)(0)
+
+#define SET_IFIELD_N(I, O, V) \
+ if (_f##I##n.i && (V) && *(V)) { \
+ jstring _str = (*_E)->NewStringUTF(_E, (V)); \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, _str); \
+ (*_E)->DeleteLocalRef(_E, _str); \
+ } else (void)(0)
+
+#define SET_IFIELD_W(I, O, V) \
+ if (_f##I##n.i && (V)) { \
+ jstring _str = (*_E)->NewString(_E, (V), (jsize)wcslen((V))); \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, _str); \
+ (*_E)->DeleteLocalRef(_E, _str); \
+ } else (void)(0)
+
+#define SET_IFIELD_O(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, (jobject)(V)); \
+ } else (void)(0)
+
+#define SET_SFIELD_Z(I, V) \
+ if (_f##I##n.i) { \
+ if ((V)) (*_E)->SetStaticBooleanField(_E, _clazzn.i, _f##I##n.i, JNI_TRUE); \
+ else (*_E)->SetStaticBooleanField(_E, _clazzn.i, _f##I##n.i, JNI_FALSE); \
+ } else (void)(0)
+
+
+#define CALL_METHOD1(I, O, V) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), NULL); \
+ } else (void)(0)
+
+#define CALL_METHOD2(I, O, V, X) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), (X), NULL); \
+ } else (void)(0)
+
+#define CALL_METHOD3(I, O, V, X, Y) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), (X), (Y), NULL); \
+ } else (void)(0)
+
+
+/* Standard Java classes */
+typedef enum {
+ ACR_CC_OBJECT,
+ ACR_CC_STRING,
+ ACR_CC_ZARRAY,
+ ACR_CC_BARRAY,
+ ACR_CC_CARRAY,
+ ACR_CC_IARRAY,
+ ACR_CC_JARRAY,
+ ACR_CC_TARRAY,
+ ACR_CC_OARRAY,
+ ACR_CC_MAX
+} acr_cclass_e;
+
+typedef enum {
+ ACR_PROC_U, /* Unknown */
+ ACR_PROC_R, /* Running or runnable (on run queue) */
+ ACR_PROC_S, /* Interruptible sleep (waiting for an event to complete) */
+ ACR_PROC_D, /* Uninterruptible sleep (usually IO) */
+ ACR_PROC_Z, /* Defunct ("zombie") process, terminated but not reaped by its parent */
+ ACR_PROC_T, /* Stopped, either by a job control signal or because it is being traced. */
+ ACR_PROC_W, /* paging */
+ ACR_PROC_X /* dead */
+ /* XXX : BSD as more */
+} acr_procstate_e;
+
+#if defined(DEBUG) || defined(_DEBUG)
+/* In DEBUG mode always use statistics */
+#ifndef ACR_DO_STATS
+#define ACR_DO_STATS 1
+#endif
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_PRIVATE_H */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_types.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_types.h?rev=762785&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_types.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_types.h Tue Apr 7 14:14:22 2009
@@ -0,0 +1,89 @@
+/* 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_TYPES_H
+#define _ACR_TYPES_H
+
+#include "acr.h"
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_types.h
+ * @brief
+ *
+ * ACR private structures
+ *
+ */
+
+/* Default buffer sizes */
+#define ACR_STYPE_SIZ 512
+#define ACR_STYPE_LEN (ACR_STYPE_SIZ - 1)
+
+#define ACR_MTYPE_SIZ 1024
+#define ACR_MTYPE_LEN (ACR_MTYPE_SIZ - 1)
+
+#define ACR_HTYPE_SIZ 8192
+#define ACR_HTYPE_LEN (ACR_HTYPE_SIZ - 1)
+
+#define ACR_MAX_PROCESSES 65536
+
+typedef struct JAVA_C_ID {
+ jclass i;
+ jclass a;
+ const char *n;
+} JAVA_C_ID;
+
+typedef struct JAVA_M_ID {
+ jmethodID i;
+ const char *n;
+ const char *s;
+} JAVA_M_ID;
+
+typedef struct JAVA_F_ID {
+ jfieldID i;
+ const char *n;
+ const char *s;
+} JAVA_F_ID;
+
+typedef struct acr_callback_t {
+ jobject object;
+ jmethodID method;
+ jint counter;
+ const char *name;
+ const char *msig;
+ void *opaque;
+} acr_callback_t;
+
+#define JSSIZE_MAX 1048576
+
+typedef struct acr_str_t {
+ jsize len;
+ union {
+ char *c;
+ jchar *w;
+ } str;
+} acr_str_t;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_TYPES_H */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_types.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_version.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_version.h?rev=762785&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_version.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_version.h Tue Apr 7 14:14:22 2009
@@ -0,0 +1,97 @@
+/* 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_VERSION_H
+#define _ACR_VERSION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_version.h
+ * @brief
+ *
+ * ACR Version
+ *
+ * There are several different mechanisms for accessing the version. There
+ * is a string form, and a set of numbers; in addition, there are constants
+ * which can be compiled into your application, and you can query the library
+ * being used for its actual version.
+ *
+ * Note that it is possible for an application to detect that it has been
+ * compiled against a different version of ACR by use of the compile-time
+ * constants and the use of the run-time query function.
+ *
+ * ACR version numbering follows the guidelines specified in:
+ *
+ * http://apr.apache.org/versioning.html
+ */
+
+/* The numeric compile-time version constants. These constants are the
+ * authoritative version numbers for ACR.
+ */
+
+/** major version
+ * Major API changes that could cause compatibility problems for older
+ * programs such as structure size changes. No binary compatibility is
+ * possible across a change in the major version.
+ */
+#define ACR_MAJOR_VERSION 1
+
+/**
+ * Minor API changes that do not cause binary compatibility problems.
+ * Should be reset to 0 when upgrading ACR_MAJOR_VERSION
+ */
+#define ACR_MINOR_VERSION 0
+
+/** patch level */
+#define ACR_PATCH_VERSION 2
+
+/**
+ * This symbol is defined for internal, "development" copies of SIGHT.
+ * This symbol will be #undef'd for releases.
+ */
+#undef ACR_IS_DEV_VERSION
+
+/* ACR_STRINGIFY is defined here, and also in apr_general.h, so wrap it */
+#ifndef ACR_STRINGIFY
+/** Properly quote a value as a string in the C preprocessor */
+#define ACR_STRINGIFY(n) ACR_STRINGIFY_HELPER(n)
+/** Helper macro for APR_STRINGIFY */
+#define ACR_STRINGIFY_HELPER(n) #n
+#endif
+
+
+/** The formatted string of APU's version */
+#define ACR_VERSION_STRING \
+ ACR_STRINGIFY(ACR_MAJOR_VERSION) "."\
+ ACR_STRINGIFY(ACR_MINOR_VERSION) "."\
+ ACR_STRINGIFY(ACR_PATCH_VERSION)\
+ ACR_IS_DEV_STRING
+
+/** Internal: string form of the "is dev" flag */
+#ifdef ACR_IS_DEV_VERSION
+#define ACR_IS_DEV_STRING "-dev"
+#else
+#define ACR_IS_DEV_STRING ""
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_VERSION_H */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_version.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=762785&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Tue Apr 7 14:14:22 2009
@@ -0,0 +1,316 @@
+/* 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_ARCH_H
+#define _ACR_ARCH_H
+
+#if !defined(PRODUCT_UNDEFINED)
+/* Vista Platform SDK definitions */
+
+typedef enum
+_TCP_TABLE_CLASS {
+ TCP_TABLE_BASIC_LISTENER,
+ TCP_TABLE_BASIC_CONNECTIONS,
+ TCP_TABLE_BASIC_ALL,
+ TCP_TABLE_OWNER_PID_LISTENER,
+ TCP_TABLE_OWNER_PID_CONNECTIONS,
+ TCP_TABLE_OWNER_PID_ALL,
+ TCP_TABLE_OWNER_MODULE_LISTENER,
+ TCP_TABLE_OWNER_MODULE_CONNECTIONS,
+ TCP_TABLE_OWNER_MODULE_ALL
+} TCP_TABLE_CLASS, *PTCP_TABLE_CLASS;
+
+typedef enum
+_UDP_TABLE_CLASS {
+ UDP_TABLE_BASIC,
+ UDP_TABLE_OWNER_PID,
+ UDP_TABLE_OWNER_MODULE
+} UDP_TABLE_CLASS, *PUDP_TABLE_CLASS;
+
+#endif /* PRODUCT_UNDEFINED */
+
+#define ACR_PLATFORM_CLASS_PATH ACR_CLASS_PATH "platform/windows/"
+
+#define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN) \
+ JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_platform_windows_##CL##_##FN
+
+typedef enum {
+ SYSDLL_KERNEL32 = 0, // kernel32 From WinBase.h
+ SYSDLL_NTDLL = 1, // ntdll From our real kernel
+ SYSDLL_USER32 = 2, // user32 From WinUser.h
+ SYSDLL_IPHLPAPI = 3, // iphlpapi From Iphlpapi.h
+ SYSDLL_JVM = 4, // jvm From our own jvm.dll
+ SYSDLL_defined = 5 // must define as last idx_ + 1
+} acr_dlltoken_e;
+
+/* Copied from http://source.winehq.org/source/include/winternl.h */
+
+typedef struct _CURDIR
+{
+ UNICODE_STRING DosPath;
+ PVOID Handle;
+} CURDIR, *PCURDIR;
+
+typedef struct RTL_DRIVE_LETTER_CURDIR
+{
+ USHORT Flags;
+ USHORT Length;
+ ULONG TimeStamp;
+ UNICODE_STRING DosPath;
+} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
+
+typedef struct tagRTL_BITMAP {
+ ULONG SizeOfBitMap; /* Number of bits in the bitmap */
+ PULONG Buffer; /* Bitmap data, assumed sized to a DWORD boundary */
+} RTL_BITMAP, *PRTL_BITMAP;
+
+typedef struct _RTL_USER_PROCESS_PARAMETERS
+{
+ ULONG AllocationSize;
+ ULONG Size;
+ ULONG Flags;
+ ULONG DebugFlags;
+ HANDLE ConsoleHandle;
+ ULONG ConsoleFlags;
+ HANDLE hStdInput;
+ HANDLE hStdOutput;
+ HANDLE hStdError;
+ CURDIR CurrentDirectory;
+ UNICODE_STRING DllPath;
+ UNICODE_STRING ImagePathName;
+ UNICODE_STRING CommandLine;
+ PWSTR Environment;
+ ULONG dwX;
+ ULONG dwY;
+ ULONG dwXSize;
+ ULONG dwYSize;
+ ULONG dwXCountChars;
+ ULONG dwYCountChars;
+ ULONG dwFillAttribute;
+ ULONG dwFlags;
+ ULONG wShowWindow;
+ UNICODE_STRING WindowTitle;
+ UNICODE_STRING Desktop;
+ UNICODE_STRING ShellInfo;
+ UNICODE_STRING RuntimeInfo;
+ RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
+} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
+
+typedef struct _PEB_LDR_DATA
+{
+ ULONG Length;
+ BOOLEAN Initialized;
+ PVOID SsHandle;
+ LIST_ENTRY InLoadOrderModuleList;
+ LIST_ENTRY InMemoryOrderModuleList;
+ LIST_ENTRY InInitializationOrderModuleList;
+} PEB_LDR_DATA, *PPEB_LDR_DATA;
+
+/***********************************************************************
+ * PEB data structure (472 bytes)
+ */
+typedef struct _ACR_PEB
+{
+ BOOLEAN InheritedAddressSpace; /* 00 */
+ BOOLEAN ReadImageFileExecOptions; /* 01 */
+ BOOLEAN BeingDebugged; /* 02 */
+ BOOLEAN SpareBool; /* 03 */
+ HANDLE Mutant; /* 04 */
+ HMODULE ImageBaseAddress; /* 08 */
+ PPEB_LDR_DATA LdrData; /* 0c */
+ RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 */
+ PVOID SubSystemData; /* 14 */
+ HANDLE ProcessHeap; /* 18 */
+ PRTL_CRITICAL_SECTION FastPebLock; /* 1c */
+ PVOID /*PPEBLOCKROUTINE*/ FastPebLockRoutine; /* 20 */
+ PVOID /*PPEBLOCKROUTINE*/ FastPebUnlockRoutine; /* 24 */
+ ULONG EnvironmentUpdateCount; /* 28 */
+ PVOID KernelCallbackTable; /* 2c */
+ PVOID EventLogSection; /* 30 */
+ PVOID EventLog; /* 34 */
+ PVOID /*PPEB_FREE_BLOCK*/ FreeList; /* 38 */
+ ULONG TlsExpansionCounter; /* 3c */
+ PRTL_BITMAP TlsBitmap; /* 40 */
+ ULONG TlsBitmapBits[2]; /* 44 */
+ PVOID ReadOnlySharedMemoryBase; /* 4c */
+ PVOID ReadOnlySharedMemoryHeap; /* 50 */
+ PVOID *ReadOnlyStaticServerData; /* 54 */
+ PVOID AnsiCodePageData; /* 58 */
+ PVOID OemCodePageData; /* 5c */
+ PVOID UnicodeCaseTableData; /* 60 */
+ ULONG NumberOfProcessors; /* 64 */
+ ULONG NtGlobalFlag; /* 68 */
+ BYTE Spare2[4]; /* 6c */
+ LARGE_INTEGER CriticalSectionTimeout; /* 70 */
+ ULONG HeapSegmentReserve; /* 78 */
+ ULONG HeapSegmentCommit; /* 7c */
+ ULONG HeapDeCommitTotalFreeThreshold; /* 80 */
+ ULONG HeapDeCommitFreeBlockThreshold; /* 84 */
+ ULONG NumberOfHeaps; /* 88 */
+ ULONG MaximumNumberOfHeaps; /* 8c */
+ PVOID *ProcessHeaps; /* 90 */
+ PVOID GdiSharedHandleTable; /* 94 */
+ PVOID ProcessStarterHelper; /* 98 */
+ PVOID GdiDCAttributeList; /* 9c */
+ PVOID LoaderLock; /* a0 */
+ ULONG OSMajorVersion; /* a4 */
+ ULONG OSMinorVersion; /* a8 */
+ ULONG OSBuildNumber; /* ac */
+ ULONG OSPlatformId; /* b0 */
+ ULONG ImageSubSystem; /* b4 */
+ ULONG ImageSubSystemMajorVersion; /* b8 */
+ ULONG ImageSubSystemMinorVersion; /* bc */
+ ULONG ImageProcessAffinityMask; /* c0 */
+ ULONG GdiHandleBuffer[34]; /* c4 */
+ ULONG PostProcessInitRoutine; /* 14c */
+ PRTL_BITMAP TlsExpansionBitmap; /* 150 */
+ ULONG TlsExpansionBitmapBits[32]; /* 154 */
+ ULONG SessionId; /* 1d4 */
+} ACR_PEB, *PACR_PEB;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern LPSYSTEM_INFO acr_osinf;
+extern LPOSVERSIONINFOEXA acr_osver;
+extern UINT64 acr_vmem;
+
+FARPROC acr_load_dll_func(acr_dlltoken_e, const char *, int);
+
+/* The acr_load_dll_func call WILL return def if the function cannot be loaded */
+
+#define ACR_DECLARE_LATE_DLL_FUNC(lib, rettype, def, \
+ calltype, fn, ord, args, names) \
+ typedef rettype (calltype *acr_late_fpt_##fn) args; \
+ static acr_late_fpt_##fn acr_late_pfn_##fn = NULL; \
+ static APR_INLINE rettype acr_late_##fn args \
+ { if (!acr_late_pfn_##fn) \
+ acr_late_pfn_##fn = (acr_late_fpt_##fn) \
+ acr_load_dll_func(lib, #fn, ord); \
+ if (acr_late_pfn_##fn) \
+ return (*(acr_late_pfn_##fn)) names; \
+ else return def; } //
+
+#define ACR_DECLARE_LATE_DLL_CALL(lib, rettype, \
+ calltype, fn, fnx, ord, args, names) \
+ typedef rettype (calltype *acr_late_fpt_##fn) args; \
+ static acr_late_fpt_##fn acr_late_pfn_##fn = NULL; \
+ static APR_INLINE rettype acr_late_##fn args \
+ { if (!acr_late_pfn_##fn) \
+ acr_late_pfn_##fn = (acr_late_fpt_##fn) \
+ acr_load_dll_func(lib, #fn, ord); \
+ if (!acr_late_pfn_##fn) \
+ acr_late_pfn_##fn = (acr_late_fpt_##fn) \
+ acr_load_dll_func(lib, #fnx, ord); \
+ if (acr_late_pfn_##fn) \
+ (*(acr_late_pfn_##fn)) names; \
+ } //
+
+
+#ifdef ACR_WANT_LATE_DLL
+
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_KERNEL32, BOOL, FALSE,
+ WINAPI, GetSystemTimes, 0, (
+ OUT LPFILETIME lpIdleTime,
+ OUT LPFILETIME lpKernelTime,
+ OUT LPFILETIME lpUserTime),
+ (lpIdleTime, lpKernelTime, lpUserTime));
+#undef GetSystemTimes
+#define GetSystemTimes acr_late_GetSystemTimes
+
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_KERNEL32, BOOL, FALSE,
+ WINAPI, IsWow64Process, 0, (
+ IN HANDLE hProcess,
+ OUT PBOOL Wow64Process),
+ (hProcess, Wow64Process));
+#undef IsWow64Process
+#define IsWow64Process acr_late_IsWow64Process
+
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_NTDLL, NTSTATUS, 1,
+ WINAPI, NtQuerySystemInformation, 0, (
+ IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
+ OUT PVOID SystemInformation,
+ IN ULONG SystemInformationLength,
+ OUT PULONG ReturnLength),
+ (SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength));
+#undef NtQuerySystemInformation
+#define NtQuerySystemInformation acr_late_NtQuerySystemInformation
+
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_NTDLL, NTSTATUS, 1,
+ WINAPI, NtQueryInformationProcess, 0, (
+ IN HANDLE ProcessHandle,
+ IN PROCESSINFOCLASS ProcessInformationClass,
+ OUT PVOID ProcessInformation,
+ IN ULONG ProcessInformationLength,
+ OUT PULONG ReturnLength),
+ (ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength));
+#undef NtQueryInformationProcess
+#define NtQueryInformationProcess acr_late_NtQueryInformationProcess
+
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_KERNEL32, BOOL, FALSE,
+ WINAPI, GetPerformanceInfo, 0, (
+ PPERFORMACE_INFORMATION pPerformanceInformation,
+ DWORD cb),
+ (pPerformanceInformation, cb));
+#undef GetPerformanceInfo
+#define GetPerformanceInfo acr_late_GetPerformanceInfo
+
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_IPHLPAPI, DWORD, ERROR_INVALID_FUNCTION,
+ WINAPI, GetExtendedTcpTable, 0, (
+ PVOID pTcpTable,
+ PDWORD pdwSize,
+ BOOL bOrder,
+ ULONG ulAf,
+ TCP_TABLE_CLASS TableClass,
+ ULONG Reserved),
+ (pTcpTable, pdwSize, bOrder, ulAf, TableClass, Reserved));
+#undef GetExtendedTcpTable
+#define GetExtendedTcpTable acr_late_GetExtendedTcpTable
+
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_IPHLPAPI, DWORD, ERROR_INVALID_FUNCTION,
+ WINAPI, GetExtendedUdpTable, 0, (
+ PVOID pUdpTable,
+ PDWORD pdwSize,
+ BOOL bOrder,
+ ULONG ulAf,
+ UDP_TABLE_CLASS TableClass,
+ ULONG Reserved),
+ (pUdpTable, pdwSize, bOrder, ulAf, TableClass, Reserved));
+#undef GetExtendedUdpTable
+#define GetExtendedUdpTable acr_late_GetExtendedUdpTable
+
+ACR_DECLARE_LATE_DLL_CALL(SYSDLL_JVM, void, JNICALL,
+ JVM_DumpAllStacks,
+ _JVM_DumpAllStacks@8, 0, (
+ JNIEnv *lpEnv,
+ jclass jClazz),
+ (lpEnv, jClazz));
+#undef JVM_DumpAllStacks
+#define JVM_DumpAllStacks acr_late_JVM_DumpAllStacks
+
+#undef ACR_WANT_LATE_DLL
+#endif
+
+#define IS_INVALID_HANDLE(h) (((h) == NULL || (h) == INVALID_HANDLE_VALUE))
+#define ACR_REGS_CPU "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\"
+#define ACR_REGS_CPU0 ACR_REGS_CPU "0\\"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ACR_PRIVATE_H */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c?rev=762785&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c Tue Apr 7 14:14:22 2009
@@ -0,0 +1,81 @@
+/* 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.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include <sys/utsname.h>
+
+ACR_JNI_EXPORT_DECLARE(jboolean, OS, is)(ACR_JNISTDARGS, jint type)
+{
+ UNREFERENCED_STDARGS;
+ if ((type & ACR_OS_UNIX) == ACR_OS_UNIX)
+ return JNI_TRUE;
+ else if (type == SIGHT_OS_LINUX)
+ return JNI_TRUE;
+ else
+ return JNI_FALSE;
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, OS, type)(ACR_JNISTDARGS)
+{
+ UNREFERENCED_STDARGS;
+ return 5;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getSysname)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.sysname);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getVersion)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.version);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getRelease)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.release);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getMachine)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.machine);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLAREjstring, OS, getNodename)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.nodename);
+ else
+ return NULL;
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/os.c?rev=762785&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/os.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/os.c Tue Apr 7 14:14:22 2009
@@ -0,0 +1,124 @@
+/* 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.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+
+#define ACR_WANT_LATE_DLL
+#include "acr_arch.h"
+
+ACR_JNI_EXPORT_DECLARE(jboolean, OS, is)(ACR_JNISTDARGS, jint type)
+{
+ UNREFERENCED_STDARGS;
+#ifdef _WIN64
+ if (type == ACR_OS_WIN64)
+ return JNI_TRUE;
+ else
+#endif
+ if ((type & ACR_OS_WINDOWS) == ACR_OS_WINDOWS)
+ return JNI_TRUE;
+ else if (type == ACR_OS_WOW64) {
+ BOOL is = FALSE;
+ IsWow64Process(GetCurrentProcess(), &is);
+ return V2Z(is);
+ }
+ else
+ return JNI_FALSE;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getSysname)(ACR_JNISTDARGS)
+{
+ return CSTR_TO_JSTRING("Windows");
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getVersion)(ACR_JNISTDARGS)
+{
+ char buf[ACR_SBUFFER_SIZ];
+
+ if (ACR_osver->dwMajorVersion == 4) {
+ strcpy(buf, "NT4");
+ }
+ else if (acr_osver->dwMajorVersion == 5) {
+ if (acr_osver->dwMinorVersion == 0) {
+ strcpy(buf, "2000");
+ }
+ else if (acr_osver->dwMinorVersion == 2) {
+ strcpy(buf, "2003");
+ }
+ else {
+ strcpy(buf, "XP");
+ }
+ }
+ else if (acr_osver->dwMajorVersion == 6) {
+ strcpy(buf, "VISTA");
+ }
+ else {
+ strcpy(buf, "UNKNOWN");
+ }
+ if (acr_osver->szCSDVersion[0]) {
+ strcat(buf, " (");
+ strcat(buf, acr_osver->szCSDVersion);
+ strcat(buf, ")");
+ }
+ return CSTR_TO_JSTRING(buf);
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getRelease)(ACR_JNISTDARGS)
+{
+ char buf[32];
+
+ sprintf(buf, "%d.%d.%d", acr_osver->dwMajorVersion,
+ acr_osver->dwMinorVersion,
+ acr_osver->dwBuildNumber);
+ return CSTR_TO_JSTRING(buf);
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getMachine)(ACR_JNISTDARGS)
+{
+ char buf[32];
+
+ if (acr_osinf->wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
+ strcpy(buf, "x86_64");
+ else if (acr_osinf->wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
+ strcpy(buf, "ia64");
+ else if (acr_osinf->wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) {
+ int pl = acr_osinf->wProcessorLevel;
+ if (pl < 8)
+ sprintf(buf, "i%d86", acr_osinf->wProcessorLevel);
+ else {
+ /* TODO: Figure out the proper names for EMT64
+ * and other Intel processors
+ */
+ strcpy(buf, "i786");
+ }
+ }
+ else
+ return NULL;
+ return CSTR_TO_JSTRING(buf);
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getNodename)(ACR_JNISTDARGS)
+{
+ char buf[MAX_COMPUTERNAME_LENGTH + 1] = { 0 };
+ DWORD len = MAX_COMPUTERNAME_LENGTH;
+
+ if (GetComputerName(buf, &len)) {
+ return CSTR_TO_JSTRING(buf);
+ }
+ else {
+ return NULL;
+ }
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/os.c
------------------------------------------------------------------------------
svn:eol-style = native