Skip to content

Commit

Permalink
builtins: make it possible to include cheerpintrin.h in C code
Browse files Browse the repository at this point in the history
This change is partially required for libasan. Libasan relies on
__builtin_cheerp_grow_memory, however, it is compiled with -nostdinc++,
which would fail at the `#include <cstdint>` line. In theory I could
just forward declare it myself, however, I figured that it could also be
useful to be able to include this header in C source code.
  • Loading branch information
Hyxogen authored and yuri91 committed Nov 15, 2023
1 parent d7e35db commit 08adbd0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions clang/lib/Headers/cheerpintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
#ifndef __CHEERPINTRIN_H
#define __CHEERPINTRIN_H

#include <cstddef>
__attribute__ ((cheerp_genericjs)) int __builtin_cheerp_grow_memory(int pages);
__attribute__ ((cheerp_genericjs)) void* __builtin_cheerp_stack_save(void);
__attribute__ ((cheerp_genericjs)) void __builtin_cheerp_restore(void*);

#ifdef __cplusplus

#include <stddef.h>

namespace [[cheerp::genericjs]] {

Expand All @@ -39,12 +45,6 @@ R* __builtin_cheerp_make_regular(T*, int);
template<class P>
size_t __builtin_cheerp_pointer_kind(const P* ptr);

int __builtin_cheerp_grow_memory(int bytes);

void* __buitin_cheerp_stack_save();

void __buitin_cheerp_stack_restore(void*);

template<class R, class P>
R* __builtin_cheerp_downcast(const P* ptr, int offset);

Expand All @@ -54,6 +54,6 @@ int __builtin_cheerp_downcast_current(const P* ptr);
template<class P>
[[noreturn]]
void __builtin_cheerp_throw(const P* ptr);

}
#endif // __cplusplus
#endif /* __CHEERPINTRIN_H */

0 comments on commit 08adbd0

Please sign in to comment.