diff options
Diffstat (limited to 'drivers/unix')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 4 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.h | 2 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 5 | ||||
-rw-r--r-- | drivers/unix/os_unix.h | 1 | ||||
-rw-r--r-- | drivers/unix/thread_posix.cpp | 17 |
5 files changed, 26 insertions, 3 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 7284226ae7..e011176806 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -407,6 +407,10 @@ size_t DirAccessUnix::get_space_left() { #endif }; +String DirAccessUnix::get_filesystem_type() const { + return ""; //TODO this should be implemented +} + DirAccessUnix::DirAccessUnix() { dir_stream = 0; diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index 4da7e42b64..579cb0e798 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -82,6 +82,8 @@ public: virtual size_t get_space_left(); + virtual String get_filesystem_type() const; + DirAccessUnix(); ~DirAccessUnix(); }; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index ce1c183242..e3e2e10e82 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -469,6 +469,11 @@ String OS_Unix::get_environment(const String &p_var) const { return ""; } +bool OS_Unix::set_environment(const String &p_var, const String &p_value) const { + + return setenv(p_var.utf8().get_data(), p_value.utf8().get_data(), /* overwrite: */ true) == 0; +} + int OS_Unix::get_processor_count() const { return sysconf(_SC_NPROCESSORS_CONF); diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 2a23da6f28..09ab4aa1d8 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -95,6 +95,7 @@ public: virtual bool has_environment(const String &p_var) const; virtual String get_environment(const String &p_var) const; + virtual bool set_environment(const String &p_var, const String &p_value) const; virtual String get_locale() const; virtual int get_processor_count() const; diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index a81292d4a2..ef3f5fb49c 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -40,9 +40,13 @@ #include "core/os/memory.h" #include "core/safe_refcount.h" +static void _thread_id_key_destr_callback(void *p_value) { + memdelete(static_cast<Thread::ID *>(p_value)); +} + static pthread_key_t _create_thread_id_key() { pthread_key_t key; - pthread_key_create(&key, NULL); + pthread_key_create(&key, &_thread_id_key_destr_callback); return key; } @@ -63,7 +67,7 @@ void *ThreadPosix::thread_callback(void *userdata) { ThreadPosix *t = reinterpret_cast<ThreadPosix *>(userdata); t->id = atomic_increment(&next_thread_id); - pthread_setspecific(thread_id_key, (void *)t->id); + pthread_setspecific(thread_id_key, (void *)memnew(ID(t->id))); ScriptServer::thread_enter(); //scripts may need to attach a stack @@ -89,7 +93,14 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_ } Thread::ID ThreadPosix::get_thread_id_func_posix() { - return (ID)pthread_getspecific(thread_id_key); + void *value = pthread_getspecific(thread_id_key); + + if (value) + return *static_cast<ID *>(value); + + ID new_id = atomic_increment(&next_thread_id); + pthread_setspecific(thread_id_key, (void *)memnew(ID(new_id))); + return new_id; } void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) { |