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 // Default constructor. Call init() after this.
105 WSAEventWrapper(int fd
, DWORD dwSelFlags
);
108 // Used for two-step initialization after calling
109 // default constructor.
110 void init(int fd
, DWORD dwSelFlags
);
117 WSAEVENT
getEventHandle()
128 // Error string text. The int argument is compatible
129 // with both int WSAGetLastError() and DWORD GetLastError()
130 // I tried avoiding having to pass the error explicitly, but
131 // it didn't work this was invoked with say
132 // throw new SomeException(_Jv_WinStrError()).
134 _Jv_WinStrError (LPCTSTR lpszPrologue
, int nErrorCode
);
137 _Jv_WinStrError (int nErrorCode
);
140 _Jv_ThrowIOException (DWORD dwErrorCode
);
143 _Jv_ThrowIOException ();
146 _Jv_ThrowSocketException (DWORD dwErrorCode
);
149 _Jv_ThrowSocketException ();
151 // Platform implementation
152 extern void _Jv_platform_initialize (void);
153 extern void _Jv_platform_initProperties (java::util::Properties
*);
154 extern jlong
_Jv_platform_gettimeofday ();
155 extern int _Jv_pipe (int filedes
[2]);
158 _Jv_platform_close_on_exec (HANDLE h
);
160 #ifdef JV_HASH_SYNCHRONIZATION
161 /* Suspends the execution of the current thread for the specified
162 number of microseconds. Tries to emulate the behaviour of usleep()
163 on UNIX and provides a granularity of 1 millisecond. */
165 _Jv_platform_usleep (unsigned long usecs
)
169 unsigned long millis
= ((usecs
+ 999UL) / 1000UL);
173 #endif /* JV_HASH_SYNCHRONIZATION */
175 /* Store up to SIZE return address of the current program state in
176 ARRAY and return the exact number of values stored. */
177 extern int backtrace (void **__array
, int __size
);
179 #endif /* __JV_WIN32_H__ */