[LibOS] Use struct shim_lock instead of LOCKTYPE

This commit is contained in:
Michał Kowalczyk
2019-05-23 19:13:31 +02:00
parent 48226cda8a
commit 1076fd4fa0
23 changed files with 43 additions and 43 deletions
+2 -2
View File
@@ -168,7 +168,7 @@ struct shim_dentry {
mode_t type;
mode_t mode;
LOCKTYPE lock;
struct shim_lock lock;
REFTYPE ref_count;
};
@@ -339,7 +339,7 @@ int walk_mounts (int (*walk) (struct shim_mount * mount, void * arg),
/* functions for dcache supports */
int init_dcache (void);
extern LOCKTYPE dcache_lock;
extern struct shim_lock dcache_lock;
/* check permission (specified by mask) of a dentry. If force is not set,
* permission is considered granted on invalid dentries */
+4 -4
View File
@@ -69,7 +69,7 @@ enum shim_file_type {
};
struct shim_file_data {
LOCKTYPE lock;
struct shim_lock lock;
struct atomic_int version;
bool queried;
enum shim_file_type type;
@@ -365,7 +365,7 @@ struct shim_handle {
int acc_mode;
IDTYPE owner;
REFTYPE opened;
LOCKTYPE lock;
struct shim_lock lock;
};
/* allocating / manage handle */
@@ -390,8 +390,8 @@ struct shim_handle_map {
FDTYPE fd_top;
/* refrence count and lock */
REFTYPE ref_count;
LOCKTYPE lock;
REFTYPE ref_count;
struct shim_lock lock;
/* An array of file descriptor belong to this mapping */
struct shim_fd_handle ** map;
+12 -12
View File
@@ -475,14 +475,14 @@ static inline void enable_preempt (shim_tcb_t * tcb)
#define DEBUG_LOCK 0
static inline bool __lock_created(LOCKTYPE * l)
static inline bool __lock_created(struct shim_lock* l)
{
return l->lock != NULL;
}
#define lock_created(l) __lock_created(&(l))
static inline void __clear_lock(LOCKTYPE * l)
static inline void __clear_lock(struct shim_lock* l)
{
l->lock = NULL;
l->owner = 0;
@@ -490,7 +490,7 @@ static inline void __clear_lock(LOCKTYPE * l)
#define clear_lock(l) __clear_lock(&(l))
static inline void __create_lock(LOCKTYPE * l)
static inline void __create_lock(struct shim_lock* l)
{
l->lock = DkMutexCreate(0);
/* l->owner = LOCK_FREE; */
@@ -499,14 +499,14 @@ static inline void __create_lock(LOCKTYPE * l)
#define create_lock(l) __create_lock(&(l))
static inline void __destroy_lock(LOCKTYPE * l)
static inline void __destroy_lock(struct shim_lock* l)
{
DkObjectClose(l->lock);
}
#define destroy_lock(l) __destroy_lock(&(l))
static inline void ____try_create_lock(LOCKTYPE * l)
static inline void ____try_create_lock(struct shim_lock* l)
{
if (!__lock_created(l))
__create_lock(l);
@@ -516,11 +516,11 @@ static inline void ____try_create_lock(LOCKTYPE * l)
#if DEBUG_LOCK == 1
# define lock(l) __lock(&(l), #l, __FILE__, __LINE__)
static inline void __lock (LOCKTYPE * l,
static inline void __lock (struct shim_lock* l,
const char * name, const char * file, int line)
#else
# define lock(l) __lock(&(l))
static inline void __lock (LOCKTYPE * l)
static inline void __lock (struct shim_lock* l)
#endif
{
if (!lock_enabled || !l->lock)
@@ -542,11 +542,11 @@ static inline void __lock (LOCKTYPE * l)
#if DEBUG_LOCK == 1
# define unlock(l) __unlock(&(l), #l, __FILE__, __LINE__)
static inline void __unlock (LOCKTYPE * l,
static inline void __unlock (struct shim_lock* l,
const char * name, const char * file, int line)
#else
# define unlock(l) __unlock(&(l))
static inline void __unlock (LOCKTYPE * l)
static inline void __unlock (struct shim_lock* l)
#endif
{
if (!lock_enabled || !l->lock)
@@ -563,7 +563,7 @@ static inline void __unlock (LOCKTYPE * l)
enable_preempt(tcb);
}
static inline bool __locked (LOCKTYPE * l)
static inline bool __locked (struct shim_lock* l)
{
if (!lock_enabled || !l->lock)
return false;
@@ -576,7 +576,7 @@ static inline bool __locked (LOCKTYPE * l)
#define DEBUG_MASTER_LOCK 0
extern LOCKTYPE __master_lock;
extern struct shim_lock __master_lock;
#if DEBUG_MASTER_LOCK == 1
# define master_lock() \
@@ -594,7 +594,7 @@ extern LOCKTYPE __master_lock;
# define master_unlock() do { unlock(__master_lock); } while (0)
#endif
static inline void create_lock_runtime (LOCKTYPE * l)
static inline void create_lock_runtime (struct shim_lock* l)
{
if (!lock_created(*l)) {
master_lock();
+2 -2
View File
@@ -49,7 +49,7 @@ enum { PID_NS, SYSV_NS, TOTAL_NS };
struct shim_process {
IDTYPE vmid;
LOCKTYPE lock;
struct shim_lock lock;
int exit_code;
struct shim_ipc_info * self, * parent;
struct shim_ipc_info * ns[TOTAL_NS];
@@ -97,7 +97,7 @@ struct shim_ipc_port {
LIST_TYPE(shim_ipc_port) hlist;
LIST_TYPE(shim_ipc_port) list;
LISTP_TYPE(shim_ipc_msg_obj) msgs;
LOCKTYPE msgs_lock;
struct shim_lock msgs_lock;
port_fini fini[MAX_IPC_PORT_FINI_CB];
+3 -3
View File
@@ -89,7 +89,7 @@ struct shim_thread {
void * frameptr;
REFTYPE ref_count;
LOCKTYPE lock;
struct shim_lock lock;
#ifdef PROFILE
unsigned long exit_time;
@@ -112,7 +112,7 @@ struct shim_simple_thread {
LIST_TYPE(shim_simple_thread) list;
REFTYPE ref_count;
LOCKTYPE lock;
struct shim_lock lock;
#ifdef PROFILE
unsigned long exit_time;
@@ -246,7 +246,7 @@ static inline void thread_wakeup (struct shim_thread * thread)
DkEventSet(thread->scheduler_event);
}
extern LOCKTYPE thread_list_lock;
extern struct shim_lock thread_list_lock;
struct shim_thread * __lookup_thread (IDTYPE tid);
struct shim_thread * lookup_thread (IDTYPE tid);
+2 -2
View File
@@ -476,10 +476,10 @@ typedef struct atomic_int REFTYPE;
#include <pal.h>
typedef struct shim_lock {
struct shim_lock {
PAL_HANDLE lock;
IDTYPE owner;
} LOCKTYPE;
};
typedef struct shim_aevent {
PAL_HANDLE event;
+1 -1
View File
@@ -32,7 +32,7 @@
#include <pal.h>
#include <pal_error.h>
static LOCKTYPE handle_mgr_lock;
static struct shim_lock handle_mgr_lock;
#define HANDLE_MGR_ALLOC 32
+1 -1
View File
@@ -39,7 +39,7 @@ static IDTYPE tid_alloc_idx __attribute_migratable = 0;
static LISTP_TYPE(shim_thread) thread_list = LISTP_INIT;
DEFINE_LISTP(shim_simple_thread);
static LISTP_TYPE(shim_simple_thread) simple_thread_list = LISTP_INIT;
LOCKTYPE thread_list_lock;
struct shim_lock thread_list_lock;
static IDTYPE internal_tid_alloc_idx = INTERNAL_TID_BASE;
+1 -1
View File
@@ -113,7 +113,7 @@ static MEM_MGR vma_mgr = NULL;
*/
DEFINE_LISTP(shim_vma);
static LISTP_TYPE(shim_vma) vma_list = LISTP_INIT;
static LOCKTYPE vma_list_lock;
static struct shim_lock vma_list_lock;
/*
* Return true if [s, e) is exactly the area represented by vma.
+1 -1
View File
@@ -195,7 +195,7 @@ static struct pid_status_cache {
struct pid_status * status;
} * pid_status_cache;
static LOCKTYPE status_lock;
static struct shim_lock status_lock;
static int proc_match_ipc_thread (const char * name)
{
+1 -1
View File
@@ -32,7 +32,7 @@
#include <list.h>
LOCKTYPE dcache_lock;
struct shim_lock dcache_lock;
#define DCACHE_MGR_ALLOC 64
#define PAGE_SIZE allocsize
+2 -2
View File
@@ -58,7 +58,7 @@ struct shim_mount * builtin_fs [NUM_BUILTIN_FS] = {
&epoll_builtin_fs,
};
static LOCKTYPE mount_mgr_lock;
static struct shim_lock mount_mgr_lock;
#define system_lock() lock(mount_mgr_lock)
#define system_unlock() unlock(mount_mgr_lock)
@@ -73,7 +73,7 @@ static MEM_MGR mount_mgr = NULL;
DEFINE_LISTP(shim_mount);
/* Links to mount->list */
static LISTP_TYPE(shim_mount) mount_list;
static LOCKTYPE mount_list_lock;
static struct shim_lock mount_list_lock;
int init_fs (void)
{
+1 -1
View File
@@ -44,7 +44,7 @@
static MEM_MGR ipc_info_mgr;
LOCKTYPE ipc_info_lock;
struct shim_lock ipc_info_lock;
struct shim_process cur_process;
+1 -1
View File
@@ -73,7 +73,7 @@ static AEVENTTYPE ipc_helper_event;
#define IN_HELPER() \
(ipc_helper_thread && ipc_helper_thread == get_cur_thread())
static LOCKTYPE ipc_helper_lock;
static struct shim_lock ipc_helper_lock;
static struct shim_ipc_port * broadcast_port;
+1 -1
View File
@@ -82,7 +82,7 @@ struct range_bitmap {
/* Helper functions __*_range_*() must be called with range_map_lock held */
static struct range_bitmap * range_map;
static LOCKTYPE range_map_lock;
static struct shim_lock range_map_lock;
#define RANGE_HASH_LEN 6
#define RANGE_HASH_NUM (1 << RANGE_HASH_LEN)
+1 -1
View File
@@ -749,7 +749,7 @@ DEFINE_LISTP(rpcmsg);
DEFINE_LISTP(rpcreq);
static LISTP_TYPE(rpcmsg) rpc_msgs;
static LISTP_TYPE(rpcreq) rpc_reqs;
static LOCKTYPE rpc_queue_lock;
static struct shim_lock rpc_queue_lock;
int get_rpc_msg (IDTYPE * sender, void * buf, int len)
{
+1 -1
View File
@@ -51,7 +51,7 @@ static enum { HELPER_NOTALIVE, HELPER_ALIVE } async_helper_state;
static struct shim_thread * async_helper_thread;
static AEVENTTYPE async_helper_event;
static LOCKTYPE async_helper_lock;
static struct shim_lock async_helper_lock;
/* Returns remaining usecs */
int64_t install_async_event (PAL_HANDLE object, unsigned long time,
+1 -1
View File
@@ -181,7 +181,7 @@ const char ** initial_envp __attribute_migratable;
* never freed or updated. */
char ** library_paths = NULL;
LOCKTYPE __master_lock;
struct shim_lock __master_lock;
bool lock_enabled;
void init_tcb (shim_tcb_t * tcb)
+1 -1
View File
@@ -38,7 +38,7 @@
#include <asm/mman.h>
static LOCKTYPE slab_mgr_lock;
static struct shim_lock slab_mgr_lock;
#define system_lock() lock(slab_mgr_lock)
#define system_unlock() unlock(slab_mgr_lock)
+1 -1
View File
@@ -54,7 +54,7 @@ struct futex_waiter {
// Links shim_futex_handle by the list field
DEFINE_LISTP(shim_futex_handle);
static LISTP_TYPE(shim_futex_handle) futex_list = LISTP_INIT;
static LOCKTYPE futex_list_lock;
static struct shim_lock futex_list_lock;
int shim_do_futex (int * uaddr, int op, int val, void * utime,
int * uaddr2, int val3)
+1 -1
View File
@@ -47,7 +47,7 @@ DEFINE_LISTP(shim_msg_handle);
static LISTP_TYPE(shim_msg_handle) msgq_list;
static LISTP_TYPE(shim_msg_handle) msgq_key_hlist [MSGQ_HASH_NUM];
static LISTP_TYPE(shim_msg_handle) msgq_qid_hlist [MSGQ_HASH_NUM];
static LOCKTYPE msgq_list_lock;
static struct shim_lock msgq_list_lock;
static int __load_msg_persist (struct shim_msg_handle * msgq, bool readmsg);
static int __store_msg_persist(struct shim_msg_handle * msgq);
+1 -1
View File
@@ -48,7 +48,7 @@ DEFINE_LISTP(shim_sem_handle);
static LISTP_TYPE(shim_sem_handle) sem_list;
static LISTP_TYPE(shim_sem_handle) sem_key_hlist [SEM_HASH_NUM];
static LISTP_TYPE(shim_sem_handle) sem_sid_hlist [SEM_HASH_NUM];
static LOCKTYPE sem_list_lock;
static struct shim_lock sem_list_lock;
DEFINE_PROFILE_CATAGORY(sysv_sem, );
+1 -1
View File
@@ -26,7 +26,7 @@
#include <shim_internal.h>
#include <shim_utils.h>
static LOCKTYPE str_mgr_lock;
static struct shim_lock str_mgr_lock;
#define system_lock() lock(str_mgr_lock)
#define system_unlock() unlock(str_mgr_lock)