| 1 | // win32.h -- Helper functions for Microsoft-flavored OSs. | 
|---|
| 2 |  | 
|---|
| 3 | /* Copyright (C) 2002, 2003  Free Software Foundation | 
|---|
| 4 |  | 
|---|
| 5 | This file is part of libgcj. | 
|---|
| 6 |  | 
|---|
| 7 | This software is copyrighted work licensed under the terms of the | 
|---|
| 8 | Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for | 
|---|
| 9 | details.  */ | 
|---|
| 10 |  | 
|---|
| 11 | #ifndef __JV_WIN32_H__ | 
|---|
| 12 | #define __JV_WIN32_H__ | 
|---|
| 13 |  | 
|---|
| 14 | #include <windows.h> | 
|---|
| 15 | #undef STRICT | 
|---|
| 16 |  | 
|---|
| 17 | #include <ws2tcpip.h> | 
|---|
| 18 | #include <gcj/cni.h> | 
|---|
| 19 | #include <java/util/Properties.h> | 
|---|
| 20 |  | 
|---|
| 21 | #include <io.h> | 
|---|
| 22 |  | 
|---|
| 23 | // Prefix and suffix for shared libraries. | 
|---|
| 24 | #define _Jv_platform_solib_prefix "" | 
|---|
| 25 | #define _Jv_platform_solib_suffix ".dll" | 
|---|
| 26 |  | 
|---|
| 27 | #ifndef DISABLE_JAVA_NET | 
|---|
| 28 |  | 
|---|
| 29 | // these errors cannot occur on Win32 | 
|---|
| 30 | #define ENOTCONN 0 | 
|---|
| 31 | #define ECONNRESET 0 | 
|---|
| 32 |  | 
|---|
| 33 | /* This is incorrect, but allows java/net/natPlainDatagramSocketImpl.cc | 
|---|
| 34 | to compile under MingW. This will be remedied in a subsequent gcj | 
|---|
| 35 | release where the Win32 and Posix networking code have been forked.  */ | 
|---|
| 36 | #define ECONNREFUSED 0 | 
|---|
| 37 |  | 
|---|
| 38 | #ifndef ENOPROTOOPT | 
|---|
| 39 | #define ENOPROTOOPT 109 | 
|---|
| 40 | #endif | 
|---|
| 41 |  | 
|---|
| 42 | #endif // DISABLE_JAVA_NET | 
|---|
| 43 |  | 
|---|
| 44 | extern void _Jv_platform_initialize (void); | 
|---|
| 45 | extern void _Jv_platform_initProperties (java::util::Properties*); | 
|---|
| 46 | extern jlong _Jv_platform_gettimeofday (); | 
|---|
| 47 | extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *); | 
|---|
| 48 |  | 
|---|
| 49 | inline void | 
|---|
| 50 | _Jv_platform_close_on_exec (jint) | 
|---|
| 51 | { | 
|---|
| 52 | // Ignore. | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | #ifdef JV_HASH_SYNCHRONIZATION | 
|---|
| 56 | /* Suspends the execution of the current thread for the specified | 
|---|
| 57 | number of microseconds.  Tries to emulate the behaviour of usleep() | 
|---|
| 58 | on UNIX and provides a granularity of 1 millisecond.  */ | 
|---|
| 59 | inline void | 
|---|
| 60 | _Jv_platform_usleep (unsigned long usecs) | 
|---|
| 61 | { | 
|---|
| 62 | if (usecs > 0UL) | 
|---|
| 63 | { | 
|---|
| 64 | unsigned long millis = ((usecs + 999UL) / 1000UL); | 
|---|
| 65 | Sleep (millis); | 
|---|
| 66 | } | 
|---|
| 67 | } | 
|---|
| 68 | #endif /* JV_HASH_SYNCHRONIZATION */ | 
|---|
| 69 |  | 
|---|
| 70 | #ifndef DISABLE_JAVA_NET | 
|---|
| 71 |  | 
|---|
| 72 | static inline int | 
|---|
| 73 | _Jv_socket (int domain, int type, int protocol) | 
|---|
| 74 | { | 
|---|
| 75 | return ::socket (domain, type, protocol); | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | inline int | 
|---|
| 79 | _Jv_connect (jint fd, sockaddr *ptr, int len) | 
|---|
| 80 | { | 
|---|
| 81 | return ::connect (fd, ptr, len); | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 | inline int | 
|---|
| 85 | _Jv_close (jint fd) | 
|---|
| 86 | { | 
|---|
| 87 | return ::closesocket (fd); | 
|---|
| 88 | } | 
|---|
| 89 |  | 
|---|
| 90 | inline int | 
|---|
| 91 | _Jv_bind (int fd, struct sockaddr *addr, int addrlen) | 
|---|
| 92 | { | 
|---|
| 93 | return ::bind (fd, addr, addrlen); | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|
| 96 | inline int | 
|---|
| 97 | _Jv_accept (int fd, struct sockaddr *addr, socklen_t *addrlen) | 
|---|
| 98 | { | 
|---|
| 99 | return ::accept (fd, addr, addrlen); | 
|---|
| 100 | } | 
|---|
| 101 |  | 
|---|
| 102 | inline int | 
|---|
| 103 | _Jv_listen (int fd, int backlog) | 
|---|
| 104 | { | 
|---|
| 105 | return ::listen (fd, backlog); | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 | inline int | 
|---|
| 109 | _Jv_write(int s, void *buf, int len) | 
|---|
| 110 | { | 
|---|
| 111 | return ::send (s, (char*) buf, len, 0); | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | inline int | 
|---|
| 115 | _Jv_read(int s, void *buf, int len) | 
|---|
| 116 | { | 
|---|
| 117 | return ::recv (s, (char*) buf, len, 0); | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | #endif /* DISABLE_JAVA_NET */ | 
|---|
| 121 |  | 
|---|
| 122 | /* Store up to SIZE return address of the current program state in | 
|---|
| 123 | ARRAY and return the exact number of values stored.  */ | 
|---|
| 124 | extern int backtrace (void **__array, int __size); | 
|---|
| 125 |  | 
|---|
| 126 | #endif /* __JV_WIN32_H__ */ | 
|---|