commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r771190 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_private.h os/unix/file.c os/unix/syslog.c os/unix/uuid.c os/win32/file.c os/win32/syslog.c os/win32/uuid.c shared/error.c shared/memory.c
Date Mon, 04 May 2009 06:13:08 GMT
Author: mturk
Date: Mon May  4 06:13:05 2009
New Revision: 771190

URL: http://svn.apache.org/viewvc?rev=771190&view=rev
Log:
Use package macros

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/uuid.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/uuid.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c
    commons/sandbox/runtime/trunk/src/main/native/shared/memory.c

Modified: 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=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Mon May  4 06:13:05
2009
@@ -31,9 +31,20 @@
  *
  */
 
-#define ACR_CLASS_PATH                    "org/apache/commons/runtime/"
+#define ACR_CLASS_PATH              "org/apache/commons/runtime/"
+#define ACR_EXCEPTION_CLASS_PATH    "org/apache/commons/runtime/exception/"
+#define ACR_IO_CLASS_PATH           "org/apache/commons/runtime/io/"
+#define ACR_NET_CLASS_PATH          "org/apache/commons/runtime/net/"
+#define ACR_UTIL_CLASS_PATH         "org/apache/commons/runtime/util/"
+
 #define ACR_JNI_EXPORT_DECLARE(RT, CL, MN)  \
     JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_##CL##_##MN
+#define ACR_IO_EXPORT_DECLARE(RT, CL, MN)  \
+    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_io_##CL##_##MN
+#define ACR_NET_EXPORT_DECLARE(RT, CL, MN)  \
+    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_net_##CL##_##MN
+#define ACR_UTIL_EXPORT_DECLARE(RT, CL, MN)  \
+    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_util_##CL##_##MN
 
 
 /* ACR_ALIGN() is only to be used to align on a power of 2 boundary */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c?rev=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c Mon May  4 06:13:05 2009
@@ -108,7 +108,7 @@
     return -1;
 }
 
-ACR_JNI_EXPORT_DECLARE(int, io_File, ftype0)(ACR_JNISTDARGS, jstring pathname)
+ACR_IO_EXPORT_DECLARE(int, File, ftype0)(ACR_JNISTDARGS, jstring pathname)
 {
     int type = ACR_FT_UNKFILE;
 
@@ -120,9 +120,9 @@
     return type;
 }
 
-ACR_JNI_EXPORT_DECLARE(jboolean, io_File, mkslink0)(ACR_JNISTDARGS,
-                                                    jstring target,
-                                                    jstring lnkname)
+ACR_IO_EXPORT_DECLARE(jboolean, File, mkslink0)(ACR_JNISTDARGS,
+                                                jstring target,
+                                                jstring lnkname)
 {
     jboolean rc = JNI_FALSE;
 
@@ -146,9 +146,9 @@
     return rc;
 }
 
-ACR_JNI_EXPORT_DECLARE(jboolean, io_File, mkhlink0)(ACR_JNISTDARGS,
-                                                    jstring target,
-                                                    jstring lnkname)
+ACR_IO_EXPORT_DECLARE(jboolean, File, mkhlink0)(ACR_JNISTDARGS,
+                                                jstring target,
+                                                jstring lnkname)
 {
     jboolean rc = JNI_FALSE;
 
@@ -172,8 +172,8 @@
     return rc;
 }
 
-ACR_JNI_EXPORT_DECLARE(jstring, io_File, target0)(ACR_JNISTDARGS,
-                                                  jstring lnkname)
+ACR_IO_EXPORT_DECLARE(jstring, File, target0)(ACR_JNISTDARGS,
+                                              jstring lnkname)
 {
     jstring rv = NULL;
 
@@ -288,7 +288,7 @@
     return -1;
 }
 
-ACR_JNI_EXPORT_DECLARE(int, io_File, fprot0)(ACR_JNISTDARGS, jstring pathname)
+ACR_IO_EXPORT_DECLARE(int, File, fprot0)(ACR_JNISTDARGS, jstring pathname)
 {
     int prot = 0;
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c?rev=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c Mon May  4 06:13:05 2009
@@ -34,15 +34,15 @@
 
 #define LOG_MSG_DOMAIN  "runtime"
 
-ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init0)(ACR_JNISTDARGS)
+ACR_UTIL_EXPORT_DECLARE(void, Syslog, init0)(ACR_JNISTDARGS)
 {
 
     UNREFERENCED_STDARGS;
     openlog(LOG_MSG_DOMAIN, LOG_CONS | LOG_PID, LOG_LOCAL0);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init1)(ACR_JNISTDARGS,
-                                                 jstring domain)
+ACR_UTIL_EXPORT_DECLARE(void, Syslog, init1)(ACR_JNISTDARGS,
+                                             jstring domain)
 {
 
     UNREFERENCED_O;
@@ -53,15 +53,15 @@
     } END_WITH_CSTR(domain);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, util_Syslog, close0)(ACR_JNISTDARGS)
