Author: infinity0
Date: 2009-03-30 23:51:44 +0000 (Mon, 30 Mar 2009)
New Revision: 26260

Modified:
   trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native16Code.java
   trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native8Code.java
   trunk/contrib/fec/lib/linux/x86_64/libfec16.so
   trunk/contrib/fec/lib/linux/x86_64/libfec8.so
   trunk/contrib/fec/src/csrc/Makefile
   trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native16Code.h
   trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native8Code.h
   trunk/contrib/fec/src/csrc/fec.c
   trunk/contrib/fec/src/csrc/fec16-jinterf.c
   trunk/contrib/fec/src/csrc/fec8-jinterf.c
Log:
fix native FEC impl on amd64

Modified: trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native16Code.java
===================================================================
--- trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native16Code.java   
2009-03-30 13:57:14 UTC (rev 26259)
+++ trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native16Code.java   
2009-03-30 23:51:44 UTC (rev 26260)
@@ -18,7 +18,7 @@
     // One must be very very careful not to let code escape, it stores the
     // memory address of a fec_parms struct and if modified could give an
     // attacker the ability to point to anything in memory.
-    private int code;
+    private final long code;
     
     static {
         String path = NativeDeployer.getLibraryPath
@@ -59,15 +59,15 @@
     }
 
     protected native void nativeEncode
