Browse Source

Merge branch 'stdc-compatiability' into 'master'

Stdc compatiability

See merge request redox-os/relibc!258
Jeremy Soller 5 years ago
parent
commit
77a0294114
2 changed files with 38 additions and 2 deletions
  1. 28 0
      include/features.h
  2. 10 2
      include/stddef.h

+ 28 - 0
include/features.h

@@ -0,0 +1,28 @@
+/*
+ * MIT License
+ * Copyright (c) 2020 Rich Felker musl-libc
+ */
+
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
+#define __inline inline
+#elif !defined(__GNUC__)
+#define __inline
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#elif defined(__GNUC__)
+#define _Noreturn __attribute__((__noreturn__))
+#else
+#define _Noreturn
+#endif
+
+#endif

+ 10 - 2
include/stddef.h

@@ -4,12 +4,20 @@
 
 #define NULL 0
 
-typedef signed long long ptrdiff_t;
+#ifndef __PTRDIFF_TYPE__
+#define __PTRDIFF_TYPE__ long int
+#endif
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
 
+#ifndef __cplusplus
 typedef int32_t wchar_t;
+#endif /* #ifndef __cplusplus */
 typedef int32_t wint_t;
 
-typedef unsigned long long size_t;
+
+typedef long unsigned int size_t;
+
+typedef struct { long long __ll; long double __ld; } max_align_t;
 
 #define offsetof(type, member) __builtin_offsetof(type, member)