src/share/vm/prims/hpi_imported.h

Wed, 08 Oct 2008 08:10:51 -0700

author
ksrini
date
Wed, 08 Oct 2008 08:10:51 -0700
changeset 823
f008d3631bd1
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6755845: JVM_FindClassFromBoot triggers assertions
Summary: Fixes assertions caused by one jvm_entry calling another, solved by refactoring code and modified gamma test.
Reviewed-by: dholmes, xlu

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

mercurial