Skip to content

Commit

Permalink
Added missing libcxx headers and using:: declarations. (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZERICO2005 authored Jan 22, 2025
1 parent 26ea392 commit bb562f7
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/libc/include/fenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ int feupdateenv(const fenv_t *);
}
#endif

#endif
#endif /* _FENV_P_ONLY */

#endif
#endif /* _FENV_P */
6 changes: 3 additions & 3 deletions src/libc/include/float.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

#define FLT_RADIX __FLT_RADIX__

#if __STDC_VERSION__ >= 199901L
#if (__STDC_VERSION__ >= 199901L) || (defined(__cplusplus) && __cplusplus >= 201103L)
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__

#define DECIMAL_DIG __DECIMAL_DIG__
#endif

#if __STDC_VERSION__ >= 201112L
#if (__STDC_VERSION__ >= 201112L) || (defined(__cplusplus) && __cplusplus >= 201703L)
#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
Expand Down Expand Up @@ -64,4 +64,4 @@

#define FLT_ROUNDS ((__fe_cur_env ^ 1) & 3)

#endif
#endif /* _FLOAT_H */
2 changes: 1 addition & 1 deletion src/libc/include/inttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
#define SCNxMAX __UINTMAX_FMTx__

#define SCNdPTR __INTPTR_FMTd__
#define SCNiPTR __ INTPTR_FMTi__
#define SCNiPTR __INTPTR_FMTi__
#define SCNoPTR __UINTPTR_FMTo__
#define SCNuPTR __UINTPTR_FMTu__
#define SCNxPTR __UINTPTR_FMTx__
Expand Down
2 changes: 1 addition & 1 deletion src/libc/include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,4 @@ long double truncl(long double);
}
#endif

#endif
#endif /* _MATH_H */
2 changes: 1 addition & 1 deletion src/libc/include/setjmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ void longjmp(jmp_buf env, int val) __attribute__((noreturn));

__END_DECLS

#endif
#endif /* _SETJMP_H */
12 changes: 6 additions & 6 deletions src/libc/include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
#include <cdefs.h>

typedef struct {
int quot;
int rem;
int quot;
int rem;
} div_t;

typedef struct {
long quot;
long rem;
long quot;
long rem;
} ldiv_t;

typedef struct {
long long rem;
long long quot;
long long rem;
long long quot;
} lldiv_t;

#define EXIT_SUCCESS 0
Expand Down
2 changes: 1 addition & 1 deletion src/libc/include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void *memmove(void *dest, const void *src, size_t n)
void *memset(void *s, int c, size_t n) __attribute__((nonnull(1)));

int memcmp(const void *s1, const void *s2, size_t n)
__attribute__((nonnull(1, 2)));
__attribute__((nonnull(1, 2)));

void *memchr(const void *s, int c, size_t n) __attribute__((nonnull(1)));

Expand Down
18 changes: 9 additions & 9 deletions src/libc/include/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ typedef unsigned long time_t;
typedef unsigned long clock_t;

struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};

__BEGIN_DECLS
Expand Down
4 changes: 4 additions & 0 deletions src/libcxx/include/cassert
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// -*- C++ -*-
#ifndef _EZCXX_CASSERT
#define _EZCXX_CASSERT

#include <assert.h>

#pragma clang system_header

