OSDN Git Service

* resolve.cc (ncode): Use _Jv_platform_ffi_abi.
[pf3gnuchains/gcc-fork.git] / libjava / include / win32.h
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 // Separator for file name components.
28 #define _Jv_platform_file_separator ((jchar) '\\')
29 // Separator for path components.
30 #define _Jv_platform_path_separator ((jchar) ';')
31
32 // List of names for `JNI_OnLoad'.  On Win32, JNI_OnLoad is an
33 // "stdcall" function taking two pointers (8 bytes) as arguments.  It
34 // could also have been exported as "JNI_OnLoad@8" (MinGW) or
35 // "_JNI_OnLoad@8" (MSVC).
36 #define _Jv_platform_onload_names \
37     { "JNI_OnLoad", "JNI_OnLoad@8", "_JNI_OnLoad@8", NULL }
38
39 // Type of libffi ABI used by JNICALL methods.  NOTE: This must agree
40 // with the JNICALL definition in jni.h
41 #define _Jv_platform_ffi_abi FFI_STDCALL
42
43 #ifndef DISABLE_JAVA_NET
44
45 // these errors cannot occur on Win32
46 #define ENOTCONN 0
47 #define ECONNRESET 0
48
49 #ifndef ENOPROTOOPT
50 #define ENOPROTOOPT 109
51 #endif
52
53 #endif // DISABLE_JAVA_NET
54
55 extern void _Jv_platform_initialize (void);
56 extern void _Jv_platform_initProperties (java::util::Properties*);
57 extern jlong _Jv_platform_gettimeofday ();
58
59 inline void
60 _Jv_platform_close_on_exec (jint)
61 {
62   // Ignore.
63 }
64
65 #ifdef JV_HASH_SYNCHRONIZATION
66 /* Suspends the execution of the current thread for the specified
67    number of microseconds.  Tries to emulate the behaviour of usleep()
68    on UNIX and provides a granularity of 1 millisecond.  */
69 inline void
70 _Jv_platform_usleep (unsigned long usecs)
71 {
72   if (usecs > 0UL)
73     {
74       unsigned long millis = ((usecs + 999UL) / 1000UL);
75       Sleep (millis);
76     }
77 }
78 #endif /* JV_HASH_SYNCHRONIZATION */
79
80 #ifndef DISABLE_JAVA_NET
81
82 static inline int
83 _Jv_socket (int domain, int type, int protocol)
84 {
85   return ::socket (domain, type, protocol);
86 }
87
88 inline int
89 _Jv_connect (jint fd, sockaddr *ptr, int len)
90 {
91   return ::connect (fd, ptr, len);
92 }
93
94 inline int
95 _Jv_close (jint fd)
96 {
97   return ::closesocket (fd);
98 }
99
100 inline int
101 _Jv_bind (int fd, struct sockaddr *addr, int addrlen)
102 {
103   return ::bind (fd, addr, addrlen);
104 }
105
106 inline int
107 _Jv_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
108 {
109   return ::accept (fd, addr, addrlen);
110 }
111
112 inline int
113 _Jv_listen (int fd, int backlog)
114 {
115   return ::listen (fd, backlog);
116 }
117
118 inline int
119 _Jv_write(int s, void *buf, int len)
120 {
121   return ::send (s, (char*) buf, len, 0);
122 }
123
124 inline int
125 _Jv_read(int s, void *buf, int len)
126 {
127   return ::recv (s, (char*) buf, len, 0);
128 }
129
130 #endif /* DISABLE_JAVA_NET */
131
132 /* Store up to SIZE return address of the current program state in
133    ARRAY and return the exact number of values stored.  */
134 extern int backtrace (void **__array, int __size);
135
136 #endif /* __JV_WIN32_H__ */