| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
| 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #if OS(LINUX) | 52 #if OS(LINUX) |
| 53 #include <sys/syscall.h> | 53 #include <sys/syscall.h> |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 #if OS(LINUX) || OS(ANDROID) | 56 #if OS(LINUX) || OS(ANDROID) |
| 57 #include <unistd.h> | 57 #include <unistd.h> |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 namespace WTF { | 60 namespace WTF { |
| 61 | 61 |
| 62 static Mutex* atomicallyInitializedStaticMutex; | |
| 63 | |
| 64 void initializeThreading() | 62 void initializeThreading() |
| 65 { | 63 { |
| 66 // This should only be called once. | 64 //wtfThreadData(); |
| 67 ASSERT(!atomicallyInitializedStaticMutex); | |
| 68 | |
| 69 // StringImpl::empty() does not construct its static string in a threadsafe
fashion, | |
| 70 // so ensure it has been initialized from here. | |
| 71 StringImpl::empty(); | |
| 72 StringImpl::empty16Bit(); | |
| 73 atomicallyInitializedStaticMutex = new Mutex; | |
| 74 wtfThreadData(); | |
| 75 initializeDates(); | |
| 76 // Force initialization of static DoubleToStringConverter converter variable | |
| 77 // inside EcmaScriptConverter function while we are in single thread mode. | |
| 78 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); | |
| 79 } | 65 } |
| 80 | 66 |
| 81 void lockAtomicallyInitializedStaticMutex() | 67 void lockAtomicallyInitializedStaticMutex() |
| 82 { | 68 { |
| 83 ASSERT(atomicallyInitializedStaticMutex); | |
| 84 atomicallyInitializedStaticMutex->lock(); | |
| 85 } | 69 } |
| 86 | 70 |
| 87 void unlockAtomicallyInitializedStaticMutex() | 71 void unlockAtomicallyInitializedStaticMutex() |
| 88 { | 72 { |
| 89 atomicallyInitializedStaticMutex->unlock(); | |
| 90 } | 73 } |
| 91 | 74 |
| 92 ThreadIdentifier currentThread() | 75 ThreadIdentifier currentThread() |
| 93 { | 76 { |
| 94 #if OS(MACOSX) | 77 #if OS(MACOSX) |
| 95 return pthread_mach_thread_np(pthread_self()); | 78 return pthread_mach_thread_np(pthread_self()); |
| 96 #elif OS(LINUX) | 79 #elif OS(LINUX) |
| 97 return syscall(__NR_gettid); | 80 return syscall(__NR_gettid); |
| 98 #elif OS(ANDROID) | 81 #elif OS(ANDROID) |
| 99 return gettid(); | 82 return gettid(); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 237 |
| 255 void willCreateThread() | 238 void willCreateThread() |
| 256 { | 239 { |
| 257 s_threadCreated = true; | 240 s_threadCreated = true; |
| 258 } | 241 } |
| 259 #endif | 242 #endif |
| 260 | 243 |
| 261 } // namespace WTF | 244 } // namespace WTF |
| 262 | 245 |
| 263 #endif // OS(POSIX) | 246 #endif // OS(POSIX) |
| OLD | NEW |