Skip to content
Browse files

Fixing (I hope) problems on 64-bit Linux systems.

  • Loading branch information...
1 parent a8fc175 commit 97d67464ae4870a4003d5d8d548f6a72543964dd @damellis damellis committed Feb 16, 2011
Showing with 16 additions and 7 deletions.
  1. +14 −6 src/SerialImp.c
  2. +2 −1 src/SerialImp.h
View
20 src/SerialImp.c
@@ -1337,7 +1337,7 @@ int init_threads( struct event_info_struct *eis )
report("init_threads: get eis\n");
jeis = (*eis->env)->GetFieldID( eis->env, eis->jclazz, "eis", "J" );
report("init_threads: set eis\n");
- (*eis->env)->SetIntField(eis->env, *eis->jobj, jeis, ( size_t ) eis );
+ (*eis->env)->SetLongField(eis->env, *eis->jobj, jeis, ( size_t ) eis );
report("init_threads: stop\n");
report_time_end( );
return( 1 );
@@ -1530,7 +1530,7 @@ JNIEXPORT jboolean JNICALL RXTXPort(nativeDrain)( JNIEnv *env,
jobject jobj, jboolean interrupted )
{
int fd = get_java_var( env, jobj,"fd","I" );
- struct event_info_struct *eis = ( struct event_info_struct * ) get_java_var( env, jobj, "eis", "J" );
+ struct event_info_struct *eis = ( struct event_info_struct * ) get_java_var_long( env, jobj, "eis", "J" );
int result, count=0;
char message[80];
@@ -2939,7 +2939,7 @@ int read_byte_array( JNIEnv *env,
/* TRENT */
int flag, count = 0;
struct event_info_struct *eis = ( struct event_info_struct * )
- get_java_var( env, *jobj,"eis","J" );
+ get_java_var_long( env, *jobj,"eis","J" );
report_time_start();
flag = eis->eventflags[SPE_DATA_AVAILABLE];
@@ -4873,9 +4873,9 @@ get_java_var
exceptions: none
comments:
----------------------------------------------------------*/
-size_t get_java_var( JNIEnv *env, jobject jobj, char *id, char *type )
+long get_java_var_long( JNIEnv *env, jobject jobj, char *id, char *type )
{
- int result = 0;
+ long result = 0;
jclass jclazz = (*env)->GetObjectClass( env, jobj );
jfieldID jfd = (*env)->GetFieldID( env, jclazz, id, type );
@@ -4889,7 +4889,11 @@ size_t get_java_var( JNIEnv *env, jobject jobj, char *id, char *type )
LEAVE( "get_java_var" );
return result;
}
- result = (int)( (*env)->GetIntField( env, jobj, jfd ) );
+ if ( !strcmp( type, "J" ) ) {
+ result = (long)( (*env)->GetLongField( env, jobj, jfd ) );
+ } else {
+ result = (int) ( (*env)->GetIntField( env, jobj, jfd ) );
+ }
/* ct7 & gel * Added DeleteLocalRef */
(*env)->DeleteLocalRef( env, jclazz );
if(!strncmp( "fd",id,2) && result == 0)
@@ -4900,6 +4904,10 @@ size_t get_java_var( JNIEnv *env, jobject jobj, char *id, char *type )
return result;
}
+int get_java_var( JNIEnv *env, jobject jobj, char *id, char *type ) {
+ return (int) get_java_var_long( env, jobj, id, type );
+}
+
/*----------------------------------------------------------
throw_java_exception
View
3 src/SerialImp.h
@@ -413,7 +413,8 @@ int translate_parity( JNIEnv *, tcflag_t *, jint );
void system_wait();
void finalize_event_info_struct( struct event_info_struct * );
int read_byte_array( JNIEnv *, jobject *, int, unsigned char *, int, int );
-size_t get_java_var( JNIEnv *, jobject, char *, char * );
+int get_java_var( JNIEnv *, jobject, char *, char * );
+long get_java_var_long( JNIEnv *, jobject, char *, char * );
jboolean is_interrupted( struct event_info_struct * );
int send_event(struct event_info_struct *, jint, int );
void dump_termios(char *,struct termios *);

0 comments on commit 97d6746

Please sign in to comment.
Something went wrong with that request. Please try again.