You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/05/10 09:07:15 UTC

svn commit: r1101344 - in /commons/sandbox/runtime/trunk/src/main/native/os: unix/arch_defs.h win32/arch_defs.h win32/inetsock.c

Author: mturk
Date: Tue May 10 07:07:14 2011
New Revision: 1101344

URL: http://svn.apache.org/viewvc?rev=1101344&view=rev
Log:
Add macros for casting sockets from jint

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/inetsock.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h?rev=1101344&r1=1101343&r2=1101344&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h Tue May 10 07:07:14 2011
@@ -73,6 +73,8 @@ typedef struct stat         struct_stat_
 # endif
 #endif
 
+#define I2H(I)              (void *)((intptr_t)(I))
+#define I2SOCK(I)           (I)
 #define ACR_PATH_MAX        8192
 #define ACR_CRLF            "\n"
 /* Any value will do */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h?rev=1101344&r1=1101343&r2=1101344&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h Tue May 10 07:07:14 2011
@@ -41,6 +41,7 @@
 #endif
 
 #define I2H(I)                  (HANDLE)IntToPtr((I))
+#define I2SOCK(I)               (SOCKET)IntToPtr((I))
 #define ACR_CRLF                "\r\n"
 #define ACR__THREAD(pg)         _cr__thread(pg)
 #define RESOURCE_NAME_LEN       64

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/inetsock.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/inetsock.c?rev=1101344&r1=1101343&r2=1101344&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/inetsock.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/inetsock.c Tue May 10 07:07:14 2011
@@ -24,7 +24,7 @@
 
 ACR_NET_EXPORT(jint, SocketDescriptor, close0)(JNI_STDARGS, jint fd)
 {
-    if (closesocket((SOCKET)fd) == -1)
+    if (closesocket(I2SOCK(fd)) == -1)
         return ACR_GET_OS_ERROR();
     else
         return 0;
@@ -32,7 +32,7 @@ ACR_NET_EXPORT(jint, SocketDescriptor, c
 
 ACR_NET_EXPORT(jint, SocketDescriptor, sync0)(JNI_STDARGS, jint fd)
 {
-    if (send((SOCKET)fd, (const char *)&fd, 0, 0) == -1)
+    if (send(I2SOCK(fd), (const char *)&fd, 0, 0) == -1)
         return ACR_GET_OS_ERROR();
     else
         return 0;