pure sdk for main
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
#ifndef _LINUX_UNALIGNED_BYTESHIFT_H
|
||||
#define _LINUX_UNALIGNED_BYTESHIFT_H
|
||||
|
||||
static inline uint16 __get_unaligned_le16(const uint8 *p)
|
||||
{
|
||||
return p[0] | p[1] << 8;
|
||||
}
|
||||
|
||||
static inline uint32 __get_unaligned_le32(const uint8 *p)
|
||||
{
|
||||
return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
|
||||
}
|
||||
|
||||
static inline uint64 __get_unaligned_le64(const uint8 *p)
|
||||
{
|
||||
return (uint64)__get_unaligned_le32(p + 4) << 32 |
|
||||
__get_unaligned_le32(p);
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_le16(uint16 val, uint8 *p)
|
||||
{
|
||||
*p++ = val;
|
||||
*p++ = val >> 8;
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_le32(uint32 val, uint8 *p)
|
||||
{
|
||||
__put_unaligned_le16(val >> 16, p + 2);
|
||||
__put_unaligned_le16(val, p);
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_le64(uint64 val, uint8 *p)
|
||||
{
|
||||
__put_unaligned_le32(val >> 32, p + 4);
|
||||
__put_unaligned_le32(val, p);
|
||||
}
|
||||
|
||||
static inline uint16 get_unaligned_le16(const void *p)
|
||||
{
|
||||
return __get_unaligned_le16((const uint8 *)p);
|
||||
}
|
||||
|
||||
static inline uint32 get_unaligned_le32(const void *p)
|
||||
{
|
||||
return __get_unaligned_le32((const uint8 *)p);
|
||||
}
|
||||
|
||||
static inline uint64 get_unaligned_le64(const void *p)
|
||||
{
|
||||
return __get_unaligned_le64((const uint8 *)p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_le16(uint16 val, void *p)
|
||||
{
|
||||
__put_unaligned_le16(val, (uint8 *)p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_le32(uint32 val, void *p)
|
||||
{
|
||||
__put_unaligned_le32(val, (uint8 *)p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_le64(uint64 val, void *p)
|
||||
{
|
||||
__put_unaligned_le64(val, (uint8 *)p);
|
||||
}
|
||||
|
||||
static inline uint16 __get_unaligned_be16(const uint8 *p)
|
||||
{
|
||||
return p[0] << 8 | p[1];
|
||||
}
|
||||
|
||||
static inline uint32 __get_unaligned_be32(const uint8 *p)
|
||||
{
|
||||
return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
||||
}
|
||||
|
||||
static inline uint64 __get_unaligned_be64(const uint8 *p)
|
||||
{
|
||||
return (uint64)__get_unaligned_be32(p) << 32 |
|
||||
__get_unaligned_be32(p + 4);
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_be16(uint16 val, uint8 *p)
|
||||
{
|
||||
*p++ = val >> 8;
|
||||
*p++ = val;
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_be32(uint32 val, uint8 *p)
|
||||
{
|
||||
__put_unaligned_be16(val >> 16, p);
|
||||
__put_unaligned_be16(val, p + 2);
|
||||
}
|
||||
|
||||
static inline void __put_unaligned_be64(uint64 val, uint8 *p)
|
||||
{
|
||||
__put_unaligned_be32(val >> 32, p);
|
||||
__put_unaligned_be32(val, p + 4);
|
||||
}
|
||||
|
||||
static inline uint16 get_unaligned_be16(const void *p)
|
||||
{
|
||||
return __get_unaligned_be16((const uint8 *)p);
|
||||
}
|
||||
|
||||
static inline uint32 get_unaligned_be32(const void *p)
|
||||
{
|
||||
return __get_unaligned_be32((const uint8 *)p);
|
||||
}
|
||||
|
||||
static inline uint64 get_unaligned_be64(const void *p)
|
||||
{
|
||||
return __get_unaligned_be64((const uint8 *)p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_be16(uint16 val, void *p)
|
||||
{
|
||||
__put_unaligned_be16(val, (uint8 *)p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_be32(uint32 val, void *p)
|
||||
{
|
||||
__put_unaligned_be32(val, (uint8 *)p);
|
||||
}
|
||||
|
||||
static inline void put_unaligned_be64(uint64 val, void *p)
|
||||
{
|
||||
__put_unaligned_be64(val, (uint8 *)p);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */
|
||||
@@ -0,0 +1,144 @@
|
||||
#ifndef _OHOS_DEFS_H_
|
||||
#define _OHOS_DEFS_H_
|
||||
#include "los_interrupt.h"
|
||||
#include "los_debug.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define osWaitForever (-1)
|
||||
|
||||
#define ASSERT LOS_ASSERT
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#ifndef __inline
|
||||
#define __inline inline
|
||||
#endif
|
||||
|
||||
#ifndef __weak
|
||||
#define __weak __attribute__((weak))
|
||||
#endif
|
||||
|
||||
#ifndef __alias
|
||||
#define __alias(f) __attribute__((alias(#f)))
|
||||
#endif
|
||||
|
||||
#ifndef __at_section
|
||||
#define __at_section(sec) __attribute__((section(sec)))
|
||||
#endif
|
||||
|
||||
#ifndef __used
|
||||
#define __used __attribute__((used))
|
||||
#endif
|
||||
|
||||
#ifndef __aligned
|
||||
#define __aligned(n) __attribute__((aligned(n)))
|
||||
#endif
|
||||
|
||||
#ifndef __packed
|
||||
#define __packed __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#ifndef __init
|
||||
//#define __init __at_section("INIT.TXT")
|
||||
#define __init
|
||||
#endif
|
||||
|
||||
#ifndef __initdata
|
||||
//#define __initdata __at_section("INIT.DAT")
|
||||
#define __initdata
|
||||
#endif
|
||||
|
||||
#ifndef __initconst
|
||||
//#define __initconst __at_section("INIT.RO")
|
||||
#define __initconst
|
||||
#endif
|
||||
|
||||
#ifndef __rom
|
||||
//#define __rom __at_section(".rom.text")
|
||||
#define __rom
|
||||
#endif
|
||||
|
||||
#ifndef __romro
|
||||
//#define __romro __at_section(".rom.ro")
|
||||
#define __romro
|
||||
#endif
|
||||
|
||||
#ifndef __ram
|
||||
//#define __ram __at_section(".ram.text")
|
||||
#define __ram
|
||||
#endif
|
||||
|
||||
#ifndef __bobj
|
||||
//#define __bobj __at_section(".bobj")
|
||||
#define __bobj
|
||||
#endif
|
||||
|
||||
#ifndef __dsleep_text
|
||||
//#define __dsleep_text __at_section(".dsleep.text")
|
||||
#define __dsleep_text
|
||||
#endif
|
||||
|
||||
#ifndef __dsleep_date
|
||||
//#define __dsleep_date __at_section(".dsleep.data")
|
||||
#define __dsleep_date
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(a) (1UL << (a))
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((long) &((type *) 0)->member)
|
||||
#endif
|
||||
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
void *__mptr = (void *)(ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
#ifndef RETURN_ADDR
|
||||
#define RETURN_ADDR() __builtin_return_address(0)
|
||||
#endif
|
||||
|
||||
#ifndef __always_inline
|
||||
#define __always_inline inline
|
||||
#endif
|
||||
|
||||
#ifndef ASSERT_HOLDUP
|
||||
#define ASSERT_HOLDUP 0
|
||||
#endif
|
||||
|
||||
#ifndef ATCMD_ARGS_COUNT
|
||||
#define ATCMD_ARGS_COUNT (16)
|
||||
#endif
|
||||
|
||||
#ifndef ATCMD_PRINT_BUF_SIZE
|
||||
#define ATCMD_PRINT_BUF_SIZE (256)
|
||||
#endif
|
||||
|
||||
static int inline min(int a, int b)
|
||||
{
|
||||
return ((a)<(b)?(a):(b));
|
||||
}
|
||||
static int inline max(int a, int b)
|
||||
{
|
||||
return ((a)>(b)?(a):(b));
|
||||
}
|
||||
|
||||
#define cpu_dcache_disable() csi_dcache_clean_invalid(); csi_dcache_disable();
|
||||
#define cpu_dcache_enable() csi_dcache_enable()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef __CSKY_SLEEP_H_
|
||||
#define __CSKY_SLEEP_H_
|
||||
#include "los_tick.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define os_jiffies_to_msecs(j) LOS_Tick2MS(j)
|
||||
#define os_msecs_to_jiffies(m) LOS_MS2Tick(m)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
|
||||
#ifndef _OS_CSKY_STDLIB_H_
|
||||
#define _OS_CSKY_STDLIB_H_
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "osal/sleep.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef os_malloc
|
||||
#define os_malloc(s) malloc(s)
|
||||
#endif
|
||||
#ifndef os_free
|
||||
#define os_free(p) do{ free((void *)p); (p)=NULL;}while(0)
|
||||
#endif
|
||||
#ifndef os_zalloc
|
||||
#define os_zalloc(s) zalloc(s)
|
||||
#endif
|
||||
#ifndef os_realloc
|
||||
#define os_realloc(p,s) realloc(p,s)
|
||||
#endif
|
||||
#ifndef os_calloc
|
||||
#define os_calloc(p,s) calloc(p, s)
|
||||
#endif
|
||||
|
||||
#ifndef os_malloc_psram
|
||||
#define os_malloc_psram(s) _os_malloc_psram(s)
|
||||
#endif
|
||||
#ifndef os_free_psram
|
||||
#define os_free_psram(p) do{ _os_free_psram((void *)p); (p)=NULL;}while(0)
|
||||
#endif
|
||||
#ifndef os_zalloc_psram
|
||||
#define os_zalloc_psram(s) _os_zalloc_psram(s)
|
||||
#endif
|
||||
#ifndef os_realloc_psram
|
||||
#define os_realloc_psram(p,s) _os_realloc_psram(p,s)
|
||||
#endif
|
||||
#ifndef os_calloc_psram
|
||||
#define os_calloc_psram(p,s) _os_calloc_psram(p, s)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MEM_TRACE
|
||||
#define os_strcpy(d,s) _os_strcpy((char *)(d), (const char *)(s))
|
||||
#define os_strncpy(d,s,n) _os_strncpy((char *)(d), (const char *)(s), n)
|
||||
#define os_memset(s,c,n) _os_memset((void *)(s), c, n)
|
||||
#define os_memcpy(d,s,n) _os_memcpy((void *)(d), (const void *)(s), n)
|
||||
#define os_memmove(d,s,n) _os_memmove((void *)(d), (const void *)(s), n)
|
||||
#define os_sprintf(s, ...) _os_sprintf((char *)(s), __VA_ARGS__)
|
||||
#define os_vsnprintf _os_vsnprintf
|
||||
#define os_snprintf _os_snprintf
|
||||
#else
|
||||
#define os_strcpy(d,s) strcpy((char *)(d), (const char *)(s))
|
||||
#define os_strncpy(d,s,n) strncpy((char *)(d), (const char *)(s), n)
|
||||
#define os_memset(s,c,n) memset((void *)(s), c, n)
|
||||
#define os_memcpy(d,s,n) memcpy((void *)(d), (const void *)(s), n)
|
||||
#define os_memmove(d,s,n) memmove((void *)(d), (const void *)(s), n)
|
||||
#define os_sprintf(s, ...) sprintf((char *)(s), __VA_ARGS__)
|
||||
#define os_vsnprintf vsnprintf
|
||||
#define os_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#define os_abs abs
|
||||
#define os_atoi(c) atoi((const char *)c)
|
||||
#define os_atol(c) atol((const char *)c)
|
||||
#define os_atoll(c) atoll((const char *)c)
|
||||
#define os_atof(c) atof((const char *)c)
|
||||
#define os_strcmp(s1,s2) strcmp((const char *)(s1), (const char *)(s2))
|
||||
#define os_strstr(s1,s2) strstr((const char *)(s1), (const char *)(s2))
|
||||
#define os_strchr(s,c) strchr((const char *)(s), c)
|
||||
#define os_strlen(s) strlen((const char *)(s))
|
||||
#define os_memcmp(s1,s2,n) memcmp((const void *)(s1), (const void *)(s2), n)
|
||||
#define os_strncmp(s1,s2,n) strncmp((const char *)s1, (const char *)s2, n)
|
||||
#define os_strrchr(s,c) strrchr((const char *)(s), c)
|
||||
#define os_strncasecmp(s1,s2,n) strncasecmp((const char *)(s1), (const char *)(s2), n)
|
||||
#define os_strcasecmp(s1,s2) strcasecmp((const char *)(s1), (const char *)(s2))
|
||||
#define os_srand(v) srand(v)
|
||||
#define os_rand() rand()
|
||||
#define os_sscanf sscanf
|
||||
#define os_htons(x) ((((x) & (uint16)0x00ffUL) << 8) | (((x) & (uint16)0xff00UL) >> 8))
|
||||
#define os_ntohs(x) os_htons(x)
|
||||
#define os_htonl(x) ((((x) & (uint32)0x000000ffUL) << 24) | \
|
||||
(((x) & (uint32)0x0000ff00UL) << 8) | \
|
||||
(((x) & (uint32)0x00ff0000UL) >> 8) | \
|
||||
(((x) & (uint32)0xff000000UL) >> 24))
|
||||
#define os_ntohl(x) os_htonl(x)
|
||||
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
char *os_strdup(const char *s);
|
||||
uint32 os_atoh(char *str);
|
||||
uint64 os_atohl(char *str);
|
||||
|
||||
void *zalloc(size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
|
||||
#ifndef __CSKY_OS_TIME_H_
|
||||
#define __CSKY_OS_TIME_H_
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __NEWLIB__
|
||||
#include <sys/timespec.h>
|
||||
|
||||
|
||||
#if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED)
|
||||
typedef uint64 time_t;
|
||||
#define __time_t_defined
|
||||
#define _TIME_T_DECLARED
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _USECONDS_T_DECLARED
|
||||
typedef unsigned long useconds_t; /* microseconds (unsigned) */
|
||||
#define _USECONDS_T_DECLARED
|
||||
#endif
|
||||
|
||||
#if !defined(_CLOCKID_T_DECLARED)
|
||||
typedef unsigned long clockid_t;
|
||||
#define __clockid_t_defined
|
||||
#define _CLOCKID_T_DECLARED
|
||||
#endif
|
||||
|
||||
#if !defined(__timer_t_defined) && !defined(_TIMER_T_DECLARED)
|
||||
typedef unsigned long timer_t;
|
||||
#define __timer_t_defined
|
||||
#define _TIMER_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _SYS_TIMESPEC_H_
|
||||
struct itimerspec {
|
||||
struct timespec it_interval; /**< Timer period. */
|
||||
struct timespec it_value; /**< Timer expiration. */
|
||||
};
|
||||
#endif
|
||||
|
||||
/*struct timeval */
|
||||
/* Convenience macros for operations on timevals.
|
||||
NOTE: `timercmp' does not work for >= or <=. */
|
||||
#ifndef timerisset
|
||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||
#endif
|
||||
|
||||
#ifndef timerclear
|
||||
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
|
||||
#endif
|
||||
|
||||
#ifndef timercmp
|
||||
#define timercmp(a, b, CMP) \
|
||||
(((a)->tv_sec == (b)->tv_sec) ? \
|
||||
((a)->tv_usec CMP (b)->tv_usec) : \
|
||||
((a)->tv_sec CMP (b)->tv_sec))
|
||||
#endif
|
||||
|
||||
#if 1 //see: posix/timer.c
|
||||
|
||||
#ifndef timeradd
|
||||
#define timeradd(a, b, result) \
|
||||
do { \
|
||||
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
|
||||
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
|
||||
if ((result)->tv_usec >= 1000000) \
|
||||
{ \
|
||||
++(result)->tv_sec; \
|
||||
(result)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef timersub
|
||||
#define timersub(a, b, result) \
|
||||
do { \
|
||||
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
|
||||
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
|
||||
if ((result)->tv_usec < 0) { \
|
||||
--(result)->tv_sec; \
|
||||
(result)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
extern int32 settimeofday(const struct timeval *tv, const struct timezone *tz);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
#ifndef __CSKY_TYPESDEF_H_
|
||||
#define __CSKY_TYPESDEF_H_
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//typedef enum { FALSE=0, TRUE=1, false=0, true=1} bool;
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed int int32;
|
||||
typedef signed long long int64;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
#ifndef _SIZE_T_DECLARED
|
||||
typedef unsigned int size_t;
|
||||
#define _SIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T_DECLARED
|
||||
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
|
||||
typedef int ssize_t;
|
||||
#else
|
||||
typedef long ssize_t;
|
||||
#endif
|
||||
#define _SSIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
typedef unsigned long ulong;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "byteshift.h"
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user