#endif // _EZCXX_CASSERT
1 change: 1 addition & 0 deletions src/libcxx/include/cctype
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace std {
using ::isalnum;
using ::isalpha;
using ::isblank;
using ::iscntrl;
using ::isdigit;
using ::isgraph;
Expand Down
13 changes: 13 additions & 0 deletions src/libcxx/include/cerrno
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// -*- C++ -*-
#ifndef _EZCXX_CERRNO
#define _EZCXX_CERRNO

#include <errno.h>

#pragma clang system_header

namespace std {
using ::errno;
} // namespace std

#endif // _EZCXX_CERRNO
9 changes: 9 additions & 0 deletions src/libcxx/include/cfloat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// -*- C++ -*-
#ifndef _EZCXX_CFLOAT
#define _EZCXX_CFLOAT

#include <float.h>

#pragma clang system_header

#endif // _EZCXX_CFLOAT
22 changes: 22 additions & 0 deletions src/libcxx/include/cinttypes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -*- C++ -*-
#ifndef _EZCXX_CINTTYPES
#define _EZCXX_CINTTYPES

#include <inttypes.h>
#include <cstdint>

#pragma clang system_header

namespace std {

using ::imaxdiv_t;

using ::imaxabs;
inline constexpr intmax_t abs(intmax_t __x) { return imaxabs(__x); }

using ::imaxdiv;
inline constexpr imaxdiv_t div(intmax_t __x, intmax_t __y) { return imaxdiv(__x, __y); }

} // namespace std

#endif // _EZCXX_CINTTYPES
9 changes: 9 additions & 0 deletions src/libcxx/include/ciso646
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// -*- C++ -*-
#ifndef _EZCXX_CISO646
#define _EZCXX_CISO646

#include <iso646.h>

#pragma clang system_header

#endif // _EZCXX_CISO646
2 changes: 1 addition & 1 deletion src/libcxx/include/concepts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ concept floating_point = is_floating_point_v<_Tp>;

} // namespace std

#endif // _EZCXX_CONCEPTS
#endif // _EZCXX_CONCEPTS
15 changes: 15 additions & 0 deletions src/libcxx/include/csetjmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// -*- C++ -*-
#ifndef _EZCXX_CSETJMP
#define _EZCXX_CSETJMP

#include <setjmp.h>

#pragma clang system_header

namespace std {
using ::jmp_buf;
using ::setjmp;
using ::longjmp;
} // namespace std

#endif // _EZCXX_CSETJMP
9 changes: 9 additions & 0 deletions src/libcxx/include/cstdalign
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// -*- C++ -*-
#ifndef _EZCXX_CSTDALIGN
#define _EZCXX_CSTDALIGN

#include <stdalign.h>

#pragma clang system_header

#endif // _EZCXX_CSTDALIGN
9 changes: 9 additions & 0 deletions src/libcxx/include/cstdbool
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// -*- C++ -*-
#ifndef _EZCXX_CSTDBOOL
#define _EZCXX_CSTDBOOL

#include <stdbool.h>

#pragma clang system_header

#endif // _EZCXX_CSTDBOOL
2 changes: 2 additions & 0 deletions src/libcxx/include/cstdint
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ using::int8_t;
using::int16_t;
using::int24_t;
using::int32_t;
using::int48_t;
using::int64_t;

using::uint8_t;
using::uint16_t;
using::uint24_t;
using::uint32_t;
using::uint48_t;
using::uint64_t;

using::int_least8_t;
Expand Down
11 changes: 11 additions & 0 deletions src/libcxx/include/cstdlib
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ using ::free;
using ::atof;
using ::atoi;
using ::atol;
using ::atoll;
using ::strtof;
using ::strtod;
using ::strtol;
using ::strtoll;
using ::strtoul;
using ::strtoull;

using ::srand;
using ::rand;
Expand All @@ -36,8 +39,16 @@ using ::_Exit;

using ::abs;
using ::labs;
using ::llabs;
inline constexpr long abs(long __x) { return labs(__x); }
inline constexpr long long abs(long long __x) { return llabs(__x); }

using ::div;
using ::ldiv;
using ::lldiv;
inline constexpr ldiv_t div(long __x, long __y) { return ldiv(__x, __y); }
inline constexpr lldiv_t div(long long __x, long long __y) { return lldiv(__x, __y); }

} // namespace std

#endif // _EZCXX_CSTDLIB
25 changes: 25 additions & 0 deletions src/libcxx/include/ctime
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// -*- C++ -*-
#ifndef _EZCXX_CTIME
#define _EZCXX_CTIME

#include <time.h>

#pragma clang system_header

namespace std {
using ::clock_t;
using ::time_t;
using ::tm;

using ::clock;
using ::difftime;
using ::mktime;
using ::time;
using ::localtime;
using ::gmtime;
using ::asctime;
using ::ctime;
using ::strftime;
} // namespace std

#endif // _EZCXX_CTIME

0 comments on commit bb562f7

Please sign in to comment.