From 950b4526c79a1e80b26a75e2f220a534bda964ac Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jeremy@system76.com> Date: Mon, 26 Nov 2018 21:35:02 -0700 Subject: [PATCH] - 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 --- Makefile | 7 ++++--- include/complex.h | 3 +-- include/math.h | 5 +---- src/header/{aio => _aio}/cbindgen.toml | 0 src/header/{aio => _aio}/mod.rs | 0 src/header/{grp => _grp}/cbindgen.toml | 0 src/header/{grp => _grp}/mod.rs | 0 src/header/{wctype => _wctype}/cbindgen.toml | 0 src/header/{wctype => _wctype}/mod.rs | 0 src/header/arpa_inet/cbindgen.toml | 3 +++ src/header/limits/cbindgen.toml | 2 +- src/header/mod.rs | 6 +++--- src/header/netinet_in/Cargo.toml | 7 ------- src/header/netinet_in/cbindgen.toml | 2 +- src/header/sgtty/cbindgen.toml | 2 +- src/header/signal/cbindgen.toml | 2 +- src/header/sys_ioctl/cbindgen.toml | 5 +---- src/header/sys_resource/cbindgen.toml | 8 ++++---- src/header/sys_select/cbindgen.toml | 4 +++- src/header/sys_socket/cbindgen.toml | 2 +- src/header/sys_stat/cbindgen.toml | 3 +++ src/header/sys_time/cbindgen.toml | 5 +---- src/header/sys_wait/cbindgen.toml | 2 +- src/header/time/cbindgen.toml | 5 +---- tests/stdio/fseek.c | 2 +- tests/stdlib/alloc.c | 1 + tests/sys_utsname/uname.c | 2 +- tests/time/asctime.c | 2 +- tests/time/gmtime.c | 4 ++-- tests/time/time.c | 2 +- tests/unistd/pipe.c | 4 ++-- tests/unistd/sleep.c | 2 +- tests/wchar/mbsrtowcs.c | 9 +++++---- 33 files changed, 46 insertions(+), 55 deletions(-) rename src/header/{aio => _aio}/cbindgen.toml (100%) rename src/header/{aio => _aio}/mod.rs (100%) rename src/header/{grp => _grp}/cbindgen.toml (100%) rename src/header/{grp => _grp}/mod.rs (100%) rename src/header/{wctype => _wctype}/cbindgen.toml (100%) rename src/header/{wctype => _wctype}/mod.rs (100%) delete mode 100644 src/header/netinet_in/Cargo.toml diff --git a/Makefile b/Makefile index 074fe4ee0..6cf390cf7 100644 --- a/Makefile +++ b/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 diff --git a/include/complex.h b/include/complex.h index 5ce9f25af..5ae2f020d 100644 --- a/include/complex.h +++ b/include/complex.h @@ -1,2 +1 @@ -#define OPENLIBM_USE_HOST_FENV_H 1 -#include <openlibm.h> +#include <openlibm_complex.h> diff --git a/include/math.h b/include/math.h index 7b69f5f07..82d66d596 100644 --- a/include/math.h +++ b/include/math.h @@ -1,4 +1 @@ -#define OPENLIBM_USE_HOST_FENV_H 1 -#include <openlibm.h> -#undef I -#undef complex +#include <openlibm_math.h> diff --git a/src/header/aio/cbindgen.toml b/src/header/_aio/cbindgen.toml similarity index 100% rename from src/header/aio/cbindgen.toml rename to src/header/_aio/cbindgen.toml diff --git a/src/header/aio/mod.rs b/src/header/_aio/mod.rs similarity index 100% rename from src/header/aio/mod.rs rename to src/header/_aio/mod.rs diff --git a/src/header/grp/cbindgen.toml b/src/header/_grp/cbindgen.toml similarity index 100% rename from src/header/grp/cbindgen.toml rename to src/header/_grp/cbindgen.toml diff --git a/src/header/grp/mod.rs b/src/header/_grp/mod.rs similarity index 100% rename from src/header/grp/mod.rs rename to src/header/_grp/mod.rs diff --git a/src/header/wctype/cbindgen.toml b/src/header/_wctype/cbindgen.toml similarity index 100% rename from src/header/wctype/cbindgen.toml rename to src/header/_wctype/cbindgen.toml diff --git a/src/header/wctype/mod.rs b/src/header/_wctype/mod.rs similarity index 100% rename from src/header/wctype/mod.rs rename to src/header/_wctype/mod.rs diff --git a/src/header/arpa_inet/cbindgen.toml b/src/header/arpa_inet/cbindgen.toml index 4e00706ff..5daf2b0e7 100644 --- a/src/header/arpa_inet/cbindgen.toml +++ b/src/header/arpa_inet/cbindgen.toml @@ -5,3 +5,6 @@ style = "Tag" [enum] prefix_with_name = true + +[export.rename] +"in_addr" = "struct in_addr" diff --git a/src/header/limits/cbindgen.toml b/src/header/limits/cbindgen.toml index e25e6c670..a30a93ab2 100644 --- a/src/header/limits/cbindgen.toml +++ b/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 diff --git a/src/header/mod.rs b/src/header/mod.rs index e02ccd3ef..2b872ccf4 100644 --- a/src/header/mod.rs +++ b/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; diff --git a/src/header/netinet_in/Cargo.toml b/src/header/netinet_in/Cargo.toml deleted file mode 100644 index eccbe4ee9..000000000 --- a/src/header/netinet_in/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "netinet" -version = "0.1.0" -authors = ["Dan Robertson <danlrobertson89@gmail.com>"] - -[dependencies] -in_h = { path = "in" } diff --git a/src/header/netinet_in/cbindgen.toml b/src/header/netinet_in/cbindgen.toml index e6241ead1..53b7362a4 100644 --- a/src/header/netinet_in/cbindgen.toml +++ b/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"] diff --git a/src/header/sgtty/cbindgen.toml b/src/header/sgtty/cbindgen.toml index 910143569..e93ce1bf3 100644 --- a/src/header/sgtty/cbindgen.toml +++ b/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 diff --git a/src/header/signal/cbindgen.toml b/src/header/signal/cbindgen.toml index 53986d342..9c8f81a17 100644 --- a/src/header/signal/cbindgen.toml +++ b/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__" diff --git a/src/header/sys_ioctl/cbindgen.toml b/src/header/sys_ioctl/cbindgen.toml index 40b2c3fbd..076a5c0ab 100644 --- a/src/header/sys_ioctl/cbindgen.toml +++ b/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__" diff --git a/src/header/sys_resource/cbindgen.toml b/src/header/sys_resource/cbindgen.toml index 606e604b4..3cc67a2d5 100644 --- a/src/header/sys_resource/cbindgen.toml +++ b/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" diff --git a/src/header/sys_select/cbindgen.toml b/src/header/sys_select/cbindgen.toml index a8038e749..2dc2a15bc 100644 --- a/src/header/sys_select/cbindgen.toml +++ b/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" diff --git a/src/header/sys_socket/cbindgen.toml b/src/header/sys_socket/cbindgen.toml index cafa4389d..41c88c45f 100644 --- a/src/header/sys_socket/cbindgen.toml +++ b/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__" diff --git a/src/header/sys_stat/cbindgen.toml b/src/header/sys_stat/cbindgen.toml index 073794146..921ba6d19 100644 --- a/src/header/sys_stat/cbindgen.toml +++ b/src/header/sys_stat/cbindgen.toml @@ -6,3 +6,6 @@ style = "Tag" [enum] prefix_with_name = true + +[export.rename] +"timespec" = "struct timespec" diff --git a/src/header/sys_time/cbindgen.toml b/src/header/sys_time/cbindgen.toml index 232e796d7..d4f553679 100644 --- a/src/header/sys_time/cbindgen.toml +++ b/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 diff --git a/src/header/sys_wait/cbindgen.toml b/src/header/sys_wait/cbindgen.toml index 1f9e768ed..7396a4319 100644 --- a/src/header/sys_wait/cbindgen.toml +++ b/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 diff --git a/src/header/time/cbindgen.toml b/src/header/time/cbindgen.toml index 6186533ac..3dfc4c452 100644 --- a/src/header/time/cbindgen.toml +++ b/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 diff --git a/tests/stdio/fseek.c b/tests/stdio/fseek.c index 4bed8733c..84f544d2a 100644 --- a/tests/stdio/fseek.c +++ b/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)); } diff --git a/tests/stdlib/alloc.c b/tests/stdlib/alloc.c index 6c1d04d04..bfb867340 100644 --- a/tests/stdlib/alloc.c +++ b/tests/stdlib/alloc.c @@ -1,3 +1,4 @@ +#include <malloc.h> #include <stdio.h> #include <stdlib.h> diff --git a/tests/sys_utsname/uname.c b/tests/sys_utsname/uname.c index c58c8cb19..05ad03401 100644 --- a/tests/sys_utsname/uname.c +++ b/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); } } diff --git a/tests/time/asctime.c b/tests/time/asctime.c index 6462d44cc..a2a3db03f 100644 --- a/tests/time/asctime.c +++ b/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); diff --git a/tests/time/gmtime.c b/tests/time/gmtime.c index 59a71a79c..836822db3 100644 --- a/tests/time/gmtime.c +++ b/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 || diff --git a/tests/time/time.c b/tests/time/time.c index 5c60f4a4c..bf827b1c0 100644 --- a/tests/time/time.c +++ b/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); diff --git a/tests/unistd/pipe.c b/tests/unistd/pipe.c index cbd3caffb..af5b2d89a 100644 --- a/tests/unistd/pipe.c +++ b/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"); diff --git a/tests/unistd/sleep.c b/tests/unistd/sleep.c index 40672c278..cf395a783 100644 --- a/tests/unistd/sleep.c +++ b/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; diff --git a/tests/wchar/mbsrtowcs.c b/tests/wchar/mbsrtowcs.c index 1ee1560a9..070cabc3c 100644 --- a/tests/wchar/mbsrtowcs.c +++ b/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); -} \ No newline at end of file +} -- GitLab