diff --git a/vm/errors.h b/vm/errors.h index cbb8bed016..14e755a095 100755 --- a/vm/errors.h +++ b/vm/errors.h @@ -47,3 +47,7 @@ user-space */ CELL signal_number; CELL signal_fault_addr; void *signal_callstack_top; + +void memory_signal_handler_impl(void); +void divide_by_zero_signal_handler_impl(void); +void misc_signal_handler_impl(void); diff --git a/vm/os-unix.h b/vm/os-unix.h index f5dcf8dda5..cbce7de985 100755 --- a/vm/os-unix.h +++ b/vm/os-unix.h @@ -39,6 +39,3 @@ s64 current_millis(void); void sleep_millis(CELL msec); void reset_stdio(void); - -void memory_signal_handler_impl(void); -void misc_signal_handler_impl(void); diff --git a/vm/os-windows-ce.c b/vm/os-windows-ce.c index e6ef8b1108..1465e0c89f 100755 --- a/vm/os-windows-ce.c +++ b/vm/os-windows-ce.c @@ -37,6 +37,11 @@ char *getenv(char *name) return 0; /* unreachable */ } +DEFINE_PRIMITIVE(os_envs) +{ + not_implemented_error(); +} + void c_to_factor_toplevel(CELL quot) { c_to_factor(quot); diff --git a/vm/os-windows-nt.c b/vm/os-windows-nt.c old mode 100644 new mode 100755 index 9a54b895b8..baa0a06c4b --- a/vm/os-windows-nt.c +++ b/vm/os-windows-nt.c @@ -23,6 +23,35 @@ DEFINE_PRIMITIVE(cd) SetCurrentDirectory(unbox_u16_string()); } +DEFINE_PRIMITIVE(os_envs) +{ + GROWABLE_ARRAY(result); + + TCHAR *env = GetEnvironmentStrings(); + TCHAR *finger = env; + + for(;;) + { + TCHAR *scan = finger; + while(*scan != '\0') + scan++; + if(scan == finger) + break; + + REGISTER_UNTAGGED(result); + CELL string = tag_object(from_u16_string(finger)); + UNREGISTER_UNTAGGED(result); + GROWABLE_ADD(result,string); + + finger = scan + 1; + } + + FreeEnvironmentStrings(env); + + GROWABLE_TRIM(result); + dpush(tag_object(result)); +} + long exception_handler(PEXCEPTION_POINTERS pe) { PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord; diff --git a/vm/os-windows-nt.h b/vm/os-windows-nt.h index 452e42448b..f7c56c129d 100755 --- a/vm/os-windows-nt.h +++ b/vm/os-windows-nt.h @@ -17,9 +17,4 @@ typedef char F_SYMBOL; #define FACTOR_DLL_NAME "factor-nt.dll" void c_to_factor_toplevel(CELL quot); - -void memory_signal_handler_impl(void); -void divide_by_zero_signal_handler_impl(void); -void misc_signal_handler_impl(void); - long exception_handler(PEXCEPTION_POINTERS pe); diff --git a/vm/os-windows.c b/vm/os-windows.c index 1c07fd09cd..aa0e0ed8c1 100755 --- a/vm/os-windows.c +++ b/vm/os-windows.c @@ -207,8 +207,3 @@ void sleep_millis(DWORD msec) { Sleep(msec); } - -DEFINE_PRIMITIVE(os_envs) -{ - not_implemented_error(); -}