J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | #ifndef _JAVASOFT_HPI_IMPL_H_ |
| 27 | #define _JAVASOFT_HPI_IMPL_H_ |
| 28 | |
| 29 | #include "hpi.h" |
| 30 | |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | #include "vm_calls.h" |
| 36 | |
| 37 | extern int nReservedBytes; |
| 38 | sys_thread_t *allocThreadBlock(void); |
| 39 | void freeThreadBlock(sys_thread_t *tid); |
| 40 | int threadBootstrapMD(sys_thread_t **tid, sys_mon_t **lockP, int nb); |
| 41 | |
| 42 | HPI_SysInfo *sysGetSysInfo(void); |
| 43 | long sysGetMilliTicks(void); |
| 44 | jlong sysTimeMillis(void); |
| 45 | |
| 46 | signal_handler_t sysSignal(int sig, signal_handler_t handler); |
| 47 | void sysRaise(int sig); |
| 48 | void sysSignalNotify(int sig); |
| 49 | int sysSignalWait(void); |
| 50 | int sysShutdown(void); |
| 51 | int sysSetLoggingLevel(int level); |
| 52 | bool_t sysSetMonitoringOn(bool_t on); |
| 53 | int sysGetLastErrorString(char *buf, int len); |
| 54 | |
| 55 | void * sysMalloc(size_t); |
| 56 | void * sysRealloc(void*, size_t); |
| 57 | void sysFree(void*); |
| 58 | void * sysCalloc(size_t, size_t); |
| 59 | char * sysStrdup(const char * string); |
| 60 | void * sysMapMem(size_t, size_t *); |
| 61 | void * sysUnmapMem(void *, size_t, size_t *); |
| 62 | void * sysCommitMem(void * ptr, size_t size, size_t * actual); |
| 63 | void * sysDecommitMem(void * ptr, size_t size, size_t * actual); |
| 64 | void * sysAllocBlock(size_t, void**); |
| 65 | void sysFreeBlock(void *); |
| 66 | |
| 67 | void sysBuildLibName(char *, int, char *, char *); |
| 68 | int sysBuildFunName(char *, int, int, int); |
| 69 | void * sysLoadLibrary(const char *, char *err_buf, int err_buflen); |
| 70 | void sysUnloadLibrary(void *); |
| 71 | void * sysFindLibraryEntry(void *, const char *); |
| 72 | |
| 73 | int sysThreadBootstrap(sys_thread_t **, sys_mon_t **, int); |
| 74 | int sysThreadCreate(sys_thread_t **, |
| 75 | long, |
| 76 | void (*)(void *), |
| 77 | void *arg); |
| 78 | void sysThreadExit(void); |
| 79 | sys_thread_t * sysThreadSelf(void); |
| 80 | void sysThreadYield(void); |
| 81 | int sysThreadSuspend(sys_thread_t *); |
| 82 | int sysThreadResume(sys_thread_t *); |
| 83 | int sysThreadSetPriority(sys_thread_t *, int); |
| 84 | int sysThreadGetPriority(sys_thread_t *, int *); |
| 85 | void * sysThreadStackPointer(sys_thread_t *); |
| 86 | void * sysThreadStackTop(sys_thread_t *); |
| 87 | long * sysThreadRegs(sys_thread_t *, int *); |
| 88 | int sysThreadSingle(void); |
| 89 | void sysThreadMulti(void); |
| 90 | int sysThreadEnumerateOver(int (*)(sys_thread_t *, void *), void *); |
| 91 | int sysThreadCheckStack(void); |
| 92 | void sysThreadPostException(sys_thread_t *, void *); |
| 93 | void sysThreadInterrupt(sys_thread_t *); |
| 94 | int sysThreadIsInterrupted(sys_thread_t *, int); |
| 95 | int sysThreadAlloc(sys_thread_t **); |
| 96 | int sysThreadFree(void); |
| 97 | size_t sysThreadSizeof(void); |
| 98 | jlong sysThreadCPUTime(void); |
| 99 | int sysThreadGetStatus(sys_thread_t *, sys_mon_t **); |
| 100 | int sysAdjustUserThreadCount(int delta); |
| 101 | bool_t sysThreadIsRunning(sys_thread_t *); |
| 102 | void sysThreadProfSuspend(sys_thread_t *); |
| 103 | void sysThreadProfResume(sys_thread_t *); |
| 104 | int sysAdjustTimeSlice(int); |
| 105 | int sysThreadEnumerateOver(int (*f)(sys_thread_t *, void *), void *arg); |
| 106 | void * sysThreadInterruptEvent(void); |
| 107 | void * sysThreadNativeID(sys_thread_t *); |
| 108 | |
| 109 | size_t sysMonitorSizeof(void); |
| 110 | int sysMonitorInit(sys_mon_t *); |
| 111 | int sysMonitorDestroy(sys_mon_t *); |
| 112 | int sysMonitorEnter(sys_thread_t *, sys_mon_t *); |
| 113 | bool_t sysMonitorEntered(sys_thread_t *, sys_mon_t *); |
| 114 | int sysMonitorExit(sys_thread_t *, sys_mon_t *); |
| 115 | int sysMonitorNotify(sys_thread_t *, sys_mon_t *); |
| 116 | int sysMonitorNotifyAll(sys_thread_t *, sys_mon_t *); |
| 117 | int sysMonitorWait(sys_thread_t *, sys_mon_t *, jlong); |
| 118 | bool_t sysMonitorInUse(sys_mon_t *); |
| 119 | sys_thread_t * sysMonitorOwner(sys_mon_t *); |
| 120 | int sysMonitorGetInfo(sys_mon_t *, sys_mon_info *); |
| 121 | |
| 122 | char *sysNativePath(char *path); |
| 123 | int sysFileType(const char *path); |
| 124 | int sysOpen(const char *name, int openMode, int filePerm); |
| 125 | int sysClose(int fd); |
| 126 | jlong sysSeek(int fd, jlong offset, int whence); |
| 127 | int sysSetLength(int fd, jlong length); |
| 128 | int sysSync(int fd); |
| 129 | int sysAvailable(int fd, jlong *bytes); |
| 130 | size_t sysRead(int fd, void *buf, unsigned int nBytes); |
| 131 | size_t sysWrite(int fd, const void *buf, unsigned int nBytes); |
| 132 | int sysFileSizeFD(int fd, jlong *size); |
| 133 | |
| 134 | int sysSocketClose(int fd); |
| 135 | int sysSocketShutdown(int fd, int howto); |
| 136 | long sysSocketAvailable(int fd, jint *pbytes); |
| 137 | int sysConnect(int fd, struct sockaddr *him, int len); |
| 138 | int sysBind(int fd, struct sockaddr *him, int len); |
| 139 | int sysAccept(int fd, struct sockaddr *him, int *len); |
| 140 | int sysGetSockName(int fd, struct sockaddr *him, int *len); |
| 141 | #ifdef _LP64 |
| 142 | ssize_t sysSendTo(int fd, char *buf, int len, int flags, struct sockaddr *to, |
| 143 | int tolen); |
| 144 | ssize_t sysRecvFrom(int fd, char *buf, int nbytes, int flags, |
| 145 | struct sockaddr *from, int *fromlen); |
| 146 | ssize_t sysRecv(int fd, char *buf, int nBytes, int flags); |
| 147 | ssize_t sysSend(int fd, char *buf, int nBytes, int flags); |
| 148 | #else |
| 149 | int sysSendTo(int fd, char *buf, int len, int flags, struct sockaddr *to, |
| 150 | int tolen); |
| 151 | int sysRecvFrom(int fd, char *buf, int nbytes, int flags, |
| 152 | struct sockaddr *from, int *fromlen); |
| 153 | int sysRecv(int fd, char *buf, int nBytes, int flags); |
| 154 | int sysSend(int fd, char *buf, int nBytes, int flags); |
| 155 | #endif |
| 156 | int sysListen(int fd, int count); |
| 157 | int sysTimeout(int fd, long timeout); |
| 158 | int sysGetHostName(char* name, int namelen); |
| 159 | struct hostent *sysGetHostByAddr(const char* name, int len, int type); |
| 160 | struct hostent *sysGetHostByName(char *hostname); |
| 161 | int sysSocket(int domain, int type, int protocol); |
| 162 | int sysGetSockOpt(int fd, int level, int optname, char *optval, int *optlen); |
| 163 | int sysSetSockOpt(int fd, int level, int optname, const char *optval, int optlen); |
| 164 | struct protoent * sysGetProtoByName(char* name); |
| 165 | |
| 166 | #define SYS_SIG_DFL HPI_SIG_DFL |
| 167 | #define SYS_SIG_ERR HPI_SIG_ERR |
| 168 | #define SYS_SIG_IGN HPI_SIG_IGN |
| 169 | |
| 170 | #define SYS_OK HPI_OK |
| 171 | #define SYS_ERR HPI_ERR |
| 172 | #define SYS_INTRPT HPI_INTRPT |
| 173 | #define SYS_TIMEOUT HPI_TIMEOUT |
| 174 | #define SYS_NOMEM HPI_NOMEM |
| 175 | #define SYS_NORESOURCE HPI_NORESOURCE |
| 176 | |
| 177 | #define SYS_THREAD_RUNNABLE HPI_THREAD_RUNNABLE |
| 178 | #define SYS_THREAD_MONITOR_WAIT HPI_THREAD_MONITOR_WAIT |
| 179 | #define SYS_THREAD_CONDVAR_WAIT HPI_THREAD_CONDVAR_WAIT |
| 180 | |
| 181 | #define MinimumPriority HPI_MINIMUM_PRIORITY |
| 182 | #define MaximumPriority HPI_MAXIMUM_PRIORITY |
| 183 | #define NormalPriority HPI_NORMAL_PRIORITY |
| 184 | |
| 185 | #define SYS_THREAD_SUSPENDED HPI_THREAD_SUSPENDED |
| 186 | |
| 187 | #define PAGE_ALIGNMENT HPI_PAGE_ALIGNMENT |
| 188 | |
| 189 | #define SYS_TIMEOUT_INFINITY HPI_TIMEOUT_INFINITY |
| 190 | |
| 191 | #define SYS_FILETYPE_REGULAR HPI_FILETYPE_REGULAR |
| 192 | #define SYS_FILETYPE_DIRECTORY HPI_FILETYPE_DIRECTORY |
| 193 | #define SYS_FILETYPE_OTHER HPI_FILETYPE_OTHER |
| 194 | |
| 195 | typedef void *stackp_t; |
| 196 | |
| 197 | /* global vars */ |
| 198 | |
| 199 | extern int logging_level; |
| 200 | extern bool_t profiler_on; |
| 201 | |
| 202 | #ifdef __cplusplus |
| 203 | } |
| 204 | #endif |
| 205 | |
| 206 | #endif /* !_JAVASOFT_HPI_IMPL_H_ */ |