commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r887847 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_private.h shared/clazz.c shared/constp.c shared/db.c shared/descriptor.c shared/memory.c shared/pointer.c
Date Mon, 07 Dec 2009 06:34:42 GMT
Author: mturk
Date: Mon Dec  7 06:34:41 2009
New Revision: 887847

URL: http://svn.apache.org/viewvc?rev=887847&view=rev
Log:
Get rid of 32/64 bit class wrappers. Use long for all platforms as generic pointer storage

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
    commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
    commons/sandbox/runtime/trunk/src/main/native/shared/constp.c
    commons/sandbox/runtime/trunk/src/main/native/shared/db.c
    commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
    commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
    commons/sandbox/runtime/trunk/src/main/native/shared/pointer.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=887847&r1=887846&r2=887847&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 Dec  7 06:34:41
2009
@@ -268,21 +268,17 @@
 #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 V2Z(V)                  ((V) ? JNI_TRUE : JNI_FALSE)
 #define J2W(V)                  _w##V
 #define J2S(V)                  _c##V
 
 #if CC_SIZEOF_VOIDP == 8
-typedef jlong                   jniptr;
-#define P2N(P)                  ((jlong)LLT(P))
-#define N2P(P, T)               ((T)LLT((jlong)P))
+#define P2J(P)                  ((jlong)LLT(P))
+#define J2P(P, T)               ((T)LLT(P))
 #define I2P(P, T)               ((T)LLT((jlong)P & 0x00000000FFFFFFFFL))
 #else
-typedef jint                    jniptr;
-#define P2N(P)                  ((jint)LLT(P))
-#define N2P(P, T)               ((T)LLT((jint)P))
+#define P2J(P)                  ((jlong)LLT(P)   & 0x00000000FFFFFFFFL)
+#define J2P(P, T)               ((T)LLT((jlong)P & 0x00000000FFFFFFFFL))
 #define I2P(P, T)               ((T)LLT((jint)P))
 #endif
 
@@ -431,9 +427,6 @@
         else     (*_E)->SetStaticBooleanField(_E, _clazzn.i, _f##I##n.i, JNI_FALSE); 
  \
     } else (void)(0)
 
