155 lines
4.7 KiB
C
155 lines
4.7 KiB
C
/* tccdefs.h
|
|
|
|
Nothing is defined before this file except target machine, target os
|
|
and the few things related to option settings in tccpp.c:tcc_predefs().
|
|
|
|
This file is either included at runtime as is, or converted and
|
|
included as C-strings at compile-time (depending on CONFIG_TCC_PREDEFS).
|
|
*/
|
|
|
|
#define __SIZE_TYPE__ unsigned int
|
|
#define __PTRDIFF_TYPE__ int
|
|
#define __ILP32__ 1
|
|
#define _ILP32 1
|
|
|
|
#define __SIZEOF_INT__ 4
|
|
#define __INT_MAX__ 0x7fffffff
|
|
#define __LONG_MAX__ 0x7fffffffL
|
|
|
|
#define __SIZEOF_LONG_LONG__ 8
|
|
#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
|
|
|
|
#define __CHAR_BIT__ 8
|
|
#define __ORDER_LITTLE_ENDIAN__ 1234
|
|
#define __ORDER_BIG_ENDIAN__ 4321
|
|
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
|
|
|
#define __WCHAR_TYPE__ int
|
|
#define __WINT_TYPE__ int
|
|
|
|
#if __STDC_VERSION__ >= 201112L
|
|
# define __STDC_NO_ATOMICS__ 1
|
|
# define __STDC_NO_COMPLEX__ 1
|
|
# define __STDC_NO_THREADS__ 1
|
|
# define __STDC_UTF_16__ 1
|
|
# define __STDC_UTF_32__ 1
|
|
#endif
|
|
|
|
/* Some derived integer types needed to get stdint.h to compile correctly on some platforms */
|
|
#define __UINTPTR_TYPE__ unsigned __PTRDIFF_TYPE__
|
|
#define __INTPTR_TYPE__ __PTRDIFF_TYPE__
|
|
|
|
#define __UINT8_MAX__ 0xff
|
|
#define __UINT8_TYPE__ unsigned char
|
|
#define __UINT8_C(c) c
|
|
#define __INT8_MAX__ 0x7f
|
|
#define __INT8_TYPE__ signed char
|
|
#define __INT8_C(c) c
|
|
|
|
#define __UINT16_MAX__ 0xffff
|
|
#define __UINT16_TYPE__ short unsigned int
|
|
#define __UINT16_C(c) c
|
|
#define __INT16_MAX__ 0x7fff
|
|
#define __INT16_TYPE__ short int
|
|
#define __INT16_C(c) c
|
|
|
|
#define __UINT32_MAX__ 0xffffffffU
|
|
#define __UINT32_TYPE__ unsigned int
|
|
#define __UINT32_C(c) c ## U
|
|
#define __INT32_MAX__ 0x7fffffff
|
|
#define __INT32_TYPE__ int
|
|
#define __INT32_C(c) c
|
|
|
|
#define __INT64_MAX__ 0x7fffffffffffffffLL
|
|
#define __INT64_TYPE__ long long int
|
|
#define __INT64_C(c) c ## LL
|
|
#define __UINT64_MAX__ 0xffffffffffffffffULL
|
|
#define __UINT64_TYPE__ long long unsigned int
|
|
#define __UINT64_C(c) c ## ULL
|
|
|
|
/* glibc defines. We do not support __USER_NAME_PREFIX__ */
|
|
#define __REDIRECT(name, proto, alias) name proto __asm__ (#alias)
|
|
#define __REDIRECT_NTH(name, proto, alias) name proto __asm__ (#alias) __THROW
|
|
#define __REDIRECT_NTHNL(name, proto, alias) name proto __asm__ (#alias) __THROWNL
|
|
|
|
/* not implemented */
|
|
#define __PRETTY_FUNCTION__ __FUNCTION__
|
|
#define __has_builtin(x) 0
|
|
#define __has_feature(x) 0
|
|
#define __has_attribute(x) 0
|
|
|
|
/* C23 Keywords */
|
|
#define _Nonnull
|
|
#define _Nullable
|
|
#define _Nullable_result
|
|
#define _Null_unspecified
|
|
|
|
/* skip __builtin... with -E */
|
|
#ifndef __TCC_PP__
|
|
|
|
# define __builtin_offsetof(type, field) ((__SIZE_TYPE__)&((type*)0)->field)
|
|
# define __builtin_extract_return_addr(x) x
|
|
|
|
/* __builtin_va_list */
|
|
typedef char *__builtin_va_list;
|
|
# define __builtin_va_start(ap,last) (ap = ((char *)&(last)) + ((sizeof(last)+3)&~3))
|
|
# define __builtin_va_arg(ap,t) (*(t*)((ap+=(sizeof(t)+3)&~3)-((sizeof(t)+3)&~3)))
|
|
|
|
# define __builtin_va_end(ap) (void)(ap)
|
|
# ifndef __builtin_va_copy
|
|
# define __builtin_va_copy(dest, src) (dest) = (src)
|
|
# endif /* !__builtin_va_copy */
|
|
|
|
/* TCC BBUILTIN */
|
|
# ifdef __leading_underscore
|
|
# define __RENAME(X) __asm__("_"X)
|
|
# else
|
|
# define __RENAME(X) __asm__(X)
|
|
# endif
|
|
|
|
|
|
# define __BUILTIN(ret,name,params) ret __builtin_##name params __RENAME(#name);
|
|
|
|
__BUILTIN(void*, memcpy, (void *, const void*, __SIZE_TYPE__))
|
|
__BUILTIN(void*, memmove, (void *, const void*, __SIZE_TYPE__))
|
|
__BUILTIN(void*, memset, (void *, int, __SIZE_TYPE__))
|
|
__BUILTIN(int, memcmp, (const void *, const void*, __SIZE_TYPE__))
|
|
__BUILTIN(__SIZE_TYPE__, strlen, (const char *))
|
|
__BUILTIN(char*, strcpy, (char *, const char *))
|
|
__BUILTIN(char*, strncpy, (char *, const char*, __SIZE_TYPE__))
|
|
__BUILTIN(int, strcmp, (const char*, const char*))
|
|
__BUILTIN(int, strncmp, (const char*, const char*, __SIZE_TYPE__))
|
|
__BUILTIN(char*, strcat, (char*, const char*))
|
|
__BUILTIN(char*, strncat, (char*, const char*, __SIZE_TYPE__))
|
|
__BUILTIN(char*, strchr, (const char*, int))
|
|
__BUILTIN(char*, strrchr, (const char*, int))
|
|
__BUILTIN(char*, strdup, (const char*))
|
|
|
|
|
|
__BUILTIN(void*, malloc, (__SIZE_TYPE__))
|
|
__BUILTIN(void*, realloc, (void *, __SIZE_TYPE__))
|
|
__BUILTIN(void*, calloc, (__SIZE_TYPE__, __SIZE_TYPE__))
|
|
__BUILTIN(void*, memalign, (__SIZE_TYPE__, __SIZE_TYPE__))
|
|
__BUILTIN(void, free, (void*))
|
|
|
|
__BUILTIN(void*, alloca, (__SIZE_TYPE__))
|
|
|
|
__BUILTIN(void, abort, (void))
|
|
|
|
# undef __BUILTIN
|
|
# undef __RENAME
|
|
|
|
# define __BUILTIN_EXTERN(name,u) \
|
|
int __builtin_##name(u int); \
|
|
int __builtin_##name##l(u long); \
|
|
int __builtin_##name##ll(u long long);
|
|
|
|
__BUILTIN_EXTERN(ffs,)
|
|
__BUILTIN_EXTERN(clz, unsigned)
|
|
__BUILTIN_EXTERN(ctz, unsigned)
|
|
__BUILTIN_EXTERN(clrsb,)
|
|
__BUILTIN_EXTERN(popcount, unsigned)
|
|
__BUILTIN_EXTERN(parity, unsigned)
|
|
# undef __BUILTIN_EXTERN
|
|
|
|
#endif /* !__TCC_PP__ */
|