comparison libstdc++-v3/libsupc++/eh_terminate.cc @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 // -*- C++ -*- std::terminate, std::unexpected and friends. 1 // -*- C++ -*- std::terminate, std::unexpected and friends.
2 // Copyright (C) 1994-2018 Free Software Foundation, Inc. 2 // Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 // 3 //
4 // This file is part of GCC. 4 // This file is part of GCC.
5 // 5 //
6 // GCC is free software; you can redistribute it and/or modify 6 // GCC is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by 7 // it under the terms of the GNU General Public License as published by
24 24
25 #include "typeinfo" 25 #include "typeinfo"
26 #include "exception" 26 #include "exception"
27 #include <cstdlib> 27 #include <cstdlib>
28 #include "unwind-cxx.h" 28 #include "unwind-cxx.h"
29 #include "eh_term_handler.h"
29 #include <bits/exception_defines.h> 30 #include <bits/exception_defines.h>
30 #include <bits/atomic_lockfree_defines.h> 31 #include <bits/atomic_lockfree_defines.h>
31 32
32 #if ATOMIC_POINTER_LOCK_FREE < 2 33 #if ATOMIC_POINTER_LOCK_FREE < 2
33 #include <ext/concurrence.h> 34 #include <ext/concurrence.h>
71 } 72 }
72 73
73 std::terminate_handler 74 std::terminate_handler
74 std::set_terminate (std::terminate_handler func) throw() 75 std::set_terminate (std::terminate_handler func) throw()
75 { 76 {
77 if (!func)
78 func = _GLIBCXX_DEFAULT_TERM_HANDLER;
79
76 std::terminate_handler old; 80 std::terminate_handler old;
77 #if ATOMIC_POINTER_LOCK_FREE > 1 81 #if ATOMIC_POINTER_LOCK_FREE > 1
78 __atomic_exchange (&__terminate_handler, &func, &old, __ATOMIC_ACQ_REL); 82 __atomic_exchange (&__terminate_handler, &func, &old, __ATOMIC_ACQ_REL);
79 #else 83 #else
80 __gnu_cxx::__scoped_lock l(mx); 84 __gnu_cxx::__scoped_lock l(mx);
98 } 102 }
99 103
100 std::unexpected_handler 104 std::unexpected_handler
101 std::set_unexpected (std::unexpected_handler func) throw() 105 std::set_unexpected (std::unexpected_handler func) throw()
102 { 106 {
107 if (!func)
108 func = std::terminate;
109
103 std::unexpected_handler old; 110 std::unexpected_handler old;
104 #if ATOMIC_POINTER_LOCK_FREE > 1 111 #if ATOMIC_POINTER_LOCK_FREE > 1
105 __atomic_exchange (&__unexpected_handler, &func, &old, __ATOMIC_ACQ_REL); 112 __atomic_exchange (&__unexpected_handler, &func, &old, __ATOMIC_ACQ_REL);
106 #else 113 #else
107 __gnu_cxx::__scoped_lock l(mx); 114 __gnu_cxx::__scoped_lock l(mx);