-#if CC_SIZEOF_VOIDP == 8
-
-#define IFIELD_PTR  "J"
 #define GET_IFIELD_P(I, O)  \
     (_f##I##n.i && (O)) ? (*_E)->GetLongField(_E, (O), _f##I##n.i) : 0
 #define GET_IFIELD_V(I, O, T)  \
@@ -445,21 +438,6 @@
         (*_E)->SetLongField(_E, (O), _f##I##n.i, (jlong)((acr_ssize_t)(V))); \
     } else (void)(0)
 
-#else  /* CC_SIZEOF_VOIDP == 4 */
-
-#define IFIELD_PTR  "I"
-#define GET_IFIELD_P(I, O)  \
-    (_f##I##n.i && (O)) ? (*_E)->GetIntField(_E, (O), _f##I##n.i) : 0
-#define GET_IFIELD_V(I, O, T)  \
-    (_f##I##n.i && (O)) ? (T)((acr_ssize_t)(*_E)->GetIntField(_E, (O),      \
-                              _f##I##n.i)) : NULL
-
-#define SET_IFIELD_P(I, O, V)  \
-    if (_f##I##n.i && (O)) {                                                \
-        (*_E)->SetIntField(_E, (O), _f##I##n.i, (jint)((acr_ssize_t)(V)));  \
-    } else (void)(0)
-
-#endif /* CC_SIZEOF_VOIDP == 8 */
 
 #define CALL_VMETHOD0(I, O)  \
     if (_m##I##n.i) {                                                       \

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=887847&r1=887846&r2=887847&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Mon Dec  7 06:34:41 2009
@@ -375,7 +375,7 @@
 
 /* Forward class loading declarations */
 ACR_CLASS_LDEC(Descriptor);
-ACR_CLASS_LDEC(AbstractPointer);
+ACR_CLASS_LDEC(GenericPointer);
 ACR_CLASS_LDEC(ConstPointer);
 ACR_CLASS_LDEC(Callback);
 ACR_CLASS_LDEC(DirectBuffer);
@@ -394,7 +394,7 @@
 {
 
     ACR_CLASS_LRUN(Descriptor);
-    ACR_CLASS_LRUN(AbstractPointer);
+    ACR_CLASS_LRUN(GenericPointer);
     ACR_CLASS_LRUN(ConstPointer);
     ACR_CLASS_LRUN(Callback);
     ACR_CLASS_LRUN(DirectBuffer);
@@ -419,7 +419,7 @@
 {
 
     ACR_CLASS_URUN(Descriptor);
-    ACR_CLASS_URUN(AbstractPointer);
+    ACR_CLASS_URUN(GenericPointer);
     ACR_CLASS_URUN(ConstPointer);
     ACR_CLASS_URUN(Callback);
     ACR_CLASS_URUN(DirectBuffer);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/constp.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/constp.c?rev=887847&r1=887846&r2=887847&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/constp.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/constp.c Mon Dec  7 06:34:41 2009
@@ -30,17 +30,11 @@
 /**
  * ConstPointer utilities
  */
-/**
- * Pointer class utilities
- */
-#if CC_SIZEOF_VOIDP == 8
-#define ACR_CPT_EXPORT_DECLARE(RT, FN)  \
-    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_ConstPointer64_##FN
 
 J_DECLARE_CLAZZ = {
     NULL,
     NULL,
-    ACR_CLASS_PATH "ConstPointer64"
+    ACR_CLASS_PATH "ConstPointer"
 };
 
 J_DECLARE_M_ID(0000) = {
@@ -49,24 +43,6 @@
     "(JJJ)V"
 };
 
-#else
-#define ACR_DBB_EXPORT_DECLARE(RT, FN)  \
-    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_ConstPointer32_##FN
-
-J_DECLARE_CLAZZ = {
-    NULL,
-    NULL,
-    ACR_CLASS_PATH "ConstPointer32"
-};
-
-J_DECLARE_M_ID(0000) = {
-    NULL,
-    "<init>",
-    "(III)V"
-};
-
-#endif
-
 ACR_CLASS_LDEF(ConstPointer)
 {
     int rv;
@@ -96,7 +72,7 @@
 {
     if (_clazzn.i && J4MID(0000)) {
          return (*_E)->NewObject(_E, _clazzn.i, J4MID(0000),
-                                 P2N(p), P2N(cb), (acr_ptr_t)len);
+                                 P2J(p), P2J(cb), (jlong)len);
     }
     else {
         ACR_SET_OS_ERROR(ACR_ECLASSNOTFOUND);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/db.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/db.c?rev=887847&r1=887846&r2=887847&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/db.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/db.c Mon Dec  7 06:34:41 2009
@@ -34,14 +34,10 @@
 /**
  * Pointer class utilities
  */
-#if CC_SIZEOF_VOIDP == 8
-#define ACR_DBB_EXPORT_DECLARE(RT, FN)  \
-    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_DirectBuffer64_##FN
-
 J_DECLARE_CLAZZ = {
     NULL,
     NULL,
-    ACR_CLASS_PATH "DirectBuffer64"
+    ACR_CLASS_PATH "DirectBuffer"
 };
 
 J_DECLARE_M_ID(0000) = {
@@ -50,24 +46,6 @@
     "(JJJ)V"
 };
 
-#else
-#define ACR_DBB_EXPORT_DECLARE(RT, FN)  \
-    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_DirectBuffer32_##FN
-
-J_DECLARE_CLAZZ = {
-    NULL,
-    NULL,
-    ACR_CLASS_PATH "DirectBuffer32"
-};
-
-J_DECLARE_M_ID(0000) = {
-    NULL,
-    "<init>",
-    "(III)V"
-};
-
-#endif
-
 ACR_CLASS_LDEF(DirectBuffer)
 {
     int rv;
@@ -122,8 +100,8 @@
             /* Create the DirectBuffer class with default cleanup.
              */
             ptr = (*_E)->NewObject(_E, _clazzn.i, J4MID(0000),
-                                   P2N(mem), P2N(direct_buffer_cleanup),
-                                   (acr_ptr_t)len);
+                                   P2J(mem), P2J(direct_buffer_cleanup),
+                                   (jlong)len);
             if (!ptr)
                 x_free(mem);
         }
@@ -140,7 +118,7 @@
 {
     if (_clazzn.i && J4MID(0000)) {
         return (*_E)->NewObject(_E, _clazzn.i, J4MID(0000),
-                                P2N(p), P2N(cb), (acr_ptr_t)len);
+                                P2J(p), P2J(cb), (jlong)len);
     }
     else {
         ACR_SET_OS_ERROR(ACR_ECLASSNOTFOUND);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c?rev=887847&r1=887846&r2=887847&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c Mon Dec  7 06:34:41
2009
@@ -30,12 +30,11 @@
 /**
  * Descriptor class utilities
  */
-#if CC_SIZEOF_VOIDP == 8
 
 J_DECLARE_CLAZZ = {
     NULL,
     NULL,
-    ACR_CLASS_PATH "Descriptor64"
+    ACR_CLASS_PATH "Descriptor"
 };
 
 J_DECLARE_M_ID(0000) = {
@@ -44,22 +43,6 @@
     "(IIJJ)V"
 };
 
-#else
-
-J_DECLARE_CLAZZ = {
-    NULL,
-    NULL,
-    ACR_CLASS_PATH "Descriptor32"
-};
-
-
-J_DECLARE_M_ID(0000) = {
-    NULL,
-    "<init>",
-    "(IIII)V"
-};
-
-#endif
 
 J_DECLARE_F_ID(0000) = {
     NULL,
@@ -76,13 +59,13 @@
 J_DECLARE_F_ID(0002) = {
     NULL,
     "PHANDLE",
-    IFIELD_PTR
+    "J"
 };
 
 J_DECLARE_F_ID(0003) = {
     NULL,
     "HANDLER",
-    IFIELD_PTR
+    "J"
 };
 
 J_DECLARE_F_ID(0004) = {
@@ -269,7 +252,7 @@
 {
     if (_clazzn.i && J4MID(0000))
         return (*_E)->NewObject(_E, _clazzn.i, J4MID(0000),
-                                (jint)f, (jint)i, P2N(p), P2N(cb));
+                                (jint)f, (jint)i, P2J(p), P2J(cb));
     else {
         ACR_SET_OS_ERROR(ACR_ECLASSNOTFOUND);
         return NULL;

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=887847&r1=887846&r2=887847&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Mon Dec  7 06:34:41 2009
@@ -399,78 +399,75 @@
     ACR_PointerSet(_E, src, np, ss);
 }
 
-ACR_JNI_EXPORT_DECLARE(jobject, Memory, slice0)(ACR_JNISTDARGS,
-                                                jobject src, jlong off,
-                                                jlong siz)
+ACR_JNI_EXPORT_DECLARE(jint, Memory, peek0)(ACR_JNISTDARGS, jlong a)
 {
-    size_t  so  = (size_t)off;
-    size_t  ss  = (size_t)siz;
-    size_t  sl;
-    char   *sp = (char *)ACR_PointerGet(_E, src, &sl);
-
+    jint rv = 0;
     UNREFERENCED_O;
 
-    if (!sp) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
+    __TRY
+    {
+        rv = *(J2P(a, char *));
     }
-    if ((so + ss) > sl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
+    __EXCEPT
+    {
+        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
+    return rv;
+}
+
+ACR_JNI_EXPORT_DECLARE(void, Memory, poke0)(ACR_JNISTDARGS, jlong a, jint v)
+{
+    UNREFERENCED_O;
+    __TRY
+    {
+        *(J2P(a, char *)) = (char)(v & 0xFF);
+    }
+    __EXCEPT
+    {
+        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
+    }
+    __ENDTRY
+}
+
+ACR_JNI_EXPORT_DECLARE(jobject, Memory, slice0)(ACR_JNISTDARGS,
+                                                jlong src, jlong siz)
+{
+    size_t  ss = (size_t)siz;
+    char   *sp = J2P(src, char *);
+
+    UNREFERENCED_O;
 
     /* Create the Pointer class without the cleanup.
      * Original object will clean the entire allocated memory.
      */
-    return ACR_NewBasicPointer(_E, sp + so, ss, NULL);
+    return ACR_NewBasicPointer(_E, sp, ss, NULL);
 }
 
 ACR_JNI_EXPORT_DECLARE(jobject, Memory, slice1)(ACR_JNISTDARGS,
-                                                jobject src, jlong off,
-                                                jlong siz)
+                                                jlong src, jlong siz)
 {
-    size_t  so  = (size_t)off;
-    size_t  ss  = (size_t)siz;
-    size_t  sl;
-    char   *sp = (char *)ACR_PointerGet(_E, src, &sl);
+    size_t  ss = (size_t)siz;
+    char   *sp = J2P(src, char *);
 
     UNREFERENCED_O;
 
-    if (!sp) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if ((so + ss) > sl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
-
     /* Create the ConstPointer class.
      */
-    return ACR_NewConstPointer(_E, sp + so, ss, NULL);
+    return ACR_NewConstPointer(_E, sp, ss, NULL);
 }
 
+
 ACR_JNI_EXPORT_DECLARE(jobject, Memory, dup0)(ACR_JNISTDARGS,
-                                              jobject src, jlong off,
-                                              jlong siz)
+                                              jlong src, jlong siz)
 {
     jobject po = NULL;
-    size_t  so  = (size_t)off;
-    size_t  ss  = (size_t)siz;
-    size_t  sl;
+    size_t  ss = (size_t)siz;
     void   *dp;
-    char   *sp = (char *)ACR_PointerGet(_E, src, &sl);
+    char   *sp = J2P(src, char *);
 
     UNREFERENCED_O;
 
-    if (!sp) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if ((so + ss) > sl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
     dp = ACR_Malloc(_E, THROW_NMARK, ACR_ALIGN_DEFAULT(ss));
     if (dp == NULL) {
         /* Allocation failed.
@@ -480,7 +477,7 @@
     /* Copy the original content */
     __TRY
     {
-        memcpy(dp, sp + so, ss);
+        memcpy(dp, sp, ss);
         po = ACR_NewBasicPointer(_E, dp, ss, memory_pointer_cleanup);
     }
     __EXCEPT
@@ -497,35 +494,17 @@
     return po;
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, copy0)(ACR_JNISTDARGS, jobject src,
-                                            jlong soff, jobject dst,
-                                            jlong doff, jlong size)
+ACR_JNI_EXPORT_DECLARE(void, Memory, copy0)(ACR_JNISTDARGS, jlong src,
+                                            jlong dst, jlong size)
 {
-    size_t  dl;
-    size_t  sl;
-    size_t  dn = (size_t)doff;
-    size_t  sn = (size_t)soff;
     size_t  cs = (size_t)size;
-    char    *d = (char *)ACR_PointerGet(_E, dst, &dl);
-    char    *s = (char *)ACR_PointerGet(_E, src, &sl);
-
-    if (!d || !s) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if ((dn + cs) > dl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    if ((sn + cs) > sl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
+    char    *d = J2P(dst, char *);
+    char    *s = J2P(src, char *);
 
     /* Do a memcpy */
     __TRY
     {
-        memcpy(d + dn, s + sn, cs);
+        memcpy(d, s, cs);
     }
     __EXCEPT
     {
@@ -534,35 +513,17 @@
     __ENDTRY
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, move0)(ACR_JNISTDARGS, jobject src,
-                                            jlong soff, jobject dst,
-                                            jlong doff, jlong size)
+ACR_JNI_EXPORT_DECLARE(void, Memory, move0)(ACR_JNISTDARGS, jlong src,
+                                            jlong dst, jlong size)
 {
-    size_t  dl;
-    size_t  sl;
-    size_t  dn = (size_t)doff;
-    size_t  sn = (size_t)soff;
     size_t  cs = (size_t)size;
-    char    *d = (char *)ACR_PointerGet(_E, dst, &dl);
-    char    *s = (char *)ACR_PointerGet(_E, src, &sl);
-
-    if (!d || !s) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if ((dn + cs) > dl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    if ((sn + cs) > sl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
+    char    *d = J2P(dst, char *);
+    char    *s = J2P(src, char *);
 
     /* Do a memmove */
     __TRY
     {
-        memmove(d + dn, s + sn, cs);
+        memmove(d, s, cs);
     }
     __EXCEPT
     {
@@ -571,30 +532,16 @@
     __ENDTRY
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, clear0)(ACR_JNISTDARGS, jobject dst,
-                                             jlong doff, jlong size)
+ACR_JNI_EXPORT_DECLARE(void, Memory, clear0)(ACR_JNISTDARGS, jlong  dst,
+                                             jlong size)
 {
-    size_t  dl;
-    size_t  dn = (size_t)doff;
     size_t  cs = (size_t)size;
-    char    *d = (char *)ACR_PointerGet(_E, dst, &dl);
+    char    *d = J2P(dst, char *);
 
-    if (!d) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (doff < 0L || size < 1L) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
-        return;
-    }
-    if ((dn + size) > dl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
     /* Do a memset */
     __TRY
     {
-        memset(d + dn, 0, cs);
+        memset(d, 0, cs);
     }
     __EXCEPT
     {
@@ -603,30 +550,16 @@
     __ENDTRY
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, set0)(ACR_JNISTDARGS, jobject dst,
-                                           jlong doff, jlong size, jint c)
+ACR_JNI_EXPORT_DECLARE(void, Memory, set0)(ACR_JNISTDARGS, jlong dst,
+                                           jlong size, jint c)
 {
-    size_t  dl;
-    size_t  dn = (size_t)doff;
     size_t  cs = (size_t)size;
-    char    *d = (char *)ACR_PointerGet(_E, dst, &dl);
+    char    *d = J2P(dst, char *);
 
-    if (!d) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (doff < 0L || size < 1L) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
-        return;
-    }
-    if ((dn + size) > dl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
     /* Do a memset */
     __TRY
     {
-        memset(d + dn, c, cs);
+        memset(d, c, cs);
     }
     __EXCEPT
     {
@@ -1111,4 +1044,3 @@
     }
     (*_E)->GetDoubleArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
 }
-

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c?rev=887847&r1=887846&r2=887847&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Mon Dec  7 06:34:41 2009
@@ -28,14 +28,10 @@
 /**
  * Pointer class utilities
  */
-#if CC_SIZEOF_VOIDP == 8
-#define ACR_PTR_EXPORT_DECLARE(RT, FN)  \
-    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_Pointer64_##FN
-
 J_DECLARE_CLAZZ = {
     NULL,
     NULL,
-    ACR_CLASS_PATH "Pointer64"
+    ACR_CLASS_PATH "GenericPointer"
 };
 
 J_DECLARE_M_ID(0000) = {
@@ -44,44 +40,26 @@
     "(JJJ)V"
 };
 
-#else
-#define ACR_PTR_EXPORT_DECLARE(RT, FN)  \
-    JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_Pointer32_##FN
-
-J_DECLARE_CLAZZ = {
-    NULL,
-    NULL,
-    ACR_CLASS_PATH "Pointer32"
-};
-
-J_DECLARE_M_ID(0000) = {
-    NULL,
-    "<init>",
-    "(III)V"
-};
-
-#endif
-
 J_DECLARE_F_ID(0000) = {
     NULL,
     "POINTER",
-    IFIELD_PTR
+    "J"
 };
 
 J_DECLARE_F_ID(0001) = {
     NULL,
     "CLEANUP",
-    IFIELD_PTR
+    "J"
 };
 
 J_DECLARE_F_ID(0002) = {
     NULL,
     "PLENGTH",
-    IFIELD_PTR
+    "J"
 };
 
 
-ACR_CLASS_LDEF(AbstractPointer)
+ACR_CLASS_LDEF(GenericPointer)
 {
     int rv;
 
@@ -95,7 +73,7 @@
     return ACR_SUCCESS;
 }
 
-ACR_CLASS_UDEF(AbstractPointer)
+ACR_CLASS_UDEF(GenericPointer)
 {
     ACR_UnloadClass(_E, &_clazzn);
 }
@@ -110,7 +88,7 @@
 
 static int initp0(JNIEnv *_E)
 {
-    ACR_CLASS_LRUN(AbstractPointer);
+    ACR_CLASS_LRUN(GenericPointer);
     return 0;
 }
 
@@ -122,7 +100,7 @@
 }
 #endif
 
-ACR_JNI_EXPORT_DECLARE(jobject, AbstractPointer, nullp0)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(jobject, Pointer, nullp0)(ACR_JNISTDARGS)
 {
     UNREFERENCED_O;
     if (!_clazzn.i) {
@@ -131,7 +109,7 @@
     return ACR_NewBasicPointer(_E, 0, 0, NULL);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, AbstractPointer, cleanup0)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Pointer, cleanup0)(ACR_JNISTDARGS)
 {
     if (_clazzn.i && J4MID(0000)) {
         acr_pointer_cleanup_fn_t *cleanup;
@@ -156,7 +134,7 @@
 
 }
 
-ACR_JNI_EXPORT_DECLARE(void, AbstractPointer, cleanup1)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Pointer, cleanup1)(ACR_JNISTDARGS)
 {
     if (_clazzn.i && J4MID(0000)) {
         acr_pointer_cleanup_fn_t *cleanup;
@@ -174,74 +152,14 @@
     }
 }
 
-ACR_PTR_EXPORT_DECLARE(jint, peek0)(ACR_JNISTDARGS, jniptr a)
-{
-    jint rv = 0;
-    UNREFERENCED_O;
-
-    __TRY
-    {
-        rv = *(N2P(a, char *));
-    }
-    __EXCEPT
-    {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
-    }
-    __ENDTRY
-    return rv;
-}
-
-ACR_PTR_EXPORT_DECLARE(void, poke0)(ACR_JNISTDARGS, jniptr a, jint v)
-{
-    UNREFERENCED_O;
-    __TRY
-    {
-        *(N2P(a, char *)) = (char)(v & 0xFF);
-    }
-    __EXCEPT
-    {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
-    }
-    __ENDTRY
-}
-
-ACR_PTR_EXPORT_DECLARE(void, copy0)(ACR_JNISTDARGS, jniptr s,
-                                    jniptr d, jniptr l)
-{
-    UNREFERENCED_O;
-    __TRY
-    {
-        memcpy(N2P(d, void *), N2P(s, const void *), (size_t)l);
-    }
-    __EXCEPT {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
-    }
-    __ENDTRY
-}
-
-ACR_PTR_EXPORT_DECLARE(void, move0)(ACR_JNISTDARGS, jniptr s,
-                                    jniptr d, jniptr l)
-{
-    UNREFERENCED_O;
-    __TRY
-    {
-        memmove(N2P(d, void *), N2P(s, const void *), (size_t)l);
-    }
-    __EXCEPT
-    {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
-    }
-    __ENDTRY
-}
-
-ACR_PTR_EXPORT_DECLARE(int, memcmp0)(ACR_JNISTDARGS, jniptr a,
-                                     jniptr b, jniptr n)
+ACR_JNI_EXPORT_DECLARE(int, Pointer, memcmp0)(ACR_JNISTDARGS, jlong a,
+                                              jlong b, jlong n)
 {
     int rv;
     UNREFERENCED_O;
     __TRY
     {
-        rv = memcmp(N2P(a, void *), N2P(b, const void *), (size_t)n);
+        rv = memcmp(J2P(a, const void *), J2P(b, const void *), (size_t)n);
         if (rv)
             rv = rv > 0 ? 1 : -1;
     }
@@ -259,7 +177,7 @@
 {
     if (_clazzn.i && J4MID(0000))
         return (*_E)->NewObject(_E, _clazzn.i, J4MID(0000),
-                                P2N(p), P2N(cb), (acr_ptr_t)len);
+                                P2J(p), P2J(cb), (jlong)len);
     else {
         ACR_SET_OS_ERROR(ACR_ECLASSNOTFOUND);
         return NULL;



Mime
View raw message