Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • redox-os/relibc
  • martin/relibc
  • ashton/relibc
  • vincent/relibc
  • boomshroom/relibc
  • njskalski/relibc
  • gmacd/relibc
  • mati865/relibc
  • nicoan/relibc
  • lmiskiew/relibc
  • devnexen/relibc
  • jamesgraves/relibc
  • oddcoder/relibc
  • andar1an/relibc
  • gugz0r/relibc
  • matijaskala/relibc
  • zen3ger/relibc
  • arthurpaulino/relibc
  • Majoneza/relibc
  • 4lDO2/relibc
  • enygmator/relibc
  • JustAnotherDev/relibc
  • doriancodes/relibc
  • adamantinum/relibc
  • wiredtv/relibc
  • stratact/relibc
  • Ramla-I/relibc
  • bitstr0m/relibc
  • bpisch/relibc
  • henritel/relibc
  • smckay/relibc
  • xTibor/relibc
  • devajithvs/relibc
  • andypython/relibc
  • t-nil/relibc
  • DataTriny/relibc
  • SteveLauC/relibc
  • dlrobertson/relibc
  • josh/relibc
  • AgostonSzepessy/relibc
  • TheDarkula/relibc
  • willnode/relibc
  • bamontan/relibc
  • raffaeleragni/relibc
  • redoxeon/relibc
  • darley/relibc
  • ayf/relibc
  • heghe/relibc
  • Ivan/relibc
  • hasheddan/relibc
  • dahc/relibc
  • auwardoctor/relibc
  • kodicraft/relibc
  • jasonhansel/relibc
  • kel/relibc
  • microcolonel/relibc
  • GrayJack/relibc
  • sahitpj/relibc
  • plimkilde/relibc
  • BjornTheProgrammer/relibc
  • defra/relibc
  • jD91mZM2/relibc
  • Schyrsivochter/relibc
  • ebalalic/relibc
  • adchacon/relibc
  • aaronjanse/relibc
  • josh_williams/relibc
  • 8tab/relibc
  • athei/relibc
  • carrot93/relibc
  • RA_GM1/relibc
  • zhaozhao/relibc
  • JCake/relibc
  • KGrewal1/relibc
  • feliwir/relibc
  • emturner/relibc
  • LuigiPiucco/relibc
  • bfrascher/relibc
  • starsheriff/relibc
  • kcired/relibc
  • jamespcfrancis/relibc
  • omar-mohamed-khallaf/relibc
  • neallred/relibc
  • rw_van/relibc
  • Skallwar/relibc
  • matt-vdv/relibc
  • SoyaOhnishi/relibc
  • ArniDagur/relibc
  • tlam/relibc
  • glongo/relibc
  • kamirr/relibc
  • abdullah/relibc
  • saeedtabrizi/relibc
  • sajattack/relibc
  • seanpk/relibc
  • MaikuZ/relibc
  • jamadazi/relibc
  • coolreader18/relibc
  • wt/relibc
  • lebensterben/relibc
  • uuuvn/relibc
  • vadorovsky/relibc
  • ids1024/relibc
  • freewilll/relibc
  • LLeny/relibc
  • alfredoyang/relibc
  • batonius/relibc
  • TornaxO7/relibc
  • bjorn3/relibc
  • Arcterus/relibc
  • Tommoa/relibc
  • samuela/relibc
  • mindriot101/relibc
  • lygstate/relibc
