mirror of
https://github.com/google/pebble.git
synced 2025-05-29 14:33:12 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
41
src/libc/include/_ansi.h
Normal file
41
src/libc/include/_ansi.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// this is all magic necessary for pre-ansi compatible code
|
||||
|
||||
#define _PTR void *
|
||||
#define _AND ,
|
||||
#define _NOARGS void
|
||||
#define _CONST const
|
||||
#define _VOLATILE volatile
|
||||
#define _SIGNED signed
|
||||
#define _DOTS , ...
|
||||
#define _VOID void
|
||||
|
||||
#define _EXFUN(name, proto) name proto
|
||||
#define _EXPARM(name, proto) (* name) proto
|
||||
|
||||
#define _DEFUN(name, arglist, args) name(args)
|
||||
#define _DEFUN_VOID(name) name(_NOARGS)
|
||||
#define _CAST_VOID (void)
|
||||
#ifndef _LONG_DOUBLE
|
||||
#define _LONG_DOUBLE long double
|
||||
#endif
|
||||
#ifndef _PARAMS
|
||||
#define _PARAMS(paramlist) paramlist
|
||||
#endif
|
21
src/libc/include/alloca.h
Normal file
21
src/libc/include/alloca.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *alloca(size_t size);
|
68
src/libc/include/ctype.h
Normal file
68
src/libc/include/ctype.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Casts to int ensure that the return value is int, as spec indicates
|
||||
|
||||
// Uppercase
|
||||
#define _CUP (1 << 0)
|
||||
// Lowercase
|
||||
#define _CLO (1 << 1)
|
||||
// Number
|
||||
#define _CNU (1 << 2)
|
||||
// Space
|
||||
#define _CSP (1 << 3)
|
||||
// Punctuation
|
||||
#define _CPU (1 << 4)
|
||||
// Control
|
||||
#define _CCT (1 << 5)
|
||||
// Printable (only for ' ')
|
||||
#define _CPR (1 << 6)
|
||||
// Hex character
|
||||
#define _CHX (1 << 7)
|
||||
|
||||
// ctype flag table for all char values
|
||||
extern const unsigned char __ctype_data[256];
|
||||
|
||||
// Cast to unsigned char to prevent overflow and to map signed char to our range.
|
||||
// This lets us cut out 128 bytes of data from __ctype_data
|
||||
#define __ctype_get(C) (__ctype_data[(unsigned char)(C)])
|
||||
#define __ctype_check(C, FLG) ((int)(__ctype_get(C) & (FLG)))
|
||||
|
||||
#define isalpha(C) __ctype_check(C, _CUP|_CLO)
|
||||
#define isupper(C) __ctype_check(C, _CUP)
|
||||
#define islower(C) __ctype_check(C, _CLO)
|
||||
#define isdigit(C) __ctype_check(C, _CNU)
|
||||
#define isxdigit(C) __ctype_check(C, _CHX|_CNU)
|
||||
#define isspace(C) __ctype_check(C, _CSP)
|
||||
#define ispunct(C) __ctype_check(C, _CPU)
|
||||
#define isalnum(C) __ctype_check(C, _CUP|_CLO|_CNU)
|
||||
#define isprint(C) __ctype_check(C, _CUP|_CLO|_CNU|_CPU|_CPR)
|
||||
#define isgraph(C) __ctype_check(C, _CUP|_CLO|_CNU|_CPU)
|
||||
#define iscntrl(C) __ctype_check(C, _CCT)
|
||||
|
||||
#define isascii(C) ((int)(((unsigned char)(C)) < 0x80))
|
||||
#define toascii(C) ((int)(((unsigned char)(C)) & 0x7F))
|
||||
|
||||
// __typeof__ use is to prevent double-evaluation
|
||||
#define toupper(C) \
|
||||
({ __typeof__(C) X = (C); \
|
||||
islower(X) ? (int)X - 'a' + 'A' : (int)X; })
|
||||
|
||||
#define tolower(C) \
|
||||
({ __typeof__(C) X = (C); \
|
||||
isupper(X) ? (int)X - 'A' + 'a' : (int)X; })
|
314
src/libc/include/inttypes.h
Normal file
314
src/libc/include/inttypes.h
Normal file
|
@ -0,0 +1,314 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// There's no way to check this from the preprocessor, and this header isn't freestanding, so...
|
||||
// If we ever upgrade GCC, we may need to re-evaluate these two.
|
||||
// You can check the types by running `arm-none-eabi-gcc -dM -E - </dev/null` and looking for
|
||||
// __UINT32_TYPE__ and __UINTPTR_TYPE__ respectively.
|
||||
#if defined(__clang__)
|
||||
#define __UINT32_IS_LONG 0
|
||||
#else
|
||||
#define __UINT32_IS_LONG 1
|
||||
#endif
|
||||
#define __UINTPTR_IS_LONG 0
|
||||
|
||||
#define __PRICHAR ""
|
||||
#define __PRISHORT ""
|
||||
#define __PRIINT ""
|
||||
#define __PRILONG "l"
|
||||
#define __PRILLONG "ll"
|
||||
|
||||
#define __PRI8(t) __PRICHAR#t
|
||||
#define __PRI16(t) __PRISHORT#t
|
||||
#if __UINT32_IS_LONG
|
||||
# define __PRI32(t) __PRILONG#t
|
||||
#else
|
||||
# define __PRI32(t) __PRIINT#t
|
||||
#endif
|
||||
|
||||
#define __PRI64(t) __PRILLONG#t
|
||||
|
||||
#if __UINTPTR_IS_LONG
|
||||
#define __PRIPTR(t) __PRILONG#t
|
||||
#else
|
||||
#define __PRIPTR(t) __PRIINT#t
|
||||
#endif
|
||||
|
||||
#ifndef PRId8
|
||||
# define PRId8 __PRI8(d)
|
||||
#endif
|
||||
#ifndef PRIi8
|
||||
# define PRIi8 __PRI8(i)
|
||||
#endif
|
||||
#ifndef PRIo8
|
||||
# define PRIo8 __PRI8(o)
|
||||
#endif
|
||||
#ifndef PRIu8
|
||||
# define PRIu8 __PRI8(u)
|
||||
#endif
|
||||
#ifndef PRIx8
|
||||
# define PRIx8 __PRI8(x)
|
||||
#endif
|
||||
#ifndef PRIX8
|
||||
# define PRIX8 __PRI8(X)
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST8
|
||||
# define PRIdLEAST8 PRId8
|
||||
#endif
|
||||
#ifndef PRIdFAST8
|
||||
# define PRIdFAST8 PRId8
|
||||
#endif
|
||||
#ifndef PRIiLEAST8
|
||||
# define PRIiLEAST8 PRIi8
|
||||
#endif
|
||||
#ifndef PRIiFAST8
|
||||
# define PRIiFAST8 PRIi8
|
||||
#endif
|
||||
#ifndef PRIoLEAST8
|
||||
# define PRIoLEAST8 PRIo8
|
||||
#endif
|
||||
#ifndef PRIoFAST8
|
||||
# define PRIoFAST8 PRIo8
|
||||
#endif
|
||||
#ifndef PRIuLEAST8
|
||||
# define PRIuLEAST8 PRIu8
|
||||
#endif
|
||||
#ifndef PRIuFAST8
|
||||
# define PRIuFAST8 PRIu8
|
||||
#endif
|
||||
#ifndef PRIxLEAST8
|
||||
# define PRIxLEAST8 PRIx8
|
||||
#endif
|
||||
#ifndef PRIxFAST8
|
||||
# define PRIxFAST8 PRIx8
|
||||
#endif
|
||||
#ifndef PRIXLEAST8
|
||||
# define PRIXLEAST8 PRIX8
|
||||
#endif
|
||||
#ifndef PRIXFAST8
|
||||
# define PRIXFAST8 PRIX8
|
||||
#endif
|
||||
|
||||
#ifndef PRId16
|
||||
# define PRId16 __PRI16(d)
|
||||
#endif
|
||||
#ifndef PRIi16
|
||||
# define PRIi16 __PRI16(i)
|
||||
#endif
|
||||
#ifndef PRIo16
|
||||
# define PRIo16 __PRI16(o)
|
||||
#endif
|
||||
#ifndef PRIu16
|
||||
# define PRIu16 __PRI16(u)
|
||||
#endif
|
||||
#ifndef PRIx16
|
||||
# define PRIx16 __PRI16(x)
|
||||
#endif
|
||||
#ifndef PRIX16
|
||||
# define PRIX16 __PRI16(X)
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST16
|
||||
# define PRIdLEAST16 PRId16
|
||||
#endif
|
||||
#ifndef PRIdFAST16
|
||||
# define PRIdFAST16 PRId16
|
||||
#endif
|
||||
#ifndef PRIiLEAST16
|
||||
# define PRIiLEAST16 PRIi16
|
||||
#endif
|
||||
#ifndef PRIiFAST16
|
||||
# define PRIiFAST16 PRIi16
|
||||
#endif
|
||||
#ifndef PRIoLEAST16
|
||||
# define PRIoLEAST16 PRIo16
|
||||
#endif
|
||||
#ifndef PRIoFAST16
|
||||
# define PRIoFAST16 PRIo16
|
||||
#endif
|
||||
#ifndef PRIuLEAST16
|
||||
# define PRIuLEAST16 PRIu16
|
||||
#endif
|
||||
#ifndef PRIuFAST16
|
||||
# define PRIuFAST16 PRIu16
|
||||
#endif
|
||||
#ifndef PRIxLEAST16
|
||||
# define PRIxLEAST16 PRIx16
|
||||
#endif
|
||||
#ifndef PRIxFAST16
|
||||
# define PRIxFAST16 PRIx16
|
||||
#endif
|
||||
#ifndef PRIXLEAST16
|
||||
# define PRIXLEAST16 PRIX16
|
||||
#endif
|
||||
#ifndef PRIXFAST16
|
||||
# define PRIXFAST16 PRIX16
|
||||
#endif
|
||||
|
||||
#ifndef PRId32
|
||||
# define PRId32 __PRI32(d)
|
||||
#endif
|
||||
#ifndef PRIi32
|
||||
# define PRIi32 __PRI32(i)
|
||||
#endif
|
||||
#ifndef PRIo32
|
||||
# define PRIo32 __PRI32(o)
|
||||
#endif
|
||||
#ifndef PRIu32
|
||||
# define PRIu32 __PRI32(u)
|
||||
#endif
|
||||
#ifndef PRIx32
|
||||
# define PRIx32 __PRI32(x)
|
||||
#endif
|
||||
#ifndef PRIX32
|
||||
# define PRIX32 __PRI32(X)
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST32
|
||||
# define PRIdLEAST32 PRId32
|
||||
#endif
|
||||
#ifndef PRIdFAST32
|
||||
# define PRIdFAST32 PRId32
|
||||
#endif
|
||||
#ifndef PRIiLEAST32
|
||||
# define PRIiLEAST32 PRIi32
|
||||
#endif
|
||||
#ifndef PRIiFAST32
|
||||
# define PRIiFAST32 PRIi32
|
||||
#endif
|
||||
#ifndef PRIoLEAST32
|
||||
# define PRIoLEAST32 PRIo32
|
||||
#endif
|
||||
#ifndef PRIoFAST32
|
||||
# define PRIoFAST32 PRIo32
|
||||
#endif
|
||||
#ifndef PRIuLEAST32
|
||||
# define PRIuLEAST32 PRIu32
|
||||
#endif
|
||||
#ifndef PRIuFAST32
|
||||
# define PRIuFAST32 PRIu32
|
||||
#endif
|
||||
#ifndef PRIxLEAST32
|
||||
# define PRIxLEAST32 PRIx32
|
||||
#endif
|
||||
#ifndef PRIxFAST32
|
||||
# define PRIxFAST32 PRIx32
|
||||
#endif
|
||||
#ifndef PRIXLEAST32
|
||||
# define PRIXLEAST32 PRIX32
|
||||
#endif
|
||||
#ifndef PRIXFAST32
|
||||
# define PRIXFAST32 PRIX32
|
||||
#endif
|
||||
|
||||
#ifndef PRId64
|
||||
# define PRId64 __PRI64(d)
|
||||
#endif
|
||||
#ifndef PRIi64
|
||||
# define PRIi64 __PRI64(i)
|
||||
#endif
|
||||
#ifndef PRIo64
|
||||
# define PRIo64 __PRI64(o)
|
||||
#endif
|
||||
#ifndef PRIu64
|
||||
# define PRIu64 __PRI64(u)
|
||||
#endif
|
||||
#ifndef PRIx64
|
||||
# define PRIx64 __PRI64(x)
|
||||
#endif
|
||||
#ifndef PRIX64
|
||||
# define PRIX64 __PRI64(X)
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST64
|
||||
# define PRIdLEAST64 PRId64
|
||||
#endif
|
||||
#ifndef PRIdFAST64
|
||||
# define PRIdFAST64 PRId64
|
||||
#endif
|
||||
#ifndef PRIiLEAST64
|
||||
# define PRIiLEAST64 PRIi64
|
||||
#endif
|
||||
#ifndef PRIiFAST64
|
||||
# define PRIiFAST64 PRIi64
|
||||
#endif
|
||||
#ifndef PRIoLEAST64
|
||||
# define PRIoLEAST64 PRIo64
|
||||
#endif
|
||||
#ifndef PRIoFAST64
|
||||
# define PRIoFAST64 PRIo64
|
||||
#endif
|
||||
#ifndef PRIuLEAST64
|
||||
# define PRIuLEAST64 PRIu64
|
||||
#endif
|
||||
#ifndef PRIuFAST64
|
||||
# define PRIuFAST64 PRIu64
|
||||
#endif
|
||||
#ifndef PRIxLEAST64
|
||||
# define PRIxLEAST64 PRIx64
|
||||
#endif
|
||||
#ifndef PRIxFAST64
|
||||
# define PRIxFAST64 PRIx64
|
||||
#endif
|
||||
#ifndef PRIXLEAST64
|
||||
# define PRIXLEAST64 PRIX64
|
||||
#endif
|
||||
#ifndef PRIXFAST64
|
||||
# define PRIXFAST64 PRIX64
|
||||
#endif
|
||||
|
||||
#ifndef PRIdPTR
|
||||
# define PRIdPTR __PRIPTR(d)
|
||||
#endif
|
||||
#ifndef PRIiPTR
|
||||
# define PRIiPTR __PRIPTR(i)
|
||||
#endif
|
||||
#ifndef PRIoPTR
|
||||
# define PRIoPTR __PRIPTR(o)
|
||||
#endif
|
||||
#ifndef PRIuPTR
|
||||
# define PRIuPTR __PRIPTR(u)
|
||||
#endif
|
||||
#ifndef PRIxPTR
|
||||
# define PRIxPTR __PRIPTR(x)
|
||||
#endif
|
||||
#ifndef PRIXPTR
|
||||
# define PRIXPTR __PRIPTR(X)
|
||||
#endif
|
||||
|
||||
#ifndef PRIdMAX
|
||||
# define PRIdMAX PRId64
|
||||
#endif
|
||||
#ifndef PRIiMAX
|
||||
# define PRIiMAX PRIi64
|
||||
#endif
|
||||
#ifndef PRIoMAX
|
||||
# define PRIoMAX PRIo64
|
||||
#endif
|
||||
#ifndef PRIuMAX
|
||||
# define PRIuMAX PRIu64
|
||||
#endif
|
||||
#ifndef PRIxMAX
|
||||
# define PRIxMAX PRIx64
|
||||
#endif
|
||||
#ifndef PRIXMAX
|
||||
# define PRIXMAX PRIX64
|
||||
#endif
|
72
src/libc/include/locale.h
Normal file
72
src/libc/include/locale.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
// We use newlib's order because why not and it'll make us more compatible.
|
||||
#ifndef LC_ALL
|
||||
# define LC_ALL 0
|
||||
#endif
|
||||
#ifndef LC_COLLATE
|
||||
# define LC_COLLATE 1
|
||||
#endif
|
||||
#ifndef LC_CTYPE
|
||||
# define LC_CTYPE 2
|
||||
#endif
|
||||
#ifndef LC_MONETARY
|
||||
# define LC_MONETARY 3
|
||||
#endif
|
||||
#ifndef LC_NUMERIC
|
||||
# define LC_NUMERIC 4
|
||||
#endif
|
||||
#ifndef LC_TIME
|
||||
# define LC_TIME 5
|
||||
#endif
|
||||
#ifndef LC_MESSAGES
|
||||
# define LC_MESSAGES 6
|
||||
#endif
|
||||
|
||||
struct lconv {
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
char *int_curr_symbol;
|
||||
char *currency_symbol;
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char int_frac_digits;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char int_n_cs_precedes;
|
||||
char int_n_sep_by_space;
|
||||
char int_n_sign_posn;
|
||||
char int_p_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
};
|
||||
|
||||
char *setlocale(int category, const char *locale);
|
23
src/libc/include/math.h
Normal file
23
src/libc/include/math.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef float float_t;
|
||||
|
||||
typedef double double_t;
|
||||
|
||||
double round(double d);
|
44
src/libc/include/setjmp.h
Normal file
44
src/libc/include/setjmp.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Notes:
|
||||
// This is entirely non-portable. It will need to be rewritten if we stop using ARM.
|
||||
// Unfortunately, there is no portable way to define these.
|
||||
// This means unit tests can't use our setjmp/longjmp either.
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __arm__
|
||||
// On ARM at least, GPRs are longs
|
||||
// This still holds on A64.
|
||||
struct __jmp_buf_struct {
|
||||
long r4, r5, r6, r7, r8, r9, sl, fp, sp, lr;
|
||||
// Using real FPU
|
||||
#if defined(__VFP_FP__) && !defined(__SOFTFP__)
|
||||
// FPU registers are still 32bit on A64 though, so they're ints
|
||||
int s[16]; /* s16~s31 */
|
||||
int fpscr;
|
||||
#endif
|
||||
};
|
||||
typedef struct __jmp_buf_struct jmp_buf[1];
|
||||
|
||||
int setjmp(jmp_buf env);
|
||||
void longjmp(jmp_buf buf, int value);
|
||||
#else
|
||||
// other implementations either use system setjmp or don't have it.
|
||||
# include_next <setjmp.h>
|
||||
#endif
|
47
src/libc/include/stdio.h
Normal file
47
src/libc/include/stdio.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#define __need___va_list
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef struct {
|
||||
} FILE;
|
||||
|
||||
// stdio.h isn't supposed to define va_list, so _need___va_list gives us __gnuc_va_list
|
||||
// Let's define that to something less compiler-specific
|
||||
#define __VA_LIST __gnuc_va_list
|
||||
|
||||
int printf(const char *__restrict format, ...)
|
||||
__attribute__((format (printf, 1, 2)));
|
||||
int sprintf(char * restrict str, const char * restrict format, ...)
|
||||
__attribute__((__format__(__printf__, 2, 3)));
|
||||
int snprintf(char * restrict str, size_t size, const char * restrict format, ...)
|
||||
__attribute__((__format__(__printf__, 3, 4)));
|
||||
int vsprintf(char * restrict str, const char * restrict format, __VA_LIST ap)
|
||||
__attribute__((__format__(__printf__, 2, 0)));
|
||||
int vsnprintf(char * restrict str, size_t size, const char * restrict format, __VA_LIST ap)
|
||||
__attribute__((__format__(__printf__, 3, 0)));
|
||||
|
||||
#if !UNITTEST
|
||||
#define sniprintf snprintf
|
||||
#define vsniprintf vsnprintf
|
||||
#endif
|
59
src/libc/include/stdlib.h
Normal file
59
src/libc/include/stdlib.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
#ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
#endif
|
||||
|
||||
// It's an int.
|
||||
#ifndef RAND_MAX
|
||||
# define RAND_MAX (0x7FFFFFFFL)
|
||||
#endif
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
int abs(int j) __attribute__((__const__));
|
||||
long labs(long j) __attribute__((__const__));
|
||||
|
||||
#if __clang__
|
||||
// Default builtins break the clang build for some reason,
|
||||
// and we don't have a real implementation of these functions
|
||||
#define abs(x) __builtin_abs(x)
|
||||
#define labs(x) __builtin_labs(x)
|
||||
#endif
|
||||
|
||||
int atoi(const char *nptr) __attribute__((__pure__));
|
||||
long int atol(const char *nptr) __attribute__((__pure__));
|
||||
long int strtol(const char * restrict nptr, char ** restrict endptr, int base);
|
||||
|
||||
// Implemented in src/fw/util/rand/rand.c
|
||||
int rand(void);
|
||||
int rand_r(unsigned *seed);
|
||||
void srand(unsigned seed);
|
||||
|
||||
void exit(int status) __attribute__((noreturn));
|
||||
|
||||
// Not implemented, but included in the header to build the default platform.c of libs.
|
||||
void free(void *ptr);
|
||||
void *malloc(size_t bytes);
|
45
src/libc/include/string.h
Normal file
45
src/libc/include/string.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t n);
|
||||
void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
|
||||
void *memmove(void *s1, const void *s2, size_t n);
|
||||
void *memset(void *s, int c, size_t n);
|
||||
void *memchr(const void *s, int c, size_t n);
|
||||
char *strcat(char * restrict s1, const char * restrict s2);
|
||||
char *strncat(char * restrict s1, const char * restrict s2, size_t n);
|
||||
size_t strlen(const char *s);
|
||||
size_t strnlen(const char *s, size_t maxlen);
|
||||
char *strcpy(char * restrict s1, const char * restrict s2);
|
||||
char *strncpy(char * restrict s1, const char * restrict s2, size_t n);
|
||||
int strcmp(const char *s1, const char *s2);
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
char *strchr(const char *s, int c);
|
||||
char *strrchr(const char *s, int c);
|
||||
size_t strcspn(const char *s1, const char *s2);
|
||||
size_t strspn(const char *s1, const char *s2);
|
||||
char *strstr(const char *s1, const char *s2);
|
||||
|
||||
int atoi(const char *nptr) __attribute__((__pure__));
|
||||
long int atol(const char *nptr) __attribute__((__pure__));
|
||||
long int strtol(const char * restrict nptr, char ** restrict endptr, int base);
|
||||
unsigned long int strtoul(const char * restrict nptr, char ** restrict endptr, int base);
|
29
src/libc/include/sys/cdefs.h
Normal file
29
src/libc/include/sys/cdefs.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS };
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
|
||||
#define __P(protos) protos
|
||||
#define __CONCAT(x, y) x ## y
|
||||
#define __STRING(x) #x
|
19
src/libc/include/sys/stat.h
Normal file
19
src/libc/include/sys/stat.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// stub
|
29
src/libc/include/sys/types.h
Normal file
29
src/libc/include/sys/types.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
|
||||
// Cheap trick to make __SIZE_TYPE__ give an unsigned version
|
||||
#define unsigned signed
|
||||
typedef __SIZE_TYPE__ ssize_t;
|
||||
#undef unsigned
|
||||
|
||||
typedef signed long int time_t;
|
||||
|
||||
typedef ssize_t off_t;
|
19
src/libc/include/unistd.h
Normal file
19
src/libc/include/unistd.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// stub
|
19
src/libc/include/wchar.h
Normal file
19
src/libc/include/wchar.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// stub
|
19
src/libc/include/wctype.h
Normal file
19
src/libc/include/wctype.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// stub
|
Loading…
Add table
Add a link
Reference in a new issue