Apply clang-format for core/shared and product-mini files (#785)

Apply clang-format for core/shared and product-mini files
This commit is contained in:
Wenyong Huang
2021-10-14 09:12:07 +08:00
committed by GitHub
parent fb4afc7ca4
commit 17f62ad472
107 changed files with 3436 additions and 2898 deletions

View File

@ -30,7 +30,6 @@ extern "C" {
* 2. To build the app-mgr and app-framework, you must implement it
*/
/**
* Ceates a thread
*
@ -41,8 +40,9 @@ extern "C" {
*
* @return 0 if success.
*/
int os_thread_create(korp_tid *p_tid, thread_start_routine_t start, void *arg,
unsigned int stack_size);
int
os_thread_create(korp_tid *p_tid, thread_start_routine_t start, void *arg,
unsigned int stack_size);
/**
* Creates a thread with priority
@ -55,8 +55,9 @@ int os_thread_create(korp_tid *p_tid, thread_start_routine_t start, void *arg,
*
* @return 0 if success.
*/
int os_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start,
void *arg, unsigned int stack_size, int prio);
int
os_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start,
void *arg, unsigned int stack_size, int prio);
/**
* Waits for the thread specified by thread to terminate
@ -66,7 +67,8 @@ int os_thread_create_with_prio(korp_tid *p_tid, thread_start_routine_t start,
*
* @return return 0 if success
*/
int os_thread_join(korp_tid thread, void **retval);
int
os_thread_join(korp_tid thread, void **retval);
/**
* Detach the thread specified by thread
@ -82,7 +84,8 @@ int os_thread_detach(korp_tid);
*
* @param retval the return value of the current thread
*/
void os_thread_exit(void *retval);
void
os_thread_exit(void *retval);
/**
* Initialize current thread environment if current thread
@ -90,12 +93,14 @@ void os_thread_exit(void *retval);
*
* @return 0 if success, -1 otherwise
*/
int os_thread_env_init();
int
os_thread_env_init();
/**
* Destroy current thread environment
*/
void os_thread_env_destroy();
void
os_thread_env_destroy();
/**
* Suspend execution of the calling thread for (at least)
@ -103,7 +108,8 @@ void os_thread_env_destroy();
*
* @return 0 if success, -1 otherwise
*/
int os_usleep(uint32 usec);
int
os_usleep(uint32 usec);
/**
* Creates a recursive mutex
@ -112,7 +118,8 @@ int os_usleep(uint32 usec);
*
* @return 0 if success
*/
int os_recursive_mutex_init(korp_mutex *mutex);
int
os_recursive_mutex_init(korp_mutex *mutex);
/**
* This function creates a condition variable
@ -121,7 +128,8 @@ int os_recursive_mutex_init(korp_mutex *mutex);
*
* @return 0 if success
*/
int os_cond_init(korp_cond *cond);
int
os_cond_init(korp_cond *cond);
/**
* This function destroys condition variable
@ -130,7 +138,8 @@ int os_cond_init(korp_cond *cond);
*
* @return 0 if success
*/
int os_cond_destroy(korp_cond *cond);
int
os_cond_destroy(korp_cond *cond);
/**
* Wait a condition variable.
@ -140,7 +149,8 @@ int os_cond_destroy(korp_cond *cond);
*
* @return 0 if success
*/
int os_cond_wait(korp_cond *cond, korp_mutex *mutex);
int
os_cond_wait(korp_cond *cond, korp_mutex *mutex);
/**
* Wait a condition varible or return if time specified passes.
@ -151,7 +161,8 @@ int os_cond_wait(korp_cond *cond, korp_mutex *mutex);
*
* @return 0 if success
*/
int os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds);
int
os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds);
/**
* Signals the condition variable
@ -160,7 +171,8 @@ int os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds);
*
* @return 0 if success
*/
int os_cond_signal(korp_cond *cond);
int
os_cond_signal(korp_cond *cond);
#ifdef __cplusplus
}

View File

