mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Introduce usage of __builtin_unreachable() and noreturn (#248)
This commit adds an UNREACHABLE() macro that expands to either the __builtin_unreachable() compiler builtin (for release builds) or abort(3) (for development builds). This is used to mark code paths that are never to be reached. It also adds the 'noreturn' attribute to functions that never return: path_exec(), sh_done() and sh_syntax(). The UNREACHABLE() macro is not added after calling these. The purpose of these is: * to slightly improve GCC/Clang compiler optimizations; * to fix a few compiler warnings; * to add code clarity. Changes of note: src/cmd/ksh93/sh/io.c: outexcept(): - Avoid using __builtin_unreachable() here since errormsg can return despite using ERROR_system(1), as shp->jmplist->mode is temporarily set to 0. See: https://github.com/att/ast/issues/1336 src/cmd/ksh93/tests/io.sh: - Add a regression test for the ksh2020 bug referenced above. src/lib/libast/features/common: - Detect the existence of either the C11 stdnoreturn.h header or the GCC noreturn attribute, preferring the former when available. - Test for the existence of __builtin_unreachable(). Use it for release builds. On development builds, use abort() instead, which crahses reliably for debugging when unreachable code is reached. Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
56913f8c2a
commit
c4f980eb29
87 changed files with 1170 additions and 122 deletions
|
|
@ -82,7 +82,7 @@ extern Pathcomp_t *path_absolute(Shell_t*, const char*, Pathcomp_t*, int);
|
|||
extern char *path_basename(const char*);
|
||||
extern char *path_fullname(Shell_t*,const char*);
|
||||
extern int path_expand(Shell_t*,const char*, struct argnod**);
|
||||
extern void path_exec(Shell_t*,const char*,char*[],struct argnod*);
|
||||
extern noreturn void path_exec(Shell_t*,const char*,char*[],struct argnod*);
|
||||
extern pid_t path_spawn(Shell_t*,const char*,char*[],char*[],Pathcomp_t*,int);
|
||||
#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
|
||||
# define extern __EXPORT__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue