[Pal] Add noreturn function attribute where appropriate

Add noreturn function attribute to _DkThreadExit(), pal_main(),
pal_linux_main(), start_execution(), and ocall_exit().
This commit is contained in:
Isaku Yamahata
2019-06-19 12:48:03 -07:00
committed by Dmitrii Kuvaiskii
parent 326fc07933
commit ba169becae
12 changed files with 21 additions and 16 deletions
+2 -4
View File
@@ -26,6 +26,7 @@
#include "pal_internal.h"
#include "pal_debug.h"
#include "pal_error.h"
#include "pal_rtld.h"
#include "api.h"
#include <sysdeps/generic/ldsodefs.h>
@@ -216,11 +217,8 @@ static int loader_filter (const char * key, int len)
key[4] == 'e' && key[5] == 'r' && key[6] == '.') ? 0 : 1;
}
void start_execution (const char * first_argument, const char ** arguments,
const char ** environments);
/* 'pal_main' must be called by the host-specific bootloader */
void pal_main (
noreturn void pal_main (
PAL_NUM instance_id, /* current instance id */
PAL_HANDLE manifest_handle, /* manifest handle if opened */
PAL_HANDLE exec_handle, /* executable handle if opened */
+2 -2
View File
@@ -1299,8 +1299,8 @@ void * stack_before_call __attribute_unused = NULL;
#endif
#endif /* !CALL_ENTRY */
void start_execution (const char * first_argument, const char ** arguments,
const char ** environs)
noreturn void start_execution (const char * first_argument,
const char ** arguments, const char ** environs)
{
/* First we will try to run all the preloaded libraries which come with
entry points */
+1 -1
View File
@@ -113,7 +113,7 @@ void _DkThreadYieldExecution (void)
}
/* _DkThreadExit for internal use: Thread exiting */
void _DkThreadExit (void)
noreturn void _DkThreadExit (void)
{
INLINE_SYSCALL(exit, 1, 0);
}
+1 -1
View File
@@ -138,7 +138,7 @@ void _DkThreadYieldExecution (void)
}
/* _DkThreadExit for internal use: Thread exiting */
void _DkThreadExit (void)
noreturn void _DkThreadExit (void)
{
ocall_exit(0);
}
+1 -2
View File
@@ -11,7 +11,7 @@
#include <api.h>
#include <asm/errno.h>
int ocall_exit(int exitcode)
noreturn void ocall_exit(int exitcode)
{
int64_t code = exitcode;
// There are two reasons for this loop:
@@ -21,7 +21,6 @@ int ocall_exit(int exitcode)
while (true) {
sgx_ocall(OCALL_EXIT, (void *) code);
}
return 0;
}
int ocall_print_string (const char * str, unsigned int length)
+1 -1
View File
@@ -8,7 +8,7 @@
#include <linux/socket.h>
#include <linux/poll.h>
int ocall_exit (int exitcode);
noreturn void ocall_exit (int exitcode);
int ocall_print_string (const char * str, unsigned int length);
-1
View File
@@ -306,7 +306,6 @@ done_init:
printf("Executable not found\n");
printf("USAGE: %s [executable|manifest] args ...\n", pal_name);
_DkProcessExit(0);
return;
}
signal_setup();
+4 -1
View File
@@ -167,7 +167,7 @@ void _DkThreadYieldExecution (void)
}
/* _DkThreadExit for internal use: Thread exiting */
void _DkThreadExit (void)
noreturn void _DkThreadExit (void)
{
PAL_TCB* tcb = get_tcb();
PAL_HANDLE handle = tcb->handle;
@@ -191,6 +191,9 @@ void _DkThreadExit (void)
}
INLINE_SYSCALL(exit, 1, 0);
while (true) {
/* nothing */
}
}
int _DkThreadResume (PAL_HANDLE threadHandle)
+1
View File
@@ -192,6 +192,7 @@ typedef struct pal_tcb {
void * param;
} PAL_TCB;
noreturn void pal_linux_main (void * args);
int pal_thread_init (void * tcbptr);
static inline PAL_TCB * get_tcb (void)
+4 -1
View File
@@ -49,9 +49,12 @@ void _DkThreadYieldExecution (void)
}
/* _DkThreadExit for internal use: Thread exiting */
void _DkThreadExit (void)
noreturn void _DkThreadExit (void)
{
/* need to be implemented */
while (true) {
/* nothing */
}
}
int _DkThreadResume (PAL_HANDLE threadHandle)
+2 -2
View File
@@ -249,7 +249,7 @@ extern PAL_CONTROL __pal_control;
(((unsigned long)(addr)) & pal_state.alloc_mask))
/* Main initialization function */
void pal_main (
noreturn void pal_main (
PAL_NUM instance_id, /* current instance id */
PAL_HANDLE manifest_handle, /* manifest handle if opened */
PAL_HANDLE exec_handle, /* executable handle if opened */
@@ -296,7 +296,7 @@ PAL_HANDLE _DkBroadcastStreamOpen (void);
/* DkProcess and DkThread calls */
int _DkThreadCreate (PAL_HANDLE * handle, int (*callback) (void *),
const void * param);
void _DkThreadExit (void);
noreturn void _DkThreadExit (void);
int _DkThreadDelayExecution (unsigned long * duration);
void _DkThreadYieldExecution (void);
int _DkThreadResume (PAL_HANDLE threadHandle);
+2
View File
@@ -180,5 +180,7 @@ do_lookup_map (ElfW(Sym) * ref, const char * undef_name,
void _DkDebugAddMap (struct link_map * map);
void _DkDebugDelMap (struct link_map * map);
noreturn void start_execution (const char * first_argument,
const char ** arguments, const char ** environs);
#endif /* PAL_RTLD_H */