Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/abi-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ jobs:
$extra_args \
./glibc/usr/*-linux-gnu/include/ \
./packages/mlibc-headers-only/usr/include/ \
-Mmfs >> $GITHUB_STEP_SUMMARY 2>&1
-Mmfst >> $GITHUB_STEP_SUMMARY 2>&1
echo '```' >> $GITHUB_STEP_SUMMARY
working-directory: build/
39 changes: 39 additions & 0 deletions options/ansi/include/bits/ansi/fenv.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef MLIBC_FENV_H
#define MLIBC_FENV_H

#if !defined(__ASSEMBLER__)
#include <bits/types.h>
#endif /* !defined(__ASSEMBLER__) */

#if defined(__x86_64__) || defined(__i386__)

#define FE_DENORMAL 2
Expand All @@ -17,6 +21,17 @@
#define FE_UPWARD 0x800
#define FE_TOWARDZERO 0xC00

typedef __mlibc_uint16 fexcept_t;

typedef struct {
__mlibc_uint32 __control_word;
__mlibc_uint32 __status_word;
__mlibc_uint32 __unused[5];
#if defined(__x86_64__)
__mlibc_uint32 __mxcsr;
#endif
} fenv_t;

#elif defined(__aarch64__)

#define FE_INVALID 1
Expand All @@ -32,6 +47,13 @@
#define FE_DOWNWARD 0x800000
#define FE_TOWARDZERO 0xC00000

typedef unsigned int fexcept_t;

typedef struct {
unsigned int __fpcr;
unsigned int __fpsr;
} fenv_t;

#elif defined(__riscv) && __riscv_xlen == 64

#define FE_INEXACT 1
Expand All @@ -47,6 +69,9 @@
#define FE_DOWNWARD 2
#define FE_UPWARD 3

typedef unsigned int fexcept_t;
typedef unsigned int fenv_t;

#elif defined (__m68k__)

#if __HAVE_68881__ || __mcffpu__ || __HAVE_FPU_
Expand All @@ -71,6 +96,14 @@

#endif

#if !defined(__ASSEMBLER__)
typedef unsigned int fexcept_t;

typedef struct {
fexcept_t __excepts;
} fenv_t;
#endif /* !defined(__ASSEMBLER__) */

#elif defined(__loongarch64)

#define FE_INEXACT 0x010000
Expand All @@ -86,6 +119,12 @@
#define FE_UPWARD 0x200
#define FE_DOWNWARD 0x300

typedef unsigned int fexcept_t;

typedef struct {
unsigned int __fp_control_register;
} fenv_t;

#else
#error Unknown architecture
#endif
Expand Down
10 changes: 0 additions & 10 deletions options/ansi/include/fenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@
#ifndef _FENV_H
#define _FENV_H

#include <bits/types.h>
#include <bits/ansi/fenv.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
__mlibc_uint32 __control_word;
__mlibc_uint32 __status_word;
__mlibc_uint32 __unused[5];
__mlibc_uint32 __mxcsr;
} fenv_t;

typedef __mlibc_uint16 fexcept_t;

Comment on lines -12 to -20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is a useful fix, it probably has non-trivial implications and requires a world bump.

#ifndef __MLIBC_ABI_ONLY

int feclearexcept(int __excepts);
Expand Down
26 changes: 14 additions & 12 deletions options/ansi/include/inttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#ifndef __MLIBC_ABI_ONLY

#if UINTPTR_MAX == UINT64_MAX
# define __PRIFAST "l"
# define __PRI64 "l"
# define __PRIPTR "l"
#else
# define __PRIFAST ""
# define __PRI64 "ll"
# define __PRIPTR ""
#endif
Expand All @@ -27,14 +29,14 @@
#define PRIi16 "i"
#define PRIdLEAST16 "d"
#define PRIiLEAST16 "i"
#define PRIdFAST16 "ld"
#define PRIiFAST16 "li"
#define PRIdFAST16 __PRIFAST "d"
#define PRIiFAST16 __PRIFAST "i"
#define PRId32 "d"
#define PRIi32 "i"
#define PRIdLEAST32 "d"
#define PRIiLEAST32 "i"
#define PRIdFAST32 "ld"
#define PRIiFAST32 "li"
#define PRIdFAST32 __PRIFAST "d"
#define PRIiFAST32 __PRIFAST "i"
#define PRId64 __PRI64 "d"
#define PRIi64 __PRI64 "i"
#define PRIdLEAST64 __PRI64 "d"
Expand Down Expand Up @@ -65,10 +67,10 @@
#define PRIuLEAST16 "u"
#define PRIxLEAST16 "x"
#define PRIXLEAST16 "X"
#define PRIoFAST16 "lo"
#define PRIuFAST16 "lu"
#define PRIxFAST16 "lx"
#define PRIXFAST16 "lX"
#define PRIoFAST16 __PRIFAST "o"
#define PRIuFAST16 __PRIFAST "u"
#define PRIxFAST16 __PRIFAST "x"
#define PRIXFAST16 __PRIFAST "X"
#define PRIo32 "o"
#define PRIu32 "u"
#define PRIx32 "x"
Expand All @@ -77,10 +79,10 @@
#define PRIuLEAST32 "u"
#define PRIxLEAST32 "x"
#define PRIXLEAST32 "X"
#define PRIoFAST32 "lo"
#define PRIuFAST32 "lu"
#define PRIxFAST32 "lx"
#define PRIXFAST32 "lX"
#define PRIoFAST32 __PRIFAST "o"
#define PRIuFAST32 __PRIFAST "u"
#define PRIxFAST32 __PRIFAST "x"
#define PRIXFAST32 __PRIFAST "X"
#define PRIo64 __PRI64 "o"
#define PRIu64 __PRI64 "u"
#define PRIx64 __PRI64 "x"
Expand Down
29 changes: 9 additions & 20 deletions options/ansi/include/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@
# define MB_LEN_MAX 4
#endif

