code change
[IRC.git] / Robust / src / Runtime / socket.c
index 7c079ac095d87e1abb93c0b2662ac1f71aba380c..7ced4ce3775162f95e16ef702c90360cf6893359 100644 (file)
 #endif
 #include "SimpleHash.h"
 #include "GenericHashtable.h"
+#include "methodheaders.h"
 
 struct RuntimeHash *fdtoobject;
 
+#ifdef D___Socket______nativeConnect____I__AR_B_I
 int CALL24(___Socket______nativeConnect____I__AR_B_I, int ___fd___, int ___port___, struct ___Socket___ * ___this___, int ___fd___, struct ArrayObject * ___address___,int ___port___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -41,8 +43,8 @@ int CALL24(___Socket______nativeConnect____I__AR_B_I, int ___fd___, int ___port_
 #endif
 
   {
-  int flag = 1;
-  setsockopt(___fd___, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(flag));
+    int flag = 1;
+    setsockopt(___fd___, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(flag));
   }
   if (rc<0) goto error;
 
@@ -61,9 +63,11 @@ error:
   return -1;
 #endif
 }
+#endif
 
 #ifdef TASK
-int CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ * ___this___, int ___fd___) {
+#ifdef D___Socket______nativeBindFD____I
+void CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ * ___this___, int ___fd___) {
 #ifdef MULTICORE
 #else
   if (RuntimeHashcontainskey(fdtoobject, ___fd___))
@@ -71,11 +75,11 @@ int CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ *
   RuntimeHashadd(fdtoobject, ___fd___, (int) VAR(___this___));
   addreadfd(___fd___);
 #endif
-  return 0;
 }
 #endif
+#endif
 
-
+#ifdef D___Socket______nativeBind_____AR_B_I
 int CALL12(___Socket______nativeBind_____AR_B_I, int ___port___,  struct ArrayObject * ___address___, int ___port___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -133,7 +137,9 @@ error:
 #endif
 #endif
 }
+#endif
 
+#ifdef D___InetAddress______getHostByName_____AR_B
 struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct ArrayObject * ___hostname___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -153,40 +159,41 @@ struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct A
   h=gethostbyname(str);
   free(str);
 
-       if (h != NULL) {
-               for (n=0; h->h_addr_list[n]; n++) /* do nothing */ ;
+  if (h != NULL) {
+    for (n=0; h->h_addr_list[n]; n++) /* do nothing */;
 
 #ifdef PRECISE_GC
-  arraybytearray=allocate_newarray(___params___,BYTEARRAYARRAYTYPE,n);
+    arraybytearray=allocate_newarray(___params___,BYTEARRAYARRAYTYPE,n);
 #else
-  arraybytearray=allocate_newarray(BYTEARRAYARRAYTYPE,n);
+    arraybytearray=allocate_newarray(BYTEARRAYARRAYTYPE,n);
 #endif
-  for(i=0; i<n; i++) {
-    struct ArrayObject *bytearray;
+    for(i=0; i<n; i++) {
+      struct ArrayObject *bytearray;
 #ifdef PRECISE_GC
-    {
-      INTPTR ptrarray[]={1, (INTPTR) ___params___, (INTPTR)arraybytearray};
-      bytearray=allocate_newarray(&ptrarray,BYTEARRAYTYPE,h->h_length);
-      arraybytearray=(struct ArrayObject *) ptrarray[2];
-    }
+      {
+        INTPTR ptrarray[]={1, (INTPTR) ___params___, (INTPTR)arraybytearray};
+        bytearray=allocate_newarray(&ptrarray,BYTEARRAYTYPE,h->h_length);
+        arraybytearray=(struct ArrayObject *) ptrarray[2];
+      }
 #else
-    bytearray=allocate_newarray(BYTEARRAYTYPE,h->h_length);
+      bytearray=allocate_newarray(BYTEARRAYTYPE,h->h_length);
 #endif
-    ((void **)&((&arraybytearray->___length___)[1]))[i]=bytearray;
-    {
-      int ha=ntohl(*(int *)h->h_addr_list[i]);
-      (&bytearray->___length___)[1]=ha;
+      ((void **)&((&arraybytearray->___length___)[1]))[i]=bytearray;
+      {
+        int ha=ntohl(*(int *)h->h_addr_list[i]);
+        (&bytearray->___length___)[1]=ha;
+      }
     }
-  }
 
-  return arraybytearray;
+    return arraybytearray;
+  } else {
+    return NULL;
+  }
 #endif
-       }
-       else
-               return NULL;
 }
+#endif
 
-
+#ifdef D___ServerSocket______createSocket____I
 int CALL12(___ServerSocket______createSocket____I, int port, struct ___ServerSocket___ * ___this___, int port) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -291,7 +298,9 @@ int CALL12(___ServerSocket______createSocket____I, int port, struct ___ServerSoc
   return fd;
 #endif
 }
+#endif
 
+#ifdef D___ServerSocket______nativeaccept____L___Socket___
 int CALL02(___ServerSocket______nativeaccept____L___Socket___,struct ___ServerSocket___ * ___this___, struct ___Socket___ * ___s___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -344,7 +353,9 @@ int CALL02(___ServerSocket______nativeaccept____L___Socket___,struct ___ServerSo
   return newfd;
 #endif
 }
+#endif
 
+#ifdef D___Socket______nativeWrite_____AR_B_I_I
 void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, struct ___Socket___ * ___this___, struct ArrayObject * ___b___, int offset, int length) {
 #ifdef MULTICORE
 #else
@@ -356,7 +367,7 @@ void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, str
     while(length>0) {
       bytewritten=write(fd, &charstr[offset], length);
       if (bytewritten==-1&&errno!=EAGAIN)
-       break;
+        break;
       length-=bytewritten;
       offset+=bytewritten;
     }
@@ -369,7 +380,10 @@ void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, str
   }
 #endif
 }
+#endif
+
 
+#ifdef D___Socket______nativeRead_____AR_B
 int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___, struct ArrayObject * ___b___) {
 #ifdef MULTICORE
   return -1;
@@ -422,7 +436,9 @@ int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___,
   return byteread;
 #endif
 }
+#endif
 
+#ifdef D___Socket______nativeClose____
 void CALL01(___Socket______nativeClose____, struct ___Socket___ * ___this___) {
 #ifdef MULTICORE
 #else
@@ -438,3 +454,4 @@ void CALL01(___Socket______nativeClose____, struct ___Socket___ * ___this___) {
   close(fd);
 #endif
 }
+#endif