FSF GCC merge 02/23/03
[official-gcc.git] / libjava / include / win32.h
blob4330c79d397e2a705ba3330667925494fe9221dc
1 // win32.h -- Helper functions for Microsoft-flavored OSs.
3 /* Copyright (C) 2002, 2003 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 #ifndef __JV_WIN32_H__
12 #define __JV_WIN32_H__
14 #include <windows.h>
15 #undef STRICT
17 #include <ws2tcpip.h>
18 #include <gcj/cni.h>
19 #include <java/util/Properties.h>
21 #include <io.h>
23 // Prefix and suffix for shared libraries.
24 #define _Jv_platform_solib_prefix ""
25 #define _Jv_platform_solib_suffix ".dll"
27 #ifndef DISABLE_JAVA_NET
29 // these errors cannot occur on Win32
30 #define ENOTCONN 0
31 #define ECONNRESET 0
33 #ifndef ENOPROTOOPT
34 #define ENOPROTOOPT 109
35 #endif
37 #endif // DISABLE_JAVA_NET
39 extern void _Jv_platform_initialize (void);
40 extern void _Jv_platform_initProperties (java::util::Properties*);
41 extern jlong _Jv_platform_gettimeofday ();
43 inline void
44 _Jv_platform_close_on_exec (jint)
46 // Ignore.
49 #ifdef JV_HASH_SYNCHRONIZATION
50 /* Suspends the execution of the current thread for the specified
51 number of microseconds. Tries to emulate the behaviour of usleep()
52 on UNIX and provides a granularity of 1 millisecond. */
53 inline void
54 _Jv_platform_usleep (unsigned long usecs)
56 if (usecs > 0UL)
58 unsigned long millis = ((usecs + 999UL) / 1000UL);
59 Sleep (millis);
62 #endif /* JV_HASH_SYNCHRONIZATION */
64 #ifndef DISABLE_JAVA_NET
66 static inline int
67 _Jv_socket (int domain, int type, int protocol)
69 return ::socket (domain, type, protocol);
72 inline int
73 _Jv_connect (jint fd, sockaddr *ptr, int len)
75 return ::connect (fd, ptr, len);
78 inline int
79 _Jv_close (jint fd)
81 return ::closesocket (fd);
84 inline int
85 _Jv_bind (int fd, struct sockaddr *addr, int addrlen)
87 return ::bind (fd, addr, addrlen);
90 inline int
91 _Jv_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
93 return ::accept (fd, addr, addrlen);
96 inline int
97 _Jv_listen (int fd, int backlog)
99 return ::listen (fd, backlog);
102 inline int
103 _Jv_write(int s, void *buf, int len)
105 return ::send (s, (char*) buf, len, 0);
108 inline int
109 _Jv_read(int s, void *buf, int len)
111 return ::recv (s, (char*) buf, len, 0);
114 #endif /* DISABLE_JAVA_NET */
116 /* Store up to SIZE return address of the current program state in
117 ARRAY and return the exact number of values stored. */
118 extern int backtrace (void **__array, int __size);
120 #endif /* __JV_WIN32_H__ */