Hi,

here comes the target native layer implementation for the MinGW platform.
Nothing funky, for the most part this forwards to the generic/posix
impl. I would think that somebody with some more knowledge of the build
machinery must implement to include that target when compiling on MinGW.

2006-01-16  Roman Kennke  <[EMAIL PROTECTED]>

        * native/target/MinGW/target_native.h,
        * native/target/MinGW/target_native_file.h,
        * native/target/MinGW/target_native_io.h,
        * native/target/MinGW/target_native_math.h,
        * native/target/MinGW/target_native_memory.h,
        * native/target/MinGW/target_native_misc.h,
        * native/target/MinGW/target_native_network.h:
        New files. Implement the target native layer for the MinGW
        platform.

/Roman
Index: native/target/MinGW/target_native.h
===================================================================
RCS file: native/target/MinGW/target_native.h
diff -N native/target/MinGW/target_native.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/target/MinGW/target_native.h	16 Jan 2006 12:41:06 -0000
@@ -0,0 +1,82 @@
+/* target_native.h - Some general definitions for the MinGW platform
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+Description: MinGW target global defintions
+Systems    : all
+*/
+
+#ifndef __TARGET_NATIVE__
+#define __TARGET_NATIVE__
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <stdlib.h>
+#include <winsock.h>
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+
+#define TARGET_NATIVE_ERROR_CONNECTION_REFUSED WSAECONNREFUSED
+#define TARGET_NATIVE_ERROR_TIMEDOUT           WSAETIMEDOUT
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* include rest of definitions from generic file (do not move it to 
+   another position!) */
+#include "target_generic.h"
+
+#endif /* __TARGET_NATIVE__ */
+
+/* end of file */
Index: native/target/MinGW/target_native_file.h
===================================================================
RCS file: native/target/MinGW/target_native_file.h
diff -N native/target/MinGW/target_native_file.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/target/MinGW/target_native_file.h	16 Jan 2006 12:41:06 -0000
@@ -0,0 +1,143 @@
+/* target_native_file.h - File operations for the MinGW platform
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+Description: MinGW target defintions of file functions
+Systems    : all
+*/
+
+#ifndef __TARGET_NATIVE_FILE__
+#define __TARGET_NATIVE_FILE__
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <io.h>
+#include <windows.h>
+#include <winbase.h>
+
+#include "target_native.h"
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+#define TARGET_NATIVE_FILE_FILEFLAG_SYNC  0
+#define TARGET_NATIVE_FILE_FILEFLAG_DSYNC 0
+
+#define TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL (S_IRUSR | S_IWUSR)
+#define TARGET_NATIVE_FILE_FILEPERMISSION_PRIVATE (S_IRUSR | S_IWUSR)
+#define TARGET_NATIVE_FILE_FILEPERMISSION_READONLY (~(S_IWRITE))
+
+/* not available */
+#define TARGET_NATIVE_FILE_LOCKMODE_READ  0
+#define TARGET_NATIVE_FILE_LOCKMODE_WRITE 0
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+#define TARGET_NATIVE_FILE_OPEN(filename,filedescriptor,flags,permissions,result) \
+  do { \
+    filedescriptor=open(filename, \
+                        flags, \
+                        permissions \
+                        ); \
+    result=(filedescriptor>=0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+   } while (0)
+
+#define TARGET_NATIVE_FILE_TRUNCATE(filedescriptor,offset,result) \
+  do { \
+    result=(chsize(filedescriptor,offset)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+
+#define TARGET_NATIVE_FILE_IS_EXECUTABLE(filename,result) \
+  do { \
+    const char *__FILE_EXTENSIONS[] = {"",".exe",".com",".bat"}; \
+    \
+    int         __z; \
+    char        __tmpFilename[MAX_PATH]; \
+    struct stat __statBuffer; \
+    \
+    __z = 0; \
+    do { \
+      strncpy(__tmpFilename,filename,MAX_PATH); \
+      strncat(__tmpFilename,__FILE_EXTENSIONS[__z],MAX_PATH-strlen(__tmpFilename)); \
+      result = ((stat(__tmpFilename,&__statBuffer)==0) && (S_ISREG(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+      __z++; \
+    } while ((result == TARGET_NATIVE_ERROR) && (__z<4)); \
+  } while (0)
+
+#define TARGET_NATIVE_FILE_MAKE_DIR(name,result) \
+  do { \
+    result=((mkdir(name)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR); \
+  } while (0)
+
+#define TARGET_NATIVE_FILE_FSYNC(filedescriptor,result) \
+  do { \
+    result=TARGET_NATIVE_OK; \
+  } while (0)
+
+#define TARGET_NATIVE_FILE_LOCK(filedescriptor,mode,offset,length,wait,result) \
+  do { \
+    result=TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_FILE_UNLOCK(filedescriptor,offset,length,result) \
+  do { \
+    result=TARGET_NATIVE_ERROR; \
+  } while (0)
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* include rest of definitions from generic file (do not move it to 
+   another position!) */
+#include "target_generic_file.h"
+
+#endif /* __TARGET_NATIVE_FILE__ */
+
+/* end of file */
Index: native/target/MinGW/target_native_io.h
===================================================================
RCS file: native/target/MinGW/target_native_io.h
diff -N native/target/MinGW/target_native_io.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/target/MinGW/target_native_io.h	16 Jan 2006 12:41:06 -0000
@@ -0,0 +1,85 @@
+/* target_native_io.h - Native methods for I/O operations
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+Description: MinGW target defintions of I/O functions
+Systems    : all
+*/
+
+#ifndef __TARGET_NATIVE_IO__
+#define __TARGET_NATIVE_IO__
+
+/* check if target_native_io.h included */
+#ifndef __TARGET_NATIVE_IO__
+  #error Do NOT INCLUDE generic target files! Include the corresponding native target files instead!
+#endif
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "target_native.h"
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* include rest of definitions from generic file (do not move it to 
+   another position!) */
+#include "target_generic_io.h"
+
+#endif /* __TARGET_NATIVE_IO__ */
+
+/* end of file */
Index: native/target/MinGW/target_native_math.h
===================================================================
RCS file: native/target/MinGW/target_native_math.h
diff -N native/target/MinGW/target_native_math.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/target/MinGW/target_native_math.h	16 Jan 2006 12:41:06 -0000
@@ -0,0 +1,81 @@
+/* target_native_math.h - Math operations for the MinGW platform
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+Description: MinGW target defintions of int/int64 constants/
+             macros/functions
+Systems    : all
+*/
+
+#ifndef __TARGET_NATIVE_MATH__
+#define __TARGET_NATIVE_MATH__
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <stdlib.h>
+
+#include "target_native.h"
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* include rest of definitions from generic file (do not move it to 
+   another position!) */
+#include "target_generic_math.h"
+
+#endif /* __TARGET_NATIVE_MATH__ */
+
+/* end of file */
Index: native/target/MinGW/target_native_memory.h
===================================================================
RCS file: native/target/MinGW/target_native_memory.h
diff -N native/target/MinGW/target_native_memory.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/target/MinGW/target_native_memory.h	16 Jan 2006 12:41:06 -0000
@@ -0,0 +1,86 @@
+/* target_native_memory.h - Memory operations for the MinGW platform
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+Description: MinGW target defintions of memory functions
+Systems    : all
+*/
+
+#ifndef __TARGET_NATIVE_MEMORY__
+#define __TARGET_NATIVE_MEMORY__
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <stdlib.h>
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+#define TARGET_NATIVE_MEMORY_MAP_PROTECTION_NONE    0
+#define TARGET_NATIVE_MEMORY_MAP_PROTECTION_READ    FILE_MAP_READ
+#define TARGET_NATIVE_MEMORY_MAP_PROTECTION_WRITE   FILE_MAP_WRITE
+#define TARGET_NATIVE_MEMORY_MAP_PROTECTION_EXECUTE 0
+
+#define TARGET_NATIVE_MEMORY_MAP_FLAGS_FIXED   0
+#define TARGET_NATIVE_MEMORY_MAP_FLAGS_SHARED  0
+#define TARGET_NATIVE_MEMORY_MAP_FLAGS_PRIVATE 0
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* include rest of definitions from generic file (do not move it to 
+   another position!) */
+#include "target_generic_memory.h"
+
+#endif /* __TARGET_NATIVE_MEMORY__ */
+
+/* end of file */
Index: native/target/MinGW/target_native_misc.h
===================================================================
RCS file: native/target/MinGW/target_native_misc.h
diff -N native/target/MinGW/target_native_misc.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/target/MinGW/target_native_misc.h	16 Jan 2006 12:41:06 -0000
@@ -0,0 +1,80 @@
+/* target_native_misc.h - Miscallaneous operations for the MinGW platform
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+Description: MinGW target defintions of miscellaneous functions
+Systems    : all
+*/
+
+#ifndef __TARGET_NATIVE_MISC__
+#define __TARGET_NATIVE_MISC__
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <stdlib.h>
+
+#include "target_native.h"
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* include rest of definitions from generic file (do not move it to 
+   another position!) */
+#include "target_generic_misc.h"
+
+#endif /* __TARGET_NATIVE_MISC__ */
+
+/* end of file */
Index: native/target/MinGW/target_native_network.h
===================================================================
RCS file: native/target/MinGW/target_native_network.h
diff -N native/target/MinGW/target_native_network.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/target/MinGW/target_native_network.h	16 Jan 2006 12:41:06 -0000
@@ -0,0 +1,522 @@
+/* target_native_network.h - Networking operations for the MinGW platform
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+/*
+Description: MinGW target defintions of network functions
+Systems    : all
+*/
+
+#ifndef __TARGET_NATIVE_NETWORK__
+#define __TARGET_NATIVE_NETWORK__
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <stdlib.h>
+#include <windows.h>
+#include <winbase.h>
+#include <winsock.h>
+
+#include "target_native.h"
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/* Hint: target generic macros can not be used, because of completely
+   different header files and some different datatypes
+*/
+
+#define TARGET_NATIVE_NETWORK_GET_IPADDRESS_ANY() \
+  INADDR_ANY
+
+#define TARGET_NATIVE_NETWORK_GET_HOSTNAME(name,maxNameLength,result) \
+  do { \
+    result=(gethostname(name,maxNameLength-1) == 0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    name[maxNameLength-1]='\0'; \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS(address,name,maxNameLen,result) \
+  do { \
+    int            __networkAddress; \
+    struct hostent *__hostEntry; \
+    \
+    __networkAddress=htonl(address); \
+    __hostEntry = gethostbyaddr((char*)&__networkAddress,sizeof(__networkAddress),AF_INET); \
+    if (__hostEntry!=NULL) \
+    { \
+      strncpy(name,__hostEntry->h_name,maxNameLen-1); \
+      name[maxNameLen]='\0'; \
+      result=TARGET_NATIVE_OK; \
+    } \
+    else \
+    { \
+      result=TARGET_NATIVE_ERROR; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_BY_NAME(name,addresses,maxAddressSize,addressCount,result) \
+  do { \
+    struct hostent *__hostEntry; \
+    \
+    addressCount = 0; \
+    __hostEntry = gethostbyname(name); \
+    if (__hostEntry != NULL) \
+    { \
+      while ((addressCount<maxAddressSize) && (__hostEntry->h_addr_list[addressCount]!=NULL)) \
+      { \
+        addresses[addressCount]=ntohl(*(int*)(__hostEntry->h_addr_list[addressCount])); \
+        addressCount++; \
+      } \
+      result=TARGET_NATIVE_OK; \
+    } \
+    else \
+    { \
+        result=TARGET_NATIVE_ERROR; \
+    } \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM(socketDescriptor,result) \
+  do { \
+    SOCKET __socket; \
+    \
+    socketDescriptor = 0; \
+    \
+    __socket = socket(AF_INET,SOCK_STREAM,0); \
+    if (__socket != INVALID_SOCKET) \
+    { \
+      socketDescriptor = (int)__socket; \
+      result = TARGET_NATIVE_OK; \
+    } \
+    else \
+    { \
+      result = TARGET_NATIVE_ERROR; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM(socketDescriptor,result) \
+  do { \
+    SOCKET __socket; \
+    \
+    socketDescriptor = 0; \
+    \
+    __socket = socket(AF_INET,SOCK_DGRAM,0); \
+    if (__socket != INVALID_SOCKET) \
+    { \
+      socketDescriptor = (int)__socket; \
+      result = TARGET_NATIVE_OK; \
+    } \
+    else \
+    { \
+      result = TARGET_NATIVE_ERROR; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_CLOSE(socketDescriptor,result) \
+  do { \
+    result=(closesocket(socketDescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_SHUTDOWN_INPUT(socketDescriptor,result) \
+  do { \
+    result=(shutdown(socketDescriptor,SD_RECEIVE)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_SHUTDOWN_OUTPUT(socketDescriptor,result) \
+  do { \
+    result=(shutdown(socketDescriptor,SD_SEND)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_CONNECT(socketDescriptor,address,port,result) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    \
+    memset(&__socketAddress,0,sizeof(__socketAddress)); \
+    __socketAddress.sin_family      = AF_INET; \
+    __socketAddress.sin_addr.s_addr = htonl(address); \
+    __socketAddress.sin_port        = htons(((short)port)); \
+    \
+    result=(connect(socketDescriptor,(const struct sockaddr FAR*)&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_BIND(socketDescriptor,address,port,result) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    \
+    memset(&__socketAddress,0,sizeof(__socketAddress)); \
+    __socketAddress.sin_family      = AF_INET; \
+    __socketAddress.sin_addr.s_addr = htonl(address); \
+    __socketAddress.sin_port        = htons(((short)port)); \
+    \
+    result=(bind(socketDescriptor,(const struct sockaddr FAR*)&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_LISTEN(socketDescriptor,maxQueueLength,result) \
+  do { \
+    result=(listen(socketDescriptor,maxQueueLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_ACCEPT(socketDescriptor,newSocketDescriptor,result) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    int                __socketAddressLength; \
+    \
+    memset(&__socketAddress,0,sizeof(__socketAddress)); \
+    __socketAddressLength=sizeof(__socketAddress); \
+    newSocketDescriptor=accept(socketDescriptor,(struct sockaddr FAR*)&__socketAddress,&__socketAddressLength); \
+    result=(newSocketDescriptor!=INVALID_SOCKET)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO(socketDescriptor,localAddress,localPort,result) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    int                __socketAddressLength; \
+    \
+    localAddress=0; \
+    localPort   =0; \
+    \
+    __socketAddressLength=sizeof(__socketAddress); \
+    result=(getsockname(socketDescriptor,(struct sockaddr FAR*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__socketAddressLength>=sizeof(__socketAddress)); \
+      localAddress=ntohl(__socketAddress.sin_addr.s_addr); \
+      localPort   =ntohs(__socketAddress.sin_port); \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO(socketDescriptor,remoteAddress,remotePort,result) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    int                __socketAddressLength; \
+    \
+    remoteAddress=0; \
+    remotePort   =0; \
+    \
+    __socketAddressLength=sizeof(__socketAddress); \
+    result=(getpeername(socketDescriptor,(struct sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__socketAddressLength>=sizeof(__socketAddress)); \
+      remoteAddress=ntohl(__socketAddress.sin_addr.s_addr); \
+      remotePort   =ntohs(__socketAddress.sin_port); \
+    } \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE(socketDescriptor,bytesAvailable,result) \
+  do { \
+    u_long __value; \
+    \
+    bytesAvailable=0; \
+    \
+    result=(ioctlsocket(socketDescriptor,FIONREAD,&__value)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      bytesAvailable=__value; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_RECEIVE(socketDescriptor,buffer,maxLength,bytesReceived) \
+  do { \
+    bytesReceived=recv(socketDescriptor,buffer,maxLength,0); \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT(socketDescriptor,buffer,maxLength,address,port,bytesReceived) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    int                __socketAddressLength; \
+    \
+    port=0; \
+    \
+    memset(&__socketAddress,0,sizeof(__socketAddress)); \
+    __socketAddressLength=sizeof(__socketAddress); \
+    bytesReceived=recvfrom(socketDescriptor,buffer,maxLength,0,(struct sockaddr FAR*)&__socketAddress,&__socketAddressLength); \
+    if (__socketAddressLength==sizeof(__socketAddress)) \
+    { \
+      address=ntohl(__socketAddress.sin_addr.s_addr); \
+      port   =ntohs(__socketAddress.sin_port); \
+    } \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_SEND(socketDescriptor,buffer,length,bytesSent) \
+  do { \
+    bytesSent=send(socketDescriptor,buffer,length,0); \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT(socketDescriptor,buffer,length,address,port,bytesSent) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    \
+    memset(&__socketAddress,0,sizeof(__socketAddress)); \
+    __socketAddress.sin_family      = AF_INET; \
+    __socketAddress.sin_addr.s_addr = htonl(address); \
+    __socketAddress.sin_port        = htons((short)port); \
+    bytesSent=sendto(socketDescriptor,buffer,length,0,(struct sockaddr FAR*)&__socketAddress,sizeof(__socketAddress)); \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY(socketDescriptor,flag,result) \
+  do { \
+    BOOL __value; \
+    \
+    __value=flag; \
+    result=(setsockopt(socketDescriptor,IPPROTO_TCP,TCP_NODELAY,(const char FAR*)&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER(socketDescriptor,flag,value,result) \
+  do { \
+    struct linger __linger; \
+    \
+    memset(&__linger,0,sizeof(__linger)); \
+    if (flag) \
+    { \
+      __linger.l_onoff=0; \
+    } \
+    else \
+    { \
+      __linger.l_linger=value; \
+      __linger.l_onoff =1; \
+    } \
+    result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_LINGER,(const char FAR*)&__linger,sizeof(__linger))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result) \
+  do { \
+    result = TARGET_NATIVE_OK; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF(socketDescriptor,size,result) \
+  do { \
+    int __value; \
+    \
+    __value=size; \
+    result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_SNDBUF,(const char FAR*)&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCVBUF(socketDescriptor,size,result) \
+  do { \
+    int __value; \
+    \
+    __value=size; \
+    result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_RCVBUF,(const char FAR*)&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL(socketDescriptor,value,result) \
+  do { \
+    result = TARGET_NATIVE_OK; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result) \
+  do { \
+    result = TARGET_NATIVE_OK; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result) \
+  do { \
+      BOOL __value; \
+      \
+      __value=flag; \
+      result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,(const char FAR*)&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP(socketDescriptor,address,result) \
+  do { \
+    result = TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP(socketDescriptor,address,result) \
+  do { \
+    result = TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result) \
+  do { \
+    BOOL __value; \
+    \
+    __value=flag; \
+    result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_KEEPALIVE,(const char FAR*)&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST(socketDescriptor,flag,result) \
+  do { \
+    BOOL __value; \
+    \
+    __value=flag; \
+    result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_BROADCAST,(const char FAR*)&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+  } while (0)
+
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY(socketDescriptor,flag,result) \
+  do { \
+    BOOL __value; \
+    int  __len; \
+    \
+    flag=0; \
+    \
+    __len=sizeof(__value); \
+    result=(getsockopt(socketDescriptor,IPPROTO_TCP,TCP_NODELAY,(char FAR*)&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__len>=sizeof(__value)); \
+      flag=__value; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER(socketDescriptor,flag,value,result) \
+  do { \
+    struct linger __linger; \
+    int           __len; \
+    \
+    flag =0; \
+    value=0; \
+    \
+    __len=sizeof(__linger); \
+    result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_LINGER,(char FAR*)&__linger,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__len>=sizeof(__linger)); \
+      flag =__linger.l_onoff; \
+      value=__linger.l_linger; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result) \
+  do { \
+    flag = 0; \
+    result = TARGET_NATIVE_OK; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF(socketDescriptor,size,result) \
+  do { \
+    int __value; \
+    int __len; \
+    \
+    size=0; \
+    \
+    __len=sizeof(__value); \
+    result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_SNDBUF,(char FAR*)&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__len>=sizeof(__value)); \
+      size=__value; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCVBUF(socketDescriptor,size,result) \
+  do { \
+    int __value; \
+    int __len; \
+    \
+    size=0; \
+    \
+    __len=sizeof(__value); \
+    result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_RCVBUF,(char FAR*)&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__len>=sizeof(__value)); \
+      size=__value; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL(socketDescriptor,flag,result) \
+  do { \
+    flag = 0; \
+    result = TARGET_NATIVE_OK; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result) \
+  do { \
+    address = 0; \
+    result = TARGET_NATIVE_OK; \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS(socketDescriptor,address,result) \
+  do { \
+    struct sockaddr_in __socketAddress; \
+    int                __socketAddressLength; \
+    \
+    address=0;\
+    \
+    memset(&__socketAddress,0,sizeof(__socketAddress)); \
+    __socketAddressLength=sizeof(__socketAddress); \
+    result=(getsockname(socketDescriptor,(struct sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__socketAddressLength>=sizeof(__socketAddress)); \
+      address=ntohl(__socketAddress.sin_addr.s_addr); \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result) \
+  do { \
+    BOOL __value; \
+    int  __len; \
+    \
+    flag=0; \
+    \
+    __len=sizeof(__value); \
+    result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,(char FAR*)&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__len>=sizeof(__value)); \
+      flag=__value; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result) \
+  do { \
+    BOOL __value; \
+    int  __len; \
+    \
+    flag=0; \
+    \
+    __len=sizeof(__value); \
+    result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_KEEPALIVE,(char FAR*)&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__len>=sizeof(__value)); \
+      flag=__value; \
+    } \
+  } while (0)
+#define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BROADCAST(socketDescriptor,flag,result) \
+  do { \
+    BOOL __value; \
+    int  __len; \
+    \
+    flag=0; \
+    \
+    __len=sizeof(__value); \
+    result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_BROADCAST,(char FAR*)&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+    if (result==TARGET_NATIVE_OK) \
+    { \
+      assert(__len>=sizeof(__value)); \
+      flag=__value; \
+    } \
+  } while (0)
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* include rest of definitions from generic file (do not move it to 
+   another position!) */
+#include "target_generic_network.h"
+
+#endif /* __TARGET_NATIVE_NETWORK__ */
+
+/* end of file */
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to