aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-01-05 13:58:48 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-01-05 13:58:48 -0800
commit4df57fda09c04f71a595154ca6962a95666b3685 (patch)
treef49faae476f3f419df44e4da11690ee8e94f7705 /common.cpp
parent6f45832aed0136e9f891da8eaa754c2b7f378848 (diff)
Incorporate Siteshwar's patch for building on Linux
Diffstat (limited to 'common.cpp')
-rw-r--r--common.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/common.cpp b/common.cpp
index 4b6c33c5..fb97b178 100644
--- a/common.cpp
+++ b/common.cpp
@@ -97,6 +97,8 @@ parts of fish.
struct termios shell_modes;
+static pthread_t main_thread_id = 0;
+
wchar_t ellipsis_char;
char *profile=0;
@@ -494,7 +496,7 @@ wchar_t *wcsvarname( const wchar_t *str )
return 0;
}
-wchar_t *wcsfuncname( const wchar_t *str )
+const wchar_t *wcsfuncname( const wchar_t *str )
{
return wcschr( str, L'/' );
}
@@ -1943,9 +1945,19 @@ extern "C" {
__attribute__((noinline)) void debug_thread_error(void) {}
}
+
+void set_main_thread() {
+ main_thread_id = pthread_self();
+}
+
+static bool is_main_thread() {
+ assert (main_thread_id != 0);
+ return main_thread_id == pthread_self();
+}
+
void assert_is_main_thread(const char *who)
{
- if (! pthread_main_np()) {
+ if (! is_main_thread()) {
fprintf(stderr, "Warning: %s called off of main thread. Break on debug_thread_error to debug.\n", who);
debug_thread_error();
}
@@ -1953,7 +1965,7 @@ void assert_is_main_thread(const char *who)
void assert_is_background_thread(const char *who)
{
- if (pthread_main_np()) {
+ if (is_main_thread()) {
fprintf(stderr, "Warning: %s called on the main thread (may block!). Break on debug_thread_error to debug.\n", who);
debug_thread_error();
}