Skip to content

Commit

Permalink
Vendor stdbool.h from clang 15.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-miller committed Oct 4, 2022
1 parent 720bbd0 commit 50c626f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to
#### Added
- Support for 32-bit ARM systems
- [#2360](https://github.com/iovisor/bpftrace/pull/2360)
- Add stdbool.h to built-in headers
#### Changed
#### Deprecated
#### Removed
Expand Down
34 changes: 34 additions & 0 deletions resources/stdbool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*===---- stdbool.h - Standard header for booleans -------------------------===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*
*===-----------------------------------------------------------------------===
*/

#ifndef __STDBOOL_H
#define __STDBOOL_H

#define __bool_true_false_are_defined 1

#if __STDC_VERSION__ > 201710L
/* FIXME: We should be issuing a deprecation warning here, but cannot yet due
* to system headers which include this header file unconditionally.
*/
#elif !defined(__cplusplus)
#define bool _Bool
#define true 1
#define false 0
#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
/* Define _Bool as a GNU extension. */
#define _Bool bool
#if __cplusplus < 201103L
/* For C++98, define bool, false, true as a GNU extension. */
#define bool bool
#define false false
#define true true
#endif
#endif

#endif /* __STDBOOL_H */
5 changes: 5 additions & 0 deletions src/clang_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const std::vector<CXUnsavedFile> &getDefaultHeaders()
.Contents = stdarg_h,
.Length = stdarg_h_len,
},
{
.Filename = "/bpftrace/include/stdbool.h",
.Contents = stdbool_h,
.Length = stdbool_h_len,
},
{
.Filename = "/bpftrace/include/stddef.h",
.Contents = stddef_h,
Expand Down
2 changes: 2 additions & 0 deletions src/headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extern const char limits_h[];
extern const unsigned limits_h_len;
extern const char stdarg_h[];
extern const unsigned stdarg_h_len;
extern const char stdbool_h[];
extern const unsigned stdbool_h_len;
extern const char stddef_h[];
extern const unsigned stddef_h_len;
extern const char stdint_h[];
Expand Down

0 comments on commit 50c626f

Please sign in to comment.