2 * @(#)sys_api.h 1.6 02/09/27
4 * Copyright 1995-1999 by Sun Microsystems, Inc.,
5 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
8 * This software is the confidential and proprietary information
9 * of Sun Microsystems, Inc. ("Confidential Information"). You
10 * shall not disclose such Confidential Information and shall use
11 * it only in accordance with the terms of the license agreement
12 * you entered into with Sun.
13 * Use is subject to license terms.
17 * System or Host dependent API. This defines the "porting layer" for
18 * POSIX.1 compliant operating systems.
25 * typedefs_md.h includes basic types for this platform;
26 * any macros for HPI functions have been moved to "sysmacros_md.h"
31 * Miscellaneous system utility APIs that fall outside the POSIX.1
34 * Until POSIX (P1003.1a) formerly P.4 is standard, we'll use our
35 * time struct definitions found in timeval.h.
37 long sysGetMilliTicks(void);
39 int64_t sysTimeMillis(void);
42 struct tm
* sysLocaltime(time_t *, struct tm
*);
43 struct tm
* sysGmtime(time_t *, struct tm
*);
44 void sysStrftime(char *, int, char *, struct tm
*);
45 time_t sysMktime(struct tm
*);
48 * System API for general allocations
50 void * sysMalloc(size_t);
51 void * sysRealloc(void*, size_t);
53 void * sysCalloc(size_t, size_t);
55 void * sysAllocBlock(size_t, void**);
56 void sysFreeBlock(void *);
57 #endif /* PAGED_HEAPS */
60 * System API for dynamic linking libraries into the interpreter
62 char * sysInitializeLinker(void);
63 int sysAddDLSegment(char *);
64 void sysSaveLDPath(char *);
65 long sysDynamicLink(char *);
66 void sysBuildLibName(char *, int, char *, char *);
67 int sysBuildFunName(char *, int, void *, int);
68 long * sysInvokeNative(void *, void *, long *, char *, int, void *);
71 * System API for invoking the interpreter from native applications
73 void sysGetDefaultJavaVMInitArgs(void *);
74 int sysInitializeJavaVM(void *, void *);
75 int sysFinalizeJavaVM(void *);
76 void sysAttachThreadLock();
77 void sysAttachThreadUnlock();
80 * System API for threads
82 typedef struct sys_thread sys_thread_t
;
83 typedef struct sys_mon sys_mon_t
;
84 typedef void * stackp_t
;
86 int sysThreadBootstrap(sys_thread_t
**, void *);
87 void sysThreadInitializeSystemThreads(void);
90 int sysThreadCreate(long, uint flags
, void *(*)(void *),
91 sys_thread_t
**, void *);
93 int sysThreadCreate(long, uint_t flags
, void *(*)(void *),
94 sys_thread_t
**, void *);
97 void sysThreadExit(void);
98 sys_thread_t
* sysThreadSelf(void);
99 void sysThreadYield(void);
100 int sysThreadVMSuspend(sys_thread_t
*, sys_thread_t
*);
101 void sysThreadVMSuspendMe(void);
102 int sysThreadVMUnsuspend(sys_thread_t
*);
103 int sysThreadSuspend(sys_thread_t
*);
104 int sysThreadResume(sys_thread_t
*);
105 int sysThreadSetPriority(sys_thread_t
*, int);
106 int sysThreadGetPriority(sys_thread_t
*, int *);
107 void * sysThreadStackPointer(sys_thread_t
*);
108 stackp_t
sysThreadStackBase(sys_thread_t
*);
109 void sysThreadSetStackBase(sys_thread_t
*, stackp_t
);
110 int sysThreadSingle(void);
111 void sysThreadMulti(void);
112 int sysThreadEnumerateOver(int (*)(sys_thread_t
*, void *), void *);
113 void sysThreadInit(sys_thread_t
*, stackp_t
);
114 void * sysThreadGetBackPtr(sys_thread_t
*);
115 int sysThreadCheckStack(void);
116 int sysInterruptsPending(void);
117 void sysThreadPostException(sys_thread_t
*, void *);
118 void sysThreadDumpInfo(sys_thread_t
*);
119 void sysThreadInterrupt(sys_thread_t
*);
120 int sysThreadIsInterrupted(sys_thread_t
*, long);
121 int sysThreadAlloc(sys_thread_t
**, stackp_t
, void *);
122 int sysThreadFree(sys_thread_t
*);
125 * System API for monitors
127 int sysMonitorSizeof(void);
128 int sysMonitorInit(sys_mon_t
*);
129 int sysMonitorDestroy(sys_mon_t
*);
130 int sysMonitorEnter(sys_mon_t
*);
131 bool_t
sysMonitorEntered(sys_mon_t
*);
132 int sysMonitorExit(sys_mon_t
*);
133 int sysMonitorNotify(sys_mon_t
*);
134 int sysMonitorNotifyAll(sys_mon_t
*);
135 int sysMonitorWait(sys_mon_t
*, int, bool_t
);
136 void sysMonitorDumpInfo(sys_mon_t
*);
137 bool_t
sysMonitorInUse(sys_mon_t
*);
141 #define SYS_INTRPT -2 /* Operation was interrupted */
142 #define SYS_TIMEOUT -3 /* A timer ran out */
143 #define SYS_NOMEM -5 /* Ran out of memory */
144 #define SYS_NORESOURCE -6 /* Ran out of some system resource */
147 * Symbolic constant to be used when waiting indefinitely on a condition
150 #define SYS_TIMEOUT_INFINITY -1
153 * System API for raw memory allocation
155 void * sysMapMem(long, long *);
156 void * sysUnmapMem(void *, long, long *);
157 void * sysCommitMem(void *, long, long *);
158 void * sysDecommitMem(void *, long, long *);
159 void * sysUncommitMem(void *, long, long *);
162 * System API for termination
165 int sysAtexit(void (*func
)(void));
169 * System API for files
171 extern int sysIsAbsolute(const char* path
);
172 extern int sysAccess(const char* pFile
, int perm
);
174 extern int sysStat(const char *path
, struct stat
*sbuf
);
175 extern int sysFStat(int fd
, struct stat
* sbuf
);
177 extern int sysOpen(const char *name
, int openMode
, int filePerm
);
178 extern int sysClose(int fd
);
180 extern long sysSeek(int fd
, long offset
, int whence
);
181 extern int sysAvailable(int fd
, long* bytes
);
182 extern size_t sysRead(int fd
, void *buf
, unsigned int nBytes
);
183 extern size_t sysWrite(int fd
, const void *buf
, unsigned int nBytes
);
185 extern int sysRename(const char* srcName
, const char* dstName
);
186 extern int sysUnlink(const char* file
);
188 extern int sysMkdir(const char* path
, int mode
);
189 extern int sysRmdir(const char* path
);
190 extern int sysCanonicalPath(char *path
, char *result
, int result_len
);
193 * API support needed for various multiprocessor related synchronization
194 * primitives. Systems that don't use real threads can just define
195 * these to be 0 in their sysmacros_md.h.
199 void sysMemoryFlush();
200 void sysStoreBarrier();
203 * Include platform specific macros to override these
205 #include "sysmacros_md.h"
207 #endif /* !_SYS_API_H_ */