From f4d95ce43f14576c124bfba7b571fc1745e62e4d Mon Sep 17 00:00:00 2001 From: oddcoder <ahmedsoliman@oddcoder.com> Date: Sun, 14 Jun 2020 21:55:22 +0200 Subject: [PATCH] Add sys/select.h to sys/types.h This was triggered by gcc for some reason It included sys/types.h and assumed sys/select.h to be there. And that seams to be the case in musl. The problem with relibc here is that sys/types.h is are part of relibc "include/*.h" files, while sys/select.h is generated by cbindgen. That makes it impossible to #include select.h in types.h epsecially that there are files like fcntl.c that uses types.h. They would complain about missing headers. I fixed this by renaming sys/types.h to sys/types_internal.h and then generating types.h using cbindgen as well except for that. however fcntl and dlmalloc can include types_internal instead of types.h --- include/sys/{types.h => types_internal.h} | 7 +++---- src/c/dlmalloc.c | 2 +- src/c/fcntl.c | 2 +- src/header/mod.rs | 1 + src/header/sys_types/cbindgen.toml | 7 +++++++ src/header/sys_types/mod.rs | 2 ++ 6 files changed, 15 insertions(+), 6 deletions(-) rename include/sys/{types.h => types_internal.h} (88%) create mode 100644 src/header/sys_types/cbindgen.toml create mode 100644 src/header/sys_types/mod.rs diff --git a/include/sys/types.h b/include/sys/types_internal.h similarity index 88% rename from include/sys/types.h rename to include/sys/types_internal.h index 19cf76bb7..5e533e810 100644 --- a/include/sys/types.h +++ b/include/sys/types_internal.h @@ -1,5 +1,5 @@ -#ifndef _SYS_TYPES_H -#define _SYS_TYPES_H +#ifndef _SYS_TYPES_INTERNAL_H +#define _SYS_TYPES_INTERNAL_H #include <stddef.h> typedef long blksize_t; @@ -31,5 +31,4 @@ typedef unsigned long u_long, ulong; typedef long long quad_t; typedef unsigned long long u_quad_t; typedef char *caddr_t; - -#endif /* _SYS_TYPES_H */ +#endif /* _SYS_TYPES_INTERNAL_H */ diff --git a/src/c/dlmalloc.c b/src/c/dlmalloc.c index 13db70031..8ae1f7a39 100644 --- a/src/c/dlmalloc.c +++ b/src/c/dlmalloc.c @@ -613,7 +613,7 @@ void *memset(void *s, int c, size_t n); #endif /* DARWIN */ #ifndef LACKS_SYS_TYPES_H -#include <sys/types.h> /* For size_t */ +#include <sys/types_internal.h> /* For size_t */ #endif /* LACKS_SYS_TYPES_H */ /* The maximum possible size_t value has all bits set */ diff --git a/src/c/fcntl.c b/src/c/fcntl.c index 76b92022e..23c48fa12 100644 --- a/src/c/fcntl.c +++ b/src/c/fcntl.c @@ -1,5 +1,5 @@ #include <stdarg.h> -#include <sys/types.h> +#include <sys/types_internal.h> // TODO: Can be implemented in rust when cbindgen supports "..." syntax diff --git a/src/header/mod.rs b/src/header/mod.rs index 81934256d..eb2bbeab0 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -51,6 +51,7 @@ pub mod arch_aarch64_user; pub mod arch_x64_user; pub mod sys_procfs; pub mod sys_random; +pub mod sys_types; pub mod sys_uio; pub mod sys_un; pub mod sys_utsname; diff --git a/src/header/sys_types/cbindgen.toml b/src/header/sys_types/cbindgen.toml new file mode 100644 index 000000000..c8b7fca74 --- /dev/null +++ b/src/header/sys_types/cbindgen.toml @@ -0,0 +1,7 @@ +sys_includes = ["stddef.h", "sys/types_internal.h", "sys/select.h"] +include_guard = "_SYS_TYPES_H" +language = "C" +style = "Tag" + +[enum] +prefix_with_name = true \ No newline at end of file diff --git a/src/header/sys_types/mod.rs b/src/header/sys_types/mod.rs new file mode 100644 index 000000000..c348094fc --- /dev/null +++ b/src/header/sys_types/mod.rs @@ -0,0 +1,2 @@ +//! sys/types.h +use crate::platform::types::*; -- GitLab