mirror of
https://github.com/google/pebble.git
synced 2025-07-04 13:57:04 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
72
platform/tintin/boot/libc/ctype_ptr.c
Normal file
72
platform/tintin/boot/libc/ctype_ptr.c
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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements: (sorta)
|
||||
// int isalpha(int c);
|
||||
// int isupper(int c);
|
||||
// int islower(int c);
|
||||
// int isdigit(int c);
|
||||
// int isxdigit(int c);
|
||||
// int isspace(int c);
|
||||
// int ispunct(int c);
|
||||
// int isalnum(int c);
|
||||
// int isprint(int c);
|
||||
// int isgraph(int c);
|
||||
// int iscntrl(int c);
|
||||
// int isascii(int c);
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
// Ordered for unsigned char
|
||||
const unsigned char __ctype_data[256] = {
|
||||
// ASCII set
|
||||
// These values can't change. Look at ctype.h for information on these macros.
|
||||
// +00 +01 +02 +03 +04 +05 +06 +07
|
||||
_CCT, _CCT, _CCT, _CCT, _CCT, _CCT, _CCT, _CCT, // 00
|
||||
_CCT, _CCT|_CSP, _CCT|_CSP, _CCT|_CSP, _CCT|_CSP, _CCT|_CSP, _CCT, _CCT, // 08
|
||||
_CCT, _CCT, _CCT, _CCT, _CCT, _CCT, _CCT, _CCT, // 10
|
||||
_CCT, _CCT, _CCT, _CCT, _CCT, _CCT, _CCT, _CCT, // 18
|
||||
_CSP|_CPR, _CPU, _CPU, _CPU, _CPU, _CPU, _CPU, _CPU, // 20
|
||||
_CPU, _CPU, _CPU, _CPU, _CPU, _CPU, _CPU, _CPU, // 28
|
||||
_CNU, _CNU, _CNU, _CNU, _CNU, _CNU, _CNU, _CNU, // 30
|
||||
_CNU, _CNU, _CPU, _CPU, _CPU, _CPU, _CPU, _CPU, // 38
|
||||
_CPU, _CUP|_CHX, _CUP|_CHX, _CUP|_CHX, _CUP|_CHX, _CUP|_CHX, _CUP|_CHX, _CUP, // 40
|
||||
_CUP, _CUP, _CUP, _CUP, _CUP, _CUP, _CUP, _CUP, // 48
|
||||
_CUP, _CUP, _CUP, _CUP, _CUP, _CUP, _CUP, _CUP, // 50
|
||||
_CUP, _CUP, _CUP, _CPU, _CPU, _CPU, _CPU, _CPU, // 58
|
||||
_CPU, _CLO|_CHX, _CLO|_CHX, _CLO|_CHX, _CLO|_CHX, _CLO|_CHX, _CLO|_CHX, _CLO, // 60
|
||||
_CLO, _CLO, _CLO, _CLO, _CLO, _CLO, _CLO, _CLO, // 68
|
||||
_CLO, _CLO, _CLO, _CLO, _CLO, _CLO, _CLO, _CLO, // 70
|
||||
_CLO, _CLO, _CLO, _CPU, _CPU, _CPU, _CPU, _CCT, // 78
|
||||
// Non-ASCII set
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
68
platform/tintin/boot/libc/include/ctype.h
Normal file
68
platform/tintin/boot/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; })
|
310
platform/tintin/boot/libc/include/inttypes.h
Normal file
310
platform/tintin/boot/libc/include/inttypes.h
Normal file
|
@ -0,0 +1,310 @@
|
|||
/*
|
||||
* 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.
|
||||
#define __UINT32_IS_LONG 1
|
||||
#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
|
40
platform/tintin/boot/libc/include/stdlib.h
Normal file
40
platform/tintin/boot/libc/include/stdlib.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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__));
|
||||
|
||||
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);
|
44
platform/tintin/boot/libc/include/string.h
Normal file
44
platform/tintin/boot/libc/include/string.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.
|
||||
*/
|
||||
|
||||
#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);
|
37
platform/tintin/boot/libc/string/atoi.c
Normal file
37
platform/tintin/boot/libc/string/atoi.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// int atoi(const char *nptr);
|
||||
// long int atol(const char *nptr);
|
||||
///////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
|
||||
intmax_t strtoX_core(const char * restrict nptr, char ** restrict endptr, int base, bool do_errors,
|
||||
intmax_t max, intmax_t min);
|
||||
|
||||
int atoi(const char *nptr) {
|
||||
return strtoX_core(nptr, NULL, 10, false, INT_MAX, INT_MIN);
|
||||
}
|
||||
|
||||
long int atol(const char *nptr) {
|
||||
return strtoX_core(nptr, NULL, 10, false, INT_MAX, INT_MIN);
|
||||
}
|
32
platform/tintin/boot/libc/string/memchr.c
Normal file
32
platform/tintin/boot/libc/string/memchr.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// void *memchr(const void *s, int c, size_t n);
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *memchr(const void *s, int c, size_t n) {
|
||||
const unsigned char *p = (const unsigned char*)s;
|
||||
unsigned char ch = (unsigned char)c;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (p[i] == ch) {
|
||||
return (void*)&p[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
35
platform/tintin/boot/libc/string/memcmp.c
Normal file
35
platform/tintin/boot/libc/string/memcmp.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// int memcmp(const void *s1, const void *s2, size_t n);
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t n) {
|
||||
const unsigned char *p1 = (const unsigned char*)s1;
|
||||
const unsigned char *p2 = (const unsigned char*)s2;
|
||||
while (n--) {
|
||||
int diff = *p1 - *p2;
|
||||
if (diff) {
|
||||
return diff;
|
||||
}
|
||||
p1++;
|
||||
p2++;
|
||||
}
|
||||
return 0;
|
||||
}
|
48
platform/tintin/boot/libc/string/memcpy.c
Normal file
48
platform/tintin/boot/libc/string/memcpy.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// void *memcpy(void *s1, const void *s2, size_t n);
|
||||
// void *memmove(void *s1, const void *s2, size_t n);
|
||||
///////////////////////////////////////
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void *memcpy(void * restrict s1, const void * restrict s2, size_t n) {
|
||||
char *dest = (char*)s1;
|
||||
const char *src = (const char*)s2;
|
||||
while (n--) {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
void *memmove(void * restrict s1, const void * restrict s2, size_t n) {
|
||||
char *dest = (char*)s1;
|
||||
const char *src = (const char*)s2;
|
||||
if (dest <= src) {
|
||||
while (n--) {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
} else {
|
||||
while (n--) {
|
||||
dest[n] = src[n];
|
||||
}
|
||||
}
|
||||
return s1;
|
||||
}
|
30
platform/tintin/boot/libc/string/memset.c
Normal file
30
platform/tintin/boot/libc/string/memset.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// void *memset(void *s, int c, size_t n);
|
||||
///////////////////////////////////////
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *memset(void *s, int c, size_t n) {
|
||||
unsigned char *p = (unsigned char*)s;
|
||||
while (n--) {
|
||||
*p++ = (unsigned char)c;
|
||||
}
|
||||
return s;
|
||||
}
|
45
platform/tintin/boot/libc/string/strcat.c
Normal file
45
platform/tintin/boot/libc/string/strcat.c
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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// char *strcat(char *s1, const char *s2);
|
||||
// char *strncat(char *s1, const char *s2, size_t n);
|
||||
///////////////////////////////////////
|
||||
// Notes:
|
||||
// Tuned for code size.
|
||||
|
||||
#include <string.h>
|
||||
|
||||
char *strcat(char * restrict s1, const char * restrict s2) {
|
||||
char *rc = s1;
|
||||
s1 += strlen(s1);
|
||||
strcpy(s1, s2);
|
||||
return rc;
|
||||
}
|
||||
|
||||
char *strncat(char * restrict s1, const char * restrict s2, size_t n) {
|
||||
char * rc = s1;
|
||||
s1 += strlen(s1);
|
||||
|
||||
size_t strn = strlen(s2);
|
||||
if (strn > n) {
|
||||
strn = n;
|
||||
}
|
||||
memcpy(s1, s2, strn);
|
||||
s1[strn] = '\0';
|
||||
return rc;
|
||||
}
|
40
platform/tintin/boot/libc/string/strchr.c
Normal file
40
platform/tintin/boot/libc/string/strchr.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// char *strchr(const char *s1, int c);
|
||||
// char *strrchr(const char *s1, int c);
|
||||
///////////////////////////////////////
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
char *strchr(const char *s, int c) {
|
||||
size_t n = strlen(s) + 1;
|
||||
return memchr(s, c, n);
|
||||
}
|
||||
|
||||
char *strrchr(const char *s, int c) {
|
||||
char ch = (char)c;
|
||||
size_t i = strlen(s);
|
||||
do {
|
||||
if (s[i] == ch) {
|
||||
return (char*)&s[i];
|
||||
}
|
||||
} while (i--);
|
||||
return NULL;
|
||||
}
|
39
platform/tintin/boot/libc/string/strcmp.c
Normal file
39
platform/tintin/boot/libc/string/strcmp.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// int strcmp(const char *s1, const char *s2);
|
||||
// int strncmp(const char *s1, const char *s2, size_t n);
|
||||
///////////////////////////////////////
|
||||
// Notes:
|
||||
// Tuned for code size.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
int strcmp(const char *s1, const char *s2) {
|
||||
size_t n = strlen(s1) + 1;
|
||||
return memcmp(s1, s2, n);
|
||||
}
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t n) {
|
||||
size_t strn = strlen(s1) + 1;
|
||||
if (strn < n) {
|
||||
n = strn;
|
||||
}
|
||||
return memcmp(s1, s2, n);
|
||||
}
|
44
platform/tintin/boot/libc/string/strcpy.c
Normal file
44
platform/tintin/boot/libc/string/strcpy.c
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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// char *strcpy(char *s1, const char *s2);
|
||||
// char *strncpy(char *s1, const char *s2, size_t n);
|
||||
///////////////////////////////////////
|
||||
// Notes:
|
||||
// Tuned for code size.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
char *strcpy(char * restrict s1, const char * restrict s2) {
|
||||
size_t n = strlen(s2) + 1;
|
||||
return memcpy(s1, s2, n);
|
||||
}
|
||||
|
||||
char *strncpy(char * restrict s1, const char * restrict s2, size_t n) {
|
||||
char *rc = s1;
|
||||
size_t strn = strlen(s2) + 1;
|
||||
if (strn > n) {
|
||||
strn = n;
|
||||
}
|
||||
memcpy(s1, s2, strn);
|
||||
if (n > strn) {
|
||||
memset(s1 + strn, '\0', n - strn);
|
||||
}
|
||||
return rc;
|
||||
}
|
39
platform/tintin/boot/libc/string/strlen.c
Normal file
39
platform/tintin/boot/libc/string/strlen.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// size_t strlen(const char *s);
|
||||
// size_t strnlen(const char *s, size_t maxlen);
|
||||
///////////////////////////////////////
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
size_t strlen(const char *s) {
|
||||
size_t len = 0;
|
||||
while (*s++) {
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t strnlen(const char *s, size_t maxlen) {
|
||||
size_t len = 0;
|
||||
while (*s++ && maxlen--) {
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
57
platform/tintin/boot/libc/string/strspn.c
Normal file
57
platform/tintin/boot/libc/string/strspn.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// size_t strcspn(const char *s1, const char *s2);
|
||||
// size_t strspn(const char *s1, const char *s2);
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
size_t strcspn(const char *s1, const char *s2) {
|
||||
size_t len = 0;
|
||||
const char *p;
|
||||
while (s1[len]) {
|
||||
p = s2;
|
||||
while (*p) {
|
||||
if (s1[len] == *p++) {
|
||||
return len;
|
||||
}
|
||||
}
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t strspn(const char *s1, const char *s2) {
|
||||
size_t len = 0;
|
||||
const char *p;
|
||||
while (s1[len]) {
|
||||
p = s2;
|
||||
while (*p) {
|
||||
if (s1[len] == *p) {
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
if (!*p) {
|
||||
return len;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
36
platform/tintin/boot/libc/string/strstr.c
Normal file
36
platform/tintin/boot/libc/string/strstr.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// char *strstr(const char *s1, const char *s2);
|
||||
///////////////////////////////////////
|
||||
// Notes:
|
||||
// Tuned for code size.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
char *strstr(const char *s1, const char *s2) {
|
||||
size_t len = strlen(s2);
|
||||
while (*s1) {
|
||||
if (strncmp(s1, s2, len) == 0) {
|
||||
return (char*)s1;
|
||||
}
|
||||
s1++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
81
platform/tintin/boot/libc/string/strtol.c
Normal file
81
platform/tintin/boot/libc/string/strtol.c
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// long int strtol(const char *nptr, char **endptr, int base);
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
intmax_t strtoX_core(const char * restrict nptr, char ** restrict endptr, int base, bool do_errors,
|
||||
intmax_t max, intmax_t min) {
|
||||
intmax_t value = 0;
|
||||
int sign = 1;
|
||||
while (isspace((int)*nptr)) {
|
||||
nptr++;
|
||||
}
|
||||
switch (*nptr) {
|
||||
case '+': sign = 1; nptr++; break;
|
||||
case '-': sign = -1; nptr++; break;
|
||||
}
|
||||
if (nptr[0] == '0' && nptr[1] == 'x' && (base == 0 || base == 16)) {
|
||||
base = 16;
|
||||
nptr += 2;
|
||||
} else if (nptr[0] == '0' && (base == 0 || base == 8)) {
|
||||
base = 8;
|
||||
nptr++;
|
||||
} else if (base == 0) {
|
||||
base = 10;
|
||||
}
|
||||
// We break on '\0' anyways
|
||||
for (;;) {
|
||||
char ch = *nptr;
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
ch = ch - '0';
|
||||
} else if (ch >= 'A' && ch <= 'Z') {
|
||||
ch = ch - 'A' + 10;
|
||||
} else if (ch >= 'a' && ch <= 'z') {
|
||||
ch = ch - 'a' + 10;
|
||||
} else { // This will catch '\0'
|
||||
break;
|
||||
}
|
||||
if (ch >= base) {
|
||||
break;
|
||||
}
|
||||
value *= base;
|
||||
value += ch;
|
||||
if (do_errors) {
|
||||
if ((sign > 0) && (value > max)) {
|
||||
value = max;
|
||||
} else if ((sign < 0) && (-value < min)) {
|
||||
value = -min;
|
||||
}
|
||||
}
|
||||
nptr++;
|
||||
}
|
||||
if (endptr) {
|
||||
*endptr = (char*)nptr;
|
||||
}
|
||||
return value * sign;
|
||||
}
|
||||
|
||||
long int strtol(const char * restrict nptr, char ** restrict endptr, int base) {
|
||||
return strtoX_core(nptr, endptr, base, true, INT_MAX, INT_MIN);
|
||||
}
|
27
platform/tintin/boot/libc/stub/setlocale.c
Normal file
27
platform/tintin/boot/libc/stub/setlocale.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////
|
||||
// Implements:
|
||||
// char *setlocale(int category, const char *locale);
|
||||
///////////////////////////////////////
|
||||
// Notes:
|
||||
// Simplicity references this, but we don't want to implement it.
|
||||
|
||||
#include <stddef.h>
|
||||
char *setlocale(int category, const char *locale) {
|
||||
return NULL;
|
||||
}
|
15
platform/tintin/boot/libc/wscript
Normal file
15
platform/tintin/boot/libc/wscript
Normal file
|
@ -0,0 +1,15 @@
|
|||
def build(bld):
|
||||
# Collect all the files in the libc directory
|
||||
source_dirs = ['string', 'math', 'stub']
|
||||
sources = sum([bld.path.ant_glob('%s/*.c' % d) for d in source_dirs], [])
|
||||
sources.extend(bld.path.ant_glob('*.c'))
|
||||
|
||||
# Build the libc directory using firmware environment
|
||||
bld.objects(source=sources,
|
||||
target='pblibc',
|
||||
includes=['include', '.'],
|
||||
cflags=['-fno-lto'],
|
||||
export_includes='include',
|
||||
use='')
|
||||
|
||||
# vim:filetype=python
|
Loading…
Add table
Add a link
Reference in a new issue