diff options
Diffstat (limited to 'drivers/unix')
| -rw-r--r-- | drivers/unix/SCsub | 2 | ||||
| -rw-r--r-- | drivers/unix/dir_access_unix.cpp | 14 | ||||
| -rw-r--r-- | drivers/unix/dir_access_unix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/file_access_unix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/file_access_unix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/ip_unix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/ip_unix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/mutex_posix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/mutex_posix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/os_unix.cpp | 6 | ||||
| -rw-r--r-- | drivers/unix/os_unix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/packet_peer_udp_posix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/packet_peer_udp_posix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/rw_lock_posix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/rw_lock_posix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/semaphore_posix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/semaphore_posix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/socket_helpers.h | 2 | ||||
| -rw-r--r-- | drivers/unix/stream_peer_tcp_posix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/stream_peer_tcp_posix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/tcp_server_posix.cpp | 2 | ||||
| -rw-r--r-- | drivers/unix/tcp_server_posix.h | 2 | ||||
| -rw-r--r-- | drivers/unix/thread_posix.cpp | 17 | ||||
| -rw-r--r-- | drivers/unix/thread_posix.h | 5 |
24 files changed, 43 insertions, 39 deletions
diff --git a/drivers/unix/SCsub b/drivers/unix/SCsub index 96efc91b7..5ced44dfd 100644 --- a/drivers/unix/SCsub +++ b/drivers/unix/SCsub @@ -8,7 +8,7 @@ g_set_p += 'String OS_Unix::get_global_settings_path() const {\n' g_set_p += '\treturn "' + env["unix_global_settings_path"] + '";\n' g_set_p += '}\n' g_set_p += '#endif' -f = open("os_unix_global_settings_path.gen.cpp", "wb") +f = open("os_unix_global_settings_path.gen.cpp", "w") f.write(g_set_p) f.close() diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index cf54f3fea..ddc3b2ed3 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -194,21 +194,9 @@ Error DirAccessUnix::make_dir(String p_dir) { p_dir = fix_path(p_dir); -#if 1 - - bool success = (mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0); - int err = errno; - -#else - char real_current_dir_name[2048]; - getcwd(real_current_dir_name, 2048); - chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants - bool success = (mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0); int err = errno; - chdir(real_current_dir_name); -#endif if (success) { return OK; }; diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index e4b294a80..ea0df2fa3 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index e2f04aec6..d5a66d9a1 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h index 3c4b9c0c2..6e5110431 100644 --- a/drivers/unix/file_access_unix.h +++ b/drivers/unix/file_access_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index f55b75c1d..77c942c67 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/ip_unix.h b/drivers/unix/ip_unix.h index 952d3a877..1f3b88563 100644 --- a/drivers/unix/ip_unix.h +++ b/drivers/unix/ip_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/mutex_posix.cpp b/drivers/unix/mutex_posix.cpp index 94cfcf78e..c8fe9e074 100644 --- a/drivers/unix/mutex_posix.cpp +++ b/drivers/unix/mutex_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/mutex_posix.h b/drivers/unix/mutex_posix.h index b3c0cbe05..20d546c72 100644 --- a/drivers/unix/mutex_posix.h +++ b/drivers/unix/mutex_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 0f4e8f757..75c8a153f 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -315,7 +315,9 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { void OS_Unix::delay_usec(uint32_t p_usec) const { - usleep(p_usec); + struct timespec rem = { p_usec / 1000000, (p_usec % 1000000) * 1000 }; + while (nanosleep(&rem, &rem) == EINTR) { + } } uint64_t OS_Unix::get_ticks_usec() const { diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 115bdc2d6..19e79728f 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index b21990a86..b743990b9 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/packet_peer_udp_posix.h b/drivers/unix/packet_peer_udp_posix.h index d8b08818b..e580d336b 100644 --- a/drivers/unix/packet_peer_udp_posix.h +++ b/drivers/unix/packet_peer_udp_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/rw_lock_posix.cpp b/drivers/unix/rw_lock_posix.cpp index 25bc8f0bd..ab2d6495b 100644 --- a/drivers/unix/rw_lock_posix.cpp +++ b/drivers/unix/rw_lock_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/rw_lock_posix.h b/drivers/unix/rw_lock_posix.h index f8199aeb5..40b41ce17 100644 --- a/drivers/unix/rw_lock_posix.h +++ b/drivers/unix/rw_lock_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/semaphore_posix.cpp b/drivers/unix/semaphore_posix.cpp index 8b553194d..093c6b663 100644 --- a/drivers/unix/semaphore_posix.cpp +++ b/drivers/unix/semaphore_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/semaphore_posix.h b/drivers/unix/semaphore_posix.h index c7a7f9bd8..e33de7854 100644 --- a/drivers/unix/semaphore_posix.h +++ b/drivers/unix/semaphore_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h index 5fa727a9b..3fc014429 100644 --- a/drivers/unix/socket_helpers.h +++ b/drivers/unix/socket_helpers.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 30843e494..3bc2397e6 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/stream_peer_tcp_posix.h b/drivers/unix/stream_peer_tcp_posix.h index 3f28f82b5..4c3504714 100644 --- a/drivers/unix/stream_peer_tcp_posix.h +++ b/drivers/unix/stream_peer_tcp_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp index a8554d07a..f3f9ab82f 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/tcp_server_posix.h b/drivers/unix/tcp_server_posix.h index 947050ab8..a10bafcaf 100644 --- a/drivers/unix/tcp_server_posix.h +++ b/drivers/unix/tcp_server_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index 3b895ff9c..590824692 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -36,8 +36,18 @@ #include <pthread_np.h> #endif +#include "core/safe_refcount.h" #include "os/memory.h" +static pthread_key_t _create_thread_id_key() { + pthread_key_t key; + pthread_key_create(&key, NULL); + return key; +} + +pthread_key_t ThreadPosix::thread_id_key = _create_thread_id_key(); +Thread::ID ThreadPosix::next_thread_id = 0; + Thread::ID ThreadPosix::get_id() const { return id; @@ -51,7 +61,8 @@ Thread *ThreadPosix::create_thread_posix() { void *ThreadPosix::thread_callback(void *userdata) { ThreadPosix *t = reinterpret_cast<ThreadPosix *>(userdata); - t->id = (ID)pthread_self(); + t->id = atomic_increment(&next_thread_id); + pthread_setspecific(thread_id_key, (void *)t->id); ScriptServer::thread_enter(); //scripts may need to attach a stack @@ -77,7 +88,7 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_ } Thread::ID ThreadPosix::get_thread_id_func_posix() { - return (ID)pthread_self(); + return (ID)pthread_getspecific(thread_id_key); } void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) { diff --git a/drivers/unix/thread_posix.h b/drivers/unix/thread_posix.h index 21e1d290a..d6a41ed11 100644 --- a/drivers/unix/thread_posix.h +++ b/drivers/unix/thread_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -42,6 +42,9 @@ class ThreadPosix : public Thread { + static pthread_key_t thread_id_key; + static ID next_thread_id; + pthread_t pthread; pthread_attr_t pthread_attr; ThreadCreateCallback callback; |
