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 #define WIN32_LEAN_AND_MEAN
16 #undef WIN32_LEAN_AND_MEAN
22 #include <java/util/Properties.h>
26 // Prefix and suffix for shared libraries.
27 #define _Jv_platform_solib_prefix ""
28 #define _Jv_platform_solib_suffix ".dll"
30 // Separator for file name components.
31 #define _Jv_platform_file_separator ((jchar) '\\')
32 // Separator for path components.
33 #define _Jv_platform_path_separator ((jchar) ';')
35 // List of names for `JNI_OnLoad'. On Win32, JNI_OnLoad is an
36 // "stdcall" function taking two pointers (8 bytes) as arguments. It
37 // could also have been exported as "JNI_OnLoad@8" (MinGW) or
38 // "_JNI_OnLoad@8" (MSVC).
39 #define _Jv_platform_onload_names \
40 { "JNI_OnLoad", "JNI_OnLoad@8", "_JNI_OnLoad@8", NULL }
42 // Type of libffi ABI used by JNICALL methods. NOTE: This must agree
43 // with the JNICALL definition in jni.h
44 #define _Jv_platform_ffi_abi FFI_STDCALL
46 /* Useful helper classes and methods. */
48 /* A C++ wrapper around a WSAEVENT which closes the event
49 in its destructor. If dwSelFlags is non-zero, we also
50 issue an WSAEventSelect on the socket descriptor with
51 the given flags; this is undone by a corresponding call
52 to WSAEventSelect(fd, 0, 0) in our destructor. */
56 WSAEventWrapper(int fd
, DWORD dwSelFlags
);
59 WSAEVENT
getEventHandle()
70 // Error string text. The int argument is compatible
71 // with both int WSAGetLastError() and DWORD GetLastError()
72 // I tried avoiding having to pass the error explicitly, but
73 // it didn't work this was invoked with say
74 // throw new SomeException(_Jv_WinStrError()).
76 _Jv_WinStrError (LPCTSTR lpszPrologue
, int nErrorCode
);
79 _Jv_WinStrError (int nErrorCode
);
82 _Jv_ThrowIOException (DWORD dwErrorCode
);
85 _Jv_ThrowIOException ();
88 _Jv_ThrowSocketException (DWORD dwErrorCode
);
91 _Jv_ThrowSocketException ();
93 // Platform implementation
94 extern void _Jv_platform_initialize (void);
95 extern void _Jv_platform_initProperties (java::util::Properties
*);
96 extern jlong
_Jv_platform_gettimeofday ();
97 extern int _Jv_select (int n
, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
98 extern int _Jv_pipe (int filedes
[2]);
101 _Jv_platform_close_on_exec (jint
)
106 #ifdef JV_HASH_SYNCHRONIZATION
107 /* Suspends the execution of the current thread for the specified
108 number of microseconds. Tries to emulate the behaviour of usleep()
109 on UNIX and provides a granularity of 1 millisecond. */
111 _Jv_platform_usleep (unsigned long usecs
)
115 unsigned long millis
= ((usecs
+ 999UL) / 1000UL);
119 #endif /* JV_HASH_SYNCHRONIZATION */
121 /* Store up to SIZE return address of the current program state in
122 ARRAY and return the exact number of values stored. */
123 extern int backtrace (void **__array
, int __size
);
125 #endif /* __JV_WIN32_H__ */