-        (int code, byte[][] src, int[] srcOff, int[] index, byte[][] repair, 
+        (long code, byte[][] src, int[] srcOff, int[] index, byte[][] repair, 
          int[] repairOff, int k, int packetLength);
 
-    protected native void nativeDecode(int code, byte[][] pkts, int[] pktsOff,
+    protected native void nativeDecode(long code, byte[][] pkts, int[] pktsOff,
                                        int[] index, int k, int packetLength);
 
-    protected synchronized native int nativeNewFEC(int k, int n);
+    protected synchronized native long nativeNewFEC(int k, int n);
 
-    protected synchronized native void nativeFreeFEC(int code);
+    protected synchronized native void nativeFreeFEC(long code);
 
     protected void finalize() throws Throwable {
         nativeFreeFEC(code);

Modified: trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native8Code.java
===================================================================
--- trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native8Code.java    
2009-03-30 13:57:14 UTC (rev 26259)
+++ trunk/contrib/fec/fec_src/com/onionnetworks/fec/Native8Code.java    
2009-03-30 23:51:44 UTC (rev 26260)
@@ -18,7 +18,7 @@
     // One must be very very careful not to let code escape, it stores the
     // memory address of a fec_parms struct and if modified could give an
     // attacker the ability to point to anything in memory.
-    private int code;
+    private final long code;
     
     static {
         String path = NativeDeployer.getLibraryPath
@@ -53,15 +53,15 @@
     }
 
     protected native void nativeEncode
-        (int code, byte[][] src, int[] srcOff, int[] index, byte[][] repair, 
+        (long code, byte[][] src, int[] srcOff, int[] index, byte[][] repair, 
          int[] repairOff, int k, int packetLength);
 
-    protected native void nativeDecode(int code, byte[][] pkts, int[] pktsOff,
+    protected native void nativeDecode(long code, byte[][] pkts, int[] pktsOff,
                                        int[] index, int k, int packetLength);
 
-    protected synchronized native int nativeNewFEC(int k, int n);
+    protected synchronized native long nativeNewFEC(int k, int n);
 
-    protected synchronized native void nativeFreeFEC(int code);
+    protected synchronized native void nativeFreeFEC(long code);
 
     protected void finalize() throws Throwable {
         nativeFreeFEC(code);

Modified: trunk/contrib/fec/lib/linux/x86_64/libfec16.so
===================================================================
(Binary files differ)

Modified: trunk/contrib/fec/lib/linux/x86_64/libfec8.so
===================================================================
(Binary files differ)

Modified: trunk/contrib/fec/src/csrc/Makefile
===================================================================
--- trunk/contrib/fec/src/csrc/Makefile 2009-03-30 13:57:14 UTC (rev 26259)
+++ trunk/contrib/fec/src/csrc/Makefile 2009-03-30 23:51:44 UTC (rev 26260)
@@ -16,8 +16,8 @@
 
 CC=gcc
 # COPT= -O9 -funroll-loops
-COPT= -O1 
-CFLAGS=$(COPT) -Wall # -DTEST
+COPT= -O1
+CFLAGS=$(COPT) -Wall -fPIC# -DTEST -pedantic
 SRCS= fec.c Makefile test.c fec.s.980621e \
        fec.S.980624a \
        fec.S16.980624a
@@ -31,9 +31,8 @@
        $(CC) $(CFLAGS) -DGF_BITS=8 -c -I$(JAVA_HOME)/include/ \
                -I$(JAVA_HOME)/include/linux fec8-jinterf.c \
                -o fec8-jinterf.o ; \
-       mkdir -p ../../lib/fec-linux-x86/lib/linux/x86 ; \
         ld -shared fec8-jinterf.o fec8.o -o \
-               ../../lib/fec-linux-x86/lib/linux/x86/libfec8.so
+               libfec8.so
 
 fec8.o: fec.h fec8.S
        $(CC) $(CFLAGS) -DGF_BITS=8 -c -o fec8.o fec8.S
@@ -45,9 +44,8 @@
        $(CC) $(CFLAGS) -DGF_BITS=16 -c -I$(JAVA_HOME)/include/ \
                -I$(JAVA_HOME)/include/linux fec16-jinterf.c \
                -o fec16-jinterf.o ; \
-       mkdir -p ../../lib/fec-linux-x86/lib/linux/x86 ; \
         ld -shared fec16-jinterf.o fec16.o -o \
-               ../../lib/fec-linux-x86/lib/linux/x86/libfec16.so
+               libfec16.so
 
 fec16.o: fec.h fec16.S
        $(CC) $(CFLAGS) -DGF_BITS=16 -c -o fec16.o fec16.S
@@ -56,7 +54,7 @@
        $(CC) $(CFLAGS) -DGF_BITS=16 -S -o fec16.S fec.c
 
 clean:
-       - rm *.o *.S fec
+       - rm -f *.o *.S fec *so
 
 tgz: $(ALLSRCS)
        tar cvzf vdm`date +%y%m%d`.tgz $(ALLSRCS)

Modified: trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native16Code.h
===================================================================
--- trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native16Code.h     
2009-03-30 13:57:14 UTC (rev 26259)
+++ trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native16Code.h     
2009-03-30 23:51:44 UTC (rev 26260)
@@ -7,38 +7,37 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-/* Inaccessible static: initialized */
 /*
  * Class:     com_onionnetworks_fec_Native16Code
  * Method:    nativeEncode
- * Signature: (I[[B[I[I[[B[III)V
+ * Signature: (J[[B[I[I[[B[III)V
  */
 JNIEXPORT void JNICALL Java_com_onionnetworks_fec_Native16Code_nativeEncode
-  (JNIEnv *, jobject, jint, jobjectArray, jintArray, jintArray, jobjectArray, 
jintArray, jint, jint);
+  (JNIEnv *, jobject, jlong, jobjectArray, jintArray, jintArray, jobjectArray, 
jintArray, jint, jint);
 
 /*
  * Class:     com_onionnetworks_fec_Native16Code
  * Method:    nativeDecode
- * Signature: (I[[B[I[III)V
+ * Signature: (J[[B[I[III)V
  */
 JNIEXPORT void JNICALL Java_com_onionnetworks_fec_Native16Code_nativeDecode
-  (JNIEnv *, jobject, jint, jobjectArray, jintArray, jintArray, jint, jint);
+  (JNIEnv *, jobject, jlong, jobjectArray, jintArray, jintArray, jint, jint);
 
 /*
  * Class:     com_onionnetworks_fec_Native16Code
  * Method:    nativeNewFEC
- * Signature: (II)I
+ * Signature: (II)J
  */
-JNIEXPORT jint JNICALL Java_com_onionnetworks_fec_Native16Code_nativeNewFEC
+JNIEXPORT jlong JNICALL Java_com_onionnetworks_fec_Native16Code_nativeNewFEC
   (JNIEnv *, jobject, jint, jint);
 
 /*
  * Class:     com_onionnetworks_fec_Native16Code
  * Method:    nativeFreeFEC
- * Signature: (I)V
+ * Signature: (J)V
  */
 JNIEXPORT void JNICALL Java_com_onionnetworks_fec_Native16Code_nativeFreeFEC
-  (JNIEnv *, jobject, jint);
+  (JNIEnv *, jobject, jlong);
 
 #ifdef __cplusplus
 }

Modified: trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native8Code.h
===================================================================
--- trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native8Code.h      
2009-03-30 13:57:14 UTC (rev 26259)
+++ trunk/contrib/fec/src/csrc/com_onionnetworks_fec_Native8Code.h      
2009-03-30 23:51:44 UTC (rev 26260)
@@ -7,38 +7,37 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-/* Inaccessible static: initialized */
 /*
  * Class:     com_onionnetworks_fec_Native8Code
  * Method:    nativeEncode
- * Signature: (I[[B[I[I[[B[III)V
+ * Signature: (J[[B[I[I[[B[III)V
  */
 JNIEXPORT void JNICALL Java_com_onionnetworks_fec_Native8Code_nativeEncode
-  (JNIEnv *, jobject, jint, jobjectArray, jintArray, jintArray, jobjectArray, 
jintArray, jint, jint);
+  (JNIEnv *, jobject, jlong, jobjectArray, jintArray, jintArray, jobjectArray, 
jintArray, jint, jint);
 
 /*
  * Class:     com_onionnetworks_fec_Native8Code
  * Method:    nativeDecode
- * Signature: (I[[B[I[III)V
+ * Signature: (J[[B[I[III)V
  */
 JNIEXPORT void JNICALL Java_com_onionnetworks_fec_Native8Code_nativeDecode
-  (JNIEnv *, jobject, jint, jobjectArray, jintArray, jintArray, jint, jint);
+  (JNIEnv *, jobject, jlong, jobjectArray, jintArray, jintArray, jint, jint);
 
 /*
  * Class:     com_onionnetworks_fec_Native8Code
  * Method:    nativeNewFEC
- * Signature: (II)I
+ * Signature: (II)J
  */
-JNIEXPORT jint JNICALL Java_com_onionnetworks_fec_Native8Code_nativeNewFEC
+JNIEXPORT jlong JNICALL Java_com_onionnetworks_fec_Native8Code_nativeNewFEC
   (JNIEnv *, jobject, jint, jint);
 
 /*
  * Class:     com_onionnetworks_fec_Native8Code
  * Method:    nativeFreeFEC
- * Signature: (I)V
+ * Signature: (J)V
  */
 JNIEXPORT void JNICALL Java_com_onionnetworks_fec_Native8Code_nativeFreeFEC
-  (JNIEnv *, jobject, jint);
+  (JNIEnv *, jobject, jlong);
 
 #ifdef __cplusplus
 }

Modified: trunk/contrib/fec/src/csrc/fec.c
===================================================================
--- trunk/contrib/fec/src/csrc/fec.c    2009-03-30 13:57:14 UTC (rev 26259)
+++ trunk/contrib/fec/src/csrc/fec.c    2009-03-30 23:51:44 UTC (rev 26260)
@@ -647,7 +647,7 @@
 fec_free(struct fec_parms *p)
 {
     if (p==NULL ||
-       p->magic != ( ( (FEC_MAGIC ^ p->k) ^ p->n) ^ (int)(p->enc_matrix)) ) {
+       p->magic != ( ( (FEC_MAGIC ^ p->k) ^ p->n) ^ (long)(p->enc_matrix)) ) {
        fprintf(stderr, "bad parameters to fec_free\n");
        return ;
     }
@@ -679,7 +679,7 @@
     retval->k = k ;
     retval->n = n ;
     retval->enc_matrix = NEW_GF_MATRIX(n, k);
-    retval->magic = ( ( FEC_MAGIC ^ k) ^ n) ^ (int)(retval->enc_matrix) ;
+    retval->magic = ( ( FEC_MAGIC ^ k) ^ n) ^ (long)(retval->enc_matrix) ;
     tmp_m = NEW_GF_MATRIX(n, k);
     /*
      * fill the matrix with powers of field elements, starting from 0.

Modified: trunk/contrib/fec/src/csrc/fec16-jinterf.c
===================================================================
--- trunk/contrib/fec/src/csrc/fec16-jinterf.c  2009-03-30 13:57:14 UTC (rev 
26259)
+++ trunk/contrib/fec/src/csrc/fec16-jinterf.c  2009-03-30 23:51:44 UTC (rev 
26260)
@@ -3,6 +3,7 @@
 #include "jni.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <malloc.h>
 #include "com_onionnetworks_fec_Native16Code.h"
 #include "fec.h"
@@ -15,7 +16,7 @@
  */
 JNIEXPORT void JNICALL
     Java_com_onionnetworks_fec_Native16Code_nativeEncode
-    (JNIEnv *env, jobject obj, jint code, jobjectArray src, jintArray srcOff,
+    (JNIEnv *env, jobject obj, jlong code, jobjectArray src, jintArray srcOff,
      jintArray index, jobjectArray ret, jintArray retOff, jint k, 
      jint packetLength) {
     
@@ -120,7 +121,7 @@
  */
 JNIEXPORT void JNICALL
     Java_com_onionnetworks_fec_Native16Code_nativeDecode
-    (JNIEnv *env, jobject obj, jint code, jobjectArray data, jintArray dataOff,
+    (JNIEnv *env, jobject obj, jlong code, jobjectArray data, jintArray 
dataOff,
      jintArray whichdata, jint k, jint packetLength) {
 
     jint *localWhich, *localDataOff;
@@ -184,17 +185,18 @@
 
 }
 
-JNIEXPORT jint JNICALL
+JNIEXPORT jlong JNICALL
     Java_com_onionnetworks_fec_Native16Code_nativeNewFEC
     (JNIEnv * env, jobject obj, jint k, jint n) {
     
-    return (int)fec_new(k,n); 
+    // uintptr_t is needed for systems where sizeof(void*) < sizeof(long)
+    return (long)(uintptr_t)fec_new(k,n); 
 
 }
 
 JNIEXPORT void JNICALL
     Java_com_onionnetworks_fec_Native16Code_nativeFreeFEC
-    (JNIEnv * env, jobject obj, jint code) {
+    (JNIEnv * env, jobject obj, jlong code) {
     
     fec_free((void *)code); 
 

Modified: trunk/contrib/fec/src/csrc/fec8-jinterf.c
===================================================================
--- trunk/contrib/fec/src/csrc/fec8-jinterf.c   2009-03-30 13:57:14 UTC (rev 
26259)
+++ trunk/contrib/fec/src/csrc/fec8-jinterf.c   2009-03-30 23:51:44 UTC (rev 
26260)
@@ -3,6 +3,7 @@
 #include "jni.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <malloc.h>
 #include "com_onionnetworks_fec_Native8Code.h"
 #include "fec.h"
@@ -15,7 +16,7 @@
  */
 JNIEXPORT void JNICALL
     Java_com_onionnetworks_fec_Native8Code_nativeEncode
-    (JNIEnv *env, jobject obj, jint code, jobjectArray src, jintArray srcOff,
+    (JNIEnv *env, jobject obj, jlong code, jobjectArray src, jintArray srcOff,
      jintArray index, jobjectArray ret, jintArray retOff, jint k, 
      jint packetLength) {
     
@@ -120,7 +121,7 @@
  */
 JNIEXPORT void JNICALL
     Java_com_onionnetworks_fec_Native8Code_nativeDecode
-    (JNIEnv *env, jobject obj, jint code, jobjectArray data, jintArray dataOff,
+    (JNIEnv *env, jobject obj, jlong code, jobjectArray data, jintArray 
dataOff,
      jintArray whichdata, jint k, jint packetLength) {
 
     jint *localWhich, *localDataOff;
@@ -184,17 +185,18 @@
 
 }
 
-JNIEXPORT jint JNICALL
+JNIEXPORT jlong JNICALL
     Java_com_onionnetworks_fec_Native8Code_nativeNewFEC
     (JNIEnv * env, jobject obj, jint k, jint n) {
     
-    return (int)fec_new(k,n); 
+    // uintptr_t is needed for systems where sizeof(void*) < sizeof(long)
+    return (long)(uintptr_t)fec_new(k,n);
 
 }
 
 JNIEXPORT void JNICALL
     Java_com_onionnetworks_fec_Native8Code_nativeFreeFEC
-    (JNIEnv * env, jobject obj, jint code) {
+    (JNIEnv * env, jobject obj, jlong code) {
     
     fec_free((void *)code); 
 

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to