diff --git a/Makefile b/Makefile index 074fe4ee0314567fd2e78a1c974fddbf6d1c6d4d..6cf390cf7b49c3080e3983ad4541dcfe5377570f 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 5ce9f25af7bb3ffa55b39cfee699360b541a50a2..5ae2f020d5fe67c1d7a87ff335fe2dd4fd957dd8 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 7b69f5f073fed9112f0ee10e057e6038e61470d4..82d66d596628df06b0de6e4df08849add2ec21f9 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 4e00706ff5608869db49a112bed5c9e402029937..5daf2b0e71855d59cf79b872aa36d37d627957b7 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 e25e6c67054a296c1e56543597a80fa3eb5b3788..a30a93ab2de42d4d36873cd30d3826f93c982feb 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 e02ccd3ef622c964a952aa2e26d319534fe32536..2b872ccf4348062c1409a946c57fcbc8b66c331a 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 eccbe4ee946f16f08bdc0199b9f56eddae72f4e6..0000000000000000000000000000000000000000 --- 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 e6241ead1994f9060d43bede113ec49d9c717ac9..53b7362a43283b541e949f5dab2a0decfde20273 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 910143569c16113e4386eb33b808d667d2f1b589..e93ce1bf3e600fb2bcbcca008e085e726a2de1ef 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 53986d3423cb6f046a4740d7269425f8683a144a..9c8f81a1726e219ab8bc36f4511dcd525e6d9a6c 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 40b2c3fbd1902932820852de4e9a985c43e0879f..076a5c0abc26f8c456028e7a85b3cee5742681e1 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 606e604b4020ec9a9e80b9f3e851200646b8522a..3cc67a2d5bd5e2f46822d51f9f2ea17bf023f823 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 a8038e749725e7db12408cba8a739044044f8072..2dc2a15bc63092729cce8bac399a516273d68195 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 cafa4389ddaa4b801e3371389b98ded19e5101fa..41c88c45f5e833f40124ee549c494c28e42d4ae4 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 073794146a83d87d33b8f058d64053010ca32c6f..921ba6d19bcfc28b2335f6e6311a9f9e6e88e5a7 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 232e796d7f777dbfc70b6c13595d3bd34a4f29f5..d4f553679887e833fa7e3603639a67ff1f631b39 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 1f9e768edfee676f6df3d2e8ccd3592736b027a0..7396a4319f820cea76d874c0de48d441f6c6ffea 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 6186533acd472c57ef62037c528777fd639be8ef..3dfc4c45209efaa3ed46d01d9eaa701cc36d2a28 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 4bed8733c5efa84db9916a163304a6e09356d377..84f544d2a2dee968051600c52cd7c2ca216119b5 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 6c1d04d045d06310b306f0b18556e05a62120cd8..bfb8673400f0b4b350f3e341f7345c36ec78798d 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 c58c8cb1922b5b138116db27af1846ae6fc96a1f..05ad034019bc004d0546cca99cefb57784e98a90 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 6462d44ccc9210ed3268c2f8e31f2bf4fb8b961f..a2a3db03ff36eafe60c64af90d54409463d1f498 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 59a71a79cd1d341ed1b8644074fbe2f7238e4128..836822db350a171b0166f9f02663e41cf9001690 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 5c60f4a4c36c6e4a877404192f5860b88cdb45b8..bf827b1c00df4cf6f44a6924eed2de6a77007be5 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 cbd3caffb74e31bad7c0a5893090c6fda8cd1cc4..af5b2d89ae13156a7cae3e775d9d3176342a768e 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 40672c278c8b30a0271aeaf7931190c12bfa6b20..cf395a783971d7c3be5bfaa9f54b0141d7f5f8ed 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 1ee1560a9f7c27dc13369a6694fbb2ce61543cf5..070cabc3cd748ff156d08765b60611c899dce2cd 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 +}