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

Side by Side Diff: lib/Support/CrashRecoveryContext.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 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
« no previous file with comments | « lib/Makefile ('k') | lib/Support/LockFileManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- CrashRecoveryContext.cpp - Crash Recovery ------------------------===// 1 //===--- CrashRecoveryContext.cpp - Crash Recovery ------------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 9
10 #include "llvm/Support/CrashRecoveryContext.h" 10 #include "llvm/Support/CrashRecoveryContext.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 271
272 void CrashRecoveryContext::Enable() { 272 void CrashRecoveryContext::Enable() {
273 sys::ScopedLock L(*gCrashRecoveryContextMutex); 273 sys::ScopedLock L(*gCrashRecoveryContextMutex);
274 274
275 if (gCrashRecoveryEnabled) 275 if (gCrashRecoveryEnabled)
276 return; 276 return;
277 277
278 gCrashRecoveryEnabled = true; 278 gCrashRecoveryEnabled = true;
279 279
280 #if !defined(__native_client__) // @LOCALMOD
280 // Setup the signal handler. 281 // Setup the signal handler.
281 struct sigaction Handler; 282 struct sigaction Handler;
282 Handler.sa_handler = CrashRecoverySignalHandler; 283 Handler.sa_handler = CrashRecoverySignalHandler;
283 Handler.sa_flags = 0; 284 Handler.sa_flags = 0;
284 sigemptyset(&Handler.sa_mask); 285 sigemptyset(&Handler.sa_mask);
285 286
286 for (unsigned i = 0; i != NumSignals; ++i) { 287 for (unsigned i = 0; i != NumSignals; ++i) {
287 sigaction(Signals[i], &Handler, &PrevActions[i]); 288 sigaction(Signals[i], &Handler, &PrevActions[i]);
288 } 289 }
290 // @LOCALMOD-START
291 #else
292 #warning Cannot setup the signal handler on this machine
293 #endif
294 // @LOCALMOD-END
289 } 295 }
290 296
291 void CrashRecoveryContext::Disable() { 297 void CrashRecoveryContext::Disable() {
292 sys::ScopedLock L(*gCrashRecoveryContextMutex); 298 sys::ScopedLock L(*gCrashRecoveryContextMutex);
293 299
294 if (!gCrashRecoveryEnabled) 300 if (!gCrashRecoveryEnabled)
295 return; 301 return;
296 302
297 gCrashRecoveryEnabled = false; 303 gCrashRecoveryEnabled = false;
298 304
305 #if !defined(__native_client__) // @LOCALMOD
299 // Restore the previous signal handlers. 306 // Restore the previous signal handlers.
300 for (unsigned i = 0; i != NumSignals; ++i) 307 for (unsigned i = 0; i != NumSignals; ++i)
301 sigaction(Signals[i], &PrevActions[i], nullptr); 308 sigaction(Signals[i], &PrevActions[i], nullptr);
309 #endif // @LOCALMOD
302 } 310 }
303 311
304 #endif 312 #endif
305 313
306 bool CrashRecoveryContext::RunSafely(function_ref<void()> Fn) { 314 bool CrashRecoveryContext::RunSafely(function_ref<void()> Fn) {
307 // If crash recovery is disabled, do nothing. 315 // If crash recovery is disabled, do nothing.
308 if (gCrashRecoveryEnabled) { 316 if (gCrashRecoveryEnabled) {
309 assert(!Impl && "Crash recovery context already initialized!"); 317 assert(!Impl && "Crash recovery context already initialized!");
310 CrashRecoveryContextImpl *CRCI = new CrashRecoveryContextImpl(this); 318 CrashRecoveryContextImpl *CRCI = new CrashRecoveryContextImpl(this);
311 Impl = CRCI; 319 Impl = CRCI;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 375 }
368 bool CrashRecoveryContext::RunSafelyOnThread(function_ref<void()> Fn, 376 bool CrashRecoveryContext::RunSafelyOnThread(function_ref<void()> Fn,
369 unsigned RequestedStackSize) { 377 unsigned RequestedStackSize) {
370 bool UseBackgroundPriority = hasThreadBackgroundPriority(); 378 bool UseBackgroundPriority = hasThreadBackgroundPriority();
371 RunSafelyOnThreadInfo Info = { Fn, this, UseBackgroundPriority, false }; 379 RunSafelyOnThreadInfo Info = { Fn, this, UseBackgroundPriority, false };
372 llvm_execute_on_thread(RunSafelyOnThread_Dispatch, &Info, RequestedStackSize); 380 llvm_execute_on_thread(RunSafelyOnThread_Dispatch, &Info, RequestedStackSize);
373 if (CrashRecoveryContextImpl *CRC = (CrashRecoveryContextImpl *)Impl) 381 if (CrashRecoveryContextImpl *CRC = (CrashRecoveryContextImpl *)Impl)
374 CRC->setSwitchedThread(); 382 CRC->setSwitchedThread();
375 return Info.Result; 383 return Info.Result;
376 } 384 }
OLDNEW
« no previous file with comments | « lib/Makefile ('k') | lib/Support/LockFileManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698