+ACR_UTIL_EXPORT_DECLARE(void, Syslog, close0)(ACR_JNISTDARGS)
 {
     UNREFERENCED_STDARGS;
     closelog();
 }
 
-ACR_JNI_EXPORT_DECLARE(void, util_Syslog, log0)(ACR_JNISTDARGS,
-                                                jint level,
-                                                jstring msg)
+ACR_UTIL_EXPORT_DECLARE(void, Syslog, log0)(ACR_JNISTDARGS,
+                                            jint level,
+                                            jstring msg)
 {
     UNREFERENCED_O;
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/uuid.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/uuid.c?rev=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/uuid.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/uuid.c Mon May  4 06:13:05 2009
@@ -22,7 +22,7 @@
 #if HAVE_UUID_UUID_H
 #include <uuid/uuid.h>
 
-ACR_JNI_EXPORT_DECLARE(jbyteArray, util_UUID, getb0)(ACR_JNISTDARGS)
+ACR_UTIL_EXPORT_DECLARE(jbyteArray, UUID, getb0)(ACR_JNISTDARGS)
 {
     jbyteArray rv;
     uuid_t id;
@@ -43,7 +43,7 @@
  * a decent random number generator.
  */
 
-ACR_JNI_EXPORT_DECLARE(jbyteArray, util_UUID, getb0)(ACR_JNISTDARGS)
+ACR_UTIL_EXPORT_DECLARE(jbyteArray, UUID, getb0)(ACR_JNISTDARGS)
 {
     UNREFERENCED_O;
     ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENOTIMPL, 0);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Mon May  4 06:13:05 2009
@@ -90,7 +90,7 @@
     return -1;
 }
 
-ACR_JNI_EXPORT_DECLARE(int, io_File, ftype0)(ACR_JNISTDARGS, jstring pathname)
+ACR_IO_EXPORT_DECLARE(int, File, ftype0)(ACR_JNISTDARGS, jstring pathname)
 {
     int type = ACR_FT_UNKFILE;
 
@@ -102,9 +102,9 @@
     return type;
 }
 
-ACR_JNI_EXPORT_DECLARE(jboolean, io_File, mkslink0)(ACR_JNISTDARGS,
-                                                    jstring target,
-                                                    jstring lnkname)
+ACR_IO_EXPORT_DECLARE(jboolean, File, mkslink0)(ACR_JNISTDARGS,
+                                                jstring target,
+                                                jstring lnkname)
 {
     jboolean rc = JNI_FALSE;
 
@@ -136,9 +136,9 @@
     return rc;
 }
 
-ACR_JNI_EXPORT_DECLARE(jboolean, io_File, mkhlink0)(ACR_JNISTDARGS,
-                                                    jstring target,
-                                                    jstring lnkname)
+ACR_IO_EXPORT_DECLARE(jboolean, File, mkhlink0)(ACR_JNISTDARGS,
+                                                jstring target,
+                                                jstring lnkname)
 {
     jboolean rc = JNI_FALSE;
 
@@ -162,8 +162,8 @@
     return rc;
 }
 
-ACR_JNI_EXPORT_DECLARE(jstring, io_File, target0)(ACR_JNISTDARGS,
-                                                  jstring lnkname)
+ACR_IO_EXPORT_DECLARE(jstring, File, target0)(ACR_JNISTDARGS,
+                                              jstring lnkname)
 {
     jstring rv = NULL;
 
@@ -352,7 +352,7 @@
     return 0;
 }
 
-ACR_JNI_EXPORT_DECLARE(int, io_File, fprot0)(ACR_JNISTDARGS, jstring pathname)
+ACR_IO_EXPORT_DECLARE(int, File, fprot0)(ACR_JNISTDARGS, jstring pathname)
 {
     int prot = 0;
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c?rev=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c Mon May  4 06:13:05 2009
@@ -91,15 +91,15 @@
     }
 }
 
-ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init0)(ACR_JNISTDARGS)
+ACR_UTIL_EXPORT_DECLARE(void, Syslog, init0)(ACR_JNISTDARGS)
 {
     UNREFERENCED_STDARGS;
 
     acr_init_log_source(LOG_MSG_DOMAIN);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init1)(ACR_JNISTDARGS,
-                                                 jstring domain)
+ACR_UTIL_EXPORT_DECLARE(void, Syslog, init1)(ACR_JNISTDARGS,
+                                             jstring domain)
 {
     UNREFERENCED_O;
     WITH_CSTR(domain) {
@@ -107,9 +107,9 @@
     } END_WITH_CSTR(domain);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, util_Syslog, log0)(ACR_JNISTDARGS,
-                                                jint level,
-                                                jstring msg)
+ACR_UTIL_EXPORT_DECLARE(void, Syslog, log0)(ACR_JNISTDARGS,
+                                            jint level,
+                                            jstring msg)
 {
     UNREFERENCED_O;
     WITH_WSTR(msg) {

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/uuid.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/uuid.c?rev=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/uuid.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/uuid.c Mon May  4 06:13:05 2009
@@ -19,7 +19,7 @@
 #include "acr_arch.h"
 #include "acr_error.h"
 
-ACR_JNI_EXPORT_DECLARE(jbyteArray, util_UUID, getb0)(ACR_JNISTDARGS)
+ACR_UTIL_EXPORT_DECLARE(jbyteArray, UUID, getb0)(ACR_JNISTDARGS)
 {
     jbyteArray rv;
     jbyte id[16];
@@ -34,4 +34,3 @@
     }
     return rv;
 }
-

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=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Mon May  4 06:13:05 2009
@@ -37,10 +37,10 @@
     "java/io/IOException",
     "java/io/SyncFailedException",
     "java/net/SocketException",
-    ACR_CLASS_PATH "exception/ClosedDescriptorException.java",
-    ACR_CLASS_PATH "exception/NoSuchObjectException.java",
-    ACR_CLASS_PATH "exception/OperatingSystemException.java",
-    ACR_CLASS_PATH "exception/UnsupportedOperatingSystemException.java",
+    ACR_EXCEPTION_CLASS_PATH "ClosedDescriptorException.java",
+    ACR_EXCEPTION_CLASS_PATH "NoSuchObjectException.java",
+    ACR_EXCEPTION_CLASS_PATH "OperatingSystemException.java",
+    ACR_EXCEPTION_CLASS_PATH "UnsupportedOperatingSystemException.java",
     NULL
 };
 
@@ -105,7 +105,7 @@
 ACR_DECLARE(void) ACR_ThrowExceptionA(JNIEnv *env,
                                       const char *file, int line,
                                       acr_trowclass_e clazz, const char *msg)
-{    
+{
     ACR_ThrowClassEx(env, file, line, throw_classes[clazz], msg);
 }
 

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=771190&r1=771189&r2=771190&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Mon May  4 06:13:05 2009
@@ -236,7 +236,7 @@
 }
 
 
-static int ptr_cleanup(void *mem)
+static int memory_pointer_cleanup(void *mem)
 {
     if (mem) {
         free(mem);
@@ -268,7 +268,9 @@
     if (mem) {
         /* Create the Pointer class with default cleanup.
          */
-        ptr = ACR_PointerCreate(_E, mem, (size_t)siz, ptr_cleanup);
+        ptr = ACR_PointerCreate(_E, mem, (size_t)siz, memory_pointer_cleanup);
+        if (!ptr)
+            free(mem);
     }
     return ptr;
 }
@@ -288,7 +290,9 @@
     if (mem) {
         /* Create the Pointer class with default cleanup.
          */
-        ptr = ACR_PointerCreate(_E, mem, (size_t)siz, ptr_cleanup);
+        ptr = ACR_PointerCreate(_E, mem, (size_t)siz, memory_pointer_cleanup);
+        if (!ptr)
+            free(mem);
     }
     return ptr;
 }
@@ -348,6 +352,7 @@
                                              jobject src, jlong off,
                                              jlong siz)
 {
+    jobject po;
     size_t  so  = (size_t)off;
     size_t  ss  = (size_t)siz;
     size_t  sl;
@@ -376,7 +381,14 @@
     }
     /* Copy the original content */
     memcpy(dp, sp + so, ss);
-    return ACR_PointerCreate(_E, dp, ss, ptr_cleanup);
+    po = ACR_PointerCreate(_E, dp, ss, memory_pointer_cleanup);
+    if (!po) {
+        /* Destroy the the memory we failed to attach
+         * to the new Pointer object.
+         */
+        free(dp);
+    }
+    return po;
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, copy)(ACR_JNISTDARGS, jobject src,
@@ -499,7 +511,7 @@
     size_t  pl;
     size_t  dn = (size_t)poff;
     size_t  cs = (size_t)size;
-    char    *p = (char *)ACR_PointerGet(_E, ptr, &pl);
+    jbyte   *p = (jbyte *)ACR_PointerGet(_E, ptr, &pl);
 
     if (!p) {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
@@ -509,9 +521,9 @@
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
         return NULL;
     }
-    ba = (*_E)->NewByteArray(_E, (jsize)size);
+    ba = (*_E)->NewByteArray(_E, cs);
     if (ba) {
-        (*_E)->SetByteArrayRegion(_E, ba, 0, (jsize)size, (jbyte *)p + dn);
+        (*_E)->SetByteArrayRegion(_E, ba, 0, cs, p + dn);
     }
     return ba;
 }



Mime
View raw message