* 修改编译方式为CMake
* 删除C++适配代码 * 修改编译告警
This commit is contained in:
23
common/rt/include/rt_common.h
Normal file
23
common/rt/include/rt_common.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef __RT_COMMON_H__
|
||||
#define __RT_COMMON_H__
|
||||
|
||||
#include <assert.h>
|
||||
#define EVAL_TM_STYLE "%Y-%m-%d"
|
||||
|
||||
/** Alway treated the expr as true */
|
||||
#ifndef likely
|
||||
#define likely(expr) __builtin_expect(!!(expr), 1)
|
||||
#endif
|
||||
|
||||
/** Alway treated the expr as false */
|
||||
#ifndef unlikely
|
||||
#define unlikely(expr) __builtin_expect(!!(expr), 0)
|
||||
#endif
|
||||
|
||||
#define __rt_always_inline__ __attribute__((always_inline)) inline
|
||||
|
||||
#define CHECK_OR_EXIT(condition, fmt, ...) \
|
||||
do { if(!(condition)) { mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, fmt, ##__VA_ARGS__); exit(EXIT_FAILURE); } } while(0) \
|
||||
|
||||
|
||||
#endif
|
||||
7
common/rt/include/rt_file.h
Normal file
7
common/rt/include/rt_file.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __RT_FILE_H__
|
||||
#define __RT_FILE_H__
|
||||
|
||||
extern int rt_file_exsit(const char *);
|
||||
extern int rt_dir_exsit (const char *realpath);
|
||||
|
||||
#endif
|
||||
15
common/rt/include/rt_stdlib.h
Normal file
15
common/rt/include/rt_stdlib.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef __RT_STDLIB_H__
|
||||
#define __RT_STDLIB_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/** memory flags */
|
||||
#define MPF_CLR (1 << 0) /** Clear it after allocated */
|
||||
|
||||
extern void kfree(void *p);
|
||||
|
||||
void *kmalloc(int s, int flags, int __attribute__((__unused__)) node);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
74
common/rt/include/rt_string.h
Normal file
74
common/rt/include/rt_string.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef __UTIL_STRING_H__
|
||||
#define __UTIL_STRING_H__
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef STRLEN
|
||||
#define STRLEN(STR) ((int)strlen((const char *)STR))
|
||||
#endif
|
||||
|
||||
#ifndef ISALNUM
|
||||
#define ISALNUM(S) (isalnum((const char)S))
|
||||
#endif
|
||||
|
||||
#ifndef STRCMP
|
||||
#define STRCMP(S,D) (strcmp((const char *)S, (const char *)D))
|
||||
#endif
|
||||
|
||||
#ifndef STRSTR
|
||||
#define STRSTR(D,S) (strstr((const char *)D,(const char *)S))
|
||||
#endif
|
||||
|
||||
#ifndef STRNCMP
|
||||
#define STRNCMP(S,D,L) (strncmp((const char *)S, (const char *)D, L))
|
||||
#endif
|
||||
|
||||
#ifndef STRCAT
|
||||
#define STRCAT(D,S) (strcat((char *)D, (const char *)S))
|
||||
#endif
|
||||
|
||||
#ifndef FOREVER
|
||||
#define FOREVER for(;;)
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
typedef struct atomic {
|
||||
volatile int counter;
|
||||
} atomic_t;
|
||||
|
||||
struct value_string {
|
||||
unsigned int value;
|
||||
const char *strptr;
|
||||
};
|
||||
|
||||
extern const char*
|
||||
val_to_str(const unsigned int val, const struct value_string *vs);
|
||||
|
||||
typedef struct{
|
||||
#define ATOMIC64_SIZE sizeof(long long)
|
||||
int64_t counter;
|
||||
}atomic64_t;
|
||||
|
||||
#define ATOMIC_INIT(i) { (i) }
|
||||
|
||||
#define atomic_read(v) (*(volatile int *)&(v)->counter)
|
||||
#define atomic64_read(v) (*(volatile int64_t *)&(v)->counter)
|
||||
|
||||
#define atomic_add(x, y) (__sync_add_and_fetch((&(((atomic_t *)x)->counter)), (y)))
|
||||
#define atomic64_add(x, y) (__sync_add_and_fetch((&(((atomic64_t *)x)->counter)), (y)))
|
||||
#define atomic64_sub(x, y) (__sync_sub_and_fetch((&(((atomic64_t *)x)->counter)), (y)))
|
||||
|
||||
#define atomic64_inc(x) (atomic64_add((x), 1))
|
||||
#define atomic64_dec(x) (atomic64_sub((x), 1))
|
||||
|
||||
static inline void atomic64_set(atomic64_t *v, int64_t val)
|
||||
{
|
||||
v->counter = val;
|
||||
}
|
||||
|
||||
#endif
|
||||
20
common/rt/include/rt_sync.h
Normal file
20
common/rt/include/rt_sync.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __SYSTEM_SYNC_H__
|
||||
#define __SYSTEM_SYNC_H__
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define rt_pthread_attr pthread_attr_t
|
||||
#define rt_pthread pthread_t
|
||||
#define rt_mutex pthread_mutex_t
|
||||
#define rt_mutex_attr pthread_mutexattr_t
|
||||
#define rt_mutex_init(mut, mutattr ) pthread_mutex_init(mut, mutattr)
|
||||
#define rt_mutex_lock(mut) pthread_mutex_lock(mut)
|
||||
#define rt_mutex_trylock(mut) pthread_mutex_trylock(mut)
|
||||
#define rt_mutex_unlock(mut) pthread_mutex_unlock(mut)
|
||||
#define rt_mutex_destroy(mut) pthread_mutex_destroy(mut)
|
||||
|
||||
#define INIT_MUTEX(name)\
|
||||
rt_mutex name = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
#endif
|
||||
|
||||
12
common/rt/include/rt_time.h
Normal file
12
common/rt/include/rt_time.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __RT_TM_H__
|
||||
#define __RT_TM_H__
|
||||
|
||||
struct tm *rt_localtime(time_t timep, struct tm *result);
|
||||
int rt_tms2str(uint64_t ts, const char *tm_form, char *date, size_t len);
|
||||
int rt_curr_tms2str(const char *tm_form, char *date, size_t len);
|
||||
|
||||
u_int64_t rt_time_s(void);
|
||||
u_int64_t rt_time_ms(void);
|
||||
u_int64_t rt_time_ns();
|
||||
|
||||
#endif
|
||||
25
common/rt/include/rt_tmr.h
Normal file
25
common/rt/include/rt_tmr.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*************************************************************************
|
||||
> File Name: rt_tmr.h
|
||||
> Author:
|
||||
> Mail:
|
||||
> Created Time: 2018年09月19日 星期三 15时58分04秒
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _RT_TMR_H
|
||||
#define _RT_TMR_H
|
||||
|
||||
#define RT_TMR_ADVANCED
|
||||
|
||||
extern void tmr_start(uint32_t uid);
|
||||
extern void tmr_stop(uint32_t uid);
|
||||
|
||||
/**
|
||||
* routine: must be a reentrant function.
|
||||
* An unknown error ocurrs if a thread-safe function called as a routione.
|
||||
*/
|
||||
extern uint32_t tmr_create(int module,
|
||||
const char *desc,
|
||||
void (*routine)(uint32_t, int, char **), int argc, char **argv, int sec);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user