소스 검색

[LibOS] Add noreturn function attribute where appropriate

Isaku Yamahata 5 년 전
부모
커밋
8055b40007
5개의 변경된 파일12개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 1
      LibOS/shim/include/shim_internal.h
  2. 4 2
      LibOS/shim/include/shim_table.h
  3. 3 4
      LibOS/shim/src/shim_init.c
  4. 2 3
      LibOS/shim/src/sys/shim_exit.c
  5. 2 2
      LibOS/shim/src/sys/shim_poll.c

+ 1 - 1
LibOS/shim/include/shim_internal.h

@@ -145,7 +145,7 @@ static inline PAL_HANDLE __open_shim_stdio (void)
     return shim_stdio;
 }
 
-int shim_terminate (int err);
+noreturn void shim_terminate (int err);
 
 /* assertions */
 #define USE_PAUSE       0

+ 4 - 2
LibOS/shim/include/shim_table.h

@@ -4,6 +4,8 @@
 #ifndef _SHIM_TABLE_H_
 #define _SHIM_TABLE_H_
 
+#include <stdnoreturn.h>
+
 #include <shim_types.h>
 #include <shim_unistd.h>
 
@@ -395,7 +397,7 @@ int shim_do_clone (int flags, void * user_stack_addr, int * parent_tidptr,
 int shim_do_fork (void);
 int shim_do_vfork (void);
 int shim_do_execve (const char * file, const char ** argv, const char ** envp);
-__attribute__((noreturn)) int shim_do_exit (int error_code);
+noreturn int shim_do_exit (int error_code);
 pid_t shim_do_wait4 (pid_t pid, int * stat_addr, int option,
                      struct __kernel_rusage * ru);
 int shim_do_kill (pid_t pid, int sig);
@@ -469,7 +471,7 @@ int shim_do_clock_gettime (clockid_t which_clock,
                            struct timespec * tp);
 int shim_do_clock_getres (clockid_t which_clock,
                           struct timespec * tp);
-int shim_do_exit_group (int error_code);
+noreturn int shim_do_exit_group (int error_code);
 int shim_do_tgkill (int tgid, int pid, int sig);
 int shim_do_openat (int dfd, const char * filename, int flags, int mode);
 int shim_do_mkdirat (int dfd, const char * pathname, int mode);

+ 3 - 4
LibOS/shim/src/shim_init.c

@@ -57,7 +57,7 @@ static void handle_failure (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
     shim_get_tls()->pal_errno = (arg <= PAL_ERROR_BOUND) ? arg : 0;
 }
 
-void __abort(void) {
+noreturn void __abort(void) {
     PAUSE();
     shim_terminate(-ENOTRECOVERABLE);
 }
@@ -676,7 +676,7 @@ DEFINE_PROFILE_INTERVAL(init_signal,                init);
 
 extern PAL_HANDLE thread_start_event;
 
-__attribute__((noreturn)) void* shim_init (int argc, void * args)
+noreturn void* shim_init (int argc, void * args)
 {
     debug_handle = PAL_CB(debug_stream);
     cur_process.vmid = (IDTYPE) PAL_CB(process_id);
@@ -1119,7 +1119,7 @@ static void print_profile_result (PAL_HANDLE hdl, struct shim_profile * root,
 
 static struct atomic_int in_terminate = { .counter = 0, };
 
-int shim_terminate (int err)
+noreturn void shim_terminate (int err)
 {
     debug("teminating the whole process (%d)\n", err);
 
@@ -1127,7 +1127,6 @@ int shim_terminate (int err)
     shim_clean(err);
 
     DkProcessExit(err);
-    return 0;
 }
 
 /* cleanup and terminate process, preserve exit code if err == 0 */

+ 2 - 3
LibOS/shim/src/sys/shim_exit.c

@@ -166,7 +166,7 @@ int try_process_exit (int error_code, int term_signal)
     return 0;
 }
 
-int shim_do_exit_group (int error_code)
+noreturn int shim_do_exit_group (int error_code)
 {
     INC_PROFILE_OCCURENCE(syscall_use_ipc);
     struct shim_thread * cur_thread = get_cur_thread();
@@ -193,10 +193,9 @@ int shim_do_exit_group (int error_code)
 #endif
 
     DkThreadExit();
-    return 0;
 }
 
-__attribute__((noreturn)) int shim_do_exit (int error_code)
+noreturn int shim_do_exit (int error_code)
 {
     INC_PROFILE_OCCURENCE(syscall_use_ipc);
     struct shim_thread * cur_thread = get_cur_thread();

+ 2 - 2
LibOS/shim/src/sys/shim_poll.c

@@ -39,7 +39,7 @@
 
 #include <linux/fcntl.h>
 
-void __attribute__ ((noreturn))
+noreturn void
 fortify_fail (const char *msg)
 {
     /* The loop is added only to keep gcc happy.  */
@@ -47,7 +47,7 @@ fortify_fail (const char *msg)
         debug("*** %s ***\n", msg);
 }
 
-void __attribute__ ((noreturn))
+noreturn void
 chk_fail (void)
 {
     fortify_fail ("buffer overflow detected");