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