* config/sparc/sparc.md (save_register_windowdi): Add missing mode.
[official-gcc.git] / libjava / include / win32.h
bloba660616ae4c834aa58dcc0ac7fb7cc84ba060c7e
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 // Enable UNICODE Support.?
16 #ifdef MINGW_LIBGCJ_UNICODE
17 #define UNICODE
18 #define _UNICODE
19 #endif // MINGW_LIBGCJ_UNICODE
21 #include <tchar.h>
23 // Includes
24 #define WIN32_LEAN_AND_MEAN
25 // Force Winsock 2 interface.
26 #include <winsock2.h>
27 #include <windows.h>
28 #undef WIN32_LEAN_AND_MEAN
29 #undef STRICT
31 #include <ws2tcpip.h>
32 #include <gcj/cni.h>
33 #include <jvm.h>
34 #include <java/util/Properties.h>
36 #include <io.h>
38 /* Begin UNICODE Support Classes and Functions */
40 /* Helper class which creates a temporary, null-terminated,
41 wide-character C string. */
42 class _Jv_Win32TempString
44 public:
45 _Jv_Win32TempString(jstring jstr);
46 ~_Jv_Win32TempString();
48 // Accessors
49 operator LPCTSTR() const
51 return buf_;
53 LPCTSTR buf() const
55 return buf_;
57 LPTSTR buf()
59 return buf_;
62 private:
63 TCHAR stackbuf_[500];
64 LPTSTR buf_;
67 // Mimics the JV_TEMP_STRING_UTF macro in jvm.h
68 #define JV_TEMP_STRING_WIN32(x,y) _Jv_Win32TempString x(y);
70 // Creates a jstring from a LPCTSTR
71 extern jstring _Jv_Win32NewString (LPCTSTR pcsz);
73 /* End UNICODE Helpers */
75 // Prefix and suffix for shared libraries.
76 #define _Jv_platform_solib_prefix ""
77 #define _Jv_platform_solib_suffix ".dll"
79 // Separator for file name components.
80 #define _Jv_platform_file_separator ((jchar) '\\')
81 // Separator for path components.
82 #define _Jv_platform_path_separator ((jchar) ';')
84 // List of names for `JNI_OnLoad'. On Win32, JNI_OnLoad is an
85 // "stdcall" function taking two pointers (8 bytes) as arguments. It
86 // could also have been exported as "JNI_OnLoad@8" (MinGW) or
87 // "_JNI_OnLoad@8" (MSVC).
88 #define _Jv_platform_onload_names \
89 { "JNI_OnLoad", "JNI_OnLoad@8", "_JNI_OnLoad@8", NULL }
91 // Type of libffi ABI used by JNICALL methods. NOTE: This must agree
92 // with the JNICALL definition in jni.h
93 #define _Jv_platform_ffi_abi FFI_STDCALL
95 /* Useful helper classes and methods. */
97 /* A C++ wrapper around a WSAEVENT which closes the event
98 in its destructor. If dwSelFlags is non-zero, we also
99 issue an WSAEventSelect on the socket descriptor with
100 the given flags; this is undone by a corresponding call
101 to WSAEventSelect(fd, 0, 0) in our destructor. */
102 class WSAEventWrapper
104 public:
105 // Default constructor. Call init() after this.
106 WSAEventWrapper();
107 WSAEventWrapper(int fd, DWORD dwSelFlags);
108 ~WSAEventWrapper();
110 // Used for two-step initialization after calling
111 // default constructor.
112 void init(int fd, DWORD dwSelFlags);
114 int getFD()
116 return m_fd;
119 WSAEVENT getEventHandle()
121 return m_hEvent;
124 private:
125 WSAEVENT m_hEvent;
126 int m_fd;
127 DWORD m_dwSelFlags;
130 // Error string text. The int argument is compatible
131 // with both int WSAGetLastError() and DWORD GetLastError()
132 // I tried avoiding having to pass the error explicitly, but
133 // it didn't work this was invoked with say
134 // throw new SomeException(_Jv_WinStrError()).
135 extern jstring
136 _Jv_WinStrError (LPCTSTR lpszPrologue, int nErrorCode);
138 extern jstring
139 _Jv_WinStrError (int nErrorCode);
141 extern void
142 _Jv_ThrowIOException (DWORD dwErrorCode);
144 extern void
145 _Jv_ThrowIOException ();
147 extern void
148 _Jv_ThrowSocketException (DWORD dwErrorCode);
150 extern void
151 _Jv_ThrowSocketException ();
153 // Platform implementation
154 extern void _Jv_platform_initialize (void);
155 extern void _Jv_platform_initProperties (java::util::Properties*);
156 extern jlong _Jv_platform_gettimeofday ();
157 extern int _Jv_pipe (int filedes[2]);
159 extern void
160 _Jv_platform_close_on_exec (HANDLE h);
162 #ifdef JV_HASH_SYNCHRONIZATION
163 /* Suspends the execution of the current thread for the specified
164 number of microseconds. Tries to emulate the behaviour of usleep()
165 on UNIX and provides a granularity of 1 millisecond. */
166 inline void
167 _Jv_platform_usleep (unsigned long usecs)
169 if (usecs > 0UL)
171 unsigned long millis = ((usecs + 999UL) / 1000UL);
172 Sleep (millis);
175 #endif /* JV_HASH_SYNCHRONIZATION */
177 /* Store up to SIZE return address of the current program state in
178 ARRAY and return the exact number of values stored. */
179 extern int backtrace (void **__array, int __size);
181 #endif /* __JV_WIN32_H__ */