1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/prims/hpi_imported.h Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,317 @@ 1.4 +/* 1.5 + * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +/* 1.29 + * HotSpot integration note: 1.30 + * 1.31 + * This is a consolidation of these two files: 1.32 + * src/share/hpi/export/hpi.h 1.15 99/06/18 JDK1.3 beta build I 1.33 + * src/share/hpi/export/dll.h 1.3 98/09/15 JDK1.3 beta build I 1.34 + * from the classic VM. 1.35 + * 1.36 + * bool_t is a type in the classic VM, and we define it here, 1.37 + * but in the future this should be a jboolean. 1.38 + * 1.39 + * The files are included verbatim expect for local includes removed from hpi.h. 1.40 + */ 1.41 + 1.42 +#ifndef _JAVASOFT_HPI_H_ 1.43 +#define _JAVASOFT_HPI_H_ 1.44 + 1.45 +#ifdef __cplusplus 1.46 +extern "C" { 1.47 +#endif 1.48 + 1.49 +/* A classic VMism that should become a jboolean. Fix in 1.2.1? */ 1.50 +typedef enum { HPI_FALSE = 0, HPI_TRUE = 1 } bool_t; 1.51 + 1.52 +/* 1.53 + * DLL.H: A common interface for helper DLLs loaded by the VM. 1.54 + * Each library exports the main entry point "DLL_Initialize". Through 1.55 + * that function the programmer can obtain a function pointer which has 1.56 + * type "GetInterfaceFunc." Through the function pointer the programmer 1.57 + * can obtain other interfaces supported in the DLL. 1.58 + */ 1.59 +typedef jint (JNICALL * GetInterfaceFunc) 1.60 + (void **intfP, const char *name, jint ver); 1.61 + 1.62 +jint JNICALL DLL_Initialize(GetInterfaceFunc *, void *args); 1.63 + 1.64 + 1.65 +/* 1.66 + * Host Porting Interface. This defines the "porting layer" for 1.67 + * POSIX.1 compliant operating systems. 1.68 + */ 1.69 + 1.70 +/* 1.71 + * memory allocations 1.72 + */ 1.73 +typedef struct { 1.74 + /* 1.75 + * Malloc must return a unique pointer if size == 0. 1.76 + */ 1.77 + void * (*Malloc)(size_t size); 1.78 + void * (*Realloc)(void *ptr, size_t new_size); 1.79 + /* 1.80 + * Free must allow ptr == NULL to be a no-op. 1.81 + */ 1.82 + void (*Free)(void *ptr); 1.83 + /* 1.84 + * Calloc must return a unique pointer for if 1.85 + * n_item == 0 || item_size == 0. 1.86 + */ 1.87 + void * (*Calloc)(size_t n_item, size_t item_size); 1.88 + char * (*Strdup)(const char *str); 1.89 + 1.90 + void * (*MapMem)(size_t req_size, size_t *maped_size); 1.91 + void * (*UnmapMem)(void *req_addr, size_t req_size, size_t *unmap_size); 1.92 + /* 1.93 + * CommitMem should round the ptr down to the nearest page and 1.94 + * round the size up to the nearest page so that the committed 1.95 + * region is at least as large as the requested region. 1.96 + */ 1.97 + void * (*CommitMem)(void *ptr, size_t size, size_t *actual); 1.98 + /* 1.99 + * sysDecommitMem should round the ptr up to the nearest page and 1.100 + * round the size down to the nearest page so that the decommitted 1.101 + * region is no greater than the requested region. 1.102 + */ 1.103 + void * (*DecommitMem)(void *ptr, size_t size, size_t *actual); 1.104 + 1.105 +#define HPI_PAGE_ALIGNMENT (64 * 1024) 1.106 + 1.107 + void * (*AllocBlock)(size_t size, void **headP); 1.108 + void (*FreeBlock)(void *head); 1.109 +} HPI_MemoryInterface; 1.110 + 1.111 +/* 1.112 + * dynamic linking libraries 1.113 + */ 1.114 +typedef struct { 1.115 + void (*BuildLibName)(char *buf, int buf_len, char *path, const char *name); 1.116 + int (*BuildFunName)(char *name, int name_len, int arg_size, int en_idx); 1.117 + 1.118 + void * (*LoadLibrary)(const char *name, char *err_buf, int err_buflen); 1.119 + void (*UnloadLibrary)(void *lib); 1.120 + void * (*FindLibraryEntry)(void *lib, const char *name); 1.121 +} HPI_LibraryInterface; 1.122 + 1.123 +typedef void (*signal_handler_t)(int sig, void *siginfo, void *context); 1.124 + 1.125 +#define HPI_SIG_DFL (signal_handler_t)0 1.126 +#define HPI_SIG_ERR (signal_handler_t)-1 1.127 +#define HPI_SIG_IGN (signal_handler_t)1 1.128 + 1.129 +typedef struct { 1.130 + char *name; /* name such as green/native threads. */ 1.131 + int isMP; 1.132 +} HPI_SysInfo; 1.133 + 1.134 +typedef struct { 1.135 + HPI_SysInfo * (*GetSysInfo)(void); 1.136 + long (*GetMilliTicks)(void); 1.137 + jlong (*TimeMillis)(void); 1.138 + 1.139 + signal_handler_t (*Signal)(int sig, signal_handler_t handler); 1.140 + void (*Raise)(int sig); 1.141 + void (*SignalNotify)(int sig); 1.142 + int (*SignalWait)(void); 1.143 + 1.144 + int (*Shutdown)(void); 1.145 + 1.146 + int (*SetLoggingLevel)(int level); 1.147 + bool_t (*SetMonitoringOn)(bool_t on); 1.148 + int (*GetLastErrorString)(char *buf, int len); 1.149 +} HPI_SystemInterface; 1.150 + 1.151 +/* 1.152 + * threads and monitors 1.153 + */ 1.154 +typedef struct sys_thread sys_thread_t; 1.155 +typedef struct sys_mon sys_mon_t; 1.156 + 1.157 +#define HPI_OK 0 1.158 +#define HPI_ERR -1 1.159 +#define HPI_INTRPT -2 /* Operation was interrupted */ 1.160 +#define HPI_TIMEOUT -3 /* A timer ran out */ 1.161 +#define HPI_NOMEM -5 /* Ran out of memory */ 1.162 +#define HPI_NORESOURCE -6 /* Ran out of some system resource */ 1.163 + 1.164 +/* There are three basic states: RUNNABLE, MONITOR_WAIT, and CONDVAR_WAIT. 1.165 + * When the thread is suspended in any of these states, the 1.166 + * HPI_THREAD_SUSPENDED bit will be set 1.167 + */ 1.168 +enum { 1.169 + HPI_THREAD_RUNNABLE = 1, 1.170 + HPI_THREAD_MONITOR_WAIT, 1.171 + HPI_THREAD_CONDVAR_WAIT 1.172 +}; 1.173 + 1.174 +#define HPI_MINIMUM_PRIORITY 1 1.175 +#define HPI_MAXIMUM_PRIORITY 10 1.176 +#define HPI_NORMAL_PRIORITY 5 1.177 + 1.178 +#define HPI_THREAD_SUSPENDED 0x8000 1.179 +#define HPI_THREAD_INTERRUPTED 0x4000 1.180 + 1.181 +typedef struct { 1.182 + sys_thread_t *owner; 1.183 + int entry_count; 1.184 + sys_thread_t **monitor_waiters; 1.185 + sys_thread_t **condvar_waiters; 1.186 + int sz_monitor_waiters; 1.187 + int sz_condvar_waiters; 1.188 + int n_monitor_waiters; 1.189 + int n_condvar_waiters; 1.190 +} sys_mon_info; 1.191 + 1.192 +typedef struct { 1.193 + int (*ThreadBootstrap)(sys_thread_t **tidP, 1.194 + sys_mon_t **qlockP, 1.195 + int nReservedBytes); 1.196 + int (*ThreadCreate)(sys_thread_t **tidP, 1.197 + long stk_size, 1.198 + void (*func)(void *), 1.199 + void *arg); 1.200 + sys_thread_t * (*ThreadSelf)(void); 1.201 + void (*ThreadYield)(void); 1.202 + int (*ThreadSuspend)(sys_thread_t *tid); 1.203 + int (*ThreadResume)(sys_thread_t *tid); 1.204 + int (*ThreadSetPriority)(sys_thread_t *tid, int prio); 1.205 + int (*ThreadGetPriority)(sys_thread_t *tid, int *prio); 1.206 + void * (*ThreadStackPointer)(sys_thread_t *tid); 1.207 + void * (*ThreadStackTop)(sys_thread_t *tid); 1.208 + long * (*ThreadRegs)(sys_thread_t *tid, int *regs); 1.209 + int (*ThreadSingle)(void); 1.210 + void (*ThreadMulti)(void); 1.211 + int (*ThreadEnumerateOver)(int (*func)(sys_thread_t *, void *), 1.212 + void *arg); 1.213 + int (*ThreadCheckStack)(void); 1.214 + void (*ThreadPostException)(sys_thread_t *tid, void *arg); 1.215 + void (*ThreadInterrupt)(sys_thread_t *tid); 1.216 + int (*ThreadIsInterrupted)(sys_thread_t *tid, int clear); 1.217 + int (*ThreadAlloc)(sys_thread_t **tidP); 1.218 + int (*ThreadFree)(void); 1.219 + jlong (*ThreadCPUTime)(void); 1.220 + int (*ThreadGetStatus)(sys_thread_t *tid, sys_mon_t **monitor); 1.221 + void * (*ThreadInterruptEvent)(void); 1.222 + void * (*ThreadNativeID)(sys_thread_t *tid); 1.223 + 1.224 + /* These three functions are used by the CPU time profiler. 1.225 + * sysThreadIsRunning determines whether the thread is running (not just 1.226 + * runnable). It is only safe to call this function after calling 1.227 + * sysThreadProfSuspend. 1.228 + */ 1.229 + bool_t (*ThreadIsRunning)(sys_thread_t *tid); 1.230 + void (*ThreadProfSuspend)(sys_thread_t *tid); 1.231 + void (*ThreadProfResume)(sys_thread_t *tid); 1.232 + 1.233 + int (*AdjustTimeSlice)(int ms); 1.234 + 1.235 + size_t (*MonitorSizeof)(void); 1.236 + int (*MonitorInit)(sys_mon_t *mid); 1.237 + int (*MonitorDestroy)(sys_mon_t *mid); 1.238 + int (*MonitorEnter)(sys_thread_t *self, sys_mon_t *mid); 1.239 + bool_t (*MonitorEntered)(sys_thread_t *self, sys_mon_t *mid); 1.240 + int (*MonitorExit)(sys_thread_t *self, sys_mon_t *mid); 1.241 + int (*MonitorNotify)(sys_thread_t *self, sys_mon_t *mid); 1.242 + int (*MonitorNotifyAll)(sys_thread_t *self, sys_mon_t *mid); 1.243 + int (*MonitorWait)(sys_thread_t *self, sys_mon_t *mid, jlong ms); 1.244 + bool_t (*MonitorInUse)(sys_mon_t *mid); 1.245 + sys_thread_t * (*MonitorOwner)(sys_mon_t *mid); 1.246 + int (*MonitorGetInfo)(sys_mon_t *mid, sys_mon_info *info); 1.247 + 1.248 +} HPI_ThreadInterface; 1.249 + 1.250 +/* 1.251 + * files 1.252 + */ 1.253 + 1.254 +#define HPI_FILETYPE_REGULAR (0) 1.255 +#define HPI_FILETYPE_DIRECTORY (1) 1.256 +#define HPI_FILETYPE_OTHER (2) 1.257 + 1.258 +typedef struct { 1.259 + char * (*NativePath)(char *path); 1.260 + int (*FileType)(const char *path); 1.261 + int (*Open)(const char *name, int openMode, int filePerm); 1.262 + int (*Close)(int fd); 1.263 + jlong (*Seek)(int fd, jlong offset, int whence); 1.264 + int (*SetLength)(int fd, jlong length); 1.265 + int (*Sync)(int fd); 1.266 + int (*Available)(int fd, jlong *bytes); 1.267 + size_t (*Read)(int fd, void *buf, unsigned int nBytes); 1.268 + size_t (*Write)(int fd, const void *buf, unsigned int nBytes); 1.269 + int (*FileSizeFD)(int fd, jlong *size); 1.270 +} HPI_FileInterface; 1.271 + 1.272 +/* 1.273 + * sockets 1.274 + */ 1.275 +struct sockaddr; 1.276 +struct hostent; 1.277 + 1.278 +typedef struct { 1.279 + int (*Close)(int fd); 1.280 + long (*Available)(int fd, jint *pbytes); 1.281 + int (*Connect)(int fd, struct sockaddr *him, int len); 1.282 + int (*Accept)(int fd, struct sockaddr *him, int *len); 1.283 + int (*SendTo)(int fd, char *buf, int len, int flags, 1.284 + struct sockaddr *to, int tolen); 1.285 + int (*RecvFrom)(int fd, char *buf, int nbytes, int flags, 1.286 + struct sockaddr *from, int *fromlen); 1.287 + int (*Listen)(int fd, long count); 1.288 + int (*Recv)(int fd, char *buf, int nBytes, int flags); 1.289 + int (*Send)(int fd, char *buf, int nBytes, int flags); 1.290 + int (*Timeout)(int fd, long timeout); 1.291 + struct hostent * (*GetHostByName)(char *hostname); 1.292 + int (*Socket)(int domain, int type, int protocol); 1.293 + int (*SocketShutdown)(int fd, int howto); 1.294 + int (*Bind)(int fd, struct sockaddr *him, int len); 1.295 + int (*GetSocketName)(int fd, struct sockaddr *him, int *len); 1.296 + int (*GetHostName)(char *hostname, int namelen); 1.297 + struct hostent * (*GetHostByAddr)(const char *hostname, int len, int type); 1.298 + int (*SocketGetOption)(int fd, int level, int optname, char *optval, int *optlen); 1.299 + int (*SocketSetOption)(int fd, int level, int optname, const char *optval, int optlen); 1.300 + struct protoent * (*GetProtoByName)(char* name); 1.301 +} HPI_SocketInterface; 1.302 + 1.303 +/* 1.304 + * callbacks. 1.305 + */ 1.306 +typedef struct vm_calls { 1.307 + int (*jio_fprintf)(FILE *fp, const char *fmt, ...); 1.308 + void (*panic)(const char *fmt, ...); 1.309 + void (*monitorRegister)(sys_mon_t *mid, char *info_str); 1.310 + 1.311 + void (*monitorContendedEnter)(sys_thread_t *self, sys_mon_t *mid); 1.312 + void (*monitorContendedEntered)(sys_thread_t *self, sys_mon_t *mid); 1.313 + void (*monitorContendedExit)(sys_thread_t *self, sys_mon_t *mid); 1.314 +} vm_calls_t; 1.315 + 1.316 +#ifdef __cplusplus 1.317 +} 1.318 +#endif 1.319 + 1.320 +#endif /* !_JAVASOFT_HPI_H_ */