Browse Source

Use patched cbindgen, implement stdbool and stdint

Jeremy Soller 7 years ago
parent
commit
d64dba1c1e
8 changed files with 62 additions and 14 deletions
  1. 3 0
      .gitmodules
  2. 0 4
      Cargo.toml
  3. 1 0
      cbindgen
  4. 1 1
      fcntl/Cargo.toml
  5. 9 0
      include/stdbool.h
  6. 47 2
      include/stdint.h
  7. 0 6
      include/stdlib.h
  8. 1 1
      unistd/Cargo.toml

+ 3 - 0
.gitmodules

@@ -1,3 +1,6 @@
 [submodule "openlibm"]
 	path = openlibm
 	url = https://github.com/redox-os/openlibm.git
+[submodule "cbindgen"]
+	path = cbindgen
+	url = https://github.com/redox-os/cbindgen.git

+ 0 - 4
Cargo.toml

@@ -8,10 +8,6 @@ name = "c"
 crate-type = ["staticlib"]
 
 [workspace]
-members = [
-    "fcntl",
-    "unistd"
-]
 
 [dependencies]
 fcntl = { path = "fcntl" }

+ 1 - 0
cbindgen

@@ -0,0 +1 @@
+Subproject commit 97ceb5862f397b14c5b63cd60af7f5f345ad065c

+ 1 - 1
fcntl/Cargo.toml

@@ -5,7 +5,7 @@ authors = ["Jeremy Soller <[email protected]>"]
 build = "build.rs"
 
 [build-dependencies]
-cbindgen = "0.5"
+cbindgen = { path = "../cbindgen" }
 
 [dependencies]
 common = { path = "../common" }

+ 9 - 0
include/stdbool.h

@@ -0,0 +1,9 @@
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+typedef _Bool bool;
+#define true 1
+#define false 0
+#define __bool_true_false_are_defined 1
+
+#endif /* _STDBOOL_H */

+ 47 - 2
include/stdint.h

@@ -1,7 +1,52 @@
 #ifndef _STDINT_H
 #define _STDINT_H
 
-typedef int int32_t;
-typedef int intptr_t;
+#define INT8_MIN -0x80
+#define INT8_MAX 0x7F
+typedef signed char int8_t;
+
+#define UINT8_MIN 0x00
+#define UINT8_MAX 0xFF
+typedef unsigned char uint8_t;
+
+#define INT16_MIN -0x8000
+#define INT16_MAX 0x7FFF
+typedef signed short int16_t;
+
+#define UINT16_MIN 0x0000
+#define UINT16_MAX 0xFFFF
+typedef unsigned short uint16_t;
+
+#define INT32_MIN -0x80000000
+#define INT32_MAX 0x7FFFFFFF
+typedef signed long int32_t;
+
+#define UINT32_MIN 0x00000000
+#define UINT32_MAX 0xFFFFFFFF
+typedef unsigned long uint32_t;
+
+#define INT64_MIN -0x8000000000000000
+#define INT64_MAX 0x7FFFFFFFFFFFFFFF
+typedef signed long long int64_t;
+
+#define UINT64_MIN 0x0000000000000000
+#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
+typedef unsigned long long uint64_t;
+
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+typedef int64_t intptr_t;
+
+#define UINTPTR_MIN UINT64_MIN
+#define UINTPTR_MAX UINT64_MAX
+typedef uint64_t uintptr_t;
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+typedef int64_t intmax_t;
+
+#define UINTMAX_MIN UINT64_MIN
+#define UINTMAX_MAX UINT64_MAX
+typedef uint64_t uintmax_t;
 
 #endif /* _STDINT_H */

+ 0 - 6
include/stdlib.h

@@ -1,6 +0,0 @@
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#include <sys/types.h>
-
-#endif /* _STDLIB_H */

+ 1 - 1
unistd/Cargo.toml

@@ -5,7 +5,7 @@ authors = ["Jeremy Soller <[email protected]>"]
 build = "build.rs"
 
 [build-dependencies]
-cbindgen = "0.5"
+cbindgen = { path = "../cbindgen" }
 
 [dependencies]
 common = { path = "../common" }