#ifdef LONG_MAX
# ifdef LONG_MAX == INT32_MAX
# define LONG_BIT 32
# else
/* Safe assumption */
# define LONG_BIT 64
# endif
#elif defined __LONG_MAX__
# if __LONG_MAX__ == INT32_MAX
# define LONG_BIT 32
# else
/* Safe assumption */
# define LONG_BIT 64
# endif
#else
# error "Unsupported configuration, please define either LONG_MAX or __LONG_MAX__"
#endif

#undef SCHAR_MIN
#undef SCHAR_MAX
#undef CHAR_MIN
Expand Down Expand Up @@ -99,12 +81,19 @@
/* POSIX states 9 is the minimum for NL_ARGMAX */
#define NL_ARGMAX 9

#if INTPTR_MAX == INT64_MAX
#if __INTPTR_MAX__ == __INT64_MAX__
# define SSIZE_MAX LONG_MAX
#elif INTPTR_MAX == INT32_MAX
#elif __INTPTR_MAX__ == __INT32_MAX__
# define SSIZE_MAX INT_MAX
#endif

#if __LONG_MAX__ == __INT32_MAX__
# define LONG_BIT 32
#else
/* Safe assumption */
# define LONG_BIT 64
#endif

#define _POSIX_ARG_MAX 4096
#define _POSIX_OPEN_MAX 16
#define _POSIX_HOST_NAME_MAX 255
Expand Down
6 changes: 3 additions & 3 deletions options/elf/include/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct dl_phdr_info {
};

struct link_map {
Elf64_Addr l_addr;
ElfW(Addr) l_addr;
char *l_name;
ElfW(Dyn) *l_ld;
struct link_map *l_next, *l_prev;
Expand All @@ -38,9 +38,9 @@ struct link_map {
struct r_debug {
int r_version;
struct link_map *r_map;
Elf64_Addr r_brk;
ElfW(Addr) r_brk;
enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
Elf64_Addr r_ldbase;
ElfW(Addr) r_ldbase;
};

#ifndef __MLIBC_ABI_ONLY
Expand Down
6 changes: 6 additions & 0 deletions options/posix/include/netinet/icmp6.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,15 @@ struct nd_redirect {
#define nd_rd_code nd_rd_hdr.icmp6_code
#define nd_rd_cksum nd_rd_hdr.icmp6_cksum

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define ND_NA_FLAG_OVERRIDE 0x00000020
#define ND_NA_FLAG_SOLICITED 0x00000040
#define ND_NA_FLAG_ROUTER 0x00000080
#else
#define ND_NA_FLAG_OVERRIDE 0x20000000
#define ND_NA_FLAG_SOLICITED 0x40000000
#define ND_NA_FLAG_ROUTER 0x80000000
#endif

struct nd_opt_home_agent_info {
uint8_t nd_opt_home_agent_info_type;
Expand Down
1 change: 1 addition & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ all_test_cases = [
'posix/usershell',
'posix/shm',
'posix/swab',
'posix/select',
'glibc/getopt',
'glibc/ffsl-ffsll',
'glibc/error_message_count',
Expand Down
32 changes: 32 additions & 0 deletions tests/posix/select.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <assert.h>
#include <limits.h>
#include <sys/select.h>

int main() {
fd_set fds;
FD_ZERO(&fds);

assert(!FD_ISSET(0, &fds));
assert(!FD_ISSET(1, &fds));
assert(!FD_ISSET(FD_SETSIZE - 1, &fds));

FD_SET(0, &fds);
assert(fds.fds_bits[0] == 1);
FD_SET(1, &fds);
assert(fds.fds_bits[0] == 3);
FD_SET(FD_SETSIZE - 1, &fds);
assert(fds.fds_bits[(FD_SETSIZE / (CHAR_BIT * sizeof(fds.fds_bits[0]))) - 1] == (typeof(fds.fds_bits[0])) (1UL << ((sizeof(fds.fds_bits[0]) * 8) - 1)));

assert(FD_ISSET(0, &fds));
assert(FD_ISSET(1, &fds));
assert(FD_ISSET(FD_SETSIZE - 1, &fds));

FD_CLR(1, &fds);
assert(fds.fds_bits[0] == 1);

assert(FD_ISSET(0, &fds));
assert(!FD_ISSET(1, &fds));
assert(FD_ISSET(FD_SETSIZE - 1, &fds));

return 0;
}