From ea722b614396ae6611712a33b60d6a1fc0ccd944 Mon Sep 17 00:00:00 2001 From: idgay Date: Tue, 5 Jun 2007 21:08:55 +0000 Subject: [PATCH] fix a serial bug force 32-bit compilation (JDKs seem to want that) --- tools/tinyos/java/serial/Makefile.am | 2 +- tools/tinyos/java/serial/NativeSerial_linux.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/tinyos/java/serial/Makefile.am b/tools/tinyos/java/serial/Makefile.am index 7909a9e8..2db55771 100644 --- a/tools/tinyos/java/serial/Makefile.am +++ b/tools/tinyos/java/serial/Makefile.am @@ -19,7 +19,7 @@ toscomm_dll_SOURCES = \ TOSComm_wrap.cxx libtoscomm.so: $(libtoscomm_so_SOURCES) - $(CXX) -O2 -shared -fPIC "-I$(JDK)/include" "-I$(JDK)/include/linux" \ + $(CXX) -m32 -O2 -shared -fPIC "-I$(JDK)/include" "-I$(JDK)/include/linux" \ -o $@ NativeSerial_linux.cpp toscomm.dll: $(toscomm_dll_SOURCES) diff --git a/tools/tinyos/java/serial/NativeSerial_linux.cpp b/tools/tinyos/java/serial/NativeSerial_linux.cpp index 7e66a910..76b1fee3 100644 --- a/tools/tinyos/java/serial/NativeSerial_linux.cpp +++ b/tools/tinyos/java/serial/NativeSerial_linux.cpp @@ -348,22 +348,23 @@ note( "waitForEvent begin" ); fd_set input; struct timeval tv; m_events_out = 0; + int fd = m_fd; while( m_wait_for_events && (m_fd != -1) && (m_events_out == 0) ) { FD_ZERO( &input ); - FD_SET( m_fd, &input ); + FD_SET( fd, &input ); tv.tv_sec = 0; tv.tv_usec = 100*1000; // 1ms is the minimum resolution, at best - if( select( m_fd+1, &input, NULL, NULL, &tv ) == -1 ) + if( select( fd+1, &input, NULL, NULL, &tv ) == -1 ) { if( errno == EINTR ) break; errno_wrap( true, "waitForEvent.select" ); } - if( FD_ISSET( m_fd, &input ) ) + if( FD_ISSET( fd, &input ) ) m_events_out |= DATA_AVAILABLE; } -- 2.39.2