Trivial: style fix make the style checker happy
diff --git a/CMakeLists.txt b/CMakeLists.txt index 343332e..b9bf3bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -123,12 +123,4 @@ # A C library is still needed here to provide memcpy, stdint.h, and # elf.h -target_link_libraries( - sel4runtime - PUBLIC - sel4 - muslc - sel4_autoconf - PRIVATE - sel4runtime_Config -) +target_link_libraries(sel4runtime PUBLIC sel4 muslc sel4_autoconf PRIVATE sel4runtime_Config)
diff --git a/include/sel4_arch/aarch32/sel4runtime/thread_arch.h b/include/sel4_arch/aarch32/sel4runtime/thread_arch.h index ae3307f..f5daf70 100644 --- a/include/sel4_arch/aarch32/sel4runtime/thread_arch.h +++ b/include/sel4_arch/aarch32/sel4runtime/thread_arch.h
@@ -16,26 +16,30 @@ #if ((__ARM_ARCH_6K__ || __ARM_ARCH_6ZK__) && !__thumb__) \ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7 -static inline uintptr_t sel4runtime_read_tpidr_el0(void) { +static inline uintptr_t sel4runtime_read_tpidr_el0(void) +{ uintptr_t reg; - __asm__ __volatile__ ( "mrc p15,0,%0,c13,c0,2" : "=r"(reg) ); + __asm__ __volatile__("mrc p15,0,%0,c13,c0,2" : "=r"(reg)); return reg; } -static inline void sel4runtime_write_tpidr_el0(uintptr_t reg) { - __asm__ __volatile__ ( "mcr p15,0,%0,c13,c0,2" :: "r"(reg) ); +static inline void sel4runtime_write_tpidr_el0(uintptr_t reg) +{ + __asm__ __volatile__("mcr p15,0,%0,c13,c0,2" :: "r"(reg)); } -static inline uintptr_t sel4runtime_read_tpidrro_el0(void) { +static inline uintptr_t sel4runtime_read_tpidrro_el0(void) +{ uintptr_t reg; - __asm__ __volatile__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(reg) ); + __asm__ __volatile__("mrc p15,0,%0,c13,c0,3" : "=r"(reg)); return reg; } /* * Set the value of the TLS base for the current thread. */ -static inline void sel4runtime_set_tls_base(uintptr_t tls_base) { +static inline void sel4runtime_set_tls_base(uintptr_t tls_base) +{ sel4runtime_write_tpidr_el0(tls_base); } @@ -49,12 +53,14 @@ * spaces. The IPC buffer and thread pointer occupy the first two words * in this frame respectively. */ -static inline uintptr_t sel4runtime_read_tpidr_el0(void) { +static inline uintptr_t sel4runtime_read_tpidr_el0(void) +{ void **globals_frame = (void **)seL4_GlobalsFrame; return (uintptr_t)globals_frame[0]; } -static inline uintptr_t sel4runtime_read_tpidrro_el0(void) { +static inline uintptr_t sel4runtime_read_tpidrro_el0(void) +{ void **globals_frame = (void **)seL4_GlobalsFrame; return (uintptr_t)globals_frame[1]; } @@ -63,7 +69,8 @@ /* * Set the value of the TLS base for the current thread. */ -static inline void sel4runtime_set_tls_base(uintptr_t tls_base) { +static inline void sel4runtime_set_tls_base(uintptr_t tls_base) +{ seL4_SetTLSBase(tls_base); } #else @@ -74,7 +81,8 @@ /* * Obtain the value of the TLS base for the current thread. */ -static inline uintptr_t sel4runtime_get_tls_base(void) { +static inline uintptr_t sel4runtime_get_tls_base(void) +{ return sel4runtime_read_tpidr_el0(); }
diff --git a/include/sel4_arch/ia32/sel4runtime/thread_arch.h b/include/sel4_arch/ia32/sel4runtime/thread_arch.h index 9d95944..02d638f 100644 --- a/include/sel4_arch/ia32/sel4runtime/thread_arch.h +++ b/include/sel4_arch/ia32/sel4runtime/thread_arch.h
@@ -15,9 +15,10 @@ /* * Obtain the value of the TLS base for the current thread. */ -static inline uintptr_t sel4runtime_get_tls_base(void) { +static inline uintptr_t sel4runtime_get_tls_base(void) +{ uintptr_t tp; - __asm__ __volatile__ ("movl %%gs:0,%0" : "=r" (tp) ); + __asm__ __volatile__("movl %%gs:0,%0" : "=r"(tp)); return tp; } @@ -25,7 +26,8 @@ /* * Set the value of the TLS base for the current thread. */ -static inline void sel4runtime_set_tls_base(uintptr_t tls_base) { +static inline void sel4runtime_set_tls_base(uintptr_t tls_base) +{ seL4_SetTLSBase(tls_base); } #else
diff --git a/include/sel4_arch/x86_64/sel4runtime/thread_arch.h b/include/sel4_arch/x86_64/sel4runtime/thread_arch.h index f9c4cb7..c21bfdd 100644 --- a/include/sel4_arch/x86_64/sel4runtime/thread_arch.h +++ b/include/sel4_arch/x86_64/sel4runtime/thread_arch.h
@@ -13,37 +13,43 @@ #include <stdint.h> #ifdef CONFIG_FSGSBASE_INST -static inline uintptr_t sel4runtime_read_fs_base(void) { +static inline uintptr_t sel4runtime_read_fs_base(void) +{ uintptr_t reg; - __asm__ __volatile__ ("rdfsbase %0" : "=r" (reg) ); + __asm__ __volatile__("rdfsbase %0" : "=r"(reg)); return reg; } -static inline void sel4runtime_write_fs_base(uintptr_t reg) { - __asm__ __volatile__ ("wrfsbase %0" :: "r" (reg) ); +static inline void sel4runtime_write_fs_base(uintptr_t reg) +{ + __asm__ __volatile__("wrfsbase %0" :: "r"(reg)); } -static inline uintptr_t sel4runtime_read_gs_base(void) { +static inline uintptr_t sel4runtime_read_gs_base(void) +{ uintptr_t reg; - __asm__ __volatile__ ("rdgsbase %0" : "=r" (reg) ); + __asm__ __volatile__("rdgsbase %0" : "=r"(reg)); return reg; } -static inline void sel4runtime_write_gs_base(uintptr_t reg) { - __asm__ __volatile__ ("wrgsbase %0" :: "r" (reg) ); +static inline void sel4runtime_write_gs_base(uintptr_t reg) +{ + __asm__ __volatile__("wrgsbase %0" :: "r"(reg)); } /* * Obtain the value of the TLS base for the current thread. */ -static inline uintptr_t sel4runtime_get_tls_base(void) { +static inline uintptr_t sel4runtime_get_tls_base(void) +{ return sel4runtime_read_fs_base(); } /* * Set the value of the TLS base for the current thread. */ -static inline void sel4runtime_set_tls_base(uintptr_t tls_base) { +static inline void sel4runtime_set_tls_base(uintptr_t tls_base) +{ sel4runtime_write_fs_base(tls_base); } @@ -52,9 +58,10 @@ /* * Obtain the value of the TLS base for the current thread. */ -static inline uintptr_t sel4runtime_get_tls_base(void) { +static inline uintptr_t sel4runtime_get_tls_base(void) +{ uintptr_t tp; - __asm__ __volatile__ ("mov %%fs:0,%0" : "=r" (tp) ); + __asm__ __volatile__("mov %%fs:0,%0" : "=r"(tp)); return tp; } @@ -62,7 +69,8 @@ /* * Set the value of the TLS base for the current thread. */ -static inline void sel4runtime_set_tls_base(uintptr_t tls_base) { +static inline void sel4runtime_set_tls_base(uintptr_t tls_base) +{ seL4_SetTLSBase(tls_base); } #else
diff --git a/src/env.c b/src/env.c index b3194d9..3fb5646 100644 --- a/src/env.c +++ b/src/env.c
@@ -84,7 +84,7 @@ auxv_t const *auxv; // Environment vector - char const * const *envp; + char const *const *envp; } env = { /* * Initialise the initial thread as referring to the global thread @@ -107,19 +107,23 @@ static void empty_tls(void); static bool is_initial_thread(void); -char const *sel4runtime_process_name(void) { +char const *sel4runtime_process_name(void) +{ return env.process_name; } -seL4_BootInfo *sel4runtime_bootinfo(void) { +seL4_BootInfo *sel4runtime_bootinfo(void) +{ return env.bootinfo; } -size_t sel4runtime_get_tls_size(void) { +size_t sel4runtime_get_tls_size(void) +{ return env.tls.region_size; } -int sel4runtime_initial_tls_enabled(void) { +int sel4runtime_initial_tls_enabled(void) +{ /* * If the TLS for the initial process has been activated, the thread * object in the TLS will be used rather than the static thread @@ -128,7 +132,8 @@ return env.initial_thread_tls_base != (uintptr_t)NULL; } -uintptr_t sel4runtime_write_tls_image(void *tls_memory) { +uintptr_t sel4runtime_write_tls_image(void *tls_memory) +{ if (tls_memory == NULL) { return (uintptr_t)NULL; } @@ -138,7 +143,8 @@ return tls_base_from_tls_region(tls_memory); } -uintptr_t sel4runtime_move_initial_tls(void *tls_memory) { +uintptr_t sel4runtime_move_initial_tls(void *tls_memory) +{ if (tls_memory == NULL) { return (uintptr_t)NULL; } @@ -167,7 +173,8 @@ return env.initial_thread_tls_base; } -void sel4runtime_exit(int code) { +void sel4runtime_exit(int code) +{ if (!is_initial_thread() && env.initial_thread_tcb) { seL4_TCB_Suspend(env.initial_thread_tcb); } @@ -188,7 +195,8 @@ unsigned char *local_tls_dest, unsigned char *src, size_t bytes -) { +) +{ uintptr_t local_tls_base = sel4runtime_get_tls_base(); unsigned char *local_tls = tls_from_tls_base(local_tls_base); size_t offset = local_tls_dest - local_tls; @@ -209,9 +217,10 @@ void __sel4runtime_load_env( char const *arg0, - char const * const *envp, + char const *const *envp, auxv_t const auxv[] -) { +) +{ empty_tls(); parse_auxv(auxv); parse_phdrs(); @@ -223,7 +232,8 @@ env.envp = envp; } -static void name_process(char const *name) { +static void name_process(char const *name) +{ env.process_name = name; while (name && *name != '\0') { @@ -235,7 +245,8 @@ } } -static void parse_auxv(auxv_t const auxv[]) { +static void parse_auxv(auxv_t const auxv[]) +{ for (int i = 0; auxv[i].a_type != AT_NULL; i++) { switch (auxv[i].a_type) { case AT_PHENT: { @@ -256,7 +267,9 @@ } case AT_SEL4_BOOT_INFO: { seL4_BootInfo *bootinfo = auxv[i].a_un.a_ptr; - if (bootinfo == NULL) break; + if (bootinfo == NULL) { + break; + } env.bootinfo = bootinfo; env.initial_thread_ipc_buffer = bootinfo->ipcBuffer; env.initial_thread_tcb = seL4_CapInitThreadTCB; @@ -276,20 +289,22 @@ } } -static void parse_phdrs(void) { +static void parse_phdrs(void) +{ for (size_t h = 0; h < env.program_header.count; h++) { Elf_Phdr *header = &env.program_header.headers[h]; switch (header->p_type) { - case PT_TLS: - load_tls_data(header); - break; - default: - break; + case PT_TLS: + load_tls_data(header); + break; + default: + break; } } } -static void load_tls_data(Elf_Phdr *header) { +static void load_tls_data(Elf_Phdr *header) +{ env.tls.image = (void *) header->p_vaddr; if (header->p_align > MIN_ALIGN_BYTES) { env.tls.align = header->p_align; @@ -299,18 +314,20 @@ env.tls.image_size = header->p_filesz; env.tls.memory_size = ROUND_UP(header->p_memsz, header->p_align); env.tls.region_size = tls_region_size( - env.tls.memory_size, - env.tls.align - ); + env.tls.memory_size, + env.tls.align + ); } -static void try_init_static_tls(void) { +static void try_init_static_tls(void) +{ if (env.tls.region_size <= sizeof(static_tls)) { sel4runtime_move_initial_tls(static_tls); } } -static void copy_tls_data(unsigned char *tls_region) { +static void copy_tls_data(unsigned char *tls_region) +{ unsigned char *tls = tls_from_tls_region(tls_region); __sel4runtime_memcpy(tls, env.tls.image, env.tls.image_size); unsigned char *tbss = &tls[env.tls.image_size]; @@ -322,7 +339,8 @@ } } -static uintptr_t tls_base_from_tls_region(unsigned char *tls_region) { +static uintptr_t tls_base_from_tls_region(unsigned char *tls_region) +{ uintptr_t tls_base = (uintptr_t)tls_region; #if !defined(TLS_ABOVE_TP) tls_base += env.tls.memory_size; @@ -330,7 +348,8 @@ return ROUND_UP(tls_base, env.tls.align); } -static unsigned char *tls_from_tls_base(uintptr_t tls_base) { +static unsigned char *tls_from_tls_base(uintptr_t tls_base) +{ uintptr_t tls_addr = tls_base; #if !defined(TLS_ABOVE_TP) tls_addr -= env.tls.memory_size; @@ -341,13 +360,15 @@ return (unsigned char *)tls_addr; } -static unsigned char *tls_from_tls_region(unsigned char *tls_region) { +static unsigned char *tls_from_tls_region(unsigned char *tls_region) +{ return tls_from_tls_base(tls_base_from_tls_region(tls_region)); } static thread_lookup_t *thread_lookup_from_tls_region( unsigned char *tls_region -) { +) +{ #if !defined(TLS_ABOVE_TP) return (thread_lookup_t *)tls_base_from_tls_region(tls_region); #else @@ -355,24 +376,26 @@ #endif } -static const size_t tls_region_size(size_t mem_size, size_t align) { +static const size_t tls_region_size(size_t mem_size, size_t align) +{ return align - + ROUND_UP(sizeof (thread_lookup_t), align) + + ROUND_UP(sizeof(thread_lookup_t), align) #if defined(GAP_ABOVE_TP) - + ROUND_UP(GAP_ABOVE_TP, align) + + ROUND_UP(GAP_ABOVE_TP, align) #endif - + ROUND_UP(mem_size, align); + + ROUND_UP(mem_size, align); } -static void empty_tls(void) { +static void empty_tls(void) +{ env.tls.image = NULL; env.tls.align = MIN_ALIGN_BYTES; env.tls.image_size = 0; env.tls.memory_size = 0; env.tls.region_size = tls_region_size( - env.tls.memory_size, - env.tls.align - ); + env.tls.memory_size, + env.tls.align + ); } /* @@ -381,7 +404,8 @@ * This will optimistically assume that the current thread is the * initial thread of no thread ever had TLS configured. */ -static bool is_initial_thread(void) { +static bool is_initial_thread(void) +{ return env.initial_thread_tls_base == (uintptr_t)NULL - || sel4runtime_get_tls_base() == env.initial_thread_tls_base; + || sel4runtime_get_tls_base() == env.initial_thread_tls_base; }
diff --git a/src/sel4_arch/aarch32/__aeabi_read_tp_c.c b/src/sel4_arch/aarch32/__aeabi_read_tp_c.c index 4170edd..4bea190 100644 --- a/src/sel4_arch/aarch32/__aeabi_read_tp_c.c +++ b/src/sel4_arch/aarch32/__aeabi_read_tp_c.c
@@ -13,6 +13,7 @@ #include <sel4runtime/thread_arch.h> __attribute__((__visibility__("hidden"))) -void *__aeabi_read_tp_c(void) { +void *__aeabi_read_tp_c(void) +{ return (void *)sel4runtime_get_tls_base(); }