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
11 #ifndef __JV_WIN32_H__
12 #define __JV_WIN32_H__
14 // Enable UNICODE Support.?
16 #ifdef MINGW_LIBGCJ_UNICODE
19 #endif // MINGW_LIBGCJ_UNICODE
24 #define WIN32_LEAN_AND_MEAN
26 #undef WIN32_LEAN_AND_MEAN
32 #include <java/util/Properties.h>
36 /* Begin UNICODE Support Classes and Functions */
38 /* Helper class which creates a temporary, null-terminated,
39 wide-character C string. */
40 class _Jv_Win32TempString
43 _Jv_Win32TempString(jstring jstr
);
44 ~_Jv_Win32TempString();
47 operator LPCTSTR() const
65 // Mimics the JV_TEMP_STRING_UTF macro in jvm.h
66 #define JV_TEMP_STRING_WIN32(x,y) _Jv_Win32TempString x(y);
68 // Creates a jstring from a LPCTSTR
69 extern jstring
_Jv_Win32NewString (LPCTSTR pcsz
);
71 /* End UNICODE Helpers */
73 // Prefix and suffix for shared libraries.
74 #define _Jv_platform_solib_prefix ""
75 #define _Jv_platform_solib_suffix ".dll"
77 // Separator for file name components.
78 #define _Jv_platform_file_separator ((jchar) '\\')
79 // Separator for path components.
80 #define _Jv_platform_path_separator ((jchar) ';')
82 // List of names for `JNI_OnLoad'. On Win32, JNI_OnLoad is an
83 // "stdcall" function taking two pointers (8 bytes) as arguments. It
84 // could also have been exported as "JNI_OnLoad@8" (MinGW) or
85 // "_JNI_OnLoad@8" (MSVC).
86 #define _Jv_platform_onload_names \
87 { "JNI_OnLoad", "JNI_OnLoad@8", "_JNI_OnLoad@8", NULL }
89 // Type of libffi ABI used by JNICALL methods. NOTE: This must agree
90 // with the JNICALL definition in jni.h
91 #define _Jv_platform_ffi_abi FFI_STDCALL
93 /* Useful helper classes and methods. */
95 /* A C++ wrapper around a WSAEVENT which closes the event
96 in its destructor. If dwSelFlags is non-zero, we also
97 issue an WSAEventSelect on the socket descriptor with
98 the given flags; this is undone by a corresponding call
99 to WSAEventSelect(fd, 0, 0) in our destructor. */
100 class WSAEventWrapper
103 WSAEventWrapper(int fd
, DWORD dwSelFlags
);
106 WSAEVENT
getEventHandle()
117 // Error string text. The int argument is compatible
118 // with both int WSAGetLastError() and DWORD GetLastError()
119 // I tried avoiding having to pass the error explicitly, but
120 // it didn't work this was invoked with say
121 // throw new SomeException(_Jv_WinStrError()).
123 _Jv_WinStrError (LPCTSTR lpszPrologue
, int nErrorCode
);
126 _Jv_WinStrError (int nErrorCode
);
129 _Jv_ThrowIOException (DWORD dwErrorCode
);
132 _Jv_ThrowIOException ();
135 _Jv_ThrowSocketException (DWORD dwErrorCode
);
138 _Jv_ThrowSocketException ();
140 // Platform implementation
141 extern void _Jv_platform_initialize (void);
142 extern void _Jv_platform_initProperties (java::util::Properties
*);
143 extern jlong
_Jv_platform_gettimeofday ();
144 extern int _Jv_select (int n
, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
145 extern int _Jv_pipe (int filedes
[2]);
148 _Jv_platform_close_on_exec (HANDLE h
);
150 #ifdef JV_HASH_SYNCHRONIZATION
151 /* Suspends the execution of the current thread for the specified
152 number of microseconds. Tries to emulate the behaviour of usleep()
153 on UNIX and provides a granularity of 1 millisecond. */
155 _Jv_platform_usleep (unsigned long usecs
)
159 unsigned long millis
= ((usecs
+ 999UL) / 1000UL);
163 #endif /* JV_HASH_SYNCHRONIZATION */
165 /* Store up to SIZE return address of the current program state in
166 ARRAY and return the exact number of values stored. */
167 extern int backtrace (void **__array
, int __size
);
169 #endif /* __JV_WIN32_H__ */