1 | /* |
2 | * Copyright 2018-present Facebook, Inc. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #include <folly/detail/Demangle.h> |
18 | |
19 | // Do not include <libiberty.h> (binutils) and <string.h> (glibc) in the same |
20 | // translation unit since they contain conflicting declarations for the symbol |
21 | // `basename`. |
22 | // |
23 | // So we extract the inclusion of `<demangle.h>` which includes `<libiberty.h>` |
24 | // to here, isolating it. |
25 | #if FOLLY_DETAIL_HAVE_DEMANGLE_H |
26 | #include <demangle.h> |
27 | #endif |
28 | |
29 | namespace folly { |
30 | namespace detail { |
31 | |
32 | int cplus_demangle_v3_callback_wrapper( |
33 | char const* const mangled, |
34 | void (*const cbref)(char const*, std::size_t, void*), |
35 | void* const opaque) { |
36 | #if FOLLY_DETAIL_HAVE_DEMANGLE_H |
37 | auto const options = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES; |
38 | return cplus_demangle_v3_callback(mangled, options, cbref, opaque); |
39 | #else |
40 | return 0; |
41 | #endif |
42 | } |
43 | |
44 | } // namespace detail |
45 | } // namespace folly |
46 | |