X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fos.h;h=50ff643fd2f536b0a7d7b1f75c3be76528fe8da8;hb=5f0bd05a15aaf93f46baf9b8aa3e9b0bfbca26ab;hp=584af23add22127cc3623648c13062954ed0cff5;hpb=079ef9dad558ca07cb8178ef428bf738112174fa;p=sbcl.git diff --git a/src/runtime/os.h b/src/runtime/os.h index 584af23..50ff643 100644 --- a/src/runtime/os.h +++ b/src/runtime/os.h @@ -50,7 +50,7 @@ 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 @@ -75,15 +75,19 @@ extern void os_zero(os_vm_address_t addr, os_vm_size_t length); * "hp-ux.c" in the old CMU CL code. Perhaps move/merge it in here. */ extern os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len); +#ifdef LISP_FEATURE_WIN32 +void* os_validate_recommit(os_vm_address_t addr, os_vm_size_t len); +#endif + /* This function seems to undo the effect of os_validate(..). */ 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, @@ -95,8 +99,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); @@ -112,7 +116,7 @@ os_context_register_addr(os_context_t *context, int offset); * 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 alpha +#ifdef LISP_FEATURE_ALPHA os_context_register_t * os_context_float_register_addr(os_context_t *context, int offset); #endif @@ -140,31 +144,24 @@ 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. */ #define os_trunc_to_page(addr) \ - (os_vm_address_t)(((long)(addr))&~(os_vm_page_size-1)) + (os_vm_address_t)(((uword_t)(addr))&~(os_vm_page_size-1)) #define os_round_up_to_page(addr) \ os_trunc_to_page((addr)+(os_vm_page_size-1)) #define os_trunc_size_to_page(size) \ - (os_vm_size_t)(((long)(size))&~(os_vm_page_size-1)) + (os_vm_size_t)(((uword_t)(size))&~(os_vm_page_size-1)) #define os_round_up_size_to_page(size) \ os_trunc_size_to_page((size)+(os_vm_page_size-1)) @@ -179,4 +176,43 @@ 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 +#if defined(LISP_FEATURE_SB_WIN32) +# define OS_VM_SIZE_FMT "Iu" +# define OS_VM_SIZE_FMTX "Ix" +#else +# define OS_VM_SIZE_FMT "lu" +# define OS_VM_SIZE_FMTX "lx" +#endif +#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