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