meta: move photon/libc to root
This commit is contained in:
8
libc/include/assert.h
Normal file
8
libc/include/assert.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef PHOTON_ASSERT_H_
|
||||
#define PHOTON_ASSERT_H_
|
||||
|
||||
#define assert(x) if (!(x)) { __assert_fail(#x, __FUNCTION__, __FILE__, __LINE__); }
|
||||
|
||||
extern void _Noreturn __assert_fail(const char *, const char *, const char *, int);
|
||||
|
||||
#endif
|
||||
27
libc/include/ctype.h
Normal file
27
libc/include/ctype.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef TYPES_H_
|
||||
#define TYPES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int isalnum(int c);
|
||||
extern int isalpha(int c);
|
||||
extern int iscntrl(int c);
|
||||
extern int isdigit(int c);
|
||||
extern int isgraph(int c);
|
||||
extern int islower(int c);
|
||||
extern int isprint(int c);
|
||||
extern int ispunct(int c);
|
||||
extern int isspace(int c);
|
||||
extern int isupper(int c);
|
||||
extern int isxdigit(int c);
|
||||
extern int tolower(int c);
|
||||
extern int toupper(int c);
|
||||
extern int fill_random(unsigned char *buffer, unsigned int size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
14
libc/include/dirent.h
Normal file
14
libc/include/dirent.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef DIRENT_H_
|
||||
#define DIRENT_H_
|
||||
|
||||
#include <sys/_dirent.h>
|
||||
|
||||
extern DIR *opendir(const char *path);
|
||||
extern int closedir(DIR *d);
|
||||
extern struct dirent *readdir(DIR *d);
|
||||
extern int readdir_r(DIR *d, struct dirent *entry, struct dirent **result);
|
||||
extern void rewinddir(DIR *d);
|
||||
extern void seekdir(DIR *d, long int off);
|
||||
extern long int telldir(DIR *d);
|
||||
|
||||
#endif
|
||||
14
libc/include/dlfcn.h
Normal file
14
libc/include/dlfcn.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef DLFCN_H_
|
||||
#define DLFCN_H_
|
||||
|
||||
#define RTLD_LAZY 0
|
||||
#define RTLD_NOW 1
|
||||
#define RTLD_GLOBAL 2
|
||||
#define RTLD_LOCAL 3
|
||||
|
||||
extern void *dlopen(const char *path, int mode);
|
||||
extern void *dlsym(void *handle, const char *name);
|
||||
extern int dlclose(void *handle);
|
||||
extern char *dlerror(void);
|
||||
|
||||
#endif
|
||||
19
libc/include/errno.h
Normal file
19
libc/include/errno.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef ERRNO_H_
|
||||
#define ERRNO_H_
|
||||
|
||||
#include <sys/_errno.h>
|
||||
|
||||
#define errno (__get_errno())
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void __set_errno(int v);
|
||||
extern int __get_errno(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
195
libc/include/inttypes.h
Normal file
195
libc/include/inttypes.h
Normal file
@@ -0,0 +1,195 @@
|
||||
#ifndef INTTYPES_H__
|
||||
#define INTTYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define __PRI_8_LENGTH_MODIFIER__ "hh"
|
||||
#define __PRI_64_LENGTH_MODIFIER__ "ll"
|
||||
#define __SCN_64_LENGTH_MODIFIER__ "ll"
|
||||
#define __PRI_MAX_LENGTH_MODIFIER__ "j"
|
||||
#define __SCN_MAX_LENGTH_MODIFIER__ "j"
|
||||
|
||||
#define PRId8 __PRI_8_LENGTH_MODIFIER__ "d"
|
||||
#define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i"
|
||||
#define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o"
|
||||
#define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u"
|
||||
#define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x"
|
||||
#define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X"
|
||||
|
||||
#define PRId16 "hd"
|
||||
#define PRIi16 "hi"
|
||||
#define PRIo16 "ho"
|
||||
#define PRIu16 "hu"
|
||||
#define PRIx16 "hx"
|
||||
#define PRIX16 "hX"
|
||||
|
||||
#define PRId32 "d"
|
||||
#define PRIi32 "i"
|
||||
#define PRIo32 "o"
|
||||
#define PRIu32 "u"
|
||||
#define PRIx32 "x"
|
||||
#define PRIX32 "X"
|
||||
|
||||
#define PRId64 __PRI_64_LENGTH_MODIFIER__ "d"
|
||||
#define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i"
|
||||
#define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o"
|
||||
#define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u"
|
||||
#define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x"
|
||||
#define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X"
|
||||
|
||||
#define PRIdLEAST8 PRId8
|
||||
#define PRIiLEAST8 PRIi8
|
||||
#define PRIoLEAST8 PRIo8
|
||||
#define PRIuLEAST8 PRIu8
|
||||
#define PRIxLEAST8 PRIx8
|
||||
#define PRIXLEAST8 PRIX8
|
||||
|
||||
#define PRIdLEAST16 PRId16
|
||||
#define PRIiLEAST16 PRIi16
|
||||
#define PRIoLEAST16 PRIo16
|
||||
#define PRIuLEAST16 PRIu16
|
||||
#define PRIxLEAST16 PRIx16
|
||||
#define PRIXLEAST16 PRIX16
|
||||
|
||||
#define PRIdLEAST32 PRId32
|
||||
#define PRIiLEAST32 PRIi32
|
||||
#define PRIoLEAST32 PRIo32
|
||||
#define PRIuLEAST32 PRIu32
|
||||
#define PRIxLEAST32 PRIx32
|
||||
#define PRIXLEAST32 PRIX32
|
||||
|
||||
#define PRIdLEAST64 PRId64
|
||||
#define PRIiLEAST64 PRIi64
|
||||
#define PRIoLEAST64 PRIo64
|
||||
#define PRIuLEAST64 PRIu64
|
||||
#define PRIxLEAST64 PRIx64
|
||||
#define PRIXLEAST64 PRIX64
|
||||
|
||||
#define PRIdFAST8 PRId8
|
||||
#define PRIiFAST8 PRIi8
|
||||
#define PRIoFAST8 PRIo8
|
||||
#define PRIuFAST8 PRIu8
|
||||
#define PRIxFAST8 PRIx8
|
||||
#define PRIXFAST8 PRIX8
|
||||
|
||||
#define PRIdFAST16 PRId16
|
||||
#define PRIiFAST16 PRIi16
|
||||
#define PRIoFAST16 PRIo16
|
||||
#define PRIuFAST16 PRIu16
|
||||
#define PRIxFAST16 PRIx16
|
||||
#define PRIXFAST16 PRIX16
|
||||
|
||||
#define PRIdFAST32 PRId32
|
||||
#define PRIiFAST32 PRIi32
|
||||
#define PRIoFAST32 PRIo32
|
||||
#define PRIuFAST32 PRIu32
|
||||
#define PRIxFAST32 PRIx32
|
||||
#define PRIXFAST32 PRIX32
|
||||
|
||||
#define PRIdFAST64 PRId64
|
||||
#define PRIiFAST64 PRIi64
|
||||
#define PRIoFAST64 PRIo64
|
||||
#define PRIuFAST64 PRIu64
|
||||
#define PRIxFAST64 PRIx64
|
||||
#define PRIXFAST64 PRIX64
|
||||
|
||||
/* int32_t is 'int', but intptr_t is 'long'. */
|
||||
#define PRIdPTR "ld"
|
||||
#define PRIiPTR "li"
|
||||
#define PRIoPTR "lo"
|
||||
#define PRIuPTR "lu"
|
||||
#define PRIxPTR "lx"
|
||||
#define PRIXPTR "lX"
|
||||
|
||||
#define PRIdMAX __PRI_MAX_LENGTH_MODIFIER__ "d"
|
||||
#define PRIiMAX __PRI_MAX_LENGTH_MODIFIER__ "i"
|
||||
#define PRIoMAX __PRI_MAX_LENGTH_MODIFIER__ "o"
|
||||
#define PRIuMAX __PRI_MAX_LENGTH_MODIFIER__ "u"
|
||||
#define PRIxMAX __PRI_MAX_LENGTH_MODIFIER__ "x"
|
||||
#define PRIXMAX __PRI_MAX_LENGTH_MODIFIER__ "X"
|
||||
|
||||
#define SCNd8 __PRI_8_LENGTH_MODIFIER__ "d"
|
||||
#define SCNi8 __PRI_8_LENGTH_MODIFIER__ "i"
|
||||
#define SCNo8 __PRI_8_LENGTH_MODIFIER__ "o"
|
||||
#define SCNu8 __PRI_8_LENGTH_MODIFIER__ "u"
|
||||
#define SCNx8 __PRI_8_LENGTH_MODIFIER__ "x"
|
||||
|
||||
#define SCNd16 "hd"
|
||||
#define SCNi16 "hi"
|
||||
#define SCNo16 "ho"
|
||||
#define SCNu16 "hu"
|
||||
#define SCNx16 "hx"
|
||||
|
||||
#define SCNd32 "d"
|
||||
#define SCNi32 "i"
|
||||
#define SCNo32 "o"
|
||||
#define SCNu32 "u"
|
||||
#define SCNx32 "x"
|
||||
|
||||
#define SCNd64 __SCN_64_LENGTH_MODIFIER__ "d"
|
||||
#define SCNi64 __SCN_64_LENGTH_MODIFIER__ "i"
|
||||
#define SCNo64 __SCN_64_LENGTH_MODIFIER__ "o"
|
||||
#define SCNu64 __SCN_64_LENGTH_MODIFIER__ "u"
|
||||
#define SCNx64 __SCN_64_LENGTH_MODIFIER__ "x"
|
||||
|
||||
#define SCNdLEAST8 SCNd8
|
||||
#define SCNiLEAST8 SCNi8
|
||||
#define SCNoLEAST8 SCNo8
|
||||
#define SCNuLEAST8 SCNu8
|
||||
#define SCNxLEAST8 SCNx8
|
||||
|
||||
#define SCNdLEAST16 SCNd16
|
||||
#define SCNiLEAST16 SCNi16
|
||||
#define SCNoLEAST16 SCNo16
|
||||
#define SCNuLEAST16 SCNu16
|
||||
#define SCNxLEAST16 SCNx16
|
||||
|
||||
#define SCNdLEAST32 SCNd32
|
||||
#define SCNiLEAST32 SCNi32
|
||||
#define SCNoLEAST32 SCNo32
|
||||
#define SCNuLEAST32 SCNu32
|
||||
#define SCNxLEAST32 SCNx32
|
||||
|
||||
#define SCNdLEAST64 SCNd64
|
||||
#define SCNiLEAST64 SCNi64
|
||||
#define SCNoLEAST64 SCNo64
|
||||
#define SCNuLEAST64 SCNu64
|
||||
#define SCNxLEAST64 SCNx64
|
||||
|
||||
#define SCNdFAST8 SCNd8
|
||||
#define SCNiFAST8 SCNi8
|
||||
#define SCNoFAST8 SCNo8
|
||||
#define SCNuFAST8 SCNu8
|
||||
#define SCNxFAST8 SCNx8
|
||||
|
||||
#define SCNdFAST16 SCNd16
|
||||
#define SCNiFAST16 SCNi16
|
||||
#define SCNoFAST16 SCNo16
|
||||
#define SCNuFAST16 SCNu16
|
||||
#define SCNxFAST16 SCNx16
|
||||
|
||||
#define SCNdFAST32 SCNd32
|
||||
#define SCNiFAST32 SCNi32
|
||||
#define SCNoFAST32 SCNo32
|
||||
#define SCNuFAST32 SCNu32
|
||||
#define SCNxFAST32 SCNx32
|
||||
|
||||
#define SCNdFAST64 SCNd64
|
||||
#define SCNiFAST64 SCNi64
|
||||
#define SCNoFAST64 SCNo64
|
||||
#define SCNuFAST64 SCNu64
|
||||
#define SCNxFAST64 SCNx64
|
||||
|
||||
#define SCNdPTR "ld"
|
||||
#define SCNiPTR "li"
|
||||
#define SCNoPTR "lo"
|
||||
#define SCNuPTR "lu"
|
||||
#define SCNxPTR "lx"
|
||||
|
||||
#define SCNdMAX __SCN_MAX_LENGTH_MODIFIER__ "d"
|
||||
#define SCNiMAX __SCN_MAX_LENGTH_MODIFIER__ "i"
|
||||
#define SCNoMAX __SCN_MAX_LENGTH_MODIFIER__ "o"
|
||||
#define SCNuMAX __SCN_MAX_LENGTH_MODIFIER__ "u"
|
||||
#define SCNxMAX __SCN_MAX_LENGTH_MODIFIER__ "x"
|
||||
|
||||
#endif
|
||||
37
libc/include/limits.h
Normal file
37
libc/include/limits.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef LIMITS_H_
|
||||
#define LIMITS_H_
|
||||
|
||||
#include <sys/_fconst.h>
|
||||
|
||||
#define CHAR_BIT 8
|
||||
#define SCHAR_MIN -127
|
||||
#define SCHAR_MAX 127
|
||||
#define UCHAR_MAX 255
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#define MB_LEN_MAX 1
|
||||
#define SHRT_MIN -32767
|
||||
#define SHRT_MAX 32767
|
||||
#define USHRT_MAX 65535
|
||||
#define INT_MIN -2147483648
|
||||
#define INT_MAX 2147483648
|
||||
#define UINT_MAX 4294967295
|
||||
#define LONG_MIN -2147483647
|
||||
#define LONG_MAX 2147483647
|
||||
#define ULONG_MAX 4294967295
|
||||
#define LLONG_MIN -9223372036854775807
|
||||
#define LLONG_MAX 9223372036854775807
|
||||
#define ULLONG_MAX 18446744073709551615
|
||||
#define INT8_MIN SCHAR_MIN
|
||||
#define INT8_MAX SCHAR_MAX
|
||||
#define INT16_MIN SHRT_MIN
|
||||
#define INT16_MAX SHRT_MAX
|
||||
#define INT32_MIN INT_MIN
|
||||
#define INT32_MAX INT_MAX
|
||||
#define INT64_MIN LLONG_MIN
|
||||
#define INT64_MAX LLONG_MAX
|
||||
#define UINT64_MAX ULLONG_MAX
|
||||
|
||||
#define NAME_MAX __FILENAME_MAX
|
||||
|
||||
#endif /* LIMITS_H_ */
|
||||
4
libc/include/locale.h
Normal file
4
libc/include/locale.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef LOCALE_H_
|
||||
#define LOCALE_H_
|
||||
|
||||
#endif
|
||||
249
libc/include/machine/_stdint.h
Normal file
249
libc/include/machine/_stdint.h
Normal file
@@ -0,0 +1,249 @@
|
||||
#ifndef MACHINE__STDINT_H
|
||||
#define MACHINE__STDINT_H
|
||||
|
||||
#define __EXP(x) __##x##__
|
||||
|
||||
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
|
||||
|| ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
|
||||
#define __have_longlong64 1
|
||||
#endif
|
||||
|
||||
#if __EXP(LONG_MAX) > 0x7fffffff
|
||||
#define __have_long64 1
|
||||
#elif __EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
|
||||
#define __have_long32 1
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
#ifdef __INT8_TYPE__
|
||||
typedef __INT8_TYPE__ __int8_t;
|
||||
#ifdef __UINT8_TYPE__
|
||||
typedef __UINT8_TYPE__ __uint8_t;
|
||||
#else
|
||||
typedef unsigned __INT8_TYPE__ __uint8_t;
|
||||
#endif
|
||||
#define ___int8_t_defined 1
|
||||
#elif __EXP(SCHAR_MAX) == 0x7f
|
||||
typedef signed char __int8_t ;
|
||||
typedef unsigned char __uint8_t ;
|
||||
#define ___int8_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT16_TYPE__
|
||||
typedef __INT16_TYPE__ __int16_t;
|
||||
#ifdef __UINT16_TYPE__
|
||||
typedef __UINT16_TYPE__ __uint16_t;
|
||||
#else
|
||||
typedef unsigned __INT16_TYPE__ __uint16_t;
|
||||
#endif
|
||||
#define ___int16_t_defined 1
|
||||
#elif __EXP(INT_MAX) == 0x7fff
|
||||
typedef signed int __int16_t;
|
||||
typedef unsigned int __uint16_t;
|
||||
#define ___int16_t_defined 1
|
||||
#elif __EXP(SHRT_MAX) == 0x7fff
|
||||
typedef signed short __int16_t;
|
||||
typedef unsigned short __uint16_t;
|
||||
#define ___int16_t_defined 1
|
||||
#elif __EXP(SCHAR_MAX) == 0x7fff
|
||||
typedef signed char __int16_t;
|
||||
typedef unsigned char __uint16_t;
|
||||
#define ___int16_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT32_TYPE__
|
||||
typedef __INT32_TYPE__ __int32_t;
|
||||
#ifdef __UINT32_TYPE__
|
||||
typedef __UINT32_TYPE__ __uint32_t;
|
||||
#else
|
||||
typedef unsigned __INT32_TYPE__ __uint32_t;
|
||||
#endif
|
||||
#define ___int32_t_defined 1
|
||||
#elif __EXP(INT_MAX) == 0x7fffffffL
|
||||
typedef signed int __int32_t;
|
||||
typedef unsigned int __uint32_t;
|
||||
#define ___int32_t_defined 1
|
||||
#elif __EXP(LONG_MAX) == 0x7fffffffL
|
||||
typedef signed long __int32_t;
|
||||
typedef unsigned long __uint32_t;
|
||||
#define ___int32_t_defined 1
|
||||
#elif __EXP(SHRT_MAX) == 0x7fffffffL
|
||||
typedef signed short __int32_t;
|
||||
typedef unsigned short __uint32_t;
|
||||
#define ___int32_t_defined 1
|
||||
#elif __EXP(SCHAR_MAX) == 0x7fffffffL
|
||||
typedef signed char __int32_t;
|
||||
typedef unsigned char __uint32_t;
|
||||
#define ___int32_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT64_TYPE__
|
||||
typedef __INT64_TYPE__ __int64_t;
|
||||
#ifdef __UINT64_TYPE__
|
||||
typedef __UINT64_TYPE__ __uint64_t;
|
||||
#else
|
||||
typedef unsigned __INT64_TYPE__ __uint64_t;
|
||||
#endif
|
||||
#define ___int64_t_defined 1
|
||||
#elif __EXP(LONG_MAX) > 0x7fffffff
|
||||
typedef signed long __int64_t;
|
||||
typedef unsigned long __uint64_t;
|
||||
#define ___int64_t_defined 1
|
||||
|
||||
/* GCC has __LONG_LONG_MAX__ */
|
||||
#elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff)
|
||||
typedef signed long long __int64_t;
|
||||
typedef unsigned long long __uint64_t;
|
||||
#define ___int64_t_defined 1
|
||||
|
||||
/* POSIX mandates LLONG_MAX in <limits.h> */
|
||||
#elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff)
|
||||
typedef signed long long __int64_t;
|
||||
typedef unsigned long long __uint64_t;
|
||||
#define ___int64_t_defined 1
|
||||
|
||||
#elif __EXP(INT_MAX) > 0x7fffffff
|
||||
typedef signed int __int64_t;
|
||||
typedef unsigned int __uint64_t;
|
||||
#define ___int64_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST8_TYPE__
|
||||
typedef __INT_LEAST8_TYPE__ __int_least8_t;
|
||||
#ifdef __UINT_LEAST8_TYPE__
|
||||
typedef __UINT_LEAST8_TYPE__ __uint_least8_t;
|
||||
#else
|
||||
typedef unsigned __INT_LEAST8_TYPE__ __uint_least8_t;
|
||||
#endif
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int8_t_defined)
|
||||
typedef __int8_t __int_least8_t;
|
||||
typedef __uint8_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int16_t_defined)
|
||||
typedef __int16_t __int_least8_t;
|
||||
typedef __uint16_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int32_t_defined)
|
||||
typedef __int32_t __int_least8_t;
|
||||
typedef __uint32_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least8_t;
|
||||
typedef __uint64_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST16_TYPE__
|
||||
typedef __INT_LEAST16_TYPE__ __int_least16_t;
|
||||
#ifdef __UINT_LEAST16_TYPE__
|
||||
typedef __UINT_LEAST16_TYPE__ __uint_least16_t;
|
||||
#else
|
||||
typedef unsigned __INT_LEAST16_TYPE__ __uint_least16_t;
|
||||
#endif
|
||||
#define ___int_least16_t_defined 1
|
||||
#elif defined(___int16_t_defined)
|
||||
typedef __int16_t __int_least16_t;
|
||||
typedef __uint16_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#elif defined(___int32_t_defined)
|
||||
typedef __int32_t __int_least16_t;
|
||||
typedef __uint32_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least16_t;
|
||||
typedef __uint64_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST32_TYPE__
|
||||
typedef __INT_LEAST32_TYPE__ __int_least32_t;
|
||||
#ifdef __UINT_LEAST32_TYPE__
|
||||
typedef __UINT_LEAST32_TYPE__ __uint_least32_t;
|
||||
#else
|
||||
typedef unsigned __INT_LEAST32_TYPE__ __uint_least32_t;
|
||||
#endif
|
||||
#define ___int_least32_t_defined 1
|
||||
#elif defined(___int32_t_defined)
|
||||
typedef __int32_t __int_least32_t;
|
||||
typedef __uint32_t __uint_least32_t;
|
||||
#define ___int_least32_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least32_t;
|
||||
typedef __uint64_t __uint_least32_t;
|
||||
#define ___int_least32_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST64_TYPE__
|
||||
typedef __INT_LEAST64_TYPE__ __int_least64_t;
|
||||
#ifdef __UINT_LEAST64_TYPE__
|
||||
typedef __UINT_LEAST64_TYPE__ __uint_least64_t;
|
||||
#else
|
||||
typedef unsigned __INT_LEAST64_TYPE__ __uint_least64_t;
|
||||
#endif
|
||||
#define ___int_least64_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least64_t;
|
||||
typedef __uint64_t __uint_least64_t;
|
||||
#define ___int_least64_t_defined 1
|
||||
#endif
|
||||
|
||||
#if defined(__INTMAX_TYPE__)
|
||||
typedef __INTMAX_TYPE__ __intmax_t;
|
||||
#elif __have_longlong64
|
||||
typedef signed long long __intmax_t;
|
||||
#else
|
||||
typedef signed long __intmax_t;
|
||||
#endif
|
||||
|
||||
#if defined(__UINTMAX_TYPE__)
|
||||
typedef __UINTMAX_TYPE__ __uintmax_t;
|
||||
#elif __have_longlong64
|
||||
typedef unsigned long long __uintmax_t;
|
||||
#else
|
||||
typedef unsigned long __uintmax_t;
|
||||
#endif
|
||||
|
||||
#ifdef __INTPTR_TYPE__
|
||||
typedef __INTPTR_TYPE__ __intptr_t;
|
||||
#ifdef __UINTPTR_TYPE__
|
||||
typedef __UINTPTR_TYPE__ __uintptr_t;
|
||||
#else
|
||||
typedef unsigned __INTPTR_TYPE__ __uintptr_t;
|
||||
#endif
|
||||
#elif defined(__PTRDIFF_TYPE__)
|
||||
typedef __PTRDIFF_TYPE__ __intptr_t;
|
||||
typedef unsigned __PTRDIFF_TYPE__ __uintptr_t;
|
||||
#else
|
||||
typedef long __intptr_t;
|
||||
typedef unsigned long __uintptr_t;
|
||||
#endif
|
||||
|
||||
#ifdef __SIZE_TYPE__
|
||||
typedef __SIZE_TYPE__ __size_t;
|
||||
#else
|
||||
typedef unsigned long long __size_t;
|
||||
#endif
|
||||
|
||||
typedef __int8_t __int_fast8_t;
|
||||
typedef __uint8_t __uint_fast8_t;
|
||||
|
||||
typedef __int16_t __int_fast16_t;
|
||||
typedef __uint16_t __uint_fast16_t;
|
||||
|
||||
typedef __int32_t __int_fast32_t;
|
||||
typedef __uint32_t __uint_fast32_t;
|
||||
|
||||
typedef __int64_t __int_fast64_t;
|
||||
typedef __uint64_t __uint_fast64_t;
|
||||
|
||||
#undef __EXP
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
#endif /* _MACHINE__STDINT_H */
|
||||
20
libc/include/stdarg.h
Normal file
20
libc/include/stdarg.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef STDARG_H
|
||||
#define STDARG_H
|
||||
|
||||
//typedef struct __va_list_tag *va_list;
|
||||
typedef __builtin_va_list va_list;
|
||||
|
||||
# if defined(__GNUC__) && __GNUC__ >= 3
|
||||
#define va_start(ap, arg) __builtin_va_start((ap), (arg))
|
||||
#define va_arg __builtin_va_arg
|
||||
#define va_copy __builtin_va_copy
|
||||
#define va_end(ap) __builtin_va_end((ap))
|
||||
#else
|
||||
#error Unsupported compiler
|
||||
#define va_start(ap, arg) ((ap) = ((va_list)&(arg)) + ((sizeof(long) > sizeof(arg)) ? sizeof(long) : sizeof(arg)))
|
||||
#define va_arg(ap, type) *(type *)(ap), ((ap) += ((sizeof(long) > sizeof(type)) ? sizeof(long) : sizeof(type)))
|
||||
#define va_copy(copy, arg) ((copy) = (arg))
|
||||
#define va_end(ap)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
8
libc/include/stdbool.h
Normal file
8
libc/include/stdbool.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef STDBOOL_H_
|
||||
#define STDBOOL_H_
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif
|
||||
27
libc/include/stddef.h
Normal file
27
libc/include/stddef.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef STDDEF_H_
|
||||
#define STDDEF_H_
|
||||
|
||||
#include "machine/_stdint.h"
|
||||
|
||||
#define NULL ((void *)0)
|
||||
#define offsetof(t, m) ((size_t)&(((t *)0)->m))
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
#ifndef __ptrdiff_t_defined
|
||||
#define __ptrdiff_t_defined
|
||||
typedef __intptr_t ptrdiff_t;
|
||||
#endif
|
||||
|
||||
#ifndef __size_t_defined
|
||||
#define __size_t_defined
|
||||
typedef __size_t size_t;
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
#endif /* STDDEF_H_ */
|
||||
48
libc/include/stdint.h
Normal file
48
libc/include/stdint.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef STDINT_H_
|
||||
#define STDINT_H_
|
||||
|
||||
#include <machine/_stdint.h>
|
||||
|
||||
typedef __int8_t int8_t;
|
||||
typedef __uint8_t uint8_t;
|
||||
|
||||
typedef __int16_t int16_t;
|
||||
typedef __uint16_t uint16_t;
|
||||
|
||||
typedef __int32_t int32_t;
|
||||
typedef __uint32_t uint32_t;
|
||||
|
||||
typedef __int64_t int64_t;
|
||||
typedef __uint64_t uint64_t;
|
||||
|
||||
typedef __intptr_t intptr_t;
|
||||
typedef __uintptr_t uintptr_t;
|
||||
|
||||
typedef __int_least8_t int_least8_t;
|
||||
typedef __uint_least8_t uint_least8_t;
|
||||
|
||||
typedef __int_least16_t int_least16_t;
|
||||
typedef __uint_least16_t uint_least16_t;
|
||||
|
||||
typedef __int_least32_t int_least32_t;
|
||||
typedef __uint_least32_t uint_least32_t;
|
||||
|
||||
typedef __int_least64_t int_least64_t;
|
||||
typedef __uint_least64_t uint_least64_t;
|
||||
|
||||
typedef __int_fast8_t int_fast8_t;
|
||||
typedef __uint_fast8_t uint_fast8_t;
|
||||
|
||||
typedef __int_fast16_t int_fast16_t;
|
||||
typedef __uint_fast16_t uint_fast16_t;
|
||||
|
||||
typedef __int_fast32_t int_fast32_t;
|
||||
typedef __uint_fast32_t uint_fast32_t;
|
||||
|
||||
typedef __int_fast64_t int_fast64_t;
|
||||
typedef __uint_fast64_t uint_fast64_t;
|
||||
|
||||
typedef __intmax_t intmax_t;
|
||||
typedef __uintmax_t uintmax_t;
|
||||
|
||||
#endif /* STDINT_H_ */
|
||||
67
libc/include/stdio.h
Normal file
67
libc/include/stdio.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef STDIO_H_
|
||||
#define STDIO_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/_fconst.h>
|
||||
|
||||
#if defined(__FILENAME_MAX)
|
||||
#define FILENAME_MAX __FILENAME_MAX
|
||||
#else
|
||||
#define FILENAME_MAX 1024
|
||||
#endif
|
||||
|
||||
#define BUFSIZ __FIO_BUFSZ
|
||||
|
||||
#define SEEK_SET __SEEK_SET
|
||||
#define SEEK_CUR __SEEK_CUR
|
||||
#define SEEK_END __SEEK_END
|
||||
|
||||
#define EOF -1
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct __io_file FILE;
|
||||
|
||||
extern FILE *__get_stdio_file(int);
|
||||
|
||||
#define stdin (__get_stdio_file(0))
|
||||
#define stdout (__get_stdio_file(1))
|
||||
#define stderr (__get_stdio_file(2))
|
||||
|
||||
extern FILE *fopen(const char *path, const char *mode);
|
||||
extern FILE *freopen(const char *path, const char *mode, FILE *fp);
|
||||
extern FILE *fdopen(int fd, const char *mode);
|
||||
extern int fclose(FILE *fp);
|
||||
extern int fflush(FILE *fp);
|
||||
extern size_t fread(void *ptr, size_t size, size_t count, FILE *fp);
|
||||
extern size_t fwrite(const void *ptr, size_t size, size_t count, FILE *fp);
|
||||
|
||||
extern int fileno(FILE *fp);
|
||||
extern int fputs(const char *str, FILE *fp);
|
||||
extern int fputc(int c, FILE *fp);
|
||||
extern int fgetc(FILE *fp);
|
||||
extern char *fgets(char *restrict str, int count, FILE *restrict fp);
|
||||
extern int putchar(int c);
|
||||
|
||||
extern int ungetc(int c, FILE *fp);
|
||||
|
||||
extern int printf(const char *restrict format, ...);
|
||||
extern int fprintf(FILE *fp, const char *restrict format, ...);
|
||||
extern int sprintf(char *buf, const char *restrict format, ...);
|
||||
extern int snprintf(char *buf, size_t sz, const char *restrict format, ...);
|
||||
|
||||
extern int vprintf(const char *restrict format, va_list arg);
|
||||
extern int vfprintf(FILE *fp, const char *restrict format, va_list arg);
|
||||
extern int vsprintf(char *buf, const char *restrict format, va_list arg);
|
||||
extern int vsnprintf(char *buf, size_t sz, const char *restrict format, va_list arg);
|
||||
|
||||
extern void perror(const char *s);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
34
libc/include/stdlib.h
Normal file
34
libc/include/stdlib.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef STDLIB_H_
|
||||
#define STDLIB_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern _Noreturn void abort(void);
|
||||
extern _Noreturn void exit(int code);
|
||||
extern void *malloc(size_t sz);
|
||||
extern void *realloc(void *ptr, size_t sz);
|
||||
extern void *calloc(size_t n, size_t sz);
|
||||
extern void free(void *ptr);
|
||||
|
||||
extern int rand(void);
|
||||
extern void srand(unsigned int seed);
|
||||
|
||||
extern int atoi(const char *str);
|
||||
extern double atof(const char *str);
|
||||
extern long strtol(const char *str, char **endptr, int base);
|
||||
extern unsigned long strtoul(const char *str, char **endptr, int base);
|
||||
extern float strtof(const char *str, char **endptr);
|
||||
extern double strtod(const char *str, char **endptr);
|
||||
|
||||
extern char *getenv(const char *name);
|
||||
extern int atexit(void(*fn)(void));
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
39
libc/include/string.h
Normal file
39
libc/include/string.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef STRING_H_
|
||||
#define STRING_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void *memcpy(void *dest, const void *src, size_t sz);
|
||||
extern int memcmp(const void *a, const void *b, size_t sz);
|
||||
extern void *memmove(void *dest, const void *src, size_t sz);
|
||||
extern void *memset(void *ptr, int value, size_t sz);
|
||||
|
||||
extern char *strcat(char *dest, const char *src);
|
||||
|
||||
extern size_t strlen(const char *str);
|
||||
extern int strcmp(const char *a, const char *b);
|
||||
extern int strncmp(const char *a, const char *b, size_t sz);
|
||||
|
||||
extern char *strcpy(char *dest, const char *src);
|
||||
extern char *strncpy(char *dest, const char *src, size_t sz);
|
||||
|
||||
extern char *strchr(const char *str, int ch);
|
||||
extern char *strrchr(const char *s, int c);
|
||||
extern size_t strcspn(const char *str1, const char *str2);
|
||||
|
||||
extern char *strdup(const char *s);
|
||||
|
||||
extern char *strtok(char *s, const char *delim);
|
||||
extern char *strtok_r(char *s, const char *delim, char **sp);
|
||||
|
||||
extern char *strerror(int errnum);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
46
libc/include/time.h
Normal file
46
libc/include/time.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef TIME_H_
|
||||
#define TIME_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/_time.h>
|
||||
|
||||
#define CLOCKS_PER_SEC __SYS_CLOCKS_PER_SEC
|
||||
#define CLOCK_REALTIME __SYS_CLOCK_REALTIME
|
||||
#define CLOCK_MONOTONIC __SYS_CLOCK_MONOTONIC
|
||||
|
||||
struct timespec {
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
};
|
||||
|
||||
extern clock_t clock(void);
|
||||
extern time_t time(time_t *p);
|
||||
|
||||
extern int nanosleep(const struct timespec *req, struct timespec *rem);
|
||||
|
||||
extern struct tm *gmtime(const time_t *timer);
|
||||
extern struct tm *localtime(const time_t *timer);
|
||||
extern time_t mktime(struct tm *timeptr);
|
||||
extern size_t strftime(char *str, size_t max, const char *format, const struct tm *timeptr);
|
||||
|
||||
extern void tzset(void);
|
||||
|
||||
extern int clock_getres(clockid_t clk_id, struct timespec *res);
|
||||
extern int clock_gettime(clockid_t clk_id, struct timespec *tp);
|
||||
extern int clock_settime(clockid_t clk_id, const struct timespec *tp);
|
||||
|
||||
#endif
|
||||
14
libc/include/wchar.h
Normal file
14
libc/include/wchar.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef WCHAR_H_
|
||||
#define WCHAR_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef unsigned int wchar_t;
|
||||
|
||||
extern int fwide(FILE *fp, int mode);
|
||||
|
||||
extern int vfwprintf(FILE *stream, const wchar_t *format, va_list arg);
|
||||
extern int vswprintf(wchar_t *buf, size_t len, const wchar_t *format, va_list arg);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user