home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / sys_api.h < prev    next >
C/C++ Source or Header  |  1997-11-24  |  7KB  |  213 lines

  1. /*
  2.  * @(#)sys_api.h    1.63 97/10/07
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. /*
  24.  * System or Host dependent API.  This defines the "porting layer" for
  25.  * POSIX.1 compliant operating systems.
  26.  */
  27.  
  28. #ifndef _SYS_API_H_
  29. #define _SYS_API_H_
  30.  
  31. /*
  32.  * typedefs_md.h includes basic types for this platform;
  33.  * any macros for HPI functions have been moved to "sysmacros_md.h"
  34.  */
  35. #include "typedefs_md.h"
  36.  
  37. /*
  38.  * Miscellaneous system utility APIs that fall outside the POSIX.1
  39.  * spec.
  40.  *
  41.  * Until POSIX (P1003.1a) formerly P.4 is standard, we'll use our
  42.  * time struct definitions found in timeval.h.
  43.  */
  44. #include "timeval.h"
  45. long     sysGetMilliTicks(void);
  46. long    sysTime(long *);
  47. int64_t sysTimeMillis(void);
  48.  
  49. #include "time.h"
  50. struct tm * sysLocaltime(time_t *, struct tm*);
  51. struct tm * sysGmtime(time_t *, struct tm*);
  52. void        sysStrftime(char *, int, char *, struct tm *);
  53. time_t      sysMktime(struct tm*);
  54.  
  55. /*
  56.  * System API for general allocations
  57.  */
  58. void *    sysMalloc(size_t);
  59. void *    sysRealloc(void*, size_t);
  60. void    sysFree(void*);
  61. void *    sysCalloc(size_t, size_t);
  62. #ifdef PAGED_HEAPS
  63. void *  sysAllocBlock(size_t, void**);
  64. void    sysFreeBlock(void *);
  65. #endif /* PAGED_HEAPS */
  66.  
  67. /*
  68.  * System API for dynamic linking libraries into the interpreter
  69.  */
  70. char *  sysInitializeLinker(void);
  71. int     sysAddDLSegment(char *);
  72. void    sysSaveLDPath(char *);
  73. long    sysDynamicLink(char *);
  74. void    sysBuildLibName(char *, int, char *, char *);
  75. int     sysBuildFunName(char *, int, void *, int);
  76. long *  sysInvokeNative(void *, void *, long *, char *, int, void *);
  77.  
  78. /*
  79.  * System API for invoking the interpreter from native applications
  80.  */
  81. void    sysGetDefaultJavaVMInitArgs(void *);
  82. int     sysInitializeJavaVM(void *, void *);
  83. int     sysFinalizeJavaVM(void *);
  84. void    sysAttachThreadLock();
  85. void    sysAttachThreadUnlock();
  86.  
  87. /*
  88.  * System API for threads
  89.  */
  90. typedef struct  sys_thread sys_thread_t;
  91. typedef struct  sys_mon sys_mon_t;
  92. typedef void *  stackp_t;
  93.  
  94. int     sysThreadBootstrap(sys_thread_t **, void *);
  95. void     sysThreadInitializeSystemThreads(void);
  96. int     sysThreadCreate(long, uint_t flags, void *(*)(void *),
  97.             sys_thread_t **, void *);
  98. void    sysThreadExit(void);
  99. sys_thread_t * sysThreadSelf(void);
  100. void    sysThreadYield(void);
  101. int     sysThreadVMSuspend(sys_thread_t *, sys_thread_t *);
  102. void    sysThreadVMSuspendMe(void);
  103. int     sysThreadVMUnsuspend(sys_thread_t *);
  104. int    sysThreadSuspend(sys_thread_t *);
  105. int    sysThreadResume(sys_thread_t *);
  106. int    sysThreadSetPriority(sys_thread_t *, int);
  107. int    sysThreadGetPriority(sys_thread_t *, int *);
  108. void *  sysThreadStackPointer(sys_thread_t *); 
  109. stackp_t sysThreadStackBase(sys_thread_t *); 
  110. void    sysThreadSetStackBase(sys_thread_t *, stackp_t); 
  111. int    sysThreadSingle(void);
  112. void    sysThreadMulti(void);
  113. int     sysThreadEnumerateOver(int (*)(sys_thread_t *, void *), void *);
  114. void    sysThreadInit(sys_thread_t *, stackp_t);
  115. void *  sysThreadGetBackPtr(sys_thread_t *);
  116. int     sysThreadCheckStack(void);
  117. int     sysInterruptsPending(void);
  118. void    sysThreadPostException(sys_thread_t *, void *);
  119. void    sysThreadDumpInfo(sys_thread_t *);
  120. void    sysThreadInterrupt(sys_thread_t *);
  121. int     sysThreadIsInterrupted(sys_thread_t *, long);
  122. int     sysThreadAlloc(sys_thread_t **, stackp_t, void *);
  123. int     sysThreadFree(sys_thread_t *);
  124.  
  125. /*
  126.  * System API for monitors
  127.  */
  128. int     sysMonitorSizeof(void);
  129. int     sysMonitorInit(sys_mon_t *);
  130. int     sysMonitorDestroy(sys_mon_t *);
  131. int     sysMonitorEnter(sys_mon_t *);
  132. bool_t  sysMonitorEntered(sys_mon_t *);
  133. int     sysMonitorExit(sys_mon_t *);
  134. int     sysMonitorNotify(sys_mon_t *);
  135. int     sysMonitorNotifyAll(sys_mon_t *);
  136. int     sysMonitorWait(sys_mon_t *, int, bool_t);
  137. void    sysMonitorDumpInfo(sys_mon_t *);
  138. bool_t  sysMonitorInUse(sys_mon_t *);
  139.  
  140. #define SYS_OK            0
  141. #define SYS_ERR           -1
  142. #define SYS_INTRPT     -2    /* Operation was interrupted */
  143. #define SYS_TIMEOUT    -3    /* A timer ran out */
  144. #define SYS_NOMEM      -5    /* Ran out of memory */
  145. #define SYS_NORESOURCE -6    /* Ran out of some system resource */
  146.  
  147. /*
  148.  * Symbolic constant to be used when waiting indefinitly on a condition
  149.  * variable
  150.  */
  151. #define SYS_TIMEOUT_INFINITY -1
  152.  
  153. /*
  154.  * System API for raw memory allocation
  155.  */
  156. void *  sysMapMem(long, long *);
  157. void *  sysUnmapMem(void *, long, long *);
  158. void *  sysCommitMem(void *, long, long *);
  159. void *  sysUncommitMem(void *, long, long *);
  160.  
  161. /*
  162.  * System API for termination
  163.  */
  164. void    sysExit(int);
  165. int    sysAtexit(void (*func)(void));
  166. void    sysAbort(void);
  167.  
  168. /*
  169.  * System API for files
  170.  */
  171. extern int sysIsAbsolute(const char* path);
  172. extern int sysAccess(const char* pFile, int perm);
  173.  
  174. extern int sysStat(const char *path, struct stat *sbuf);
  175. extern int sysFStat(int fd, struct stat * sbuf);
  176.  
  177. extern int sysOpen(const char *name, int openMode, int filePerm);
  178. extern int sysClose(int fd);
  179.  
  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);
  184.  
  185. extern int sysRename(const char* srcName, const char* dstName);
  186. extern int sysUnlink(const char* file);
  187.  
  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);
  191.  
  192. #include "io_md.h"
  193. extern DIR* sysOpenDir(const char* path);
  194. extern int sysCloseDir(DIR* dp);
  195. extern struct dirent* sysReadDir(DIR* dp);
  196.  
  197. /*
  198.  * API support needed for various multiprocessor related syncronization
  199.  * primitives.  Systems that don't use real threads can just define
  200.  * these to be 0 in their sysmacros_md.h.
  201.  */
  202.  
  203. int sysIsMP();
  204. void sysMemoryFlush();
  205. void sysStoreBarrier();
  206.  
  207. /*
  208.  * Include platform specific macros to override these
  209.  */
  210. #include "sysmacros_md.h"
  211.  
  212. #endif /* !_SYS_API_H_ */
  213.