114 results
Show changes
Showing with 287 additions and 80 deletions
#ifndef _BITS_ASSERT_H
#define _BITS_ASSERT_H
// Do not use include guard, to ensure assert is always defined
#ifdef assert
#undef assert
#endif
#ifdef NDEBUG
# define assert(cond) (void) 0
#else
# define assert(cond) \
((void)((cond) || (__assert(__func__, __FILE__, __LINE__, #cond), 0)))
#endif
((void)((cond) || (__assert_fail(__func__, __FILE__, __LINE__, #cond), 0)))
#endif
#ifndef _BITS_ELF_H
#define _BITS_ELF_H
#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
#define ELF32_ST_TYPE(val) ((val) & 0xf)
#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
#define ELF32_R_SYM(val) ((val) >> 8)
#define ELF32_R_TYPE(val) ((val) & 0xff)
#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
#define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
#define DT_VALRNGHI 0x6ffffdff
#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag))
#define DT_ADDRRNGHI 0x6ffffeff
#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag))
#define DT_VERNEEDNUM 0x6fffffff
#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag))
#define ELF32_M_SYM(info) ((info) >> 8)
#define ELF32_M_SIZE(info) ((unsigned char) (info))
#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
#define ELF64_M_SYM(info) ELF32_M_SYM (info)
#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
#endif /* ifdef _BITS_ELF_H*/
......@@ -5,10 +5,9 @@
extern "C" {
#endif
#define ENOTSUP EOPNOTSUPP
//TODO extern __thread int errno;
extern int errno;
#define errno (*__errno_location())
#define program_invocation_name (*__program_invocation_name())
#define program_invocation_short_name (*__program_invocation_short_name())
#ifdef __cplusplus
} // extern "C"
......
#ifndef _BITS_FCNTL_H
#define _BITS_FCNTL_H
#ifdef __cplusplus
extern "C" {
#endif
int open(const char* filename, int flags, ...);
int fcntl(int fildes, int cmd, ...);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
......@@ -5,8 +5,6 @@
// Shamelessly copy pasted from musl:
#define FLT_RADIX 2
#define FLT_TRUE_MIN 1.40129846432481707092e-45F
#define FLT_MIN 1.17549435082228750797e-38F
#define FLT_MAX 3.40282346638528859812e+38F
......
#ifndef _BITS_LIMIT_H
#define _BITS_LIMIT_H
#define MB_LEN_MAX 4 // unicode
#define CHAR_BIT __CHAR_BIT__
#ifdef __CHAR_MAX__
# define CHAR_MAX __CHAR_MAX__
......@@ -23,12 +21,12 @@
#define SHRT_MIN (-SHRT_MAX - 1)
// TODO: These might not be accurate on all platforms
#define SSIZE_MAX ((1 << 64 - 1) - 1)
#define SSIZE_MAX 0x7fffffffffffffff
#define UCHAR_MAX 255
#define UINT_MAX ((1 << 32) - 1)
#define ULLONG_MAX ((1 << 64) - 1)
#define ULONG_MAX ((1 << 64) - 1)
#define USHRT_MAX ((1 << 16) - 1)
#define UINT_MAX 0xffffffff
#define ULLONG_MAX 0xffffffffffffffff
#define ULONG_MAX 0xffffffffffffffff
#define USHRT_MAX 0xffff
#define WORD_BIT 32
#endif
#ifndef _MALLOC_H
#define _MALLOC_H
#ifndef _BITS_MALLOC_H
#define _BITS_MALLOC_H
#include <stddef.h>
......
#ifndef _BITS_NETDB_H
#define _BITS_NETDB_H
#define EAI_BADFLAGS (-1)
#define EAI_NONAME (-2)
#define EAI_AGAIN (-3)
#define EAI_FAIL (-4)
#define EAI_NODATA (-5)
#define EAI_FAMILY (-6)
#define EAI_SOCKTYPE (-7)
#define EAI_SERVICE (-8)
#define EAI_ADDRFAMILY (-9)
#define EAI_MEMORY (-10)
#define EAI_SYSTEM (-11)
#define EAI_OVERFLOW (-12)
#ifdef __cplusplus
extern "C" {
#endif
#define h_errno (*__h_errno_location())
# define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* _BITS_NETDB_H */
#define SIG_ERR ((void (*)(int)) -1)
#define SIG_DFL ((void (*)(int)) 0)
#define SIG_IGN ((void (*)(int)) 1)
#ifndef _BITS_SIGNAL_H
#define _BITS_SIGNAL_H
#define SIG_DFL ((void (*)(int))0)
#define SIG_IGN ((void (*)(int))1)
#define SIG_ERR ((void (*)(int))-1)
typedef struct siginfo siginfo_t;
typedef unsigned long long sigset_t;
typedef struct ucontext ucontext_t;
typedef struct mcontext mcontext_t;
struct sigaction {
union {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
};
unsigned long sa_flags;
void (*sa_restorer)(void);
sigset_t sa_mask;
};
#endif // _BITS_SIGNAL_H
#ifndef _BITS_STDIO_H
#define _BITS_STDIO_H
#define EOF (-1)
// XXX: this is only here because cbindgen can't handle string constants
#define P_tmpdir "/tmp"
typedef struct FILE FILE;
#ifdef __cplusplus
extern "C" {
#endif
int asprintf(char **strp, const char * fmt, ...);
int fprintf(FILE * stream, const char * fmt, ...);
int printf(const char * fmt, ...);
int snprintf(char *s, size_t n, const char * fmt, ...);
int sprintf(char *s, const char * fmt, ...);
int fscanf(FILE * stream, const char * fmt, ...);
int scanf(const char * fmt, ...);
int sscanf(const char * input, const char * fmt, ...);
#ifdef __cplusplus
} // extern "C"
#endif
// A typedef doesn't suffice, because libgmp uses this definition to check if
// STDIO was loaded.
#define FILE FILE
#endif /* _BITS_STDIO_H */
#ifndef _BITS_SYS_PTRACE_H
#define _BITS_SYS_PTRACE_H
#endif
......@@ -7,4 +7,10 @@ struct sockaddr_storage {
unsigned long __ss_align;
};
struct ucred {
pid_t pid;
uid_t uid;
gid_t gid;
};
#endif // _BITS_SYS_SOCKET_H
#ifndef _BITS_SYS_WAIT_H
#define _BITS_SYS_WAIT_H
#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
#define WTERMSIG(s) ((s) & 0x7f)
#define WEXITSTATUS(s) (((s) >> 8) & 0xff)
#define WTERMSIG(s) (((s) & 0x7f) != 0)
#define WSTOPSIG(s) WEXITSTATUS(s)
#define WCOREDUMP(s) ((s) & 0x80)
#define WIFEXITED(s) (!WTERMSIG(s))
#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
#define WCOREDUMP(s) (((s) & 0x80) != 0)
#define WIFEXITED(s) (((s) & 0x7f) == 0)
#define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
#define WIFSIGNALED(s) (((((s) & 0x7f) + 1U) & 0x7f) >= 2) // Ends with 1111111 or 10000000
#define WIFCONTINUED(s) ((s) == 0xffff)
#endif /* _BITS_SYS_WAIT_H */
......@@ -7,10 +7,6 @@
extern "C" {
#endif
int execl(const char *path, const char* argv0, ...);
int execle(const char *path, const char* argv0, ...);
int execlp(const char *file, const char* argv0, ...);
#ifdef __cplusplus
} // extern "C"
#endif
......
#ifndef _BITS_WCHAR_H
#define _BITS_WCHAR_H
// int32_t, uint32_t, WCHAR_MIN, WCHAR_MAX
#include <stdint.h>
#define WEOF (0xffffffffu)
#define WCHAR_MIN (0)
#define WCHAR_MAX (0x7fffffff)
#ifndef _WCHAR_T
#define _WCHAR_T
#ifndef __WCHAR_TYPE__
#define __WCHAR_TYPE__ int32_t
#endif
typedef __WCHAR_TYPE__ wchar_t;
#endif // _WCHAR_T
#ifndef _WINT_T
#define _WINT_T
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ uint32_t
#endif
typedef __WINT_TYPE__ wint_t;
#endif // _WINT_T
// NULL, size_t, must come after wchar_t and wint_t
#define __need_size_t
#define __need_wchar_t
#define __need_wint_t
#define __need_NULL
#include <stddef.h>
#define WEOF (0xffffffffu)
#endif /* _BITS_WCHAR_H */
#ifndef _RELIBC_CPIO_H
#define _RELIBC_CPIO_H
#define MAGIC "070707"
#define C_IRUSR 00000400
#define C_IWUSR 00000200
#define C_IXUSR 00000100
#define C_IRGRP 00000040
#define C_IWGRP 00000020
#define C_IXGRP 00000010
#define C_IROTH 00000004
#define C_IWOTH 00000002
#define C_IXOTH 00000001
#define C_ISUID 00004000
#define C_ISGID 00002000
#define C_ISVTX 00001000
#define C_ISDIR 00040000
#define C_ISFIFO 00010000
#define C_ISREG 00100000
#define C_ISBLK 00060000
#define C_ISCHR 00020000
#define C_ISCTG 00110000
#define C_ISLNK 00120000
#define C_ISSOCK 00140000
#endif /* _RELIBC_CPIO_H */
/*
* MIT License
* Copyright (c) 2020 Rich Felker musl-libc
*/
#ifndef _FEATURES_H__RELIBC
#define _FEATURES_H__RELIBC
// Version metadata for feature gating
// This is useful for divergent implementation specific behavior
// glibc, ulibc, and likely others define a similar macro
// musl does not define an equivalent macro
#define __RELIBC__ 1
#define __RELIBC__MAJOR 0
#define __RELIBC__MINOR 2
/*
* Sources:
* https://en.cppreference.com/w/c/language/attributes
* https://clang.llvm.org/docs/LanguageExtensions.html
* https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fc_005fattribute.html
* https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html
*/
// Clang doesn't define __has_cpp_attribute if compiling C code
#if !defined(__has_cpp_attribute)
#define __has_cpp_attribute(x) 0
#endif
// Clang doesn't define __has_c_attribute if compiling C++ code
#if !defined(__has_c_attribute)
#define __has_c_attribute(x) 0
#endif
// Check if C23+ attributes are available
#if defined(__cplusplus)
// HACK: GCC backports C++ attributes to C++98 but doesn't accept attributes
// placed before the function like cbindgen emits.
// Let's just disable attributes for C++98 by checking if a random C++11
// feature is available.
#define __HAS_ATTRIBUTE(x) __cpp_variable_templates &&__has_cpp_attribute(x)
#else
#define __HAS_ATTRIBUTE(x) \
(__has_c_attribute(x) || __STDC_VERSION__ >= 202311L || \
__has_cpp_attribute(x))
#endif
// TODO: Not emitted with cbindgen
#if __STDC_VERSION__ >= 199901L
#define __restrict restrict
#elif !defined(__GNUC__)
#define __restrict
#endif
// TODO: Not emitted with cbindgen
#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
#define __inline inline
#elif !defined(__GNUC__)
#define __inline
#endif
// Analogous to Rust's Never type
#if __HAS_ATTRIBUTE(noreturn)
#define __noreturn [[noreturn]]
// #elif __STDC_VERSION__ >= 201112L
// FIXME: cbindgen incorrectly places _Noreturn
// #define __noreturn _Noreturn
#elif defined(__GNUC__)
#define __noreturn __attribute__((__noreturn__))
#else
#define __noreturn
#endif
// Analogous to Rust's #[must_use]
// C23 only
#if __HAS_ATTRIBUTE(nodiscard)
#define __nodiscard [[nodiscard]]
#define __nodiscardNote(x) [[nodiscard(x)]]
#else
#define __nodiscard
#define __nodiscardNote(x)
#endif
// Analogous to Rust's #[deprecated]
// C23 only
#if __HAS_ATTRIBUTE(deprecated)
#define __deprecated [[deprecated]]
#define __deprecatedNote(x) [[deprecated(x)]]
#else
#define __deprecated
#define __deprecatedNote(x)
#endif
#endif
// Copied from musl
#ifndef _ISO646_H
#define _ISO646_H
#ifndef __cplusplus
#define and &&
#define and_eq &=
#define bitand &
#define bitor |
#define compl ~
#define not !
#define not_eq !=
#define or ||
#define or_eq |=
#define xor ^
#define xor_eq ^=
#endif
#endif
#include <openlibm_math.h>
// Included to fix mesa issues
// Missing typedefs
typedef float float_t;
typedef double double_t;
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
......@@ -12,3 +15,7 @@
#ifndef M_PI_4
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#endif
#ifndef M_2_PI
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#endif
......@@ -58,7 +58,12 @@ typedef unsigned long long jmp_buf[8];
#endif
#ifdef __x86_64__
typedef unsigned long jmp_buf[8];
typedef unsigned long jmp_buf[16];
typedef jmp_buf sigjmp_buf;
#endif
#ifdef __riscv
typedef unsigned long jmp_buf[26];
#endif
#ifdef __cplusplus
......