ATLAS Offline Software
Control
CxxUtils
Root
ubsan_suppress.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3
*/
12
#include "
CxxUtils/ubsan_suppress.h
"
13
#include <unistd.h>
14
#include <fcntl.h>
15
#include <dlfcn.h>
16
17
18
namespace
CxxUtils
{
19
20
21
class
RedirStderr
22
{
23
public
:
24
RedirStderr
();
25
~RedirStderr
();
26
RedirStderr
(
const
RedirStderr
&) =
delete
;
27
RedirStderr
&
operator=
(
const
RedirStderr
&) =
delete
;
28
29
private
:
30
int
m_nullfd
;
31
int
m_stderr
;
32
};
33
34
35
// Redirect stderr to /dev/null, remembering the original FD.
36
RedirStderr::RedirStderr
()
37
{
38
m_nullfd
=
open
(
"/dev/null"
, O_WRONLY);
39
m_stderr
= dup (2);
40
if
(
m_nullfd
>= 0) {
41
dup2 (
m_nullfd
, 2);
42
}
43
}
44
45
46
// Restore stderr to its original FD.
47
RedirStderr::~RedirStderr
()
48
{
49
dup2 (
m_stderr
, 2);
50
close (
m_nullfd
);
51
close (
m_stderr
);
52
}
53
54
69
void
ubsan_suppress
(
void
(*func)())
70
{
71
if
(dlsym (RTLD_DEFAULT,
"__ubsan_handle_add_overflow"
) != NULL)
72
{
73
RedirStderr
redir;
74
func();
75
}
76
else
{
77
func();
78
}
79
}
80
81
82
}
// namespace CxxUtils
ubsan_suppress.h
Helper for suppressing ubsan warnings.
CxxUtils::RedirStderr::RedirStderr
RedirStderr(const RedirStderr &)=delete
CxxUtils::RedirStderr::RedirStderr
RedirStderr()
Definition:
ubsan_suppress.cxx:36
CxxUtils::RedirStderr::m_stderr
int m_stderr
Definition:
ubsan_suppress.cxx:31
CxxUtils::RedirStderr::~RedirStderr
~RedirStderr()
Definition:
ubsan_suppress.cxx:47
CxxUtils
Definition:
aligned_vector.h:29
CxxUtils::RedirStderr
Definition:
ubsan_suppress.cxx:22
CxxUtils::RedirStderr::m_nullfd
int m_nullfd
Definition:
ubsan_suppress.cxx:30
CxxUtils::RedirStderr::operator=
RedirStderr & operator=(const RedirStderr &)=delete
Trk::open
@ open
Definition:
BinningType.h:40
CxxUtils::ubsan_suppress
void ubsan_suppress(void(*func)())
Helper for suppressing ubsan warnings.
Definition:
ubsan_suppress.cxx:69
Generated on Thu Nov 7 2024 21:31:15 for ATLAS Offline Software by
1.8.18