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
|
/*-----------------------------------------------------------------*-C-*---
* File: handc/runtime/osglue.h
*
* Copyright (C)1997 Donovan Kolbly <d.kolbly@rscheme.org>
* as part of the RScheme project, licensed for free use.
* See <http://www.rscheme.org/> for the latest information.
*
* File version: 1.17
* File mod date: 1997.11.29 23:10:50
* System build: v0.7.2, 97.12.21
*
* Purpose: interface to standard OS/platform features
*------------------------------------------------------------------------*/
/*
* Interface to the minimal functionality
* expected from the OS for normal
* operation
*/
#ifndef _H_RSCHEME_OSGLUE
#define _H_RSCHEME_OSGLUE
#include <stdio.h>
#include <rscheme/obj.h>
#include <rscheme/intrs.h>
void init_os( void );
/* open a file
(path is in canonical form, so you can say
os_fopen("foo/bar"), and on a Mac get fopen(":foo:bar"))
*/
FILE *os_fopen( const char *path, const char *mode );
const char *os_getenv( const char *key );
/* a minimal implementation can return "./",
but see src/corelib/process.scm for caveats
*/
obj os_getwd( void );
/* change the current working directory,
or signal an error on failure
(pathname in canonical form)
*/
void os_setwd( const char *path );
/* return YES or NO accordingly as whether the named
file exists
(pathname in canonical form)
*/
rs_bool os_file_exists_p( const char *path );
/* create a directory
(part of base system so that compiler can be self-hosting)
*/
void os_mkdir( const char *path );
/* convert a canonical pathname to local OS format */
obj os_path( obj path );
/*
arrange for some interrupts...
*/
/*
* if `msec' is 0, then signal an RSSIG_TIMEOUT immediately
*/
void os_set_timer( UINT_32 msec );
UINT_32 os_get_time_remaining( void );
/*
* os_halt_timer() must ensure that an RSSIG_TIMEOUT is not
* queued. Usually, this only needs to be checked if
* it returns 0
*/
UINT_32 os_halt_timer( void );
/*
* sleep for up to `msec' milliseconds
* returns the amount of time actually slept
* (may be larger msec, if the true real time
* is available and happens to be larger, or may
* be less if the sleep was interrupted, as by
* a signal)
*/
UINT_32 os_sleep( UINT_32 msec );
#if !HAVE_SETITIMER
#ifndef TIMER_IS_MONOTONE_COUNTER
#define TIMER_IS_MONOTONE_COUNTER
#endif
#endif
#ifdef TIMER_IS_MONOTONE_COUNTER
extern UINT_32 system_timeout;
#endif
/*
return a list of symbols specifying the OS type
*/
obj os_type( void );
/*
* manage a bounded, ordered list of integers atomically,
* with a gate on rssig_ready
*/
/*
* this is YES if there is an RS signal waiting to be
* delivered via os_get_next_sig()
* (in particular, it is NO if signals are disabled even
* if there is something in the internal queue)
*/
extern rs_bool rssig_ready;
void os_enqueue_sig( struct RSSIG_info *sig );
/* used to scan sig queue during root traversal */
int os_scan_sig_queue( unsigned *index, obj *item );
/* use the `_from_handler' form when interrupts are already disabled */
void os_enqueue_sig_from_handler( struct RSSIG_info *sig );
/* registers an interrupt handler that will run with all
* interrupts disabled, and can make use of the `os_enqueue_sig_from_handler'
* function. Returns -1 if the signal is invalid
*/
int os_register_signal_handler( int sig, void (*proc)( int ) );
struct RSSIG_info os_get_next_sig( void ); /* disables rssig_ready */
rs_bool os_set_sigenable( rs_bool flag );
void set_sigqueue_size( int n );
/* signal an instance of <os-error>, capturing the current `errno' */
void os_error( const char *fn, int num_args, ... );
/* return a message describing the error */
obj os_errormsg( int error_num );
/* time manipulation functions */
struct RSTime os_current_time( void );
struct RSTime rstime_sub( struct RSTime a, struct RSTime b );
IEEE_64 rstime_to_sec( struct RSTime a );
#endif /* _H_RSCHEME_OSGLUE */
|