annotate src/share/vm/prims/hpi_imported.h @ 1716:be3f9c242c9d

6948538: CMS: BOT walkers can fall into object allocation and initialization cracks Summary: GC workers now recognize an intermediate transient state of blocks which are allocated but have not yet completed initialization. blk_start() calls do not attempt to determine the size of a block in the transient state, rather waiting for the block to become initialized so that it is safe to query its size. Audited and ensured the order of initialization of object fields (klass, free bit and size) to respect block state transition protocol. Also included some new assertion checking code enabled in debug mode. Reviewed-by: chrisphi, johnc, poonam
author ysr
date Mon, 16 Aug 2010 15:58:42 -0700
parents c18cbe5936b8
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
26 * HotSpot integration note:
a61af66fc99e Initial load
duke
parents:
diff changeset
27 *
a61af66fc99e Initial load
duke
parents:
diff changeset
28 * This is a consolidation of these two files:
a61af66fc99e Initial load
duke
parents:
diff changeset
29 * src/share/hpi/export/hpi.h 1.15 99/06/18 JDK1.3 beta build I
a61af66fc99e Initial load
duke
parents:
diff changeset
30 * src/share/hpi/export/dll.h 1.3 98/09/15 JDK1.3 beta build I
a61af66fc99e Initial load
duke
parents:
diff changeset
31 * from the classic VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
32 *
a61af66fc99e Initial load
duke
parents:
diff changeset
33 * bool_t is a type in the classic VM, and we define it here,
a61af66fc99e Initial load
duke
parents:
diff changeset
34 * but in the future this should be a jboolean.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 *
a61af66fc99e Initial load
duke
parents:
diff changeset
36 * The files are included verbatim expect for local includes removed from hpi.h.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 */
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 #ifndef _JAVASOFT_HPI_H_
a61af66fc99e Initial load
duke
parents:
diff changeset
40 #define _JAVASOFT_HPI_H_
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 #ifdef __cplusplus
a61af66fc99e Initial load
duke
parents:
diff changeset
43 extern "C" {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 /* A classic VMism that should become a jboolean. Fix in 1.2.1? */
a61af66fc99e Initial load
duke
parents:
diff changeset
47 typedef enum { HPI_FALSE = 0, HPI_TRUE = 1 } bool_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
50 * DLL.H: A common interface for helper DLLs loaded by the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
51 * Each library exports the main entry point "DLL_Initialize". Through
a61af66fc99e Initial load
duke
parents:
diff changeset
52 * that function the programmer can obtain a function pointer which has
a61af66fc99e Initial load
duke
parents:
diff changeset
53 * type "GetInterfaceFunc." Through the function pointer the programmer
a61af66fc99e Initial load
duke
parents:
diff changeset
54 * can obtain other interfaces supported in the DLL.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 */
a61af66fc99e Initial load
duke
parents:
diff changeset
56 typedef jint (JNICALL * GetInterfaceFunc)
a61af66fc99e Initial load
duke
parents:
diff changeset
57 (void **intfP, const char *name, jint ver);
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 jint JNICALL DLL_Initialize(GetInterfaceFunc *, void *args);
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
63 * Host Porting Interface. This defines the "porting layer" for
a61af66fc99e Initial load
duke
parents:
diff changeset
64 * POSIX.1 compliant operating systems.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 */
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
68 * memory allocations
a61af66fc99e Initial load
duke
parents:
diff changeset
69 */
a61af66fc99e Initial load
duke
parents:
diff changeset
70 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
72 * Malloc must return a unique pointer if size == 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 */
a61af66fc99e Initial load
duke
parents:
diff changeset
74 void * (*Malloc)(size_t size);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void * (*Realloc)(void *ptr, size_t new_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
77 * Free must allow ptr == NULL to be a no-op.
a61af66fc99e Initial load
duke
parents:
diff changeset
78 */
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void (*Free)(void *ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
81 * Calloc must return a unique pointer for if
a61af66fc99e Initial load
duke
parents:
diff changeset
82 * n_item == 0 || item_size == 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
83 */
a61af66fc99e Initial load
duke
parents:
diff changeset
84 void * (*Calloc)(size_t n_item, size_t item_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 char * (*Strdup)(const char *str);
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 void * (*MapMem)(size_t req_size, size_t *maped_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void * (*UnmapMem)(void *req_addr, size_t req_size, size_t *unmap_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
90 * CommitMem should round the ptr down to the nearest page and
a61af66fc99e Initial load
duke
parents:
diff changeset
91 * round the size up to the nearest page so that the committed
a61af66fc99e Initial load
duke
parents:
diff changeset
92 * region is at least as large as the requested region.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 */
a61af66fc99e Initial load
duke
parents:
diff changeset
94 void * (*CommitMem)(void *ptr, size_t size, size_t *actual);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
96 * sysDecommitMem should round the ptr up to the nearest page and
a61af66fc99e Initial load
duke
parents:
diff changeset
97 * round the size down to the nearest page so that the decommitted
a61af66fc99e Initial load
duke
parents:
diff changeset
98 * region is no greater than the requested region.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 */
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void * (*DecommitMem)(void *ptr, size_t size, size_t *actual);
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 #define HPI_PAGE_ALIGNMENT (64 * 1024)
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 void * (*AllocBlock)(size_t size, void **headP);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void (*FreeBlock)(void *head);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 } HPI_MemoryInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
109 * dynamic linking libraries
a61af66fc99e Initial load
duke
parents:
diff changeset
110 */
a61af66fc99e Initial load
duke
parents:
diff changeset
111 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void (*BuildLibName)(char *buf, int buf_len, char *path, const char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 int (*BuildFunName)(char *name, int name_len, int arg_size, int en_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void * (*LoadLibrary)(const char *name, char *err_buf, int err_buflen);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void (*UnloadLibrary)(void *lib);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void * (*FindLibraryEntry)(void *lib, const char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 } HPI_LibraryInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 typedef void (*signal_handler_t)(int sig, void *siginfo, void *context);
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 #define HPI_SIG_DFL (signal_handler_t)0
a61af66fc99e Initial load
duke
parents:
diff changeset
123 #define HPI_SIG_ERR (signal_handler_t)-1
a61af66fc99e Initial load
duke
parents:
diff changeset
124 #define HPI_SIG_IGN (signal_handler_t)1
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 char *name; /* name such as green/native threads. */
a61af66fc99e Initial load
duke
parents:
diff changeset
128 int isMP;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 } HPI_SysInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 HPI_SysInfo * (*GetSysInfo)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 long (*GetMilliTicks)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 jlong (*TimeMillis)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 signal_handler_t (*Signal)(int sig, signal_handler_t handler);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 void (*Raise)(int sig);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 void (*SignalNotify)(int sig);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 int (*SignalWait)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int (*Shutdown)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 int (*SetLoggingLevel)(int level);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 bool_t (*SetMonitoringOn)(bool_t on);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 int (*GetLastErrorString)(char *buf, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } HPI_SystemInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
149 * threads and monitors
a61af66fc99e Initial load
duke
parents:
diff changeset
150 */
a61af66fc99e Initial load
duke
parents:
diff changeset
151 typedef struct sys_thread sys_thread_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 typedef struct sys_mon sys_mon_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 #define HPI_OK 0
a61af66fc99e Initial load
duke
parents:
diff changeset
155 #define HPI_ERR -1
a61af66fc99e Initial load
duke
parents:
diff changeset
156 #define HPI_INTRPT -2 /* Operation was interrupted */
a61af66fc99e Initial load
duke
parents:
diff changeset
157 #define HPI_TIMEOUT -3 /* A timer ran out */
a61af66fc99e Initial load
duke
parents:
diff changeset
158 #define HPI_NOMEM -5 /* Ran out of memory */
a61af66fc99e Initial load
duke
parents:
diff changeset
159 #define HPI_NORESOURCE -6 /* Ran out of some system resource */
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 /* There are three basic states: RUNNABLE, MONITOR_WAIT, and CONDVAR_WAIT.
a61af66fc99e Initial load
duke
parents:
diff changeset
162 * When the thread is suspended in any of these states, the
a61af66fc99e Initial load
duke
parents:
diff changeset
163 * HPI_THREAD_SUSPENDED bit will be set
a61af66fc99e Initial load
duke
parents:
diff changeset
164 */
a61af66fc99e Initial load
duke
parents:
diff changeset
165 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 HPI_THREAD_RUNNABLE = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
167 HPI_THREAD_MONITOR_WAIT,
a61af66fc99e Initial load
duke
parents:
diff changeset
168 HPI_THREAD_CONDVAR_WAIT
a61af66fc99e Initial load
duke
parents:
diff changeset
169 };
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 #define HPI_MINIMUM_PRIORITY 1
a61af66fc99e Initial load
duke
parents:
diff changeset
172 #define HPI_MAXIMUM_PRIORITY 10
a61af66fc99e Initial load
duke
parents:
diff changeset
173 #define HPI_NORMAL_PRIORITY 5
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 #define HPI_THREAD_SUSPENDED 0x8000
a61af66fc99e Initial load
duke
parents:
diff changeset
176 #define HPI_THREAD_INTERRUPTED 0x4000
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 sys_thread_t *owner;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 int entry_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 sys_thread_t **monitor_waiters;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 sys_thread_t **condvar_waiters;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 int sz_monitor_waiters;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 int sz_condvar_waiters;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 int n_monitor_waiters;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 int n_condvar_waiters;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 } sys_mon_info;
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 int (*ThreadBootstrap)(sys_thread_t **tidP,
a61af66fc99e Initial load
duke
parents:
diff changeset
191 sys_mon_t **qlockP,
a61af66fc99e Initial load
duke
parents:
diff changeset
192 int nReservedBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 int (*ThreadCreate)(sys_thread_t **tidP,
a61af66fc99e Initial load
duke
parents:
diff changeset
194 long stk_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
195 void (*func)(void *),
a61af66fc99e Initial load
duke
parents:
diff changeset
196 void *arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 sys_thread_t * (*ThreadSelf)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 void (*ThreadYield)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 int (*ThreadSuspend)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 int (*ThreadResume)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 int (*ThreadSetPriority)(sys_thread_t *tid, int prio);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 int (*ThreadGetPriority)(sys_thread_t *tid, int *prio);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void * (*ThreadStackPointer)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 void * (*ThreadStackTop)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 long * (*ThreadRegs)(sys_thread_t *tid, int *regs);
a61af66fc99e Initial load
duke
parents:
diff changeset
206 int (*ThreadSingle)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 void (*ThreadMulti)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 int (*ThreadEnumerateOver)(int (*func)(sys_thread_t *, void *),
a61af66fc99e Initial load
duke
parents:
diff changeset
209 void *arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 int (*ThreadCheckStack)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 void (*ThreadPostException)(sys_thread_t *tid, void *arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 void (*ThreadInterrupt)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 int (*ThreadIsInterrupted)(sys_thread_t *tid, int clear);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 int (*ThreadAlloc)(sys_thread_t **tidP);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 int (*ThreadFree)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 jlong (*ThreadCPUTime)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 int (*ThreadGetStatus)(sys_thread_t *tid, sys_mon_t **monitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 void * (*ThreadInterruptEvent)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 void * (*ThreadNativeID)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 /* These three functions are used by the CPU time profiler.
a61af66fc99e Initial load
duke
parents:
diff changeset
222 * sysThreadIsRunning determines whether the thread is running (not just
a61af66fc99e Initial load
duke
parents:
diff changeset
223 * runnable). It is only safe to call this function after calling
a61af66fc99e Initial load
duke
parents:
diff changeset
224 * sysThreadProfSuspend.
a61af66fc99e Initial load
duke
parents:
diff changeset
225 */
a61af66fc99e Initial load
duke
parents:
diff changeset
226 bool_t (*ThreadIsRunning)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 void (*ThreadProfSuspend)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 void (*ThreadProfResume)(sys_thread_t *tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 int (*AdjustTimeSlice)(int ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 size_t (*MonitorSizeof)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 int (*MonitorInit)(sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 int (*MonitorDestroy)(sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 int (*MonitorEnter)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 bool_t (*MonitorEntered)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 int (*MonitorExit)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 int (*MonitorNotify)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 int (*MonitorNotifyAll)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 int (*MonitorWait)(sys_thread_t *self, sys_mon_t *mid, jlong ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 bool_t (*MonitorInUse)(sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 sys_thread_t * (*MonitorOwner)(sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 int (*MonitorGetInfo)(sys_mon_t *mid, sys_mon_info *info);
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 } HPI_ThreadInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
248 * files
a61af66fc99e Initial load
duke
parents:
diff changeset
249 */
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 #define HPI_FILETYPE_REGULAR (0)
a61af66fc99e Initial load
duke
parents:
diff changeset
252 #define HPI_FILETYPE_DIRECTORY (1)
a61af66fc99e Initial load
duke
parents:
diff changeset
253 #define HPI_FILETYPE_OTHER (2)
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 char * (*NativePath)(char *path);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 int (*FileType)(const char *path);
a61af66fc99e Initial load
duke
parents:
diff changeset
258 int (*Open)(const char *name, int openMode, int filePerm);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 int (*Close)(int fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 jlong (*Seek)(int fd, jlong offset, int whence);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 int (*SetLength)(int fd, jlong length);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 int (*Sync)(int fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 int (*Available)(int fd, jlong *bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 size_t (*Read)(int fd, void *buf, unsigned int nBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 size_t (*Write)(int fd, const void *buf, unsigned int nBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 int (*FileSizeFD)(int fd, jlong *size);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 } HPI_FileInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
270 * sockets
a61af66fc99e Initial load
duke
parents:
diff changeset
271 */
a61af66fc99e Initial load
duke
parents:
diff changeset
272 struct sockaddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 struct hostent;
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 int (*Close)(int fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 long (*Available)(int fd, jint *pbytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 int (*Connect)(int fd, struct sockaddr *him, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
279 int (*Accept)(int fd, struct sockaddr *him, int *len);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 int (*SendTo)(int fd, char *buf, int len, int flags,
a61af66fc99e Initial load
duke
parents:
diff changeset
281 struct sockaddr *to, int tolen);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 int (*RecvFrom)(int fd, char *buf, int nbytes, int flags,
a61af66fc99e Initial load
duke
parents:
diff changeset
283 struct sockaddr *from, int *fromlen);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 int (*Listen)(int fd, long count);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 int (*Recv)(int fd, char *buf, int nBytes, int flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 int (*Send)(int fd, char *buf, int nBytes, int flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 int (*Timeout)(int fd, long timeout);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 struct hostent * (*GetHostByName)(char *hostname);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 int (*Socket)(int domain, int type, int protocol);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 int (*SocketShutdown)(int fd, int howto);
a61af66fc99e Initial load
duke
parents:
diff changeset
291 int (*Bind)(int fd, struct sockaddr *him, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 int (*GetSocketName)(int fd, struct sockaddr *him, int *len);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 int (*GetHostName)(char *hostname, int namelen);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 struct hostent * (*GetHostByAddr)(const char *hostname, int len, int type);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 int (*SocketGetOption)(int fd, int level, int optname, char *optval, int *optlen);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 int (*SocketSetOption)(int fd, int level, int optname, const char *optval, int optlen);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 struct protoent * (*GetProtoByName)(char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 } HPI_SocketInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
301 * callbacks.
a61af66fc99e Initial load
duke
parents:
diff changeset
302 */
a61af66fc99e Initial load
duke
parents:
diff changeset
303 typedef struct vm_calls {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 int (*jio_fprintf)(FILE *fp, const char *fmt, ...);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 void (*panic)(const char *fmt, ...);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 void (*monitorRegister)(sys_mon_t *mid, char *info_str);
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 void (*monitorContendedEnter)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 void (*monitorContendedEntered)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 void (*monitorContendedExit)(sys_thread_t *self, sys_mon_t *mid);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 } vm_calls_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 #ifdef __cplusplus
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 #endif /* !_JAVASOFT_HPI_H_ */