Remove always_inline where not needed

This commit is contained in:
Michał Kowalczyk
2020-07-05 17:24:06 +02:00
parent c7912c2d0b
commit cb7d430655
8 changed files with 20 additions and 80 deletions
@@ -20,12 +20,6 @@
::"r"(__stack_top), "r"(func), "D"(arg): "memory"); \
} while (0)
static_always_inline void* current_stack(void) {
void* _rsp;
__asm__ volatile ("movq %%rsp, %0" : "=r"(_rsp) :: "memory");
return _rsp;
}
#define CALL_ELF_ENTRY(ENTRY, ARGP) \
__asm__ volatile( \
"pushq $0\r\n" \
+8 -14
View File
@@ -399,16 +399,7 @@ void get_dentry(struct shim_dentry* dent);
/* Decrement the reference count on dent */
void put_dentry(struct shim_dentry* dent);
static_always_inline void fast_pathcpy(char* dst, const char* src, size_t size, char** ptr) {
char* d = dst;
const char* s = src;
for (size_t i = 0; i < size; i++, s++, d++)
*d = *s;
*ptr = d;
}
static_always_inline char* dentry_get_path(struct shim_dentry* dent, bool on_stack,
size_t* sizeptr) {
static inline __attribute__((always_inline)) char* dentry_get_path(struct shim_dentry* dent, bool on_stack, size_t* sizeptr) {
struct shim_mount* fs = dent->fs;
char* buffer;
char* c;
@@ -424,8 +415,10 @@ static_always_inline char* dentry_get_path(struct shim_dentry* dent, bool on_sta
return NULL;
}
if (fs && !qstrempty(&fs->path))
fast_pathcpy(c, qstrgetstr(&fs->path), fs->path.len, &c);
if (fs && !qstrempty(&fs->path)) {
memcpy(c, qstrgetstr(&fs->path), fs->path.len);
c += fs->path.len;
}
if (dent->rel_path.len) {
const char* path = qstrgetstr(&dent->rel_path);
@@ -439,7 +432,8 @@ static_always_inline char* dentry_get_path(struct shim_dentry* dent, bool on_sta
*(c++) = '/';
}
fast_pathcpy(c, path, len, &c);
memcpy(c, path, len);
c += len;
}
if (sizeptr)
@@ -449,7 +443,7 @@ static_always_inline char* dentry_get_path(struct shim_dentry* dent, bool on_sta
return buffer;
}
static_always_inline const char* dentry_get_name(struct shim_dentry* dent) {
static inline const char* dentry_get_name(struct shim_dentry* dent) {
return qstrgetstr(&dent->name);
}
-2
View File
@@ -19,8 +19,6 @@
#define EXTERN_ALIAS(name) \
extern __typeof__(name) shim_##name __attribute ((alias (ALIAS_STR(name))))
#define static_always_inline static inline __attribute__((always_inline))
#include <api.h>
#include <assert.h>
#include <atomic.h>
+2 -2
View File
@@ -428,12 +428,12 @@ struct shim_ipc_info* create_ipc_info_in_list(IDTYPE vmid, const char* uri, size
void put_ipc_info_in_list(struct shim_ipc_info* info);
struct shim_ipc_info* lookup_ipc_info(IDTYPE vmid);
static_always_inline size_t get_ipc_msg_size(size_t payload) {
static inline size_t get_ipc_msg_size(size_t payload) {
size_t size = sizeof(struct shim_ipc_msg) + payload;
return (size > IPC_MSG_MINIMAL_SIZE) ? size : IPC_MSG_MINIMAL_SIZE;
}
static_always_inline size_t get_ipc_msg_duplex_size(size_t payload) {
static inline size_t get_ipc_msg_duplex_size(size_t payload) {
static_assert(sizeof(struct shim_ipc_msg_duplex) >= sizeof(struct shim_ipc_msg),
"Incorrect shim_ipc_msg_duplex size");
return get_ipc_msg_size(payload) +
+6 -43
View File
@@ -137,10 +137,7 @@ void put_thread (struct shim_thread * thread);
void debug_setprefix (shim_tcb_t * tcb);
static inline
__attribute__((always_inline))
void debug_setbuf (shim_tcb_t * tcb, bool on_stack)
{
static inline __attribute__((always_inline)) void debug_setbuf(shim_tcb_t* tcb, bool on_stack) {
if (!debug_handle)
return;
@@ -150,17 +147,12 @@ void debug_setbuf (shim_tcb_t * tcb, bool on_stack)
debug_setprefix(tcb);
}
static inline
__attribute__((always_inline))
struct shim_thread* get_cur_thread (void) {
static inline struct shim_thread* get_cur_thread(void) {
return SHIM_TCB_GET(tp);
}
static inline
__attribute__((always_inline))
void set_cur_thread (struct shim_thread * thread)
{
shim_tcb_t * tcb = shim_get_tcb();
static inline void set_cur_thread(struct shim_thread* thread) {
shim_tcb_t* tcb = shim_get_tcb();
IDTYPE tid = 0;
if (thread) {
@@ -293,19 +285,14 @@ void get_handle_map (struct shim_handle_map * map);
void put_handle_map (struct shim_handle_map * map);
/* retriving handle mapping */
static inline __attribute__((always_inline))
struct shim_handle_map * get_cur_handle_map (struct shim_thread * thread)
{
static inline struct shim_handle_map* get_cur_handle_map(struct shim_thread* thread) {
if (!thread)
thread = get_cur_thread();
return thread ? thread->handle_map : NULL;
}
static inline __attribute__((always_inline))
void set_handle_map (struct shim_thread * thread,
struct shim_handle_map * map)
{
static inline void set_handle_map(struct shim_thread* thread, struct shim_handle_map* map) {
get_handle_map(map);
if (!thread)
@@ -335,30 +322,6 @@ struct shim_clone_args {
void * allocate_stack (size_t size, size_t protect_size, bool user);
static inline __attribute__((always_inline))
bool check_stack_size (struct shim_thread * cur_thread, int size)
{
if (!cur_thread)
cur_thread = get_cur_thread();
void * rsp;
__asm__ volatile ("movq %%rsp, %0" : "=r"(rsp) :: "memory");
if (rsp <= cur_thread->stack_top && rsp > cur_thread->stack)
return size < rsp - cur_thread->stack;
return false;
}
static inline __attribute__((always_inline))
bool check_on_stack (struct shim_thread * cur_thread, void * mem)
{
if (!cur_thread)
cur_thread = get_cur_thread();
return (mem <= cur_thread->stack_top && mem > cur_thread->stack);
}
int init_stack(const char** argv, const char** envp, const char*** out_argp,
elf_auxv_t** out_auxv);
+1 -1
View File
@@ -157,7 +157,7 @@ void free(void* mem);
void* malloc_copy(const void* mem, size_t size);
#endif
static_always_inline char* qstrtostr(struct shim_qstr* qstr, bool on_stack) {
static inline __attribute__((always_inline)) char* qstrtostr(struct shim_qstr* qstr, bool on_stack) {
int len = qstr->len;
char* buf = on_stack ? __alloca(len + 1) : malloc(len + 1);
+2 -8
View File
@@ -17,13 +17,8 @@
* size is the number of bytes pointed to by hex.
* str is the caller-provided buffer, len is the length of the buffer.
* The len must be at least (size * 2)+1.
*
* Note that it does not normalize for endianness, and pads to the
* size the compiler things the string is.
*/
static inline __attribute__((always_inline))
char * __bytes2hexstr(void * hex, size_t size, char *str, size_t len)
{
static inline char* __bytes2hexstr(void* hex, size_t size, char* str, size_t len) {
static const char* ch = "0123456789abcdef";
__UNUSED(len);
assert(len >= size * 2 + 1);
@@ -41,8 +36,7 @@ char * __bytes2hexstr(void * hex, size_t size, char *str, size_t len)
#define IS_INDEXABLE(arg) (sizeof((arg)[0]))
#define IS_ARRAY(arg) (IS_INDEXABLE(arg) > 0 && (((void *) &(arg)) == ((void *) (arg))))
static inline __attribute__((always_inline))
int8_t hex2dec(char c) {
static inline int8_t hex2dec(char c) {
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
else if (c >= 'a' && c <= 'f')
+1 -4
View File
@@ -325,10 +325,7 @@ void free (void * mem);
# define __attribute_unused __attribute__((unused))
# define __attribute_noinline __attribute__((noinline))
#else
# define __attribute_hidden
# define __attribute_always_inline
# define __attribute_unused
# define __attribute_noinline
# error Unsupported compiler
#endif
#define ALIAS_STR(name) #name