OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [include/] [win32.h] - Blame information for rev 762

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 757 jeremybenn
// win32.h -- Helper functions for Microsoft-flavored OSs.
2
 
3
/* Copyright (C) 2002, 2003, 2006  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
// Enable UNICODE support?
15
 
16
#ifdef MINGW_LIBGCJ_UNICODE
17
#define UNICODE
18
#define _UNICODE
19
#endif // MINGW_LIBGCJ_UNICODE
20
 
21
#include <tchar.h>
22
 
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
30
 
31
#include <ws2tcpip.h>
32
#include <gcj/cni.h>
33
#include <jvm.h>
34
#include <java/util/Properties.h>
35
 
36
#include <io.h>
37
 
38
/* Begin UNICODE Support Classes and Functions */
39
 
40
/* Helper class which creates a temporary, null-terminated,
41
   wide-character C string. */
42
class _Jv_Win32TempString
43
{
44
public:
45
  _Jv_Win32TempString(jstring jstr);
46
  ~_Jv_Win32TempString();
47
 
48
// Accessors
49
  operator LPCTSTR() const
50
  {
51
    return buf_;
52
  }
53
  LPCTSTR buf() const
54
  {
55
    return buf_;
56
  }
57
  LPTSTR buf()
58
  {
59
    return buf_;
60
  }
61
 
62
private:
63
  TCHAR stackbuf_[500];
64
  LPTSTR buf_;
65
};
66
 
67
// Mimics the JV_TEMP_STRING_UTF macro in jvm.h
68
#define JV_TEMP_STRING_WIN32(x,y) _Jv_Win32TempString x(y);
69
 
70
// Creates a jstring from a LPCTSTR
71
extern jstring _Jv_Win32NewString (LPCTSTR pcsz);
72
 
73
/* End UNICODE Helpers */
74
 
75
// Prefix and suffix for shared libraries.
76
#define _Jv_platform_solib_prefix ""
77
#define _Jv_platform_solib_suffix ".dll"
78
 
79
// Name of the Process implementation.
80
#define _Jv_platform_process ::java::lang::Win32Process
81
 
82
// Separator for file name components.
83
#define _Jv_platform_file_separator ((jchar) '\\')
84
// Separator for path components.
85
#define _Jv_platform_path_separator ((jchar) ';')
86
 
87
// List of names for `JNI_OnLoad'.  On Win32, JNI_OnLoad is an
88
// "stdcall" function taking two pointers (8 bytes) as arguments.  It
89
// could also have been exported as "JNI_OnLoad@8" (MinGW) or
90
// "_JNI_OnLoad@8" (MSVC).
91
#define _Jv_platform_onload_names \
92
    { "JNI_OnLoad", "JNI_OnLoad@8", "_JNI_OnLoad@8", NULL }
93
 
94
// Type of libffi ABI used by JNICALL methods.  NOTE: This must agree
95
// with the JNICALL definition in jni.h
96
#define _Jv_platform_ffi_abi FFI_STDCALL
97
 
98
/* Useful helper classes and methods. */
99
 
100
/* A C++ wrapper around a WSAEVENT which closes the event
101
   in its destructor. If dwSelFlags is non-zero, we also
102
   issue an WSAEventSelect on the socket descriptor with
103
   the given flags; this is undone by a corresponding call
104
   to WSAEventSelect(fd, 0, 0) in our destructor. */
105
class WSAEventWrapper
106
{
107
public:
108
  // Default constructor. Call init() after this.
109
  WSAEventWrapper();
110
  WSAEventWrapper(int fd, DWORD dwSelFlags);
111
  ~WSAEventWrapper();
112
 
113
  // Used for two-step initialization after calling
114
  // default constructor.
115
  void init(int fd, DWORD dwSelFlags);
116
 
117
  int getFD()
118
  {
119
    return m_fd;
120
  }
121
 
122
  WSAEVENT getEventHandle()
123
  {
124
    return m_hEvent;
125
  }
126
 
127
private:
128
  WSAEVENT m_hEvent;
129
  int m_fd;
130
  DWORD m_dwSelFlags;
131
};
132
 
133
// Error string text. The int argument is compatible
134
// with both int WSAGetLastError() and DWORD GetLastError()
135
// I tried avoiding having to pass the error explicitly, but
136
// it didn't work this was invoked with say
137
// throw new SomeException(_Jv_WinStrError()).
138
extern jstring
139
_Jv_WinStrError (LPCTSTR lpszPrologue, int nErrorCode);
140
 
141
extern jstring
142
_Jv_WinStrError (int nErrorCode);
143
 
144
extern void
145
_Jv_ThrowIOException (DWORD dwErrorCode);
146
 
147
extern void
148
_Jv_ThrowIOException ();
149
 
150
extern void
151
_Jv_ThrowSocketException (DWORD dwErrorCode);
152
 
153
extern void
154
_Jv_ThrowSocketException ();
155
 
156
// Platform implementation
157
extern void _Jv_platform_initialize (void);
158
extern void _Jv_platform_initProperties (java::util::Properties*);
159
extern jlong _Jv_platform_gettimeofday ();
160
extern jlong _Jv_platform_nanotime ();
161
extern int _Jv_pipe (int filedes[2]);
162
 
163
extern void
164
_Jv_platform_close_on_exec (HANDLE h);
165
 
166
#ifdef JV_HASH_SYNCHRONIZATION
167
/* Suspends the execution of the current thread for the specified
168
   number of microseconds.  Tries to emulate the behaviour of usleep()
169
   on UNIX and provides a granularity of 1 millisecond.  */
170
inline void
171
_Jv_platform_usleep (unsigned long usecs)
172
{
173
  if (usecs > 0UL)
174
    {
175
      unsigned long millis = ((usecs + 999UL) / 1000UL);
176
      Sleep (millis);
177
    }
178
}
179
#endif /* JV_HASH_SYNCHRONIZATION */
180
 
181
// Forward declaration.  See java-stack.h for definition.
182
struct _Jv_AddrInfo;
183
 
184
// Given an address, determine the executable or shared object that defines
185
// it and the nearest named symbol.
186
extern int _Jv_platform_dladdr (void *addr, _Jv_AddrInfo *info);
187
 
188
#endif /* __JV_WIN32_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.