Skip to content

Commit 5cc3187

Browse files
committed
[libc] Add returns_twice attribute to setjmp(3)
This is to work around a clang bug where clang will incorrectly add a tail call optimization to `setjmp(3)` if `-fno-builtins` is set (#122840).
1 parent 241e5d8 commit 5cc3187

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

libc/include/__llvm-libc-common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
#define __NOEXCEPT throw()
4646
#endif
4747

48+
#undef _Returns_twice
49+
#define _Returns_twice [[gnu::returns_twice]]
50+
4851
#else // not __cplusplus
4952

5053
#undef __BEGIN_C_DECLS
@@ -80,6 +83,9 @@
8083
#define __NOEXCEPT
8184
#endif
8285

86+
#undef _Returns_twice
87+
#define _Returns_twice __attribute__((returns_twice))
88+
8389
#endif // __cplusplus
8490

8591
#endif // LLVM_LIBC_COMMON_H

libc/include/setjmp.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ functions:
1717
standards:
1818
- stdc
1919
return_type: int
20+
attributes:
21+
- _Returns_twice
2022
arguments:
2123
- type: jmp_buf

0 commit comments

Comments
 (0)