[libc-commits] [PATCH] D145584: [libc] Add support for setjmp and longjmp in riscv

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Mar 8 10:30:24 PST 2023


michaelrj added inline comments.


================
Comment at: libc/src/setjmp/longjmp.h:16
 
-void longjmp(__jmp_buf *buf, int val);
+void longjmp(__jmp_buf *buf, int val) __NOEXCEPT;
 
----------------
mikhail.ramalho wrote:
> michaelrj wrote:
> > so far we've only been annotating functions with noexcept in the public headers. I'm not sure it's necessary here and below.
> Once I added the `__attribute((naked))`, gcc suddenly decided to be pickier and I keep getting the following warning. Adding the `__NOEXCEPT` makes it go away... Do you have any other suggestions?
> ```
> In file included from /home/mgadelha/tools/llvm-project/libc/src/setjmp/setjmp.cpp:9:
> /home/mgadelha/tools/llvm-project/libc/src/setjmp/setjmp.cpp:20:25: warning: ‘int __llvm_libc::setjmp(__jmp_buf*)’ specifies less restrictive attribute than its target ‘int __llvm_libc::__setjmp_impl__(__jmp_buf*)’: ‘nothrow’ [-Wmissing-attributes]
>    20 | LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) {
>       |                         ^~~~~~
> /home/mgadelha/tools/llvm-project/libc/src/__support/common.h:30:31: note: in definition of macro ‘LLVM_LIBC_FUNCTION’
>    30 |   decltype(__llvm_libc::name) name [[gnu::alias(#name)]];                      \
>       |                               ^~~~
> /home/mgadelha/tools/llvm-project/libc/src/__support/common.h:31:8: note: ‘int __llvm_libc::setjmp(__jmp_buf*)’ target declared here
>    31 |   type __##name##_impl__ arglist
>       |        ^~
> /home/mgadelha/tools/llvm-project/libc/src/setjmp/setjmp.cpp:20:1: note: in expansion of macro ‘LLVM_LIBC_FUNCTION’
>    20 | LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) {
>       | ^~~~~~~~~~~~~~~~~~
> [2/3] Building CXX object projects/libc/src/setjmp/CMakeFiles/libc.src.setjmp.longjmp.dir/longjmp.cpp.o
> In file included from /home/mgadelha/tools/llvm-project/libc/src/setjmp/longjmp.cpp:10:
> /home/mgadelha/tools/llvm-project/libc/src/setjmp/longjmp.cpp:20:26: warning: ‘void __llvm_libc::longjmp(__jmp_buf*, int)’ specifies less restrictive attribute than its target ‘void __llvm_libc::__longjmp_impl__(__jmp_buf*, int)’: ‘nothrow’ [-Wmissing-attributes]
>    20 | LLVM_LIBC_FUNCTION(void, longjmp, (__jmp_buf * buf, int val)) {
>       |                          ^~~~~~~
> /home/mgadelha/tools/llvm-project/libc/src/__support/common.h:30:31: note: in definition of macro ‘LLVM_LIBC_FUNCTION’
>    30 |   decltype(__llvm_libc::name) name [[gnu::alias(#name)]];                      \
>       |                               ^~~~
> /home/mgadelha/tools/llvm-project/libc/src/__support/common.h:31:8: note: ‘void __llvm_libc::longjmp(__jmp_buf*, int)’ target declared here
>    31 |   type __##name##_impl__ arglist
>       |        ^~
> /home/mgadelha/tools/llvm-project/libc/src/setjmp/longjmp.cpp:20:1: note: in expansion of macro ‘LLVM_LIBC_FUNCTION’
>    20 | LLVM_LIBC_FUNCTION(void, longjmp, (__jmp_buf * buf, int val)) {
>       | ^~~~~~~~~~~~~~~~~~
> ```
ah! That makes sense, in that case noexcept is fine.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145584/new/

https://reviews.llvm.org/D145584



More information about the libc-commits mailing list