Browse Source

- Disable output of empty header files
- Remove incorrect header styles
- Use export.replace where header style was previously needed
- Check compilation of tests using system gcc

Jeremy Soller 6 years ago
parent
commit
950b4526c7

+ 4 - 3
Makefile

@@ -31,6 +31,7 @@ all: | libc libm
 clean:
 	$(CARGO) clean
 	make -C tests clean
+	rm -rf sysroot
 
 check:
 	$(CARGO) check
@@ -39,16 +40,16 @@ fmt:
 	./fmt.sh
 
 install: all
-	mkdir -pv "$(DESTDIR)/lib"
 	mkdir -pv "$(DESTDIR)/include"
 	cp -rv "include"/* "$(DESTDIR)/include"
 	cp -rv "$(BUILD)/include"/* "$(DESTDIR)/include"
+	cp -v "openlibm/include"/*.h "$(DESTDIR)/include"
+	cp -v "openlibm/src"/*.h "$(DESTDIR)/include"
+	mkdir -pv "$(DESTDIR)/lib"
 	cp -v "$(BUILD)/release/libc.a" "$(DESTDIR)/lib"
 	cp -v "$(BUILD)/release/crt0.o" "$(DESTDIR)/lib"
 	cp -v "$(BUILD)/release/crti.o" "$(DESTDIR)/lib"
 	cp -v "$(BUILD)/release/crtn.o" "$(DESTDIR)/lib"
-	cp -rv "openlibm/include"/* "$(DESTDIR)/include"
-	cp -rv "openlibm/src"/*.h "$(DESTDIR)/include"
 	cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
 
 libc: $(BUILD)/release/libc.a $(BUILD)/release/crt0.o $(BUILD)/release/crti.o $(BUILD)/release/crtn.o $(BUILD)/include

+ 1 - 2
include/complex.h

@@ -1,2 +1 @@
-#define OPENLIBM_USE_HOST_FENV_H 1
-#include <openlibm.h>
+#include <openlibm_complex.h>

+ 1 - 4
include/math.h

@@ -1,4 +1 @@
-#define OPENLIBM_USE_HOST_FENV_H 1
-#include <openlibm.h>
-#undef I
-#undef complex
+#include <openlibm_math.h>

+ 0 - 0
src/header/aio/cbindgen.toml → src/header/_aio/cbindgen.toml


+ 0 - 0
src/header/aio/mod.rs → src/header/_aio/mod.rs


+ 0 - 0
src/header/grp/cbindgen.toml → src/header/_grp/cbindgen.toml


+ 0 - 0
src/header/grp/mod.rs → src/header/_grp/mod.rs


+ 0 - 0
src/header/wctype/cbindgen.toml → src/header/_wctype/cbindgen.toml


+ 0 - 0
src/header/wctype/mod.rs → src/header/_wctype/mod.rs


+ 3 - 0
src/header/arpa_inet/cbindgen.toml

@@ -5,3 +5,6 @@ style = "Tag"
 
 [enum]
 prefix_with_name = true
+
+[export.rename]
+"in_addr" = "struct in_addr"

+ 1 - 1
src/header/limits/cbindgen.toml

@@ -1,8 +1,8 @@
 sys_includes = []
 include_guard = "_LIMITS_H"
+trailer = "#include <bits/limits.h>"
 language = "C"
 style = "Tag"
-trailer = "#include <bits/limits.h>"
 
 [enum]
 prefix_with_name = true

+ 3 - 3
src/header/mod.rs

@@ -1,4 +1,4 @@
-pub mod aio;
+pub mod _aio;
 pub mod arpa_inet;
 pub mod assert;
 pub mod ctype;
@@ -9,7 +9,7 @@ pub mod fenv;
 pub mod float;
 pub mod fnmatch;
 pub mod getopt;
-pub mod grp;
+pub mod _grp;
 pub mod inttypes;
 pub mod libgen;
 pub mod limits;
@@ -45,4 +45,4 @@ pub mod time;
 pub mod unistd;
 pub mod utime;
 pub mod wchar;
-pub mod wctype;
+pub mod _wctype;

+ 0 - 7
src/header/netinet_in/Cargo.toml

@@ -1,7 +0,0 @@
-[package]
-name = "netinet"
-version = "0.1.0"
-authors = ["Dan Robertson <[email protected]>"]
-
-[dependencies]
-in_h = { path = "in" }

+ 1 - 1
src/header/netinet_in/cbindgen.toml

@@ -1,7 +1,7 @@
 sys_includes = ["sys/types.h", "sys/socket.h"]
 include_guard = "_NETINET_IN_H"
-style = "Both"
 language = "C"
+style = "Tag"
 
 [export]
 include = ["sockaddr_in6", "sockaddr_in", "ipv6_mreq"]

+ 1 - 1
src/header/sgtty/cbindgen.toml

@@ -1,7 +1,7 @@
 sys_includes = ["sys/ioctl.h"]
 include_guard = "_SGTTY_H"
-style = "Tag"
 language = "C"
+style = "Tag"
 
 [enum]
 prefix_with_name = true

+ 1 - 1
src/header/signal/cbindgen.toml

@@ -1,7 +1,7 @@
 sys_includes = ["stdint.h", "sys/types.h", "bits/signal.h"]
 include_guard = "_SIGNAL_H"
-style = "Tag"
 language = "C"
+style = "Tag"
 
 [defines]
 "target_os=linux" = "__linux__"

+ 1 - 4
src/header/sys_ioctl/cbindgen.toml

@@ -1,9 +1,6 @@
 include_guard = "_SYS_IOCTL_H"
 language = "C"
-
-# WORKAROUND:
-# sgtty is used by another header, and cbindgen doesn't prefix that with `struct` :|
-style = "Both"
+style = "Tag"
 
 [defines]
 "target_os=linux" = "__linux__"

+ 4 - 4
src/header/sys_resource/cbindgen.toml

@@ -2,10 +2,10 @@ sys_includes = ["sys/types.h", "stdint.h", "sys/time.h"]
 include_guard = "_SYS_RESOURCE_H"
 trailer = "#include <bits/sys/resource.h>"
 language = "C"
-
-# WORKAROUND:
-# Rusage is used by another header, and cbindgen does not prefix that usage with `struct` :|
-style = "Both"
+style = "Tag"
 
 [enum]
 prefix_with_name = true
+
+[export.rename]
+"timeval" = "struct timeval"

+ 3 - 1
src/header/sys_select/cbindgen.toml

@@ -8,5 +8,7 @@ prefix_with_name = true
 
 [export]
 # fd_set is also defined in C because cbindgen is incompatible with mem::size_of booo
-
 exclude = ["FD_SETSIZE", "fd_set"]
+
+[export.rename]
+"timeval" = "struct timeval"

+ 1 - 1
src/header/sys_socket/cbindgen.toml

@@ -1,7 +1,7 @@
 sys_includes = ["stddef.h", "stdint.h", "sys/types.h"]
 include_guard = "_SYS_SOCKET_H"
-style = "Both"
 language = "C"
+style = "Tag"
 
 [defines]
 "target_os=linux" = "__linux__"

+ 3 - 0
src/header/sys_stat/cbindgen.toml

@@ -6,3 +6,6 @@ style = "Tag"
 
 [enum]
 prefix_with_name = true
+
+[export.rename]
+"timespec" = "struct timespec"

+ 1 - 4
src/header/sys_time/cbindgen.toml

@@ -2,10 +2,7 @@ sys_includes = ["sys/types.h"]
 include_guard = "_SYS_TIME_H"
 language = "C"
 trailer = "#include <bits/sys/time.h>"
-
-# WORKAROUND:
-# Timeval is used by another header, and cbindgen doesn't prefix that with `struct` :|
-style = "Both"
+style = "Tag"
 
 [enum]
 prefix_with_name = true

+ 1 - 1
src/header/sys_wait/cbindgen.toml

@@ -1,8 +1,8 @@
 sys_includes = ["sys/types.h", "sys/resource.h"]
 include_guard = "_SYS_WAIT_H"
-style = "Type"
 trailer = "#include <bits/sys/wait.h>"
 language = "C"
+style = "Tag"
 
 [enum]
 prefix_with_name = true

+ 1 - 4
src/header/time/cbindgen.toml

@@ -1,10 +1,7 @@
 sys_includes = ["sys/types.h", "stdint.h", "stddef.h"]
 include_guard = "_TIME_H"
 language = "C"
-
-# WORKAROUND:
-# Tm is used by another header, and cbindgen doesn't prefix that with `struct` :|
-style = "Both"
+style = "Tag"
 
 [enum]
 prefix_with_name = true

+ 1 - 1
tests/stdio/fseek.c

@@ -8,5 +8,5 @@ int main() {
     }
     char buffer[256];
     printf("%s", fgets(buffer, 256, f));
-    printf("ftell: %d\n", ftello(f));
+    printf("ftell: %ld\n", ftello(f));
 }

+ 1 - 0
tests/stdlib/alloc.c

@@ -1,3 +1,4 @@
+#include <malloc.h>
 #include <stdio.h>
 #include <stdlib.h>
 

+ 1 - 1
tests/sys_utsname/uname.c

@@ -14,6 +14,6 @@ int main() {
         printf("release: '%s'\n", system_info.release);
         printf("version: '%s'\n", system_info.version);
         printf("machine: '%s'\n", system_info.machine);
-        printf("domainname: '%s'\n", system_info.domainname);
+        //printf("domainname: '%s'\n", system_info.domainname);
     }
 }

+ 1 - 1
tests/time/asctime.c

@@ -5,7 +5,7 @@
 
 int main(int argc, char** argv) {
     time_t a = 0;
-    tm *time_info = gmtime(&a);
+    struct tm *time_info = gmtime(&a);
 
     char *time_string = asctime(time_info);
 

+ 2 - 2
tests/time/gmtime.c

@@ -5,10 +5,10 @@
 
 int main(int argc, char** argv) {
     time_t a = 0;
-    tm expected = { .tm_sec = 0, .tm_min = 0, .tm_hour = 0, .tm_mday = 1, .tm_year = 70,
+    struct tm expected = { .tm_sec = 0, .tm_min = 0, .tm_hour = 0, .tm_mday = 1, .tm_year = 70,
                     .tm_wday = 4, .tm_yday = 0, .tm_isdst = 0, .tm_gmtoff = 0, .tm_zone = "UTC" };
 
-    tm *info = gmtime(&a);
+    struct tm *info = gmtime(&a);
     if (info->tm_sec != expected.tm_sec || info->tm_min != expected.tm_min ||
         info->tm_hour != expected.tm_hour || info->tm_mday != expected.tm_mday ||
         info->tm_year != expected.tm_year || info->tm_wday != expected.tm_wday ||

+ 1 - 1
tests/time/time.c

@@ -2,7 +2,7 @@
 #include <stdio.h>
 
 int main(int argc, char** argv) {
-    timespec tm = {0, 0};
+    struct timespec tm = {0, 0};
     clock_gettime(CLOCK_REALTIME, &tm);
     perror("clock_gettime");
     time(NULL);

+ 2 - 2
tests/unistd/pipe.c

@@ -32,7 +32,7 @@ int main()
             perror("pipe write");
             return 1;
         } else if (bytes != strlen(outstring)) {
-            fprintf(stderr, "pipe write: %d != %d\n", bytes, strlen(outstring));
+            fprintf(stderr, "pipe write: %d != %ld\n", bytes, strlen(outstring));
             return 1;
         }
 
@@ -57,7 +57,7 @@ int main()
             perror("pipe read");
             return 1;
         } else if (bytes != strlen(outstring)) {
-            fprintf(stderr, "pipe read: %d != %d\n", bytes, strlen(outstring));
+            fprintf(stderr, "pipe read: %d != %ld\n", bytes, strlen(outstring));
             return 1;
         } else if (memcmp(instring, outstring, sizeof(outstring)) != 0) {
             fprintf(stderr, "pipe read does not match pipe write\n");

+ 1 - 1
tests/unistd/sleep.c

@@ -7,7 +7,7 @@ int main(int argc, char** argv) {
     perror("sleep");
     usleep(1000);
     perror("usleep");
-    timespec tm = {0, 10000};
+    struct timespec tm = {0, 10000};
     nanosleep(&tm, NULL);
     perror("nanosleep");
     return 0;

+ 5 - 4
tests/wchar/mbsrtowcs.c

@@ -1,6 +1,7 @@
 #include <stdio.h>
+#include <string.h>
 #include <wchar.h>
- 
+
 void print_as_wide(const char* mbstr)
 {
     mbstate_t state;
@@ -10,14 +11,14 @@ void print_as_wide(const char* mbstr)
     mbsrtowcs(&wstr[0], &mbstr, len, &state);
 
     //Should be 5
-    printf("The length, including '\\0': %i \n",len);
+    printf("The length, including '\\0': %li \n",len);
 
     //missing wprintf to print this wide string
     //wprintf(L"The wide string: %ls \n", &wstr[0]);
 }
- 
+
 int main()
 {
     const char* mbstr = u8"z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌"
     print_as_wide(mbstr);
-}
+}