diff --git a/vm/os-freebsd.h b/vm/os-freebsd.h index 5cedbc82b7..c535e2d71f 100644 --- a/vm/os-freebsd.h +++ b/vm/os-freebsd.h @@ -10,7 +10,3 @@ extern int getosreldate(void); #define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN) #define DIRECTORY_P(file) ((file)->d_type == DT_DIR) - -#ifndef environ - extern char **environ; -#endif diff --git a/vm/os-linux.h b/vm/os-linux.h index 1a1e088359..78ecbafd35 100644 --- a/vm/os-linux.h +++ b/vm/os-linux.h @@ -3,10 +3,6 @@ #define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN) #define DIRECTORY_P(file) ((file)->d_type == DT_DIR) -#ifndef environ - extern char **environ; -#endif - int inotify_init(void); int inotify_add_watch(int fd, const char *name, u32 mask); int inotify_rm_watch(int fd, u32 wd); diff --git a/vm/os-macosx.h b/vm/os-macosx.h index 701bb8da01..b9686a5a85 100644 --- a/vm/os-macosx.h +++ b/vm/os-macosx.h @@ -12,11 +12,6 @@ const char *default_image_path(void); DLLEXPORT void c_to_factor_toplevel(CELL quot); -#ifndef environ - extern char ***_NSGetEnviron(void); - #define environ (*_NSGetEnviron()) -#endif - INLINE void *ucontext_stack_pointer(void *uap) { ucontext_t *ucontext = (ucontext_t *)uap; diff --git a/vm/os-netbsd.h b/vm/os-netbsd.h index b42c6b9d7e..54b5d0bcff 100644 --- a/vm/os-netbsd.h +++ b/vm/os-netbsd.h @@ -4,5 +4,3 @@ #define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN) #define DIRECTORY_P(file) ((file)->d_type == DT_DIR) - -extern char **environ; diff --git a/vm/os-openbsd.h b/vm/os-openbsd.h index 21e34c98f8..af47f7bcea 100644 --- a/vm/os-openbsd.h +++ b/vm/os-openbsd.h @@ -1,6 +1,2 @@ #define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN) #define DIRECTORY_P(file) ((file)->d_type == DT_DIR) - -#ifndef environ - extern char **environ; -#endif diff --git a/vm/os-solaris.h b/vm/os-solaris.h index 909cc3f4e9..788a78090b 100644 --- a/vm/os-solaris.h +++ b/vm/os-solaris.h @@ -1,4 +1,2 @@ #define UNKNOWN_TYPE_P(file) 1 #define DIRECTORY_P(file) 0 - -extern char **environ; diff --git a/vm/os-unix.c b/vm/os-unix.c index d4aebad537..fa2d5bb40c 100755 --- a/vm/os-unix.c +++ b/vm/os-unix.c @@ -99,72 +99,6 @@ DEFINE_PRIMITIVE(read_dir) dpush(result); } -DEFINE_PRIMITIVE(os_env) -{ - char *name = unbox_char_string(); - char *value = getenv(name); - if(value == NULL) - dpush(F); - else - box_char_string(value); -} - -DEFINE_PRIMITIVE(os_envs) -{ - GROWABLE_ARRAY(result); - REGISTER_ROOT(result); - char **env = environ; - - while(*env) - { - CELL string = tag_object(from_char_string(*env)); - GROWABLE_ARRAY_ADD(result,string); - env++; - } - - UNREGISTER_ROOT(result); - GROWABLE_ARRAY_TRIM(result); - dpush(result); -} - -DEFINE_PRIMITIVE(set_os_env) -{ - char *key = unbox_char_string(); - REGISTER_C_STRING(key); - char *value = unbox_char_string(); - UNREGISTER_C_STRING(key); - setenv(key, value, 1); -} - -DEFINE_PRIMITIVE(unset_os_env) -{ - char *key = unbox_char_string(); - unsetenv(key); -} - -DEFINE_PRIMITIVE(set_os_envs) -{ - F_ARRAY *array = untag_array(dpop()); - CELL size = array_capacity(array); - - /* Memory leak */ - char **env = calloc(size + 1,sizeof(CELL)); - - CELL i; - for(i = 0; i < size; i++) - { - F_STRING *string = untag_string(array_nth(array,i)); - CELL length = to_fixnum(string->length); - - char *chars = malloc(length + 1); - char_string_to_memory(string,chars); - chars[length] = '\0'; - env[i] = chars; - } - - environ = env; -} - F_SEGMENT *alloc_segment(CELL size) { int pagesize = getpagesize(); diff --git a/vm/os-windows.c b/vm/os-windows.c index 4c21c9b5c9..c36ba59a27 100755 --- a/vm/os-windows.c +++ b/vm/os-windows.c @@ -214,38 +214,3 @@ void sleep_millis(DWORD msec) { Sleep(msec); } - -DEFINE_PRIMITIVE(os_env) -{ - F_CHAR *key = unbox_u16_string(); - F_CHAR *value = safe_malloc(MAX_UNICODE_PATH * 2); - int ret; - ret = GetEnvironmentVariable(key, value, MAX_UNICODE_PATH * 2); - if(ret == 0) - dpush(F); - else - dpush(tag_object(from_u16_string(value))); - free(value); -} - -DEFINE_PRIMITIVE(set_os_env) -{ - F_CHAR *key = unbox_u16_string(); - REGISTER_C_STRING(key); - F_CHAR *value = unbox_u16_string(); - UNREGISTER_C_STRING(key); - if(!SetEnvironmentVariable(key, value)) - general_error(ERROR_IO, tag_object(get_error_message()), F, NULL); -} - -DEFINE_PRIMITIVE(unset_os_env) -{ - if(!SetEnvironmentVariable(unbox_u16_string(), NULL) - && GetLastError() != ERROR_ENVVAR_NOT_FOUND) - general_error(ERROR_IO, tag_object(get_error_message()), F, NULL); -} - -DEFINE_PRIMITIVE(set_os_envs) -{ - not_implemented_error(); -} diff --git a/vm/primitives.c b/vm/primitives.c index b5d9403342..39dc2b10d7 100755 --- a/vm/primitives.c +++ b/vm/primitives.c @@ -71,7 +71,6 @@ void *primitives[] = { primitive_exit, primitive_data_room, primitive_code_room, - primitive_os_env, primitive_millis, primitive_modify_code_heap, primitive_dlopen, @@ -141,10 +140,6 @@ void *primitives[] = { primitive_innermost_stack_frame_scan, primitive_set_innermost_stack_frame_quot, primitive_call_clear, - primitive_os_envs, - primitive_set_os_env, - primitive_unset_os_env, - primitive_set_os_envs, primitive_resize_byte_array, primitive_dll_validp, primitive_unimplemented,