simultaneous threads can cause a ruckus, but otherwise... OK.
uxenv.o:
- 00000010 b current_dir_path
- 0000000c b current_dir_path_size
- 00000000 b initial_process_clock
- 00000004 b initial_rtc
- 00000000 d utc_epoch_minus_unix_epoch
- 00000020 b zero_tx.8640
+ 00000010 b current_dir_path locked
+ 0000000c b current_dir_path_size locked
+ 00000000 b initial_process_clock read-only, initialize_process_clock
+ 00000004 b initial_rtc read-only, initialize_real_time_clock
+ 00000000 d utc_epoch_minus_unix_epoch read-only
+ 00000020 b zero_tx.8640 read-only
+
+ OK.
uxfile.o:
*/
-#include "scheme.h"
#include "prims.h"
#include "ux.h"
#include "osenv.h"
static size_t current_dir_path_size = 0;
static char * current_dir_path = 0;
+#ifdef ENABLE_SMP
+static pthread_mutex_t mutex = MUTEX_INITIALIZER;
+# ifdef ENABLE_DEBUGGING_TOOLS
+static bool locked_p = false;
+# endif
+#endif
+
const char *
OS_working_dir_pathname (void)
{
- if (current_dir_path) {
- return (current_dir_path);
- }
+ LOCK();
+ if (current_dir_path)
+ {
+ char *p = current_dir_path;
+ UNLOCK();
+ return (p);
+ }
if (current_dir_path_size == 0)
{
current_dir_path = (UX_malloc (1024));
if (current_dir_path == 0)
- error_system_call (ENOMEM, syscall_malloc);
+ {
+ UNLOCK();
+ error_system_call (ENOMEM, syscall_malloc);
+ }
current_dir_path_size = 1024;
}
while (1)
{
if ((UX_getcwd (current_dir_path, current_dir_path_size)) != 0)
- return (current_dir_path);
+ {
+ UNLOCK();
+ return (current_dir_path);
+ }
if (errno != ERANGE)
- error_system_call (errno, syscall_getcwd);
+ {
+ UNLOCK();
+ error_system_call (errno, syscall_getcwd);
+ }
current_dir_path_size *= 2;
{
char * new_current_dir_path =
if (new_current_dir_path == 0)
/* ANSI C requires `path' to be unchanged -- we may have to
discard it for systems that don't behave thus. */
- error_system_call (ENOMEM, syscall_realloc);
+ {
+ UNLOCK();
+ error_system_call (ENOMEM, syscall_realloc);
+ }
current_dir_path = new_current_dir_path;
}
}
OS_set_working_dir_pathname (const char * name)
{
size_t name_size = strlen (name);
+ LOCK();
STD_VOID_SYSTEM_CALL (syscall_chdir, (UX_chdir (name)));
while (1) {
if (name_size < current_dir_path_size) {
strcpy(current_dir_path, name);
+ UNLOCK();
return;
}
current_dir_path_size *= 2;
char * new_current_dir_path =
(UX_realloc (current_dir_path, current_dir_path_size));
if (new_current_dir_path == 0)
- error_system_call (ENOMEM, syscall_realloc);
+ {
+ UNLOCK();
+ error_system_call (ENOMEM, syscall_realloc);
+ }
current_dir_path = new_current_dir_path;
}
}