X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fos.h;h=9dd1649c0e456282889d6dae83132e04a57f78f0;hb=0285aa5ff8416027932daa001b84429be2ca559b;hp=1d8e43673ec7ebb5eb773b1414e1d935d0dbe593;hpb=cea4896b2482b7b2b429c1631d774b4cfbc0efba;p=sbcl.git diff --git a/src/runtime/os.h b/src/runtime/os.h index 1d8e436..9dd1649 100644 --- a/src/runtime/os.h +++ b/src/runtime/os.h @@ -17,6 +17,7 @@ #define _OS_H_INCLUDED_ +#include "sbcl.h" #include "runtime.h" /* Some standard preprocessor definitions and typedefs are needed from @@ -28,11 +29,6 @@ * os_vm_prot_t * type used for flags for mmap, mprotect, etc. * - * OS_VM_DEFAULT_PAGESIZE - * used by core dumping and loading logic (but dunno its exact - * definition, in particular why we can't just use getpagesize() - * instead) - * * os_vm_address_t * the type used to represent addresses? (dunno why not just void*) * os_vm_size_t, os_vm_off_t @@ -41,24 +37,20 @@ * the type used to represent context in a POSIX sigaction SA_SIGACTION * handler, i.e. the actual type of the thing pointed to by the * void* third argument of a handler */ -#if defined __FreeBSD__ -#include "bsd-os.h" -#elif defined __OpenBSD__ -#include "bsd-os.h" -#elif defined __linux__ -#include "linux-os.h" -#else -#error unsupported OS -#endif + +#include "target-os.h" + #define OS_VM_PROT_ALL \ (OS_VM_PROT_READ | OS_VM_PROT_WRITE | OS_VM_PROT_EXECUTE) +#define OS_VM_PROT_NONE 0 + extern os_vm_size_t os_vm_page_size; /* Do anything we need to do when starting up the runtime environment * in this OS. */ -extern void os_init(void); +extern void os_init(char *argv[], char *envp[]); /* Install any OS-dependent low-level signal handlers which are needed * by the runtime environment. E.g. the signals raised by a violation @@ -89,9 +81,9 @@ extern void os_invalidate(os_vm_address_t addr, os_vm_size_t len); /* This maps a file into memory, or calls lose(..) for various * failures. */ extern os_vm_address_t os_map(int fd, - int offset, - os_vm_address_t addr, - os_vm_size_t len); + int offset, + os_vm_address_t addr, + os_vm_size_t len); /* This presumably flushes the instruction cache, if that can be done * explicitly. (It doesn't seem to be an issue for the i386 port, @@ -103,8 +95,8 @@ extern void os_flush_icache(os_vm_address_t addr, os_vm_size_t len); * write-protecting a page so that the garbage collector can find out * whether it's modified by handling the signal. */ extern void os_protect(os_vm_address_t addr, - os_vm_size_t len, - os_vm_prot_t protection); + os_vm_size_t len, + os_vm_prot_t protection); /* This returns true for an address which makes sense at the Lisp level. */ extern boolean is_valid_lisp_addr(os_vm_address_t test); @@ -113,16 +105,33 @@ extern boolean is_valid_lisp_addr(os_vm_address_t test); * register, of the specified offset, for that context. The offset is * defined in the storage class (SC) defined in the Lisp virtual * machine (i.e. the file "vm.lisp" for the appropriate architecture). */ -int *os_context_register_addr(os_context_t *context, int offset); +os_context_register_t * +os_context_register_addr(os_context_t *context, int offset); + +/* FIXME: Pending investigation, this #ifdef stays as alpha. If it + * turns out that the alpha truly requires this, it can change to + * ARCH_HAS_FLOAT_REGISTERS (currently #defined in alpha-arch.h -- CSR + * 2002-02-04 */ +#ifdef LISP_FEATURE_ALPHA +os_context_register_t * +os_context_float_register_addr(os_context_t *context, int offset); +#endif /* Given a signal context, return the address for storage of the * program counter for that context. */ -int *os_context_pc_addr(os_context_t *context); +os_context_register_t *os_context_pc_addr(os_context_t *context); +#ifdef ARCH_HAS_NPC_REGISTER +os_context_register_t *os_context_npc_addr(os_context_t *context); +#endif +#ifdef ARCH_HAS_LINK_REGISTER +os_context_register_t *os_context_lr_addr(os_context_t *context); +#endif /* Given a signal context, return the address for storage of the * system stack pointer for that context. */ -int *os_context_sp_addr(os_context_t *context); - +#ifdef ARCH_HAS_STACK_POINTER +os_context_register_t *os_context_sp_addr(os_context_t *context); +#endif /* Given a signal context, return the address for storage of the * signal mask for that context. */ sigset_t *os_context_sigmask_addr(os_context_t *context); @@ -131,21 +140,14 @@ sigset_t *os_context_sigmask_addr(os_context_t *context); * depend not only on the OS, but also on the architecture, e.g. * getting at EFL/EFLAGS on the x86. Such things are defined in the * architecture-dependence files, not the OS-dependence files.) */ - + /* These are not architecture-specific functions, but are instead * general utilities defined in terms of the architecture-specific * function os_validate(..) and os_invalidate(..). - * - * FIXME: os_reallocate(..) is complicated and seems no longer to be - * used for anything. Perhaps we could delete it? */ + */ extern os_vm_address_t os_allocate(os_vm_size_t len); -extern os_vm_address_t os_allocate_at(os_vm_address_t addr, os_vm_size_t len); -extern os_vm_address_t os_reallocate(os_vm_address_t addr, - os_vm_size_t old_len, - os_vm_size_t len); extern void os_deallocate(os_vm_address_t addr, os_vm_size_t len); - /* FIXME: The os_trunc_foo(..) and os_round_foo(..) macros here could * be functions. */ @@ -170,4 +172,38 @@ extern void os_deallocate(os_vm_address_t addr, os_vm_size_t len); * to return the value in a way that Lisp can understand. */ int os_get_errno(void); +/* Return an absolute path to the runtime executable, or NULL if this + * information is unavailable. Unless external_path is non-zero the + * returned path may only be valid for the current process, ie: + * something like /proc/curproc/file. If a non-null pathname is + * returned, it must be 'free'd. */ +extern char *os_get_runtime_executable_path(int external_path); + +/* Write platforms specific ones when necessary. This is to get us off + * the ground. */ +#if N_WORD_BITS == 32 +# define OS_VM_SIZE_FMT "u" +# define OS_VM_SIZE_FMTX "x" +#else +# define OS_VM_SIZE_FMT "lu" +# define OS_VM_SIZE_FMTX "lx" +#endif + +/* FIXME: this is not the right place for this, but here we have + * a convenient base type to hand. If it turns out we can just use + * size_t everywhere, this can more to runtime.h. */ +typedef os_vm_size_t word_t; +#define WORD_FMTX OS_VM_SIZE_FMTX + +#ifdef LISP_FEATURE_SB_THREAD +# ifndef CANNOT_USE_POSIX_SEM_T +# include + typedef sem_t os_sem_t; +# endif + void os_sem_init(os_sem_t *sem, unsigned int value); + void os_sem_wait(os_sem_t *sem, char *what); + void os_sem_post(os_sem_t *sem, char *what); + void os_sem_destroy(os_sem_t *sem); +#endif + #endif