Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: src/platform/mutex.cc

Issue 23494047: Deuglify V8_INLINE and V8_NOINLINE. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform/mutex.h ('k') | src/platform/socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 16 matching lines...) Expand all
27 27
28 #include "platform/mutex.h" 28 #include "platform/mutex.h"
29 29
30 #include <cerrno> 30 #include <cerrno>
31 31
32 namespace v8 { 32 namespace v8 {
33 namespace internal { 33 namespace internal {
34 34
35 #if V8_OS_POSIX 35 #if V8_OS_POSIX
36 36
37 static V8_INLINE(void InitializeNativeHandle(pthread_mutex_t* mutex)) { 37 static V8_INLINE void InitializeNativeHandle(pthread_mutex_t* mutex) {
38 int result; 38 int result;
39 #if defined(DEBUG) 39 #if defined(DEBUG)
40 // Use an error checking mutex in debug mode. 40 // Use an error checking mutex in debug mode.
41 pthread_mutexattr_t attr; 41 pthread_mutexattr_t attr;
42 result = pthread_mutexattr_init(&attr); 42 result = pthread_mutexattr_init(&attr);
43 ASSERT_EQ(0, result); 43 ASSERT_EQ(0, result);
44 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 44 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
45 ASSERT_EQ(0, result); 45 ASSERT_EQ(0, result);
46 result = pthread_mutex_init(mutex, &attr); 46 result = pthread_mutex_init(mutex, &attr);
47 ASSERT_EQ(0, result); 47 ASSERT_EQ(0, result);
48 result = pthread_mutexattr_destroy(&attr); 48 result = pthread_mutexattr_destroy(&attr);
49 #else 49 #else
50 // Use a fast mutex (default attributes). 50 // Use a fast mutex (default attributes).
51 result = pthread_mutex_init(mutex, NULL); 51 result = pthread_mutex_init(mutex, NULL);
52 #endif // defined(DEBUG) 52 #endif // defined(DEBUG)
53 ASSERT_EQ(0, result); 53 ASSERT_EQ(0, result);
54 USE(result); 54 USE(result);
55 } 55 }
56 56
57 57
58 static V8_INLINE(void InitializeRecursiveNativeHandle(pthread_mutex_t* mutex)) { 58 static V8_INLINE void InitializeRecursiveNativeHandle(pthread_mutex_t* mutex) {
59 pthread_mutexattr_t attr; 59 pthread_mutexattr_t attr;
60 int result = pthread_mutexattr_init(&attr); 60 int result = pthread_mutexattr_init(&attr);
61 ASSERT_EQ(0, result); 61 ASSERT_EQ(0, result);
62 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 62 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
63 ASSERT_EQ(0, result); 63 ASSERT_EQ(0, result);
64 result = pthread_mutex_init(mutex, &attr); 64 result = pthread_mutex_init(mutex, &attr);
65 ASSERT_EQ(0, result); 65 ASSERT_EQ(0, result);
66 result = pthread_mutexattr_destroy(&attr); 66 result = pthread_mutexattr_destroy(&attr);
67 ASSERT_EQ(0, result); 67 ASSERT_EQ(0, result);
68 USE(result); 68 USE(result);
69 } 69 }
70 70
71 71
72 static V8_INLINE(void DestroyNativeHandle(pthread_mutex_t* mutex)) { 72 static V8_INLINE void DestroyNativeHandle(pthread_mutex_t* mutex) {
73 int result = pthread_mutex_destroy(mutex); 73 int result = pthread_mutex_destroy(mutex);
74 ASSERT_EQ(0, result); 74 ASSERT_EQ(0, result);
75 USE(result); 75 USE(result);
76 } 76 }
77 77
78 78
79 static V8_INLINE(void LockNativeHandle(pthread_mutex_t* mutex)) { 79 static V8_INLINE void LockNativeHandle(pthread_mutex_t* mutex) {
80 int result = pthread_mutex_lock(mutex); 80 int result = pthread_mutex_lock(mutex);
81 ASSERT_EQ(0, result); 81 ASSERT_EQ(0, result);
82 USE(result); 82 USE(result);
83 } 83 }
84 84
85 85
86 static V8_INLINE(void UnlockNativeHandle(pthread_mutex_t* mutex)) { 86 static V8_INLINE void UnlockNativeHandle(pthread_mutex_t* mutex) {
87 int result = pthread_mutex_unlock(mutex); 87 int result = pthread_mutex_unlock(mutex);
88 ASSERT_EQ(0, result); 88 ASSERT_EQ(0, result);
89 USE(result); 89 USE(result);
90 } 90 }
91 91
92 92
93 static V8_INLINE(bool TryLockNativeHandle(pthread_mutex_t* mutex)) { 93 static V8_INLINE bool TryLockNativeHandle(pthread_mutex_t* mutex) {
94 int result = pthread_mutex_trylock(mutex); 94 int result = pthread_mutex_trylock(mutex);
95 if (result == EBUSY) { 95 if (result == EBUSY) {
96 return false; 96 return false;
97 } 97 }
98 ASSERT_EQ(0, result); 98 ASSERT_EQ(0, result);
99 return true; 99 return true;
100 } 100 }
101 101
102 #elif V8_OS_WIN 102 #elif V8_OS_WIN
103 103
104 static V8_INLINE(void InitializeNativeHandle(PCRITICAL_SECTION cs)) { 104 static V8_INLINE void InitializeNativeHandle(PCRITICAL_SECTION cs) {
105 InitializeCriticalSection(cs); 105 InitializeCriticalSection(cs);
106 } 106 }
107 107
108 108
109 static V8_INLINE(void InitializeRecursiveNativeHandle(PCRITICAL_SECTION cs)) { 109 static V8_INLINE void InitializeRecursiveNativeHandle(PCRITICAL_SECTION cs) {
110 InitializeCriticalSection(cs); 110 InitializeCriticalSection(cs);
111 } 111 }
112 112
113 113
114 static V8_INLINE(void DestroyNativeHandle(PCRITICAL_SECTION cs)) { 114 static V8_INLINE void DestroyNativeHandle(PCRITICAL_SECTION cs) {
115 DeleteCriticalSection(cs); 115 DeleteCriticalSection(cs);
116 } 116 }
117 117
118 118
119 static V8_INLINE(void LockNativeHandle(PCRITICAL_SECTION cs)) { 119 static V8_INLINE void LockNativeHandle(PCRITICAL_SECTION cs) {
120 EnterCriticalSection(cs); 120 EnterCriticalSection(cs);
121 } 121 }
122 122
123 123
124 static V8_INLINE(void UnlockNativeHandle(PCRITICAL_SECTION cs)) { 124 static V8_INLINE void UnlockNativeHandle(PCRITICAL_SECTION cs) {
125 LeaveCriticalSection(cs); 125 LeaveCriticalSection(cs);
126 } 126 }
127 127
128 128
129 static V8_INLINE(bool TryLockNativeHandle(PCRITICAL_SECTION cs)) { 129 static V8_INLINE bool TryLockNativeHandle(PCRITICAL_SECTION cs) {
130 return TryEnterCriticalSection(cs); 130 return TryEnterCriticalSection(cs);
131 } 131 }
132 132
133 #endif // V8_OS_POSIX 133 #endif // V8_OS_POSIX
134 134
135 135
136 Mutex::Mutex() { 136 Mutex::Mutex() {
137 InitializeNativeHandle(&native_handle_); 137 InitializeNativeHandle(&native_handle_);
138 #ifdef DEBUG 138 #ifdef DEBUG
139 level_ = 0; 139 level_ = 0;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return false; 205 return false;
206 } 206 }
207 #ifdef DEBUG 207 #ifdef DEBUG
208 ASSERT_LE(0, level_); 208 ASSERT_LE(0, level_);
209 level_++; 209 level_++;
210 #endif 210 #endif
211 return true; 211 return true;
212 } 212 }
213 213
214 } } // namespace v8::internal 214 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform/mutex.h ('k') | src/platform/socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698