Compare commits
6 commits
8210ac97d3
...
b63e5af467
Author | SHA1 | Date | |
---|---|---|---|
|
b63e5af467 | ||
|
0ff1b68c09 | ||
|
85bad22f34 | ||
|
3474d7f674 | ||
|
c3c59403c9 | ||
|
020c263d5d |
9 changed files with 91 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2014, 2024 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -42,6 +42,8 @@ extern "C" {
|
||||||
|
|
||||||
#define __WSTOPSIG(status) __WTERMSIG(status)
|
#define __WSTOPSIG(status) __WTERMSIG(status)
|
||||||
|
|
||||||
|
#define __WCOREDUMP(status) ((status) & 0)
|
||||||
|
|
||||||
#define __WCONSTRUCT(nature, exitcode, signal) \
|
#define __WCONSTRUCT(nature, exitcode, signal) \
|
||||||
(((nature) & 0xFF) << 16 | \
|
(((nature) & 0xFF) << 16 | \
|
||||||
((exitcode) & 0xFF) << 8 | \
|
((exitcode) & 0xFF) << 8 | \
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#include <sortix/__/sigset.h>
|
||||||
|
|
||||||
#if __USE_SORTIX || __USE_POSIX
|
#if __USE_SORTIX || __USE_POSIX
|
||||||
#define HOST_NAME_MAX 255
|
#define HOST_NAME_MAX 255
|
||||||
#define TTY_NAME_MAX 32
|
#define TTY_NAME_MAX 32
|
||||||
|
@ -30,6 +32,7 @@
|
||||||
|
|
||||||
#if __USE_SORTIX || 202405L <= __USE_POSIX
|
#if __USE_SORTIX || 202405L <= __USE_POSIX
|
||||||
#define GETENTROPY_MAX 256
|
#define GETENTROPY_MAX 256
|
||||||
|
#define NSIG_MAX __SIGSET_NUM_SIGNALS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2014 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2012, 2014, 2024 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -48,6 +48,8 @@ extern "C" {
|
||||||
|
|
||||||
#define WSTOPSIG(status) __WSTOPSIG(status)
|
#define WSTOPSIG(status) __WSTOPSIG(status)
|
||||||
|
|
||||||
|
#define WCOREDUMP(status) __WCOREDUMP(status)
|
||||||
|
|
||||||
#define WCONSTRUCT(nature, exitcode, signal) \
|
#define WCONSTRUCT(nature, exitcode, signal) \
|
||||||
__WCONSTRUCT(nature, exitcode, signal)
|
__WCONSTRUCT(nature, exitcode, signal)
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,7 @@ stdlib/qsort.o \
|
||||||
stdlib/qsort_r.o \
|
stdlib/qsort_r.o \
|
||||||
stdlib/reallocarray.o \
|
stdlib/reallocarray.o \
|
||||||
stdlib/realloc.o \
|
stdlib/realloc.o \
|
||||||
|
stdlib/secure_getenv.o \
|
||||||
stdlib/strtod.o \
|
stdlib/strtod.o \
|
||||||
stdlib/strtof.o \
|
stdlib/strtof.o \
|
||||||
stdlib/strtold.o \
|
stdlib/strtold.o \
|
||||||
|
|
|
@ -88,6 +88,30 @@ typedef int nl_item;
|
||||||
#define YESEXPR 53
|
#define YESEXPR 53
|
||||||
#define NOEXPR 54
|
#define NOEXPR 54
|
||||||
#define CRNCYSTR 55
|
#define CRNCYSTR 55
|
||||||
|
#define ALTMON_1 56
|
||||||
|
#define ALTMON_2 57
|
||||||
|
#define ALTMON_3 58
|
||||||
|
#define ALTMON_4 59
|
||||||
|
#define ALTMON_5 60
|
||||||
|
#define ALTMON_6 61
|
||||||
|
#define ALTMON_7 62
|
||||||
|
#define ALTMON_8 63
|
||||||
|
#define ALTMON_9 64
|
||||||
|
#define ALTMON_10 65
|
||||||
|
#define ALTMON_11 66
|
||||||
|
#define ALTMON_12 67
|
||||||
|
#define ABALTMON_1 69
|
||||||
|
#define ABALTMON_2 70
|
||||||
|
#define ABALTMON_3 71
|
||||||
|
#define ABALTMON_4 72
|
||||||
|
#define ABALTMON_5 73
|
||||||
|
#define ABALTMON_6 74
|
||||||
|
#define ABALTMON_7 75
|
||||||
|
#define ABALTMON_8 76
|
||||||
|
#define ABALTMON_9 77
|
||||||
|
#define ABALTMON_10 78
|
||||||
|
#define ABALTMON_11 79
|
||||||
|
#define ABALTMON_12 80
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -168,6 +168,8 @@ struct pthread_cond_elem
|
||||||
|
|
||||||
#define PTHREAD_ONCE_INIT { PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, 0 }
|
#define PTHREAD_ONCE_INIT { PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, 0 }
|
||||||
|
|
||||||
|
#define PTHREAD_NULL ((pthread_t) 0)
|
||||||
|
|
||||||
#if defined(__is_sortix_libc)
|
#if defined(__is_sortix_libc)
|
||||||
|
|
||||||
struct pthread_key
|
struct pthread_key
|
||||||
|
|
|
@ -115,8 +115,6 @@ size_t mbstowcs(wchar_t* __restrict, const char* __restrict, size_t);
|
||||||
int mbtowc(wchar_t *__restrict, const char* __restrict, size_t);
|
int mbtowc(wchar_t *__restrict, const char* __restrict, size_t);
|
||||||
char* mkdtemp(char*);
|
char* mkdtemp(char*);
|
||||||
char* mkdtemps(char*, size_t);
|
char* mkdtemps(char*, size_t);
|
||||||
int mkostemp(char*, int);
|
|
||||||
int mkostemps(char*, int, int);
|
|
||||||
int mkstemp(char*);
|
int mkstemp(char*);
|
||||||
int mkstemps(char*, int);
|
int mkstemps(char*, int);
|
||||||
int on_exit(void (*function)(int, void*), void* arg);
|
int on_exit(void (*function)(int, void*), void* arg);
|
||||||
|
@ -157,6 +155,8 @@ long long strtoll(const char* __restrict, char** __restrict, int);
|
||||||
|
|
||||||
/* Functions from POSIX 2024. */
|
/* Functions from POSIX 2024. */
|
||||||
#if __USE_SORTIX || 202405L <= __USE_POSIX
|
#if __USE_SORTIX || 202405L <= __USE_POSIX
|
||||||
|
int mkostemp(char*, int);
|
||||||
|
int ptsname_r(int, char*, size_t);
|
||||||
void qsort_r(void*, size_t, size_t, int (*)(const void*, const void*, void*), void*);
|
void qsort_r(void*, size_t, size_t, int (*)(const void*, const void*, void*), void*);
|
||||||
#ifdef __TRACE_ALLOCATION_SITES
|
#ifdef __TRACE_ALLOCATION_SITES
|
||||||
void* reallocarray_trace(struct __allocation_site*, void*, size_t, size_t);
|
void* reallocarray_trace(struct __allocation_site*, void*, size_t, size_t);
|
||||||
|
@ -164,6 +164,7 @@ void* reallocarray_trace(struct __allocation_site*, void*, size_t, size_t);
|
||||||
#else
|
#else
|
||||||
void* reallocarray(void*, size_t, size_t);
|
void* reallocarray(void*, size_t, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
char* secure_getenv(const char*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libc)
|
#if defined(__is_sortix_libc)
|
||||||
|
@ -214,7 +215,7 @@ int posix_openpt(int);
|
||||||
uint32_t arc4random(void);
|
uint32_t arc4random(void);
|
||||||
void arc4random_buf(void*, size_t);
|
void arc4random_buf(void*, size_t);
|
||||||
uint32_t arc4random_uniform(uint32_t);
|
uint32_t arc4random_uniform(uint32_t);
|
||||||
int ptsname_r(int, char*, size_t);
|
int mkostemps(char*, int, int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2016, 2024 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -45,30 +45,30 @@ char* nl_langinfo_l(nl_item item, locale_t locale)
|
||||||
case ABDAY_5: return "Thu";
|
case ABDAY_5: return "Thu";
|
||||||
case ABDAY_6: return "Fri";
|
case ABDAY_6: return "Fri";
|
||||||
case ABDAY_7: return "Sat";
|
case ABDAY_7: return "Sat";
|
||||||
case MON_1: return "January";
|
case MON_1: case ALTMON_1: return "January";
|
||||||
case MON_2: return "February";
|
case MON_2: case ALTMON_2: return "February";
|
||||||
case MON_3: return "March";
|
case MON_3: case ALTMON_3: return "March";
|
||||||
case MON_4: return "April";
|
case MON_4: case ALTMON_4: return "April";
|
||||||
case MON_5: return "May";
|
case MON_5: case ALTMON_5: return "May";
|
||||||
case MON_6: return "June";
|
case MON_6: case ALTMON_6: return "June";
|
||||||
case MON_7: return "July";
|
case MON_7: case ALTMON_7: return "July";
|
||||||
case MON_8: return "August";
|
case MON_8: case ALTMON_8: return "August";
|
||||||
case MON_9: return "September";
|
case MON_9: case ALTMON_9: return "September";
|
||||||
case MON_10: return "October";
|
case MON_10: case ALTMON_10: return "October";
|
||||||
case MON_11: return "November";
|
case MON_11: case ALTMON_11: return "November";
|
||||||
case MON_12: return "December";
|
case MON_12: case ALTMON_12: return "December";
|
||||||
case ABMON_1: return "Jan";
|
case ABMON_1: case ABALTMON_1: return "Jan";
|
||||||
case ABMON_2: return "Feb";
|
case ABMON_2: case ABALTMON_2: return "Feb";
|
||||||
case ABMON_3: return "Mar";
|
case ABMON_3: case ABALTMON_3: return "Mar";
|
||||||
case ABMON_4: return "Apr";
|
case ABMON_4: case ABALTMON_4: return "Apr";
|
||||||
case ABMON_5: return "May";
|
case ABMON_5: case ABALTMON_5: return "May";
|
||||||
case ABMON_6: return "Jun";
|
case ABMON_6: case ABALTMON_6: return "Jun";
|
||||||
case ABMON_7: return "Jul";
|
case ABMON_7: case ABALTMON_7: return "Jul";
|
||||||
case ABMON_8: return "Aug";
|
case ABMON_8: case ABALTMON_8: return "Aug";
|
||||||
case ABMON_9: return "Sep";
|
case ABMON_9: case ABALTMON_9: return "Sep";
|
||||||
case ABMON_10: return "Oct";
|
case ABMON_10: case ABALTMON_10: return "Oct";
|
||||||
case ABMON_11: return "Nov";
|
case ABMON_11: case ABALTMON_11: return "Nov";
|
||||||
case ABMON_12: return "Dec";
|
case ABMON_12: case ABALTMON_12: return "Dec";
|
||||||
case ERA: return "";
|
case ERA: return "";
|
||||||
case ERA_D_FMT: return "";
|
case ERA_D_FMT: return "";
|
||||||
case ERA_D_T_FMT: return "";
|
case ERA_D_T_FMT: return "";
|
||||||
|
|
26
libc/stdlib/secure_getenv.c
Normal file
26
libc/stdlib/secure_getenv.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Jonas 'Sortie' Termansen.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* stdlib/secure_getenv.c
|
||||||
|
* Get an environment variable securely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
char* secure_getenv(const char* name)
|
||||||
|
{
|
||||||
|
// Sortix does not have setuid / setgid executables.
|
||||||
|
return getenv(name);
|
||||||
|
}
|
Loading…
Reference in a new issue