1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
|
/******************************** -*- C -*- ****************************
*
* System specific module declarations
*
*
***********************************************************************/
/***********************************************************************
*
* Copyright 1988,89,90,91,92,94,95,99,2000,2001,2002,2006,2007
* Free Software Foundation, Inc.
* Written by Steve Byrne.
*
* This file is part of GNU Smalltalk.
*
* GNU Smalltalk is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2, or (at your option) any later
* version.
*
* Linking GNU Smalltalk statically or dynamically with other modules is
* making a combined work based on GNU Smalltalk. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the Free Software Foundation
* give you permission to combine GNU Smalltalk with free software
* programs or libraries that are released under the GNU LGPL and with
* independent programs running under the GNU Smalltalk virtual machine.
*
* You may copy and distribute such a system following the terms of the
* GNU GPL for GNU Smalltalk and the licenses of the other code
* concerned, provided that you include the source code of that other
* code when and as the GNU GPL requires distribution of source code.
*
* Note that people who make modified versions of GNU Smalltalk are not
* obligated to grant this special exception for their modified
* versions; it is their choice whether to do so. The GNU General
* Public License gives permission to release a modified version without
* this exception; this exception also makes it possible to release a
* modified version which carries forward this exception.
*
* GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* GNU Smalltalk; see the file COPYING. If not, write to the Free Software
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
***********************************************************************/
#ifndef GST_SYSDEP_H
#define GST_SYSDEP_H
#ifdef sgi
# define _BSD_SIGNALS
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
#define TIMER_REAL SIGALRM
#define TIMER_PROCESS SIGVTALRM
#ifndef HAVE_SYS_MMAN_H
#define PROT_READ 0x1 /* Page can be read. */
#define PROT_WRITE 0x2 /* Page can be written. */
#define PROT_EXEC 0x4 /* Page can be executed. */
#define PROT_NONE 0x0 /* Page can not be accessed. */
#endif
/* These nice tests are simple, guaranteed and independent of byte order. */
#define IS_FINITE(dbl) (!IS_NAN((dbl) * 0.0))
#define IS_NAN(dbl) ((dbl) != (dbl))
typedef RETSIGTYPE (*SigHandler) ();
/* Saves and returns the current state of the software interrupt
system. Disables all interrupts. */
extern void _gst_disable_interrupts (void)
ATTRIBUTE_HIDDEN;
/* Restores the state of the interrupt system to that which it had when
_gst_disable_interrupts was last invoked. */
extern void _gst_enable_interrupts (void)
ATTRIBUTE_HIDDEN;
/* Set the signal handler for signal SIGNUM to be HANDLERFUNC. */
extern SigHandler _gst_set_signal_handler (int signum,
SigHandler handlerFunc)
ATTRIBUTE_HIDDEN;
/* Given a KIND of timer (process timer, real-time timer, etc.,
establish FUNC to be called when DELTAMILLI milliseconds have
passed according to that counter. */
extern void _gst_signal_after (int deltaMilli,
SigHandler func,
int kind)
ATTRIBUTE_HIDDEN;
/* Initialize system dependent stuff. */
extern void _gst_init_sysdep (void)
ATTRIBUTE_HIDDEN;
/* Arrange so that FUNC is called when I/O becomes possible on
registered file descriptors, and set up FD to trigger the
signal. */
extern void _gst_set_file_interrupt (int fd,
SigHandler func)
ATTRIBUTE_HIDDEN;
/* Used for debugging. You set a breakpoint in the _gst_debug routine
in the debugger, and have code call it when you want it to stop.
Performs no action normally. */
extern void _gst_debug (void)
ATTRIBUTE_HIDDEN;
/* Returns the local time since midnight in milliseconds */
extern unsigned _gst_get_milli_time (void)
ATTRIBUTE_HIDDEN;
/* Returns the time in seconds since midnight Jan 1, 1970 (standard UNIX
type time). */
extern time_t _gst_get_time (void)
ATTRIBUTE_HIDDEN;
/* Returns whether FILE1 is newer (or last modified at the same time as)
FILE2. Returns true if FILE2 is not readable, false if FILE1 is not
readable. */
extern mst_Boolean _gst_file_is_newer (const char *file1, const char *file2)
ATTRIBUTE_HIDDEN;
/* Sets the time when FILENAME was last modified. The times are in
seconds, relative to 1 Jan 2000. */
extern int _gst_set_file_access_times (const char *name, long new_atime,
long new_mtime)
ATTRIBUTE_HIDDEN;
/* Converts the given time (expressed in seconds since midnight Jan 1,
1970, and in Universal Coordinated Time) into a local time. */
extern time_t _gst_adjust_time_zone (time_t t)
ATTRIBUTE_HIDDEN;
/* Answer the current bias in seconds between UTC and local time */
extern long _gst_current_time_zone_bias (void)
ATTRIBUTE_HIDDEN;
/* Returns the full path name for a given file. */
extern char *_gst_get_full_file_name (const char *fileName)
ATTRIBUTE_HIDDEN;
/* Returns the path name for the current directory, without trailing
delimiter. The return value is a pointer to allocated string for
current path name. Caller has responsibility for freeing the
returned value when through. */
extern char *_gst_get_cur_dir_name (void)
ATTRIBUTE_HIDDEN;
/* Returns the name of the current time zone. */
extern char *_gst_current_time_zone_name (void)
ATTRIBUTE_HIDDEN;
/* Portable implementation of mprotect. The implementation does not
necessarily support PROT_EXEC or PROT_WRITE without PROT_READ. The
only guarantees are that no writing will be allowed without
PROT_WRITE and no access will be allowed for PROT_NONE. */
extern int _gst_mem_protect (PTR addr,
size_t len,
int prot)
ATTRIBUTE_HIDDEN;
/* Returns true if the file named FILENAME exists has the given
permission for the current user. Returns false otherwise. */
extern mst_Boolean _gst_file_is_readable (const char *fileName)
ATTRIBUTE_HIDDEN;
extern mst_Boolean _gst_file_is_writeable (const char *fileName)
ATTRIBUTE_HIDDEN;
extern mst_Boolean _gst_file_is_executable (const char *fileName)
ATTRIBUTE_HIDDEN;
/* Return a path to the executable given argv[0]. */
extern char *_gst_find_executable (const char *argv0)
ATTRIBUTE_HIDDEN;
/* Answer true if the file descriptor FD is associated to a pipe
(it cannot be seeked through). */
extern mst_Boolean _gst_is_pipe (int fd)
ATTRIBUTE_HIDDEN;
/* Similar to popen, but supports two-way pipes (achieved through
tty's) and returns a file descriptor. */
extern int _gst_open_pipe (const char *command,
const char *mode)
ATTRIBUTE_HIDDEN;
/* Similar to fopen, but returns a file descriptor. */
extern int _gst_open_file (const char *filename,
const char *mode)
ATTRIBUTE_HIDDEN;
/* Read SIZE bytes into BUFFER from the file descriptor, FD. */
extern int _gst_read (int fd,
PTR buffer,
int size)
ATTRIBUTE_HIDDEN;
/* Ensures that exactly SIZE bytes of BUFFER are written into the
file descriptor, FD. */
extern int _gst_full_write (int fd,
PTR buffer,
int size)
ATTRIBUTE_HIDDEN;
/* Write SIZE bytes of BUFFER into the file descriptor, FD. */
extern int _gst_write (int fd,
PTR buffer,
int size)
ATTRIBUTE_HIDDEN;
/* Read SIZE bytes into BUFFER from the file descriptor, FD. */
extern int _gst_recv (int fd,
PTR buffer,
int size,
int flags)
ATTRIBUTE_HIDDEN;
/* Write SIZE bytes of BUFFER into the socket descriptor, FD. */
extern int _gst_send (int fd,
PTR buffer,
int size,
int flags)
ATTRIBUTE_HIDDEN;
/* Writes a debug message with the given formatting. */
extern void _gst_debugf (const char *, ...)
ATTRIBUTE_PRINTF_1
ATTRIBUTE_HIDDEN;
/* Do an anonymous memory map of SIZE bytes. */
extern PTR _gst_osmem_alloc (size_t size)
ATTRIBUTE_HIDDEN;
/* Unmap the SIZE bytes at PTR. */
extern void _gst_osmem_free (PTR ptr, size_t size)
ATTRIBUTE_HIDDEN;
/* Reserve SIZE bytes of the address space without allocating them. */
extern PTR _gst_osmem_reserve (PTR base,
size_t size)
ATTRIBUTE_HIDDEN;
/* Release SIZE bytes of the address space starting from BASE. */
extern void _gst_osmem_release (PTR base,
size_t size)
ATTRIBUTE_HIDDEN;
/* Actually allocate SIZE bytes of address space, starting from BASE,
that have already been reserved. */
extern PTR _gst_osmem_commit (PTR base,
size_t size)
ATTRIBUTE_HIDDEN;
/* Free the memory used by SIZE bytes of address space, starting from BASE,
but keep the addresses reserved. */
extern void _gst_osmem_decommit (PTR base,
size_t size)
ATTRIBUTE_HIDDEN;
#endif /* GST_SYSDEP_H */
|