@ -25,23 +25,28 @@ extern "C" {
*
* @return 0 if success
*/
int bh_platform_init(void);
int
bh_platform_init(void);
/**
* Destroy the platform internal resources if needed,
* this function is called by wasm_runtime_destroy()
*/
void bh_platform_destroy(void);
void
bh_platform_destroy(void);
/**
******** memory allocator APIs **********
*/
void *os_malloc(unsigned size);
void *
os_malloc(unsigned size);
void *os_realloc(void *ptr, unsigned size);
void *
os_realloc(void *ptr, unsigned size);
void os_free(void *ptr);
void
os_free(void *ptr);
/**
* Note: the above APIs can simply return NULL if wasm runtime
@ -49,28 +54,32 @@ void os_free(void *ptr);
* Refer to wasm_runtime_full_init().
*/
int
os_printf(const char *format, ...);
int os_printf(const char *format, ...);
int os_vprintf(const char *format, va_list ap);
int
os_vprintf(const char *format, va_list ap);
/**
* Get microseconds after boot.
*/
uint64 os_time_get_boot_microsecond(void);
uint64
os_time_get_boot_microsecond(void);
/**
* Get current thread id.
* Implementation optional: Used by runtime for logging only.
*/
korp_tid os_self_thread(void);
korp_tid
os_self_thread(void);
/**
* Get current thread's stack boundary address, used for runtime
* to check the native stack overflow. Return NULL if it is not
* easy to implement, but may have potential issue.
*/
uint8 *os_thread_get_stack_boundary(void);
uint8 *
os_thread_get_stack_boundary(void);
/**
************** mutext APIs ***********
@ -78,14 +87,17 @@ uint8 *os_thread_get_stack_boundary(void);
* app-mgr: Must be implemented
*/
int os_mutex_init(korp_mutex *mutex);
int
os_mutex_init(korp_mutex *mutex);
int os_mutex_destroy(korp_mutex *mutex);
int
os_mutex_destroy(korp_mutex *mutex);
int os_mutex_lock(korp_mutex *mutex);
int os_mutex_unlock(korp_mutex *mutex);
int
os_mutex_lock(korp_mutex *mutex);
int
os_mutex_unlock(korp_mutex *mutex);
/**************************************************
* Section 2 *
@ -110,9 +122,12 @@ enum {
MMAP_MAP_FIXED = 2
};
void *os_mmap(void *hint, size_t size, int prot, int flags);
void os_munmap(void *addr, size_t size);
int os_mprotect(void *addr, size_t size, int prot);
void *
os_mmap(void *hint, size_t size, int prot, int flags);
void
os_munmap(void *addr, size_t size);
int
os_mprotect(void *addr, size_t size, int prot);
/**
* Flush cpu data cache, in some CPUs, after applying relocation to the
@ -120,7 +135,8 @@ int os_mprotect(void *addr, size_t size, int prot);
* which may cause unexpected behaviour when executing the AOT code.
* Implement this function if required, or just leave it empty.
*/
void os_dcache_flush(void);
void
os_dcache_flush(void);
#ifdef __cplusplus
}

View File

@ -42,24 +42,27 @@ extern "C" {
__declspec(dllexport) void *BH_MALLOC(unsigned int size);
__declspec(dllexport) void BH_FREE(void *ptr);
#else
__declspec(dllimport) void* BH_MALLOC(unsigned int size);
__declspec(dllimport) void BH_FREE(void* ptr);
__declspec(dllimport) void *BH_MALLOC(unsigned int size);
__declspec(dllimport) void BH_FREE(void *ptr);
#endif
#else
void *BH_MALLOC(unsigned int size);
void BH_FREE(void *ptr);
void *
BH_MALLOC(unsigned int size);
void
BH_FREE(void *ptr);
#endif
#if defined(BH_VPRINTF)
#if defined(MSVC)
__declspec(dllimport) int BH_VPRINTF(const char *format, va_list ap);
#else
int BH_VPRINTF(const char *format, va_list ap);
int
BH_VPRINTF(const char *format, va_list ap);
#endif
#endif
#ifndef NULL
#define NULL (void*)0
#define NULL (void *)0
#endif
#ifndef __cplusplus
@ -99,8 +102,7 @@ typedef double float64;
typedef uint64_t uint64;
typedef int64_t int64;
typedef void* (*thread_start_routine_t)(void*);
typedef void *(*thread_start_routine_t)(void *);
#ifdef __cplusplus
}