Newlib: implement locks
* Dynamically allocate arc4random data. Saves about 1k off the bss.
This commit is contained in:
parent
89c6c410ff
commit
e9d9201527
24 changed files with 3442 additions and 44 deletions
3147
libc/xtensa-lx106-elf/include/elf.h
Normal file
3147
libc/xtensa-lx106-elf/include/elf.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1 +1,32 @@
|
|||
/* Use default implementation, see arc4random.h */
|
||||
/*
|
||||
* Copyright (c) 2017
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void _arc4random_getentropy_fail(void);
|
||||
|
||||
#define _ARC4RANDOM_DATA
|
||||
|
||||
#define _ARC4RANDOM_GETENTROPY_FAIL() _arc4random_getentropy_fail()
|
||||
|
||||
#define _ARC4RANDOM_ALLOCATE(rsp, rsxp) \
|
||||
do { *rsp = malloc(sizeof(**rsp)); \
|
||||
*rsxp = malloc(sizeof(**rsxp)); } \
|
||||
while (0)
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -48,6 +48,23 @@
|
|||
This represents what type a float arg is passed as. It is used when the type is
|
||||
not promoted to double.
|
||||
|
||||
|
||||
__OBSOLETE_MATH_DEFAULT
|
||||
|
||||
Default value for __OBSOLETE_MATH if that's not set by the user.
|
||||
It should be set here based on predefined feature macros.
|
||||
|
||||
__OBSOLETE_MATH
|
||||
|
||||
If set to 1 then some new math code will be disabled and older libm
|
||||
code will be used instead. This is necessary because the new math
|
||||
code does not support all targets, it assumes that the toolchain has
|
||||
ISO C99 support (hexfloat literals, standard fenv semantics), the
|
||||
target has IEEE-754 conforming binary32 float and binary64 double
|
||||
(not mixed endian) representation, standard SNaN representation,
|
||||
double and single precision arithmetics has similar latency and it
|
||||
has no legacy SVID matherr support, only POSIX errno and fenv
|
||||
exception based error handling.
|
||||
*/
|
||||
|
||||
#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
|
||||
|
@ -61,6 +78,7 @@
|
|||
# else
|
||||
# define __IEEE_BIG_ENDIAN
|
||||
# endif
|
||||
# define __OBSOLETE_MATH_DEFAULT 0
|
||||
#else
|
||||
# define __IEEE_BIG_ENDIAN
|
||||
# ifdef __ARMEL__
|
||||
|
@ -75,6 +93,7 @@
|
|||
#else
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#endif
|
||||
#define __OBSOLETE_MATH_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#ifdef __epiphany__
|
||||
|
@ -435,6 +454,14 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __OBSOLETE_MATH_DEFAULT
|
||||
/* Use old math code by default. */
|
||||
#define __OBSOLETE_MATH_DEFAULT 1
|
||||
#endif
|
||||
#ifndef __OBSOLETE_MATH
|
||||
#define __OBSOLETE_MATH __OBSOLETE_MATH_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef __IEEE_BIG_ENDIAN
|
||||
#ifndef __IEEE_LITTLE_ENDIAN
|
||||
#error Endianess not declared!!
|
||||
|
|
|
@ -171,9 +171,9 @@ int _EXFUN(pthread_setschedprio, (pthread_t thread, int prio));
|
|||
#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
|
||||
|
||||
#if __GNU_VISIBLE
|
||||
int pthread_getname_np(pthread_t, char *, size_t) __nonnull(2);
|
||||
int pthread_getname_np(pthread_t, char *, size_t) __nonnull((2));
|
||||
|
||||
int pthread_setname_np(pthread_t, const char *) __nonnull(2);
|
||||
int pthread_setname_np(pthread_t, const char *) __nonnull((2));
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT)
|
||||
|
|
|
@ -796,4 +796,8 @@ _putchar_unlocked(int _c)
|
|||
|
||||
_END_STD_C
|
||||
|
||||
#if __SSP_FORTIFY_LEVEL > 0
|
||||
#include <ssp/stdio.h>
|
||||
#endif
|
||||
|
||||
#endif /* _STDIO_H_ */
|
||||
|
|
|
@ -294,7 +294,7 @@ int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
|
|||
#endif /* !__CYGWIN__ */
|
||||
|
||||
#if __POSIX_VISIBLE >= 200112
|
||||
int _EXFUN(__nonnull (1) posix_memalign,(void **, size_t, size_t));
|
||||
int _EXFUN(__nonnull ((1)) posix_memalign,(void **, size_t, size_t));
|
||||
#endif
|
||||
|
||||
char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**));
|
||||
|
@ -346,4 +346,8 @@ _Noreturn void
|
|||
|
||||
_END_STD_C
|
||||
|
||||
#if __SSP_FORTIFY_LEVEL > 0
|
||||
#include <ssp/stdlib.h>
|
||||
#endif
|
||||
|
||||
#endif /* _STDLIB_H_ */
|
||||
|
|
|
@ -169,11 +169,15 @@ int _EXFUN(strverscmp,(const char *, const char *));
|
|||
sure here. */
|
||||
#if __GNU_VISIBLE && !defined(basename)
|
||||
# define basename basename
|
||||
char *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
|
||||
char *_EXFUN(__nonnull ((1)) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
|
||||
#endif
|
||||
|
||||
#include <sys/string.h>
|
||||
|
||||
_END_STD_C
|
||||
|
||||
#if __SSP_FORTIFY_LEVEL > 0
|
||||
#include <ssp/string.h>
|
||||
#endif
|
||||
|
||||
#endif /* _STRING_H_ */
|
||||
|
|
|
@ -53,11 +53,9 @@ void explicit_bzero(void *, size_t);
|
|||
#if __MISC_VISIBLE || __POSIX_VISIBLE < 200809 || __XSI_VISIBLE >= 700
|
||||
int ffs(int) __pure2;
|
||||
#endif
|
||||
#if __GNU_VISIBLE
|
||||
#if __BSD_VISIBLE
|
||||
int ffsl(long) __pure2;
|
||||
int ffsll(long long) __pure2;
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
int fls(int) __pure2;
|
||||
int flsl(long) __pure2;
|
||||
int flsll(long long) __pure2;
|
||||
|
@ -75,4 +73,8 @@ int strncasecmp_l (const char *, const char *, size_t, locale_t);
|
|||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#if __SSP_FORTIFY_LEVEL > 0
|
||||
#include <ssp/strings.h>
|
||||
#endif
|
||||
|
||||
#endif /* _STRINGS_H_ */
|
||||
|
|
|
@ -52,17 +52,29 @@ extern "C" {
|
|||
#define _FNOFOLLOW 0x100000
|
||||
#define _FDIRECTORY 0x200000
|
||||
#define _FEXECSRCH 0x400000
|
||||
#define _FTMPFILE 0x800000
|
||||
#define _FNOATIME 0x1000000
|
||||
|
||||
#define O_BINARY _FBINARY
|
||||
#define O_TEXT _FTEXT
|
||||
#define O_CLOEXEC _FNOINHERIT
|
||||
#define O_DIRECT _FDIRECT
|
||||
#define O_NOFOLLOW _FNOFOLLOW
|
||||
#define O_DSYNC _FSYNC
|
||||
#define O_RSYNC _FSYNC
|
||||
#define O_DIRECTORY _FDIRECTORY
|
||||
#define O_EXEC _FEXECSRCH
|
||||
#define O_SEARCH _FEXECSRCH
|
||||
|
||||
/* POSIX-1.2008 specific flags */
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
#define O_CLOEXEC _FNOINHERIT
|
||||
#define O_NOFOLLOW _FNOFOLLOW
|
||||
#define O_DIRECTORY _FDIRECTORY
|
||||
#endif
|
||||
|
||||
/* Linux-specific flags */
|
||||
#if __GNU_VISIBLE
|
||||
#define O_DIRECT _FDIRECT
|
||||
#define O_TMPFILE _FTMPFILE
|
||||
#define O_NOATIME _FNOATIME
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __MISC_VISIBLE
|
||||
|
|
|
@ -397,7 +397,7 @@
|
|||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 3)
|
||||
#define __nonnull(x) __attribute__((__nonnull__(x)))
|
||||
#define __nonnull(x) __attribute__((__nonnull__ x))
|
||||
#define __nonnull_all __attribute__((__nonnull__))
|
||||
#else
|
||||
#define __nonnull(x)
|
||||
|
|
|
@ -100,6 +100,9 @@ extern "C" {
|
|||
* _SVID_SOURCE (deprecated by _DEFAULT_SOURCE)
|
||||
* _DEFAULT_SOURCE (or none of the above)
|
||||
* POSIX-1.2008 with BSD and SVr4 extensions
|
||||
*
|
||||
* _FORTIFY_SOURCE = 1 or 2
|
||||
* Object Size Checking function wrappers
|
||||
*/
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
|
@ -233,9 +236,11 @@ extern "C" {
|
|||
* __GNU_VISIBLE
|
||||
* GNU extensions; enabled with _GNU_SOURCE.
|
||||
*
|
||||
* __SSP_FORTIFY_LEVEL
|
||||
* Object Size Checking; defined to 0 (off), 1, or 2.
|
||||
*
|
||||
* In all cases above, "enabled by default" means either by defining
|
||||
* _DEFAULT_SOURCE, or by not defining any of the public feature test macros.
|
||||
* Defining _GNU_SOURCE makes all of the above avaliable.
|
||||
*/
|
||||
|
||||
#ifdef _ATFILE_SOURCE
|
||||
|
@ -314,6 +319,17 @@ extern "C" {
|
|||
#define __XSI_VISIBLE 0
|
||||
#endif
|
||||
|
||||
#if _FORTIFY_SOURCE > 0 && !defined(__cplusplus) && !defined(__lint__) && \
|
||||
(__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1)
|
||||
# if _FORTIFY_SOURCE > 1
|
||||
# define __SSP_FORTIFY_LEVEL 2
|
||||
# else
|
||||
# define __SSP_FORTIFY_LEVEL 1
|
||||
# endif
|
||||
#else
|
||||
# define __SSP_FORTIFY_LEVEL 0
|
||||
#endif
|
||||
|
||||
/* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */
|
||||
|
||||
#ifdef __rtems__
|
||||
|
@ -448,7 +464,7 @@ extern "C" {
|
|||
#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
|
||||
/* #define _POSIX_THREAD_SPORADIC_SERVER -1 */
|
||||
#define _POSIX_THREADS 200809L
|
||||
/* #define _POSIX_TIMEOUTS -1 */
|
||||
#define _POSIX_TIMEOUTS 200809L
|
||||
#define _POSIX_TIMERS 200809L
|
||||
/* #define _POSIX_TRACE -1 */
|
||||
/* #define _POSIX_TRACE_EVENT_FILTER -1 */
|
||||
|
|
|
@ -22,8 +22,17 @@ typedef _lock_t _LOCK_T;
|
|||
Lock functions all take a pointer to the _lock_t entry, so the
|
||||
value stored there can be manipulated.
|
||||
*/
|
||||
#if 0
|
||||
#define __LOCK_INIT(CLASS,NAME) CLASS _lock_t NAME = 0;
|
||||
#define __LOCK_INIT_RECURSIVE(CLASS,NAME) CLASS _lock_t NAME = 0;
|
||||
#else
|
||||
/*
|
||||
* Skip a 'static' class definition, so they are all visible and can
|
||||
* be initialize at startup.
|
||||
*/
|
||||
#define __LOCK_INIT(CLASS,NAME) _lock_t NAME = 0;
|
||||
#define __LOCK_INIT_RECURSIVE(CLASS,NAME) _lock_t NAME = 0;
|
||||
#endif
|
||||
|
||||
void _lock_init(_lock_t *lock);
|
||||
void _lock_init_recursive(_lock_t *lock);
|
||||
|
|
|
@ -73,13 +73,17 @@ int _EXFUN(execvpe, (const char *__file, char * const __argv[], char * const
|
|||
#if __ATFILE_VISIBLE
|
||||
int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags));
|
||||
#endif
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
int _EXFUN(fchdir, (int __fildes));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 199309
|
||||
int _EXFUN(fchmod, (int __fildes, mode_t __mode ));
|
||||
#endif
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
|
||||
#endif
|
||||
#endif
|
||||
#if __ATFILE_VISIBLE
|
||||
int _EXFUN(fchownat, (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags));
|
||||
#endif
|
||||
|
@ -89,7 +93,9 @@ int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] ));
|
|||
pid_t _EXFUN(fork, (void ));
|
||||
long _EXFUN(fpathconf, (int __fd, int __name ));
|
||||
int _EXFUN(fsync, (int __fd));
|
||||
#if __POSIX_VISIBLE >= 199309
|
||||
int _EXFUN(fdatasync, (int __fd));
|
||||
#endif
|
||||
#if __GNU_VISIBLE
|
||||
char * _EXFUN(get_current_dir_name, (void));
|
||||
#endif
|
||||
|
@ -113,12 +119,16 @@ char * _EXFUN(getlogin, (void ));
|
|||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
|
||||
int _EXFUN(getlogin_r, (char *name, size_t namesize) );
|
||||
#endif
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE && __POSIX_VISIBLE < 200112)
|
||||
char * _EXFUN(getpass, (const char *__prompt));
|
||||
int _EXFUN(getpagesize, (void));
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(getpeereid, (int, uid_t *, gid_t *));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
|
||||
pid_t _EXFUN(getpgid, (pid_t));
|
||||
#endif
|
||||
pid_t _EXFUN(getpgrp, (void ));
|
||||
pid_t _EXFUN(getpid, (void ));
|
||||
pid_t _EXFUN(getppid, (void ));
|
||||
|
@ -142,13 +152,17 @@ int _EXFUN(isatty, (int __fildes ));
|
|||
int _EXFUN(issetugid, (void));
|
||||
#endif
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
|
||||
#endif
|
||||
#endif
|
||||
int _EXFUN(link, (const char *__path1, const char *__path2 ));
|
||||
#if __ATFILE_VISIBLE
|
||||
int _EXFUN(linkat, (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags ));
|
||||
#endif
|
||||
#if __MISC_VISIBLE || __XSI_VISIBLE
|
||||
int _EXFUN(nice, (int __nice_value ));
|
||||
#endif
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
|
||||
#endif
|
||||
|
@ -168,8 +182,10 @@ int _EXFUN(pipe, (int __fildes[2] ));
|
|||
#if __GNU_VISIBLE
|
||||
int _EXFUN(pipe2, (int __fildes[2], int flags));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500
|
||||
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
|
||||
ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
|
||||
#endif
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(rresvport, (int *__alport));
|
||||
|
@ -179,7 +195,9 @@ int _EXFUN(rmdir, (const char *__path ));
|
|||
#if __BSD_VISIBLE
|
||||
int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
|
||||
#endif
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
|
||||
void * _EXFUN(sbrk, (ptrdiff_t __incr));
|
||||
#endif
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
|
||||
int _EXFUN(setegid, (gid_t __gid ));
|
||||
|
@ -194,7 +212,9 @@ int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist ));
|
|||
int _EXFUN(sethostname, (const char *, size_t));
|
||||
#endif
|
||||
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
|
||||
#if __SVID_VISIBLE || __XSI_VISIBLE >= 500
|
||||
int _EXFUN(setpgrp, (void ));
|
||||
#endif
|
||||
#if (__BSD_VISIBLE || __XSI_VISIBLE >= 4) && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(setregid, (gid_t __rgid, gid_t __egid));
|
||||
int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid));
|
||||
|
@ -567,4 +587,9 @@ int _EXFUN(unlinkat, (int, const char *, int));
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __SSP_FORTIFY_LEVEL > 0
|
||||
#include <ssp/unistd.h>
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_UNISTD_H */
|
||||
|
|
|
@ -189,6 +189,10 @@ int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t));
|
|||
wchar_t *_EXFUN(wmemcpy, (wchar_t *__restrict, const wchar_t *__restrict,
|
||||
size_t));
|
||||
wchar_t *_EXFUN(wmemmove, (wchar_t *, const wchar_t *, size_t));
|
||||
#if __GNU_VISIBLE
|
||||
wchar_t *_EXFUN(wmempcpy, (wchar_t *__restrict, const wchar_t *__restrict,
|
||||
size_t));
|
||||
#endif
|
||||
wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t));
|
||||
|
||||
long _EXFUN(wcstol, (const wchar_t *__restrict, wchar_t **__restrict, int));
|
||||
|
@ -331,4 +335,8 @@ int _EXFUN(_wscanf_r, (struct _reent *, const wchar_t *, ...));
|
|||
|
||||
_END_STD_C
|
||||
|
||||
#if __SSP_FORTIFY_LEVEL > 0
|
||||
#include <ssp/wchar.h>
|
||||
#endif
|
||||
|
||||
#endif /* _WCHAR_H_ */
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue