From dbabf5211212cfe8689138b422d1a9281df7a59a Mon Sep 17 00:00:00 2001 From: Tom Kuchler Date: Tue, 23 Sep 2025 16:19:10 +0200 Subject: [PATCH 01/16] Fix formatting --- newlib_shim/unistd.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/newlib_shim/unistd.c b/newlib_shim/unistd.c index 2d2eae6..a46c626 100644 --- a/newlib_shim/unistd.c +++ b/newlib_shim/unistd.c @@ -2,7 +2,11 @@ #include // Implement functions from unistd that are not already defined in other parts +<<<<<<< HEAD // of newlibs libc or in something we supply +======= +// of newlibs libc Or in something we supply +>>>>>>> Fix formatting // unsigned alarm (unsigned __secs); int chdir(const char *__path) { @@ -22,6 +26,7 @@ int chroot(const char *__path) { // int chmod (const char *__path, mode_t __mode); // int chown (const char *__path, uid_t __owner, gid_t __group); +<<<<<<< HEAD // int close_range (unsigned int __firstfd, unsigned int __lastfd, int // __flags); @@ -32,6 +37,12 @@ int chroot(const char *__path) { // char * ctermid (char *__s); char * cuserid (char *__s); +======= +// int close_range (unsigned int __firstfd, unsigned int __lastfd, int +// __flags); size_t confstr (int __name, char *__buf, size_t __len); char * +// crypt (const char *__key, const char *__salt); char * ctermid (char *__s); +// char * cuserid (char *__s); +>>>>>>> Fix formatting // int daemon (int nochdir, int noclose); // function to duplicate file descriptor to second file number @@ -67,12 +78,17 @@ int execv(const char *__path, char *const __argv[]) { } // already given in newlib // int execve (const char *__path, char * const __argv[], char * const +<<<<<<< HEAD // __envp[]); // int execvp (const char *__file, char * const __argv[]); // int execvpe (const char *__file, char * const __argv[], char * const // __envp[]); +======= +// __envp[]); int execvp (const char *__file, char * const __argv[]); int +// execvpe (const char *__file, char * const __argv[], char * const __envp[]); +>>>>>>> Fix formatting // #if __ATFILE_VISIBLE // int faccessat (int __dirfd, const char *__path, int __mode, int __flags); // #endif @@ -81,6 +97,7 @@ int execv(const char *__path, char *const __argv[]) { // int fchown (int __fildes, uid_t __owner, gid_t __group); // #if __ATFILE_VISIBLE // int fchownat (int __dirfd, const char *__path, uid_t __owner, gid_t __group, +<<<<<<< HEAD // int __flags); // #endif // int fexecve (int __fd, char * const __argv[], char * const __envp[]); @@ -89,6 +106,12 @@ int execv(const char *__path, char *const __argv[]) { int fsync(int __fd) { return 0; } int fdatasync(int __fd) { return 0; } +======= +// int __flags); #endif int fexecve (int __fd, char * const __argv[], char * +// const __envp[]); long fpathconf (int __fd, int __name); +int fsync(int __fd) { return 0; } +int fdatasync(int __fd) { return 0; } +>>>>>>> Fix formatting // char * get_current_dir_name (void); char *getcwd(char *__buf, size_t __size) { return "/"; } // int getdomainname (char *__name, size_t __len); @@ -113,6 +136,7 @@ char *getcwd(char *__buf, size_t __size) { return "/"; } // char * getwd (char *__buf); // int lchown (const char *__path, uid_t __owner, gid_t __group); // #if __ATFILE_VISIBLE +<<<<<<< HEAD // int linkat (int __dirfd1, const char *__path1, int __dirfd2, const char // *__path2, int __flags); @@ -128,12 +152,22 @@ char *getcwd(char *__buf, size_t __size) { return "/"; } // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void)); // #endif // int pipe (int __fildes[2]) { +======= +// int linkat (int __dirfd1, const char *__path1, int __dirfd2, const char +// *__path2, int __flags); #endif #if __MISC_VISIBLE || __XSI_VISIBLE int +// nice (int __nice_value); #endif #if __MISC_VISIBLE || __XSI_VISIBLE >= 4 int +// lockf (int __fd, int __cmd, off_t __len); #endif long pathconf (const char +// *__path, int __name); int pause (void); #if __POSIX_VISIBLE >= 199506 int +// pthread_atfork (void (*)(void), void (*)(void), void (*)(void)); #endif int +// pipe (int __fildes[2]) { +>>>>>>> Fix formatting // pipe2(__fileds[2], 0); // } // int pipe2 (int __fildes[2], int flags); // #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500 // ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset); // ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t +<<<<<<< HEAD // __offset); // #endif _READ_WRITE_RETURN_TYPE @@ -154,6 +188,16 @@ char *getcwd(char *__buf, size_t __size) { return "/"; } // int seteuid(uid_t __uid); // #endif // int setgid(gid_t __gid); +======= +// __offset); #endif _READ_WRITE_RETURN_TYPE read (int __fd, void *__buf, size_t +// __nbyte); #if __BSD_VISIBLE int rresvport (int *__alport); int revoke +// (char *__path); #endif int rmdir (const char *__path); #if __BSD_VISIBLE +// int ruserok (const char *rhost, int superuser, const char *ruser, const char +// *luser); #endif #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < +// 200112) void * sbrk (ptrdiff_t __incr); #endif #if __BSD_VISIBLE || +// __POSIX_VISIBLE >= 200112 int setegid (gid_t __gid); int seteuid +// (uid_t __uid); #endif int setgid (gid_t __gid); +>>>>>>> Fix formatting int setgroups(int ngroups, const gid_t *grouplist) { *__errno() = EPERM; return -1; From 1efb0c90bfd6010930f7bb6dcf9cb400ae2c8389 Mon Sep 17 00:00:00 2001 From: tom-kuchler <87128754+tom-kuchler@users.noreply.github.com> Date: Tue, 23 Sep 2025 15:57:43 +0200 Subject: [PATCH 02/16] Add dev container, fix bugs in compiler setup (#20) Features added: * Add clang include directory to cfg * Adding statiging release * Add dev container * Add runtime library interface * Adding first version of unistd.c * Adding print for exit code at debug exit Bug Fixes: * Fix bugs in compiler cfg template * Fix namecmp to recognize substrings as non equal * Fix abi thread local issue, add test program build to top level cmake project * Fix makro in cmake template * Fix debug to handle unlimited number of input items or input-/outputsets --- .github/workflows/release_experimental.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release_experimental.yml b/.github/workflows/release_experimental.yml index 4c81d76..5d220e9 100644 --- a/.github/workflows/release_experimental.yml +++ b/.github/workflows/release_experimental.yml @@ -1,9 +1,10 @@ -name: release latest with all library versions +name: release experimental with all library versions on: - pull_request: + push: branches: [ "dev/staging" ] + jobs: build: strategy: From 2f1aae3cb488513f2d3d8dd04403ee5ab9661c12 Mon Sep 17 00:00:00 2001 From: tom-kuchler <87128754+tom-kuchler@users.noreply.github.com> Date: Mon, 10 Nov 2025 18:08:15 +0100 Subject: [PATCH 03/16] Dev/staging (#23) * Add dev container * Add clang include directory to cfg * Adding staging release * Add runtime library interface * Adding first version of unistd.c * Adding print for exit code at debug exit Bug Fixes: * Fix bugs in compiler cfg template * Fix namecmp to recognize substrings as non equal * Fix abi thread local issue, add test program build to top level cmake project * Fix makro in cmake template * Fix debug to handle unlimited number of input items or input-/outputsets * Fix formatting * update kvm exit to use interrupt 32 instead of direct halt (#22) --- newlib_shim/unistd.c | 46 +------------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/newlib_shim/unistd.c b/newlib_shim/unistd.c index a46c626..afcc9e5 100644 --- a/newlib_shim/unistd.c +++ b/newlib_shim/unistd.c @@ -2,11 +2,7 @@ #include // Implement functions from unistd that are not already defined in other parts -<<<<<<< HEAD // of newlibs libc or in something we supply -======= -// of newlibs libc Or in something we supply ->>>>>>> Fix formatting // unsigned alarm (unsigned __secs); int chdir(const char *__path) { @@ -26,7 +22,6 @@ int chroot(const char *__path) { // int chmod (const char *__path, mode_t __mode); // int chown (const char *__path, uid_t __owner, gid_t __group); -<<<<<<< HEAD // int close_range (unsigned int __firstfd, unsigned int __lastfd, int // __flags); @@ -37,12 +32,6 @@ int chroot(const char *__path) { // char * ctermid (char *__s); char * cuserid (char *__s); -======= -// int close_range (unsigned int __firstfd, unsigned int __lastfd, int -// __flags); size_t confstr (int __name, char *__buf, size_t __len); char * -// crypt (const char *__key, const char *__salt); char * ctermid (char *__s); -// char * cuserid (char *__s); ->>>>>>> Fix formatting // int daemon (int nochdir, int noclose); // function to duplicate file descriptor to second file number @@ -78,17 +67,12 @@ int execv(const char *__path, char *const __argv[]) { } // already given in newlib // int execve (const char *__path, char * const __argv[], char * const -<<<<<<< HEAD // __envp[]); -// int execvp (const char *__file, char * const __argv[]); +// int execvp (const char *__file, char * const __argv[]); // int execvpe (const char *__file, char * const __argv[], char * const // __envp[]); -======= -// __envp[]); int execvp (const char *__file, char * const __argv[]); int -// execvpe (const char *__file, char * const __argv[], char * const __envp[]); ->>>>>>> Fix formatting // #if __ATFILE_VISIBLE // int faccessat (int __dirfd, const char *__path, int __mode, int __flags); // #endif @@ -97,7 +81,6 @@ int execv(const char *__path, char *const __argv[]) { // int fchown (int __fildes, uid_t __owner, gid_t __group); // #if __ATFILE_VISIBLE // int fchownat (int __dirfd, const char *__path, uid_t __owner, gid_t __group, -<<<<<<< HEAD // int __flags); // #endif // int fexecve (int __fd, char * const __argv[], char * const __envp[]); @@ -106,12 +89,6 @@ int execv(const char *__path, char *const __argv[]) { int fsync(int __fd) { return 0; } int fdatasync(int __fd) { return 0; } -======= -// int __flags); #endif int fexecve (int __fd, char * const __argv[], char * -// const __envp[]); long fpathconf (int __fd, int __name); -int fsync(int __fd) { return 0; } -int fdatasync(int __fd) { return 0; } ->>>>>>> Fix formatting // char * get_current_dir_name (void); char *getcwd(char *__buf, size_t __size) { return "/"; } // int getdomainname (char *__name, size_t __len); @@ -136,7 +113,6 @@ char *getcwd(char *__buf, size_t __size) { return "/"; } // char * getwd (char *__buf); // int lchown (const char *__path, uid_t __owner, gid_t __group); // #if __ATFILE_VISIBLE -<<<<<<< HEAD // int linkat (int __dirfd1, const char *__path1, int __dirfd2, const char // *__path2, int __flags); @@ -152,22 +128,12 @@ char *getcwd(char *__buf, size_t __size) { return "/"; } // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void)); // #endif // int pipe (int __fildes[2]) { -======= -// int linkat (int __dirfd1, const char *__path1, int __dirfd2, const char -// *__path2, int __flags); #endif #if __MISC_VISIBLE || __XSI_VISIBLE int -// nice (int __nice_value); #endif #if __MISC_VISIBLE || __XSI_VISIBLE >= 4 int -// lockf (int __fd, int __cmd, off_t __len); #endif long pathconf (const char -// *__path, int __name); int pause (void); #if __POSIX_VISIBLE >= 199506 int -// pthread_atfork (void (*)(void), void (*)(void), void (*)(void)); #endif int -// pipe (int __fildes[2]) { ->>>>>>> Fix formatting // pipe2(__fileds[2], 0); // } // int pipe2 (int __fildes[2], int flags); // #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500 // ssize_t pread (int __fd, void *__buf, size_t __nbytes, off_t __offset); // ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, off_t -<<<<<<< HEAD // __offset); // #endif _READ_WRITE_RETURN_TYPE @@ -188,16 +154,6 @@ char *getcwd(char *__buf, size_t __size) { return "/"; } // int seteuid(uid_t __uid); // #endif // int setgid(gid_t __gid); -======= -// __offset); #endif _READ_WRITE_RETURN_TYPE read (int __fd, void *__buf, size_t -// __nbyte); #if __BSD_VISIBLE int rresvport (int *__alport); int revoke -// (char *__path); #endif int rmdir (const char *__path); #if __BSD_VISIBLE -// int ruserok (const char *rhost, int superuser, const char *ruser, const char -// *luser); #endif #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < -// 200112) void * sbrk (ptrdiff_t __incr); #endif #if __BSD_VISIBLE || -// __POSIX_VISIBLE >= 200112 int setegid (gid_t __gid); int seteuid -// (uid_t __uid); #endif int setgid (gid_t __gid); ->>>>>>> Fix formatting int setgroups(int ngroups, const gid_t *grouplist) { *__errno() = EPERM; return -1; From 1954ab72bcfdf5fcc81da95180995ad9c31150bd Mon Sep 17 00:00:00 2001 From: tom-kuchler <87128754+tom-kuchler@users.noreply.github.com> Date: Fri, 19 Dec 2025 11:45:18 +0100 Subject: [PATCH 04/16] Fix bug with buffers going to previous sets (#25) * Add dev container, fix bugs in compiler setup Features added: * Add clang include directory to cfg * Adding statiging release * Add dev container * Add runtime library interface * Adding first version of unistd.c * Adding print for exit code at debug exit Bug Fixes: * Fix bugs in compiler cfg template * Fix namecmp to recognize substrings as non equal * Fix abi thread local issue, add test program build to top level cmake project * Fix makro in cmake template * Fix debug to handle unlimited number of input items or input-/outputsets * Fix formatting * update kvm exit to use interrupt 32 instead of direct halt (#22) * Fix bug with buffers going to previous sets --- system/platform/debug/debug.c | 14 +++++++++----- test_programs/libcpp/CMakeLists.txt | 4 ++++ test_programs/libcpp/input_1.txt | 1 + test_programs/libcpp/input_2.txt | 1 + test_programs/libcpp/test.cpp | 23 +++++++++++++++++++++-- 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 test_programs/libcpp/input_1.txt create mode 100644 test_programs/libcpp/input_2.txt diff --git a/system/platform/debug/debug.c b/system/platform/debug/debug.c index 143b347..e02bdf0 100644 --- a/system/platform/debug/debug.c +++ b/system/platform/debug/debug.c @@ -186,6 +186,7 @@ void __dandelion_platform_init(void) { sysdata.input_bufs = heap_ptr; for (size_t input_set = 0; input_set < input_set_index; input_set++) { + input_sets[input_set].offset = total_buffers; write_all(1, "\t", 1); write_all(1, input_sets[input_set].ident, input_sets[input_set].ident_len); write_all(1, "\n", 1); @@ -250,8 +251,6 @@ void __dandelion_platform_init(void) { } if (set_dirent_read < 0) print_and_exit("getdents failed\n", -dirent_read); - - input_sets[input_set].offset = total_buffers; } // set up sentinel set @@ -328,16 +327,21 @@ void __dandelion_platform_exit(void) { char exit_message[] = "Exiting with code "; size_t message_len = my_strlen(exit_message); write_all(1, exit_message, message_len); - char exit_code_string[11] = " \n"; + char exit_code_string[12] = " 0000000000\n"; // convert int to string int exit_code = sysdata.exit_code; + // remove sign + if (exit_code < 0) { + exit_code_string[0] = '-'; + exit_code *= -1; + } for (size_t index = 0; index < 10; index++) { - exit_code_string[9 - index] = '0' + (exit_code % 10); + exit_code_string[10 - index] = '0' + (exit_code % 10); exit_code = exit_code / 10; if (exit_code == 0) break; } - write_all(1, exit_code_string, 11); + write_all(1, exit_code_string, 12); __syscall(SYS_exit_group, sysdata.exit_code); __builtin_unreachable(); } diff --git a/test_programs/libcpp/CMakeLists.txt b/test_programs/libcpp/CMakeLists.txt index 9080e3a..8922f48 100644 --- a/test_programs/libcpp/CMakeLists.txt +++ b/test_programs/libcpp/CMakeLists.txt @@ -14,5 +14,9 @@ target_link_libraries(${TEST} PRIVATE # prepare files to run the function in debug mode file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/input_sets) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/input_sets/in_a) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/input_1.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/input_sets/in_a) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/input_sets/in_b) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/input_2.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/input_sets/in_b) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output_sets) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output_sets/stdio) \ No newline at end of file diff --git a/test_programs/libcpp/input_1.txt b/test_programs/libcpp/input_1.txt new file mode 100644 index 0000000..01db5dd --- /dev/null +++ b/test_programs/libcpp/input_1.txt @@ -0,0 +1 @@ +first input file \ No newline at end of file diff --git a/test_programs/libcpp/input_2.txt b/test_programs/libcpp/input_2.txt new file mode 100644 index 0000000..e98c3f9 --- /dev/null +++ b/test_programs/libcpp/input_2.txt @@ -0,0 +1 @@ +second input file \ No newline at end of file diff --git a/test_programs/libcpp/test.cpp b/test_programs/libcpp/test.cpp index 4511115..dac8884 100644 --- a/test_programs/libcpp/test.cpp +++ b/test_programs/libcpp/test.cpp @@ -1,15 +1,34 @@ #include #include +#include using namespace std; int main(){ - // cout << "Hello World" << endl; std::fstream fs; fs.open("/stdio/stdout", std::fstream::out); - fs << " test print " << endl; + fs << "test print " << endl; fs.close(); + std::fstream in1; + string in_file_1 = "/in_a/input_1.txt"; + in1.open(in_file_1, std::fstream::in); + if (!in1) { + cerr << "Failed to open " << in_file_1 << endl; + return -1; + } + cout << in1.rdbuf() << endl; + in1.close(); + std::fstream in2; + string in_file_2 = "/in_b/input_2.txt"; + in2.open(in_file_2, std::fstream::in); + if (!in2) { + cerr << "Failed to open " << in_file_2 << endl; + return -1; + } + cerr << in2.rdbuf() << endl; + in2.close(); + cout << "stdout print" << endl; cerr << "stderr print" << endl; return 0; From 6bbbd95d6f9e7abb7bbc2ddc079780956e828513 Mon Sep 17 00:00:00 2001 From: tom-kuchler <87128754+tom-kuchler@users.noreply.github.com> Date: Mon, 22 Dec 2025 16:03:56 +0100 Subject: [PATCH 05/16] Dev/libc extension (#26) * Added sys/uio, sys/socket and netdb * Move additional source and header files for libc to separate library --------- Co-authored-by: Tobias Stocker --- CMakeLists.txt | 7 +- libc_extension/CMakeLists.txt | 39 +++ {newlib_shim => libc_extension}/dirent.c | 0 libc_extension/include/netdb.h | 75 +++++ .../include/sys}/cpuset.h | 0 .../include/sys}/dirent.h | 0 .../include/sys}/sched.h | 0 libc_extension/include/sys/socket.h | 269 ++++++++++++++++++ .../include/sys}/statvfs.h | 11 +- libc_extension/include/sys/uio.h | 33 +++ libc_extension/netdb.c | 66 +++++ libc_extension/socket.c | 73 +++++ libc_extension/uio.c | 9 + newlib_shim/Makefile.inc | 1 - newlib_shim/patch_script | 9 - newlib_shim/shim.c | 11 - sdk_install/CMakeTemplate.txt | 1 + sdk_install/clang-template.cmake | 1 + 18 files changed, 581 insertions(+), 24 deletions(-) create mode 100644 libc_extension/CMakeLists.txt rename {newlib_shim => libc_extension}/dirent.c (100%) create mode 100644 libc_extension/include/netdb.h rename {newlib_shim => libc_extension/include/sys}/cpuset.h (100%) rename {newlib_shim => libc_extension/include/sys}/dirent.h (100%) rename {newlib_shim => libc_extension/include/sys}/sched.h (100%) create mode 100644 libc_extension/include/sys/socket.h rename {newlib_shim => libc_extension/include/sys}/statvfs.h (84%) create mode 100644 libc_extension/include/sys/uio.h create mode 100644 libc_extension/netdb.c create mode 100644 libc_extension/socket.c create mode 100644 libc_extension/uio.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f18cb68..e540d7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,11 @@ if(NEWLIB) ) add_dependencies(dlibc newlib) + # Additional headers / code needed to get libc to linux compatibility + set(LIBC_EXTENSION "c_extension") + add_subdirectory(libc_extension) + add_dependencies(${LIBC_EXTENSION} dlibc) + set(LLVM_C_FLAGS "-D_GNU_SOURCE=1") string(APPEND LLVM_C_FLAGS " -D_POSIX_TIMERS") string(APPEND LLVM_C_FLAGS " -D_POSIX_THREADS") @@ -228,7 +233,7 @@ if(NEWLIB) -DLIBCXX_ENABLE_RANDOM_DEVICE=OFF -DLIBCXX_HAS_PTHREAD_API=ON ) - add_dependencies(llvmproject newlib) + add_dependencies(llvmproject newlib ${LIBC_EXTENSION}) # Create folder at configuration time to avoid issues with includes file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/include/c++/v1) diff --git a/libc_extension/CMakeLists.txt b/libc_extension/CMakeLists.txt new file mode 100644 index 0000000..89b8e8f --- /dev/null +++ b/libc_extension/CMakeLists.txt @@ -0,0 +1,39 @@ +add_library(${LIBC_EXTENSION} STATIC) + +target_sources(${LIBC_EXTENSION} + PRIVATE + dirent.c + netdb.c + socket.c + uio.c + PUBLIC FILE_SET public_headers TYPE HEADERS + BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/ + FILES + include/netdb.h + include/sys/cpuset.h + include/sys/dirent.h + include/sys/sched.h + include/sys/socket.h + include/sys/statvfs.h + include/sys/uio.h +) + +if(CMAKE_BUILD_TYPE MATCHES "Debug") + target_compile_definitions(${LIBC_EXTENSION} PRIVATE DEBUG) + target_compile_options(${LIBC_EXTENSION} PRIVATE -g) +endif() + +target_link_libraries(${LIBC_EXTENSION} PRIVATE dlibc) + +include(GNUInstallDirs) +install(TARGETS ${LIBC_EXTENSION} + ARCHIVE FILE_SET public_headers + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ +) + +# always install after building, so the headers are available for libcxx +add_custom_command( + TARGET ${LIBC_EXTENSION} + POST_BUILD + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_CURRENT_BINARY_DIR} +) \ No newline at end of file diff --git a/newlib_shim/dirent.c b/libc_extension/dirent.c similarity index 100% rename from newlib_shim/dirent.c rename to libc_extension/dirent.c diff --git a/libc_extension/include/netdb.h b/libc_extension/include/netdb.h new file mode 100644 index 0000000..7e6c133 --- /dev/null +++ b/libc_extension/include/netdb.h @@ -0,0 +1,75 @@ +#ifndef _NETDB_H +#define _NETDB_H 1 + +#include +#include + +/* Description of data base entry for a single host. */ +struct hostent +{ + char *h_name; /* Official name of host. */ + char **h_aliases; /* Alias list. */ + int h_addrtype; /* Host address type. */ + int h_length; /* Length of address. */ + char **h_addr_list; /* List of addresses from name server. */ +}; + +/* Description of data base entry for a single network. NOTE: here a + poor assumption is made. The network number is expected to fit + into an unsigned long int variable. */ +struct netent +{ + char *n_name; /* Official name of network. */ + char **n_aliases; /* Alias list. */ + int n_addrtype; /* Net address type. */ + uint32_t n_net; /* Network number. */ +}; + +/* Description of data base entry for a single service. */ +struct protoent +{ + char *p_name; /* Official protocol name. */ + char **p_aliases; /* Alias list. */ + int p_proto; /* Protocol number. */ +}; + +/* Description of data base entry for a single service. */ +struct servent +{ + char *s_name; /* Official service name. */ + char **s_aliases; /* Alias list. */ + int s_port; /* Port number. */ + char *s_proto; /* Protocol to use. */ +}; + +# define IPPORT_RESERVED 1024 + +extern int h_errno; + +# define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */ +# define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL. */ +# define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */ +# define NO_DATA 4 /* Valid name, no data record of requested type. */ + +extern void endhostent (void); +extern void endnetent (void); +extern void endprotoent (void); +extern void endservent (void); +extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len, int __type); +extern struct hostent *gethostbyname (const char *__name); +extern struct hostent *gethostent (void); +extern struct netent *getnetbyaddr (uint32_t __net, int __type); +extern struct netent *getnetbyname (const char *__name); +extern struct netent *getnetent (void); +extern struct protoent *getprotobyname (const char *__name); +extern struct protoent *getprotobynumber (int __proto); +extern struct protoent *getprotoent (void); +extern struct servent *getservbyname (const char *__name, const char *__proto); +extern struct servent *getservbyport (int __port, const char *__proto); +extern struct servent *getservent (void); +extern void sethostent (int __stay_open); +extern void setnetent (int __stay_open); +extern void setprotoent (int __stay_open); +extern void setservent (int __stay_open); + +#endif // _NETDB_H \ No newline at end of file diff --git a/newlib_shim/cpuset.h b/libc_extension/include/sys/cpuset.h similarity index 100% rename from newlib_shim/cpuset.h rename to libc_extension/include/sys/cpuset.h diff --git a/newlib_shim/dirent.h b/libc_extension/include/sys/dirent.h similarity index 100% rename from newlib_shim/dirent.h rename to libc_extension/include/sys/dirent.h diff --git a/newlib_shim/sched.h b/libc_extension/include/sys/sched.h similarity index 100% rename from newlib_shim/sched.h rename to libc_extension/include/sys/sched.h diff --git a/libc_extension/include/sys/socket.h b/libc_extension/include/sys/socket.h new file mode 100644 index 0000000..b0eb27a --- /dev/null +++ b/libc_extension/include/sys/socket.h @@ -0,0 +1,269 @@ +#ifndef _SYS_SOCKET_H +#define _SYS_SOCKET_H 1 + +#include + +/* Type for length arguments in socket calls. */ +typedef unsigned int socklen_t; + +/* POSIX.1g specifies this type name for the `sa_family' member. */ +typedef unsigned short int sa_family_t; + +/* Structure describing a generic socket address. */ +struct sockaddr +{ + sa_family_t sa_family; /* Common data: address family and length. */ + char sa_data[14]; /* Address data. */ +}; + +/* Structure large enough to hold any socket address (with the historical + exception of AF_UNIX). */ +struct sockaddr_storage +{ + sa_family_t ss_family; /* Address family, etc. */ + char __ss_padding[(128 - (sizeof (unsigned short int)) - sizeof (unsigned long int))]; + unsigned long int __ss_align; /* Force desired alignment. */ +}; + +/* Structure describing messages sent by + `sendmsg' and received by `recvmsg'. */ +struct msghdr +{ + void *msg_name; /* Address to send to/receive from. */ + socklen_t msg_namelen; /* Length of address data. */ + + struct iovec *msg_iov; /* Vector of data to send/receive into. */ + size_t msg_iovlen; /* Number of elements in the vector. */ + + void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ + size_t msg_controllen; /* Ancillary data buffer length. + !! The type should be socklen_t but the + definition of the kernel is incompatible + with this. */ + + int msg_flags; /* Flags on received message. */ +}; + +/* Structure used for storage of ancillary data object information. */ +struct cmsghdr +{ + size_t cmsg_len; /* Length of data in cmsg_data plus length + of cmsghdr structure. + !! The type should be socklen_t but the + definition of the kernel is incompatible + with this. */ + int cmsg_level; /* Originating protocol. */ + int cmsg_type; /* Protocol specific type. */ +}; + +/* Types of sockets. */ +enum __socket_type +{ + SOCK_STREAM = 1, /* Sequenced, reliable, connection-based + byte streams. */ +#define SOCK_STREAM SOCK_STREAM + SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams + of fixed maximum length. */ +#define SOCK_DGRAM SOCK_DGRAM + SOCK_RAW = 3, /* Raw protocol interface. */ +#define SOCK_RAW SOCK_RAW + SOCK_RDM = 4, /* Reliably-delivered messages. */ +#define SOCK_RDM SOCK_RDM + SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based, + datagrams of fixed maximum length. */ +#define SOCK_SEQPACKET SOCK_SEQPACKET + SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */ +#define SOCK_DCCP SOCK_DCCP + SOCK_PACKET = 10, /* Linux specific way of getting packets + at the dev level. For writing rarp and + other similar things on the user level. */ +#define SOCK_PACKET SOCK_PACKET + + /* Flags to be ORed into the type parameter of socket and socketpair and + used for the flags parameter of paccept. */ + + SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the + new descriptor(s). */ +#define SOCK_CLOEXEC SOCK_CLOEXEC + SOCK_NONBLOCK = 00004000 /* Atomically mark descriptor(s) as + non-blocking. */ +#define SOCK_NONBLOCK SOCK_NONBLOCK +}; + +/* Protocol families. */ +#define PF_UNSPEC 0 /* Unspecified. */ +#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ +#define PF_UNIX PF_LOCAL /* POSIX name for PF_LOCAL. */ +#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ +#define PF_INET 2 /* IP protocol family. */ +#define PF_AX25 3 /* Amateur Radio AX.25. */ +#define PF_IPX 4 /* Novell Internet Protocol. */ +#define PF_APPLETALK 5 /* Appletalk DDP. */ +#define PF_NETROM 6 /* Amateur radio NetROM. */ +#define PF_BRIDGE 7 /* Multiprotocol bridge. */ +#define PF_ATMPVC 8 /* ATM PVCs. */ +#define PF_X25 9 /* Reserved for X.25 project. */ +#define PF_INET6 10 /* IP version 6. */ +#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */ +#define PF_DECnet 12 /* Reserved for DECnet project. */ +#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */ +#define PF_SECURITY 14 /* Security callback pseudo AF. */ +#define PF_KEY 15 /* PF_KEY key management API. */ +#define PF_NETLINK 16 +#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */ +#define PF_PACKET 17 /* Packet family. */ +#define PF_ASH 18 /* Ash. */ +#define PF_ECONET 19 /* Acorn Econet. */ +#define PF_ATMSVC 20 /* ATM SVCs. */ +#define PF_RDS 21 /* RDS sockets. */ +#define PF_SNA 22 /* Linux SNA Project */ +#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_PPPOX 24 /* PPPoX sockets. */ +#define PF_WANPIPE 25 /* Wanpipe API sockets. */ +#define PF_LLC 26 /* Linux LLC. */ +#define PF_IB 27 /* Native InfiniBand address. */ +#define PF_MPLS 28 /* MPLS. */ +#define PF_CAN 29 /* Controller Area Network. */ +#define PF_TIPC 30 /* TIPC sockets. */ +#define PF_BLUETOOTH 31 /* Bluetooth sockets. */ +#define PF_IUCV 32 /* IUCV sockets. */ +#define PF_RXRPC 33 /* RxRPC sockets. */ +#define PF_ISDN 34 /* mISDN sockets. */ +#define PF_PHONET 35 /* Phonet sockets. */ +#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */ +#define PF_CAIF 37 /* CAIF sockets. */ +#define PF_ALG 38 /* Algorithm sockets. */ +#define PF_NFC 39 /* NFC sockets. */ +#define PF_VSOCK 40 /* vSockets. */ +#define PF_KCM 41 /* Kernel Connection Multiplexor. */ +#define PF_QIPCRTR 42 /* Qualcomm IPC Router. */ +#define PF_SMC 43 /* SMC sockets. */ +#define PF_XDP 44 /* XDP sockets. */ +#define PF_MCTP 45 /* Management component transport protocol. */ +#define PF_MAX 46 /* For now.. */ + +/* Address families. */ +#define AF_UNSPEC PF_UNSPEC +#define AF_LOCAL PF_LOCAL +#define AF_UNIX PF_UNIX +#define AF_FILE PF_FILE +#define AF_INET PF_INET +#define AF_AX25 PF_AX25 +#define AF_IPX PF_IPX +#define AF_APPLETALK PF_APPLETALK +#define AF_NETROM PF_NETROM +#define AF_BRIDGE PF_BRIDGE +#define AF_ATMPVC PF_ATMPVC +#define AF_X25 PF_X25 +#define AF_INET6 PF_INET6 +#define AF_ROSE PF_ROSE +#define AF_DECnet PF_DECnet +#define AF_NETBEUI PF_NETBEUI +#define AF_SECURITY PF_SECURITY +#define AF_KEY PF_KEY +#define AF_NETLINK PF_NETLINK +#define AF_ROUTE PF_ROUTE +#define AF_PACKET PF_PACKET +#define AF_ASH PF_ASH +#define AF_ECONET PF_ECONET +#define AF_ATMSVC PF_ATMSVC +#define AF_RDS PF_RDS +#define AF_SNA PF_SNA +#define AF_IRDA PF_IRDA +#define AF_PPPOX PF_PPPOX +#define AF_WANPIPE PF_WANPIPE +#define AF_LLC PF_LLC +#define AF_IB PF_IB +#define AF_MPLS PF_MPLS +#define AF_CAN PF_CAN +#define AF_TIPC PF_TIPC +#define AF_BLUETOOTH PF_BLUETOOTH +#define AF_IUCV PF_IUCV +#define AF_RXRPC PF_RXRPC +#define AF_ISDN PF_ISDN +#define AF_PHONET PF_PHONET +#define AF_IEEE802154 PF_IEEE802154 +#define AF_CAIF PF_CAIF +#define AF_ALG PF_ALG +#define AF_NFC PF_NFC +#define AF_VSOCK PF_VSOCK +#define AF_KCM PF_KCM +#define AF_QIPCRTR PF_QIPCRTR +#define AF_SMC PF_SMC +#define AF_XDP PF_XDP +#define AF_MCTP PF_MCTP +#define AF_MAX PF_MAX + +/* Bits in the FLAGS argument to `send', `recv', et al. */ +enum + { + MSG_OOB = 0x01, /* Process out-of-band data. */ +#define MSG_OOB MSG_OOB + MSG_PEEK = 0x02, /* Peek at incoming messages. */ +#define MSG_PEEK MSG_PEEK + MSG_DONTROUTE = 0x04, /* Don't use local routing. */ +#define MSG_DONTROUTE MSG_DONTROUTE + MSG_CTRUNC = 0x08, /* Control data lost before delivery. */ +#define MSG_CTRUNC MSG_CTRUNC + MSG_PROXY = 0x10, /* Supply or ask second address. */ +#define MSG_PROXY MSG_PROXY + MSG_TRUNC = 0x20, +#define MSG_TRUNC MSG_TRUNC + MSG_DONTWAIT = 0x40, /* Nonblocking IO. */ +#define MSG_DONTWAIT MSG_DONTWAIT + MSG_EOR = 0x80, /* End of record. */ +#define MSG_EOR MSG_EOR + MSG_WAITALL = 0x100, /* Wait for a full request. */ +#define MSG_WAITALL MSG_WAITALL + MSG_FIN = 0x200, +#define MSG_FIN MSG_FIN + MSG_SYN = 0x400, +#define MSG_SYN MSG_SYN + MSG_CONFIRM = 0x800, /* Confirm path validity. */ +#define MSG_CONFIRM MSG_CONFIRM + MSG_RST = 0x1000, +#define MSG_RST MSG_RST + MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */ +#define MSG_ERRQUEUE MSG_ERRQUEUE + MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */ +#define MSG_NOSIGNAL MSG_NOSIGNAL + MSG_MORE = 0x8000, /* Sender will send more. */ +#define MSG_MORE MSG_MORE + MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/ +#define MSG_WAITFORONE MSG_WAITFORONE + MSG_BATCH = 0x40000, /* sendmmsg: more messages coming. */ +#define MSG_BATCH MSG_BATCH + MSG_ZEROCOPY = 0x4000000, /* Use user data in kernel path. */ +#define MSG_ZEROCOPY MSG_ZEROCOPY + MSG_FASTOPEN = 0x20000000, /* Send data in TCP SYN. */ +#define MSG_FASTOPEN MSG_FASTOPEN + + MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file + descriptor received through + SCM_RIGHTS. */ +#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC + }; + +extern int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len); +extern int bind (int __fd, const struct sockaddr *__addr, socklen_t __len); +extern int connect (int __fd, const struct sockaddr *__addr, socklen_t __len); +extern int getpeername (int __fd, struct sockaddr __addr, socklen_t *__len); +extern int getsockname (int __fd, struct sockaddr __addr, socklen_t *__len); +extern int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen); +extern int listen (int __fd, int __n); +extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags); +extern ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr __addr, + socklen_t *__addr_len); +extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags); +extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags); +extern ssize_t sendmsg (int __fd, const struct msghdr *__message, int __flags); +extern ssize_t sendto (int __fd, const void *__buf, size_t __n, int __flags, + const struct sockaddr *__addr, socklen_t __addr_len); +extern int setsockopt (int __fd, int __level, int __optname, const void *__optval, + socklen_t __optlen); +extern int shutdown (int __fd, int __how); +extern int socket (int __domain, int __type, int __protocol); +extern int sockatmark (int __fd); +extern int socketpair (int __domain, int __type, int __protocol, int __fds[2]); + +#endif // _SYS_SOCKET_H \ No newline at end of file diff --git a/newlib_shim/statvfs.h b/libc_extension/include/sys/statvfs.h similarity index 84% rename from newlib_shim/statvfs.h rename to libc_extension/include/sys/statvfs.h index 8ce27de..9677900 100644 --- a/newlib_shim/statvfs.h +++ b/libc_extension/include/sys/statvfs.h @@ -6,6 +6,7 @@ extern "C" { #endif #include +#include #define ST_RDONLY 1 #define ST_NOSUID 2 @@ -27,8 +28,14 @@ struct statvfs { unsigned long f_namemax; // Maximum filename length. }; -int statvfs(const char *path, struct statvfs *buf); -int fstatvfs(int fd, struct statvfs *buf); +int statvfs(const char *path, struct statvfs *buf) { + errno = ENOSYS; + return -1; +} +int fstatvfs(int fd, struct statvfs *buf) { + errno = ENOSYS; + return -1; +} #ifdef __cplusplus } diff --git a/libc_extension/include/sys/uio.h b/libc_extension/include/sys/uio.h new file mode 100644 index 0000000..4ddeced --- /dev/null +++ b/libc_extension/include/sys/uio.h @@ -0,0 +1,33 @@ +#ifndef _SYS_UIO_H +#define _SYS_UIO_H 1 + +#include + +/* Structure for scatter/gather I/O. */ +struct iovec +{ + void *iov_base; /* Pointer to data. */ + size_t iov_len; /* Length of data. */ +}; + +/* Read data from file descriptor FD, and put the result in the + buffers described by IOVEC, which is a vector of COUNT 'struct iovec's. + The buffers are filled in the order specified. + Operates just like 'read' (see ) except that data are + put in IOVEC instead of a contiguous buffer. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count); + +/* Write data pointed by the buffers described by IOVEC, which + is a vector of COUNT 'struct iovec's, to file descriptor FD. + The data is written in the order specified. + Operates just like 'write' (see ) except that the data + are taken from IOVEC instead of a contiguous buffer. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count); + +#endif // _SYS_UIO_H diff --git a/libc_extension/netdb.c b/libc_extension/netdb.c new file mode 100644 index 0000000..e697b0e --- /dev/null +++ b/libc_extension/netdb.c @@ -0,0 +1,66 @@ +#include + +void endhostent (void) {} + +void endnetent (void) {} + +void endprotoent (void) {} + +void endservent (void) {} + +struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len, int __type) { + return 0; +} + +struct hostent *gethostbyname (const char *__name) { + return 0; +} + +struct hostent *gethostent (void) { + return 0; +} + +struct netent *getnetbyaddr (uint32_t __net, int __type) { + return 0; +} + +struct netent *getnetbyname (const char *__name) { + return 0; +} + +struct netent *getnetent (void) { + return 0; +} + +struct protoent *getprotobyname (const char *__name) { + return 0; +} + +struct protoent *getprotobynumber (int __proto) { + return 0; +} + +struct protoent *getprotoent (void) { + return 0; +} + +struct servent *getservbyname (const char *__name, const char *__proto) { + return 0; +} + +struct servent *getservbyport (int __port, const char *__proto) { + return 0; +} + +struct servent *getservent (void) { + return 0; +} + +void sethostent (int __stay_open) {} + +void setnetent (int __stay_open) {} + +void setprotoent (int __stay_open) {} + +void setservent (int __stay_open) {} + diff --git a/libc_extension/socket.c b/libc_extension/socket.c new file mode 100644 index 0000000..7d24a11 --- /dev/null +++ b/libc_extension/socket.c @@ -0,0 +1,73 @@ +#include + +int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len) { + return -1; +} + +int bind (int __fd, const struct sockaddr *__addr, socklen_t __len) { + return -1; +} + +int connect (int __fd, const struct sockaddr *__addr, socklen_t __len) { + return -1; +} + +int getpeername (int __fd, struct sockaddr __addr, socklen_t *__len) { + return -1; +} + +int getsockname (int __fd, struct sockaddr __addr, socklen_t *__len) { + return -1; +} + +int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen) { + return -1; +} + +int listen (int __fd, int __n) { + return -1; +} + +ssize_t recv (int __fd, void *__buf, size_t __n, int __flags) { + return -1; +} + +ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr __addr, socklen_t *__addr_len) { + return -1; +} + +ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags) { + return -1; +} + +ssize_t send (int __fd, const void *__buf, size_t __n, int __flags) { + return -1; +} + +ssize_t sendmsg (int __fd, const struct msghdr *__message, int __flags) { + return -1; +} + +ssize_t sendto (int __fd, const void *__buf, size_t __n, int __flags, const struct sockaddr *__addr, socklen_t __addr_len) { + return -1; +} + +int setsockopt (int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen) { + return -1; +} + +int shutdown (int __fd, int __how) { + return -1; +} + +int socket (int __domain, int __type, int __protocol) { + return -1; +} + +int sockatmark (int __fd) { + return -1; +} + +int socketpair (int __domain, int __type, int __protocol, int __fds[2]) { + return -1; +} diff --git a/libc_extension/uio.c b/libc_extension/uio.c new file mode 100644 index 0000000..590faa1 --- /dev/null +++ b/libc_extension/uio.c @@ -0,0 +1,9 @@ +#include + +ssize_t readv (int __fd, const struct iovec *__iovec, int __count) { + return -1; +} + +ssize_t writev (int __fd, const struct iovec *__iovec, int __count) { + return -1; +} diff --git a/newlib_shim/Makefile.inc b/newlib_shim/Makefile.inc index b8fed40..acbd0d0 100644 --- a/newlib_shim/Makefile.inc +++ b/newlib_shim/Makefile.inc @@ -1,5 +1,4 @@ libc_a_SOURCES += \ - %D%/dirent.c \ %D%/pthread.c \ %D%/shim.c \ %D%/time.c \ diff --git a/newlib_shim/patch_script b/newlib_shim/patch_script index 31f1a81..9f92f72 100755 --- a/newlib_shim/patch_script +++ b/newlib_shim/patch_script @@ -19,19 +19,10 @@ then fi cp $THIS_DIR/Makefile.inc $1/newlib/libc/sys/dandelion/Makefile.inc cp $THIS_DIR/shim.c $1/newlib/libc/sys/dandelion/shim.c -cp $THIS_DIR/dirent.c $1/newlib/libc/sys/dandelion/dirent.c cp $THIS_DIR/pthread.c $1/newlib/libc/sys/dandelion/pthread.c cp $THIS_DIR/time.c $1/newlib/libc/sys/dandelion/time.c cp $THIS_DIR/unistd.c $1/newlib/libc/sys/dandelion/unistd.c cp $THIS_DIR/../include/dandelion/crt.h $1/newlib/libc/sys/dandelion/crt.h -if ! test -d $1/newlib/libc/sys/dandelion/sys -then - mkdir $1/newlib/libc/sys/dandelion/sys -fi -cp $THIS_DIR/dirent.h $1/newlib/libc/sys/dandelion/sys/dirent.h -cp $THIS_DIR/statvfs.h $1/newlib/libc/sys/dandelion/sys/statvfs.h -cp $THIS_DIR/sched.h $1/newlib/libc/sys/dandelion/sys/sched.h -cp $THIS_DIR/cpuset.h $1/newlib/libc/sys/dandelion/sys/cpuset.h cd $1 autoreconf cd newlib diff --git a/newlib_shim/shim.c b/newlib_shim/shim.c index d2374ab..50deac3 100644 --- a/newlib_shim/shim.c +++ b/newlib_shim/shim.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -187,16 +186,6 @@ int lstat(const char *file, struct stat *buf) { return stat(file, buf); } mode_t umask(mode_t mask) { return 0777; } -int statvfs(const char *file, struct statvfs *st) { - errno = ENOSYS; - return -1; -} - -int fstatvfs(int fd, struct statvfs *buf) { - errno = ENOSYS; - return -1; -} - int posix_memalign(void **memptr, size_t alignment, size_t size) { void *new_allocation = memalign(alignment, size); if (new_allocation == NULL) { diff --git a/sdk_install/CMakeTemplate.txt b/sdk_install/CMakeTemplate.txt index 3ddcc8a..614890b 100644 --- a/sdk_install/CMakeTemplate.txt +++ b/sdk_install/CMakeTemplate.txt @@ -50,6 +50,7 @@ target_link_libraries(dlibc INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/lib/libc.a" "${CMAKE_CURRENT_SOURCE_DIR}/lib/libg.a" "${CMAKE_CURRENT_SOURCE_DIR}/lib/libm.a" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/libc_extension.a" "${CMAKE_CURRENT_SOURCE_DIR}/lib/libdandelion_file_system.a" ) target_link_options(dlibc INTERFACE diff --git a/sdk_install/clang-template.cmake b/sdk_install/clang-template.cmake index c389790..0e2a504 100644 --- a/sdk_install/clang-template.cmake +++ b/sdk_install/clang-template.cmake @@ -23,6 +23,7 @@ -lm -lc -lg +-lc_extension -ldandelion_file_system -ldandelion_runtime -ldandelion_system From 25c484c96cd0b1f2c8a585621457f88743cb9709 Mon Sep 17 00:00:00 2001 From: Tom Kuchler Date: Tue, 27 Jan 2026 14:00:43 +0100 Subject: [PATCH 06/16] Removing wasm --- .github/workflows/release_experimental.yml | 2 +- .github/workflows/release_latest.yml | 2 +- CMakeLists.txt | 5 ----- Dockerfile | 4 ++-- README.md | 1 - include/dandelion/crt.h | 3 --- sdk_install/CMakeLists.txt | 11 +++-------- system/CMakeLists.txt | 2 -- system/platform/wasm/CMakeLists.txt | 2 -- system/platform/wasm/wasm.c | 8 -------- 10 files changed, 7 insertions(+), 33 deletions(-) delete mode 100644 system/platform/wasm/CMakeLists.txt delete mode 100644 system/platform/wasm/wasm.c diff --git a/.github/workflows/release_experimental.yml b/.github/workflows/release_experimental.yml index 5d220e9..1dee16b 100644 --- a/.github/workflows/release_experimental.yml +++ b/.github/workflows/release_experimental.yml @@ -13,7 +13,7 @@ jobs: matrix: cpu: ["x86_64", "aarch64"] - platform: ["debug", "mmu_linux", "kvm", "wasm"] + platform: ["debug", "mmu_linux", "kvm"] build: ["Debug", "Release"] include: - host: "ubuntu-24.04" diff --git a/.github/workflows/release_latest.yml b/.github/workflows/release_latest.yml index 000715f..74d2007 100644 --- a/.github/workflows/release_latest.yml +++ b/.github/workflows/release_latest.yml @@ -12,7 +12,7 @@ jobs: matrix: cpu: ["x86_64", "aarch64"] - platform: ["debug", "mmu_linux", "kvm", "wasm"] + platform: ["debug", "mmu_linux", "kvm"] build: ["Debug", "Release"] include: - host: "ubuntu-24.04" diff --git a/CMakeLists.txt b/CMakeLists.txt index e540d7b..789c8eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,11 +46,6 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug") add_compile_options(-gdwarf-4) endif() -# wasm does not support newlib -if(DANDELION_PLATFORM MATCHES "wasm") - set(NEWLIB OFF) -endif() - # set dependent options if(NEWLIB) set(DANDELION_FS ON) diff --git a/Dockerfile b/Dockerfile index 1db52e2..469f9cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,14 +17,14 @@ RUN apt-get install -y gcc g++ # clang uses gcc to interface with the linker # download initial clang RUN wget https://apt.llvm.org/llvm.sh -O ~/llvm.sh RUN chmod +x ~/llvm.sh -RUN ~/llvm.sh +RUN ~/llvm.sh 20 RUN ln -s /usr/bin/ld.lld-19 /usr/bin/ld.lld RUN rm -r /usr/include/* # download and set up dandelionSDK RUN wget https://github.com/eth-easl/dandelionSDK/releases/download/${VERSION}/dandelion_sdk_${BUILD}_${PLATFORM}_${TARGET_ARCH}.tar.gz -O ~/dandelionSDK.tar.gz RUN tar -xzf ~/dandelionSDK.tar.gz -C ~/ -RUN ~/dandelion_sdk/create-compiler.sh -d -c clang-19 +RUN ~/dandelion_sdk/create-compiler.sh -d -c clang-20 ENV CC="clang" ENV CXX="clang++" diff --git a/README.md b/README.md index 062fb39..b21ee10 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ The platforms are: - `MMU_FREEBSD`, for the mmu-based platforms running on freebsd - `MMU_LINUX`, for mmu-based platforms running on linux - `KVM`, for the kvm-based platform -- `WASM`, for the webassembly platform - `DEBUG` (default), for running applications locally on a linux system with mock inputs, dumping outputs to the terminal when terminating. diff --git a/include/dandelion/crt.h b/include/dandelion/crt.h index fcdc89f..ad25166 100644 --- a/include/dandelion/crt.h +++ b/include/dandelion/crt.h @@ -11,9 +11,6 @@ void _start(void) __attribute__((naked)); void _start(void) { #if defined(__x86_64__) __asm__("call __dandelion_entry\n"); -#elif defined(__wasm__) - __asm__("call __dandelion_entry\n"); - __asm__("return\n"); #elif defined(__aarch64__) __asm__("bl __dandelion_entry"); #else diff --git a/sdk_install/CMakeLists.txt b/sdk_install/CMakeLists.txt index b92cad1..14eb124 100644 --- a/sdk_install/CMakeLists.txt +++ b/sdk_install/CMakeLists.txt @@ -1,13 +1,8 @@ # actions to make the SDK build possible for outside sources -if(DANDELION_PLATFORM MATCHES "wasm") - set(DANDELION_TARGET "wasm32-unknown-dandelion") - set(TEMPLATE_TARGET "wasm32-unknown-unknown") -else() - set(DANDELION_TARGET "${ARCHITECTURE}-unknown-dandelion") - set(TEMPLATE_TARGET "${ARCHITECTURE}-unknown-elf") - set(BUILTIN_LIB "\"\${CMAKE_CURRENT_SOURCE_DIR}/lib/generic/libclang_rt.builtins-${ARCHITECTURE}.a\"") -endif() +set(DANDELION_TARGET "${ARCHITECTURE}-unknown-dandelion") +set(TEMPLATE_TARGET "${ARCHITECTURE}-unknown-elf") +set(BUILTIN_LIB "\"\${CMAKE_CURRENT_SOURCE_DIR}/lib/generic/libclang_rt.builtins-${ARCHITECTURE}.a\"") # Configure CMakeLists containing runtime, dlibc and dlibcxx configure_file(CMakeTemplate.txt ${CMAKE_INSTALL_PREFIX}/CMakeLists.txt diff --git a/system/CMakeLists.txt b/system/CMakeLists.txt index 5dca486..0456d37 100644 --- a/system/CMakeLists.txt +++ b/system/CMakeLists.txt @@ -31,8 +31,6 @@ elseif(DANDELION_PLATFORM MATCHES "mmu_linux") add_subdirectory(syscall/linux) elseif(DANDELION_PLATFORM MATCHES "kvm") add_subdirectory(platform/kvm) -elseif(DANDELION_PLATFORM MATCHES "wasm") - add_subdirectory(platform/wasm) else() message(FATAL_ERROR "Invalid platform: ${DANDELION_PLATFORM}") endif() diff --git a/system/platform/wasm/CMakeLists.txt b/system/platform/wasm/CMakeLists.txt deleted file mode 100644 index 1cad536..0000000 --- a/system/platform/wasm/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -set(SOURCES wasm.c) -target_sources(${SYSTEM_LIB} PRIVATE ${SOURCES}) diff --git a/system/platform/wasm/wasm.c b/system/platform/wasm/wasm.c deleted file mode 100644 index fe34f8d..0000000 --- a/system/platform/wasm/wasm.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../../system.h" -#include - -void __dandelion_platform_init(void) {} - -void __dandelion_platform_exit(void) {} - -void __dandelion_platform_set_thread_pointer(void *ptr) {} \ No newline at end of file From 372892c2b757365a328143e116b022ab66baa633 Mon Sep 17 00:00:00 2001 From: tom-kuchler <87128754+tom-kuchler@users.noreply.github.com> Date: Wed, 11 Mar 2026 09:34:02 +0100 Subject: [PATCH 07/16] Update Dockerfile Fix inconsistency in clang version. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 469f9cb..2602f19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get install -y gcc g++ # clang uses gcc to interface with the linker RUN wget https://apt.llvm.org/llvm.sh -O ~/llvm.sh RUN chmod +x ~/llvm.sh RUN ~/llvm.sh 20 -RUN ln -s /usr/bin/ld.lld-19 /usr/bin/ld.lld +RUN ln -s /usr/bin/ld.lld-20 /usr/bin/ld.lld RUN rm -r /usr/include/* # download and set up dandelionSDK @@ -31,4 +31,4 @@ ENV CXX="clang++" # additional useful tooling RUN apt-get install -y cmake -RUN apt-get install -y git \ No newline at end of file +RUN apt-get install -y git From 6c83d53676e3661e6a260fe5fbdfcd4eb3da316e Mon Sep 17 00:00:00 2001 From: tom-kuchler <87128754+tom-kuchler@users.noreply.github.com> Date: Mon, 23 Mar 2026 13:12:32 +0100 Subject: [PATCH 08/16] Dev/pic (#27) * Ensure all libraries are PIC, adding dev/urandom * Adding actual time measurements --------- Co-authored-by: Tobias Stocker --- CMakeLists.txt | 20 ++-- file_system/devices.h | 39 +++++++ file_system/file_system.c | 128 +++++++++++++---------- file_system/file_system.h | 12 ++- file_system/fs_implementation.c | 24 +++-- newlib_shim/compiler_wrapper_template.sh | 7 +- newlib_shim/time.c | 36 +++++-- sdk_install/clang-template.cmake | 2 + test_programs/libcpp/test.cpp | 11 ++ 9 files changed, 195 insertions(+), 84 deletions(-) create mode 100644 file_system/devices.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 789c8eb..e81a41a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ include(ExternalProject) # binary options option(FREESTANDING "toggles the include of memcpy, memset, memmove and memcmp" ON) -option(DANDELION_FS "toggles include of lowes level file system provided by dandelion" OFF) option(NEWLIB "toggles builing of newlib on top of dandelion interface" OFF) # string options @@ -46,11 +45,6 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug") add_compile_options(-gdwarf-4) endif() -# set dependent options -if(NEWLIB) - set(DANDELION_FS ON) -endif() - # if freestanding is on add the FREESTANDING definition to all compilation if(FREESTANDING) add_compile_definitions(FREESTANDING) @@ -60,11 +54,6 @@ add_subdirectory(system) add_subdirectory(runtime) add_subdirectory(sdk_install) -if(DANDELION_FS) - set(FILE_SYSTEM_LIB "dandelion_file_system") - add_subdirectory(file_system) -endif() - # set default level of parallelism if(NOT CMAKE_BUILD_PARALLEL_LEVEL) cmake_host_system_information(RESULT CMAKE_BUILD_PARALLEL_LEVEL QUERY NUMBER_OF_LOGICAL_CORES) @@ -73,9 +62,13 @@ else() endif() if(NEWLIB) + set(FILE_SYSTEM_LIB "dandelion_file_system") + add_subdirectory(file_system) + set(NEWLIB_C_FLAGS "--target=${ARCHITECTURE}-none-elf") string(APPEND NEWLIB_C_FLAGS " -nostdinc") string(APPEND NEWLIB_C_FLAGS " -nostdlib") + string(APPEND NEWLIB_C_FLAGS " -fPIC") string(APPEND NEWLIB_C_FLAGS " -idirafter${COMPILER_RUNTIME_INCLUDE}") if(CMAKE_BUILD_TYPE MATCHES "Debug") string(APPEND NEWLIB_C_FLAGS " -gdwarf-4") @@ -83,7 +76,7 @@ if(NEWLIB) set(NEWLIB_COMPILER ${CMAKE_BINARY_DIR}/compiler_wrapped.sh) configure_file(newlib_shim/compiler_wrapper_template.sh ${NEWLIB_COMPILER} - FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE) + FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE @ONLY) set(NEWLIB_CONFIG_ARGS "--host=${ARCHITECTURE}-dandelion") list(APPEND NEWLIB_CONFIG_ARGS "--disable-newlib-reent-thread-local") @@ -206,6 +199,7 @@ if(NEWLIB) -DCMAKE_CXX_FLAGS:STRING=${LLVM_CXX_FLAGS} -DLLVM_DEFAULT_TARGET_TRIPLE=${ARCHITECTURE}-none-elf -DLLVM_INCLUDE_TESTS=OFF + -DLLVM_ENABLE_PIC=ON -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCOMPILER_RT_BUILD_BUILTINS=ON -DCOMPILER_RT_BAREMETAL_BUILD=ON @@ -225,7 +219,7 @@ if(NEWLIB) -DLIBCXX_INCLUDE_BENCHMARKS=OFF -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_ENABLE_FILESYSTEM=ON - -DLIBCXX_ENABLE_RANDOM_DEVICE=OFF + -DLIBCXX_ENABLE_RANDOM_DEVICE=ON -DLIBCXX_HAS_PTHREAD_API=ON ) add_dependencies(llvmproject newlib ${LIBC_EXTENSION}) diff --git a/file_system/devices.h b/file_system/devices.h new file mode 100644 index 0000000..7d8b037 --- /dev/null +++ b/file_system/devices.h @@ -0,0 +1,39 @@ +#ifndef __DANDELION_DEVICES__ +#define __DANDELION_DEVICES__ + +#include + +// Define /dev/urandom +// Using the newlib random functions +extern void srand(unsigned int seed); +extern void srandom(unsigned int seed); +extern long random(void); +void urandom_init(int64_t seed) { + // TODO also seed the other random functions from newlib + srand(seed); + srandom(seed); +}; +size_t urandom_read(char* ptr, size_t len, int64_t offset, char options) { + // ignoring offset and flags; + size_t long_size = sizeof(long); + size_t long_interations = len / long_size; + + long* long_ptr = (long*) ptr; + for(size_t long_index = 0; long_index < long_interations; long_index++){ + long_ptr[long_index] = random(); + } + + size_t long_offset = long_interations*long_size; + long random_num = random(); + for(size_t char_index = 0; char_index < len - long_offset; char_index++){ + ptr[long_offset + char_index] = (char)(random_num >> (8*char_index)); + } + return len; +}; +size_t urandom_write(char* ptr, size_t len, int64_t offset, char options) { + return 0; +}; + +// TODO: implement /dev/random with the arc4random, for better but slower randomness + +#endif //__DANDELION_DEVICES__ \ No newline at end of file diff --git a/file_system/file_system.c b/file_system/file_system.c index 484ba8c..ec24d08 100644 --- a/file_system/file_system.c +++ b/file_system/file_system.c @@ -1,4 +1,5 @@ #include "file_system.h" +#include "devices.h" #include "include/fs_interface.h" #include @@ -7,9 +8,57 @@ #include "dandelion/system/system.h" #include "paths.h" -// static variables -D_File *fs_root; -OpenFile *open_files; +OpenFile open_files[FS_MAX_FILES] = {NULL}; + +// folders that are always present +// initialize with hard links = 1 to make sure we never attempt deallocation +D_File fs_root = { + .name = "/\0", + .next = NULL, + .parent = NULL, + .type = DIRECTORY, + .child = NULL, + .hard_links = 1, + .open_descripotors = 0, + .mode = 0, +}; +static D_File stdio_folder = { + .name = "stdio\0", + .next = NULL, + .parent = NULL, + .type = DIRECTORY, + .child = NULL, + .hard_links = 1, + .open_descripotors = 0, + .mode = 0, +}; +static D_File device_folder = { + .name = "dev\0", + .next = NULL, + .parent = NULL, + .type = DIRECTORY, + .child = NULL, + .hard_links = 1, + .open_descripotors = 0, + .mode = 0, +}; + +// static devices +static Device urandom_device = { + .state = NULL, + .read = urandom_read, + .write = urandom_write, +}; +static D_File urandom_file = { + .name = "urandom\0", + .next = NULL, + .parent = NULL, + .type = DEVICE, + .device = &urandom_device, + .hard_links = 1, + .open_descripotors = 0, + .mode = S_IRUSR, +}; D_File *create_file(Path *name, char *content, size_t length, uint32_t mode) { D_File *new_file = dandelion_alloc(sizeof(D_File), _Alignof(D_File)); @@ -90,6 +139,7 @@ int link_file_to_folder(D_File *folder, D_File *file) { return 0; } +// Assumes the file has already been checked to be a directory D_File *find_file_in_dir(D_File *directory, Path file) { // handle special cases for . and .. if (file.length == 1 && file.path[0] == '.') { @@ -113,7 +163,7 @@ D_File *find_file_in_dir(D_File *directory, Path file) { } D_File *find_file_path(Path file_path) { - D_File *current = fs_root; + D_File *current = &fs_root; for (Path subpath = get_component_advance(&file_path); subpath.length != 0; subpath = get_component_advance(&file_path)) { if (current->type != DIRECTORY) { @@ -202,6 +252,10 @@ int free_data(D_File *file) { case FILE: free_file_chunks(file->content); break; + case DEVICE: + // device should never have 0 hard links + // TODO insert panic here + break; default: // unkown file type return -1; @@ -290,9 +344,6 @@ int open_existing_file(unsigned int index, D_File *file, int flags, if (file->type == FILE) { new_chunk = file->content; } - // an open file stays open even if it is removed from the file system, so - // we add a hard link while it is open - file->hard_links += 1; // mark that the file is open file->open_descripotors += 1; @@ -403,44 +454,19 @@ int fs_initialize(int *argc, char ***argv, char ***environ) { // error value int error; - // create root folder - fs_root = dandelion_alloc(sizeof(D_File), _Alignof(D_File)); - if (fs_root == NULL) { - dandelion_exit(ENOMEM); - return -1; - } - fs_root->name[0] = '/'; - fs_root->name[1] = '\0'; - fs_root->type = DIRECTORY; - fs_root->next = NULL; - fs_root->parent = NULL; - fs_root->child = NULL; - fs_root->hard_links = 1; - - // create stdio folder and stdout/stderr file - D_File *stdio_folder = dandelion_alloc(sizeof(D_File), _Alignof(D_File)); - if (stdio_folder == NULL) { - dandelion_exit(ENOMEM); - return -1; - } - memcpy(stdio_folder->name, "stdio\0", 7); - stdio_folder->type = DIRECTORY; - stdio_folder->child = NULL; - stdio_folder->hard_links = 0; - if ((error = link_file_to_folder(fs_root, stdio_folder)) != 0) { + if ((error = link_file_to_folder(&fs_root, &device_folder)) != 0) { return error; } - - // allocate the file table - open_files = - dandelion_alloc(sizeof(OpenFile) * FS_MAX_FILES, _Alignof(OpenFile)); - if (open_files == NULL) { - dandelion_exit(ENOMEM); - return -1; + + // initialize and add urandom device + urandom_init(0x39917A73ACA200E4ull); // TODO: get this from input struct + if ((error = link_file_to_folder(&device_folder, &urandom_file)) != 0) { + return error; } - // make sure file pointers are zeroed, as we used them to detect used files - for (size_t index = 0; index < FS_MAX_FILES; index++) { - open_files[index].file = NULL; + + // create stdio folder and stdout/stderr file + if ((error = link_file_to_folder(&fs_root, &stdio_folder)) != 0) { + return error; } // create and open stderr @@ -451,7 +477,7 @@ int fs_initialize(int *argc, char ***argv, char ***environ) { error = open_existing_file(STDERR_FILENO, stderr_file, O_WRONLY, 0, 0); if (error != 0) return error; - error = link_file_to_folder(stdio_folder, stderr_file); + error = link_file_to_folder(&stdio_folder, stderr_file); if (error != 0) return error; @@ -463,7 +489,7 @@ int fs_initialize(int *argc, char ***argv, char ***environ) { error = open_existing_file(STDOUT_FILENO, stdout_file, O_WRONLY, 0, 0); if (error != 0) return error; - error = link_file_to_folder(stdio_folder, stdout_file); + error = link_file_to_folder(&stdio_folder, stdout_file); if (error != 0) return error; @@ -481,7 +507,7 @@ int fs_initialize(int *argc, char ***argv, char ***environ) { if (set_path.length == 0) continue; // create directories for set - D_File *set_directory = create_directories(fs_root, set_path, 1); + D_File *set_directory = create_directories(&fs_root, set_path, 1); if (set_directory == NULL) { // TODO write to stderr on what happened return -1; @@ -543,7 +569,7 @@ int fs_initialize(int *argc, char ***argv, char ***environ) { if (set_path.length == 0) continue; // create directories for set - D_File *set_directory = create_directories(fs_root, set_path, 1); + D_File *set_directory = create_directories(&fs_root, set_path, 1); if (set_directory == NULL) { // TODO write to stderr on what happened return -1; @@ -564,7 +590,7 @@ int fs_initialize(int *argc, char ***argv, char ***environ) { if (error != 0) { return error; } - if (link_file_to_folder(stdio_folder, stdin_file) != 0) { + if (link_file_to_folder(&stdio_folder, stdin_file) != 0) { return -1; } } @@ -659,18 +685,14 @@ int add_output_from_file(D_File *file, Path previous_path, size_t set_index) { return 0; } -int fs_terminate() { - // if fs has not been initialized properly, nothing we can do - if (fs_root == NULL) { - return 0; - } +int fs_terminate() { // go through output set names and find all files in folders that are // named after them size_t output_sets = dandelion_output_set_count(); for (size_t set_index = 0; set_index < output_sets; set_index++) { Path set_ident = {.path = dandelion_output_set_ident(set_index), .length = dandelion_output_set_ident_len(set_index)}; - D_File *set_directory = find_file_in_dir(fs_root, set_ident); + D_File *set_directory = find_file_in_dir(&fs_root, set_ident); if (set_directory == NULL) { continue; } diff --git a/file_system/file_system.h b/file_system/file_system.h index 0df9554..c2e1ed4 100644 --- a/file_system/file_system.h +++ b/file_system/file_system.h @@ -29,6 +29,7 @@ typedef enum FileType { FILE, DIRECTORY, + DEVICE, } FileType; typedef struct FileChunk { @@ -38,6 +39,14 @@ typedef struct FileChunk { struct FileChunk *next; } FileChunk; +typedef struct Device { + // for devices that need state can store pointer to arbitrary function + void* state; + // functions a device needs to implement + size_t(*read)(char*, size_t, int64_t, char); + size_t(*write)(char*, size_t, int64_t, char); +} Device; + // Use D_File instead of File, to avoid potential naming overlap typedef struct D_File { char name[FS_NAME_LENGTH]; @@ -45,8 +54,9 @@ typedef struct D_File { struct D_File *parent; FileType type; union { - struct D_File *child; FileChunk *content; + struct D_File *child; + Device *device; }; unsigned short hard_links; unsigned short open_descripotors; diff --git a/file_system/fs_implementation.c b/file_system/fs_implementation.c index 8c878c0..942e707 100644 --- a/file_system/fs_implementation.c +++ b/file_system/fs_implementation.c @@ -7,8 +7,8 @@ #include -extern D_File *fs_root; -extern OpenFile *open_files; +extern D_File fs_root; +extern OpenFile open_files[]; // Allocate new filesystem chunk, return NULL if ENOMEM; // round up allocation to next multiple of FS_CHUNK_SIZE @@ -72,7 +72,7 @@ int dandelion_link(const char *old, const char *new_name) { Path new_path = path_from_string(new_name); Path new_file_name = get_file(new_path); Path new_file_dir = get_directories(new_path); - D_File *new_dir = create_directories(fs_root, new_file_dir, 0); + D_File *new_dir = create_directories(&fs_root, new_file_dir, 0); if (new_dir == NULL) { return -ENOTDIR; } @@ -128,7 +128,7 @@ int dandelion_open(const char *name, int flags, uint32_t mode) { if (file_name.length >= FS_NAME_LENGTH) { return -EINVAL; } - D_File *parent = create_directories(fs_root, dir_path, 0); + D_File *parent = create_directories(&fs_root, dir_path, 0); if (parent == NULL) { return -ENOTDIR; } @@ -157,7 +157,6 @@ int dandelion_open(const char *name, int flags, uint32_t mode) { if (open_error < 0) return open_error; - current->open_descripotors += 1; return file_descriptor; } @@ -344,7 +343,11 @@ size_t dandelion_read(int file, char *ptr, size_t len, int64_t offset, if (open_file->file == NULL || open_file->open_flags & O_WRONLY) { return -EBADF; } - if (open_file->file->type != FILE) { + + if(open_file->file->type == DEVICE){ + size_t result = open_file->file->device->read(ptr, len, offset, options); + return result; + } else if (open_file->file->type != FILE) { return -EINVAL; } // if len is 0, it is supposed to only check for these errors and return @@ -424,7 +427,10 @@ size_t dandelion_write(int file, char *ptr, size_t len, int64_t offset, if (open_file->file == NULL || open_file->open_flags & O_RDONLY) { return -EBADF; } - if (open_file->file->type != FILE) { + + if(open_file->file->type == DEVICE){ + return open_file->file->device->write(ptr, len, offset, options); + } else if (open_file->file->type != FILE) { return -EINVAL; } @@ -554,7 +560,7 @@ static inline int __dandelion_truncate(D_File *file, int64_t length) { if (length < 0) return -EINVAL; if (file->type != FILE) - return -EISDIR; + return -EBADF; int64_t remaining_size = length; FileChunk *current = file->content; // go to length, and cut off left over after that if there is any @@ -623,7 +629,7 @@ int dandelion_opendir(const char *name, DIR *dir) { } int dandelion_closedir(DIR *dir) { - dir->dir -= 1; + dir->dir->open_descripotors -= 1; int err = free_data(dir->dir); return err; } diff --git a/newlib_shim/compiler_wrapper_template.sh b/newlib_shim/compiler_wrapper_template.sh index 0e7b144..db24a4f 100644 --- a/newlib_shim/compiler_wrapper_template.sh +++ b/newlib_shim/compiler_wrapper_template.sh @@ -1,2 +1,7 @@ #! /bin/bash -@CMAKE_C_COMPILER@ @NEWLIB_C_FLAGS@ "$@" + +# need to remove stdinc++ from input, as it causes a redundancy warning with stdinc, which causes errors for programs with -Werror +ARGS="$@" +ARGS="${ARGS//"-nostdinc++"/}" + +@CMAKE_C_COMPILER@ @NEWLIB_C_FLAGS@ $ARGS diff --git a/newlib_shim/time.c b/newlib_shim/time.c index a278e54..a75ed52 100644 --- a/newlib_shim/time.c +++ b/newlib_shim/time.c @@ -4,24 +4,46 @@ llvmproject */ #define _POSIX_MONOTONIC_CLOCK +#define __GNU_VISIBLE 0 #include #include #undef errno extern int errno; +#if defined(__aarch64__) + static uint64_t __rdtsc() { + uint64_t t; + __asm volatile ("mrs %0, cntvct_el0"::"r"(thread_data)); + } +#elif defined(__x86_64__) + static uint64_t __rdtsc() { + uint64_t t; + __asm volatile ("rdtsc": "=A"(t)); + return t; + } +#else +#error "Unsupported architecture" +#endif + + int clock_settime(clockid_t clock_id, const struct timespec *tp) { errno = EINVAL; return -1; } int clock_gettime(clockid_t clock_id, struct timespec *tp) { - if (clock_id == CLOCK_MONOTONIC) { - static struct timespec monotonic_time = {.tv_nsec = 0, .tv_sec = 0}; - monotonic_time.tv_nsec += 1; - *tp = monotonic_time; - return 0; + // TODO add static timestamp at the start to offset here and possibly fix to get actual realtime instead of offset one + // TODO check if we need to differentiate any of these and if they need setup from the dandelion side + static char is_initialized = 0; + static uint64_t base_time; + if (is_initialized == 0) { + base_time = __rdtsc(); + is_initialized = 1; } - errno = EINVAL; - return -1; + uint64_t time_diff = __rdtsc() - base_time; + uint64_t divisor = 1000000000; + tp->tv_nsec = time_diff % divisor; + tp->tv_sec = time_diff / divisor; + return 0; } int clock_getres(clockid_t clock_id, struct timespec *res) { errno = EINVAL; diff --git a/sdk_install/clang-template.cmake b/sdk_install/clang-template.cmake index 0e2a504..99fc15d 100644 --- a/sdk_install/clang-template.cmake +++ b/sdk_install/clang-template.cmake @@ -3,6 +3,8 @@ -D_GNU_SOURCE=1 -D__GNU__ -D__rtems__ +# prevent thread local storage in compilation, TODO: remove if we can provide TLS +-D__thread="" # compiler flags -fPIE diff --git a/test_programs/libcpp/test.cpp b/test_programs/libcpp/test.cpp index dac8884..642b5bd 100644 --- a/test_programs/libcpp/test.cpp +++ b/test_programs/libcpp/test.cpp @@ -10,6 +10,17 @@ int main(){ fs << "test print " << endl; fs.close(); + std::fstream random; + random.open("/dev/urandom", std::fstream::in); + if(!random) { + cerr << "Failed to open /dev/urandom" << endl; + return -1; + } + int64_t random_number; + random.read((char*)&random_number,8); + cout << "Random number: " << random_number << endl; + + std::fstream in1; string in_file_1 = "/in_a/input_1.txt"; in1.open(in_file_1, std::fstream::in); From c3b4162cac7e5fa6415099b6c215e4dc7fb9fe79 Mon Sep 17 00:00:00 2001 From: Tobias Stocker <61014201+tostocker@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:38:12 +0100 Subject: [PATCH 09/16] DuckDB header extension (#28) * Added automake installer script * Added dlfcn header * Added arpa/inet.h, netinet/in.h, semaphore.h header, fixed template bug * Added more headers * Added mman header * Buildtool install script fix * Compiler template extension --------- Co-authored-by: Tobias Stocker Co-authored-by: Tobias Stocker --- libc_extension/CMakeLists.txt | 15 ++++ libc_extension/dlfcn.c | 6 ++ libc_extension/if.c | 6 ++ libc_extension/ifaddrs.c | 4 + libc_extension/include/arpa/inet.h | 13 +++ libc_extension/include/dlfcn.h | 16 ++++ libc_extension/include/ifaddrs.h | 27 ++++++ libc_extension/include/net/if.h | 18 ++++ libc_extension/include/netinet/in.h | 124 ++++++++++++++++++++++++++++ libc_extension/include/semaphore.h | 32 +++++++ libc_extension/include/sys/mman.h | 37 +++++++++ libc_extension/inet.c | 14 ++++ libc_extension/mman.c | 14 ++++ libc_extension/pthread.c | 3 + libc_extension/sched.c | 5 ++ libc_extension/semaphore.c | 12 +++ scripts/install_buildtools.sh | 34 ++++++++ sdk_install/clang-template.cmake | 7 +- 18 files changed, 386 insertions(+), 1 deletion(-) create mode 100644 libc_extension/dlfcn.c create mode 100644 libc_extension/if.c create mode 100644 libc_extension/ifaddrs.c create mode 100644 libc_extension/include/arpa/inet.h create mode 100644 libc_extension/include/dlfcn.h create mode 100644 libc_extension/include/ifaddrs.h create mode 100644 libc_extension/include/net/if.h create mode 100644 libc_extension/include/netinet/in.h create mode 100644 libc_extension/include/semaphore.h create mode 100644 libc_extension/include/sys/mman.h create mode 100644 libc_extension/inet.c create mode 100644 libc_extension/mman.c create mode 100644 libc_extension/pthread.c create mode 100644 libc_extension/sched.c create mode 100644 libc_extension/semaphore.c create mode 100755 scripts/install_buildtools.sh diff --git a/libc_extension/CMakeLists.txt b/libc_extension/CMakeLists.txt index 89b8e8f..adcd588 100644 --- a/libc_extension/CMakeLists.txt +++ b/libc_extension/CMakeLists.txt @@ -3,15 +3,30 @@ add_library(${LIBC_EXTENSION} STATIC) target_sources(${LIBC_EXTENSION} PRIVATE dirent.c + dlfcn.c + if.c + ifaddrs.c + inet.c + mman.c netdb.c + pthread.c + sched.c + semaphore.c socket.c uio.c PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/ FILES + include/dlfcn.h + include/ifaddrs.h include/netdb.h + include/semaphore.h + include/arpa/inet.h + include/net/if.h + include/netinet/in.h include/sys/cpuset.h include/sys/dirent.h + include/sys/mman.h include/sys/sched.h include/sys/socket.h include/sys/statvfs.h diff --git a/libc_extension/dlfcn.c b/libc_extension/dlfcn.c new file mode 100644 index 0000000..ca2611b --- /dev/null +++ b/libc_extension/dlfcn.c @@ -0,0 +1,6 @@ +#include + +int dlclose (void *__handle) { return -1; } +char *dlerror (void) { return 0; } +void *dlopen (const char *__file, int __mode) { return 0; } +void *dlsym (void *__restrict __handle, const char *__restrict __name) { return 0; } diff --git a/libc_extension/if.c b/libc_extension/if.c new file mode 100644 index 0000000..7df680a --- /dev/null +++ b/libc_extension/if.c @@ -0,0 +1,6 @@ +#include + +unsigned int if_nametoindex (const char *__ifname) { return 0; } +char *if_indextoname (unsigned int __ifindex, char __ifname[IF_NAMESIZE]) { return 0; } +struct if_nameindex *if_nameindex (void) { return 0; } +void if_freenameindex (struct if_nameindex *__ptr) { return; } diff --git a/libc_extension/ifaddrs.c b/libc_extension/ifaddrs.c new file mode 100644 index 0000000..efb422f --- /dev/null +++ b/libc_extension/ifaddrs.c @@ -0,0 +1,4 @@ +#include + +int getifaddrs (struct ifaddrs **__ifap) { return -1; } +void freeifaddrs (struct ifaddrs *__ifa) { return; } diff --git a/libc_extension/include/arpa/inet.h b/libc_extension/include/arpa/inet.h new file mode 100644 index 0000000..47776b2 --- /dev/null +++ b/libc_extension/include/arpa/inet.h @@ -0,0 +1,13 @@ +/* THIS IS A DUMMY HEADER */ + +#ifndef _ARPA_INET_H +#define _ARPA_INET_H 1 + +#include /* To define `struct in_addr'. */ + +extern in_addr_t inet_addr (const char *__cp); +extern char *inet_ntoa (struct in_addr __in); +extern const char *inet_ntop (int __af, const void * __cp, char * __buf, socklen_t __len); +extern int inet_pton (int __af, const char * __cp, void * __buf); + +#endif // _ARPA_INET_H diff --git a/libc_extension/include/dlfcn.h b/libc_extension/include/dlfcn.h new file mode 100644 index 0000000..35eeab3 --- /dev/null +++ b/libc_extension/include/dlfcn.h @@ -0,0 +1,16 @@ +/* THIS IS A DUMMY HEADER */ + +#ifndef _DLFCN_H +#define _DLFCN_H 1 + +#define RTLD_LAZY 0x00001 +#define RTLD_NOW 0x00002 +#define RTLD_GLOBAL 0x00100 +#define RTLD_LOCAL 0 + +extern int dlclose (void *__handle); +extern char *dlerror (void); +extern void *dlopen (const char *__file, int __mode); +extern void *dlsym (void *__restrict __handle, const char *__restrict __name); + +#endif /* dlfcn.h */ diff --git a/libc_extension/include/ifaddrs.h b/libc_extension/include/ifaddrs.h new file mode 100644 index 0000000..c91b73c --- /dev/null +++ b/libc_extension/include/ifaddrs.h @@ -0,0 +1,27 @@ +/* THIS IS A DUMMY HEADER */ + +#ifndef _IFADDRS_H +#define _IFADDRS_H 1 + +#include + +struct ifaddrs { + struct ifaddrs *ifa_next; + + char *ifa_name; + unsigned int ifa_flags; + + struct sockaddr *ifa_addr; + struct sockaddr *ifa_netmask; + union { + struct sockaddr *ifu_broadaddr; + struct sockaddr *ifu_dstaddr; + } ifa_ifu; + + void *ifa_data; +}; + +extern int getifaddrs (struct ifaddrs **__ifap); +extern void freeifaddrs (struct ifaddrs *__ifa); + +#endif /* ifaddrs.h */ diff --git a/libc_extension/include/net/if.h b/libc_extension/include/net/if.h new file mode 100644 index 0000000..27bdbcd --- /dev/null +++ b/libc_extension/include/net/if.h @@ -0,0 +1,18 @@ +/* THIS IS A DUMMY HEADER */ + +#ifndef _NET_IF_H +#define _NET_IF_H 1 + +#define IF_NAMESIZE 16 + +struct if_nameindex { + unsigned int if_index; + char *if_name; +}; + +extern unsigned int if_nametoindex (const char *__ifname); +extern char *if_indextoname (unsigned int __ifindex, char __ifname[IF_NAMESIZE]); +extern struct if_nameindex *if_nameindex (void); +extern void if_freenameindex (struct if_nameindex *__ptr); + +#endif /* net/if.h */ diff --git a/libc_extension/include/netinet/in.h b/libc_extension/include/netinet/in.h new file mode 100644 index 0000000..c4e1463 --- /dev/null +++ b/libc_extension/include/netinet/in.h @@ -0,0 +1,124 @@ +/* THIS IS A DUMMY HEADER */ + +#ifndef _NETINET_IN_H +#define _NETINET_IN_H 1 + +#include +#include + +typedef uint16_t in_port_t; +typedef uint32_t in_addr_t; + +struct in_addr { + in_addr_t s_addr; +}; + +struct sockaddr_in { + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; +}; + +struct in6_addr { + uint8_t s6_addr[16]; +}; + +struct sockaddr_in6 { + sa_family_t sin6_family; + in_port_t sin6_port; + uint32_t sin6_flowinfo; + struct in6_addr sin6_addr; + uint32_t sin6_scope_id; +}; + +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; + +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; + unsigned int ipv6mr_interface; +}; + +enum { + IPPROTO_IP = 0, + IPPROTO_ICMP = 1, + IPPROTO_TCP = 6, + IPPROTO_UDP = 17, + IPPROTO_IPV6 = 41, + IPPROTO_RAW = 255, +}; +#define IPPROTO_IP IPPROTO_IP +#define IPPROTO_ICMP IPPROTO_ICMP +#define IPPROTO_TCP IPPROTO_TCP +#define IPPROTO_UDP IPPROTO_UDP +#define IPPROTO_IPV6 IPPROTO_IPV6 +#define IPPROTO_RAW IPPROTO_RAW + +#define INADDR_ANY ((in_addr_t) 0x00000000) +#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) + +#define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 + +# define IN6_IS_ADDR_UNSPECIFIED(a) \ + (__extension__ \ + ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == 0 \ + && __a->__in6_u.__u6_addr32[3] == 0; })) + +# define IN6_IS_ADDR_LOOPBACK(a) \ + (__extension__ \ + ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == 0 \ + && __a->__in6_u.__u6_addr32[3] == htonl (1); })) + +# define IN6_IS_ADDR_LINKLOCAL(a) \ + (__extension__ \ + ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ + (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); })) + +# define IN6_IS_ADDR_SITELOCAL(a) \ + (__extension__ \ + ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ + (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); })) + +# define IN6_IS_ADDR_V4MAPPED(a) \ + (__extension__ \ + ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); })) + +# define IN6_IS_ADDR_V4COMPAT(a) \ + (__extension__ \ + ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == 0 \ + && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; })) + +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((const uint8_t *) (a))[1] & 0xf) == 0x1)) + +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((const uint8_t *) (a))[1] & 0xf) == 0x2)) + +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((const uint8_t *) (a))[1] & 0xf) == 0x5)) + +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((const uint8_t *) (a))[1] & 0xf) == 0x8)) + +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((const uint8_t *) (a))[1] & 0xf) == 0xe)) + +#endif // _NETINET_IN_H \ No newline at end of file diff --git a/libc_extension/include/semaphore.h b/libc_extension/include/semaphore.h new file mode 100644 index 0000000..60dc33d --- /dev/null +++ b/libc_extension/include/semaphore.h @@ -0,0 +1,32 @@ +/* THIS IS A DUMMY HEADER */ + +#ifndef _SEMAPHORE_H +#define _SEMAPHORE_H 1 + +#include + +#if __WORDSIZE == 64 +# define __SIZEOF_SEM_T 32 +#else +# define __SIZEOF_SEM_T 16 +#endif + +typedef union { + char __size[__SIZEOF_SEM_T]; + long int __align; +} sem_t; + +#define SEM_FAILED ((sem_t *) 0) + +extern int sem_close (sem_t *__sem); +extern int sem_destroy (sem_t *__sem); +extern int sem_getvalue (sem_t *__sem, int *__sval); +extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value); +extern sem_t *sem_open (const char *__name, int __oflag, ...); +extern int sem_post (sem_t *__sem); +extern int sem_timedwait (sem_t *__sem, const struct timespec *__abstime); +extern int sem_trywait (sem_t *__sem); +extern int sem_unlink (const char *__name); +extern int sem_wait (sem_t *__sem); + +#endif /* semaphore.h */ diff --git a/libc_extension/include/sys/mman.h b/libc_extension/include/sys/mman.h new file mode 100644 index 0000000..93e2449 --- /dev/null +++ b/libc_extension/include/sys/mman.h @@ -0,0 +1,37 @@ +/* THIS IS A DUMMY HEADER */ + +#ifndef _SYS_MMAN_H +#define _SYS_MMAN_H 1 + +#include + +#define PROT_READ 0x1 +#define PROT_WRITE 0x2 +#define PROT_EXEC 0x4 +#define PROT_NONE 0x0 + +#define MAP_SHARED 0x01 +#define MAP_PRIVATE 0x02 +#define MAP_FIXED 0x10 + +#define MS_ASYNC 1 +#define MS_SYNC 4 +#define MS_INVALIDATE 2 + +#define MCL_CURRENT 1 +#define MCL_FUTURE 2 + +#define MAP_FAILED ((void *) -1) + +extern int mlock (const void *__addr, size_t __len); +extern int mlockall (int __flags); +extern void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset); +extern int mprotect (void *__addr, size_t __len, int __prot); +extern int msync (void *__addr, size_t __len, int __flags); +extern int munlock (const void *__addr, size_t __len); +extern int munlockall (void); +extern int munmap (void *__addr, size_t __len); +extern int shm_open (const char *__name, int __oflag, mode_t __mode); +extern int shm_unlink (const char *__name); + +#endif /* sys/mman.h */ diff --git a/libc_extension/inet.c b/libc_extension/inet.c new file mode 100644 index 0000000..7346a14 --- /dev/null +++ b/libc_extension/inet.c @@ -0,0 +1,14 @@ +#include + +in_addr_t inet_addr (const char *__cp) { + return -1; +} +char *inet_ntoa (struct in_addr __in) { + return 0; +} +const char *inet_ntop (int __af, const void *restrict __cp, char *restrict __buf, socklen_t __len) { + return 0; +} +int inet_pton (int __af, const char *restrict __cp, void *restrict __buf) { + return -1; +} diff --git a/libc_extension/mman.c b/libc_extension/mman.c new file mode 100644 index 0000000..eed4447 --- /dev/null +++ b/libc_extension/mman.c @@ -0,0 +1,14 @@ +#include + +int mlock (const void *__addr, size_t __len) { return -1; } +int mlockall (int __flags) { return -1; } +void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset) { + return 0; +} +int mprotect (void *__addr, size_t __len, int __prot) { return -1; } +int msync (void *__addr, size_t __len, int __flags) { return -1; } +int munlock (const void *__addr, size_t __len) { return -1; } +int munlockall (void) { return -1; } +int munmap (void *__addr, size_t __len) { return -1; } +int shm_open (const char *__name, int __oflag, mode_t __mode) { return -1; } +int shm_unlink (const char *__name) { return -1; } \ No newline at end of file diff --git a/libc_extension/pthread.c b/libc_extension/pthread.c new file mode 100644 index 0000000..8751e88 --- /dev/null +++ b/libc_extension/pthread.c @@ -0,0 +1,3 @@ +#include + +int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) { return -1; } diff --git a/libc_extension/sched.c b/libc_extension/sched.c new file mode 100644 index 0000000..bf5749b --- /dev/null +++ b/libc_extension/sched.c @@ -0,0 +1,5 @@ +#include +#include + +int sched_yield (void) { return -1; } +int sched_getcpu(void) { return ENOTSUP; } diff --git a/libc_extension/semaphore.c b/libc_extension/semaphore.c new file mode 100644 index 0000000..a6eb07c --- /dev/null +++ b/libc_extension/semaphore.c @@ -0,0 +1,12 @@ +#include + +int sem_close (sem_t *__sem) { return -1; } +int sem_destroy (sem_t *__sem) { return -1; } +int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval) { return -1; } +int sem_init (sem_t *__sem, int __pshared, unsigned int __value) { return -1; } +sem_t *sem_open (const char *__name, int __oflag, ...) { return 0; } +int sem_post (sem_t *__sem) { return -1; } +int sem_timedwait (sem_t *__restrict __sem, const struct timespec *__restrict __abstime) { return -1; } +int sem_trywait (sem_t *__sem) { return -1; } +int sem_unlink (const char *__name) { return -1; } +int sem_wait (sem_t *__sem) { return -1; } diff --git a/scripts/install_buildtools.sh b/scripts/install_buildtools.sh new file mode 100755 index 0000000..f565115 --- /dev/null +++ b/scripts/install_buildtools.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -euo pipefail + +readonly install_dir=$HOME/.local +readonly autoconf_version="2.69" + +if [ ! -d "$install_dir/bin" ]; then + mkdir "$install_dir/bin" + echo "export PATH=\"$install_dir/bin:\$PATH\"" >> ~/.bashrc + source ~/.bashrc +fi + +# install m4 (required to build autoconf) +if ! command -v m4 > /dev/null 2>&1; then + sudo apt update + sudo apt install -y m4 +fi + +# install automake +if ! command automake > /dev/null 2>&1; then + sudo apt update + sudo apt install -y automake +fi + +# install (specific version of) autoconf +wget --continue --quiet "https://ftp.gnu.org/gnu/autoconf/autoconf-${autoconf_version}.tar.gz" -O _autoconf.tar.gz +mkdir _autoconf +tar -xzf _autoconf.tar.gz -C _autoconf --strip-components=1 +pushd _autoconf +./configure --prefix="$install_dir" +make -j$(nproc) +make install +popd +rm -rf _autoconf* diff --git a/sdk_install/clang-template.cmake b/sdk_install/clang-template.cmake index 99fc15d..088bf60 100644 --- a/sdk_install/clang-template.cmake +++ b/sdk_install/clang-template.cmake @@ -2,18 +2,23 @@ --target=@TEMPLATE_TARGET@ -D_GNU_SOURCE=1 -D__GNU__ +-D__unix__ +-D__dandelion__ -D__rtems__ # prevent thread local storage in compilation, TODO: remove if we can provide TLS -D__thread="" +-D__TM_GMTOFF=tm_gmtoff # compiler flags -fPIE +#-march=haswell +#-mtune=haswell # include flags -nostdinc -isystem/include -isystem/include/sys --isystemCOMPILER_INCLUDES +-isystem@COMPILER_RUNTIME_INCLUDE@ # linker flags -T/linker.ld From 2bf02bbb05acbc0a01e19afc5516ad0323a05b69 Mon Sep 17 00:00:00 2001 From: Tobias Stocker <61014201+tostocker@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:10:49 +0100 Subject: [PATCH 10/16] Fixed template bug introduced in last PR (#29) --- sdk_install/clang-template.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk_install/clang-template.cmake b/sdk_install/clang-template.cmake index 088bf60..f7fd75a 100644 --- a/sdk_install/clang-template.cmake +++ b/sdk_install/clang-template.cmake @@ -18,7 +18,7 @@ -nostdinc -isystem/include -isystem/include/sys --isystem@COMPILER_RUNTIME_INCLUDE@ +-isystemCOMPILER_INCLUDES # linker flags -T/linker.ld From 724adcd376782faecb4e087be28fec097dcc3f5a Mon Sep 17 00:00:00 2001 From: Lanzelot <154733307+Lanzelot711@users.noreply.github.com> Date: Fri, 26 Jun 2026 13:15:32 +0200 Subject: [PATCH 11/16] Dev/testing (#30) * Add musl test to test the libc implementation. * Add a harness for the musl test library to extract failures and classify them. * Extend the implementation to have all expected header files, functions and defines. * Update and extend the Docker files for easier reproduction. --------- Co-authored-by: Lanzelot Moll --- .github/workflows/release_latest_testing.yml | 208 +++ .gitignore | 3 + CMakeLists.txt | 39 + README.md | 48 +- dev/Dockerfile.dlibc | 38 + dev/README | 138 ++ dev/dev_container.sh | 240 ++++ dev/dev_prepare_libctest.sh | 130 ++ dev/dev_rebuild.sh | 357 +++++ dev/dev_run_libctest_ctest.sh | 77 + dev/dev_update_libctest_patch.sh | 22 + dev/dev_update_newlib_patch.sh | 44 + libc_extension/CMakeLists.txt | 77 +- libc_extension/aio.c | 62 + libc_extension/arpa_inet.c | 38 + libc_extension/crypt.c | 9 + libc_extension/dlfcn.c | 29 +- libc_extension/if.c | 6 - libc_extension/ifaddrs.c | 7 +- libc_extension/include/aio.h | 51 + libc_extension/include/arpa/inet.h | 43 +- libc_extension/include/crypt.h | 14 + libc_extension/include/dlfcn.h | 31 +- libc_extension/include/mntent.h | 41 + libc_extension/include/monetary.h | 15 + libc_extension/include/mqueue.h | 41 + libc_extension/include/net/if.h | 29 +- libc_extension/include/netdb.h | 63 +- libc_extension/include/netinet/in.h | 175 +-- libc_extension/include/netinet/tcp.h | 7 + libc_extension/include/nl_types.h | 32 + libc_extension/include/poll.h | 6 + libc_extension/include/resolv.h | 15 + libc_extension/include/semaphore.h | 44 +- libc_extension/include/sys/ipc.h | 35 + libc_extension/include/sys/mman.h | 89 +- libc_extension/include/sys/msg.h | 37 + libc_extension/include/sys/poll.h | 36 + libc_extension/include/sys/sem.h | 42 + libc_extension/include/sys/shm_template.h | 40 + libc_extension/include/sys/socket.h | 84 +- libc_extension/include/sys/syscall.h | 24 + libc_extension/include/sys/termios.h | 163 +++ libc_extension/include/sys/un.h | 20 + libc_extension/include/sys/utsname_template.h | 25 + libc_extension/include/syslog.h | 58 + libc_extension/include/utmpx.h | 45 + libc_extension/inet.c | 14 - libc_extension/mman.c | 14 - libc_extension/mntent.c | 45 + libc_extension/monetary.c | 20 + libc_extension/mqueue.c | 92 ++ libc_extension/net_if.c | 25 + libc_extension/netdb.c | 64 + libc_extension/netinet_in.c | 4 + libc_extension/nl_types.c | 23 + libc_extension/poll.c | 10 + libc_extension/pthread.c | 7 +- libc_extension/resolv.c | 13 + libc_extension/sched.c | 11 +- libc_extension/semaphore.c | 81 +- libc_extension/socket.c | 43 +- libc_extension/sys_ipc.c | 9 + libc_extension/sys_mman.c | 83 ++ libc_extension/sys_msg.c | 36 + libc_extension/sys_sem.c | 31 + libc_extension/sys_shm.c | 32 + libc_extension/sys_syscall.c | 7 + libc_extension/sys_termios.c | 76 + libc_extension/sys_utsname.c | 8 + libc_extension/syslog.c | 25 + libc_extension/uio.c | 9 + libc_extension/utmpx.c | 29 + libc_test/.dockerignore | 5 + libc_test/.gitignore | 5 + libc_test/README | 19 + libc_test/config.mak.dlibc | 16 + libc_test/gen_csv.py | 133 ++ libc_test/libc-test.patch | 270 ++++ libc_test/run_test_dlibc.py | 252 ++++ libc_test/scripts/analyze_results.ipynb | 643 +++++++++ ...ibc_extension_manual_stubbed_functions.csv | 142 ++ .../newlib_shim_manual_stubbed_functions.csv | 149 ++ .../stub_inventory/stubbed_functions.csv | 290 ++++ newlib_shim/Makefile.inc | 5 +- newlib_shim/math_stubs.c | 65 + newlib_shim/newlib-cygwin-3.5.3.patch | 1254 ++++++++++++++++- newlib_shim/patch_script | 9 +- newlib_shim/pthread.c | 143 +- newlib_shim/search.c | 38 + newlib_shim/shim.c | 377 ++++- newlib_shim/signal_dandelion.c | 87 ++ newlib_shim/sys/fcntl.h | 38 + newlib_shim/time.c | 22 +- newlib_shim/unistd.c | 41 +- sdk_install/clang-template.cmake | 8 +- 96 files changed, 7379 insertions(+), 320 deletions(-) create mode 100644 .github/workflows/release_latest_testing.yml create mode 100644 dev/Dockerfile.dlibc create mode 100644 dev/README create mode 100755 dev/dev_container.sh create mode 100755 dev/dev_prepare_libctest.sh create mode 100755 dev/dev_rebuild.sh create mode 100755 dev/dev_run_libctest_ctest.sh create mode 100755 dev/dev_update_libctest_patch.sh create mode 100755 dev/dev_update_newlib_patch.sh create mode 100644 libc_extension/aio.c create mode 100644 libc_extension/arpa_inet.c create mode 100644 libc_extension/crypt.c delete mode 100644 libc_extension/if.c create mode 100644 libc_extension/include/aio.h create mode 100644 libc_extension/include/crypt.h create mode 100644 libc_extension/include/mntent.h create mode 100644 libc_extension/include/monetary.h create mode 100644 libc_extension/include/mqueue.h create mode 100644 libc_extension/include/netinet/tcp.h create mode 100644 libc_extension/include/nl_types.h create mode 100644 libc_extension/include/poll.h create mode 100644 libc_extension/include/resolv.h create mode 100644 libc_extension/include/sys/ipc.h create mode 100644 libc_extension/include/sys/msg.h create mode 100644 libc_extension/include/sys/poll.h create mode 100644 libc_extension/include/sys/sem.h create mode 100644 libc_extension/include/sys/shm_template.h create mode 100644 libc_extension/include/sys/syscall.h create mode 100644 libc_extension/include/sys/termios.h create mode 100644 libc_extension/include/sys/un.h create mode 100644 libc_extension/include/sys/utsname_template.h create mode 100644 libc_extension/include/syslog.h create mode 100644 libc_extension/include/utmpx.h delete mode 100644 libc_extension/inet.c delete mode 100644 libc_extension/mman.c create mode 100644 libc_extension/mntent.c create mode 100644 libc_extension/monetary.c create mode 100644 libc_extension/mqueue.c create mode 100644 libc_extension/net_if.c create mode 100644 libc_extension/netinet_in.c create mode 100644 libc_extension/nl_types.c create mode 100644 libc_extension/poll.c create mode 100644 libc_extension/resolv.c create mode 100644 libc_extension/sys_ipc.c create mode 100644 libc_extension/sys_mman.c create mode 100644 libc_extension/sys_msg.c create mode 100644 libc_extension/sys_sem.c create mode 100644 libc_extension/sys_shm.c create mode 100644 libc_extension/sys_syscall.c create mode 100644 libc_extension/sys_termios.c create mode 100644 libc_extension/sys_utsname.c create mode 100644 libc_extension/syslog.c create mode 100644 libc_extension/utmpx.c create mode 100644 libc_test/.dockerignore create mode 100644 libc_test/.gitignore create mode 100644 libc_test/README create mode 100644 libc_test/config.mak.dlibc create mode 100644 libc_test/gen_csv.py create mode 100644 libc_test/libc-test.patch create mode 100644 libc_test/run_test_dlibc.py create mode 100644 libc_test/scripts/analyze_results.ipynb create mode 100644 libc_test/scripts/stub_inventory/libc_extension_manual_stubbed_functions.csv create mode 100644 libc_test/scripts/stub_inventory/newlib_shim_manual_stubbed_functions.csv create mode 100644 libc_test/scripts/stub_inventory/stubbed_functions.csv create mode 100644 newlib_shim/math_stubs.c create mode 100644 newlib_shim/search.c create mode 100644 newlib_shim/signal_dandelion.c create mode 100644 newlib_shim/sys/fcntl.h diff --git a/.github/workflows/release_latest_testing.yml b/.github/workflows/release_latest_testing.yml new file mode 100644 index 0000000..ef2f3cc --- /dev/null +++ b/.github/workflows/release_latest_testing.yml @@ -0,0 +1,208 @@ +name: release testing with all library versions + +on: + push: + branches: [ "main", "dev/staging" ] + pull_request: + branches: [ "main", "dev/staging" ] + +jobs: + build: + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + matrix: + cpu: ["x86_64", "aarch64"] + platform: ["debug", "mmu_linux", "kvm"] + build: ["Debug", "Release"] + include: + - host: "ubuntu-24.04" + cpu: "x86_64" + - host: "ubuntu-24.04-arm" + cpu: "aarch64" + + runs-on: ${{ matrix.host }} + + steps: + - uses: actions/checkout@v6 + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y automake curl wget gpg lsb-release software-properties-common + + - name: Install clang-20 + run: | + wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh + chmod +x /tmp/llvm.sh + sudo /tmp/llvm.sh 20 + sudo ln -sf /usr/bin/ld.lld-20 /usr/bin/ld.lld + + - name: Install autoconf 2.69 + run: | + curl -O https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz + tar xvf autoconf-2.69.tar.gz + mkdir bin + mkdir build + cd build + ../autoconf-2.69/configure + make && sudo make install + + - name: Generate build directory name + id: build + run: echo "dir=build_${{ matrix.platform }}_${{ matrix.cpu }}" >> $GITHUB_OUTPUT + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.build.outputs.dir }} + -DCMAKE_CXX_COMPILER=clang++-20 + -DCMAKE_C_COMPILER=clang-20 + -DDANDELION_PLATFORM=${{ matrix.platform }} + -DNEWLIB=ON + -DCMAKE_BUILD_TYPE=${{ matrix.build }} + + - name: Build + run: cmake --build ${{ steps.build.outputs.dir }} + + - name: Install + run: cmake --install ${{ steps.build.outputs.dir }} + + - name: Compress + shell: bash + working-directory: ${{ steps.build.outputs.dir }} + run: tar -czf "dandelion_sdk_${{matrix.build}}_${{matrix.platform}}_${{matrix.cpu}}.tar.gz" dandelion_sdk + + - uses: actions/upload-artifact@v6 + with: + name: release-package-${{ matrix.build }}-${{ matrix.platform }}-${{ matrix.cpu }} + path: ${{ steps.build.outputs.dir }}/dandelion_sdk_${{matrix.build}}_${{matrix.platform}}_${{matrix.cpu}}.tar.gz + + test-and-analyze: + needs: build + strategy: + fail-fast: false + + matrix: + cpu: ["x86_64", "aarch64"] + include: + - host: "ubuntu-24.04" + cpu: "x86_64" + - host: "ubuntu-24.04-arm" + cpu: "aarch64" + + runs-on: ${{ matrix.host }} + timeout-minutes: 120 + env: + SDK_SRC: ${{ github.workspace }}/dandelionSDK + SDK_INSTALL: ${{ github.workspace }}/dandelion_sdk + LIBCTEST_DIR: ${{ github.workspace }}/dandelionSDK/libc_test + + steps: + - uses: actions/checkout@v6 + with: + path: dandelionSDK + + - uses: actions/setup-python@v6 + with: + python-version: "3.12" + + - name: Install test dependencies + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + build-essential ca-certificates make file \ + wget gpg lsb-release software-properties-common \ + gcc g++ automake curl + + - name: Install clang-20 + run: | + wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh + chmod +x /tmp/llvm.sh + sudo /tmp/llvm.sh 20 + sudo ln -sf /usr/bin/ld.lld-20 /usr/bin/ld.lld + + - name: Install analysis dependencies + run: python -m pip install --upgrade pip nbconvert jupyter pandas tabulate + + - uses: actions/download-artifact@v4 + with: + name: release-package-Release-debug-${{ matrix.cpu }} + path: downloaded-package + + - name: Unpack release SDK for libc-test + run: | + rm -rf "$SDK_INSTALL" + mkdir -p "$SDK_INSTALL" + tar -xzf "downloaded-package/dandelion_sdk_Release_debug_${{ matrix.cpu }}.tar.gz" -C "$GITHUB_WORKSPACE" + + - name: Create compiler wrapper from release SDK + run: | + "$SDK_INSTALL/create-compiler.sh" -c clang-20 + chmod u+x "$SDK_INSTALL/${{ matrix.cpu }}-unknown-dandelion-clang" + + - name: Run libc-test against release SDK + working-directory: dandelionSDK + run: > + ./dev/dev_rebuild.sh test + --arch ${{ matrix.cpu }} + --platform debug + --build-type Release + --log test_${{ matrix.cpu }}_debug_Release.log + --csv test_results.csv + + - name: Run notebook analysis + working-directory: dandelionSDK/libc_test/scripts + run: jupyter nbconvert --to notebook --execute --inplace analyze_results.ipynb + + - name: Prepare uploaded results + run: | + mkdir -p uploaded-results + cp "dandelionSDK/libc_test/report/function_failure_summary.csv" "uploaded-results/function_failure_summary_${{ matrix.cpu }}_debug_Release.csv" + cp "dandelionSDK/libc_test/report/function_failure_summary.md" "uploaded-results/function_failure_summary_${{ matrix.cpu }}_debug_Release.md" + cp "dandelionSDK/libc_test/report/failure_line_details.csv" "uploaded-results/failure_line_details_${{ matrix.cpu }}_debug_Release.csv" + cp "dandelionSDK/libc_test/logs/test_results.csv" "uploaded-results/test_results_${{ matrix.cpu }}_debug_Release.csv" + + - uses: actions/upload-artifact@v7 + with: + name: libc-test-analysis-${{ matrix.cpu }}-debug-Release + path: uploaded-results/ + + publish-release: + needs: + - build + - test-and-analyze + runs-on: ubuntu-24.04 + permissions: + contents: write + + steps: + - uses: actions/download-artifact@v7 + with: + pattern: libc-test-analysis-*-debug-Release + path: downloaded-results + merge-multiple: true + + - uses: actions/download-artifact@v7 + with: + pattern: release-package-* + path: downloaded-packages + merge-multiple: true + + - name: Publish release assets + shell: bash + run: | + mkdir -p release-assets + tar -czf release-assets/test_artifacts.tar.gz -C downloaded-results . + cp downloaded-packages/*.tar.gz release-assets/ + if ! gh release view testing >/dev/null 2>&1; then + gh release create testing --title "testing" --notes "" --latest=false --draft + else + gh release edit testing --title "testing" --latest=false --draft + fi + gh release upload testing release-assets/* --clobber + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index c063e79..14305c6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ compile_commands.json # rust test build folders */target/ Cargo.lock +dev/.dlibc-dev/ +libc_test/logs/ +libc_test/report/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e81a41a..c1b9f77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) project(dandelion-sdk) include(ExternalProject) +include(CTest) # binary options option(FREESTANDING "toggles the include of memcpy, memset, memmove and memcmp" ON) @@ -15,6 +16,8 @@ option(NEWLIB "toggles builing of newlib on top of dandelion interface" OFF) set(ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "the architecture to build for") set(DANDELION_PLATFORM "debug" CACHE STRING "backend to build for") set(PAGE_SIZE "4096" CACHE STRING "Page size for the runtime to assume.") +set(UTSNAME_FIELD_SIZE "65" CACHE STRING "Size of each utsname string field.") + message(STATUS "Building for ${DANDELION_PLATFORM} on ${ARCHITECTURE}") # Constants @@ -70,6 +73,7 @@ if(NEWLIB) string(APPEND NEWLIB_C_FLAGS " -nostdlib") string(APPEND NEWLIB_C_FLAGS " -fPIC") string(APPEND NEWLIB_C_FLAGS " -idirafter${COMPILER_RUNTIME_INCLUDE}") + string(APPEND NEWLIB_C_FLAGS " -D__DANDELION__") if(CMAKE_BUILD_TYPE MATCHES "Debug") string(APPEND NEWLIB_C_FLAGS " -gdwarf-4") endif() @@ -246,4 +250,39 @@ if(NEWLIB) add_subdirectory(test_programs) + if(BUILD_TESTING) + set(LIBCTEST_SHIM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libc_test") + set(LIBCTEST_CTEST_WORKTREE "${CMAKE_BINARY_DIR}/libc-test") + + add_test( + NAME libc_test_full + COMMAND + "${CMAKE_CURRENT_SOURCE_DIR}/dev/dev_run_libctest_ctest.sh" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_BINARY_DIR}" + "${CMAKE_INSTALL_PREFIX}" + "${LIBCTEST_SHIM_DIR}" + "${LIBCTEST_CTEST_WORKTREE}" + ) + set_tests_properties( + libc_test_full + PROPERTIES + LABELS "libc-test" + TIMEOUT 1800 + ) + + add_custom_target( + check-libc + COMMAND + "${CMAKE_CURRENT_SOURCE_DIR}/dev/dev_run_libctest_ctest.sh" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_BINARY_DIR}" + "${CMAKE_INSTALL_PREFIX}" + "${LIBCTEST_SHIM_DIR}" + "${LIBCTEST_CTEST_WORKTREE}" + DEPENDS newlib llvmproject + USES_TERMINAL + ) + endif() + endif() diff --git a/README.md b/README.md index b21ee10..2eef7e3 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ These currently include: A bigger selection of example functions can be found at [Function Examples](https://github.com/eth-easl/dandelionFunctionExamples) +The top-level `Dockerfile` is for running the SDK. +The build and development workflow is documented in `dev/README`. + ## Platforms and Architectures We support libraries for a variety of backends in Dandelion for both `x86_64` and `aarch64` @@ -102,7 +105,10 @@ For newlib to be built correctly the autoconf version 2.69. This also enables the build of the in memory file system, which can also be built without the other newlib builds by setting `-DDANDELION_FS=ON` -## Build Container +In `dev/README` you can find instructions on how to build the SDK with +our convenience SDK build and development workflows. + +## Container to use the SDK We also provide a docker file to construct a build container with the correct tools set up in them. To create the container with docker use the following command: ``` @@ -124,6 +130,46 @@ To add more tools to the build environment, they can be added to the docker file FROM dandelion_dev_docker:latest ``` +### Running A Simple Program + +The debug backend expects the current working directory to contain `input_sets/` and `output_sets/`. +If these folders are missing, the program will terminate before running user code. + +The following example builds and runs [`test_programs/libc/test.c`](test_programs/libc/test.c) inside the container: + +```bash +docker build --build-arg TARGET_ARCH=aarch64 -t dandelion_docker_image . + +docker run --rm -it \ + --mount type=bind,src="$(pwd)",dst=/workspace \ + --workdir=/workspace \ + dandelion_docker_image \ + bash + +mkdir -p /tmp/dandelion-smoke +cat > /tmp/dandelion-smoke/CMakeLists.txt <<'EOF' +cmake_minimum_required(VERSION 3.20) +project(dandelion_smoke C) +add_subdirectory(/root/dandelion_sdk sdk) +add_executable(smoke /workspace/test_programs/libc/test.c) +target_link_libraries(smoke PRIVATE dlibc dandelion_runtime) +EOF + +cmake -S /tmp/dandelion-smoke -B /tmp/dandelion-smoke/build +cmake --build /tmp/dandelion-smoke/build -j + +mkdir -p /tmp/run/input_sets/stdio /tmp/run/output_sets +printf 'abc' > /tmp/run/input_sets/stdio/stdin +printf 'smoke arg1 arg2' > /tmp/run/input_sets/stdio/argv +printf 'HOME=/root' > /tmp/run/input_sets/stdio/environ + +cd /tmp/run +/tmp/dandelion-smoke/build/smoke +``` + +The program writes its regular output to stdout/stderr and uses the files in `input_sets/stdio/` +to populate `stdin`, `argv`, and `environ`. + ## Freestanding The GCC/Clang standard expects 4 functions to allways be provided in any environment (even freestanding), which allow the compiler to always just insert them. (https://gcc.gnu.org/onlinedocs/gcc/Standards.html) diff --git a/dev/Dockerfile.dlibc b/dev/Dockerfile.dlibc new file mode 100644 index 0000000..1b220bb --- /dev/null +++ b/dev/Dockerfile.dlibc @@ -0,0 +1,38 @@ +# syntax=docker/dockerfile:1 +# +# Base image for the containerized dandelionSDK + libc-test workflow. +# +# Typical usage (mount-based workflow): +# ./dev/dev_container.sh --sdk /path/to/dandelionSDK +# # inside container: /work/dandelionSDK/dev/dev_rebuild.sh all +# +FROM ubuntu:24.04 + +ARG TARGET_ARCH=aarch64 + +ENV DEBIAN_FRONTEND=noninteractive + +# --- All build dependencies (SDK build + libc-test) --- +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential ca-certificates cmake git make file \ + wget gpg lsb-release software-properties-common \ + gcc g++ automake curl && \ + rm -rf /var/lib/apt/lists/* + +# clang-20 via the LLVM APT script +RUN wget https://apt.llvm.org/llvm.sh -O ~/llvm.sh && \ + chmod +x ~/llvm.sh && \ + ~/llvm.sh 20 && \ + ln -sf /usr/bin/ld.lld-20 /usr/bin/ld.lld && \ + rm ~/llvm.sh + +# autoconf 2.69 — exact version required by newlib's configure +RUN curl -sL https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz | tar xz && \ + cd autoconf-2.69 && ./configure --quiet && make -s && make install && \ + cd / && rm -rf autoconf-2.69 + +WORKDIR /work + +# This image is intended for mount-based use via dev_container.sh + dev_rebuild.sh. +CMD ["/bin/sh", "-lc", "echo 'Use /work/dandelionSDK/dev/dev_rebuild.sh all inside a dev shell container to build mounted dandelionSDK and run libc-test.' >&2 && sleep infinity"] diff --git a/dev/README b/dev/README new file mode 100644 index 0000000..87c73ae --- /dev/null +++ b/dev/README @@ -0,0 +1,138 @@ +Dandelion SDK dev workflow +========================== + +This directory contains the container-based development workflow for building +the SDK and running libc-test. + +Inside the dev container: + +- `SDK_SRC` points at `/work/dandelionSDK` +- `SDK_BUILD` points at `/work/sdk-build` +- `SDK_INSTALL` points at `/work/dandelion_sdk` + +The generated upstream libc-test checkout lives at: + +- `/work/sdk-build/libc-test` + +On the host, the persistent state directory is: + +- `dev/.dlibc-dev/` + +That state directory is bind-mounted into the container so the SDK build cache, +installed toolchain, and generated libc-test checkout persist across runs. + +Start or reuse the dev container from the repository root: + +```bash +./dev/dev_container.sh --sdk /path/to/dandelionSDK +``` + +If you are already in the `dandelionSDK` root, this also works: + +```bash +./dev/dev_container.sh +``` + +Inside the container, rebuild and install the SDK: + +```bash +./dev/dev_rebuild.sh sdk --log sdk.log +``` + +Rebuild the SDK and force the cached newlib patch to be reapplied: + +```bash +./dev/dev_rebuild.sh sdk --refresh-newlib-patch --log sdk.log +``` + +Reset the cached newlib checkout before reapplying the patch: + +```bash +./dev/dev_rebuild.sh sdk --refresh-newlib-patch --reset-newlib-tree --log sdk.log +``` + +Prepare or refresh the generated libc-test checkout: + +```bash +./dev/dev_prepare_libctest.sh +``` + +Reset the generated libc-test checkout back to the pinned upstream revision +before reapplying the patch and overlay files: + +```bash +./dev/dev_prepare_libctest.sh --reset +``` + +If you edit the generated libc-test checkout and want to refresh the tracked +patch file, run: + +```bash +./dev/dev_update_libctest_patch.sh +``` + +If you edit the cached newlib checkout and want to refresh the tracked newlib +patch file, run: + +```bash +./dev/dev_update_newlib_patch.sh +``` + +Rebuild everything and run libc-test: + +```bash +./dev/dev_rebuild.sh all --log all.log --csv all.csv +``` + +Run libc-test only against the installed SDK: + +```bash +./dev/dev_rebuild.sh test --log test.log --csv test.csv +``` + +Run the full libc-test suite through CTest from the configured SDK build +directory: + +```bash +cd /work/sdk-build +ctest --output-on-failure -R '^libc_test_full$' +``` + +Or use the convenience build target: + +```bash +cmake --build /work/sdk-build --target check-libc -j +``` + +Summarize pass counts from a generated CSV: + +```bash +awk -F, 'NR>1 {total++; if ($2=="PASS") pass++} END {print "passes=" pass "\ntotal=" total}' logs/test.csv +``` + +Generated artifacts: + +- libc-test logs: `/work/dandelionSDK/libc_test/logs/` +- libc-test reports: `/work/dandelionSDK/libc_test/report/` +- runtime stdio captures: `/work/dandelionSDK/libc_test/logs/test_stdio/` + +Adding a libc-test source file: + +Add a new self-contained `.c` file under one of these directories in the +generated checkout: + +- `/work/sdk-build/libc-test/src/api/` +- `/work/sdk-build/libc-test/src/functional/` +- `/work/sdk-build/libc-test/src/regression/` + +Use `src/api/` for interface/header exposure checks and `src/functional/` or +`src/regression/` for runtime behavior tests. + +Troubleshooting: + +If you delete `dev/.dlibc-dev/` on the host, recreate the dev container too so +the bind mounts are refreshed: + +```bash +./dev/dev_container.sh --recreate-container +``` diff --git a/dev/dev_container.sh b/dev/dev_container.sh new file mode 100755 index 0000000..cd11a5f --- /dev/null +++ b/dev/dev_container.sh @@ -0,0 +1,240 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +IMAGE_NAME="${IMAGE_NAME:-dev_dandelion_sdk}" +CONTAINER_NAME="${CONTAINER_NAME:-dev_dandelion_sdk_container}" +SDK_DIR_DEFAULT="${DANDELION_SDK_DIR:-$SCRIPT_DIR/../}" +STATE_DIR_DEFAULT="${DLIBC_DEV_STATE_DIR:-$SCRIPT_DIR/.dlibc-dev}" +CONTAINER_ROOT_DEFAULT="${DLIBC_CONTAINER_ROOT:-/work}" +SDK_MOUNT_DEFAULT="${SDK_MOUNT:-$CONTAINER_ROOT_DEFAULT/dandelionSDK}" +SDK_BUILD_MOUNT_DEFAULT="${SDK_BUILD_MOUNT:-$CONTAINER_ROOT_DEFAULT/sdk-build}" +SDK_INSTALL_MOUNT_DEFAULT="${SDK_INSTALL_MOUNT:-$CONTAINER_ROOT_DEFAULT/dandelion_sdk}" + +SDK_DIR="$SDK_DIR_DEFAULT" +STATE_DIR="$STATE_DIR_DEFAULT" +SDK_MOUNT="$SDK_MOUNT_DEFAULT" +SDK_BUILD_MOUNT="$SDK_BUILD_MOUNT_DEFAULT" +SDK_INSTALL_MOUNT="$SDK_INSTALL_MOUNT_DEFAULT" +ENSURE_ONLY=false +REBUILD_IMAGE=false +RECREATE_CONTAINER=false + +require_docker() { + if ! command -v docker >/dev/null 2>&1; then + echo "Error: docker command not found in PATH" >&2 + exit 1 + fi +} + +abspath_existing_dir() { + local dir="$1" + ( + cd "$dir" >/dev/null 2>&1 && pwd -P + ) +} + +abspath_parent_child() { + local path="$1" + local parent + local child + parent="$(dirname "$path")" + child="$(basename "$path")" + ( + mkdir -p "$parent" >/dev/null 2>&1 + cd "$parent" >/dev/null 2>&1 && printf '%s/%s\n' "$(pwd -P)" "$child" + ) +} + +usage() { + cat <&2 + usage >&2 + exit 1 + ;; + esac +done + +require_docker + +if [[ ! -d "$SDK_DIR" ]]; then + echo "Error: SDK directory not found: $SDK_DIR" >&2 + exit 1 +fi +if [[ ! -f "$SDK_DIR/CMakeLists.txt" ]]; then + echo "Error: SDK directory does not look like dandelionSDK root: $SDK_DIR" >&2 + echo "Expected file missing: $SDK_DIR/CMakeLists.txt" >&2 + exit 1 +fi + +SCRIPT_DIR="$(abspath_existing_dir "$SCRIPT_DIR")" +SDK_DIR="$(abspath_existing_dir "$SDK_DIR")" +STATE_DIR="$(abspath_parent_child "$STATE_DIR")" + +for path_var in SDK_MOUNT SDK_BUILD_MOUNT SDK_INSTALL_MOUNT; do + path_value="${!path_var}" + if [[ "$path_value" != /* ]]; then + echo "Error: $path_var must be an absolute container path: $path_value" >&2 + exit 1 + fi +done + +mkdir -p "$STATE_DIR/sdk-build" "$STATE_DIR/dandelion_sdk" + +image_exists() { + docker image inspect "$IMAGE_NAME" >/dev/null 2>&1 +} + +if [[ "$REBUILD_IMAGE" == true ]] || ! image_exists; then + echo "Building image '$IMAGE_NAME'..." + docker buildx build --load \ + -f "$SCRIPT_DIR/Dockerfile.dlibc" \ + -t "$IMAGE_NAME" \ + "$SDK_DIR" +fi + +container_exists() { + docker container inspect "$CONTAINER_NAME" >/dev/null 2>&1 +} + +container_running() { + [[ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME")" == "true" ]] +} + +container_image_matches() { + local image_id + local container_image_id + + image_id="$(docker image inspect -f '{{.Id}}' "$IMAGE_NAME")" + container_image_id="$(docker inspect -f '{{.Image}}' "$CONTAINER_NAME")" + [[ "$image_id" == "$container_image_id" ]] +} + +if container_exists && [[ "$RECREATE_CONTAINER" == true ]]; then + echo "Removing existing container '$CONTAINER_NAME'..." + docker rm -f "$CONTAINER_NAME" >/dev/null +fi + +if container_exists && ! container_image_matches; then + echo "Existing container '$CONTAINER_NAME' uses an outdated image; recreating it..." + docker rm -f "$CONTAINER_NAME" >/dev/null +fi + +if container_exists; then + if ! container_running; then + echo "Starting existing container '$CONTAINER_NAME'..." + docker start "$CONTAINER_NAME" >/dev/null + fi +else + echo "Creating container '$CONTAINER_NAME'..." + docker run -d \ + --name "$CONTAINER_NAME" \ + -e SDK_SRC="$SDK_MOUNT" \ + -e SDK_BUILD="$SDK_BUILD_MOUNT" \ + -e SDK_INSTALL="$SDK_INSTALL_MOUNT" \ + -v "$SDK_DIR:$SDK_MOUNT" \ + -v "$STATE_DIR/sdk-build:$SDK_BUILD_MOUNT" \ + -v "$STATE_DIR/dandelion_sdk:$SDK_INSTALL_MOUNT" \ + -w "$SDK_MOUNT" \ + "$IMAGE_NAME" \ + sleep infinity >/dev/null +fi + +echo "Container '$CONTAINER_NAME' is ready." +echo "SDK mount: $SDK_DIR -> $SDK_MOUNT" +echo "State mount: $STATE_DIR/sdk-build -> $SDK_BUILD_MOUNT" +echo "State mount: $STATE_DIR/dandelion_sdk -> $SDK_INSTALL_MOUNT" +echo "Inside container, use:" +echo " cd $SDK_MOUNT" +echo " ./dev/dev_rebuild.sh all # incremental SDK rebuild + libc-test run + CSV" +echo " ./dev/dev_rebuild.sh sdk # incremental SDK rebuild only" +echo " ./dev/dev_rebuild.sh test # rerun libc-test against installed SDK" + +if [[ "$ENSURE_ONLY" == true ]]; then + exit 0 +fi + +docker_exec_args=( + -e SDK_SRC="$SDK_MOUNT" + -e SDK_BUILD="$SDK_BUILD_MOUNT" + -e SDK_INSTALL="$SDK_INSTALL_MOUNT" +) + +if [[ -t 0 && -t 1 ]]; then + docker_exec_args+=(-it) +else + docker_exec_args+=(-i) +fi + +exec docker exec \ + "${docker_exec_args[@]}" \ + -w "$SDK_MOUNT" \ + "$CONTAINER_NAME" bash diff --git a/dev/dev_prepare_libctest.sh b/dev/dev_prepare_libctest.sh new file mode 100755 index 0000000..bb0eb11 --- /dev/null +++ b/dev/dev_prepare_libctest.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +LIBCTEST_DIR="${LIBCTEST_DIR:-$(cd "$SCRIPT_DIR/../libc_test" && pwd)}" +ROOT_DIR_DEFAULT="$(cd "$LIBCTEST_DIR/.." && pwd)" +STATE_DIR_DEFAULT="${SCRIPT_DIR}/.dlibc-dev" +SDK_BUILD="${SDK_BUILD:-$STATE_DIR_DEFAULT/sdk-build}" +LIBCTEST_WORKTREE="${LIBCTEST_WORKTREE:-$SDK_BUILD/libc-test}" +UPSTREAM_URL="https://repo.or.cz/libc-test.git" +UPSTREAM_REF="f2bac7711bec93467b73bec1465579ea0b8d5071" +PATCH_FILE="$LIBCTEST_DIR/libc-test.patch" +STAMP_FILE="$LIBCTEST_WORKTREE/.dandelion-prepared" +RESET_TREE=false +FETCH_MISSING=false + +usage() { + cat <<'EOF' +Usage: ./dev_prepare_libctest.sh [options] + +Prepare the generated libc-test worktree under SDK_BUILD from upstream plus +the local patch. + +Options: + --reset Reset the generated worktree before reapplying the patch + --fetch-missing Fetch from origin if the pinned upstream ref is missing locally + -h, --help Show help +EOF +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --reset) + RESET_TREE=true + shift + ;; + --fetch-missing) + FETCH_MISSING=true + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown option: $1" >&2 + usage >&2 + exit 1 + ;; + esac +done + +if [[ ! -f "$PATCH_FILE" ]]; then + echo "Patch file not found: $PATCH_FILE" >&2 + exit 1 +fi + +overlay_state() { + python3 - "$LIBCTEST_DIR" <<'PY' +from pathlib import Path +import hashlib +import sys + +base = Path(sys.argv[1]) +paths = [ + "libc-test.patch", + ".dockerignore", + "config.mak.dlibc", + "gen_csv.py", + "run_test_dlibc.py", + "scripts/analyze_results.ipynb", + "scripts/stub_inventory/libc_extension_manual_stubbed_functions.csv", + "scripts/stub_inventory/newlib_shim_manual_stubbed_functions.csv", + "scripts/stub_inventory/stubbed_functions.csv", +] + +digest = hashlib.sha256() +for rel in paths: + digest.update(rel.encode("utf-8")) + digest.update(b"\0") + digest.update((base / rel).read_bytes()) + digest.update(b"\0") + +print(digest.hexdigest()) +PY +} + +copy_overlay() { + cp "$LIBCTEST_DIR/.dockerignore" "$LIBCTEST_WORKTREE/.dockerignore" + cp "$LIBCTEST_DIR/config.mak.dlibc" "$LIBCTEST_WORKTREE/config.mak.dlibc" + cp "$LIBCTEST_DIR/gen_csv.py" "$LIBCTEST_WORKTREE/gen_csv.py" + cp "$LIBCTEST_DIR/run_test_dlibc.py" "$LIBCTEST_WORKTREE/run_test_dlibc.py" + mkdir -p "$LIBCTEST_WORKTREE/scripts/stub_inventory" + cp "$LIBCTEST_DIR/scripts/analyze_results.ipynb" "$LIBCTEST_WORKTREE/scripts/analyze_results.ipynb" + cp "$LIBCTEST_DIR/scripts/stub_inventory/"*.csv "$LIBCTEST_WORKTREE/scripts/stub_inventory/" +} + +EXPECTED_STATE="$(overlay_state)" + +if [[ ! -d "$LIBCTEST_WORKTREE/.git" ]]; then + rm -rf "$LIBCTEST_WORKTREE" + git clone "$UPSTREAM_URL" "$LIBCTEST_WORKTREE" +fi + +if ! git -C "$LIBCTEST_WORKTREE" cat-file -e "${UPSTREAM_REF}^{commit}" 2>/dev/null; then + if [[ "$FETCH_MISSING" == true ]]; then + git -C "$LIBCTEST_WORKTREE" fetch origin + else + echo "Pinned upstream ref $UPSTREAM_REF is not available in $LIBCTEST_WORKTREE." >&2 + echo "Rerun with --fetch-missing to fetch it from origin." >&2 + exit 1 + fi +fi + +CURRENT_STATE="" +if [[ -f "$STAMP_FILE" ]]; then + CURRENT_STATE="$(tr -d '[:space:]' < "$STAMP_FILE")" +fi + +if [[ "$RESET_TREE" == true || "$CURRENT_STATE" != "$EXPECTED_STATE" ]]; then + git -C "$LIBCTEST_WORKTREE" reset --hard "$UPSTREAM_REF" + git -C "$LIBCTEST_WORKTREE" clean -fdx + git -C "$LIBCTEST_WORKTREE" apply "$PATCH_FILE" + copy_overlay + printf '%s\n' "$EXPECTED_STATE" > "$STAMP_FILE" +fi + +mkdir -p "$LIBCTEST_DIR/logs" "$LIBCTEST_DIR/report" + +echo "Prepared libc-test worktree at $LIBCTEST_WORKTREE" diff --git a/dev/dev_rebuild.sh b/dev/dev_rebuild.sh new file mode 100755 index 0000000..57b401a --- /dev/null +++ b/dev/dev_rebuild.sh @@ -0,0 +1,357 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +usage() { + cat <<'EOF' +Usage: ./dev_rebuild.sh [all|sdk|test] [options] + +Commands: + all Rebuild/install dandelionSDK, then build+run libc-test (default) + sdk Rebuild/install dandelionSDK only + test Build+run libc-test only (uses already-installed SDK) + +Options: + --arch ARCH Target architecture (default: CMake/system default) + --platform NAME Dandelion platform (default: debug) + --build-type TYPE CMake build type (default: Release) + --jobs N Parallel jobs (default: nproc) + --clean Run clean steps before building + --refresh-newlib-patch + Reapply the cached newlib patch without recloning + --reset-newlib-tree Reset the cached newlib checkout before reapplying + the patch (useful after patch edits) + --log FILE Write build/test logs to logs/FILE + --csv FILE Write CSV output to logs/FILE (instead of stdout) + -h, --help Show help + +Environment defaults: + SDK_SRC (default: repo root, or dev_container-provided mount) + SDK_BUILD (default: dev/.dlibc-dev/sdk-build, or dev_container-provided mount) + SDK_INSTALL (default: dev/.dlibc-dev/dandelion_sdk, or dev_container-provided mount) + LIBCTEST_DIR (default: sibling libc_test shim dir) + LIBCTEST_WORKTREE + (default: SDK_BUILD/libc-test) +EOF +} + +COMMAND="all" +if [[ $# -gt 0 ]]; then + case "$1" in + all|sdk|test) + COMMAND="$1" + shift + ;; + esac +fi + +ARCH="${TARGET_ARCH:-}" +ARCH_EXPLICIT=false +PLATFORM="${DANDELION_PLATFORM:-debug}" +BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" +JOBS="$(nproc)" +CLEAN=false +REFRESH_NEWLIB_PATCH=false +RESET_NEWLIB_TREE=false +LOG_FILE="" +CSV_FILE="" + +if [[ -n "${TARGET_ARCH:-}" ]]; then + ARCH_EXPLICIT=true +fi + +while [[ $# -gt 0 ]]; do + case "$1" in + --arch) + ARCH="$2" + ARCH_EXPLICIT=true + shift 2 + ;; + --platform) + PLATFORM="$2" + shift 2 + ;; + --build-type) + BUILD_TYPE="$2" + shift 2 + ;; + --jobs) + JOBS="$2" + shift 2 + ;; + --clean) + CLEAN=true + shift + ;; + --refresh-newlib-patch) + REFRESH_NEWLIB_PATCH=true + shift + ;; + --reset-newlib-tree) + RESET_NEWLIB_TREE=true + REFRESH_NEWLIB_PATCH=true + shift + ;; + --log) + LOG_FILE="$2" + shift 2 + ;; + --csv) + CSV_FILE="$2" + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown option: $1" >&2 + usage >&2 + exit 1 + ;; + esac +done + +LIBCTEST_DIR="${LIBCTEST_DIR:-$(cd "$SCRIPT_DIR/../libc_test" && pwd)}" +ROOT_DIR_DEFAULT="$(cd "$LIBCTEST_DIR/.." && pwd)" +STATE_DIR_DEFAULT="${SCRIPT_DIR}/.dlibc-dev" +SDK_SRC="${SDK_SRC:-$ROOT_DIR_DEFAULT}" +SDK_BUILD="${SDK_BUILD:-$STATE_DIR_DEFAULT/sdk-build}" +SDK_INSTALL="${SDK_INSTALL:-$STATE_DIR_DEFAULT/dandelion_sdk}" +LIBCTEST_WORKTREE="${LIBCTEST_WORKTREE:-$SDK_BUILD/libc-test}" +LOG_DIR="${LIBCTEST_DIR}/logs" +SDK_CC="" +NEWLIB_SRC_DIR="${SDK_BUILD}/newlib-cygwin/src/newlib" +NEWLIB_BUILD_DIR="${SDK_BUILD}/newlib-cygwin/src/newlib-build" +NEWLIB_PATCH_STAMP="${NEWLIB_BUILD_DIR}/patch_applied" +NEWLIB_EP_STAMP_DIR="${SDK_BUILD}/newlib-cygwin/src/newlib-stamp" +NEWLIB_COMPLETE_STAMP="${SDK_BUILD}/CMakeFiles/newlib-complete" + +if [[ ! -d "$SDK_SRC" ]]; then + echo "SDK source directory not found: $SDK_SRC" >&2 + exit 1 +fi +if [[ ! -f "$SDK_SRC/CMakeLists.txt" ]]; then + echo "SDK source is not dandelionSDK repo root: $SDK_SRC" >&2 + echo "Expected file missing: $SDK_SRC/CMakeLists.txt" >&2 + exit 1 +fi +if [[ ! -d "$LIBCTEST_DIR" ]]; then + echo "libc-test directory not found: $LIBCTEST_DIR" >&2 + exit 1 +fi +if [[ ! -f "$LIBCTEST_DIR/libc-test.patch" ]]; then + echo "libc-test shim directory is missing its patch file: $LIBCTEST_DIR/libc-test.patch" >&2 + exit 1 +fi + +mkdir -p "$SDK_BUILD" "$SDK_INSTALL" + +normalize_output_path() { + local file_name + file_name="$(basename "$1")" + printf '%s/%s\n' "$LOG_DIR" "$file_name" +} + +detect_configured_arch() { + local cmake_cache="$SDK_BUILD/CMakeCache.txt" + + if [[ ! -f "$cmake_cache" ]]; then + return + fi + + awk -F= '/^ARCHITECTURE:STRING=/{print $2; exit}' "$cmake_cache" +} + +resolve_sdk_cc() { + local detected_arch="" + local matches=() + + if [[ "$ARCH_EXPLICIT" == true && -n "$ARCH" ]]; then + SDK_CC="${SDK_INSTALL}/${ARCH}-unknown-dandelion-clang" + return + fi + + detected_arch="$(detect_configured_arch)" + if [[ -n "$detected_arch" ]]; then + ARCH="$detected_arch" + SDK_CC="${SDK_INSTALL}/${ARCH}-unknown-dandelion-clang" + return + fi + + shopt -s nullglob + matches=("$SDK_INSTALL"/*-unknown-dandelion-clang) + shopt -u nullglob + + if [[ ${#matches[@]} -eq 1 ]]; then + SDK_CC="${matches[0]}" + ARCH="${SDK_CC##*/}" + ARCH="${ARCH%-unknown-dandelion-clang}" + return + fi + + if [[ ${#matches[@]} -gt 1 ]]; then + echo "Multiple compiler wrappers found in $SDK_INSTALL; rerun with --arch to choose one" >&2 + exit 1 + fi + + SDK_CC="" +} + +mkdir -p "$LOG_DIR" + +if [[ -n "$LOG_FILE" ]]; then + LOG_FILE="$(normalize_output_path "$LOG_FILE")" +fi + +if [[ -n "$CSV_FILE" ]]; then + CSV_FILE="$(normalize_output_path "$CSV_FILE")" +fi + +if [[ -n "$LOG_FILE" ]]; then + : >"$LOG_FILE" +fi + +run_cmd() { + if [[ -n "$LOG_FILE" ]]; then + "$@" >>"$LOG_FILE" 2>&1 + else + "$@" + fi +} + +refresh_newlib_patch() { + if [[ ! -d "$NEWLIB_SRC_DIR/.git" ]]; then + echo "==> Cached newlib checkout not found at $NEWLIB_SRC_DIR; skipping patch refresh" + return + fi + + if [[ "$RESET_NEWLIB_TREE" == true ]]; then + echo "==> Resetting cached newlib checkout" + run_cmd git -C "$NEWLIB_SRC_DIR" reset --hard HEAD + run_cmd git -C "$NEWLIB_SRC_DIR" clean -fd + fi + + echo "==> Clearing newlib patch stamp" + run_cmd rm -f "$NEWLIB_PATCH_STAMP" + + echo "==> Invalidating newlib external-project stamps" + run_cmd rm -f \ + "$NEWLIB_EP_STAMP_DIR/newlib-patch_disconnected" \ + "$NEWLIB_EP_STAMP_DIR/newlib-configure" \ + "$NEWLIB_EP_STAMP_DIR/newlib-build" \ + "$NEWLIB_EP_STAMP_DIR/newlib-install" \ + "$NEWLIB_EP_STAMP_DIR/newlib-done" \ + "$NEWLIB_COMPLETE_STAMP" +} + +rebuild_sdk() { + if [[ "$REFRESH_NEWLIB_PATCH" == true ]]; then + refresh_newlib_patch + fi + + echo "==> Configuring dandelionSDK in $SDK_BUILD" + cmake_args=( + -S "$SDK_SRC" + -B "$SDK_BUILD" + -DCMAKE_C_COMPILER=clang-20 + -DCMAKE_CXX_COMPILER=clang++-20 + -DDANDELION_PLATFORM="$PLATFORM" + -DNEWLIB=ON + -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON + -DCMAKE_BUILD_TYPE="$BUILD_TYPE" + -DCMAKE_INSTALL_PREFIX="$SDK_INSTALL" + ) + + if [[ "$ARCH_EXPLICIT" == true ]]; then + cmake_args+=(-DARCHITECTURE="$ARCH") + fi + + run_cmd cmake "${cmake_args[@]}" + + echo "==> Building required SDK targets" + + run_cmd cmake --build "$SDK_BUILD" \ + --target dandelion_system dandelion_runtime dandelion_file_system newlib llvmproject \ + -j"$JOBS" + + echo "==> Installing dandelionSDK" + run_cmd cmake --install "$SDK_BUILD" + + echo "==> Creating wrapped compiler" + run_cmd "$SDK_INSTALL/create-compiler.sh" -c clang-20 + resolve_sdk_cc + if [[ -z "$SDK_CC" ]]; then + echo "Unable to determine compiler wrapper path in $SDK_INSTALL" >&2 + exit 1 + fi + # On the Docker workflow the copied clang wrapper can lose its execute bit + # on the bind-mounted install dir, which later breaks libc-test with + # "Permission denied" when invoking $SDK_CC. + run_cmd chmod u+x "$SDK_CC" + if [[ ! -x "$SDK_CC" ]]; then + echo "Wrapped compiler is not executable after creation: $SDK_CC" >&2 + exit 1 + fi +} + +emit_csv() { + if [[ -n "$CSV_FILE" ]]; then + python3 "$LIBCTEST_WORKTREE/gen_csv.py" "$LIBCTEST_WORKTREE/src" >"$CSV_FILE" + echo "CSV written to $CSV_FILE" + else + python3 "$LIBCTEST_WORKTREE/gen_csv.py" "$LIBCTEST_WORKTREE/src" + fi +} + +prepare_libctest() { + run_cmd "$SCRIPT_DIR/dev_prepare_libctest.sh" --fetch-missing +} + +run_tests() { + resolve_sdk_cc + if [[ ! -x "$SDK_CC" ]]; then + if [[ -n "$SDK_CC" ]]; then + echo "Expected compiler wrapper not found: $SDK_CC" >&2 + else + echo "Expected compiler wrapper not found in $SDK_INSTALL" >&2 + fi + if [[ -n "$ARCH" ]]; then + echo "Run: ./dev_rebuild.sh sdk --arch $ARCH" >&2 + else + echo "Run: ./dev_rebuild.sh sdk --arch " >&2 + fi + exit 1 + fi + + prepare_libctest + + cd "$LIBCTEST_WORKTREE" + cp config.mak.dlibc config.mak + mkdir -p input_sets output_sets + mkdir -p "$LOG_DIR" + + if [[ "$CLEAN" == true ]]; then + run_cmd make cleanall + fi + + echo "==> Building and running libc-test" + if ! run_cmd env DLIBC_STDIO_ARTIFACTS="$LOG_DIR/test_stdio" make -k -j"$JOBS" CC="$SDK_CC"; then + true + fi + emit_csv +} + +case "$COMMAND" in + sdk) + rebuild_sdk + ;; + test) + run_tests + ;; + all) + rebuild_sdk + run_tests + ;; +esac diff --git a/dev/dev_run_libctest_ctest.sh b/dev/dev_run_libctest_ctest.sh new file mode 100755 index 0000000..7a9a38d --- /dev/null +++ b/dev/dev_run_libctest_ctest.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +usage() { + cat <<'EOF' +Usage: ./dev_run_libctest_ctest.sh + +Run the full libc-test suite for CTest and fail if any test case fails. +EOF +} + +if [[ $# -ne 5 ]]; then + usage >&2 + exit 1 +fi + +SDK_SRC="$1" +SDK_BUILD="$2" +SDK_INSTALL="$3" +LIBCTEST_DIR="$4" +LIBCTEST_WORKTREE="$5" +LOG_NAME="ctest.log" +CSV_NAME="ctest.csv" + +if [[ ! -f "$SDK_BUILD/CMakeCache.txt" ]]; then + echo "SDK build directory is not configured: $SDK_BUILD" >&2 + exit 1 +fi + +mkdir -p "$LIBCTEST_DIR/logs" + +cmake --install "$SDK_BUILD" + +if [[ ! -x "$SDK_INSTALL/create-compiler.sh" ]]; then + echo "Missing compiler wrapper generator: $SDK_INSTALL/create-compiler.sh" >&2 + exit 1 +fi + +"$SDK_INSTALL/create-compiler.sh" -c clang-20 + +env \ + SDK_SRC="$SDK_SRC" \ + SDK_BUILD="$SDK_BUILD" \ + SDK_INSTALL="$SDK_INSTALL" \ + LIBCTEST_DIR="$LIBCTEST_DIR" \ + LIBCTEST_WORKTREE="$LIBCTEST_WORKTREE" \ + "$SCRIPT_DIR/dev_rebuild.sh" test --log "$LOG_NAME" --csv "$CSV_NAME" + +python3 - "$LIBCTEST_DIR/logs/$CSV_NAME" <<'PY' +import csv +import sys +from pathlib import Path + +csv_path = Path(sys.argv[1]) +if not csv_path.is_file(): + print(f"Missing libc-test CSV report: {csv_path}", file=sys.stderr) + raise SystemExit(1) + +with csv_path.open(newline="", encoding="utf-8") as handle: + rows = list(csv.DictReader(handle)) + +failures = [row for row in rows if row.get("result") != "PASS"] +passes = sum(1 for row in rows if row.get("result") == "PASS") + +print(f"libc-test summary: passes={passes} failures={len(failures)} total={len(rows)}") + +if failures: + print("First failing rows:", file=sys.stderr) + for row in failures[:20]: + print( + f"{row.get('test','')},{row.get('failure_stage','')},{row.get('evidence_file','')}", + file=sys.stderr, + ) + raise SystemExit(1) +PY diff --git a/dev/dev_update_libctest_patch.sh b/dev/dev_update_libctest_patch.sh new file mode 100755 index 0000000..81291fb --- /dev/null +++ b/dev/dev_update_libctest_patch.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +LIBCTEST_DIR="${LIBCTEST_DIR:-$(cd "$SCRIPT_DIR/../libc_test" && pwd)}" +STATE_DIR_DEFAULT="${SCRIPT_DIR}/.dlibc-dev" +SDK_BUILD="${SDK_BUILD:-$STATE_DIR_DEFAULT/sdk-build}" +LIBCTEST_WORKTREE="${LIBCTEST_WORKTREE:-$SDK_BUILD/libc-test}" +PATCH_FILE="$LIBCTEST_DIR/libc-test.patch" + +if [[ ! -d "$LIBCTEST_WORKTREE/.git" ]]; then + echo "Generated libc-test worktree not found: $LIBCTEST_WORKTREE" >&2 + exit 1 +fi + +if [[ ! -f "$PATCH_FILE" ]]; then + echo "Patch file not found: $PATCH_FILE" >&2 + exit 1 +fi + +git -C "$LIBCTEST_WORKTREE" diff -- . > "$PATCH_FILE" +echo "Wrote patch to $PATCH_FILE" diff --git a/dev/dev_update_newlib_patch.sh b/dev/dev_update_newlib_patch.sh new file mode 100755 index 0000000..1804d4d --- /dev/null +++ b/dev/dev_update_newlib_patch.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +LIBCTEST_DIR="${LIBCTEST_DIR:-$(cd "$SCRIPT_DIR/../libc_test" && pwd)}" +ROOT_DIR_DEFAULT="$(cd "$LIBCTEST_DIR/.." && pwd)" +STATE_DIR_DEFAULT="${SCRIPT_DIR}/.dlibc-dev" +SDK_SRC="${SDK_SRC:-$ROOT_DIR_DEFAULT}" +SDK_BUILD="${SDK_BUILD:-$STATE_DIR_DEFAULT/sdk-build}" +NEWLIB_SRC_DIR="${SDK_BUILD}/newlib-cygwin/src/newlib" +PATCH_FILE="${SDK_SRC}/newlib_shim/newlib-cygwin-3.5.3.patch" +EXCLUDE_PATHS=( + ':(exclude)configure' + ':(exclude)*/configure' + ':(exclude)Makefile.in' + ':(exclude)*/Makefile.in' + ':(exclude)aclocal.m4' + ':(exclude)*/aclocal.m4' + ':(exclude)config.h.in' + ':(exclude)*/config.h.in' + ':(exclude)autom4te.cache' + ':(exclude)*/autom4te.cache' + ':(exclude)libtool' + ':(exclude)*/libtool' + ':(exclude)config.status' + ':(exclude)*/config.status' + ':(exclude)Makefile' + ':(exclude)*/Makefile' + ':(exclude)stamp-h1' + ':(exclude)*/stamp-h1' +) + +if [[ ! -d "$NEWLIB_SRC_DIR/.git" ]]; then + echo "Cached newlib checkout not found: $NEWLIB_SRC_DIR" >&2 + exit 1 +fi + +if [[ ! -d "$SDK_SRC/newlib_shim" ]]; then + echo "SDK shim directory not found: $SDK_SRC/newlib_shim" >&2 + exit 1 +fi + +git -C "$NEWLIB_SRC_DIR" diff -- . "${EXCLUDE_PATHS[@]}" > "$PATCH_FILE" +echo "Wrote patch to $PATCH_FILE" diff --git a/libc_extension/CMakeLists.txt b/libc_extension/CMakeLists.txt index adcd588..0f65896 100644 --- a/libc_extension/CMakeLists.txt +++ b/libc_extension/CMakeLists.txt @@ -1,36 +1,91 @@ add_library(${LIBC_EXTENSION} STATIC) +set(LIBC_EXTENSION_GENERATED_INCLUDE_DIR + ${CMAKE_CURRENT_BINARY_DIR}/include) +# Render sys/shm.h from the source template so SHMLBA tracks the configured PAGE_SIZE. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/include/sys/shm_template.h + ${LIBC_EXTENSION_GENERATED_INCLUDE_DIR}/sys/shm.h + @ONLY +) +# Render sys/utsname.h from the source template so field sizes track the configured UTSNAME_FIELD_SIZE. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/include/sys/utsname_template.h + ${LIBC_EXTENSION_GENERATED_INCLUDE_DIR}/sys/utsname.h + @ONLY +) + target_sources(${LIBC_EXTENSION} PRIVATE - dirent.c + arpa_inet.c + aio.c dlfcn.c - if.c + dirent.c ifaddrs.c - inet.c - mman.c + mqueue.c + nl_types.c + poll.c + semaphore.c + sys_ipc.c + sys_msg.c + sys_sem.c + monetary.c + net_if.c + netinet_in.c netdb.c pthread.c sched.c - semaphore.c socket.c + crypt.c + mntent.c + resolv.c + sys_mman.c + sys_shm.c + sys_syscall.c + sys_termios.c + sys_utsname.c + syslog.c + utmpx.c uio.c PUBLIC FILE_SET public_headers TYPE HEADERS - BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/ + BASE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/include/ + ${LIBC_EXTENSION_GENERATED_INCLUDE_DIR} FILES + include/arpa/inet.h + include/aio.h + include/crypt.h include/dlfcn.h include/ifaddrs.h - include/netdb.h + include/mqueue.h + include/mntent.h + include/nl_types.h + include/poll.h + include/resolv.h include/semaphore.h - include/arpa/inet.h + include/monetary.h include/net/if.h include/netinet/in.h + include/netinet/tcp.h + include/netdb.h include/sys/cpuset.h include/sys/dirent.h + include/sys/ipc.h include/sys/mman.h + include/sys/msg.h + include/sys/sem.h + include/sys/syscall.h + include/sys/poll.h include/sys/sched.h include/sys/socket.h include/sys/statvfs.h + include/sys/termios.h include/sys/uio.h + include/sys/un.h + ${LIBC_EXTENSION_GENERATED_INCLUDE_DIR}/sys/utsname.h + ${LIBC_EXTENSION_GENERATED_INCLUDE_DIR}/sys/shm.h + include/syslog.h + include/utmpx.h ) if(CMAKE_BUILD_TYPE MATCHES "Debug") @@ -38,6 +93,10 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug") target_compile_options(${LIBC_EXTENSION} PRIVATE -g) endif() +# Compile against generated headers before source templates +target_include_directories(${LIBC_EXTENSION} BEFORE PRIVATE + ${LIBC_EXTENSION_GENERATED_INCLUDE_DIR} +) target_link_libraries(${LIBC_EXTENSION} PRIVATE dlibc) include(GNUInstallDirs) @@ -51,4 +110,4 @@ add_custom_command( TARGET ${LIBC_EXTENSION} POST_BUILD COMMAND ${CMAKE_COMMAND} --install ${CMAKE_CURRENT_BINARY_DIR} -) \ No newline at end of file +) diff --git a/libc_extension/aio.c b/libc_extension/aio.c new file mode 100644 index 0000000..1799601 --- /dev/null +++ b/libc_extension/aio.c @@ -0,0 +1,62 @@ +#include +#include + + +// https://man7.org/linux/man-pages/man7/aio.7.html + +int aio_cancel(int fd, struct aiocb *aiocbp) { + (void)fd; + (void)aiocbp; + errno = ENOSYS; + return -1; +} + +int aio_error(const struct aiocb *aiocbp) { + (void)aiocbp; + errno = ENOSYS; + return -1; +} + +int aio_fsync(int op, struct aiocb *aiocbp) { + (void)op; + (void)aiocbp; + errno = ENOSYS; + return -1; +} + +int aio_read(struct aiocb *aiocbp) { + (void)aiocbp; + errno = ENOSYS; + return -1; +} + +ssize_t aio_return(struct aiocb *aiocbp) { + (void)aiocbp; + errno = ENOSYS; + return -1; +} + +int aio_suspend(const struct aiocb *const aiocb_list[], int nitems, + const struct timespec *timeout) { + (void)aiocb_list; + (void)nitems; + (void)timeout; + errno = ENOSYS; + return -1; +} + +int aio_write(struct aiocb *aiocbp) { + (void)aiocbp; + errno = ENOSYS; + return -1; +} + +int lio_listio(int mode, struct aiocb *restrict const list[restrict], int nent, + struct sigevent *restrict sig) { + (void)mode; + (void)list; + (void)nent; + (void)sig; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/arpa_inet.c b/libc_extension/arpa_inet.c new file mode 100644 index 0000000..3342bd1 --- /dev/null +++ b/libc_extension/arpa_inet.c @@ -0,0 +1,38 @@ +#include +#include + +uint32_t htonl(uint32_t hostlong) { + (void)hostlong; + errno = ENOSYS; + return 0; +} + +in_addr_t inet_addr(const char *cp) { + (void)cp; + errno = ENOSYS; + return (in_addr_t)-1; +} + +char *inet_ntoa(struct in_addr in) { + (void)in; + errno = ENOSYS; + return 0; +} + +const char *inet_ntop(int af, const void *restrict src, char *restrict dst, + socklen_t size) { + (void)af; + (void)src; + (void)dst; + (void)size; + errno = ENOSYS; + return 0; +} + +int inet_pton(int af, const char *restrict src, void *restrict dst) { + (void)af; + (void)src; + (void)dst; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/crypt.c b/libc_extension/crypt.c new file mode 100644 index 0000000..f762b94 --- /dev/null +++ b/libc_extension/crypt.c @@ -0,0 +1,9 @@ +#include +#include + +char *crypt(const char *phrase, const char *setting) { + (void)phrase; + (void)setting; + errno = ENOSYS; + return 0; +} diff --git a/libc_extension/dlfcn.c b/libc_extension/dlfcn.c index ca2611b..85c976f 100644 --- a/libc_extension/dlfcn.c +++ b/libc_extension/dlfcn.c @@ -1,6 +1,27 @@ #include +#include -int dlclose (void *__handle) { return -1; } -char *dlerror (void) { return 0; } -void *dlopen (const char *__file, int __mode) { return 0; } -void *dlsym (void *__restrict __handle, const char *__restrict __name) { return 0; } +int dlclose(void *handle) { + (void)handle; + errno = ENOSYS; + return -1; +} + +char *dlerror(void) { + errno = ENOSYS; + return "dynamic loading is not supported"; +} + +void *dlopen(const char *file, int mode) { + (void)file; + (void)mode; + errno = ENOSYS; + return NULL; +} + +void *dlsym(void *restrict handle, const char *restrict name) { + (void)handle; + (void)name; + errno = ENOSYS; + return NULL; +} diff --git a/libc_extension/if.c b/libc_extension/if.c deleted file mode 100644 index 7df680a..0000000 --- a/libc_extension/if.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -unsigned int if_nametoindex (const char *__ifname) { return 0; } -char *if_indextoname (unsigned int __ifindex, char __ifname[IF_NAMESIZE]) { return 0; } -struct if_nameindex *if_nameindex (void) { return 0; } -void if_freenameindex (struct if_nameindex *__ptr) { return; } diff --git a/libc_extension/ifaddrs.c b/libc_extension/ifaddrs.c index efb422f..1254563 100644 --- a/libc_extension/ifaddrs.c +++ b/libc_extension/ifaddrs.c @@ -1,4 +1,9 @@ #include +#include -int getifaddrs (struct ifaddrs **__ifap) { return -1; } +int getifaddrs (struct ifaddrs **__ifap) { + (void)__ifap; + errno = ENOSYS; + return -1; +} void freeifaddrs (struct ifaddrs *__ifa) { return; } diff --git a/libc_extension/include/aio.h b/libc_extension/include/aio.h new file mode 100644 index 0000000..b8e6648 --- /dev/null +++ b/libc_extension/include/aio.h @@ -0,0 +1,51 @@ +#ifndef _AIO_H +#define _AIO_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/librt-ddefs.html */ + + +/* POSIX AIO cancellation status codes */ +#define AIO_CANCELED 0 +#define AIO_NOTCANCELED 1 +#define AIO_ALLDONE 2 + +#define LIO_READ 0 +#define LIO_WRITE 1 +#define LIO_NOP 2 +#define LIO_WAIT 0 +#define LIO_NOWAIT 1 + +struct aiocb { + int aio_fildes; + off_t aio_offset; + volatile void *aio_buf; + size_t aio_nbytes; + int aio_reqprio; + struct sigevent aio_sigevent; + int aio_lio_opcode; +}; + +int aio_cancel(int, struct aiocb *); +int aio_error(const struct aiocb *); +int aio_fsync(int, struct aiocb *); +int aio_read(struct aiocb *); +ssize_t aio_return(struct aiocb *); +int aio_suspend(const struct aiocb *const[], int, const struct timespec *); +int aio_write(struct aiocb *); +int lio_listio(int, struct aiocb *restrict const[restrict], int, + struct sigevent *restrict); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libc_extension/include/arpa/inet.h b/libc_extension/include/arpa/inet.h index 47776b2..eca9376 100644 --- a/libc_extension/include/arpa/inet.h +++ b/libc_extension/include/arpa/inet.h @@ -1,13 +1,38 @@ -/* THIS IS A DUMMY HEADER */ - #ifndef _ARPA_INET_H -#define _ARPA_INET_H 1 +#define _ARPA_INET_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint16_t in_port_t; +typedef uint32_t in_addr_t; + +struct in_addr { + in_addr_t s_addr; +}; + +/* https://man7.org/linux/man-pages/man0/netinet_in.h.0p.html */ +#define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 + +/* https://man7.org/linux/man-pages/man3/htonl.3p.html */ + +uint32_t htonl(uint32_t); +uint16_t htons(uint16_t); +uint32_t ntohl(uint32_t); +uint16_t ntohs(uint16_t); -#include /* To define `struct in_addr'. */ +in_addr_t inet_addr(const char *); +char *inet_ntoa(struct in_addr); +const char *inet_ntop(int, const void *restrict, char *restrict, socklen_t); +int inet_pton(int, const char *restrict, void *restrict); -extern in_addr_t inet_addr (const char *__cp); -extern char *inet_ntoa (struct in_addr __in); -extern const char *inet_ntop (int __af, const void * __cp, char * __buf, socklen_t __len); -extern int inet_pton (int __af, const char * __cp, void * __buf); +#ifdef __cplusplus +} +#endif -#endif // _ARPA_INET_H +#endif diff --git a/libc_extension/include/crypt.h b/libc_extension/include/crypt.h new file mode 100644 index 0000000..31dc351 --- /dev/null +++ b/libc_extension/include/crypt.h @@ -0,0 +1,14 @@ +#ifndef _CRYPT_H +#define _CRYPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +char *crypt(const char *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _CRYPT_H */ diff --git a/libc_extension/include/dlfcn.h b/libc_extension/include/dlfcn.h index 35eeab3..33128dd 100644 --- a/libc_extension/include/dlfcn.h +++ b/libc_extension/include/dlfcn.h @@ -1,16 +1,23 @@ -/* THIS IS A DUMMY HEADER */ +#ifndef _DLFCN_H +#define _DLFCN_H -#ifndef _DLFCN_H -#define _DLFCN_H 1 +#ifdef __cplusplus +extern "C" { +#endif -#define RTLD_LAZY 0x00001 -#define RTLD_NOW 0x00002 -#define RTLD_GLOBAL 0x00100 -#define RTLD_LOCAL 0 +/* https://sources.debian.org/src/musl/1.1.5-2%2Bdeb8u1/include/dlfcn.h */ +#define RTLD_LAZY 1 +#define RTLD_NOW 2 +#define RTLD_GLOBAL 256 +#define RTLD_LOCAL 0 -extern int dlclose (void *__handle); -extern char *dlerror (void); -extern void *dlopen (const char *__file, int __mode); -extern void *dlsym (void *__restrict __handle, const char *__restrict __name); +int dlclose(void *); +char *dlerror(void); +void *dlopen(const char *, int); +void *dlsym(void *restrict, const char *restrict); -#endif /* dlfcn.h */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libc_extension/include/mntent.h b/libc_extension/include/mntent.h new file mode 100644 index 0000000..8c77b02 --- /dev/null +++ b/libc_extension/include/mntent.h @@ -0,0 +1,41 @@ +#ifndef _MNTENT_H +#define _MNTENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://codebrowser.dev/glibc/glibc/misc/mntent.h.html */ +#define MNTTYPE_IGNORE "ignore" +#define MNTTYPE_NFS "nfs" +#define MNTTYPE_SWAP "swap" +#define MNTOPT_DEFAULTS "defaults" +#define MNTOPT_RO "ro" +#define MNTOPT_RW "rw" +#define MNTOPT_SUID "suid" +#define MNTOPT_NOSUID "nosuid" +#define MNTOPT_NOAUTO "noauto" + +struct mntent { + char *mnt_fsname; + char *mnt_dir; + char *mnt_type; + char *mnt_opts; + int mnt_freq; + int mnt_passno; +}; + +FILE *setmntent(const char *, const char *); +struct mntent *getmntent(FILE *); +struct mntent *getmntent_r(FILE *, struct mntent *, char *, int); +int addmntent(FILE *, const struct mntent *); +int endmntent(FILE *); +char *hasmntopt(const struct mntent *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _MNTENT_H */ diff --git a/libc_extension/include/monetary.h b/libc_extension/include/monetary.h new file mode 100644 index 0000000..fc31cc9 --- /dev/null +++ b/libc_extension/include/monetary.h @@ -0,0 +1,15 @@ +#ifndef _MONETARY_H_ +#define _MONETARY_H_ + +#include +#include +#include + +__BEGIN_DECLS + +ssize_t strfmon(char *restrict, size_t, const char *restrict, ...); +ssize_t strfmon_l(char *restrict, size_t, locale_t, const char *restrict, ...); + +__END_DECLS + +#endif /* _MONETARY_H_ */ diff --git a/libc_extension/include/mqueue.h b/libc_extension/include/mqueue.h new file mode 100644 index 0000000..84c2934 --- /dev/null +++ b/libc_extension/include/mqueue.h @@ -0,0 +1,41 @@ +#ifndef _MQUEUE_H +#define _MQUEUE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://man7.org/linux/man-pages/man0/mqueue.h.0p.html */ + +typedef int mqd_t; + +struct mq_attr { + long mq_flags; + long mq_maxmsg; + long mq_msgsize; + long mq_curmsgs; +}; + +int mq_close(mqd_t); +int mq_getattr(mqd_t, struct mq_attr *); +int mq_notify(mqd_t, const struct sigevent *); +mqd_t mq_open(const char *, int, ...); +ssize_t mq_receive(mqd_t, char *, size_t, unsigned *); +int mq_send(mqd_t, const char *, size_t, unsigned); +int mq_setattr(mqd_t, const struct mq_attr *restrict, + struct mq_attr *restrict); +ssize_t mq_timedreceive(mqd_t, char *restrict, size_t, unsigned *restrict, + const struct timespec *restrict); +int mq_timedsend(mqd_t, const char *, size_t, unsigned, + const struct timespec *); +int mq_unlink(const char *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libc_extension/include/net/if.h b/libc_extension/include/net/if.h index 27bdbcd..cf16ea8 100644 --- a/libc_extension/include/net/if.h +++ b/libc_extension/include/net/if.h @@ -1,18 +1,23 @@ -/* THIS IS A DUMMY HEADER */ +#ifndef _NET_IF_H_ +#define _NET_IF_H_ -#ifndef _NET_IF_H -#define _NET_IF_H 1 - -#define IF_NAMESIZE 16 +#include +/* https://man7.org/linux/man-pages/man0/net_if.h.0p.html */ +/* https://git.musl-libc.org/cgit/musl/tree/include/net/if.h */ +#define IF_NAMESIZE 16 struct if_nameindex { - unsigned int if_index; - char *if_name; + unsigned if_index; + char *if_name; }; -extern unsigned int if_nametoindex (const char *__ifname); -extern char *if_indextoname (unsigned int __ifindex, char __ifname[IF_NAMESIZE]); -extern struct if_nameindex *if_nameindex (void); -extern void if_freenameindex (struct if_nameindex *__ptr); +__BEGIN_DECLS + +void if_freenameindex(struct if_nameindex *); +char *if_indextoname(unsigned, char *); +struct if_nameindex *if_nameindex(void); +unsigned if_nametoindex(const char *); + +__END_DECLS -#endif /* net/if.h */ +#endif /* _NET_IF_H_ */ diff --git a/libc_extension/include/netdb.h b/libc_extension/include/netdb.h index 7e6c133..3d69519 100644 --- a/libc_extension/include/netdb.h +++ b/libc_extension/include/netdb.h @@ -3,6 +3,11 @@ #include #include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* Description of data base entry for a single host. */ struct hostent @@ -51,6 +56,47 @@ extern int h_errno; # define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */ # define NO_DATA 4 /* Valid name, no data record of requested type. */ +struct addrinfo +{ + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; + +/* https://sources.debian.org/src/glibc/2.43-1/resolv/netdb.h */ +# define AI_PASSIVE 0x0001 +# define AI_CANONNAME 0x0002 +# define AI_NUMERICHOST 0x0004 +# define AI_V4MAPPED 0x0008 +# define AI_ALL 0x0010 +# define AI_ADDRCONFIG 0x0020 +# define AI_NUMERICSERV 0x0400 + +/* https://git.musl-libc.org/cgit/musl/tree/include/netdb.h */ + # define NI_NUMERICHOST 0x0001 + # define NI_NUMERICSERV 0x0002 +# define NI_NOFQDN 0x0004 +# define NI_NAMEREQD 0x0008 +# define NI_DGRAM 0x0010 +# define NI_NUMERICSCOPE 0x000000100 + +/* https://sources.debian.org/src/glibc/2.43-1/resolv/netdb.h */ +# define EAI_BADFLAGS -1 +# define EAI_NONAME -2 +# define EAI_AGAIN -3 +# define EAI_FAIL -4 +# define EAI_FAMILY -6 +# define EAI_SOCKTYPE -7 +# define EAI_SERVICE -8 +# define EAI_MEMORY -10 +# define EAI_SYSTEM -11 +# define EAI_OVERFLOW -12 + extern void endhostent (void); extern void endnetent (void); extern void endprotoent (void); @@ -71,5 +117,20 @@ extern void sethostent (int __stay_open); extern void setnetent (int __stay_open); extern void setprotoent (int __stay_open); extern void setservent (int __stay_open); +extern void freeaddrinfo (struct addrinfo *__ai); +extern int getaddrinfo (const char *__restrict __name, + const char *__restrict __service, + const struct addrinfo *__restrict __req, + struct addrinfo **__restrict __pai); +extern int getnameinfo (const struct sockaddr *__restrict __sa, + socklen_t __salen, + char *__restrict __host, socklen_t __hostlen, + char *__restrict __serv, socklen_t __servlen, + int __flags); +extern const char *gai_strerror (int __ecode); + +#ifdef __cplusplus +} +#endif -#endif // _NETDB_H \ No newline at end of file +#endif // _NETDB_H diff --git a/libc_extension/include/netinet/in.h b/libc_extension/include/netinet/in.h index c4e1463..9ec374c 100644 --- a/libc_extension/include/netinet/in.h +++ b/libc_extension/include/netinet/in.h @@ -1,124 +1,97 @@ -/* THIS IS A DUMMY HEADER */ - -#ifndef _NETINET_IN_H -#define _NETINET_IN_H 1 +#ifndef _NETINET_IN_H_ +#define _NETINET_IN_H_ +#include +#include #include -#include -typedef uint16_t in_port_t; -typedef uint32_t in_addr_t; +/* https://git.musl-libc.org/cgit/musl/tree/include/netinet/in.h */ +#define IPPROTO_IP 0 +#define IPPROTO_ICMP 1 +#define IPPROTO_TCP 6 +#define IPPROTO_UDP 17 +#define IPPROTO_IPV6 41 +#define IPPROTO_RAW 255 -struct in_addr { - in_addr_t s_addr; -}; +/* https://git.musl-libc.org/cgit/musl/tree/include/netinet/in.h */ +#define INADDR_ANY ((in_addr_t)0) +#define INADDR_BROADCAST ((in_addr_t)0xffffffff) +#define INADDR_NONE ((in_addr_t)0xffffffff) +#define INADDR_LOOPBACK ((in_addr_t)0x7f000001) struct sockaddr_in { - sa_family_t sin_family; - in_port_t sin_port; - struct in_addr sin_addr; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + uint8_t sin_zero[8]; }; struct in6_addr { - uint8_t s6_addr[16]; + union { + uint8_t __s6_addr[16]; + uint16_t __s6_addr16[8]; + uint32_t __s6_addr32[4]; + } __in6_union; }; +#define s6_addr __in6_union.__s6_addr +#define s6_addr16 __in6_union.__s6_addr16 +#define s6_addr32 __in6_union.__s6_addr32 struct sockaddr_in6 { - sa_family_t sin6_family; - in_port_t sin6_port; - uint32_t sin6_flowinfo; - struct in6_addr sin6_addr; - uint32_t sin6_scope_id; + sa_family_t sin6_family; + in_port_t sin6_port; + uint32_t sin6_flowinfo; + struct in6_addr sin6_addr; + uint32_t sin6_scope_id; }; -extern const struct in6_addr in6addr_any; -extern const struct in6_addr in6addr_loopback; - struct ipv6_mreq { - struct in6_addr ipv6mr_multiaddr; - unsigned int ipv6mr_interface; + struct in6_addr ipv6mr_multiaddr; + unsigned ipv6mr_interface; }; -enum { - IPPROTO_IP = 0, - IPPROTO_ICMP = 1, - IPPROTO_TCP = 6, - IPPROTO_UDP = 17, - IPPROTO_IPV6 = 41, - IPPROTO_RAW = 255, -}; -#define IPPROTO_IP IPPROTO_IP -#define IPPROTO_ICMP IPPROTO_ICMP -#define IPPROTO_TCP IPPROTO_TCP -#define IPPROTO_UDP IPPROTO_UDP -#define IPPROTO_IPV6 IPPROTO_IPV6 -#define IPPROTO_RAW IPPROTO_RAW - -#define INADDR_ANY ((in_addr_t) 0x00000000) -#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) - -#define INET_ADDRSTRLEN 16 -#define INET6_ADDRSTRLEN 46 - -# define IN6_IS_ADDR_UNSPECIFIED(a) \ - (__extension__ \ - ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->__in6_u.__u6_addr32[0] == 0 \ - && __a->__in6_u.__u6_addr32[1] == 0 \ - && __a->__in6_u.__u6_addr32[2] == 0 \ - && __a->__in6_u.__u6_addr32[3] == 0; })) - -# define IN6_IS_ADDR_LOOPBACK(a) \ - (__extension__ \ - ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->__in6_u.__u6_addr32[0] == 0 \ - && __a->__in6_u.__u6_addr32[1] == 0 \ - && __a->__in6_u.__u6_addr32[2] == 0 \ - && __a->__in6_u.__u6_addr32[3] == htonl (1); })) - -# define IN6_IS_ADDR_LINKLOCAL(a) \ - (__extension__ \ - ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); })) - -# define IN6_IS_ADDR_SITELOCAL(a) \ - (__extension__ \ - ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); })) - -# define IN6_IS_ADDR_V4MAPPED(a) \ - (__extension__ \ - ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->__in6_u.__u6_addr32[0] == 0 \ - && __a->__in6_u.__u6_addr32[1] == 0 \ - && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); })) - -# define IN6_IS_ADDR_V4COMPAT(a) \ - (__extension__ \ - ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->__in6_u.__u6_addr32[0] == 0 \ - && __a->__in6_u.__u6_addr32[1] == 0 \ - && __a->__in6_u.__u6_addr32[2] == 0 \ - && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; })) +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; +/* https://sources.debian.org/src/glibc/2.41-7/inet/netinet/in.h/ */ +#define IN6ADDR_ANY_INIT { { { 0 } } } +#define IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } } } + +/* https://git.musl-libc.org/cgit/musl/tree/include/netinet/in.h */ +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_JOIN_GROUP 20 +#define IPV6_LEAVE_GROUP 21 +#define IPV6_V6ONLY 26 + +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ + (a)->s6_addr32[2] == 0 && (a)->s6_addr32[3] == 0) +#define IN6_IS_ADDR_LOOPBACK(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ + (a)->s6_addr32[2] == 0 && (a)->s6_addr32[3] == htonl(1)) +#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) +#define IN6_IS_ADDR_LINKLOCAL(a) \ + ((a)->s6_addr[0] == 0xfe && ((a)->s6_addr[1] & 0xc0) == 0x80) +#define IN6_IS_ADDR_SITELOCAL(a) \ + ((a)->s6_addr[0] == 0xfe && ((a)->s6_addr[1] & 0xc0) == 0xc0) +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ + (a)->s6_addr32[2] == htonl(0xffff)) +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ + (a)->s6_addr32[2] == 0 && ntohl((a)->s6_addr32[3]) > 1) #define IN6_IS_ADDR_MC_NODELOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((const uint8_t *) (a))[1] & 0xf) == 0x1)) - + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x1) #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((const uint8_t *) (a))[1] & 0xf) == 0x2)) - + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x2) #define IN6_IS_ADDR_MC_SITELOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((const uint8_t *) (a))[1] & 0xf) == 0x5)) - + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x5) #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((const uint8_t *) (a))[1] & 0xf) == 0x8)) - + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x8) #define IN6_IS_ADDR_MC_GLOBAL(a) \ - (IN6_IS_ADDR_MULTICAST(a) \ - && ((((const uint8_t *) (a))[1] & 0xf) == 0xe)) - -#endif // _NETINET_IN_H \ No newline at end of file + (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0xe) + +#endif /* _NETINET_IN_H_ */ diff --git a/libc_extension/include/netinet/tcp.h b/libc_extension/include/netinet/tcp.h new file mode 100644 index 0000000..3ce8978 --- /dev/null +++ b/libc_extension/include/netinet/tcp.h @@ -0,0 +1,7 @@ +#ifndef _NETINET_TCP_H_ +#define _NETINET_TCP_H_ + +/* https://git.musl-libc.org/cgit/musl/tree/include/netinet/tcp.h */ +#define TCP_NODELAY 1 + +#endif /* _NETINET_TCP_H_ */ diff --git a/libc_extension/include/nl_types.h b/libc_extension/include/nl_types.h new file mode 100644 index 0000000..7500814 --- /dev/null +++ b/libc_extension/include/nl_types.h @@ -0,0 +1,32 @@ +#ifndef _NL_TYPES_H_ +#define _NL_TYPES_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://sources.debian.org/src/glibc/2.43-1/catgets/nl_types.h */ +#define NL_SETD 1 +#define NL_CAT_LOCALE 1 + +typedef struct __nl_cat_d { + void *__data; + int __size; +} *nl_catd; + +#ifndef _NL_ITEM_DECLARED +typedef __nl_item nl_item; +#define _NL_ITEM_DECLARED +#endif + +int catclose(nl_catd); +char *catgets(nl_catd, int, int, const char *); +nl_catd catopen(const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _NL_TYPES_H_ */ diff --git a/libc_extension/include/poll.h b/libc_extension/include/poll.h new file mode 100644 index 0000000..2611296 --- /dev/null +++ b/libc_extension/include/poll.h @@ -0,0 +1,6 @@ +#ifndef _POLL_H +#define _POLL_H + +#include + +#endif /* _POLL_H */ diff --git a/libc_extension/include/resolv.h b/libc_extension/include/resolv.h new file mode 100644 index 0000000..0dc3e90 --- /dev/null +++ b/libc_extension/include/resolv.h @@ -0,0 +1,15 @@ +#ifndef _RESOLV_H +#define _RESOLV_H + +#ifdef __cplusplus +extern "C" { +#endif + +int dn_expand(const unsigned char *, const unsigned char *, + const unsigned char *, char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _RESOLV_H */ diff --git a/libc_extension/include/semaphore.h b/libc_extension/include/semaphore.h index 60dc33d..ec33bbb 100644 --- a/libc_extension/include/semaphore.h +++ b/libc_extension/include/semaphore.h @@ -1,32 +1,32 @@ -/* THIS IS A DUMMY HEADER */ - #ifndef _SEMAPHORE_H -#define _SEMAPHORE_H 1 +#define _SEMAPHORE_H +#include #include -#if __WORDSIZE == 64 -# define __SIZEOF_SEM_T 32 -#else -# define __SIZEOF_SEM_T 16 +#ifdef __cplusplus +extern "C" { #endif -typedef union { - char __size[__SIZEOF_SEM_T]; - long int __align; +typedef struct { + int __value; } sem_t; -#define SEM_FAILED ((sem_t *) 0) +#define SEM_FAILED ((sem_t *)0) + +int sem_close(sem_t *); +int sem_destroy(sem_t *); +int sem_getvalue(sem_t *restrict, int *restrict); +int sem_init(sem_t *, int, unsigned); +sem_t *sem_open(const char *, int, ...); +int sem_post(sem_t *); +int sem_timedwait(sem_t *restrict, const struct timespec *restrict); +int sem_trywait(sem_t *); +int sem_unlink(const char *); +int sem_wait(sem_t *); -extern int sem_close (sem_t *__sem); -extern int sem_destroy (sem_t *__sem); -extern int sem_getvalue (sem_t *__sem, int *__sval); -extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value); -extern sem_t *sem_open (const char *__name, int __oflag, ...); -extern int sem_post (sem_t *__sem); -extern int sem_timedwait (sem_t *__sem, const struct timespec *__abstime); -extern int sem_trywait (sem_t *__sem); -extern int sem_unlink (const char *__name); -extern int sem_wait (sem_t *__sem); +#ifdef __cplusplus +} +#endif -#endif /* semaphore.h */ +#endif /* _SEMAPHORE_H */ diff --git a/libc_extension/include/sys/ipc.h b/libc_extension/include/sys/ipc.h new file mode 100644 index 0000000..96e4e76 --- /dev/null +++ b/libc_extension/include/sys/ipc.h @@ -0,0 +1,35 @@ +#ifndef _SYS_IPC_H +#define _SYS_IPC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ipc_perm { + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; +}; + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/ipc.h */ +#define IPC_CREAT 01000 +#define IPC_EXCL 02000 +#define IPC_NOWAIT 04000 +#define IPC_PRIVATE ((key_t)0) + +/* https://github.com/torvalds/linux/blob/master/include/uapi/linux/ipc.h */ +#define IPC_RMID 0 +#define IPC_SET 1 +#define IPC_STAT 2 + +key_t ftok(const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_IPC_H */ diff --git a/libc_extension/include/sys/mman.h b/libc_extension/include/sys/mman.h index 93e2449..1c1bc31 100644 --- a/libc_extension/include/sys/mman.h +++ b/libc_extension/include/sys/mman.h @@ -1,37 +1,58 @@ -/* THIS IS A DUMMY HEADER */ - -#ifndef _SYS_MMAN_H -#define _SYS_MMAN_H 1 +#ifndef _SYS_MMAN_H +#define _SYS_MMAN_H #include -#define PROT_READ 0x1 -#define PROT_WRITE 0x2 -#define PROT_EXEC 0x4 -#define PROT_NONE 0x0 - -#define MAP_SHARED 0x01 -#define MAP_PRIVATE 0x02 -#define MAP_FIXED 0x10 - -#define MS_ASYNC 1 -#define MS_SYNC 4 -#define MS_INVALIDATE 2 - -#define MCL_CURRENT 1 -#define MCL_FUTURE 2 - -#define MAP_FAILED ((void *) -1) - -extern int mlock (const void *__addr, size_t __len); -extern int mlockall (int __flags); -extern void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset); -extern int mprotect (void *__addr, size_t __len, int __prot); -extern int msync (void *__addr, size_t __len, int __flags); -extern int munlock (const void *__addr, size_t __len); -extern int munlockall (void); -extern int munmap (void *__addr, size_t __len); -extern int shm_open (const char *__name, int __oflag, mode_t __mode); -extern int shm_unlink (const char *__name); - -#endif /* sys/mman.h */ +#ifdef __cplusplus +extern "C" { +#endif + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ +#define PROT_NONE 0x0 +#define PROT_READ 0x1 +#define PROT_WRITE 0x2 +#define PROT_EXEC 0x4 + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ +#define MAP_SHARED 0x01 +#define MAP_PRIVATE 0x02 +#define MAP_FIXED 0x10 +#define MAP_ANON 0x20 +#define MAP_ANONYMOUS MAP_ANON + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ +#define MAP_FAILED ((void *)-1) + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ +#define MS_ASYNC 1 +#define MS_INVALIDATE 2 +#define MS_SYNC 4 + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ +#define MCL_CURRENT 1 +#define MCL_FUTURE 2 + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ +#define POSIX_MADV_NORMAL 0 +#define POSIX_MADV_RANDOM 1 +#define POSIX_MADV_SEQUENTIAL 2 +#define POSIX_MADV_WILLNEED 3 +#define POSIX_MADV_DONTNEED 4 + +void *mmap(void *, size_t, int, int, int, off_t); +int mprotect(void *, size_t, int); +int msync(void *, size_t, int); +int munmap(void *, size_t); +int mlock(const void *, size_t); +int mlockall(int); +int munlock(const void *, size_t); +int munlockall(void); +int posix_madvise(void *, size_t, int); +int shm_open(const char *, int, mode_t); +int shm_unlink(const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MMAN_H */ diff --git a/libc_extension/include/sys/msg.h b/libc_extension/include/sys/msg.h new file mode 100644 index 0000000..4227b0c --- /dev/null +++ b/libc_extension/include/sys/msg.h @@ -0,0 +1,37 @@ +#ifndef _SYS_MSG_H +#define _SYS_MSG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://github.com/torvalds/linux/blob/master/include/uapi/linux/msg.h */ +#define MSG_NOERROR 010000 + +typedef unsigned long msgqnum_t; +typedef unsigned long msglen_t; + +struct msqid_ds { + struct ipc_perm msg_perm; + msgqnum_t msg_qnum; + msglen_t msg_qbytes; + pid_t msg_lspid; + pid_t msg_lrpid; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; +}; + +int msgctl(int, int, struct msqid_ds *); +int msgget(key_t, int); +ssize_t msgrcv(int, void *, size_t, long, int); +int msgsnd(int, const void *, size_t, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MSG_H */ diff --git a/libc_extension/include/sys/poll.h b/libc_extension/include/sys/poll.h new file mode 100644 index 0000000..525a7b4 --- /dev/null +++ b/libc_extension/include/sys/poll.h @@ -0,0 +1,36 @@ +#ifndef _SYS_POLL_H +#define _SYS_POLL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned int nfds_t; + +struct pollfd { + int fd; + short events; + short revents; +}; + +/* https://sources.debian.org/src/glibc/2.43-1/sysdeps/unix/sysv/linux/bits/poll.h */ +#define POLLIN 0x001 +#define POLLPRI 0x002 +#define POLLOUT 0x004 +#define POLLERR 0x008 +#define POLLHUP 0x010 +#define POLLNVAL 0x020 +#define POLLRDNORM 0x040 +#define POLLRDBAND 0x080 +#define POLLWRNORM 0x100 +#define POLLWRBAND 0x200 + +int poll(struct pollfd[], nfds_t, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_POLL_H */ diff --git a/libc_extension/include/sys/sem.h b/libc_extension/include/sys/sem.h new file mode 100644 index 0000000..7805929 --- /dev/null +++ b/libc_extension/include/sys/sem.h @@ -0,0 +1,42 @@ +#ifndef _SYS_SEM_H +#define _SYS_SEM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://github.com/torvalds/linux/blob/master/include/uapi/linux/sem.h */ +#define SEM_UNDO 0x1000 +#define GETNCNT 14 +#define GETPID 11 +#define GETVAL 12 +#define GETALL 13 +#define GETZCNT 15 +#define SETVAL 16 +#define SETALL 17 + +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + time_t sem_ctime; + unsigned short sem_nsems; +}; + +struct sembuf { + unsigned short sem_num; + short sem_op; + short sem_flg; +}; + +int semctl(int, int, int, ...); +int semget(key_t, int, int); +int semop(int, struct sembuf *, size_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SEM_H */ diff --git a/libc_extension/include/sys/shm_template.h b/libc_extension/include/sys/shm_template.h new file mode 100644 index 0000000..31a557a --- /dev/null +++ b/libc_extension/include/sys/shm_template.h @@ -0,0 +1,40 @@ +#ifndef _SYS_SHM_H +#define _SYS_SHM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned long shmatt_t; + +/* https://github.com/torvalds/linux/blob/master/include/uapi/linux/shm.h */ +#define SHM_RDONLY 010000 +#define SHM_RND 020000 + +/* https://refspecs.linuxfoundation.org/LSB_2.0.1/LSB-Core-AMD64/LSB-Core-AMD64.diff.pdf */ +#define SHMLBA @PAGE_SIZE@ + +struct shmid_ds { + struct ipc_perm shm_perm; + size_t shm_segsz; + pid_t shm_lpid; + pid_t shm_cpid; + shmatt_t shm_nattch; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; +}; + +void *shmat(int, const void *, int); +int shmctl(int, int, struct shmid_ds *); +int shmdt(const void *); +int shmget(key_t, size_t, int); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SHM_H */ diff --git a/libc_extension/include/sys/socket.h b/libc_extension/include/sys/socket.h index b0eb27a..da9463e 100644 --- a/libc_extension/include/sys/socket.h +++ b/libc_extension/include/sys/socket.h @@ -1,7 +1,12 @@ #ifndef _SYS_SOCKET_H #define _SYS_SOCKET_H 1 +#ifdef __cplusplus +extern "C" { +#endif + #include +#include /* Type for length arguments in socket calls. */ typedef unsigned int socklen_t; @@ -33,13 +38,10 @@ struct msghdr socklen_t msg_namelen; /* Length of address data. */ struct iovec *msg_iov; /* Vector of data to send/receive into. */ - size_t msg_iovlen; /* Number of elements in the vector. */ + int msg_iovlen; /* Number of elements in the vector. */ void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ - size_t msg_controllen; /* Ancillary data buffer length. - !! The type should be socklen_t but the - definition of the kernel is incompatible - with this. */ + socklen_t msg_controllen; /* Ancillary data buffer length. */ int msg_flags; /* Flags on received message. */ }; @@ -47,15 +49,17 @@ struct msghdr /* Structure used for storage of ancillary data object information. */ struct cmsghdr { - size_t cmsg_len; /* Length of data in cmsg_data plus length - of cmsghdr structure. - !! The type should be socklen_t but the - definition of the kernel is incompatible - with this. */ + socklen_t cmsg_len; /* Length of data in cmsg_data plus header. */ int cmsg_level; /* Originating protocol. */ int cmsg_type; /* Protocol specific type. */ }; +struct linger +{ + int l_onoff; + int l_linger; +}; + /* Types of sockets. */ enum __socket_type { @@ -194,6 +198,30 @@ enum __socket_type #define AF_MCTP PF_MCTP #define AF_MAX PF_MAX +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h */ +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_LINGER 13 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#define SO_ACCEPTCONN 30 +#define SOL_SOCKET 1 +#define SOMAXCONN 128 + +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 + /* Bits in the FLAGS argument to `send', `recv', et al. */ enum { @@ -244,15 +272,39 @@ enum #define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC }; +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h */ +#define CMSG_DATA(cmsg) \ + ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1)) +#define CMSG_NXTHDR(mhdr, cmsg) \ + ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \ + (((((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)) + \ + sizeof(struct cmsghdr)) >= \ + ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen) - \ + (unsigned char *)(cmsg)) \ + ? 0 : (struct cmsghdr *)((unsigned char *)(cmsg) + \ + (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)))) +#define CMSG_FIRSTHDR(mhdr) \ + ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? \ + (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0) +#define CMSG_ALIGN(len) \ + (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) +#define CMSG_SPACE(len) \ + (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr))) +#define CMSG_LEN(len) \ + (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) + +/* https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h */ +#define SCM_RIGHTS 0x01 + extern int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len); extern int bind (int __fd, const struct sockaddr *__addr, socklen_t __len); extern int connect (int __fd, const struct sockaddr *__addr, socklen_t __len); -extern int getpeername (int __fd, struct sockaddr __addr, socklen_t *__len); -extern int getsockname (int __fd, struct sockaddr __addr, socklen_t *__len); +extern int getpeername (int __fd, struct sockaddr *__addr, socklen_t *__len); +extern int getsockname (int __fd, struct sockaddr *__addr, socklen_t *__len); extern int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen); extern int listen (int __fd, int __n); extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags); -extern ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr __addr, +extern ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr *__addr, socklen_t *__addr_len); extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags); extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags); @@ -266,4 +318,8 @@ extern int socket (int __domain, int __type, int __protocol); extern int sockatmark (int __fd); extern int socketpair (int __domain, int __type, int __protocol, int __fds[2]); -#endif // _SYS_SOCKET_H \ No newline at end of file +#ifdef __cplusplus +} +#endif + +#endif // _SYS_SOCKET_H diff --git a/libc_extension/include/sys/syscall.h b/libc_extension/include/sys/syscall.h new file mode 100644 index 0000000..bd61264 --- /dev/null +++ b/libc_extension/include/sys/syscall.h @@ -0,0 +1,24 @@ +#ifndef _SYS_SYSCALL_H +#define _SYS_SYSCALL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/syscall.h.in */ +#if defined(__x86_64__) +#define SYS_read 0 +#endif + +/* https://git.musl-libc.org/cgit/musl/tree/arch/aarch64/bits/syscall.h.in */ +#if defined(__aarch64__) +#define SYS_read 63 +#endif + +long syscall(long, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSCALL_H */ diff --git a/libc_extension/include/sys/termios.h b/libc_extension/include/sys/termios.h new file mode 100644 index 0000000..fd3371c --- /dev/null +++ b/libc_extension/include/sys/termios.h @@ -0,0 +1,163 @@ +#ifndef _SYS_TERMIOS_H +#define _SYS_TERMIOS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-struct.h.html */ +#define NCCS 32 + +struct termios { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t c_line; + cc_t c_cc[NCCS]; + speed_t c_ispeed; + speed_t c_ospeed; +}; + +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_cc.h.html */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 + +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_iflag.h.html */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 + +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_oflag.h.html */ +#define OPOST 0000001 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 + +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios.h.html + * https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_cflag.h.html + */ +#define B0 0000000 +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 + +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_lflag.h.html */ +#define ISIG 0000001 +#define ICANON 0000002 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define IEXTEN 0100000 + +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-tcflow.h.html */ +#ifndef TCSANOW +#define TCSANOW 0 +#endif +#ifndef TCSADRAIN +#define TCSADRAIN 1 +#endif +#ifndef TCSAFLUSH +#define TCSAFLUSH 2 +#endif +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios.h.html */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +speed_t cfgetispeed(const struct termios *); +speed_t cfgetospeed(const struct termios *); +int cfsetispeed(struct termios *, speed_t); +int cfsetospeed(struct termios *, speed_t); +int tcdrain(int); +int tcflow(int, int); +int tcflush(int, int); +int tcgetattr(int, struct termios *); +pid_t tcgetsid(int); +int tcsendbreak(int, int); +int tcsetattr(int, int, const struct termios *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TERMIOS_H */ diff --git a/libc_extension/include/sys/un.h b/libc_extension/include/sys/un.h new file mode 100644 index 0000000..b8ebb2a --- /dev/null +++ b/libc_extension/include/sys/un.h @@ -0,0 +1,20 @@ +#ifndef _SYS_UN_H +#define _SYS_UN_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct sockaddr_un { + sa_family_t sun_family; + /* https://man7.org/linux/man-pages/man7/unix.7.html */ + char sun_path[108]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UN_H */ diff --git a/libc_extension/include/sys/utsname_template.h b/libc_extension/include/sys/utsname_template.h new file mode 100644 index 0000000..802039a --- /dev/null +++ b/libc_extension/include/sys/utsname_template.h @@ -0,0 +1,25 @@ +#ifndef _SYS_UTSNAME_H +#define _SYS_UTSNAME_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://man7.org/linux/man-pages/man2/uname.2.html + * https://sources.debian.org/src/glibc/2.41-12/sysdeps/unix/sysv/linux/bits/utsname.h/ + */ +struct utsname { + char sysname[@UTSNAME_FIELD_SIZE@]; + char nodename[@UTSNAME_FIELD_SIZE@]; + char release[@UTSNAME_FIELD_SIZE@]; + char version[@UTSNAME_FIELD_SIZE@]; + char machine[@UTSNAME_FIELD_SIZE@]; +}; + +int uname(struct utsname *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_UTSNAME_H */ diff --git a/libc_extension/include/syslog.h b/libc_extension/include/syslog.h new file mode 100644 index 0000000..ddfe49e --- /dev/null +++ b/libc_extension/include/syslog.h @@ -0,0 +1,58 @@ +#ifndef _SYSLOG_H +#define _SYSLOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://codebrowser.dev/glibc/glibc/misc/sys/syslog.h.html */ +#define LOG_PID 0x01 +#define LOG_CONS 0x02 +#define LOG_ODELAY 0x04 +#define LOG_NDELAY 0x08 +#define LOG_NOWAIT 0x10 + +/* https://codebrowser.dev/glibc/glibc/misc/sys/syslog.h.html */ +#define LOG_KERN (0 << 3) +#define LOG_USER (1 << 3) +#define LOG_MAIL (2 << 3) +#define LOG_DAEMON (3 << 3) +#define LOG_AUTH (4 << 3) +#define LOG_SYSLOG (5 << 3) +#define LOG_LPR (6 << 3) +#define LOG_NEWS (7 << 3) +#define LOG_UUCP (8 << 3) +#define LOG_CRON (9 << 3) +#define LOG_AUTHPRIV (10 << 3) +#define LOG_FTP (11 << 3) +#define LOG_LOCAL0 (16 << 3) +#define LOG_LOCAL1 (17 << 3) +#define LOG_LOCAL2 (18 << 3) +#define LOG_LOCAL3 (19 << 3) +#define LOG_LOCAL4 (20 << 3) +#define LOG_LOCAL5 (21 << 3) +#define LOG_LOCAL6 (22 << 3) +#define LOG_LOCAL7 (23 << 3) + +/* https://codebrowser.dev/glibc/glibc/misc/sys/syslog.h.html */ +#define LOG_EMERG 0 +#define LOG_ALERT 1 +#define LOG_CRIT 2 +#define LOG_ERR 3 +#define LOG_WARNING 4 +#define LOG_NOTICE 5 +#define LOG_INFO 6 +#define LOG_DEBUG 7 + +#define LOG_MASK(pri) (1 << (pri)) + +void closelog(void); +void openlog(const char *, int, int); +int setlogmask(int); +void syslog(int, const char *, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSLOG_H */ diff --git a/libc_extension/include/utmpx.h b/libc_extension/include/utmpx.h new file mode 100644 index 0000000..7138e56 --- /dev/null +++ b/libc_extension/include/utmpx.h @@ -0,0 +1,45 @@ +#ifndef _UTMPX_H +#define _UTMPX_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* https://codebrowser.dev/glibc/glibc/sysdeps/gnu/bits/utmpx.h.html */ +#define __UT_LINESIZE 32 +#define __UT_NAMESIZE 32 + +struct utmpx { + short ut_type; + pid_t ut_pid; + char ut_line[__UT_LINESIZE]; + char ut_id[4]; + char ut_user[__UT_NAMESIZE]; + struct timeval ut_tv; +}; + +/* https://codebrowser.dev/glibc/glibc/sysdeps/gnu/bits/utmpx.h.html */ +#define EMPTY 0 +#define BOOT_TIME 2 +#define NEW_TIME 3 +#define OLD_TIME 4 +#define INIT_PROCESS 5 +#define LOGIN_PROCESS 6 +#define USER_PROCESS 7 +#define DEAD_PROCESS 8 + +void endutxent(void); +struct utmpx *getutxent(void); +struct utmpx *getutxid(const struct utmpx *); +struct utmpx *getutxline(const struct utmpx *); +struct utmpx *pututxline(const struct utmpx *); +void setutxent(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _UTMPX_H */ diff --git a/libc_extension/inet.c b/libc_extension/inet.c deleted file mode 100644 index 7346a14..0000000 --- a/libc_extension/inet.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -in_addr_t inet_addr (const char *__cp) { - return -1; -} -char *inet_ntoa (struct in_addr __in) { - return 0; -} -const char *inet_ntop (int __af, const void *restrict __cp, char *restrict __buf, socklen_t __len) { - return 0; -} -int inet_pton (int __af, const char *restrict __cp, void *restrict __buf) { - return -1; -} diff --git a/libc_extension/mman.c b/libc_extension/mman.c deleted file mode 100644 index eed4447..0000000 --- a/libc_extension/mman.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -int mlock (const void *__addr, size_t __len) { return -1; } -int mlockall (int __flags) { return -1; } -void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset) { - return 0; -} -int mprotect (void *__addr, size_t __len, int __prot) { return -1; } -int msync (void *__addr, size_t __len, int __flags) { return -1; } -int munlock (const void *__addr, size_t __len) { return -1; } -int munlockall (void) { return -1; } -int munmap (void *__addr, size_t __len) { return -1; } -int shm_open (const char *__name, int __oflag, mode_t __mode) { return -1; } -int shm_unlink (const char *__name) { return -1; } \ No newline at end of file diff --git a/libc_extension/mntent.c b/libc_extension/mntent.c new file mode 100644 index 0000000..6f399a5 --- /dev/null +++ b/libc_extension/mntent.c @@ -0,0 +1,45 @@ +#include +#include + +FILE *setmntent(const char *file, const char *mode) { + (void)file; + (void)mode; + errno = ENOSYS; + return 0; +} + +struct mntent *getmntent(FILE *stream) { + (void)stream; + errno = ENOSYS; + return 0; +} + +struct mntent *getmntent_r(FILE *stream, struct mntent *result, char *buffer, + int bufsize) { + (void)stream; + (void)result; + (void)buffer; + (void)bufsize; + errno = ENOSYS; + return 0; +} + +int addmntent(FILE *stream, const struct mntent *mnt) { + (void)stream; + (void)mnt; + errno = ENOSYS; + return 1; +} + +int endmntent(FILE *stream) { + (void)stream; + errno = ENOSYS; + return 0; +} + +char *hasmntopt(const struct mntent *mnt, const char *opt) { + (void)mnt; + (void)opt; + errno = ENOSYS; + return 0; +} diff --git a/libc_extension/monetary.c b/libc_extension/monetary.c new file mode 100644 index 0000000..c49828d --- /dev/null +++ b/libc_extension/monetary.c @@ -0,0 +1,20 @@ +#include +#include +// https://man7.org/linux/man-pages/man0/monetary.h.0p.html +ssize_t strfmon(char *restrict s, size_t max, const char *restrict format, ...) { + (void)s; + (void)max; + (void)format; + errno = ENOSYS; + return -1; +} + +ssize_t strfmon_l(char *restrict s, size_t max, locale_t loc, + const char *restrict format, ...) { + (void)s; + (void)max; + (void)loc; + (void)format; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/mqueue.c b/libc_extension/mqueue.c new file mode 100644 index 0000000..f58fb3e --- /dev/null +++ b/libc_extension/mqueue.c @@ -0,0 +1,92 @@ +#include +#include +#include + +int mq_close(mqd_t mqdes) { + (void)mqdes; + errno = ENOSYS; + return -1; +} + +int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat) { + (void)mqdes; + (void)mqstat; + errno = ENOSYS; + return -1; +} + +int mq_notify(mqd_t mqdes, const struct sigevent *notification) { + (void)mqdes; + (void)notification; + errno = ENOSYS; + return -1; +} + +mqd_t mq_open(const char *name, int oflag, ...) { + va_list ap; + + (void)name; + (void)oflag; + va_start(ap, oflag); + va_end(ap); + errno = ENOSYS; + return (mqd_t)-1; +} + +ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, + unsigned *msg_prio) { + (void)mqdes; + (void)msg_ptr; + (void)msg_len; + (void)msg_prio; + errno = ENOSYS; + return -1; +} + +int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, + unsigned msg_prio) { + (void)mqdes; + (void)msg_ptr; + (void)msg_len; + (void)msg_prio; + errno = ENOSYS; + return -1; +} + +int mq_setattr(mqd_t mqdes, const struct mq_attr *restrict mqstat, + struct mq_attr *restrict omqstat) { + (void)mqdes; + (void)mqstat; + (void)omqstat; + errno = ENOSYS; + return -1; +} + +ssize_t mq_timedreceive(mqd_t mqdes, char *restrict msg_ptr, size_t msg_len, + unsigned *restrict msg_prio, + const struct timespec *restrict abs_timeout) { + (void)mqdes; + (void)msg_ptr; + (void)msg_len; + (void)msg_prio; + (void)abs_timeout; + errno = ENOSYS; + return -1; +} + +int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, + unsigned msg_prio, const struct timespec *abs_timeout) { + (void)mqdes; + (void)msg_ptr; + (void)msg_len; + (void)msg_prio; + (void)abs_timeout; + errno = ENOSYS; + return -1; +} + +int mq_unlink(const char *name) { + (void)name; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/net_if.c b/libc_extension/net_if.c new file mode 100644 index 0000000..b05dc5e --- /dev/null +++ b/libc_extension/net_if.c @@ -0,0 +1,25 @@ +#include +#include + +void if_freenameindex(struct if_nameindex *ptr) { + (void)ptr; + errno = ENOSYS; +} + +char *if_indextoname(unsigned ifindex, char *ifname) { + (void)ifindex; + (void)ifname; + errno = ENOSYS; + return 0; +} + +struct if_nameindex *if_nameindex(void) { + errno = ENOSYS; + return 0; +} + +unsigned if_nametoindex(const char *ifname) { + (void)ifname; + errno = ENOSYS; + return 0; +} diff --git a/libc_extension/netdb.c b/libc_extension/netdb.c index e697b0e..a86c1de 100644 --- a/libc_extension/netdb.c +++ b/libc_extension/netdb.c @@ -1,4 +1,7 @@ #include +#include + +int h_errno; void endhostent (void) {} @@ -9,50 +12,75 @@ void endprotoent (void) {} void endservent (void) {} struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len, int __type) { + (void)__addr; + (void)__len; + (void)__type; + errno = ENOSYS; return 0; } struct hostent *gethostbyname (const char *__name) { + (void)__name; + errno = ENOSYS; return 0; } struct hostent *gethostent (void) { + errno = ENOSYS; return 0; } struct netent *getnetbyaddr (uint32_t __net, int __type) { + (void)__net; + (void)__type; + errno = ENOSYS; return 0; } struct netent *getnetbyname (const char *__name) { + (void)__name; + errno = ENOSYS; return 0; } struct netent *getnetent (void) { + errno = ENOSYS; return 0; } struct protoent *getprotobyname (const char *__name) { + (void)__name; + errno = ENOSYS; return 0; } struct protoent *getprotobynumber (int __proto) { + (void)__proto; + errno = ENOSYS; return 0; } struct protoent *getprotoent (void) { + errno = ENOSYS; return 0; } struct servent *getservbyname (const char *__name, const char *__proto) { + (void)__name; + (void)__proto; + errno = ENOSYS; return 0; } struct servent *getservbyport (int __port, const char *__proto) { + (void)__port; + (void)__proto; + errno = ENOSYS; return 0; } struct servent *getservent (void) { + errno = ENOSYS; return 0; } @@ -64,3 +92,39 @@ void setprotoent (int __stay_open) {} void setservent (int __stay_open) {} +void freeaddrinfo(struct addrinfo *__ai) { + (void)__ai; +} + +int getaddrinfo(const char *__restrict __name, + const char *__restrict __service, + const struct addrinfo *__restrict __req, + struct addrinfo **__restrict __pai) { + (void)__name; + (void)__service; + (void)__req; + (void)__pai; + errno = ENOSYS; + return EAI_SYSTEM; +} + +int getnameinfo(const struct sockaddr *__restrict __sa, + socklen_t __salen, + char *__restrict __host, socklen_t __hostlen, + char *__restrict __serv, socklen_t __servlen, + int __flags) { + (void)__sa; + (void)__salen; + (void)__host; + (void)__hostlen; + (void)__serv; + (void)__servlen; + (void)__flags; + errno = ENOSYS; + return EAI_SYSTEM; +} + +const char *gai_strerror(int __ecode) { + (void)__ecode; + return "address resolution is not supported"; +} diff --git a/libc_extension/netinet_in.c b/libc_extension/netinet_in.c new file mode 100644 index 0000000..3ef7387 --- /dev/null +++ b/libc_extension/netinet_in.c @@ -0,0 +1,4 @@ +#include + +const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; diff --git a/libc_extension/nl_types.c b/libc_extension/nl_types.c new file mode 100644 index 0000000..c967065 --- /dev/null +++ b/libc_extension/nl_types.c @@ -0,0 +1,23 @@ +#include +#include + +int catclose(nl_catd catd) { + (void)catd; + errno = ENOSYS; + return -1; +} + +char *catgets(nl_catd catd, int set_id, int msg_id, const char *s) { + (void)catd; + (void)set_id; + (void)msg_id; + errno = ENOSYS; + return (char *)s; +} + +nl_catd catopen(const char *name, int oflag) { + (void)name; + (void)oflag; + errno = ENOSYS; + return (nl_catd)-1; +} diff --git a/libc_extension/poll.c b/libc_extension/poll.c new file mode 100644 index 0000000..422f0aa --- /dev/null +++ b/libc_extension/poll.c @@ -0,0 +1,10 @@ +#include +#include + +int poll(struct pollfd *fds, nfds_t nfds, int timeout) { + (void)fds; + (void)nfds; + (void)timeout; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/pthread.c b/libc_extension/pthread.c index 8751e88..041566f 100644 --- a/libc_extension/pthread.c +++ b/libc_extension/pthread.c @@ -1,3 +1,8 @@ #include +#include -int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) { return -1; } +int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) { + (void)__rwlock; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/resolv.c b/libc_extension/resolv.c new file mode 100644 index 0000000..c99b3be --- /dev/null +++ b/libc_extension/resolv.c @@ -0,0 +1,13 @@ +#include +#include + +int dn_expand(const unsigned char *msg, const unsigned char *eomorig, + const unsigned char *comp_dn, char *exp_dn, int length) { + (void)msg; + (void)eomorig; + (void)comp_dn; + (void)exp_dn; + (void)length; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/sched.c b/libc_extension/sched.c index bf5749b..d511db8 100644 --- a/libc_extension/sched.c +++ b/libc_extension/sched.c @@ -1,5 +1,12 @@ #include #include -int sched_yield (void) { return -1; } -int sched_getcpu(void) { return ENOTSUP; } +int sched_yield (void) { + errno = ENOSYS; + return -1; +} + +int sched_getcpu(void) { + errno = ENOTSUP; + return -1; +} diff --git a/libc_extension/semaphore.c b/libc_extension/semaphore.c index a6eb07c..7b9641a 100644 --- a/libc_extension/semaphore.c +++ b/libc_extension/semaphore.c @@ -1,12 +1,73 @@ +#include #include +#include -int sem_close (sem_t *__sem) { return -1; } -int sem_destroy (sem_t *__sem) { return -1; } -int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval) { return -1; } -int sem_init (sem_t *__sem, int __pshared, unsigned int __value) { return -1; } -sem_t *sem_open (const char *__name, int __oflag, ...) { return 0; } -int sem_post (sem_t *__sem) { return -1; } -int sem_timedwait (sem_t *__restrict __sem, const struct timespec *__restrict __abstime) { return -1; } -int sem_trywait (sem_t *__sem) { return -1; } -int sem_unlink (const char *__name) { return -1; } -int sem_wait (sem_t *__sem) { return -1; } +int sem_close(sem_t *sem) { + (void)sem; + errno = ENOSYS; + return -1; +} + +int sem_destroy(sem_t *sem) { + (void)sem; + errno = ENOSYS; + return -1; +} + +int sem_getvalue(sem_t *restrict sem, int *restrict sval) { + (void)sem; + (void)sval; + errno = ENOSYS; + return -1; +} + +int sem_init(sem_t *sem, int pshared, unsigned value) { + (void)sem; + (void)pshared; + (void)value; + errno = ENOSYS; + return -1; +} + +sem_t *sem_open(const char *name, int oflag, ...) { + va_list ap; + + (void)name; + (void)oflag; + va_start(ap, oflag); + va_end(ap); + errno = ENOSYS; + return SEM_FAILED; +} + +int sem_post(sem_t *sem) { + (void)sem; + errno = ENOSYS; + return -1; +} + +int sem_timedwait(sem_t *restrict sem, + const struct timespec *restrict abs_timeout) { + (void)sem; + (void)abs_timeout; + errno = ENOSYS; + return -1; +} + +int sem_trywait(sem_t *sem) { + (void)sem; + errno = ENOSYS; + return -1; +} + +int sem_unlink(const char *name) { + (void)name; + errno = ENOSYS; + return -1; +} + +int sem_wait(sem_t *sem) { + (void)sem; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/socket.c b/libc_extension/socket.c index 7d24a11..d87c676 100644 --- a/libc_extension/socket.c +++ b/libc_extension/socket.c @@ -1,73 +1,110 @@ #include +#include int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len) { + (void)__fd; (void)__addr; (void)__addr_len; + errno = ENOSYS; return -1; } int bind (int __fd, const struct sockaddr *__addr, socklen_t __len) { + (void)__fd; (void)__addr; (void)__len; + errno = ENOSYS; return -1; } int connect (int __fd, const struct sockaddr *__addr, socklen_t __len) { + (void)__fd; (void)__addr; (void)__len; + errno = ENOSYS; return -1; } -int getpeername (int __fd, struct sockaddr __addr, socklen_t *__len) { +int getpeername (int __fd, struct sockaddr *__addr, socklen_t *__len) { + (void)__fd; (void)__addr; (void)__len; + errno = ENOSYS; return -1; } -int getsockname (int __fd, struct sockaddr __addr, socklen_t *__len) { +int getsockname (int __fd, struct sockaddr *__addr, socklen_t *__len) { + (void)__fd; (void)__addr; (void)__len; + errno = ENOSYS; return -1; } int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen) { + (void)__fd; (void)__level; (void)__optname; (void)__optval; (void)__optlen; + errno = ENOSYS; return -1; } int listen (int __fd, int __n) { + (void)__fd; (void)__n; + errno = ENOSYS; return -1; } ssize_t recv (int __fd, void *__buf, size_t __n, int __flags) { + (void)__fd; (void)__buf; (void)__n; (void)__flags; + errno = ENOSYS; return -1; } -ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr __addr, socklen_t *__addr_len) { +ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr *__addr, socklen_t *__addr_len) { + (void)__fd; (void)__buf; (void)__n; (void)__flags; (void)__addr; (void)__addr_len; + errno = ENOSYS; return -1; } ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags) { + (void)__fd; (void)__message; (void)__flags; + errno = ENOSYS; return -1; } ssize_t send (int __fd, const void *__buf, size_t __n, int __flags) { + (void)__fd; (void)__buf; (void)__n; (void)__flags; + errno = ENOSYS; return -1; } ssize_t sendmsg (int __fd, const struct msghdr *__message, int __flags) { + (void)__fd; (void)__message; (void)__flags; + errno = ENOSYS; return -1; } ssize_t sendto (int __fd, const void *__buf, size_t __n, int __flags, const struct sockaddr *__addr, socklen_t __addr_len) { + (void)__fd; (void)__buf; (void)__n; (void)__flags; (void)__addr; (void)__addr_len; + errno = ENOSYS; return -1; } int setsockopt (int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen) { + (void)__fd; (void)__level; (void)__optname; (void)__optval; (void)__optlen; + errno = ENOSYS; return -1; } int shutdown (int __fd, int __how) { + (void)__fd; (void)__how; + errno = ENOSYS; return -1; } int socket (int __domain, int __type, int __protocol) { + (void)__domain; (void)__type; (void)__protocol; + errno = ENOSYS; return -1; } int sockatmark (int __fd) { + (void)__fd; + errno = ENOSYS; return -1; } int socketpair (int __domain, int __type, int __protocol, int __fds[2]) { + (void)__domain; (void)__type; (void)__protocol; (void)__fds; + errno = ENOSYS; return -1; } diff --git a/libc_extension/sys_ipc.c b/libc_extension/sys_ipc.c new file mode 100644 index 0000000..e8828a0 --- /dev/null +++ b/libc_extension/sys_ipc.c @@ -0,0 +1,9 @@ +#include +#include + +key_t ftok(const char *path, int id) { + (void)path; + (void)id; + errno = ENOSYS; + return (key_t)-1; +} diff --git a/libc_extension/sys_mman.c b/libc_extension/sys_mman.c new file mode 100644 index 0000000..3cec4ea --- /dev/null +++ b/libc_extension/sys_mman.c @@ -0,0 +1,83 @@ +#include +#include + +void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { + (void)addr; + (void)length; + (void)prot; + (void)flags; + (void)fd; + (void)offset; + errno = ENOSYS; + return MAP_FAILED; +} + +int mprotect(void *addr, size_t len, int prot) { + (void)addr; + (void)len; + (void)prot; + errno = ENOSYS; + return -1; +} + +int msync(void *addr, size_t len, int flags) { + (void)addr; + (void)len; + (void)flags; + errno = ENOSYS; + return -1; +} + +int munmap(void *addr, size_t len) { + (void)addr; + (void)len; + errno = ENOSYS; + return -1; +} + +int mlock(const void *addr, size_t len) { + (void)addr; + (void)len; + errno = ENOSYS; + return -1; +} + +int mlockall(int flags) { + (void)flags; + errno = ENOSYS; + return -1; +} + +int munlock(const void *addr, size_t len) { + (void)addr; + (void)len; + errno = ENOSYS; + return -1; +} + +int munlockall(void) { + errno = ENOSYS; + return -1; +} + +int posix_madvise(void *addr, size_t len, int advice) { + (void)addr; + (void)len; + (void)advice; + errno = ENOSYS; + return -1; +} + +int shm_open(const char *name, int oflag, mode_t mode) { + (void)name; + (void)oflag; + (void)mode; + errno = ENOSYS; + return -1; +} + +int shm_unlink(const char *name) { + (void)name; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/sys_msg.c b/libc_extension/sys_msg.c new file mode 100644 index 0000000..4be0015 --- /dev/null +++ b/libc_extension/sys_msg.c @@ -0,0 +1,36 @@ +#include +#include + +int msgctl(int msqid, int cmd, struct msqid_ds *buf) { + (void)msqid; + (void)cmd; + (void)buf; + errno = ENOSYS; + return -1; +} + +int msgget(key_t key, int msgflg) { + (void)key; + (void)msgflg; + errno = ENOSYS; + return -1; +} + +ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) { + (void)msqid; + (void)msgp; + (void)msgsz; + (void)msgtyp; + (void)msgflg; + errno = ENOSYS; + return -1; +} + +int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) { + (void)msqid; + (void)msgp; + (void)msgsz; + (void)msgflg; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/sys_sem.c b/libc_extension/sys_sem.c new file mode 100644 index 0000000..a204b0e --- /dev/null +++ b/libc_extension/sys_sem.c @@ -0,0 +1,31 @@ +#include +#include +#include + +int semctl(int semid, int semnum, int cmd, ...) { + va_list ap; + + (void)semid; + (void)semnum; + (void)cmd; + va_start(ap, cmd); + va_end(ap); + errno = ENOSYS; + return -1; +} + +int semget(key_t key, int nsems, int semflg) { + (void)key; + (void)nsems; + (void)semflg; + errno = ENOSYS; + return -1; +} + +int semop(int semid, struct sembuf *sops, size_t nsops) { + (void)semid; + (void)sops; + (void)nsops; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/sys_shm.c b/libc_extension/sys_shm.c new file mode 100644 index 0000000..3c0ea71 --- /dev/null +++ b/libc_extension/sys_shm.c @@ -0,0 +1,32 @@ +#include +#include + +void *shmat(int shmid, const void *shmaddr, int shmflg) { + (void)shmid; + (void)shmaddr; + (void)shmflg; + errno = ENOSYS; + return (void *)-1; +} + +int shmctl(int shmid, int cmd, struct shmid_ds *buf) { + (void)shmid; + (void)cmd; + (void)buf; + errno = ENOSYS; + return -1; +} + +int shmdt(const void *shmaddr) { + (void)shmaddr; + errno = ENOSYS; + return -1; +} + +int shmget(key_t key, size_t size, int shmflg) { + (void)key; + (void)size; + (void)shmflg; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/sys_syscall.c b/libc_extension/sys_syscall.c new file mode 100644 index 0000000..8bdd226 --- /dev/null +++ b/libc_extension/sys_syscall.c @@ -0,0 +1,7 @@ +#include + +long syscall(long number, ...) { + (void)number; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/sys_termios.c b/libc_extension/sys_termios.c new file mode 100644 index 0000000..44fddf3 --- /dev/null +++ b/libc_extension/sys_termios.c @@ -0,0 +1,76 @@ +#include +#include + +speed_t cfgetispeed(const struct termios *termios_p) { + (void)termios_p; + errno = ENOSYS; + return 0; +} + +speed_t cfgetospeed(const struct termios *termios_p) { + (void)termios_p; + errno = ENOSYS; + return 0; +} + +int cfsetispeed(struct termios *termios_p, speed_t speed) { + (void)termios_p; + (void)speed; + errno = ENOSYS; + return -1; +} + +int cfsetospeed(struct termios *termios_p, speed_t speed) { + (void)termios_p; + (void)speed; + errno = ENOSYS; + return -1; +} + +int tcdrain(int fd) { + (void)fd; + errno = ENOSYS; + return -1; +} + +int tcflow(int fd, int action) { + (void)fd; + (void)action; + errno = ENOSYS; + return -1; +} + +int tcflush(int fd, int queue_selector) { + (void)fd; + (void)queue_selector; + errno = ENOSYS; + return -1; +} + +int tcgetattr(int fd, struct termios *termios_p) { + (void)fd; + (void)termios_p; + errno = ENOSYS; + return -1; +} + +pid_t tcgetsid(int fd) { + (void)fd; + errno = ENOSYS; + return (pid_t)-1; +} + +int tcsendbreak(int fd, int duration) { + (void)fd; + (void)duration; + errno = ENOSYS; + return -1; +} + +int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) { + (void)fd; + (void)optional_actions; + (void)termios_p; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/sys_utsname.c b/libc_extension/sys_utsname.c new file mode 100644 index 0000000..9b23945 --- /dev/null +++ b/libc_extension/sys_utsname.c @@ -0,0 +1,8 @@ +#include +#include + +int uname(struct utsname *buf) { + (void)buf; + errno = ENOSYS; + return -1; +} diff --git a/libc_extension/syslog.c b/libc_extension/syslog.c new file mode 100644 index 0000000..5dc80eb --- /dev/null +++ b/libc_extension/syslog.c @@ -0,0 +1,25 @@ +#include +#include + +void closelog(void) { + errno = ENOSYS; +} + +void openlog(const char *ident, int option, int facility) { + (void)ident; + (void)option; + (void)facility; + errno = ENOSYS; +} + +int setlogmask(int maskpri) { + (void)maskpri; + errno = ENOSYS; + return 0; +} + +void syslog(int priority, const char *format, ...) { + (void)priority; + (void)format; + errno = ENOSYS; +} diff --git a/libc_extension/uio.c b/libc_extension/uio.c index 590faa1..8dec4a8 100644 --- a/libc_extension/uio.c +++ b/libc_extension/uio.c @@ -1,9 +1,18 @@ #include +#include ssize_t readv (int __fd, const struct iovec *__iovec, int __count) { + (void)__fd; + (void)__iovec; + (void)__count; + errno = ENOSYS; return -1; } ssize_t writev (int __fd, const struct iovec *__iovec, int __count) { + (void)__fd; + (void)__iovec; + (void)__count; + errno = ENOSYS; return -1; } diff --git a/libc_extension/utmpx.c b/libc_extension/utmpx.c new file mode 100644 index 0000000..b77fc73 --- /dev/null +++ b/libc_extension/utmpx.c @@ -0,0 +1,29 @@ +#include +#include + +void endutxent(void) { errno = ENOSYS; } + +struct utmpx *getutxent(void) { + errno = ENOSYS; + return 0; +} + +struct utmpx *getutxid(const struct utmpx *id) { + (void)id; + errno = ENOSYS; + return 0; +} + +struct utmpx *getutxline(const struct utmpx *line) { + (void)line; + errno = ENOSYS; + return 0; +} + +struct utmpx *pututxline(const struct utmpx *utmpx) { + (void)utmpx; + errno = ENOSYS; + return 0; +} + +void setutxent(void) { errno = ENOSYS; } diff --git a/libc_test/.dockerignore b/libc_test/.dockerignore new file mode 100644 index 0000000..c873007 --- /dev/null +++ b/libc_test/.dockerignore @@ -0,0 +1,5 @@ +upstream/ +logs/ +report/ +input_sets/ +output_sets/ diff --git a/libc_test/.gitignore b/libc_test/.gitignore new file mode 100644 index 0000000..a466d4c --- /dev/null +++ b/libc_test/.gitignore @@ -0,0 +1,5 @@ +logs/ +report/ +input_sets/ +output_sets/ +.DS_Store diff --git a/libc_test/README b/libc_test/README new file mode 100644 index 0000000..03b4dc4 --- /dev/null +++ b/libc_test/README @@ -0,0 +1,19 @@ +libc-test support files for dandelionSDK +======================================= + +This directory contains the tracked support files for the libc-test workflow: + +- `libc-test.patch`: local patch applied to the generated upstream checkout +- `config.mak.dlibc`: dandelion-specific libc-test configuration +- `run_test_dlibc.py`: runtime helper used instead of the upstream C runtest +- `gen_csv.py`: CSV summary generator for test results +- `scripts/analyze_results.ipynb`: result analysis notebook +- `scripts/stub_inventory/*.csv`: known stub inventory inputs for analysis + +Generated logs and reports are written under: + +- `logs/` +- `report/` + +The development and test workflow is documented in +[`dev/README`](../dev/README). diff --git a/libc_test/config.mak.dlibc b/libc_test/config.mak.dlibc new file mode 100644 index 0000000..5f34c8e --- /dev/null +++ b/libc_test/config.mak.dlibc @@ -0,0 +1,16 @@ +CFLAGS += -pipe -std=c99 -Wall -Wno-unused-function -Wno-missing-braces -Wno-unused -Wno-overflow +CFLAGS += -Wno-unknown-pragmas +CFLAGS += -Wno-implicit-function-declaration -Wno-implicit-int -Wno-pointer-sign -Wno-pointer-arith +CFLAGS += -Wno-strict-prototypes +CFLAGS += -g +LDFLAGS += -g +LDLIBS += -lpthread -lm -lrt + +CFLAGS += -D_FILE_OFFSET_BITS=64 +LDLIBS += -lcrypt -ldl -lresolv -lutil -lpthread + + +# Use a Python-based test runner instead of the C runtest (which needs +# fork/exec). The runner handles timeouts, per-test working dirs, and failure +# reporting. +RUN_TEST = python3 ./run_test_dlibc.py diff --git a/libc_test/gen_csv.py b/libc_test/gen_csv.py new file mode 100644 index 0000000..187c23f --- /dev/null +++ b/libc_test/gen_csv.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python3 +"""Generate a detailed test results CSV. + +Usage: + gen_csv.py [build_dir] + +Output columns: + test,result,failure_stage,evidence_file +""" + +from __future__ import annotations + +import csv +import os +import sys +from pathlib import Path + + +RUNTIME_EXCLUDED_SUFFIXES = (".o.err", ".lo.err", ".ld.err", ".so.err") +BUILD_SUFFIXES = (".o.err", ".lo.err", ".ld.err", ".so.err") +STAGE_INFO = { + ".ld.err": ("link", 4), + ".so.err": ("shared_link", 3), + ".o.err": ("compile", 2), + ".lo.err": ("shared_compile", 1), +} + + +def path_has_common(path: str) -> bool: + return "common" in Path(path).parts + + +def iter_matching_files(build_dir: str, suffixes: tuple[str, ...]) -> list[str]: + matches: list[str] = [] + for root, _, files in os.walk(build_dir): + for filename in files: + full_path = os.path.join(root, filename) + # exlucde common directory as it contains no tests + if path_has_common(full_path): + continue + # check for suffixes of selected build stages + if filename.endswith(suffixes): + matches.append(full_path) + matches.sort() + return matches + + +def artifact_exists(err_path: str) -> bool: + if err_path.endswith(".ld.err"): + return os.path.exists(err_path[: -len(".ld.err")] + ".exe") + if err_path.endswith(".so.err"): + return os.path.exists(err_path[: -len(".so.err")] + ".so") + if err_path.endswith(".o.err"): + return os.path.exists(err_path[: -len(".o.err")] + ".o") + if err_path.endswith(".lo.err"): + return os.path.exists(err_path[: -len(".lo.err")] + ".lo") + return False + + +def contains_fail_line(path: str) -> bool: + with open(path, "r", encoding="utf-8", errors="replace") as handle: + return any(line.startswith("FAIL ") for line in handle) + + +def relative_test_name(path: str, build_dir: str, suffix: str) -> str: + without_suffix = path[: -len(suffix)] + return os.path.relpath(without_suffix, build_dir) + + +def collect_runtime_rows(build_dir: str) -> tuple[set[str], list[tuple[str, str, str, str]]]: + ran_tests: set[str] = set() + rows: list[tuple[str, str, str, str]] = [] + + for err_path in iter_matching_files(build_dir, (".err",)): + if err_path.endswith(RUNTIME_EXCLUDED_SUFFIXES): + continue + + name = relative_test_name(err_path, build_dir, ".err") + ran_tests.add(name) + + if contains_fail_line(err_path): + rows.append((name, "FAIL", "runtime", err_path)) + else: + rows.append((name, "PASS", "pass", err_path)) + + return ran_tests, rows + + +def collect_build_rows(build_dir: str, ran_tests: set[str]) -> list[tuple[str, str, str, str]]: + best_by_test: dict[str, tuple[int, str, str]] = {} + + for err_path in iter_matching_files(build_dir, BUILD_SUFFIXES): + if os.path.getsize(err_path) == 0: + continue + if artifact_exists(err_path): + continue + + suffix = next((item for item in BUILD_SUFFIXES if err_path.endswith(item)), None) + if suffix is None: + continue + + name = relative_test_name(err_path, build_dir, suffix) + if name in ran_tests: + continue + + stage, priority = STAGE_INFO[suffix] + current = best_by_test.get(name) + if current is None or priority > current[0]: + best_by_test[name] = (priority, stage, err_path) + + rows = [ + (name, "FAIL", stage, evidence) + for name, (_, stage, evidence) in best_by_test.items() + ] + return rows + + +def main(argv: list[str]) -> int: + # set build directory or default to src + build_dir = argv[1] if len(argv) > 1 else "src" + + runtime_tests, rows = collect_runtime_rows(build_dir) + rows.extend(collect_build_rows(build_dir, runtime_tests)) + rows.sort(key=lambda row: row[0]) + + writer = csv.writer(sys.stdout, lineterminator="\n") + writer.writerow(("test", "result", "failure_stage", "evidence_file")) + writer.writerows(rows) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv)) diff --git a/libc_test/libc-test.patch b/libc_test/libc-test.patch new file mode 100644 index 0000000..29741f5 --- /dev/null +++ b/libc_test/libc-test.patch @@ -0,0 +1,270 @@ +diff --git a/.gitignore b/.gitignore +index 14d4095..c751a30 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -1,7 +1,12 @@ + *.err ++*.lo ++*.pyc + *.o + *.so + *.a + *.exe + config.mak + REPORT ++.dlibc-dev/ ++logs/ ++.DS_Store +\ No newline at end of file +diff --git a/Makefile b/Makefile +index cf2ab2b..b87ed97 100644 +--- a/Makefile ++++ b/Makefile +@@ -42,6 +42,7 @@ define default_template + $(1).BINS_TEMPL:=bin.exe bin-static.exe + $(1).NAMES:=$$(filter $(1)/%,$$(NAMES)) + $(1).OBJS:=$$($(1).NAMES:%=$(B)/%.o) ++$(1).LOBJS:=$$($(1).NAMES:%=$(B)/%.lo) + endef + $(foreach d,$(DIRS),$(eval $(call default_template,$(d)))) + common.BINS_TEMPL:= +@@ -93,10 +94,16 @@ $(B)/common/libtest.a: $(common.OBJS) + $(AR) rc $@ $^ + $(RANLIB) $@ + ++$(B)/common/libtest_pic.a: $(common.LOBJS) ++ rm -f $@ ++ $(AR) rc $@ $^ ++ $(RANLIB) $@ ++ + $(B)/common/all: $(B)/common/runtest.exe + + $(ERRS): $(B)/common/runtest.exe | $(BDIRS) +-$(BINS) $(LIBS): $(B)/common/libtest.a ++$(BINS) $(filter %.exe,$(LIBS)): $(B)/common/libtest.a ++$(filter %.so,$(LIBS)): $(B)/common/libtest_pic.a + $(OBJS): src/common/test.h | $(BDIRS) + $(BDIRS): + mkdir -p $@ +@@ -115,12 +122,12 @@ $(math.OBJS): src/common/mtest.h + $(B)/api/main.exe: $(api.OBJS) + api/main.OBJS:=$(api.OBJS) + $(api.OBJS):$(B)/common/options.h +-$(api.OBJS):CFLAGS+=-pedantic-errors -Werror -Wno-unused -D_XOPEN_SOURCE=700 ++$(api.OBJS):CFLAGS+=-pedantic-errors -Wno-unused -D_XOPEN_SOURCE=700 + + all run: $(B)/REPORT + grep FAIL $< || echo PASS + clean: +- rm -f $(OBJS) $(BINS) $(LIBS) $(B)/common/libtest.a $(B)/common/runtest.exe $(B)/common/options.h $(B)/*/*.err ++ rm -f $(OBJS) $(LOBJS) $(BINS) $(LIBS) $(B)/common/libtest.a $(B)/common/libtest_pic.a $(B)/common/runtest.exe $(B)/common/options.h $(B)/*/*.err + cleanall: clean + rm -f $(B)/REPORT $(B)/*/REPORT + $(B)/REPORT: +@@ -133,7 +140,7 @@ $(B)/%.s:: src/%.c + $(B)/%.lo:: src/%.c + $(CC) $(CFLAGS) $($*.CFLAGS) -fPIC -DSHARED -c -o $@ $< 2>$@.err || echo BUILDERROR $@; cat $@.err + $(B)/%.so: $(B)/%.lo +- $(CC) -shared $(LDFLAGS) $($*.so.LDFLAGS) -o $@ $(sort $< $($*.so.LOBJS)) $(LDLIBS) $($*.so.LDLIBS) 2>$@.err || echo BUILDERROR $@; cat $@.err ++ $(CC) -shared $(LDFLAGS) $($*.so.LDFLAGS) -o $@ $(sort $< $($*.so.LOBJS)) $(B)/common/libtest_pic.a $($*.so.LDLIBS) 2>$@.err || echo BUILDERROR $@; cat $@.err + $(B)/%-static.exe: $(B)/%.o + $(CC) -static $(LDFLAGS) $($*-static.LDFLAGS) -o $@ $(sort $< $($*-static.OBJS)) $(LDLIBS) $($*-static.LDLIBS) 2>$@.ld.err || echo BUILDERROR $@; cat $@.ld.err + $(B)/%.exe: $(B)/%.o +@@ -148,7 +155,6 @@ $(B)/%.exe: $(B)/%.o + %.ld.err: %.exe + touch $@ + %.err: %.exe +- $(RUN_TEST) $< >$@ || true ++ $(RUN_TEST) $< >$@ 2>&1 || true + + .PHONY: all run clean cleanall +- +diff --git a/src/api/pthread.c b/src/api/pthread.c +index db772bb..7de2554 100644 +--- a/src/api/pthread.c ++++ b/src/api/pthread.c +@@ -30,7 +30,8 @@ C(PTHREAD_MUTEX_NORMAL) + C(PTHREAD_MUTEX_RECURSIVE) + C(PTHREAD_MUTEX_ROBUST) + C(PTHREAD_MUTEX_STALLED) +-C(PTHREAD_ONCE_INIT) ++// Relacement for: C(PTHREAD_ONCE_INIT) was too strict, definition only expects value to exist, but no to be an integer expression ++{pthread_once_t x = PTHREAD_ONCE_INIT;} + #if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) + C(PTHREAD_PRIO_INHERIT) + #endif +diff --git a/src/api/stddef.c b/src/api/stddef.c +index 3f7664e..5741918 100644 +--- a/src/api/stddef.c ++++ b/src/api/stddef.c +@@ -4,7 +4,9 @@ + static void f() + { + {void *p=NULL;} +-C(offsetof(struct{int i;}, i)) ++// fix c99 compatibility issue with offsetof ++struct off_s { int i; }; ++C(offsetof(struct off_s, i)) + T(ptrdiff_t) + T(wchar_t) + T(size_t) +diff --git a/src/common/runtest.c b/src/common/runtest.c +index ea0c1a8..77134cc 100644 +--- a/src/common/runtest.c ++++ b/src/common/runtest.c +@@ -1,100 +1,13 @@ +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include ++/* ++ * dlibc stub: the real runtest uses fork/exec/waitpid which dlibc ++ * does not support. This placeholder compiles and links but is never ++ * actually invoked — RUN_TEST is overridden in config.mak.dlibc to ++ * use a Python-based runner instead. ++ */ + #include "test.h" + +-static void handler(int s) +-{ +-} +- +-static int start(char *wrap, char *argv[]) +-{ +- int pid; +- +- pid = fork(); +- if (pid == 0) { +- t_setrlim(RLIMIT_STACK, 100*1024); +- if (*wrap) { +- argv--; +- argv[0] = wrap; +- } +- execv(argv[0], argv); +- t_error("%s exec failed: %s\n", argv[0], strerror(errno)); +- exit(1); +- } +- return pid; +-} +- +-static void usage(char *argv[]) +-{ +- t_error("usage: %s [-t timeoutsec] [-w wrapcmd] cmd [args..]\n", argv[0]); +- exit(-1); +-} +- + int main(int argc, char *argv[]) + { +- char *wrap = ""; +- int timeoutsec = 5; +- int timeout = 0; +- int status; +- sigset_t set; +- int opt; +- int pid; +- +- while ((opt = getopt(argc, argv, "w:t:")) != -1) { +- switch (opt) { +- case 'w': +- wrap = optarg; +- break; +- case 't': +- timeoutsec = atoi(optarg); +- break; +- default: +- usage(argv); +- } +- } +- if (optind >= argc) +- usage(argv); +- argv += optind; +- sigemptyset(&set); +- sigaddset(&set, SIGCHLD); +- sigprocmask(SIG_BLOCK, &set, 0); +- signal(SIGCHLD, handler); +- pid = start(wrap, argv); +- if (pid == -1) { +- t_error("%s fork failed: %s\n", argv[0], strerror(errno)); +- t_printf("FAIL %s [internal]\n", argv[0]); +- return -1; +- } +- if (sigtimedwait(&set, 0, &(struct timespec){timeoutsec,0}) == -1) { +- if (errno == EAGAIN) +- timeout = 1; +- else +- t_error("%s sigtimedwait failed: %s\n", argv[0], strerror(errno)); +- if (kill(pid, SIGKILL) == -1) +- t_error("%s kill failed: %s\n", argv[0], strerror(errno)); +- } +- if (waitpid(pid, &status, 0) != pid) { +- t_error("%s waitpid failed: %s\n", argv[0], strerror(errno)); +- t_printf("FAIL %s [internal]\n", argv[0]); +- return -1; +- } +- if (WIFEXITED(status)) { +- if (WEXITSTATUS(status) == 0) +- return t_status; +- t_printf("FAIL %s [status %d]\n", argv[0], WEXITSTATUS(status)); +- } else if (timeout) { +- t_printf("FAIL %s [timed out]\n", argv[0]); +- } else if (WIFSIGNALED(status)) { +- t_printf("FAIL %s [signal %s]\n", argv[0], strsignal(WTERMSIG(status))); +- } else +- t_printf("FAIL %s [unknown]\n", argv[0]); ++ t_error("runtest: not usable under dlibc, use python3 ./run_test_dlibc.py\n"); + return 1; + } +diff --git a/src/common/setrlim.c b/src/common/setrlim.c +index cc89f61..903a0a5 100644 +--- a/src/common/setrlim.c ++++ b/src/common/setrlim.c +@@ -23,4 +23,3 @@ int t_setrlim(int r, long lim) + } + return 0; + } +- +diff --git a/src/functional/env.c b/src/functional/env.c +index cf86439..372a557 100644 +--- a/src/functional/env.c ++++ b/src/functional/env.c +@@ -17,7 +17,7 @@ int main() + if (!environ) + t_error("environ is NULL\n"); + if (clearenv() || (environ && *environ)) +- t_error("clrearenv: %s\n", strerror(errno)); ++ t_error("clearenv: %s\n", strerror(errno)); + if (putenv("TEST=1")) + t_error("putenv: %s\n", strerror(errno)); + if (strcmp(environ[0],"TEST=1") != 0) +diff --git a/src/functional/tls_align.mk b/src/functional/tls_align.mk +index a829b84..0e8845d 100644 +--- a/src/functional/tls_align.mk ++++ b/src/functional/tls_align.mk +@@ -1,6 +1,5 @@ +-$(N).LDLIBS := $(B)/$(D)/tls_align_dso.so ++$(N).LDLIBS := $(B)/$(D)/tls_align_dso.o + $(N)-static.LDLIBS := $(B)/$(D)/tls_align_dso.o + +-$(B)/$(N).exe: $(B)/$(D)/tls_align_dso.so ++$(B)/$(N).exe: $(B)/$(D)/tls_align_dso.o + $(B)/$(N)-static.exe: $(B)/$(D)/tls_align_dso.o +- +diff --git a/src/regression/raise-race.c b/src/regression/raise-race.c +index 6b4c4ef..0557b62 100644 +--- a/src/regression/raise-race.c ++++ b/src/regression/raise-race.c +@@ -70,7 +70,7 @@ int main(void) + for (i = 0; i < 100; i++) { + r = pthread_kill(t, SIGRTMIN+1); + if (r) +- t_error("phread_kill failed: %s\n", strerror(r)); ++ t_error("pthread_kill failed: %s\n", strerror(r)); + } + r = pthread_join(t,&p); + if (r) diff --git a/libc_test/run_test_dlibc.py b/libc_test/run_test_dlibc.py new file mode 100644 index 0000000..a2313bf --- /dev/null +++ b/libc_test/run_test_dlibc.py @@ -0,0 +1,252 @@ +#!/usr/bin/env python3 +"""Python-based test runner for dlibc. + +Replaces the shell-based runtest helper while preserving the same interface: + runtest [-t timeout] [-w wrap] cmd [args...] +""" + +from __future__ import annotations + +import getopt +import os +import resource +import shutil +import signal +import shlex +import subprocess +import sys +import tempfile +from pathlib import Path + +STACK_LIMIT_BYTES = 100 * 1024 +INTERNAL_EXIT_CODE = 255 + + +class UsageError(Exception): + """Raised when the runner invocation is invalid.""" + + +def usage(prog: str) -> None: + print(f"usage: {prog} [-t timeoutsec] [-w wrapcmd] cmd [args..]", file=sys.stderr) + + +def parse_args(argv: list[str]) -> tuple[str, str, list[str]]: + timeout = 5 + wrap = "" + try: + options, remaining = getopt.getopt(argv, "w:t:") + except getopt.GetoptError: + usage(Path(sys.argv[0]).name) + raise UsageError("invalid arguments") + + for opt, value in options: + if opt == "-w": + wrap = value + elif opt == "-t": + try: + timeout = int(value) + except ValueError: + timeout = 0 + + if not remaining: + usage(Path(sys.argv[0]).name) + raise UsageError("missing test command") + + return timeout, wrap, remaining + + +def resolve_test_bin(test_bin: str) -> str: + # check if the test_bin is an absolute path + if os.path.isabs(test_bin): + return test_bin + return os.path.join(os.getcwd(), test_bin) + + +def artifact_subpath(test_rel: str) -> Path: + return Path(test_rel.lstrip("/")) + + +def set_stack_limit() -> None: + try: + soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_STACK) + if STACK_LIMIT_BYTES <= hard_limit: + resource.setrlimit(resource.RLIMIT_STACK, (STACK_LIMIT_BYTES, STACK_LIMIT_BYTES)) + elif STACK_LIMIT_BYTES <= soft_limit: + resource.setrlimit(resource.RLIMIT_STACK, (STACK_LIMIT_BYTES, hard_limit)) + except (OSError, ValueError): + # Match the C helper's "best effort" behavior: exec should still proceed. + pass + + +def write_meta( + meta_file: Path, + test_bin: str, + test_rel: str, + timeout: int, + wrap: str, + exit_code: int, + artifact_dir: Path, + tmpdir: str, +) -> None: + meta_file.write_text( + "\n".join( + [ + f"test_bin={test_bin}", + f"test_rel={test_rel}", + f"timeout={timeout}", + f"wrap={wrap}", + f"exit_code={exit_code}", + f"artifact_dir={artifact_dir}", + f"tmpdir={tmpdir}", + ] + ) + + "\n", + encoding="utf-8", + ) + + +def copy_stdio_file(src: Path, dst: Path) -> None: + if src.is_file(): + shutil.copyfile(src, dst) + + +def replay_file(path: Path, stream) -> None: + if not path.exists(): + return + + with path.open("rb") as handle: + shutil.copyfileobj(handle, stream.buffer) + stream.flush() + + +def replay_outputs( + tmpdir_path: Path, + artifact_dir: Path, + host_stdout: Path, + host_stderr: Path, + dandelion_stdout: Path, + dandelion_stderr: Path, +) -> None: + output_sets_dir = tmpdir_path / "output_sets" + if output_sets_dir.is_dir(): + shutil.copytree(output_sets_dir, artifact_dir / "output_sets") + + copy_stdio_file(output_sets_dir / "stdio" / "stdout", dandelion_stdout) + copy_stdio_file(output_sets_dir / "stdio" / "stderr", dandelion_stderr) + + # replay the host stdout and stderr to the console + # this is useful for debugging the test runner itself + replay_file(host_stdout, sys.stdout) + replay_file(host_stderr, sys.stderr) + + +def format_signal_failure(return_code: int) -> str: + signal_number = -return_code + try: + signal_name = signal.strsignal(signal_number) + except (AttributeError, ValueError): + signal_name = None + if signal_name: + return f"[signal {signal_name}]" + return "[unknown]" + + +def report_internal(test_bin: str, message: str) -> int: + print(f"{test_bin} {message}", file=sys.stderr) + print(f"FAIL {test_bin} [internal]") + return INTERNAL_EXIT_CODE + + +def main(argv: list[str]) -> int: + runner_name = Path(argv[0]).name if argv else "run_test_dlibc.py" + try: + timeout, wrap, remaining = parse_args(argv[1:]) + except UsageError as exc: + return report_internal(runner_name, str(exc)) + + # resolve the test binary to an absolute path + test_bin = resolve_test_bin(remaining[0]) + test_args = remaining[1:] + + script_dir = Path(__file__).resolve().parent + artifact_root = Path( + os.environ.get("DLIBC_STDIO_ARTIFACTS", str(script_dir / "logs" / "test_stdio")) + ) + # create root folder for artifacts + artifact_root.mkdir(parents=True, exist_ok=True) + + test_rel = test_bin + script_dir_prefix = str(script_dir) + os.sep + if test_bin.startswith(script_dir_prefix): + test_rel = test_bin[len(script_dir_prefix) :] + + artifact_dir = artifact_root / artifact_subpath(test_rel) + # remove existing artifacts + shutil.rmtree(artifact_dir, ignore_errors=True) + artifact_dir.mkdir(parents=True, exist_ok=True) + + tmpdir = tempfile.mkdtemp() + tmpdir_path = Path(tmpdir) + (tmpdir_path / "input_sets").mkdir(parents=True, exist_ok=True) + (tmpdir_path / "output_sets" / "stdio").mkdir(parents=True, exist_ok=True) + + host_stdout = artifact_dir / "host.stdout" + host_stderr = artifact_dir / "host.stderr" + meta_file = artifact_dir / "meta.txt" + dandelion_stdout = artifact_dir / "dandelion.stdout" + dandelion_stderr = artifact_dir / "dandelion.stderr" + + command = [*shlex.split(wrap), test_bin, *test_args] if wrap else [test_bin, *test_args] + + rc = 0 + timed_out = False + try: + with host_stdout.open("wb") as stdout_handle, host_stderr.open("wb") as stderr_handle: + try: + process = subprocess.Popen( + command, + cwd=tmpdir, + stdout=stdout_handle, + stderr=stderr_handle, + preexec_fn=set_stack_limit, + ) + except OSError as exc: + rc = 1 + print(f"{command[0]} exec failed: {exc.strerror}", file=stderr_handle) + else: + try: + rc = process.wait(timeout=timeout) + except subprocess.TimeoutExpired: + timed_out = True + process.kill() + rc = process.wait() + + write_meta(meta_file, test_bin, test_rel, timeout, wrap, rc, artifact_dir, tmpdir) + replay_outputs(tmpdir_path, artifact_dir, host_stdout, host_stderr, dandelion_stdout, dandelion_stderr) + except Exception as exc: + try: + write_meta(meta_file, test_bin, test_rel, timeout, wrap, INTERNAL_EXIT_CODE, artifact_dir, tmpdir) + except Exception: + pass + return report_internal(test_bin, f"internal runner failure: {exc}") + finally: + shutil.rmtree(tmpdir, ignore_errors=True) + + if timed_out: + print(f"FAIL {test_bin} [timed out]") + return 1 + if rc == 0: + return 0 + if rc > 0: + print(f"FAIL {test_bin} [status {rc}]") + return 1 + if rc < 0: + print(f"FAIL {test_bin} {format_signal_failure(rc)}") + return 1 + + print(f"FAIL {test_bin} [unknown]") + return 1 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv)) diff --git a/libc_test/scripts/analyze_results.ipynb b/libc_test/scripts/analyze_results.ipynb new file mode 100644 index 0000000..156ee59 --- /dev/null +++ b/libc_test/scripts/analyze_results.ipynb @@ -0,0 +1,643 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "d07fb1e6", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: pip in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (26.0.1)\n", + "Collecting nbconvert\n", + " Downloading nbconvert-7.17.0-py3-none-any.whl.metadata (8.4 kB)\n", + "Collecting jupyter\n", + " Downloading jupyter-1.1.1-py2.py3-none-any.whl.metadata (2.0 kB)\n", + "Requirement already satisfied: pandas in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (2.3.3)\n", + "Collecting tabulate\n", + " Using cached tabulate-0.9.0-py3-none-any.whl.metadata (34 kB)\n", + "Collecting beautifulsoup4 (from nbconvert)\n", + " Downloading beautifulsoup4-4.14.3-py3-none-any.whl.metadata (3.8 kB)\n", + "Collecting bleach!=5.0.0 (from bleach[css]!=5.0.0->nbconvert)\n", + " Downloading bleach-6.2.0-py3-none-any.whl.metadata (30 kB)\n", + "Collecting defusedxml (from nbconvert)\n", + " Downloading defusedxml-0.7.1-py2.py3-none-any.whl.metadata (32 kB)\n", + "Requirement already satisfied: importlib-metadata>=3.6 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from nbconvert) (8.7.1)\n", + "Collecting jinja2>=3.0 (from nbconvert)\n", + " Downloading jinja2-3.1.6-py3-none-any.whl.metadata (2.9 kB)\n", + "Requirement already satisfied: jupyter-core>=4.7 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from nbconvert) (5.8.1)\n", + "Collecting jupyterlab-pygments (from nbconvert)\n", + " Downloading jupyterlab_pygments-0.3.0-py3-none-any.whl.metadata (4.4 kB)\n", + "Collecting markupsafe>=2.0 (from nbconvert)\n", + " Downloading markupsafe-3.0.3-cp39-cp39-macosx_11_0_arm64.whl.metadata (2.7 kB)\n", + "Collecting mistune<4,>=2.0.3 (from nbconvert)\n", + " Downloading mistune-3.2.0-py3-none-any.whl.metadata (1.9 kB)\n", + "Collecting nbclient>=0.5.0 (from nbconvert)\n", + " Downloading nbclient-0.10.2-py3-none-any.whl.metadata (8.3 kB)\n", + "Collecting nbformat>=5.7 (from nbconvert)\n", + " Downloading nbformat-5.10.4-py3-none-any.whl.metadata (3.6 kB)\n", + "Requirement already satisfied: packaging in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from nbconvert) (26.0)\n", + "Collecting pandocfilters>=1.4.1 (from nbconvert)\n", + " Downloading pandocfilters-1.5.1-py2.py3-none-any.whl.metadata (9.0 kB)\n", + "Requirement already satisfied: pygments>=2.4.1 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from nbconvert) (2.20.0)\n", + "Requirement already satisfied: traitlets>=5.1 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from nbconvert) (5.14.3)\n", + "Requirement already satisfied: typing-extensions in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from mistune<4,>=2.0.3->nbconvert) (4.15.0)\n", + "Collecting notebook (from jupyter)\n", + " Downloading notebook-7.5.5-py3-none-any.whl.metadata (10 kB)\n", + "Collecting jupyter-console (from jupyter)\n", + " Downloading jupyter_console-6.6.3-py3-none-any.whl.metadata (5.8 kB)\n", + "Requirement already satisfied: ipykernel in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from jupyter) (6.31.0)\n", + "Collecting ipywidgets (from jupyter)\n", + " Downloading ipywidgets-8.1.8-py3-none-any.whl.metadata (2.4 kB)\n", + "Collecting jupyterlab (from jupyter)\n", + " Downloading jupyterlab-4.5.6-py3-none-any.whl.metadata (16 kB)\n", + "Requirement already satisfied: numpy>=1.22.4 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from pandas) (2.0.2)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from pandas) (2.9.0.post0)\n", + "Requirement already satisfied: pytz>=2020.1 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from pandas) (2026.1.post1)\n", + "Requirement already satisfied: tzdata>=2022.7 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from pandas) (2026.1)\n", + "Collecting webencodings (from bleach!=5.0.0->bleach[css]!=5.0.0->nbconvert)\n", + " Downloading webencodings-0.5.1-py2.py3-none-any.whl.metadata (2.1 kB)\n", + "Collecting tinycss2<1.5,>=1.1.0 (from bleach[css]!=5.0.0->nbconvert)\n", + " Downloading tinycss2-1.4.0-py3-none-any.whl.metadata (3.0 kB)\n", + "Requirement already satisfied: zipp>=3.20 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from importlib-metadata>=3.6->nbconvert) (3.23.0)\n", + "Requirement already satisfied: platformdirs>=2.5 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from jupyter-core>=4.7->nbconvert) (4.4.0)\n", + "Requirement already satisfied: jupyter-client>=6.1.12 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from nbclient>=0.5.0->nbconvert) (8.6.3)\n", + "Requirement already satisfied: pyzmq>=23.0 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from jupyter-client>=6.1.12->nbclient>=0.5.0->nbconvert) (27.1.0)\n", + "Requirement already satisfied: tornado>=6.2 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from jupyter-client>=6.1.12->nbclient>=0.5.0->nbconvert) (6.5.5)\n", + "Collecting fastjsonschema>=2.15 (from nbformat>=5.7->nbconvert)\n", + " Downloading fastjsonschema-2.21.2-py3-none-any.whl.metadata (2.3 kB)\n", + "Collecting jsonschema>=2.6 (from nbformat>=5.7->nbconvert)\n", + " Downloading jsonschema-4.25.1-py3-none-any.whl.metadata (7.6 kB)\n", + "Collecting attrs>=22.2.0 (from jsonschema>=2.6->nbformat>=5.7->nbconvert)\n", + " Downloading attrs-26.1.0-py3-none-any.whl.metadata (8.8 kB)\n", + "Collecting jsonschema-specifications>=2023.03.6 (from jsonschema>=2.6->nbformat>=5.7->nbconvert)\n", + " Downloading jsonschema_specifications-2025.9.1-py3-none-any.whl.metadata (2.9 kB)\n", + "Collecting referencing>=0.28.4 (from jsonschema>=2.6->nbformat>=5.7->nbconvert)\n", + " Downloading referencing-0.36.2-py3-none-any.whl.metadata (2.8 kB)\n", + "Collecting rpds-py>=0.7.1 (from jsonschema>=2.6->nbformat>=5.7->nbconvert)\n", + " Downloading rpds_py-0.27.1-cp39-cp39-macosx_11_0_arm64.whl.metadata (4.2 kB)\n", + "Requirement already satisfied: six>=1.5 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n", + "Collecting soupsieve>=1.6.1 (from beautifulsoup4->nbconvert)\n", + " Downloading soupsieve-2.8.3-py3-none-any.whl.metadata (4.6 kB)\n", + "Requirement already satisfied: appnope>=0.1.2 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipykernel->jupyter) (0.1.4)\n", + "Requirement already satisfied: comm>=0.1.1 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipykernel->jupyter) (0.2.3)\n", + "Requirement already satisfied: debugpy>=1.6.5 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipykernel->jupyter) (1.8.20)\n", + "Requirement already satisfied: ipython>=7.23.1 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipykernel->jupyter) (8.18.1)\n", + "Requirement already satisfied: matplotlib-inline>=0.1 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipykernel->jupyter) (0.2.1)\n", + "Requirement already satisfied: nest-asyncio>=1.4 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipykernel->jupyter) (1.6.0)\n", + "Requirement already satisfied: psutil>=5.7 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipykernel->jupyter) (7.2.2)\n", + "Requirement already satisfied: decorator in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel->jupyter) (5.2.1)\n", + "Requirement already satisfied: jedi>=0.16 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel->jupyter) (0.19.2)\n", + "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel->jupyter) (3.0.52)\n", + "Requirement already satisfied: stack-data in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel->jupyter) (0.6.3)\n", + "Requirement already satisfied: exceptiongroup in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel->jupyter) (1.3.1)\n", + "Requirement already satisfied: pexpect>4.3 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel->jupyter) (4.9.0)\n", + "Requirement already satisfied: wcwidth in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=7.23.1->ipykernel->jupyter) (0.6.0)\n", + "Requirement already satisfied: parso<0.9.0,>=0.8.4 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel->jupyter) (0.8.6)\n", + "Requirement already satisfied: ptyprocess>=0.5 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from pexpect>4.3->ipython>=7.23.1->ipykernel->jupyter) (0.7.0)\n", + "Collecting widgetsnbextension~=4.0.14 (from ipywidgets->jupyter)\n", + " Downloading widgetsnbextension-4.0.15-py3-none-any.whl.metadata (1.6 kB)\n", + "Collecting jupyterlab_widgets~=3.0.15 (from ipywidgets->jupyter)\n", + " Downloading jupyterlab_widgets-3.0.16-py3-none-any.whl.metadata (20 kB)\n", + "Collecting async-lru>=1.0.0 (from jupyterlab->jupyter)\n", + " Downloading async_lru-2.0.5-py3-none-any.whl.metadata (4.5 kB)\n", + "Collecting httpx<1,>=0.25.0 (from jupyterlab->jupyter)\n", + " Downloading httpx-0.28.1-py3-none-any.whl.metadata (7.1 kB)\n", + "Collecting jupyter-lsp>=2.0.0 (from jupyterlab->jupyter)\n", + " Downloading jupyter_lsp-2.3.1-py3-none-any.whl.metadata (1.8 kB)\n", + "Collecting jupyter-server<3,>=2.4.0 (from jupyterlab->jupyter)\n", + " Downloading jupyter_server-2.17.0-py3-none-any.whl.metadata (8.5 kB)\n", + "Collecting jupyterlab-server<3,>=2.28.0 (from jupyterlab->jupyter)\n", + " Downloading jupyterlab_server-2.28.0-py3-none-any.whl.metadata (5.9 kB)\n", + "Collecting notebook-shim>=0.2 (from jupyterlab->jupyter)\n", + " Downloading notebook_shim-0.2.4-py3-none-any.whl.metadata (4.0 kB)\n", + "Requirement already satisfied: setuptools>=41.1.0 in /Users/lmo/workspace/ETH/Semesterprojekt/dandelionSDK/.venv/lib/python3.9/site-packages (from jupyterlab->jupyter) (58.0.4)\n", + "Collecting tomli>=1.2.2 (from jupyterlab->jupyter)\n", + " Downloading tomli-2.4.1-py3-none-any.whl.metadata (10 kB)\n", + "Collecting anyio (from httpx<1,>=0.25.0->jupyterlab->jupyter)\n", + " Downloading anyio-4.12.1-py3-none-any.whl.metadata (4.3 kB)\n", + "Collecting certifi (from httpx<1,>=0.25.0->jupyterlab->jupyter)\n", + " Downloading certifi-2026.2.25-py3-none-any.whl.metadata (2.5 kB)\n", + "Collecting httpcore==1.* (from httpx<1,>=0.25.0->jupyterlab->jupyter)\n", + " Downloading httpcore-1.0.9-py3-none-any.whl.metadata (21 kB)\n", + "Collecting idna (from httpx<1,>=0.25.0->jupyterlab->jupyter)\n", + " Downloading idna-3.11-py3-none-any.whl.metadata (8.4 kB)\n", + "Collecting h11>=0.16 (from httpcore==1.*->httpx<1,>=0.25.0->jupyterlab->jupyter)\n", + " Downloading h11-0.16.0-py3-none-any.whl.metadata (8.3 kB)\n", + "Collecting argon2-cffi>=21.1 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter)\n", + " Downloading argon2_cffi-25.1.0-py3-none-any.whl.metadata (4.1 kB)\n", + "Collecting jupyter-events>=0.11.0 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter)\n", + " Downloading jupyter_events-0.12.0-py3-none-any.whl.metadata (5.8 kB)\n", + "Collecting jupyter-server-terminals>=0.4.4 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter)\n", + " Downloading jupyter_server_terminals-0.5.4-py3-none-any.whl.metadata (5.9 kB)\n", + "Collecting overrides>=5.0 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter)\n", + " Downloading overrides-7.7.0-py3-none-any.whl.metadata (5.8 kB)\n", + "Collecting prometheus-client>=0.9 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter)\n", + " Downloading prometheus_client-0.24.1-py3-none-any.whl.metadata (2.1 kB)\n", + "Collecting send2trash>=1.8.2 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter)\n", + " Downloading send2trash-2.1.0-py3-none-any.whl.metadata (4.1 kB)\n" + ] + } + ], + "source": [ + "# !pip install pip nbconvert jupyter pandas tabulate" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "41df5ddb", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'pandas'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[3], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mlogging\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Filterer\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mpathlib\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Path\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mpandas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mpd\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mos\u001b[39;00m\n\u001b[1;32m 6\u001b[0m path \u001b[38;5;241m=\u001b[39m Path(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m..\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;241m/\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlogs\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m/\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtest_results.csv\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pandas'" + ] + } + ], + "source": [ + "from logging import Filterer\n", + "from pathlib import Path\n", + "import pandas as pd\n", + "import os\n", + "\n", + "path = Path(\"..\") / \"logs\" / \"test_results.csv\"\n", + "\n", + "# read the csv file\n", + "df = pd.read_csv(path)\n", + "\n", + "Filtered = df[df['result'] == 'FAIL']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6856b58e", + "metadata": {}, + "outputs": [], + "source": [ + "def get_stdio_and_err(name, evidence_file, failure_stage):\n", + " \"expects name to be a string in format: functional/fcntl\"\n", + " evidence_path = Path(\"..\") / evidence_file\n", + "\n", + " std_out = \"\"\n", + " std_err = \"\"\n", + " host_out = \"\"\n", + " host_err = \"\"\n", + " error_file = \"\"\n", + " meta_data = \"\"\n", + "\n", + " def read_file_if_exists(path):\n", + " if path.exists():\n", + " return path.read_text(encoding=\"utf-8\", errors=\"replace\")\n", + " return \"\"\n", + "\n", + " error_file = read_file_if_exists(evidence_path)\n", + "\n", + " if failure_stage == \"runtime\":\n", + " artifact_dir = Path(\"..\") / \"logs\" / \"test_stdio\" / Path(evidence_file).with_suffix(\".exe\")\n", + " std_out = read_file_if_exists(artifact_dir / \"dandelion.stdout\")\n", + " std_err = read_file_if_exists(artifact_dir / \"dandelion.stderr\")\n", + " host_out = read_file_if_exists(artifact_dir / \"host.stdout\")\n", + " host_err = read_file_if_exists(artifact_dir / \"host.stderr\")\n", + " meta_data = read_file_if_exists(artifact_dir / \"meta.txt\")\n", + "\n", + " return {\"stdout\": std_out, \"stderr\": std_err, \".err\": error_file, \"host_out\": host_out, \"host_err\": host_err, \"meta_data\": meta_data}\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "96c23949", + "metadata": {}, + "outputs": [], + "source": [ + "rows = []\n", + "for index, row in Filtered.iterrows():\n", + " data = get_stdio_and_err(\n", + " str(row[\"test\"]),\n", + " str(row[\"evidence_file\"]),\n", + " str(row[\"failure_stage\"]),\n", + " )\n", + " rows.append({\n", + " \"test\": str(row[\"test\"]),\n", + " \"result\": str(row[\"result\"]),\n", + " \"failure_stage\": str(row[\"failure_stage\"]),\n", + " \"evidence_file\": str(row[\"evidence_file\"]),\n", + " \"stdout\": data[\"stdout\"],\n", + " \"stderr\": data[\"stderr\"],\n", + " \".err\": data[\".err\"],\n", + " \"host_out\": data[\"host_out\"],\n", + " \"host_err\": data[\"host_err\"],\n", + " \"meta_data\": data[\"meta_data\"]\n", + " })\n", + "\n", + "df_new = pd.DataFrame(rows)\n", + "\n", + "# filter into categories\n", + "df_segfault = df_new[df_new[\".err\"].str.contains(\"Segmentation fault\", na=False)]\n", + "df_new = df_new[~df_new[\".err\"].str.contains(\"Segmentation fault\", na=False)]\n", + "\n", + "timed_out = df_new[df_new[\".err\"].str.contains(\"timed out\", na=False)]\n", + "df_new = df_new[~df_new[\".err\"].str.contains(\"timed out\", na=False)]\n", + "\n", + "empty_stdout = df_new[df_new[\"stdout\"] == \"\"]\n", + "std_out_rows = df_new[df_new[\"stdout\"] != \"\"]\n", + "\n", + "#TODO analyze stdout\n", + "\n", + "#1. Function not implemented\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e7136e48", + "metadata": {}, + "outputs": [], + "source": [ + "from pathlib import Path\n", + "\n", + "stout_appended = \"\"\n", + "report_dir = Path(\"..\") / \"report\"\n", + "report_dir.mkdir(parents=True, exist_ok=True)\n", + "\n", + "# write stout_appended.txt\n", + "for _, row in std_out_rows.iterrows():\n", + " for line in row[\"stdout\"].splitlines():\n", + " if line.strip():\n", + " stout_appended += line + \"\\n\"\n", + "\n", + "(report_dir / \"stout_appended.txt\").write_text(stout_appended)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c5e385d3", + "metadata": {}, + "outputs": [], + "source": [ + "import re\n", + "from pathlib import Path\n", + "from typing import Dict, List, Optional, Tuple\n", + "\n", + "scripts_dir = Path(\"..\") / \"scripts\"\n", + "report_dir = Path(\"..\") / \"report\"\n", + "report_dir.mkdir(parents=True, exist_ok=True)\n", + "\n", + "SOURCE_PREFIX_RE = re.compile(r'^(?:X\\s+)?(?P[^:\\n]+):(?P\\d+):\\s+')\n", + "PREFIX = r'^(?:X\\s+)?[^:\\n]+:\\d+:\\s+'\n", + "FUNCTION_PATTERNS = [\n", + " # Matches assignment chains like \"x = y = fopen(...)\".\n", + " re.compile(PREFIX + r'\\(?\\s*(?:[A-Za-z_][A-Za-z0-9_]*\\s*=\\s*)+([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()'),\n", + " # Matches FP-mode-prefixed calls like \"RN nearbyint(...)\".\n", + " re.compile(PREFIX + r'(?:bad fp exception:\\s+)?(?:RN|RZ|RU|RD)\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()'),\n", + " # Matches ordinal call descriptions like \"1st foo(...)\".\n", + " re.compile(PREFIX + r'\\d+(?:st|nd|rd|th)\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()'),\n", + " # Matches sizeof-based call descriptions like \"sizeof pow(...) want 4 got 8\".\n", + " re.compile(PREFIX + r'sizeof\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()'),\n", + " # Matches bracketed prefixes before failed calls like \"[thread 1]: pthread_create(...) == 0 failed\".\n", + " re.compile(PREFIX + r'(?:\\[[^\\]]+\\]:\\s+)+([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\().*\\bfailed\\b'),\n", + " # Matches negated failed calls like \"!!feof(...) failed\" or \"!pthread_join(...) failed\".\n", + " re.compile(PREFIX + r'!+\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\().*\\bfailed\\b'),\n", + " # Matches parenthesized function contexts like \"failed (blocking sem_wait, ...)\".\n", + " re.compile(PREFIX + r'.*\\bfailed\\b\\s*\\((?:blocking|non-blocking)\\s+([A-Za-z_][A-Za-z0-9_]*)\\b'),\n", + " # Matches parenthesized function contexts like \"failed (shm_open, seqno)\".\n", + " re.compile(PREFIX + r'.*\\bfailed\\b\\s*\\(([A-Za-z_][A-Za-z0-9_]*)\\s*,'),\n", + " # Matches status lines like \"regcomp returned 2\".\n", + " re.compile(PREFIX + r'([A-Za-z_][A-Za-z0-9_]*)\\s+returned\\s+[-+]?\\d+\\b'),\n", + " # Matches expectation lines like \"pthread_create should fail with EAGAIN but failed with 1\".\n", + " re.compile(PREFIX + r'([A-Za-z_][A-Za-z0-9_]*)\\s+should\\s+fail\\b'),\n", + " # Matches descriptive result lines like \"fgets read back: ...\".\n", + " re.compile(PREFIX + r'([A-Za-z_][A-Za-z0-9_]*)\\s+read back\\s*:'),\n", + " # Matches narrative lines like \"pthread_once ran init 0 times\".\n", + " re.compile(PREFIX + r'([A-Za-z_][A-Za-z0-9_]*)\\s+ran\\b'),\n", + " # Matches narrative failures like \"fesetenv did not restore upward rounding\".\n", + " re.compile(PREFIX + r'([a-z_][A-Za-z0-9_]*)\\s+did\\s+not\\b'),\n", + " # Matches regression text like \"ftello is broken before flush\".\n", + " re.compile(PREFIX + r'([a-z_][A-Za-z0-9_]*)\\s+is\\s+broken\\b'),\n", + " # Matches OOM-style lines like \"malloc was successful\".\n", + " re.compile(PREFIX + r'([a-z_][A-Za-z0-9_]*)\\s+was\\s+successful\\b'),\n", + " # Matches mismatch lines like \"read 1 instead of 0\".\n", + " re.compile(PREFIX + r'([a-z_][A-Za-z0-9_]*)\\s+[-+]?\\d+\\s+instead\\s+of\\s+[-+]?\\d+\\b'),\n", + " # Matches status lines like \"getrlimit 2: Success\".\n", + " re.compile(PREFIX + r'([A-Za-z_][A-Za-z0-9_]*)\\s+\\d+\\s*:'),\n", + " # Matches plain call forms like \"fopen(...)\".\n", + " re.compile(PREFIX + r'([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()'),\n", + " # Matches plain labels like \"malloc:\".\n", + " re.compile(PREFIX + r'([A-Za-z_][A-Za-z0-9_]*)\\s*:'),\n", + " # Matches lowercase trailing failure lines like \"pthread_kill failed\".\n", + " re.compile(PREFIX + r'([a-z_][A-Za-z0-9_]{1,})\\s+failed\\b'),\n", + "]\n", + "\n", + "\n", + "def extract_source_info(line: str) -> Tuple[Optional[str], Optional[int]]:\n", + " match = SOURCE_PREFIX_RE.match(line)\n", + " if not match:\n", + " return None, None\n", + " return match.group(\"source\"), int(match.group(\"source_line\"))\n", + "\n", + "\n", + "\n", + "def normalize_function_name(name: str) -> Optional[str]:\n", + " # Drop obvious non-function captures like one-letter locals and macro names.\n", + " if len(name) == 1 and name.islower():\n", + " return None\n", + " if re.fullmatch(r'[A-Z0-9_]+', name):\n", + " return None\n", + " return name\n", + "\n", + "\n", + "\n", + "def extract_func_name(line: str) -> Optional[str]:\n", + " for pattern in FUNCTION_PATTERNS:\n", + " match = pattern.search(line)\n", + " if match:\n", + " function_name = normalize_function_name(match.group(1))\n", + " if function_name:\n", + " return function_name\n", + " return None\n", + "\n", + "\n", + "\n", + "def last_nonempty_line(text: str) -> str:\n", + " for line in reversed(text.splitlines()):\n", + " if line.strip():\n", + " return line\n", + " return \"\"\n", + "\n", + "\n", + "\n", + "def add_test_level_rows(frame: pd.DataFrame, failure_category: str, rows: List[Dict[str, object]]) -> None:\n", + " for _, row in frame.iterrows():\n", + " raw_line = last_nonempty_line(row[\".err\"])\n", + " rows.append(\n", + " {\n", + " \"test\": row[\"test\"],\n", + " \"failure_category\": failure_category,\n", + " \"function_name\": None,\n", + " \"source\": None,\n", + " \"source_line\": None,\n", + " \"raw_line\": raw_line,\n", + " }\n", + " )\n", + "\n", + "\n", + "SUMMARY_LABELS = {\n", + " \"function_not_implemented\": \"Not implemented\",\n", + " \"stdout_failure\": \"Implemented - FAILS TESTS\",\n", + "}\n", + "\n", + "\n", + "def build_function_summary(\n", + " frame: pd.DataFrame,\n", + " known_stub_functions: Optional[set[str]] = None,\n", + ") -> pd.DataFrame:\n", + " summary_rows = frame.loc[\n", + " frame[\"function_name\"].notna() & frame[\"failure_category\"].isin(SUMMARY_LABELS),\n", + " [\"function_name\", \"failure_category\"],\n", + " ].copy()\n", + " summary_rows[\"status\"] = summary_rows[\"failure_category\"].map(SUMMARY_LABELS)\n", + "\n", + " if known_stub_functions:\n", + " stub_rows = pd.DataFrame(\n", + " {\n", + " \"function_name\": sorted(known_stub_functions),\n", + " \"failure_category\": \"function_not_implemented\",\n", + " \"status\": SUMMARY_LABELS[\"function_not_implemented\"],\n", + " }\n", + " )\n", + " summary_rows = pd.concat([summary_rows, stub_rows], ignore_index=True)\n", + "\n", + " function_summary_df = (\n", + " summary_rows.groupby(\"function_name\")[\"status\"]\n", + " .agg(\n", + " lambda statuses: \"Not implemented\"\n", + " if \"Not implemented\" in set(statuses)\n", + " else \"Implemented - FAILS TESTS\"\n", + " )\n", + " .reset_index()\n", + " .sort_values([\"status\", \"function_name\"])\n", + " )\n", + "\n", + " return function_summary_df\n", + "\n", + "\n", + "analysis_rows = []\n", + "\n", + "# Add segfault, timed out and empty stdout rows\n", + "add_test_level_rows(df_segfault, \"segmentation_fault\", analysis_rows)\n", + "add_test_level_rows(timed_out, \"timed_out\", analysis_rows)\n", + "add_test_level_rows(empty_stdout, \"empty_stdout\", analysis_rows)\n", + "\n", + "for _, row in std_out_rows.iterrows():\n", + " for raw_line in row[\"stdout\"].splitlines():\n", + " #skip empty lines\n", + " if not raw_line.strip():\n", + " continue\n", + "\n", + " source, source_line = extract_source_info(raw_line)\n", + " function_name = extract_func_name(raw_line)\n", + " failure_category = (\n", + " \"function_not_implemented\"\n", + " if \"Function not implemented\" in raw_line\n", + " else \"stdout_failure\"\n", + " )\n", + "\n", + " analysis_rows.append(\n", + " {\n", + " \"test\": row[\"test\"],\n", + " \"failure_category\": failure_category,\n", + " \"function_name\": function_name,\n", + " \"source\": source,\n", + " \"source_line\": source_line,\n", + " \"raw_line\": raw_line,\n", + " }\n", + " )\n", + "\n", + "analysis_df = pd.DataFrame(\n", + " analysis_rows,\n", + " columns=[\"test\", \"failure_category\", \"function_name\", \"source\", \"source_line\", \"raw_line\"],\n", + ")\n", + "analysis_df[\"source_line\"] = analysis_df[\"source_line\"].astype(\"Int64\")\n", + "\n", + "function_summary_df = build_function_summary(analysis_df)\n", + "\n", + "stout_lines = analysis_df.loc[analysis_df[\"failure_category\"] == \"stdout_failure\", \"raw_line\"]\n", + "\n", + "analysis_df.to_csv(report_dir / \"failure_line_details.csv\", index=False)\n", + "function_summary_df.to_csv(report_dir / \"function_failure_summary.csv\", index=False)\n", + "\n", + "\n", + "funcs = sorted(function_summary_df[\"function_name\"].unique().tolist())\n", + "function_summary_df.head()\n", + "\n", + "\n", + "uncategorized_lines = analysis_df.loc[\n", + " (analysis_df[\"failure_category\"] == \"stdout_failure\") & (analysis_df[\"function_name\"].isna()),\n", + " \"raw_line\"\n", + "]\n", + "\n", + "print(len(uncategorized_lines))\n", + "\n", + "uncategorized_lines_string = \"\"\n", + "for line in uncategorized_lines:\n", + " uncategorized_lines_string += line + \"\\n\"\n", + "\n", + "(report_dir / \"uncategorized_lines.txt\").write_text(uncategorized_lines_string)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "42db5fac", + "metadata": {}, + "outputs": [], + "source": [ + "# Outputs written under ../report by the extraction cells above:\n", + "# - failure_line_details.csv: one row per observed failure line\n", + "# - function_failure_summary.csv: one row per function with a summary status\n", + "# - stout_appended.txt: stdout failures excluding \"Function not implemented\"\n", + "# - uncategorized_lines.txt: stdout failures where no function name was extracted\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "42db5fac", + "metadata": {}, + "outputs": [], + "source": [ + "function_summary_df[function_summary_df[\"status\"] == \"Implemented - FAILS TESTS\"]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "96bf3a99", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "19a323c9", + "metadata": {}, + "outputs": [], + "source": [ + "analysis_df[\"failure_category\"].value_counts()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd3c698e", + "metadata": {}, + "outputs": [], + "source": [ + "stdout_line_count = sum(\n", + " 1\n", + " for _, row in std_out_rows.iterrows()\n", + " for line in row[\"stdout\"].splitlines()\n", + " if line.strip()\n", + ")\n", + "\n", + "analysis_stdout_count = (\n", + " analysis_df[\"failure_category\"].isin([\"stdout_failure\", \"function_not_implemented\"])\n", + ").sum()\n", + "\n", + "assert stdout_line_count == analysis_stdout_count" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0ba77d7f", + "metadata": {}, + "outputs": [], + "source": [ + "# save function_summary_df as markdown\n", + "function_summary_df.to_markdown(report_dir / \"function_failure_summary.md\", index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c4031431", + "metadata": {}, + "outputs": [], + "source": [ + "stub_inventory_path = scripts_dir / \"stub_inventory\" / \"stubbed_functions.csv\"\n", + "stub_inventory_df = pd.read_csv(stub_inventory_path)\n", + "known_stub_functions = set(stub_inventory_df[\"function\"].dropna())\n", + "\n", + "analysis_df[\"function_name\"] = analysis_df[\"function_name\"].replace({\n", + " \"memfill\": \"mmap\",\n", + " \"vmfill\": \"mmap\",\n", + "})\n", + "\n", + "known_stub_mask = (\n", + " analysis_df[\"failure_category\"].eq(\"stdout_failure\")\n", + " & analysis_df[\"function_name\"].isin(known_stub_functions)\n", + ")\n", + "analysis_df.loc[known_stub_mask, \"failure_category\"] = \"function_not_implemented\"\n", + "\n", + "function_summary_df = build_function_summary(analysis_df, known_stub_functions)\n", + "\n", + "analysis_df.to_csv(report_dir / \"failure_line_details.csv\", index=False)\n", + "function_summary_df.to_csv(report_dir / \"function_failure_summary.csv\", index=False)\n", + "function_summary_df.to_markdown(report_dir / \"function_failure_summary.md\", index=False)\n", + "\n", + "analysis_df[\"failure_category\"].value_counts()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "75f40f3a", + "metadata": {}, + "outputs": [], + "source": [ + "unique_function_counts = (\n", + " analysis_df.dropna(subset=[\"function_name\"])\n", + " .groupby(\"failure_category\")[\"function_name\"]\n", + " .nunique()\n", + " .reindex(analysis_df[\"failure_category\"].value_counts().index, fill_value=0)\n", + ")\n", + "\n", + "unique_function_counts" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/libc_test/scripts/stub_inventory/libc_extension_manual_stubbed_functions.csv b/libc_test/scripts/stub_inventory/libc_extension_manual_stubbed_functions.csv new file mode 100644 index 0000000..6e806d0 --- /dev/null +++ b/libc_test/scripts/stub_inventory/libc_extension_manual_stubbed_functions.csv @@ -0,0 +1,142 @@ +function,file,line,source_area,stub_kind,evidence,signature +aio_cancel,dandelionSDK/libc_extension/aio.c,7,libc_extension,explicit_errno_stub,ENOSYS,"int aio_cancel(int fd, struct aiocb *aiocbp)" +aio_error,dandelionSDK/libc_extension/aio.c,14,libc_extension,explicit_errno_stub,ENOSYS,int aio_error(const struct aiocb *aiocbp) +aio_fsync,dandelionSDK/libc_extension/aio.c,20,libc_extension,explicit_errno_stub,ENOSYS,"int aio_fsync(int op, struct aiocb *aiocbp)" +aio_read,dandelionSDK/libc_extension/aio.c,27,libc_extension,explicit_errno_stub,ENOSYS,int aio_read(struct aiocb *aiocbp) +aio_return,dandelionSDK/libc_extension/aio.c,33,libc_extension,explicit_errno_stub,ENOSYS,ssize_t aio_return(struct aiocb *aiocbp) +aio_suspend,dandelionSDK/libc_extension/aio.c,39,libc_extension,explicit_errno_stub,ENOSYS,"int aio_suspend(const struct aiocb *const aiocb_list[], int nitems, const struct timespec *timeout)" +aio_write,dandelionSDK/libc_extension/aio.c,48,libc_extension,explicit_errno_stub,ENOSYS,int aio_write(struct aiocb *aiocbp) +lio_listio,dandelionSDK/libc_extension/aio.c,54,libc_extension,explicit_errno_stub,ENOSYS,"int lio_listio(int mode, struct aiocb *restrict const list[restrict], int nent, struct sigevent *restrict sig)" +htonl,dandelionSDK/libc_extension/arpa_inet.c,4,libc_extension,explicit_errno_stub,ENOSYS,uint32_t htonl(uint32_t hostlong) +inet_addr,dandelionSDK/libc_extension/arpa_inet.c,10,libc_extension,explicit_errno_stub,ENOSYS,in_addr_t inet_addr(const char *cp) +inet_ntoa,dandelionSDK/libc_extension/arpa_inet.c,16,libc_extension,explicit_errno_stub,ENOSYS,char *inet_ntoa(struct in_addr in) +inet_ntop,dandelionSDK/libc_extension/arpa_inet.c,22,libc_extension,explicit_errno_stub,ENOSYS,"const char *inet_ntop(int af, const void *restrict src, char *restrict dst, socklen_t size)" +inet_pton,dandelionSDK/libc_extension/arpa_inet.c,32,libc_extension,explicit_errno_stub,ENOSYS,"int inet_pton(int af, const char *restrict src, void *restrict dst)" +crypt,dandelionSDK/libc_extension/crypt.c,4,libc_extension,explicit_errno_stub,ENOSYS,"char *crypt(const char *phrase, const char *setting)" +dlclose,dandelionSDK/libc_extension/dlfcn.c,4,libc_extension,explicit_errno_stub,ENOSYS,int dlclose(void *handle) +dlerror,dandelionSDK/libc_extension/dlfcn.c,10,libc_extension,explicit_errno_stub,ENOSYS,char *dlerror(void) +dlopen,dandelionSDK/libc_extension/dlfcn.c,15,libc_extension,explicit_errno_stub,ENOSYS,"void *dlopen(const char *file, int mode)" +dlsym,dandelionSDK/libc_extension/dlfcn.c,22,libc_extension,explicit_errno_stub,ENOSYS,"void *dlsym(void *restrict handle, const char *restrict name)" +getifaddrs,dandelionSDK/libc_extension/ifaddrs.c,4,libc_extension,explicit_errno_stub,ENOSYS,int getifaddrs (struct ifaddrs **__ifap) +statvfs,dandelionSDK/libc_extension/include/sys/statvfs.h,31,include,explicit_errno_stub,ENOSYS,"int statvfs(const char *path, struct statvfs *buf)" +fstatvfs,dandelionSDK/libc_extension/include/sys/statvfs.h,35,include,explicit_errno_stub,ENOSYS,"int fstatvfs(int fd, struct statvfs *buf)" +setmntent,dandelionSDK/libc_extension/mntent.c,4,libc_extension,explicit_errno_stub,ENOSYS,"FILE *setmntent(const char *file, const char *mode)" +getmntent,dandelionSDK/libc_extension/mntent.c,11,libc_extension,explicit_errno_stub,ENOSYS,struct mntent *getmntent(FILE *stream) +getmntent_r,dandelionSDK/libc_extension/mntent.c,17,libc_extension,explicit_errno_stub,ENOSYS,"struct mntent *getmntent_r(FILE *stream, struct mntent *result, char *buffer, int bufsize)" +addmntent,dandelionSDK/libc_extension/mntent.c,27,libc_extension,explicit_errno_stub,ENOSYS,"int addmntent(FILE *stream, const struct mntent *mnt)" +endmntent,dandelionSDK/libc_extension/mntent.c,34,libc_extension,explicit_errno_stub,ENOSYS,int endmntent(FILE *stream) +hasmntopt,dandelionSDK/libc_extension/mntent.c,40,libc_extension,explicit_errno_stub,ENOSYS,"char *hasmntopt(const struct mntent *mnt, const char *opt)" +strfmon,dandelionSDK/libc_extension/monetary.c,4,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t strfmon(char *restrict s, size_t max, const char *restrict format, ...)" +strfmon_l,dandelionSDK/libc_extension/monetary.c,12,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t strfmon_l(char *restrict s, size_t max, locale_t loc, const char *restrict format, ...)" +mq_close,dandelionSDK/libc_extension/mqueue.c,5,libc_extension,explicit_errno_stub,ENOSYS,int mq_close(mqd_t mqdes) +mq_getattr,dandelionSDK/libc_extension/mqueue.c,11,libc_extension,explicit_errno_stub,ENOSYS,"int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat)" +mq_notify,dandelionSDK/libc_extension/mqueue.c,18,libc_extension,explicit_errno_stub,ENOSYS,"int mq_notify(mqd_t mqdes, const struct sigevent *notification)" +mq_open,dandelionSDK/libc_extension/mqueue.c,25,libc_extension,explicit_errno_stub,ENOSYS,"mqd_t mq_open(const char *name, int oflag, ...)" +mq_receive,dandelionSDK/libc_extension/mqueue.c,36,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)" +mq_send,dandelionSDK/libc_extension/mqueue.c,46,libc_extension,explicit_errno_stub,ENOSYS,"int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)" +mq_setattr,dandelionSDK/libc_extension/mqueue.c,56,libc_extension,explicit_errno_stub,ENOSYS,"int mq_setattr(mqd_t mqdes, const struct mq_attr *restrict mqstat, struct mq_attr *restrict omqstat)" +mq_timedreceive,dandelionSDK/libc_extension/mqueue.c,65,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t mq_timedreceive(mqd_t mqdes, char *restrict msg_ptr, size_t msg_len, unsigned *restrict msg_prio, const struct timespec *restrict abs_timeout)" +mq_timedsend,dandelionSDK/libc_extension/mqueue.c,77,libc_extension,explicit_errno_stub,ENOSYS,"int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *abs_timeout)" +mq_unlink,dandelionSDK/libc_extension/mqueue.c,88,libc_extension,explicit_errno_stub,ENOSYS,int mq_unlink(const char *name) +if_freenameindex,dandelionSDK/libc_extension/net_if.c,4,libc_extension,explicit_errno_stub,ENOSYS,void if_freenameindex(struct if_nameindex *ptr) +if_indextoname,dandelionSDK/libc_extension/net_if.c,9,libc_extension,explicit_errno_stub,ENOSYS,"char *if_indextoname(unsigned ifindex, char *ifname)" +if_nameindex,dandelionSDK/libc_extension/net_if.c,16,libc_extension,explicit_errno_stub,ENOSYS,struct if_nameindex *if_nameindex(void) +if_nametoindex,dandelionSDK/libc_extension/net_if.c,21,libc_extension,explicit_errno_stub,ENOSYS,unsigned if_nametoindex(const char *ifname) +gethostbyaddr,dandelionSDK/libc_extension/netdb.c,14,libc_extension,explicit_errno_stub,ENOSYS,"struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len, int __type)" +gethostbyname,dandelionSDK/libc_extension/netdb.c,22,libc_extension,explicit_errno_stub,ENOSYS,struct hostent *gethostbyname (const char *__name) +gethostent,dandelionSDK/libc_extension/netdb.c,28,libc_extension,explicit_errno_stub,ENOSYS,struct hostent *gethostent (void) +getnetbyaddr,dandelionSDK/libc_extension/netdb.c,33,libc_extension,explicit_errno_stub,ENOSYS,"struct netent *getnetbyaddr (uint32_t __net, int __type)" +getnetbyname,dandelionSDK/libc_extension/netdb.c,40,libc_extension,explicit_errno_stub,ENOSYS,struct netent *getnetbyname (const char *__name) +getnetent,dandelionSDK/libc_extension/netdb.c,46,libc_extension,explicit_errno_stub,ENOSYS,struct netent *getnetent (void) +getprotobyname,dandelionSDK/libc_extension/netdb.c,51,libc_extension,explicit_errno_stub,ENOSYS,struct protoent *getprotobyname (const char *__name) +getprotobynumber,dandelionSDK/libc_extension/netdb.c,57,libc_extension,explicit_errno_stub,ENOSYS,struct protoent *getprotobynumber (int __proto) +getprotoent,dandelionSDK/libc_extension/netdb.c,63,libc_extension,explicit_errno_stub,ENOSYS,struct protoent *getprotoent (void) +getservbyname,dandelionSDK/libc_extension/netdb.c,68,libc_extension,explicit_errno_stub,ENOSYS,"struct servent *getservbyname (const char *__name, const char *__proto)" +getservbyport,dandelionSDK/libc_extension/netdb.c,75,libc_extension,explicit_errno_stub,ENOSYS,"struct servent *getservbyport (int __port, const char *__proto)" +getservent,dandelionSDK/libc_extension/netdb.c,82,libc_extension,explicit_errno_stub,ENOSYS,struct servent *getservent (void) +getaddrinfo,dandelionSDK/libc_extension/netdb.c,99,libc_extension,explicit_errno_stub,ENOSYS,"int getaddrinfo(const char *__restrict __name, const char *__restrict __service, const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai)" +getnameinfo,dandelionSDK/libc_extension/netdb.c,111,libc_extension,explicit_errno_stub,ENOSYS,"int getnameinfo(const struct sockaddr *__restrict __sa, socklen_t __salen, char *__restrict __host, socklen_t __hostlen, char *__restrict __serv, socklen_t __servlen, int __flags)" +catclose,dandelionSDK/libc_extension/nl_types.c,4,libc_extension,explicit_errno_stub,ENOSYS,int catclose(nl_catd catd) +catgets,dandelionSDK/libc_extension/nl_types.c,10,libc_extension,explicit_errno_stub,ENOSYS,"char *catgets(nl_catd catd, int set_id, int msg_id, const char *s)" +catopen,dandelionSDK/libc_extension/nl_types.c,18,libc_extension,explicit_errno_stub,ENOSYS,"nl_catd catopen(const char *name, int oflag)" +poll,dandelionSDK/libc_extension/poll.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int poll(struct pollfd *fds, nfds_t nfds, int timeout)" +pthread_rwlock_destroy,dandelionSDK/libc_extension/pthread.c,4,libc_extension,explicit_errno_stub,ENOSYS,int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) +dn_expand,dandelionSDK/libc_extension/resolv.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int dn_expand(const unsigned char *msg, const unsigned char *eomorig, const unsigned char *comp_dn, char *exp_dn, int length)" +sched_yield,dandelionSDK/libc_extension/sched.c,4,libc_extension,explicit_errno_stub,ENOSYS,int sched_yield (void) +sched_getcpu,dandelionSDK/libc_extension/sched.c,9,libc_extension,explicit_errno_stub,ENOTSUP,int sched_getcpu(void) +sem_close,dandelionSDK/libc_extension/semaphore.c,5,libc_extension,explicit_errno_stub,ENOSYS,int sem_close(sem_t *sem) +sem_destroy,dandelionSDK/libc_extension/semaphore.c,11,libc_extension,explicit_errno_stub,ENOSYS,int sem_destroy(sem_t *sem) +sem_getvalue,dandelionSDK/libc_extension/semaphore.c,17,libc_extension,explicit_errno_stub,ENOSYS,"int sem_getvalue(sem_t *restrict sem, int *restrict sval)" +sem_init,dandelionSDK/libc_extension/semaphore.c,24,libc_extension,explicit_errno_stub,ENOSYS,"int sem_init(sem_t *sem, int pshared, unsigned value)" +sem_open,dandelionSDK/libc_extension/semaphore.c,32,libc_extension,explicit_errno_stub,ENOSYS,"sem_t *sem_open(const char *name, int oflag, ...)" +sem_post,dandelionSDK/libc_extension/semaphore.c,43,libc_extension,explicit_errno_stub,ENOSYS,int sem_post(sem_t *sem) +sem_timedwait,dandelionSDK/libc_extension/semaphore.c,49,libc_extension,explicit_errno_stub,ENOSYS,"int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict abs_timeout)" +sem_trywait,dandelionSDK/libc_extension/semaphore.c,57,libc_extension,explicit_errno_stub,ENOSYS,int sem_trywait(sem_t *sem) +sem_unlink,dandelionSDK/libc_extension/semaphore.c,63,libc_extension,explicit_errno_stub,ENOSYS,int sem_unlink(const char *name) +sem_wait,dandelionSDK/libc_extension/semaphore.c,69,libc_extension,explicit_errno_stub,ENOSYS,int sem_wait(sem_t *sem) +accept,dandelionSDK/libc_extension/socket.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len)" +bind,dandelionSDK/libc_extension/socket.c,10,libc_extension,explicit_errno_stub,ENOSYS,"int bind (int __fd, const struct sockaddr *__addr, socklen_t __len)" +connect,dandelionSDK/libc_extension/socket.c,16,libc_extension,explicit_errno_stub,ENOSYS,"int connect (int __fd, const struct sockaddr *__addr, socklen_t __len)" +getpeername,dandelionSDK/libc_extension/socket.c,22,libc_extension,explicit_errno_stub,ENOSYS,"int getpeername (int __fd, struct sockaddr *__addr, socklen_t *__len)" +getsockname,dandelionSDK/libc_extension/socket.c,28,libc_extension,explicit_errno_stub,ENOSYS,"int getsockname (int __fd, struct sockaddr *__addr, socklen_t *__len)" +getsockopt,dandelionSDK/libc_extension/socket.c,34,libc_extension,explicit_errno_stub,ENOSYS,"int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen)" +listen,dandelionSDK/libc_extension/socket.c,40,libc_extension,explicit_errno_stub,ENOSYS,"int listen (int __fd, int __n)" +recv,dandelionSDK/libc_extension/socket.c,46,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t recv (int __fd, void *__buf, size_t __n, int __flags)" +recvfrom,dandelionSDK/libc_extension/socket.c,52,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr *__addr, socklen_t *__addr_len)" +recvmsg,dandelionSDK/libc_extension/socket.c,58,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags)" +send,dandelionSDK/libc_extension/socket.c,64,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t send (int __fd, const void *__buf, size_t __n, int __flags)" +sendmsg,dandelionSDK/libc_extension/socket.c,70,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t sendmsg (int __fd, const struct msghdr *__message, int __flags)" +sendto,dandelionSDK/libc_extension/socket.c,76,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t sendto (int __fd, const void *__buf, size_t __n, int __flags, const struct sockaddr *__addr, socklen_t __addr_len)" +setsockopt,dandelionSDK/libc_extension/socket.c,82,libc_extension,explicit_errno_stub,ENOSYS,"int setsockopt (int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen)" +shutdown,dandelionSDK/libc_extension/socket.c,88,libc_extension,explicit_errno_stub,ENOSYS,"int shutdown (int __fd, int __how)" +socket,dandelionSDK/libc_extension/socket.c,94,libc_extension,explicit_errno_stub,ENOSYS,"int socket (int __domain, int __type, int __protocol)" +sockatmark,dandelionSDK/libc_extension/socket.c,100,libc_extension,explicit_errno_stub,ENOSYS,int sockatmark (int __fd) +socketpair,dandelionSDK/libc_extension/socket.c,106,libc_extension,explicit_errno_stub,ENOSYS,"int socketpair (int __domain, int __type, int __protocol, int __fds[2])" +ftok,dandelionSDK/libc_extension/sys_ipc.c,4,libc_extension,explicit_errno_stub,ENOSYS,"key_t ftok(const char *path, int id)" +mmap,dandelionSDK/libc_extension/sys_mman.c,4,libc_extension,explicit_errno_stub,ENOSYS,"void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)" +mprotect,dandelionSDK/libc_extension/sys_mman.c,15,libc_extension,explicit_errno_stub,ENOSYS,"int mprotect(void *addr, size_t len, int prot)" +msync,dandelionSDK/libc_extension/sys_mman.c,23,libc_extension,explicit_errno_stub,ENOSYS,"int msync(void *addr, size_t len, int flags)" +munmap,dandelionSDK/libc_extension/sys_mman.c,31,libc_extension,explicit_errno_stub,ENOSYS,"int munmap(void *addr, size_t len)" +mlock,dandelionSDK/libc_extension/sys_mman.c,38,libc_extension,explicit_errno_stub,ENOSYS,"int mlock(const void *addr, size_t len)" +mlockall,dandelionSDK/libc_extension/sys_mman.c,45,libc_extension,explicit_errno_stub,ENOSYS,int mlockall(int flags) +munlock,dandelionSDK/libc_extension/sys_mman.c,51,libc_extension,explicit_errno_stub,ENOSYS,"int munlock(const void *addr, size_t len)" +munlockall,dandelionSDK/libc_extension/sys_mman.c,58,libc_extension,explicit_errno_stub,ENOSYS,int munlockall(void) +posix_madvise,dandelionSDK/libc_extension/sys_mman.c,63,libc_extension,explicit_errno_stub,ENOSYS,"int posix_madvise(void *addr, size_t len, int advice)" +shm_open,dandelionSDK/libc_extension/sys_mman.c,71,libc_extension,explicit_errno_stub,ENOSYS,"int shm_open(const char *name, int oflag, mode_t mode)" +shm_unlink,dandelionSDK/libc_extension/sys_mman.c,79,libc_extension,explicit_errno_stub,ENOSYS,int shm_unlink(const char *name) +msgctl,dandelionSDK/libc_extension/sys_msg.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int msgctl(int msqid, int cmd, struct msqid_ds *buf)" +msgget,dandelionSDK/libc_extension/sys_msg.c,12,libc_extension,explicit_errno_stub,ENOSYS,"int msgget(key_t key, int msgflg)" +msgrcv,dandelionSDK/libc_extension/sys_msg.c,19,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)" +msgsnd,dandelionSDK/libc_extension/sys_msg.c,29,libc_extension,explicit_errno_stub,ENOSYS,"int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)" +semctl,dandelionSDK/libc_extension/sys_sem.c,5,libc_extension,explicit_errno_stub,ENOSYS,"int semctl(int semid, int semnum, int cmd, ...)" +semget,dandelionSDK/libc_extension/sys_sem.c,17,libc_extension,explicit_errno_stub,ENOSYS,"int semget(key_t key, int nsems, int semflg)" +semop,dandelionSDK/libc_extension/sys_sem.c,25,libc_extension,explicit_errno_stub,ENOSYS,"int semop(int semid, struct sembuf *sops, size_t nsops)" +shmat,dandelionSDK/libc_extension/sys_shm.c,4,libc_extension,explicit_errno_stub,ENOSYS,"void *shmat(int shmid, const void *shmaddr, int shmflg)" +shmctl,dandelionSDK/libc_extension/sys_shm.c,12,libc_extension,explicit_errno_stub,ENOSYS,"int shmctl(int shmid, int cmd, struct shmid_ds *buf)" +shmdt,dandelionSDK/libc_extension/sys_shm.c,20,libc_extension,explicit_errno_stub,ENOSYS,int shmdt(const void *shmaddr) +shmget,dandelionSDK/libc_extension/sys_shm.c,26,libc_extension,explicit_errno_stub,ENOSYS,"int shmget(key_t key, size_t size, int shmflg)" +syscall,dandelionSDK/libc_extension/sys_syscall.c,3,libc_extension,explicit_errno_stub,ENOSYS,"long syscall(long number, ...)" +cfgetispeed,dandelionSDK/libc_extension/sys_termios.c,4,libc_extension,explicit_errno_stub,ENOSYS,speed_t cfgetispeed(const struct termios *termios_p) +cfgetospeed,dandelionSDK/libc_extension/sys_termios.c,10,libc_extension,explicit_errno_stub,ENOSYS,speed_t cfgetospeed(const struct termios *termios_p) +cfsetispeed,dandelionSDK/libc_extension/sys_termios.c,16,libc_extension,explicit_errno_stub,ENOSYS,"int cfsetispeed(struct termios *termios_p, speed_t speed)" +cfsetospeed,dandelionSDK/libc_extension/sys_termios.c,23,libc_extension,explicit_errno_stub,ENOSYS,"int cfsetospeed(struct termios *termios_p, speed_t speed)" +tcdrain,dandelionSDK/libc_extension/sys_termios.c,30,libc_extension,explicit_errno_stub,ENOSYS,int tcdrain(int fd) +tcflow,dandelionSDK/libc_extension/sys_termios.c,36,libc_extension,explicit_errno_stub,ENOSYS,"int tcflow(int fd, int action)" +tcflush,dandelionSDK/libc_extension/sys_termios.c,43,libc_extension,explicit_errno_stub,ENOSYS,"int tcflush(int fd, int queue_selector)" +tcgetattr,dandelionSDK/libc_extension/sys_termios.c,50,libc_extension,explicit_errno_stub,ENOSYS,"int tcgetattr(int fd, struct termios *termios_p)" +tcgetsid,dandelionSDK/libc_extension/sys_termios.c,57,libc_extension,explicit_errno_stub,ENOSYS,pid_t tcgetsid(int fd) +tcsendbreak,dandelionSDK/libc_extension/sys_termios.c,63,libc_extension,explicit_errno_stub,ENOSYS,"int tcsendbreak(int fd, int duration)" +tcsetattr,dandelionSDK/libc_extension/sys_termios.c,70,libc_extension,explicit_errno_stub,ENOSYS,"int tcsetattr(int fd, int optional_actions, const struct termios *termios_p)" +uname,dandelionSDK/libc_extension/sys_utsname.c,4,libc_extension,explicit_errno_stub,ENOSYS,int uname(struct utsname *buf) +closelog,dandelionSDK/libc_extension/syslog.c,4,libc_extension,explicit_errno_stub,ENOSYS,void closelog(void) +openlog,dandelionSDK/libc_extension/syslog.c,8,libc_extension,explicit_errno_stub,ENOSYS,"void openlog(const char *ident, int option, int facility)" +setlogmask,dandelionSDK/libc_extension/syslog.c,15,libc_extension,explicit_errno_stub,ENOSYS,int setlogmask(int maskpri) +syslog,dandelionSDK/libc_extension/syslog.c,21,libc_extension,explicit_errno_stub,ENOSYS,"void syslog(int priority, const char *format, ...)" +readv,dandelionSDK/libc_extension/uio.c,4,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t readv (int __fd, const struct iovec *__iovec, int __count)" +writev,dandelionSDK/libc_extension/uio.c,12,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t writev (int __fd, const struct iovec *__iovec, int __count)" +endutxent,dandelionSDK/libc_extension/utmpx.c,4,libc_extension,explicit_errno_stub,ENOSYS,void endutxent(void) +getutxent,dandelionSDK/libc_extension/utmpx.c,6,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *getutxent(void) +getutxid,dandelionSDK/libc_extension/utmpx.c,11,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *getutxid(const struct utmpx *id) +getutxline,dandelionSDK/libc_extension/utmpx.c,17,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *getutxline(const struct utmpx *line) +pututxline,dandelionSDK/libc_extension/utmpx.c,23,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *pututxline(const struct utmpx *utmpx) +setutxent,dandelionSDK/libc_extension/utmpx.c,29,libc_extension,explicit_errno_stub,ENOSYS,void setutxent(void) diff --git a/libc_test/scripts/stub_inventory/newlib_shim_manual_stubbed_functions.csv b/libc_test/scripts/stub_inventory/newlib_shim_manual_stubbed_functions.csv new file mode 100644 index 0000000..52fd482 --- /dev/null +++ b/libc_test/scripts/stub_inventory/newlib_shim_manual_stubbed_functions.csv @@ -0,0 +1,149 @@ +function,file,line,source_area,stub_kind,evidence,signature +pthread_mutexattr_init,dandelionSDK/newlib_shim/pthread.c,16,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_mutexattr_init(pthread_mutexattr_t *attr)" +pthread_mutexattr_destroy,dandelionSDK/newlib_shim/pthread.c,17,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)" +pthread_mutexattr_setpshared,dandelionSDK/newlib_shim/pthread.c,18,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)" +pthread_mutexattr_gettype,dandelionSDK/newlib_shim/pthread.c,24,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict attr, int *restrict type)" +pthread_mutexattr_settype,dandelionSDK/newlib_shim/pthread.c,28,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)" +pthread_mutexattr_getrobust,dandelionSDK/newlib_shim/pthread.c,31,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict attr, int *restrict robust)" +pthread_mutexattr_setrobust,dandelionSDK/newlib_shim/pthread.c,38,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust)" +pthread_mutexattr_getprotocol,dandelionSDK/newlib_shim/pthread.c,44,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict attr, int *restrict protocol)" +pthread_mutexattr_setprotocol,dandelionSDK/newlib_shim/pthread.c,51,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol)" +pthread_mutex_timedlock,dandelionSDK/newlib_shim/pthread.c,96,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutex_timedlock(pthread_mutex_t *restrict mutex, const struct timespec *restrict timeout)" +pthread_mutex_consistent,dandelionSDK/newlib_shim/pthread.c,115,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutex_consistent(pthread_mutex_t *mutex)" +pthread_rwlock_init,dandelionSDK/newlib_shim/pthread.c,120,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlockattr_t *restrict attr)" +pthread_rwlock_destry,dandelionSDK/newlib_shim/pthread.c,124,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_rwlock_destry(pthread_rwlock_t *rwlock)" +pthread_rwlock_rdlock,dandelionSDK/newlib_shim/pthread.c,125,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)" +pthread_rwlock_tryrdlock,dandelionSDK/newlib_shim/pthread.c,126,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)" +pthread_rwlock_wrlock,dandelionSDK/newlib_shim/pthread.c,127,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)" +pthread_rwlock_trywrlock,dandelionSDK/newlib_shim/pthread.c,128,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)" +pthread_rwlock_unlock,dandelionSDK/newlib_shim/pthread.c,129,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)" +pthread_cond_init,dandelionSDK/newlib_shim/pthread.c,131,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EAGAIN,"int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr)" +pthread_cond_destroy,dandelionSDK/newlib_shim/pthread.c,135,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_cond_destroy(pthread_cond_t *cond)" +pthread_condattr_init,dandelionSDK/newlib_shim/pthread.c,136,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_condattr_init(pthread_condattr_t *attr)" +pthread_condattr_destroy,dandelionSDK/newlib_shim/pthread.c,141,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_condattr_destroy(pthread_condattr_t *attr)" +pthread_condattr_getclock,dandelionSDK/newlib_shim/pthread.c,146,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_condattr_getclock(const pthread_condattr_t *restrict attr, clockid_t *restrict clock_id)" +pthread_condattr_setclock,dandelionSDK/newlib_shim/pthread.c,153,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id)" +pthread_cond_wait,dandelionSDK/newlib_shim/pthread.c,159,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOTRECOVERABLE,"int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex)" +pthread_cond_timedwait,dandelionSDK/newlib_shim/pthread.c,163,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOTRECOVERABLE,"int pthread_cond_timedwait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstim)" +pthread_cond_signal,dandelionSDK/newlib_shim/pthread.c,168,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_cond_signal(pthread_cond_t *cond)" +pthread_cond_broadcast,dandelionSDK/newlib_shim/pthread.c,169,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_cond_broadcast(pthread_cond_t *cond)" +pthread_barrier_init,dandelionSDK/newlib_shim/pthread.c,171,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count)" +pthread_barrier_destroy,dandelionSDK/newlib_shim/pthread.c,180,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_barrier_destroy(pthread_barrier_t *barrier)" +pthread_barrier_wait,dandelionSDK/newlib_shim/pthread.c,185,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_barrier_wait(pthread_barrier_t *barrier)" +pthread_create,dandelionSDK/newlib_shim/pthread.c,200,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void *), void *restrict arg)" +pthread_join,dandelionSDK/newlib_shim/pthread.c,205,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_join(pthread_t thread, void **retval)" +pthread_detach,dandelionSDK/newlib_shim/pthread.c,206,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_detach(pthread_t thread)" +pthread_cancel,dandelionSDK/newlib_shim/pthread.c,208,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_cancel(pthread_t thread)" +pthread_kill,dandelionSDK/newlib_shim/pthread.c,214,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_kill(pthread_t thread, int sig)" +pthread_setcancelstate,dandelionSDK/newlib_shim/pthread.c,221,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_setcancelstate(int state, int *oldstate)" +pthread_setcanceltype,dandelionSDK/newlib_shim/pthread.c,230,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_setcanceltype(int type, int *oldtype)" +pthread_testcancel,dandelionSDK/newlib_shim/pthread.c,239,newlib_shim,explicit_errno_stub,ENOSYS,"void pthread_testcancel(void)" +pthread_exit,dandelionSDK/newlib_shim/pthread.c,241,newlib_shim,explicit_errno_stub,ENOSYS,"void pthread_exit(void *value_ptr)" +_pthread_cleanup_push,dandelionSDK/newlib_shim/pthread.c,247,newlib_shim,explicit_errno_stub,ENOSYS,"void _pthread_cleanup_push(struct _pthread_cleanup_context *context, void (*routine)(void *), void *arg)" +_pthread_cleanup_pop,dandelionSDK/newlib_shim/pthread.c,255,newlib_shim,explicit_errno_stub,ENOSYS,"void _pthread_cleanup_pop(struct _pthread_cleanup_context *context, int execute)" +pthread_atfork,dandelionSDK/newlib_shim/pthread.c,337,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOMEM,"int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))" +insque,dandelionSDK/newlib_shim/search.c,7,newlib_shim,explicit_errno_stub,ENOSYS,"void insque(void *elem, void *prev)" +lfind,dandelionSDK/newlib_shim/search.c,13,newlib_shim,explicit_errno_stub,ENOSYS,"void *lfind(const void *key, const void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *))" +lsearch,dandelionSDK/newlib_shim/search.c,24,newlib_shim,explicit_errno_stub,ENOSYS,"void *lsearch(const void *key, void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *))" +remque,dandelionSDK/newlib_shim/search.c,35,newlib_shim,explicit_errno_stub,ENOSYS,"void remque(void *elem)" +execve,dandelionSDK/newlib_shim/shim.c,217,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOMEM,"int execve(const char *name, char *const argv[], char *const env[])" +fcntl,dandelionSDK/newlib_shim/shim.c,222,newlib_shim,explicit_errno_stub,ENOSYS,"int fcntl(int fd, int op, ...)" +siglongjmp,dandelionSDK/newlib_shim/shim.c,229,newlib_shim,manual_placeholder_stub,prints error and exits instead of siglongjmp,"void siglongjmp(sigjmp_buf env, int val)" +posix_fadvise,dandelionSDK/newlib_shim/shim.c,236,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_fadvise(int fd, off_t offset, off_t len, int advice)" +posix_fallocate,dandelionSDK/newlib_shim/shim.c,245,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_fallocate(int fd, off_t offset, off_t len)" +clearenv,dandelionSDK/newlib_shim/shim.c,253,newlib_shim,explicit_errno_stub,ENOSYS,"int clearenv(void)" +nexttoward,dandelionSDK/newlib_shim/shim.c,258,newlib_shim,explicit_errno_stub,ENOSYS,"double nexttoward(double x, long double y)" +nexttowardf,dandelionSDK/newlib_shim/shim.c,265,newlib_shim,explicit_errno_stub,ENOSYS,"float nexttowardf(float x, long double y)" +nexttowardl,dandelionSDK/newlib_shim/shim.c,272,newlib_shim,explicit_errno_stub,ENOSYS,"long double nexttowardl(long double x, long double y)" +getdelim,dandelionSDK/newlib_shim/shim.c,279,newlib_shim,explicit_errno_stub,ENOSYS,"ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter, FILE *restrict stream)" +getline,dandelionSDK/newlib_shim/shim.c,289,newlib_shim,explicit_errno_stub,ENOSYS,"ssize_t getline(char **restrict lineptr, size_t *restrict n, FILE *restrict stream)" +fork,dandelionSDK/newlib_shim/shim.c,298,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EAGAIN,"int fork()" +grantpt,dandelionSDK/newlib_shim/shim.c,303,newlib_shim,explicit_errno_stub,ENOSYS,"int grantpt(int fd)" +basename,dandelionSDK/newlib_shim/shim.c,309,newlib_shim,explicit_errno_stub,ENOSYS,"char *basename(char *path)" +dirname,dandelionSDK/newlib_shim/shim.c,315,newlib_shim,explicit_errno_stub,ENOSYS,"char *dirname(char *path)" +getppid,dandelionSDK/newlib_shim/shim.c,323,newlib_shim,explicit_errno_stub,ENOSYS,"pid_t getppid(void)" +getegid,dandelionSDK/newlib_shim/shim.c,328,newlib_shim,explicit_errno_stub,ENOSYS,"gid_t getegid(void)" +geteuid,dandelionSDK/newlib_shim/shim.c,333,newlib_shim,explicit_errno_stub,ENOSYS,"uid_t geteuid(void)" +fnmatch,dandelionSDK/newlib_shim/shim.c,338,newlib_shim,explicit_errno_stub,ENOSYS,"int fnmatch(const char *pattern, const char *string, int flags)" +iconv_open,dandelionSDK/newlib_shim/shim.c,346,newlib_shim,explicit_errno_stub,ENOSYS,"iconv_t iconv_open(const char *tocode, const char *fromcode)" +iconv,dandelionSDK/newlib_shim/shim.c,353,newlib_shim,explicit_errno_stub,ENOSYS,"size_t iconv(iconv_t cd, char **__restrict inbuf, size_t *__restrict inbytesleft, char **__restrict outbuf, size_t *__restrict outbytesleft)" +iconv_close,dandelionSDK/newlib_shim/shim.c,364,newlib_shim,explicit_errno_stub,ENOSYS,"int iconv_close(iconv_t cd)" +popen,dandelionSDK/newlib_shim/shim.c,370,newlib_shim,explicit_errno_stub,ENOSYS,"FILE *popen(const char *command, const char *type)" +pclose,dandelionSDK/newlib_shim/shim.c,377,newlib_shim,explicit_errno_stub,ENOSYS,"int pclose(FILE *stream)" +flockfile,dandelionSDK/newlib_shim/shim.c,383,newlib_shim,explicit_errno_stub,ENOSYS,"void flockfile(FILE *stream)" +funlockfile,dandelionSDK/newlib_shim/shim.c,388,newlib_shim,explicit_errno_stub,ENOSYS,"void funlockfile(FILE *stream)" +posix_spawn_file_actions_init,dandelionSDK/newlib_shim/shim.c,393,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawn_file_actions_init(posix_spawn_file_actions_t *file_actions)" +posix_spawn_file_actions_addclose,dandelionSDK/newlib_shim/shim.c,399,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions, int fildes)" +posix_spawn_file_actions_adddup2,dandelionSDK/newlib_shim/shim.c,407,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *file_actions, int fildes, int newfildes)" +posix_spawn_file_actions_destroy,dandelionSDK/newlib_shim/shim.c,416,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *file_actions)" +posix_spawnp,dandelionSDK/newlib_shim/shim.c,422,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawnp(pid_t *restrict pid, const char *restrict file, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char *const envp[restrict])" +initstate,dandelionSDK/newlib_shim/shim.c,437,newlib_shim,explicit_errno_stub,ENOSYS,"char *initstate(unsigned seed, char *state, size_t size)" +setstate,dandelionSDK/newlib_shim/shim.c,445,newlib_shim,explicit_errno_stub,ENOSYS,"char *setstate(char *state)" +time,dandelionSDK/newlib_shim/shim.c,451,newlib_shim,explicit_errno_stub,ENOSYS,"time_t time(time_t *timer)" +futimens,dandelionSDK/newlib_shim/shim.c,459,newlib_shim,explicit_errno_stub,ENOSYS,"int futimens(int fd, const struct timespec times[2])" +utimensat,dandelionSDK/newlib_shim/shim.c,466,newlib_shim,explicit_errno_stub,ENOSYS,"int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags)" +getpwnam_r,dandelionSDK/newlib_shim/shim.c,476,newlib_shim,explicit_errno_stub,ENOSYS,"int getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t buflen, struct passwd **result)" +regcomp,dandelionSDK/newlib_shim/shim.c,489,newlib_shim,explicit_errno_stub,ENOSYS,"int regcomp(regex_t *restrict preg, const char *restrict pattern, int cflags)" +regerror,dandelionSDK/newlib_shim/shim.c,497,newlib_shim,explicit_errno_stub,ENOSYS,"size_t regerror(int errcode, const regex_t *restrict preg, char *restrict errbuf, size_t errbuf_size)" +regexec,dandelionSDK/newlib_shim/shim.c,508,newlib_shim,explicit_errno_stub,ENOSYS,"int regexec(const regex_t *restrict preg, const char *restrict string, size_t nmatch, regmatch_t pmatch[restrict], int eflags)" +regfree,dandelionSDK/newlib_shim/shim.c,519,newlib_shim,explicit_errno_stub,ENOSYS,"void regfree(regex_t *preg)" +exp10l,dandelionSDK/newlib_shim/shim.c,524,newlib_shim,explicit_errno_stub,ENOSYS,"long double exp10l(long double x)" +pow10l,dandelionSDK/newlib_shim/shim.c,530,newlib_shim,explicit_errno_stub,ENOSYS,"long double pow10l(long double x)" +sincosl,dandelionSDK/newlib_shim/shim.c,536,newlib_shim,explicit_errno_stub,ENOSYS,"void sincosl(long double x, long double *sinx, long double *cosx)" +__kernel_tanl,dandelionSDK/newlib_shim/shim.c,547,newlib_shim,explicit_errno_stub,ENOSYS,"long double __kernel_tanl(long double x, long double y, int iy)" +__pleval,dandelionSDK/newlib_shim/shim.c,555,newlib_shim,explicit_errno_stub,ENOSYS,"unsigned long __pleval(const char *expr, unsigned long n)" +waitpid,dandelionSDK/newlib_shim/shim.c,562,newlib_shim,explicit_errno_stub,ENOSYS,"pid_t waitpid(pid_t pid, int *status, int options)" +waitid,dandelionSDK/newlib_shim/shim.c,570,newlib_shim,explicit_errno_stub,ENOSYS,"int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options)" +getpriority,dandelionSDK/newlib_shim/shim.c,579,newlib_shim,explicit_errno_stub,ENOSYS,"int getpriority(int which, id_t who)" +getrlimit,dandelionSDK/newlib_shim/shim.c,586,newlib_shim,explicit_errno_stub,ENOSYS,"int getrlimit(int resource, struct rlimit *rlim)" +getrusage,dandelionSDK/newlib_shim/shim.c,593,newlib_shim,explicit_errno_stub,ENOSYS,"int getrusage(int who, struct rusage *usage)" +gettimeofday,dandelionSDK/newlib_shim/shim.c,600,newlib_shim,explicit_errno_stub,ENOSYS,"int gettimeofday(struct timeval *restrict p, void *restrict tz)" +kill,dandelionSDK/newlib_shim/shim.c,607,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int kill(int pid, int sig)" +pipe,dandelionSDK/newlib_shim/shim.c,612,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EFAULT,"int pipe(int pipefd[2])" +posix_openpt,dandelionSDK/newlib_shim/shim.c,617,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_openpt(int flags)" +ptsname,dandelionSDK/newlib_shim/shim.c,623,newlib_shim,explicit_errno_stub,ENOSYS,"char *ptsname(int fd)" +setpriority,dandelionSDK/newlib_shim/shim.c,629,newlib_shim,explicit_errno_stub,ENOSYS,"int setpriority(int which, id_t who, int prio)" +setrlimit,dandelionSDK/newlib_shim/shim.c,637,newlib_shim,explicit_errno_stub,ENOSYS,"int setrlimit(int resource, const struct rlimit *rlim)" +readlink,dandelionSDK/newlib_shim/shim.c,644,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,"ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize)" +realpath,dandelionSDK/newlib_shim/shim.c,650,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,"char *realpath(const char *path, char *resolved_path)" +sigaction,dandelionSDK/newlib_shim/shim.c,655,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int sigaction(int signum, const struct sigaction *_Nullable restrict act, struct sigaction *_Nullable restrict oldact)" +sysconf,dandelionSDK/newlib_shim/shim.c,661,newlib_shim,explicit_errno_stub,ENOSYS,"long sysconf(int name)" +times,dandelionSDK/newlib_shim/shim.c,667,newlib_shim,explicit_errno_stub,ENOSYS,"clock_t times(struct tms *buf)" +unlockpt,dandelionSDK/newlib_shim/shim.c,673,newlib_shim,explicit_errno_stub,ENOSYS,"int unlockpt(int fd)" +wait,dandelionSDK/newlib_shim/shim.c,679,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ECHILD,"int wait(int *status)" +wordexp,dandelionSDK/newlib_shim/shim.c,684,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure WRDE_NOSPACE,"int wordexp(const char *s, wordexp_t *p, int flags)" +sighold,dandelionSDK/newlib_shim/signal_dandelion.c,14,newlib_shim,explicit_errno_stub,ENOSYS,"int sighold(int sig)" +sigignore,dandelionSDK/newlib_shim/signal_dandelion.c,20,newlib_shim,explicit_errno_stub,ENOSYS,"int sigignore(int sig)" +siginterrupt,dandelionSDK/newlib_shim/signal_dandelion.c,26,newlib_shim,explicit_errno_stub,ENOSYS,"int siginterrupt(int sig, int flag)" +sigrelse,dandelionSDK/newlib_shim/signal_dandelion.c,33,newlib_shim,explicit_errno_stub,ENOSYS,"int sigrelse(int sig)" +sigset,dandelionSDK/newlib_shim/signal_dandelion.c,39,newlib_shim,explicit_errno_stub,ENOSYS,"_sig_func_ptr sigset(int sig, _sig_func_ptr disp)" +pthread_sigmask,dandelionSDK/newlib_shim/signal_dandelion.c,46,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict oldset)" +sigaddset,dandelionSDK/newlib_shim/signal_dandelion.c,57,newlib_shim,explicit_errno_stub,ENOSYS,"int sigaddset(sigset_t *set, int signo)" +sigemptyset,dandelionSDK/newlib_shim/signal_dandelion.c,64,newlib_shim,explicit_errno_stub,ENOSYS,"int sigemptyset(sigset_t *set)" +sigismember,dandelionSDK/newlib_shim/signal_dandelion.c,72,newlib_shim,explicit_errno_stub,ENOSYS,"int sigismember(const sigset_t *set, int signo)" +sigprocmask,dandelionSDK/newlib_shim/signal_dandelion.c,79,newlib_shim,explicit_errno_stub,ENOSYS,"int sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict oldset)" +sigaltstack,dandelionSDK/newlib_shim/signal_dandelion.c,90,newlib_shim,explicit_errno_stub,ENOSYS,"int sigaltstack(const stack_t *restrict ss, stack_t *restrict old_ss)" +getdate,dandelionSDK/newlib_shim/time.c,34,newlib_shim,explicit_errno_stub,ENOSYS,"struct tm *getdate(const char *string)" +getdate_r,dandelionSDK/newlib_shim/time.c,41,newlib_shim,explicit_errno_stub,ENOSYS,"int getdate_r(const char *string, struct tm *result)" +clock_settime,dandelionSDK/newlib_shim/time.c,49,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int clock_settime(clockid_t clock_id, const struct timespec *tp)" +clock_getres,dandelionSDK/newlib_shim/time.c,68,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int clock_getres(clockid_t clock_id, struct timespec *res)" +timer_create,dandelionSDK/newlib_shim/time.c,75,newlib_shim,explicit_errno_stub,ENOTSUP,"int timer_create(clockid_t clock_id, struct sigevent *__restrict evp, timer_t *__restrict timerid)" +timer_delete,dandelionSDK/newlib_shim/time.c,83,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int timer_delete(timer_t timerid)" +timer_settime,dandelionSDK/newlib_shim/time.c,90,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict value, struct itimerspec *__restrict ovalue)" +timer_gettime,dandelionSDK/newlib_shim/time.c,97,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int timer_gettime(timer_t timerid, struct itimerspec *value)" +timer_getoverrun,dandelionSDK/newlib_shim/time.c,102,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int timer_getoverrun(timer_t timerid)" +chdir,dandelionSDK/newlib_shim/unistd.c,8,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,"int chdir(const char *__path)" +fchdir,dandelionSDK/newlib_shim/unistd.c,12,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,"int fchdir(int __fildes)" +chroot,dandelionSDK/newlib_shim/unistd.c,17,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,"int chroot(const char *__path)" +daemon,dandelionSDK/newlib_shim/unistd.c,35,newlib_shim,explicit_errno_stub,ENOSYS,"int daemon(int nochdir, int noclose)" +dup3,dandelionSDK/newlib_shim/unistd.c,48,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EMFILE,"int dup3(int __fildes, int __fildes2, int flags)" +dup2,dandelionSDK/newlib_shim/unistd.c,52,newlib_shim,manual_placeholder_stub,delegates to dup3 placeholder failure EMFILE,"int dup2(int __fildes, int __fildes2)" +dup,dandelionSDK/newlib_shim/unistd.c,53,newlib_shim,manual_placeholder_stub,delegates to dup3 placeholder failure EMFILE,"int dup(int __fildes)" +execl,dandelionSDK/newlib_shim/unistd.c,64,newlib_shim,explicit_errno_stub,ENOSYS,"int execl(const char *__path, const char *arg, ...)" +execle,dandelionSDK/newlib_shim/unistd.c,70,newlib_shim,explicit_errno_stub,ENOSYS,"int execle(const char *__path, const char *arg, ...)" +execv,dandelionSDK/newlib_shim/unistd.c,80,newlib_shim,manual_placeholder_stub,delegates to execve placeholder failure ENOMEM,"int execv(const char *__path, char *const __argv[])" +setgroups,dandelionSDK/newlib_shim/unistd.c,172,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int setgroups(int ngroups, const gid_t *grouplist)" +sleep,dandelionSDK/newlib_shim/unistd.c,192,newlib_shim,explicit_errno_stub,ENOSYS,"unsigned sleep(unsigned int __seconds)" +vfork,dandelionSDK/newlib_shim/unistd.c,225,newlib_shim,explicit_errno_stub,ENOSYS,"pid_t vfork(void)" +symlink,dandelionSDK/newlib_shim/unistd.c,258,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int symlink(const char *__name1, const char *__name2)" +mknod,dandelionSDK/newlib_shim/unistd.c,263,newlib_shim,explicit_errno_stub,ENOSYS,"int mknod(const char *__path, mode_t __mode, dev_t __dev)" diff --git a/libc_test/scripts/stub_inventory/stubbed_functions.csv b/libc_test/scripts/stub_inventory/stubbed_functions.csv new file mode 100644 index 0000000..f149cc5 --- /dev/null +++ b/libc_test/scripts/stub_inventory/stubbed_functions.csv @@ -0,0 +1,290 @@ +function,file,line,source_area,stub_kind,evidence,signature +aio_cancel,dandelionSDK/libc_extension/aio.c,7,libc_extension,explicit_errno_stub,ENOSYS,"int aio_cancel(int fd, struct aiocb *aiocbp)" +aio_error,dandelionSDK/libc_extension/aio.c,14,libc_extension,explicit_errno_stub,ENOSYS,int aio_error(const struct aiocb *aiocbp) +aio_fsync,dandelionSDK/libc_extension/aio.c,20,libc_extension,explicit_errno_stub,ENOSYS,"int aio_fsync(int op, struct aiocb *aiocbp)" +aio_read,dandelionSDK/libc_extension/aio.c,27,libc_extension,explicit_errno_stub,ENOSYS,int aio_read(struct aiocb *aiocbp) +aio_return,dandelionSDK/libc_extension/aio.c,33,libc_extension,explicit_errno_stub,ENOSYS,ssize_t aio_return(struct aiocb *aiocbp) +aio_suspend,dandelionSDK/libc_extension/aio.c,39,libc_extension,explicit_errno_stub,ENOSYS,"int aio_suspend(const struct aiocb *const aiocb_list[], int nitems, const struct timespec *timeout)" +aio_write,dandelionSDK/libc_extension/aio.c,48,libc_extension,explicit_errno_stub,ENOSYS,int aio_write(struct aiocb *aiocbp) +lio_listio,dandelionSDK/libc_extension/aio.c,54,libc_extension,explicit_errno_stub,ENOSYS,"int lio_listio(int mode, struct aiocb *restrict const list[restrict], int nent, struct sigevent *restrict sig)" +htonl,dandelionSDK/libc_extension/arpa_inet.c,4,libc_extension,explicit_errno_stub,ENOSYS,uint32_t htonl(uint32_t hostlong) +inet_addr,dandelionSDK/libc_extension/arpa_inet.c,10,libc_extension,explicit_errno_stub,ENOSYS,in_addr_t inet_addr(const char *cp) +inet_ntoa,dandelionSDK/libc_extension/arpa_inet.c,16,libc_extension,explicit_errno_stub,ENOSYS,char *inet_ntoa(struct in_addr in) +inet_ntop,dandelionSDK/libc_extension/arpa_inet.c,22,libc_extension,explicit_errno_stub,ENOSYS,"const char *inet_ntop(int af, const void *restrict src, char *restrict dst, socklen_t size)" +inet_pton,dandelionSDK/libc_extension/arpa_inet.c,32,libc_extension,explicit_errno_stub,ENOSYS,"int inet_pton(int af, const char *restrict src, void *restrict dst)" +crypt,dandelionSDK/libc_extension/crypt.c,4,libc_extension,explicit_errno_stub,ENOSYS,"char *crypt(const char *phrase, const char *setting)" +dlclose,dandelionSDK/libc_extension/dlfcn.c,4,libc_extension,explicit_errno_stub,ENOSYS,int dlclose(void *handle) +dlerror,dandelionSDK/libc_extension/dlfcn.c,10,libc_extension,explicit_errno_stub,ENOSYS,char *dlerror(void) +dlopen,dandelionSDK/libc_extension/dlfcn.c,15,libc_extension,explicit_errno_stub,ENOSYS,"void *dlopen(const char *file, int mode)" +dlsym,dandelionSDK/libc_extension/dlfcn.c,22,libc_extension,explicit_errno_stub,ENOSYS,"void *dlsym(void *restrict handle, const char *restrict name)" +getifaddrs,dandelionSDK/libc_extension/ifaddrs.c,4,libc_extension,explicit_errno_stub,ENOSYS,int getifaddrs (struct ifaddrs **__ifap) +statvfs,dandelionSDK/libc_extension/include/sys/statvfs.h,31,include,explicit_errno_stub,ENOSYS,"int statvfs(const char *path, struct statvfs *buf)" +fstatvfs,dandelionSDK/libc_extension/include/sys/statvfs.h,35,include,explicit_errno_stub,ENOSYS,"int fstatvfs(int fd, struct statvfs *buf)" +setmntent,dandelionSDK/libc_extension/mntent.c,4,libc_extension,explicit_errno_stub,ENOSYS,"FILE *setmntent(const char *file, const char *mode)" +getmntent,dandelionSDK/libc_extension/mntent.c,11,libc_extension,explicit_errno_stub,ENOSYS,struct mntent *getmntent(FILE *stream) +getmntent_r,dandelionSDK/libc_extension/mntent.c,17,libc_extension,explicit_errno_stub,ENOSYS,"struct mntent *getmntent_r(FILE *stream, struct mntent *result, char *buffer, int bufsize)" +addmntent,dandelionSDK/libc_extension/mntent.c,27,libc_extension,explicit_errno_stub,ENOSYS,"int addmntent(FILE *stream, const struct mntent *mnt)" +endmntent,dandelionSDK/libc_extension/mntent.c,34,libc_extension,explicit_errno_stub,ENOSYS,int endmntent(FILE *stream) +hasmntopt,dandelionSDK/libc_extension/mntent.c,40,libc_extension,explicit_errno_stub,ENOSYS,"char *hasmntopt(const struct mntent *mnt, const char *opt)" +strfmon,dandelionSDK/libc_extension/monetary.c,4,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t strfmon(char *restrict s, size_t max, const char *restrict format, ...)" +strfmon_l,dandelionSDK/libc_extension/monetary.c,12,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t strfmon_l(char *restrict s, size_t max, locale_t loc, const char *restrict format, ...)" +mq_close,dandelionSDK/libc_extension/mqueue.c,5,libc_extension,explicit_errno_stub,ENOSYS,int mq_close(mqd_t mqdes) +mq_getattr,dandelionSDK/libc_extension/mqueue.c,11,libc_extension,explicit_errno_stub,ENOSYS,"int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat)" +mq_notify,dandelionSDK/libc_extension/mqueue.c,18,libc_extension,explicit_errno_stub,ENOSYS,"int mq_notify(mqd_t mqdes, const struct sigevent *notification)" +mq_open,dandelionSDK/libc_extension/mqueue.c,25,libc_extension,explicit_errno_stub,ENOSYS,"mqd_t mq_open(const char *name, int oflag, ...)" +mq_receive,dandelionSDK/libc_extension/mqueue.c,36,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)" +mq_send,dandelionSDK/libc_extension/mqueue.c,46,libc_extension,explicit_errno_stub,ENOSYS,"int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)" +mq_setattr,dandelionSDK/libc_extension/mqueue.c,56,libc_extension,explicit_errno_stub,ENOSYS,"int mq_setattr(mqd_t mqdes, const struct mq_attr *restrict mqstat, struct mq_attr *restrict omqstat)" +mq_timedreceive,dandelionSDK/libc_extension/mqueue.c,65,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t mq_timedreceive(mqd_t mqdes, char *restrict msg_ptr, size_t msg_len, unsigned *restrict msg_prio, const struct timespec *restrict abs_timeout)" +mq_timedsend,dandelionSDK/libc_extension/mqueue.c,77,libc_extension,explicit_errno_stub,ENOSYS,"int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *abs_timeout)" +mq_unlink,dandelionSDK/libc_extension/mqueue.c,88,libc_extension,explicit_errno_stub,ENOSYS,int mq_unlink(const char *name) +if_freenameindex,dandelionSDK/libc_extension/net_if.c,4,libc_extension,explicit_errno_stub,ENOSYS,void if_freenameindex(struct if_nameindex *ptr) +if_indextoname,dandelionSDK/libc_extension/net_if.c,9,libc_extension,explicit_errno_stub,ENOSYS,"char *if_indextoname(unsigned ifindex, char *ifname)" +if_nameindex,dandelionSDK/libc_extension/net_if.c,16,libc_extension,explicit_errno_stub,ENOSYS,struct if_nameindex *if_nameindex(void) +if_nametoindex,dandelionSDK/libc_extension/net_if.c,21,libc_extension,explicit_errno_stub,ENOSYS,unsigned if_nametoindex(const char *ifname) +gethostbyaddr,dandelionSDK/libc_extension/netdb.c,14,libc_extension,explicit_errno_stub,ENOSYS,"struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len, int __type)" +gethostbyname,dandelionSDK/libc_extension/netdb.c,22,libc_extension,explicit_errno_stub,ENOSYS,struct hostent *gethostbyname (const char *__name) +gethostent,dandelionSDK/libc_extension/netdb.c,28,libc_extension,explicit_errno_stub,ENOSYS,struct hostent *gethostent (void) +getnetbyaddr,dandelionSDK/libc_extension/netdb.c,33,libc_extension,explicit_errno_stub,ENOSYS,"struct netent *getnetbyaddr (uint32_t __net, int __type)" +getnetbyname,dandelionSDK/libc_extension/netdb.c,40,libc_extension,explicit_errno_stub,ENOSYS,struct netent *getnetbyname (const char *__name) +getnetent,dandelionSDK/libc_extension/netdb.c,46,libc_extension,explicit_errno_stub,ENOSYS,struct netent *getnetent (void) +getprotobyname,dandelionSDK/libc_extension/netdb.c,51,libc_extension,explicit_errno_stub,ENOSYS,struct protoent *getprotobyname (const char *__name) +getprotobynumber,dandelionSDK/libc_extension/netdb.c,57,libc_extension,explicit_errno_stub,ENOSYS,struct protoent *getprotobynumber (int __proto) +getprotoent,dandelionSDK/libc_extension/netdb.c,63,libc_extension,explicit_errno_stub,ENOSYS,struct protoent *getprotoent (void) +getservbyname,dandelionSDK/libc_extension/netdb.c,68,libc_extension,explicit_errno_stub,ENOSYS,"struct servent *getservbyname (const char *__name, const char *__proto)" +getservbyport,dandelionSDK/libc_extension/netdb.c,75,libc_extension,explicit_errno_stub,ENOSYS,"struct servent *getservbyport (int __port, const char *__proto)" +getservent,dandelionSDK/libc_extension/netdb.c,82,libc_extension,explicit_errno_stub,ENOSYS,struct servent *getservent (void) +getaddrinfo,dandelionSDK/libc_extension/netdb.c,99,libc_extension,explicit_errno_stub,ENOSYS,"int getaddrinfo(const char *__restrict __name, const char *__restrict __service, const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai)" +getnameinfo,dandelionSDK/libc_extension/netdb.c,111,libc_extension,explicit_errno_stub,ENOSYS,"int getnameinfo(const struct sockaddr *__restrict __sa, socklen_t __salen, char *__restrict __host, socklen_t __hostlen, char *__restrict __serv, socklen_t __servlen, int __flags)" +catclose,dandelionSDK/libc_extension/nl_types.c,4,libc_extension,explicit_errno_stub,ENOSYS,int catclose(nl_catd catd) +catgets,dandelionSDK/libc_extension/nl_types.c,10,libc_extension,explicit_errno_stub,ENOSYS,"char *catgets(nl_catd catd, int set_id, int msg_id, const char *s)" +catopen,dandelionSDK/libc_extension/nl_types.c,18,libc_extension,explicit_errno_stub,ENOSYS,"nl_catd catopen(const char *name, int oflag)" +poll,dandelionSDK/libc_extension/poll.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int poll(struct pollfd *fds, nfds_t nfds, int timeout)" +pthread_rwlock_destroy,dandelionSDK/libc_extension/pthread.c,4,libc_extension,explicit_errno_stub,ENOSYS,int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) +dn_expand,dandelionSDK/libc_extension/resolv.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int dn_expand(const unsigned char *msg, const unsigned char *eomorig, const unsigned char *comp_dn, char *exp_dn, int length)" +sched_yield,dandelionSDK/libc_extension/sched.c,4,libc_extension,explicit_errno_stub,ENOSYS,int sched_yield (void) +sched_getcpu,dandelionSDK/libc_extension/sched.c,9,libc_extension,explicit_errno_stub,ENOTSUP,int sched_getcpu(void) +sem_close,dandelionSDK/libc_extension/semaphore.c,5,libc_extension,explicit_errno_stub,ENOSYS,int sem_close(sem_t *sem) +sem_destroy,dandelionSDK/libc_extension/semaphore.c,11,libc_extension,explicit_errno_stub,ENOSYS,int sem_destroy(sem_t *sem) +sem_getvalue,dandelionSDK/libc_extension/semaphore.c,17,libc_extension,explicit_errno_stub,ENOSYS,"int sem_getvalue(sem_t *restrict sem, int *restrict sval)" +sem_init,dandelionSDK/libc_extension/semaphore.c,24,libc_extension,explicit_errno_stub,ENOSYS,"int sem_init(sem_t *sem, int pshared, unsigned value)" +sem_open,dandelionSDK/libc_extension/semaphore.c,32,libc_extension,explicit_errno_stub,ENOSYS,"sem_t *sem_open(const char *name, int oflag, ...)" +sem_post,dandelionSDK/libc_extension/semaphore.c,43,libc_extension,explicit_errno_stub,ENOSYS,int sem_post(sem_t *sem) +sem_timedwait,dandelionSDK/libc_extension/semaphore.c,49,libc_extension,explicit_errno_stub,ENOSYS,"int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict abs_timeout)" +sem_trywait,dandelionSDK/libc_extension/semaphore.c,57,libc_extension,explicit_errno_stub,ENOSYS,int sem_trywait(sem_t *sem) +sem_unlink,dandelionSDK/libc_extension/semaphore.c,63,libc_extension,explicit_errno_stub,ENOSYS,int sem_unlink(const char *name) +sem_wait,dandelionSDK/libc_extension/semaphore.c,69,libc_extension,explicit_errno_stub,ENOSYS,int sem_wait(sem_t *sem) +accept,dandelionSDK/libc_extension/socket.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len)" +bind,dandelionSDK/libc_extension/socket.c,10,libc_extension,explicit_errno_stub,ENOSYS,"int bind (int __fd, const struct sockaddr *__addr, socklen_t __len)" +connect,dandelionSDK/libc_extension/socket.c,16,libc_extension,explicit_errno_stub,ENOSYS,"int connect (int __fd, const struct sockaddr *__addr, socklen_t __len)" +getpeername,dandelionSDK/libc_extension/socket.c,22,libc_extension,explicit_errno_stub,ENOSYS,"int getpeername (int __fd, struct sockaddr *__addr, socklen_t *__len)" +getsockname,dandelionSDK/libc_extension/socket.c,28,libc_extension,explicit_errno_stub,ENOSYS,"int getsockname (int __fd, struct sockaddr *__addr, socklen_t *__len)" +getsockopt,dandelionSDK/libc_extension/socket.c,34,libc_extension,explicit_errno_stub,ENOSYS,"int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen)" +listen,dandelionSDK/libc_extension/socket.c,40,libc_extension,explicit_errno_stub,ENOSYS,"int listen (int __fd, int __n)" +recv,dandelionSDK/libc_extension/socket.c,46,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t recv (int __fd, void *__buf, size_t __n, int __flags)" +recvfrom,dandelionSDK/libc_extension/socket.c,52,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr *__addr, socklen_t *__addr_len)" +recvmsg,dandelionSDK/libc_extension/socket.c,58,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags)" +send,dandelionSDK/libc_extension/socket.c,64,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t send (int __fd, const void *__buf, size_t __n, int __flags)" +sendmsg,dandelionSDK/libc_extension/socket.c,70,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t sendmsg (int __fd, const struct msghdr *__message, int __flags)" +sendto,dandelionSDK/libc_extension/socket.c,76,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t sendto (int __fd, const void *__buf, size_t __n, int __flags, const struct sockaddr *__addr, socklen_t __addr_len)" +setsockopt,dandelionSDK/libc_extension/socket.c,82,libc_extension,explicit_errno_stub,ENOSYS,"int setsockopt (int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen)" +shutdown,dandelionSDK/libc_extension/socket.c,88,libc_extension,explicit_errno_stub,ENOSYS,"int shutdown (int __fd, int __how)" +socket,dandelionSDK/libc_extension/socket.c,94,libc_extension,explicit_errno_stub,ENOSYS,"int socket (int __domain, int __type, int __protocol)" +sockatmark,dandelionSDK/libc_extension/socket.c,100,libc_extension,explicit_errno_stub,ENOSYS,int sockatmark (int __fd) +socketpair,dandelionSDK/libc_extension/socket.c,106,libc_extension,explicit_errno_stub,ENOSYS,"int socketpair (int __domain, int __type, int __protocol, int __fds[2])" +ftok,dandelionSDK/libc_extension/sys_ipc.c,4,libc_extension,explicit_errno_stub,ENOSYS,"key_t ftok(const char *path, int id)" +mmap,dandelionSDK/libc_extension/sys_mman.c,4,libc_extension,explicit_errno_stub,ENOSYS,"void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)" +mprotect,dandelionSDK/libc_extension/sys_mman.c,15,libc_extension,explicit_errno_stub,ENOSYS,"int mprotect(void *addr, size_t len, int prot)" +msync,dandelionSDK/libc_extension/sys_mman.c,23,libc_extension,explicit_errno_stub,ENOSYS,"int msync(void *addr, size_t len, int flags)" +munmap,dandelionSDK/libc_extension/sys_mman.c,31,libc_extension,explicit_errno_stub,ENOSYS,"int munmap(void *addr, size_t len)" +mlock,dandelionSDK/libc_extension/sys_mman.c,38,libc_extension,explicit_errno_stub,ENOSYS,"int mlock(const void *addr, size_t len)" +mlockall,dandelionSDK/libc_extension/sys_mman.c,45,libc_extension,explicit_errno_stub,ENOSYS,int mlockall(int flags) +munlock,dandelionSDK/libc_extension/sys_mman.c,51,libc_extension,explicit_errno_stub,ENOSYS,"int munlock(const void *addr, size_t len)" +munlockall,dandelionSDK/libc_extension/sys_mman.c,58,libc_extension,explicit_errno_stub,ENOSYS,int munlockall(void) +posix_madvise,dandelionSDK/libc_extension/sys_mman.c,63,libc_extension,explicit_errno_stub,ENOSYS,"int posix_madvise(void *addr, size_t len, int advice)" +shm_open,dandelionSDK/libc_extension/sys_mman.c,71,libc_extension,explicit_errno_stub,ENOSYS,"int shm_open(const char *name, int oflag, mode_t mode)" +shm_unlink,dandelionSDK/libc_extension/sys_mman.c,79,libc_extension,explicit_errno_stub,ENOSYS,int shm_unlink(const char *name) +msgctl,dandelionSDK/libc_extension/sys_msg.c,4,libc_extension,explicit_errno_stub,ENOSYS,"int msgctl(int msqid, int cmd, struct msqid_ds *buf)" +msgget,dandelionSDK/libc_extension/sys_msg.c,12,libc_extension,explicit_errno_stub,ENOSYS,"int msgget(key_t key, int msgflg)" +msgrcv,dandelionSDK/libc_extension/sys_msg.c,19,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)" +msgsnd,dandelionSDK/libc_extension/sys_msg.c,29,libc_extension,explicit_errno_stub,ENOSYS,"int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)" +semctl,dandelionSDK/libc_extension/sys_sem.c,5,libc_extension,explicit_errno_stub,ENOSYS,"int semctl(int semid, int semnum, int cmd, ...)" +semget,dandelionSDK/libc_extension/sys_sem.c,17,libc_extension,explicit_errno_stub,ENOSYS,"int semget(key_t key, int nsems, int semflg)" +semop,dandelionSDK/libc_extension/sys_sem.c,25,libc_extension,explicit_errno_stub,ENOSYS,"int semop(int semid, struct sembuf *sops, size_t nsops)" +shmat,dandelionSDK/libc_extension/sys_shm.c,4,libc_extension,explicit_errno_stub,ENOSYS,"void *shmat(int shmid, const void *shmaddr, int shmflg)" +shmctl,dandelionSDK/libc_extension/sys_shm.c,12,libc_extension,explicit_errno_stub,ENOSYS,"int shmctl(int shmid, int cmd, struct shmid_ds *buf)" +shmdt,dandelionSDK/libc_extension/sys_shm.c,20,libc_extension,explicit_errno_stub,ENOSYS,int shmdt(const void *shmaddr) +shmget,dandelionSDK/libc_extension/sys_shm.c,26,libc_extension,explicit_errno_stub,ENOSYS,"int shmget(key_t key, size_t size, int shmflg)" +syscall,dandelionSDK/libc_extension/sys_syscall.c,3,libc_extension,explicit_errno_stub,ENOSYS,"long syscall(long number, ...)" +cfgetispeed,dandelionSDK/libc_extension/sys_termios.c,4,libc_extension,explicit_errno_stub,ENOSYS,speed_t cfgetispeed(const struct termios *termios_p) +cfgetospeed,dandelionSDK/libc_extension/sys_termios.c,10,libc_extension,explicit_errno_stub,ENOSYS,speed_t cfgetospeed(const struct termios *termios_p) +cfsetispeed,dandelionSDK/libc_extension/sys_termios.c,16,libc_extension,explicit_errno_stub,ENOSYS,"int cfsetispeed(struct termios *termios_p, speed_t speed)" +cfsetospeed,dandelionSDK/libc_extension/sys_termios.c,23,libc_extension,explicit_errno_stub,ENOSYS,"int cfsetospeed(struct termios *termios_p, speed_t speed)" +tcdrain,dandelionSDK/libc_extension/sys_termios.c,30,libc_extension,explicit_errno_stub,ENOSYS,int tcdrain(int fd) +tcflow,dandelionSDK/libc_extension/sys_termios.c,36,libc_extension,explicit_errno_stub,ENOSYS,"int tcflow(int fd, int action)" +tcflush,dandelionSDK/libc_extension/sys_termios.c,43,libc_extension,explicit_errno_stub,ENOSYS,"int tcflush(int fd, int queue_selector)" +tcgetattr,dandelionSDK/libc_extension/sys_termios.c,50,libc_extension,explicit_errno_stub,ENOSYS,"int tcgetattr(int fd, struct termios *termios_p)" +tcgetsid,dandelionSDK/libc_extension/sys_termios.c,57,libc_extension,explicit_errno_stub,ENOSYS,pid_t tcgetsid(int fd) +tcsendbreak,dandelionSDK/libc_extension/sys_termios.c,63,libc_extension,explicit_errno_stub,ENOSYS,"int tcsendbreak(int fd, int duration)" +tcsetattr,dandelionSDK/libc_extension/sys_termios.c,70,libc_extension,explicit_errno_stub,ENOSYS,"int tcsetattr(int fd, int optional_actions, const struct termios *termios_p)" +uname,dandelionSDK/libc_extension/sys_utsname.c,4,libc_extension,explicit_errno_stub,ENOSYS,int uname(struct utsname *buf) +closelog,dandelionSDK/libc_extension/syslog.c,4,libc_extension,explicit_errno_stub,ENOSYS,void closelog(void) +openlog,dandelionSDK/libc_extension/syslog.c,8,libc_extension,explicit_errno_stub,ENOSYS,"void openlog(const char *ident, int option, int facility)" +setlogmask,dandelionSDK/libc_extension/syslog.c,15,libc_extension,explicit_errno_stub,ENOSYS,int setlogmask(int maskpri) +syslog,dandelionSDK/libc_extension/syslog.c,21,libc_extension,explicit_errno_stub,ENOSYS,"void syslog(int priority, const char *format, ...)" +readv,dandelionSDK/libc_extension/uio.c,4,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t readv (int __fd, const struct iovec *__iovec, int __count)" +writev,dandelionSDK/libc_extension/uio.c,12,libc_extension,explicit_errno_stub,ENOSYS,"ssize_t writev (int __fd, const struct iovec *__iovec, int __count)" +endutxent,dandelionSDK/libc_extension/utmpx.c,4,libc_extension,explicit_errno_stub,ENOSYS,void endutxent(void) +getutxent,dandelionSDK/libc_extension/utmpx.c,6,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *getutxent(void) +getutxid,dandelionSDK/libc_extension/utmpx.c,11,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *getutxid(const struct utmpx *id) +getutxline,dandelionSDK/libc_extension/utmpx.c,17,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *getutxline(const struct utmpx *line) +pututxline,dandelionSDK/libc_extension/utmpx.c,23,libc_extension,explicit_errno_stub,ENOSYS,struct utmpx *pututxline(const struct utmpx *utmpx) +setutxent,dandelionSDK/libc_extension/utmpx.c,29,libc_extension,explicit_errno_stub,ENOSYS,void setutxent(void) +pthread_mutexattr_init,dandelionSDK/newlib_shim/pthread.c,16,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_mutexattr_init(pthread_mutexattr_t *attr) +pthread_mutexattr_destroy,dandelionSDK/newlib_shim/pthread.c,17,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) +pthread_mutexattr_setpshared,dandelionSDK/newlib_shim/pthread.c,18,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)" +pthread_mutexattr_gettype,dandelionSDK/newlib_shim/pthread.c,24,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict attr, int *restrict type)" +pthread_mutexattr_settype,dandelionSDK/newlib_shim/pthread.c,28,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)" +pthread_mutexattr_getrobust,dandelionSDK/newlib_shim/pthread.c,31,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict attr, int *restrict robust)" +pthread_mutexattr_setrobust,dandelionSDK/newlib_shim/pthread.c,38,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust)" +pthread_mutexattr_getprotocol,dandelionSDK/newlib_shim/pthread.c,44,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict attr, int *restrict protocol)" +pthread_mutexattr_setprotocol,dandelionSDK/newlib_shim/pthread.c,51,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol)" +pthread_mutex_timedlock,dandelionSDK/newlib_shim/pthread.c,96,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_mutex_timedlock(pthread_mutex_t *restrict mutex, const struct timespec *restrict timeout)" +pthread_mutex_consistent,dandelionSDK/newlib_shim/pthread.c,115,newlib_shim,explicit_errno_stub,ENOSYS,int pthread_mutex_consistent(pthread_mutex_t *mutex) +pthread_rwlock_init,dandelionSDK/newlib_shim/pthread.c,120,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlockattr_t *restrict attr)" +pthread_rwlock_destry,dandelionSDK/newlib_shim/pthread.c,124,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_rwlock_destry(pthread_rwlock_t *rwlock) +pthread_rwlock_rdlock,dandelionSDK/newlib_shim/pthread.c,125,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) +pthread_rwlock_tryrdlock,dandelionSDK/newlib_shim/pthread.c,126,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) +pthread_rwlock_wrlock,dandelionSDK/newlib_shim/pthread.c,127,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) +pthread_rwlock_trywrlock,dandelionSDK/newlib_shim/pthread.c,128,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) +pthread_rwlock_unlock,dandelionSDK/newlib_shim/pthread.c,129,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) +pthread_cond_init,dandelionSDK/newlib_shim/pthread.c,131,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EAGAIN,"int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr)" +pthread_cond_destroy,dandelionSDK/newlib_shim/pthread.c,135,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_cond_destroy(pthread_cond_t *cond) +pthread_condattr_init,dandelionSDK/newlib_shim/pthread.c,136,newlib_shim,explicit_errno_stub,ENOSYS,int pthread_condattr_init(pthread_condattr_t *attr) +pthread_condattr_destroy,dandelionSDK/newlib_shim/pthread.c,141,newlib_shim,explicit_errno_stub,ENOSYS,int pthread_condattr_destroy(pthread_condattr_t *attr) +pthread_condattr_getclock,dandelionSDK/newlib_shim/pthread.c,146,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_condattr_getclock(const pthread_condattr_t *restrict attr, clockid_t *restrict clock_id)" +pthread_condattr_setclock,dandelionSDK/newlib_shim/pthread.c,153,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id)" +pthread_cond_wait,dandelionSDK/newlib_shim/pthread.c,159,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOTRECOVERABLE,"int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex)" +pthread_cond_timedwait,dandelionSDK/newlib_shim/pthread.c,163,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOTRECOVERABLE,"int pthread_cond_timedwait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstim)" +pthread_cond_signal,dandelionSDK/newlib_shim/pthread.c,168,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_cond_signal(pthread_cond_t *cond) +pthread_cond_broadcast,dandelionSDK/newlib_shim/pthread.c,169,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_cond_broadcast(pthread_cond_t *cond) +pthread_barrier_init,dandelionSDK/newlib_shim/pthread.c,171,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count)" +pthread_barrier_destroy,dandelionSDK/newlib_shim/pthread.c,180,newlib_shim,explicit_errno_stub,ENOSYS,int pthread_barrier_destroy(pthread_barrier_t *barrier) +pthread_barrier_wait,dandelionSDK/newlib_shim/pthread.c,185,newlib_shim,explicit_errno_stub,ENOSYS,int pthread_barrier_wait(pthread_barrier_t *barrier) +pthread_create,dandelionSDK/newlib_shim/pthread.c,200,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void *), void *restrict arg)" +pthread_join,dandelionSDK/newlib_shim/pthread.c,205,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int pthread_join(pthread_t thread, void **retval)" +pthread_detach,dandelionSDK/newlib_shim/pthread.c,206,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int pthread_detach(pthread_t thread) +pthread_cancel,dandelionSDK/newlib_shim/pthread.c,208,newlib_shim,explicit_errno_stub,ENOSYS,int pthread_cancel(pthread_t thread) +pthread_kill,dandelionSDK/newlib_shim/pthread.c,214,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_kill(pthread_t thread, int sig)" +pthread_setcancelstate,dandelionSDK/newlib_shim/pthread.c,221,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_setcancelstate(int state, int *oldstate)" +pthread_setcanceltype,dandelionSDK/newlib_shim/pthread.c,230,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_setcanceltype(int type, int *oldtype)" +pthread_testcancel,dandelionSDK/newlib_shim/pthread.c,239,newlib_shim,explicit_errno_stub,ENOSYS,void pthread_testcancel(void) +pthread_exit,dandelionSDK/newlib_shim/pthread.c,241,newlib_shim,explicit_errno_stub,ENOSYS,void pthread_exit(void *value_ptr) +_pthread_cleanup_push,dandelionSDK/newlib_shim/pthread.c,247,newlib_shim,explicit_errno_stub,ENOSYS,"void _pthread_cleanup_push(struct _pthread_cleanup_context *context, void (*routine)(void *), void *arg)" +_pthread_cleanup_pop,dandelionSDK/newlib_shim/pthread.c,255,newlib_shim,explicit_errno_stub,ENOSYS,"void _pthread_cleanup_pop(struct _pthread_cleanup_context *context, int execute)" +pthread_atfork,dandelionSDK/newlib_shim/pthread.c,337,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOMEM,"int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))" +insque,dandelionSDK/newlib_shim/search.c,7,newlib_shim,explicit_errno_stub,ENOSYS,"void insque(void *elem, void *prev)" +lfind,dandelionSDK/newlib_shim/search.c,13,newlib_shim,explicit_errno_stub,ENOSYS,"void *lfind(const void *key, const void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *))" +lsearch,dandelionSDK/newlib_shim/search.c,24,newlib_shim,explicit_errno_stub,ENOSYS,"void *lsearch(const void *key, void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *))" +remque,dandelionSDK/newlib_shim/search.c,35,newlib_shim,explicit_errno_stub,ENOSYS,void remque(void *elem) +execve,dandelionSDK/newlib_shim/shim.c,217,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ENOMEM,"int execve(const char *name, char *const argv[], char *const env[])" +fcntl,dandelionSDK/newlib_shim/shim.c,222,newlib_shim,explicit_errno_stub,ENOSYS,"int fcntl(int fd, int op, ...)" +siglongjmp,dandelionSDK/newlib_shim/shim.c,229,newlib_shim,manual_placeholder_stub,prints error and exits instead of siglongjmp,"void siglongjmp(sigjmp_buf env, int val)" +posix_fadvise,dandelionSDK/newlib_shim/shim.c,236,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_fadvise(int fd, off_t offset, off_t len, int advice)" +posix_fallocate,dandelionSDK/newlib_shim/shim.c,245,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_fallocate(int fd, off_t offset, off_t len)" +clearenv,dandelionSDK/newlib_shim/shim.c,253,newlib_shim,explicit_errno_stub,ENOSYS,int clearenv(void) +nexttoward,dandelionSDK/newlib_shim/shim.c,258,newlib_shim,explicit_errno_stub,ENOSYS,"double nexttoward(double x, long double y)" +nexttowardf,dandelionSDK/newlib_shim/shim.c,265,newlib_shim,explicit_errno_stub,ENOSYS,"float nexttowardf(float x, long double y)" +nexttowardl,dandelionSDK/newlib_shim/shim.c,272,newlib_shim,explicit_errno_stub,ENOSYS,"long double nexttowardl(long double x, long double y)" +getdelim,dandelionSDK/newlib_shim/shim.c,279,newlib_shim,explicit_errno_stub,ENOSYS,"ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter, FILE *restrict stream)" +getline,dandelionSDK/newlib_shim/shim.c,289,newlib_shim,explicit_errno_stub,ENOSYS,"ssize_t getline(char **restrict lineptr, size_t *restrict n, FILE *restrict stream)" +fork,dandelionSDK/newlib_shim/shim.c,298,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EAGAIN,int fork() +grantpt,dandelionSDK/newlib_shim/shim.c,303,newlib_shim,explicit_errno_stub,ENOSYS,int grantpt(int fd) +basename,dandelionSDK/newlib_shim/shim.c,309,newlib_shim,explicit_errno_stub,ENOSYS,char *basename(char *path) +dirname,dandelionSDK/newlib_shim/shim.c,315,newlib_shim,explicit_errno_stub,ENOSYS,char *dirname(char *path) +getppid,dandelionSDK/newlib_shim/shim.c,323,newlib_shim,explicit_errno_stub,ENOSYS,pid_t getppid(void) +getegid,dandelionSDK/newlib_shim/shim.c,328,newlib_shim,explicit_errno_stub,ENOSYS,gid_t getegid(void) +geteuid,dandelionSDK/newlib_shim/shim.c,333,newlib_shim,explicit_errno_stub,ENOSYS,uid_t geteuid(void) +fnmatch,dandelionSDK/newlib_shim/shim.c,338,newlib_shim,explicit_errno_stub,ENOSYS,"int fnmatch(const char *pattern, const char *string, int flags)" +iconv_open,dandelionSDK/newlib_shim/shim.c,346,newlib_shim,explicit_errno_stub,ENOSYS,"iconv_t iconv_open(const char *tocode, const char *fromcode)" +iconv,dandelionSDK/newlib_shim/shim.c,353,newlib_shim,explicit_errno_stub,ENOSYS,"size_t iconv(iconv_t cd, char **__restrict inbuf, size_t *__restrict inbytesleft, char **__restrict outbuf, size_t *__restrict outbytesleft)" +iconv_close,dandelionSDK/newlib_shim/shim.c,364,newlib_shim,explicit_errno_stub,ENOSYS,int iconv_close(iconv_t cd) +popen,dandelionSDK/newlib_shim/shim.c,370,newlib_shim,explicit_errno_stub,ENOSYS,"FILE *popen(const char *command, const char *type)" +pclose,dandelionSDK/newlib_shim/shim.c,377,newlib_shim,explicit_errno_stub,ENOSYS,int pclose(FILE *stream) +flockfile,dandelionSDK/newlib_shim/shim.c,383,newlib_shim,explicit_errno_stub,ENOSYS,void flockfile(FILE *stream) +funlockfile,dandelionSDK/newlib_shim/shim.c,388,newlib_shim,explicit_errno_stub,ENOSYS,void funlockfile(FILE *stream) +posix_spawn_file_actions_init,dandelionSDK/newlib_shim/shim.c,393,newlib_shim,explicit_errno_stub,ENOSYS,int posix_spawn_file_actions_init(posix_spawn_file_actions_t *file_actions) +posix_spawn_file_actions_addclose,dandelionSDK/newlib_shim/shim.c,399,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions, int fildes)" +posix_spawn_file_actions_adddup2,dandelionSDK/newlib_shim/shim.c,407,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *file_actions, int fildes, int newfildes)" +posix_spawn_file_actions_destroy,dandelionSDK/newlib_shim/shim.c,416,newlib_shim,explicit_errno_stub,ENOSYS,int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *file_actions) +posix_spawnp,dandelionSDK/newlib_shim/shim.c,422,newlib_shim,explicit_errno_stub,ENOSYS,"int posix_spawnp(pid_t *restrict pid, const char *restrict file, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char *const envp[restrict])" +initstate,dandelionSDK/newlib_shim/shim.c,437,newlib_shim,explicit_errno_stub,ENOSYS,"char *initstate(unsigned seed, char *state, size_t size)" +setstate,dandelionSDK/newlib_shim/shim.c,445,newlib_shim,explicit_errno_stub,ENOSYS,char *setstate(char *state) +time,dandelionSDK/newlib_shim/shim.c,451,newlib_shim,explicit_errno_stub,ENOSYS,time_t time(time_t *timer) +futimens,dandelionSDK/newlib_shim/shim.c,459,newlib_shim,explicit_errno_stub,ENOSYS,"int futimens(int fd, const struct timespec times[2])" +utimensat,dandelionSDK/newlib_shim/shim.c,466,newlib_shim,explicit_errno_stub,ENOSYS,"int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags)" +getpwnam_r,dandelionSDK/newlib_shim/shim.c,476,newlib_shim,explicit_errno_stub,ENOSYS,"int getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t buflen, struct passwd **result)" +regcomp,dandelionSDK/newlib_shim/shim.c,489,newlib_shim,explicit_errno_stub,ENOSYS,"int regcomp(regex_t *restrict preg, const char *restrict pattern, int cflags)" +regerror,dandelionSDK/newlib_shim/shim.c,497,newlib_shim,explicit_errno_stub,ENOSYS,"size_t regerror(int errcode, const regex_t *restrict preg, char *restrict errbuf, size_t errbuf_size)" +regexec,dandelionSDK/newlib_shim/shim.c,508,newlib_shim,explicit_errno_stub,ENOSYS,"int regexec(const regex_t *restrict preg, const char *restrict string, size_t nmatch, regmatch_t pmatch[restrict], int eflags)" +regfree,dandelionSDK/newlib_shim/shim.c,519,newlib_shim,explicit_errno_stub,ENOSYS,void regfree(regex_t *preg) +exp10l,dandelionSDK/newlib_shim/shim.c,524,newlib_shim,explicit_errno_stub,ENOSYS,long double exp10l(long double x) +pow10l,dandelionSDK/newlib_shim/shim.c,530,newlib_shim,explicit_errno_stub,ENOSYS,long double pow10l(long double x) +sincosl,dandelionSDK/newlib_shim/shim.c,536,newlib_shim,explicit_errno_stub,ENOSYS,"void sincosl(long double x, long double *sinx, long double *cosx)" +__kernel_tanl,dandelionSDK/newlib_shim/shim.c,547,newlib_shim,explicit_errno_stub,ENOSYS,"long double __kernel_tanl(long double x, long double y, int iy)" +__pleval,dandelionSDK/newlib_shim/shim.c,555,newlib_shim,explicit_errno_stub,ENOSYS,"unsigned long __pleval(const char *expr, unsigned long n)" +waitpid,dandelionSDK/newlib_shim/shim.c,562,newlib_shim,explicit_errno_stub,ENOSYS,"pid_t waitpid(pid_t pid, int *status, int options)" +waitid,dandelionSDK/newlib_shim/shim.c,570,newlib_shim,explicit_errno_stub,ENOSYS,"int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options)" +getpriority,dandelionSDK/newlib_shim/shim.c,579,newlib_shim,explicit_errno_stub,ENOSYS,"int getpriority(int which, id_t who)" +getrlimit,dandelionSDK/newlib_shim/shim.c,586,newlib_shim,explicit_errno_stub,ENOSYS,"int getrlimit(int resource, struct rlimit *rlim)" +getrusage,dandelionSDK/newlib_shim/shim.c,593,newlib_shim,explicit_errno_stub,ENOSYS,"int getrusage(int who, struct rusage *usage)" +gettimeofday,dandelionSDK/newlib_shim/shim.c,600,newlib_shim,explicit_errno_stub,ENOSYS,"int gettimeofday(struct timeval *restrict p, void *restrict tz)" +kill,dandelionSDK/newlib_shim/shim.c,607,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int kill(int pid, int sig)" +pipe,dandelionSDK/newlib_shim/shim.c,612,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EFAULT,int pipe(int pipefd[2]) +posix_openpt,dandelionSDK/newlib_shim/shim.c,617,newlib_shim,explicit_errno_stub,ENOSYS,int posix_openpt(int flags) +ptsname,dandelionSDK/newlib_shim/shim.c,623,newlib_shim,explicit_errno_stub,ENOSYS,char *ptsname(int fd) +setpriority,dandelionSDK/newlib_shim/shim.c,629,newlib_shim,explicit_errno_stub,ENOSYS,"int setpriority(int which, id_t who, int prio)" +setrlimit,dandelionSDK/newlib_shim/shim.c,637,newlib_shim,explicit_errno_stub,ENOSYS,"int setrlimit(int resource, const struct rlimit *rlim)" +readlink,dandelionSDK/newlib_shim/shim.c,644,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,"ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize)" +realpath,dandelionSDK/newlib_shim/shim.c,650,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,"char *realpath(const char *path, char *resolved_path)" +sigaction,dandelionSDK/newlib_shim/shim.c,655,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int sigaction(int signum, const struct sigaction *_Nullable restrict act, struct sigaction *_Nullable restrict oldact)" +sysconf,dandelionSDK/newlib_shim/shim.c,661,newlib_shim,explicit_errno_stub,ENOSYS,long sysconf(int name) +times,dandelionSDK/newlib_shim/shim.c,667,newlib_shim,explicit_errno_stub,ENOSYS,clock_t times(struct tms *buf) +unlockpt,dandelionSDK/newlib_shim/shim.c,673,newlib_shim,explicit_errno_stub,ENOSYS,int unlockpt(int fd) +wait,dandelionSDK/newlib_shim/shim.c,679,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure ECHILD,int wait(int *status) +wordexp,dandelionSDK/newlib_shim/shim.c,684,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure WRDE_NOSPACE,"int wordexp(const char *s, wordexp_t *p, int flags)" +sighold,dandelionSDK/newlib_shim/signal_dandelion.c,14,newlib_shim,explicit_errno_stub,ENOSYS,int sighold(int sig) +sigignore,dandelionSDK/newlib_shim/signal_dandelion.c,20,newlib_shim,explicit_errno_stub,ENOSYS,int sigignore(int sig) +siginterrupt,dandelionSDK/newlib_shim/signal_dandelion.c,26,newlib_shim,explicit_errno_stub,ENOSYS,"int siginterrupt(int sig, int flag)" +sigrelse,dandelionSDK/newlib_shim/signal_dandelion.c,33,newlib_shim,explicit_errno_stub,ENOSYS,int sigrelse(int sig) +sigset,dandelionSDK/newlib_shim/signal_dandelion.c,39,newlib_shim,explicit_errno_stub,ENOSYS,"_sig_func_ptr sigset(int sig, _sig_func_ptr disp)" +pthread_sigmask,dandelionSDK/newlib_shim/signal_dandelion.c,46,newlib_shim,explicit_errno_stub,ENOSYS,"int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict oldset)" +sigaddset,dandelionSDK/newlib_shim/signal_dandelion.c,57,newlib_shim,explicit_errno_stub,ENOSYS,"int sigaddset(sigset_t *set, int signo)" +sigemptyset,dandelionSDK/newlib_shim/signal_dandelion.c,64,newlib_shim,explicit_errno_stub,ENOSYS,int sigemptyset(sigset_t *set) +sigismember,dandelionSDK/newlib_shim/signal_dandelion.c,72,newlib_shim,explicit_errno_stub,ENOSYS,"int sigismember(const sigset_t *set, int signo)" +sigprocmask,dandelionSDK/newlib_shim/signal_dandelion.c,79,newlib_shim,explicit_errno_stub,ENOSYS,"int sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict oldset)" +sigaltstack,dandelionSDK/newlib_shim/signal_dandelion.c,90,newlib_shim,explicit_errno_stub,ENOSYS,"int sigaltstack(const stack_t *restrict ss, stack_t *restrict old_ss)" +getdate,dandelionSDK/newlib_shim/time.c,34,newlib_shim,explicit_errno_stub,ENOSYS,struct tm *getdate(const char *string) +getdate_r,dandelionSDK/newlib_shim/time.c,41,newlib_shim,explicit_errno_stub,ENOSYS,"int getdate_r(const char *string, struct tm *result)" +clock_settime,dandelionSDK/newlib_shim/time.c,49,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int clock_settime(clockid_t clock_id, const struct timespec *tp)" +clock_getres,dandelionSDK/newlib_shim/time.c,68,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int clock_getres(clockid_t clock_id, struct timespec *res)" +timer_create,dandelionSDK/newlib_shim/time.c,75,newlib_shim,explicit_errno_stub,ENOTSUP,"int timer_create(clockid_t clock_id, struct sigevent *__restrict evp, timer_t *__restrict timerid)" +timer_delete,dandelionSDK/newlib_shim/time.c,83,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int timer_delete(timer_t timerid) +timer_settime,dandelionSDK/newlib_shim/time.c,90,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict value, struct itimerspec *__restrict ovalue)" +timer_gettime,dandelionSDK/newlib_shim/time.c,97,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,"int timer_gettime(timer_t timerid, struct itimerspec *value)" +timer_getoverrun,dandelionSDK/newlib_shim/time.c,102,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EINVAL,int timer_getoverrun(timer_t timerid) +chdir,dandelionSDK/newlib_shim/unistd.c,8,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,int chdir(const char *__path) +fchdir,dandelionSDK/newlib_shim/unistd.c,12,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,int fchdir(int __fildes) +chroot,dandelionSDK/newlib_shim/unistd.c,17,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EACCES,int chroot(const char *__path) +daemon,dandelionSDK/newlib_shim/unistd.c,35,newlib_shim,explicit_errno_stub,ENOSYS,"int daemon(int nochdir, int noclose)" +dup3,dandelionSDK/newlib_shim/unistd.c,48,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EMFILE,"int dup3(int __fildes, int __fildes2, int flags)" +dup2,dandelionSDK/newlib_shim/unistd.c,52,newlib_shim,manual_placeholder_stub,delegates to dup3 placeholder failure EMFILE,"int dup2(int __fildes, int __fildes2)" +dup,dandelionSDK/newlib_shim/unistd.c,53,newlib_shim,manual_placeholder_stub,delegates to dup3 placeholder failure EMFILE,int dup(int __fildes) +execl,dandelionSDK/newlib_shim/unistd.c,64,newlib_shim,explicit_errno_stub,ENOSYS,"int execl(const char *__path, const char *arg, ...)" +execle,dandelionSDK/newlib_shim/unistd.c,70,newlib_shim,explicit_errno_stub,ENOSYS,"int execle(const char *__path, const char *arg, ...)" +execv,dandelionSDK/newlib_shim/unistd.c,80,newlib_shim,manual_placeholder_stub,delegates to execve placeholder failure ENOMEM,"int execv(const char *__path, char *const __argv[])" +setgroups,dandelionSDK/newlib_shim/unistd.c,172,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int setgroups(int ngroups, const gid_t *grouplist)" +sleep,dandelionSDK/newlib_shim/unistd.c,192,newlib_shim,explicit_errno_stub,ENOSYS,unsigned sleep(unsigned int __seconds) +vfork,dandelionSDK/newlib_shim/unistd.c,225,newlib_shim,explicit_errno_stub,ENOSYS,pid_t vfork(void) +symlink,dandelionSDK/newlib_shim/unistd.c,258,newlib_shim,manual_placeholder_stub,returns fixed placeholder failure EPERM,"int symlink(const char *__name1, const char *__name2)" +mknod,dandelionSDK/newlib_shim/unistd.c,263,newlib_shim,explicit_errno_stub,ENOSYS,"int mknod(const char *__path, mode_t __mode, dev_t __dev)" diff --git a/newlib_shim/Makefile.inc b/newlib_shim/Makefile.inc index acbd0d0..19a67f6 100644 --- a/newlib_shim/Makefile.inc +++ b/newlib_shim/Makefile.inc @@ -1,5 +1,8 @@ libc_a_SOURCES += \ + %D%/math_stubs.c \ %D%/pthread.c \ + %D%/search.c \ + %D%/signal_dandelion.c \ %D%/shim.c \ %D%/time.c \ - %D%/unistd.c \ No newline at end of file + %D%/unistd.c diff --git a/newlib_shim/math_stubs.c b/newlib_shim/math_stubs.c new file mode 100644 index 0000000..0816c90 --- /dev/null +++ b/newlib_shim/math_stubs.c @@ -0,0 +1,65 @@ +#include +#include + +// defined by newlib, but not always avaliable in headers +#undef errno +extern int errno; + +double nexttoward(double x, long double y) { + (void)x; + (void)y; + errno = ENOSYS; + return NAN; +} + +float nexttowardf(float x, long double y) { + (void)x; + (void)y; + errno = ENOSYS; + return NAN; +} + +long double nexttowardl(long double x, long double y) { + (void)x; + (void)y; + errno = ENOSYS; + return (long double)NAN; +} + +long double exp10l(long double x) { + (void)x; + errno = ENOSYS; + return NAN; +} + +long double pow10l(long double x) { + (void)x; + errno = ENOSYS; + return NAN; +} + +void sincosl(long double x, long double *sinx, long double *cosx) { + (void)x; + if (sinx != NULL) { + *sinx = NAN; + } + if (cosx != NULL) { + *cosx = NAN; + } + errno = ENOSYS; +} + +long double __kernel_tanl(long double x, long double y, int iy) { + (void)x; + (void)y; + (void)iy; + errno = ENOSYS; + return NAN; +} + +unsigned long __pleval(const char *expr, unsigned long n) { + (void)expr; + (void)n; + errno = ENOSYS; + return (unsigned long)-1; +} diff --git a/newlib_shim/newlib-cygwin-3.5.3.patch b/newlib_shim/newlib-cygwin-3.5.3.patch index eebcbf6..1252621 100644 --- a/newlib_shim/newlib-cygwin-3.5.3.patch +++ b/newlib_shim/newlib-cygwin-3.5.3.patch @@ -1,5 +1,5 @@ diff --git a/config.sub b/config.sub -index 63c1f1c8b..2971cb107 100755 +index 63c1f1c8..2971cb10 100755 --- a/config.sub +++ b/config.sub @@ -1325,6 +1325,9 @@ case $os in @@ -22,7 +22,7 @@ index 63c1f1c8b..2971cb107 100755 musl* | newlib* | uclibc*) ;; diff --git a/newlib/Makefile.am b/newlib/Makefile.am -index 4ab36b8d8..0eacadd84 100644 +index 4ab36b8d..0eacadd8 100644 --- a/newlib/Makefile.am +++ b/newlib/Makefile.am @@ -113,19 +113,19 @@ rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst * @@ -59,7 +59,7 @@ index 4ab36b8d8..0eacadd84 100644 ## Place the libm_a objects in libc/ to keep the top dir tidy. stamp-libc-math-objects: libm.a diff --git a/newlib/configure.host b/newlib/configure.host -index 386183466..9a1f02ac2 100644 +index 38618346..0f42f769 100644 --- a/newlib/configure.host +++ b/newlib/configure.host @@ -430,6 +430,12 @@ case "${host}" in @@ -75,7 +75,7 @@ index 386183466..9a1f02ac2 100644 *-*-netware*) signal_dir= sys_dir=netware -@@ -631,7 +636,7 @@ newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVID +@@ -631,7 +637,7 @@ newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVID ;; aarch64*-*-*) default_newlib_io_long_long="yes" @@ -85,7 +85,7 @@ index 386183466..9a1f02ac2 100644 arc*-*-*) syscall_dir=syscalls diff --git a/newlib/libc/acinclude.m4 b/newlib/libc/acinclude.m4 -index 24148b13f..063723483 100644 +index 24148b13..06372348 100644 --- a/newlib/libc/acinclude.m4 +++ b/newlib/libc/acinclude.m4 @@ -13,7 +13,7 @@ AM_CONDITIONAL(HAVE_UNIX_DIR, test x${unix_dir} != x) @@ -97,38 +97,377 @@ index 24148b13f..063723483 100644 epiphany h8300hms h8500hms m88kbug mmixware -diff --git a/newlib/libc/include/sys/stat.h b/newlib/libc/include/sys/stat.h -index 98f5addb4..046cb91bd 100644 ---- a/newlib/libc/include/sys/stat.h -+++ b/newlib/libc/include/sys/stat.h -@@ -142,8 +142,10 @@ int mkfifo (const char *__path, mode_t __mode ); - int stat (const char *__restrict __path, struct stat *__restrict __sbuf ); - mode_t umask (mode_t __mask ); +diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h +index ad3028e4..84de9095 100644 +--- a/newlib/libc/include/complex.h ++++ b/newlib/libc/include/complex.h +@@ -9,7 +9,7 @@ + #define _COMPLEX_H --#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) -+#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) || defined(__DANDELION__) - int lstat (const char *__restrict __path, struct stat *__restrict __buf ); + #define complex _Complex +-#define _Complex_I 1.0fi ++#define _Complex_I (__extension__ 1.0fi) + #define I _Complex_I + + #include +diff --git a/newlib/libc/include/glob.h b/newlib/libc/include/glob.h +index 7a300e69..c565210d 100644 +--- a/newlib/libc/include/glob.h ++++ b/newlib/libc/include/glob.h +@@ -37,12 +37,13 @@ + #define _GLOB_H_ + + #include ++#include + + struct stat; + typedef struct { +- int gl_pathc; /* Count of total paths so far. */ +- int gl_matchc; /* Count of paths matching pattern. */ +- int gl_offs; /* Reserved at beginning of gl_pathv. */ ++ size_t gl_pathc; /* Count of total paths so far. */ ++ size_t gl_matchc; /* Count of paths matching pattern. */ ++ size_t gl_offs; /* Reserved at beginning of gl_pathv. */ + int gl_flags; /* Copy of flags parameter to glob. */ + char **gl_pathv; /* List of paths matching pattern. */ + /* Copy of errfunc parameter to glob. */ +@@ -66,6 +67,8 @@ typedef struct { + #define GLOB_MARK 0x0008 /* Append / to matching directories. */ + #define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ + #define GLOB_NOSORT 0x0020 /* Don't sort. */ ++/* https://git.musl-libc.org/cgit/musl/tree/include/glob.h */ ++#define GLOB_NOESCAPE 0x40 /* Disable backslash escaping. */ + + #define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ + #define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ +@@ -78,6 +81,9 @@ typedef struct { + /* backwards compatibility, this is the old name for this option */ + #define GLOB_MAXPATH GLOB_LIMIT + ++/* https://git.musl-libc.org/cgit/musl/tree/include/glob.h */ ++#define GLOB_ABORTED 2 /* Unignored error. */ ++#define GLOB_NOMATCH 3 /* No match and GLOB_NOCHECK was not set. */ + #define GLOB_NOSPACE (-1) /* Malloc call failed. */ + #define GLOB_ABEND (-2) /* Unignored error. */ + +diff --git a/newlib/libc/include/limits.h b/newlib/libc/include/limits.h +index 893f1083..910d59aa 100644 +--- a/newlib/libc/include/limits.h ++++ b/newlib/libc/include/limits.h +@@ -145,3 +145,223 @@ + #ifndef PATH_MAX + #define PATH_MAX 4096 + #endif ++ ++#if __POSIX_VISIBLE >= 2 ++/* https://man7.org/linux/man-pages/man0/limits.h.0p.html ++ https://github.com/bminor/glibc/blob/master/posix/bits/posix2_lim.h */ ++#ifndef CHARCLASS_NAME_MAX ++#define CHARCLASS_NAME_MAX 2048 +#endif -+#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) - int mknod (const char *__path, mode_t __mode, dev_t __dev ); ++#ifndef COLL_WEIGHTS_MAX ++#define COLL_WEIGHTS_MAX 255 ++#endif ++#ifndef EXPR_NEST_MAX ++#define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX ++#endif ++#ifndef LINE_MAX ++#define LINE_MAX _POSIX2_LINE_MAX ++#endif ++#ifndef RE_DUP_MAX ++#define RE_DUP_MAX 0x7fff ++#endif ++#endif ++ ++#if __POSIX_VISIBLE ++/* https://man7.org/linux/man-pages/man0/limits.h.0p.html ++ https://github.com/bminor/glibc/blob/master/posix/bits/posix1_lim.h */ ++#ifndef _POSIX_CLOCKRES_MIN ++#define _POSIX_CLOCKRES_MIN 20000000 ++#endif ++#ifndef _POSIX_AIO_LISTIO_MAX ++#define _POSIX_AIO_LISTIO_MAX 2 ++#endif ++#ifndef _POSIX_AIO_MAX ++#define _POSIX_AIO_MAX 1 ++#endif ++#ifndef _POSIX_ARG_MAX ++#define _POSIX_ARG_MAX 4096 ++#endif ++#ifndef _POSIX_CHILD_MAX ++#define _POSIX_CHILD_MAX 25 ++#endif ++#ifndef _POSIX_DELAYTIMER_MAX ++#define _POSIX_DELAYTIMER_MAX 32 ++#endif ++#ifndef _POSIX_HOST_NAME_MAX ++#define _POSIX_HOST_NAME_MAX 255 ++#endif ++#ifndef _POSIX_LINK_MAX ++#define _POSIX_LINK_MAX 8 ++#endif ++#ifndef _POSIX_LOGIN_NAME_MAX ++#define _POSIX_LOGIN_NAME_MAX 9 ++#endif ++#ifndef _POSIX_MAX_CANON ++#define _POSIX_MAX_CANON 255 ++#endif ++#ifndef _POSIX_MAX_INPUT ++#define _POSIX_MAX_INPUT 255 ++#endif ++#ifndef _POSIX_MQ_OPEN_MAX ++#define _POSIX_MQ_OPEN_MAX 8 ++#endif ++#ifndef _POSIX_MQ_PRIO_MAX ++#define _POSIX_MQ_PRIO_MAX 32 ++#endif ++#ifndef _POSIX_NAME_MAX ++#define _POSIX_NAME_MAX 14 ++#endif ++#ifndef _POSIX_NGROUPS_MAX ++#define _POSIX_NGROUPS_MAX 8 ++#endif ++#ifndef _POSIX_OPEN_MAX ++#define _POSIX_OPEN_MAX 20 ++#endif ++#ifndef _POSIX_PATH_MAX ++#define _POSIX_PATH_MAX 256 ++#endif ++#ifndef _POSIX_PIPE_BUF ++#define _POSIX_PIPE_BUF 512 ++#endif ++#ifndef _POSIX_RE_DUP_MAX ++#define _POSIX_RE_DUP_MAX 255 ++#endif ++#ifndef _POSIX_RTSIG_MAX ++#define _POSIX_RTSIG_MAX 8 ++#endif ++#ifndef _POSIX_SEM_NSEMS_MAX ++#define _POSIX_SEM_NSEMS_MAX 256 ++#endif ++#ifndef _POSIX_SEM_VALUE_MAX ++#define _POSIX_SEM_VALUE_MAX 32767 ++#endif ++#ifndef _POSIX_SIGQUEUE_MAX ++#define _POSIX_SIGQUEUE_MAX 32 ++#endif ++#ifndef _POSIX_SSIZE_MAX ++#define _POSIX_SSIZE_MAX 32767 ++#endif ++#ifndef _POSIX_SS_REPL_MAX ++#define _POSIX_SS_REPL_MAX 4 ++#endif ++#ifndef _POSIX_STREAM_MAX ++#define _POSIX_STREAM_MAX 8 ++#endif ++#ifndef _POSIX_SYMLINK_MAX ++#define _POSIX_SYMLINK_MAX 255 ++#endif ++#ifndef _POSIX_SYMLOOP_MAX ++#define _POSIX_SYMLOOP_MAX 8 ++#endif ++/* https://man7.org/linux/man-pages/man0/limits.h.0p.html ++ https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/local_lim.h */ ++#ifndef _POSIX_THREAD_DESTRUCTOR_ITERATIONS ++#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 ++#endif ++#ifndef _POSIX_THREAD_KEYS_MAX ++#define _POSIX_THREAD_KEYS_MAX 128 ++#endif ++#ifndef _POSIX_THREAD_THREADS_MAX ++#define _POSIX_THREAD_THREADS_MAX 64 ++#endif ++#ifndef _POSIX_TIMER_MAX ++#define _POSIX_TIMER_MAX 32 ++#endif ++#ifndef _POSIX_TTY_NAME_MAX ++#define _POSIX_TTY_NAME_MAX 9 ++#endif ++#ifndef _POSIX_TZNAME_MAX ++#define _POSIX_TZNAME_MAX 6 ++#endif ++#endif ++ ++#if __POSIX_VISIBLE >= 2 ++/* https://man7.org/linux/man-pages/man0/limits.h.0p.html ++ https://github.com/bminor/glibc/blob/master/posix/bits/posix2_lim.h */ ++#ifndef _POSIX2_BC_BASE_MAX ++#define _POSIX2_BC_BASE_MAX 99 ++#endif ++#ifndef _POSIX2_BC_DIM_MAX ++#define _POSIX2_BC_DIM_MAX 2048 ++#endif ++#ifndef _POSIX2_BC_SCALE_MAX ++#define _POSIX2_BC_SCALE_MAX 99 ++#endif ++#ifndef _POSIX2_BC_STRING_MAX ++#define _POSIX2_BC_STRING_MAX 1000 ++#endif ++#ifndef _POSIX2_CHARCLASS_NAME_MAX ++#define _POSIX2_CHARCLASS_NAME_MAX 14 ++#endif ++#ifndef _POSIX2_COLL_WEIGHTS_MAX ++#define _POSIX2_COLL_WEIGHTS_MAX 2 ++#endif ++#ifndef _POSIX2_EXPR_NEST_MAX ++#define _POSIX2_EXPR_NEST_MAX 32 ++#endif ++#ifndef _POSIX2_LINE_MAX ++#define _POSIX2_LINE_MAX 2048 ++#endif ++#endif ++ ++#if __XSI_VISIBLE ++/* https://man7.org/linux/man-pages/man0/limits.h.0p.html */ ++#ifndef _XOPEN_IOV_MAX ++#define _XOPEN_IOV_MAX 16 ++#endif ++#ifndef _XOPEN_NAME_MAX ++#define _XOPEN_NAME_MAX 255 ++#endif ++#ifndef _XOPEN_PATH_MAX ++#define _XOPEN_PATH_MAX 1024 ++#endif ++#endif ++ ++#ifndef SSIZE_MAX ++/* https://github.com/bminor/glibc/blob/master/posix/bits/posix1_lim.h */ ++#if __SIZEOF_SIZE_T__ == __SIZEOF_LONG__ ++#define SSIZE_MAX LONG_MAX ++#else ++#define SSIZE_MAX INT_MAX ++#endif ++#endif ++ ++#ifndef WORD_BIT ++/* https://github.com/bminor/glibc/blob/master/include/bits/xopen_lim.h */ ++#if __INT_MAX__ == 32767 ++#define WORD_BIT 16 ++#elif __INT_MAX__ == 2147483647 ++#define WORD_BIT 32 ++#else ++#define WORD_BIT 64 ++#endif ++#endif ++ ++#ifndef LONG_BIT ++/* https://github.com/bminor/glibc/blob/master/include/bits/xopen_lim.h */ ++#if __LONG_MAX__ == 2147483647 ++#define LONG_BIT 32 ++#else ++#define LONG_BIT 64 ++#endif ++#endif ++ ++#if __XSI_VISIBLE ++/* https://man7.org/linux/man-pages/man0/limits.h.0p.html ++ https://github.com/bminor/glibc/blob/master/include/bits/xopen_lim.h */ ++#ifndef NL_LANGMAX ++#define NL_LANGMAX _POSIX2_LINE_MAX ++#endif ++#ifndef NL_MSGMAX ++#define NL_MSGMAX INT_MAX ++#endif ++#ifndef NL_SETMAX ++#define NL_SETMAX INT_MAX ++#endif ++#ifndef NL_TEXTMAX ++#define NL_TEXTMAX INT_MAX ++#endif ++#ifndef NZERO ++#define NZERO 20 ++#endif ++#endif +diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h +index e3534e18..c7c75d39 100644 +--- a/newlib/libc/include/machine/setjmp.h ++++ b/newlib/libc/include/machine/setjmp.h +@@ -439,7 +439,7 @@ typedef int jmp_buf[_JBLEN]; + + _END_STD_C + +-#if (defined(__CYGWIN__) || defined(__rtems__)) && __POSIX_VISIBLE ++#if (defined(__CYGWIN__) || defined(__rtems__) || defined(__DANDELION__)) && __POSIX_VISIBLE + #include + + #ifdef __cplusplus +@@ -457,7 +457,7 @@ typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))]; + #define _SAVEMASK _JBLEN + #define _SIGMASK (_JBLEN+1) + +-#ifdef __CYGWIN__ ++#if defined(__CYGWIN__) + # define _CYGWIN_WORKING_SIGSETJMP + #endif + +@@ -467,11 +467,14 @@ typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))]; + #define __SIGMASK_FUNC sigprocmask + #endif + +-#ifdef __CYGWIN__ ++#if defined(__CYGWIN__) || defined(__DANDELION__) + /* Per POSIX, siglongjmp has to be implemented as function. Cygwin + provides functions for both, siglongjmp and sigsetjmp since 2.2.0. */ + extern void siglongjmp (sigjmp_buf, int) __attribute__ ((__noreturn__)); + extern int sigsetjmp (sigjmp_buf, int); ++#elif defined(__rtems__) ++/* https://pubs.opengroup.org/onlinepubs/9699919799/functions/siglongjmp.html */ ++extern void siglongjmp (sigjmp_buf, int) __attribute__ ((__noreturn__)); + #endif + + #if defined(__GNUC__) +@@ -485,6 +488,7 @@ extern int sigsetjmp (sigjmp_buf, int); + setjmp (*_sjbuf)); \ + }) + ++#if !defined(__rtems__) && !defined(__DANDELION__) + #define siglongjmp(env, val) \ + __extension__ \ + ({ \ +@@ -494,6 +498,7 @@ extern int sigsetjmp (sigjmp_buf, int); + : 0), \ + longjmp (*_sjbuf, val)); \ + }) ++#endif /* !__rtems__ && !__DANDELION__ */ + + #else /* !__GNUC__ */ + +@@ -501,9 +506,11 @@ extern int sigsetjmp (sigjmp_buf, int); + __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\ + setjmp (env)) + ++#if !defined(__rtems__) && !defined(__DANDELION__) + #define siglongjmp(env, val) ((((env)[_SAVEMASK])?\ + __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\ + longjmp (env, val)) ++#endif /* !__rtems__ && !__DANDELION__ */ + #endif -diff --git a/newlib/libc/sys/Makefile.inc b/newlib/libc/sys/Makefile.inc -index 24d8407d5..c22987333 100644 ---- a/newlib/libc/sys/Makefile.inc -+++ b/newlib/libc/sys/Makefile.inc -@@ -1,3 +1,6 @@ -+if HAVE_LIBC_SYS_DANDELION_DIR -+include %D%/dandelion/Makefile.inc -+endif - if HAVE_LIBC_SYS_A29KHIF_DIR - include %D%/a29khif/Makefile.inc - endif diff --git a/newlib/libc/include/pthread.h b/newlib/libc/include/pthread.h -index c99ad395d..109112630 100644 +index c99ad395..ba50c700 100644 --- a/newlib/libc/include/pthread.h +++ b/newlib/libc/include/pthread.h -@@ -235,18 +235,18 @@ int pthread_attr_setguardsize (pthread_attr_t *__attr, size_t __guardsize); +@@ -57,6 +57,10 @@ int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, + + int pthread_mutexattr_gettype (const pthread_mutexattr_t *__attr, int *__kind); + int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind); ++int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr, ++ int *__robustness); ++int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr, ++ int __robustness); + + #endif + +@@ -79,6 +83,7 @@ int pthread_mutex_destroy (pthread_mutex_t *__mutex); + int pthread_mutex_lock (pthread_mutex_t *__mutex); + int pthread_mutex_trylock (pthread_mutex_t *__mutex); + int pthread_mutex_unlock (pthread_mutex_t *__mutex); ++int pthread_mutex_consistent (pthread_mutex_t *__mutex); + + #if defined(_POSIX_TIMEOUTS) + +@@ -235,18 +240,18 @@ int pthread_attr_setguardsize (pthread_attr_t *__attr, size_t __guardsize); */ #if __GNU_VISIBLE #if defined(__rtems__) @@ -159,3 +498,858 @@ index c99ad395d..109112630 100644 #endif /* defined(__rtems__) */ #endif /* __GNU_VISIBLE */ +diff --git a/newlib/libc/include/regex.h b/newlib/libc/include/regex.h +index fa3e2687..c260aeb4 100644 +--- a/newlib/libc/include/regex.h ++++ b/newlib/libc/include/regex.h +@@ -38,6 +38,7 @@ + #define _REGEX_H_ + + #include ++#include + + /* types */ + typedef off_t regoff_t; +diff --git a/newlib/libc/include/search.h b/newlib/libc/include/search.h +index ed321b0f..3d0d2005 100644 +--- a/newlib/libc/include/search.h ++++ b/newlib/libc/include/search.h +@@ -51,14 +51,18 @@ __BEGIN_DECLS + int hcreate(size_t); + void hdestroy(void); + ENTRY *hsearch(ENTRY, ACTION); ++void insque(void *, void *); ++void *lfind(const void *, const void *, size_t *, size_t, __compar_fn_t); ++void *lsearch(const void *, void *, size_t *, size_t, __compar_fn_t); + int hcreate_r(size_t, struct hsearch_data *); + void hdestroy_r(struct hsearch_data *); + int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); + void *tdelete(const void *__restrict, void **__restrict, __compar_fn_t); + void tdestroy (void *, void (*)(void *)); +-void *tfind(const void *, void **, __compar_fn_t); ++void *tfind(const void *, void *const *, __compar_fn_t); + void *tsearch(const void *, void **, __compar_fn_t); + void twalk(const void *, void (*)(const void *, VISIT, int)); ++void remque(void *); + __END_DECLS + + #endif /* !_SEARCH_H_ */ +diff --git a/newlib/libc/include/signal.h b/newlib/libc/include/signal.h +index 23a9863e..08f8df05 100644 +--- a/newlib/libc/include/signal.h ++++ b/newlib/libc/include/signal.h +@@ -18,6 +18,10 @@ typedef _sig_func_ptr sighandler_t; /* glibc naming */ + #define SIG_DFL ((_sig_func_ptr)0) /* Default action */ + #define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ + #define SIG_ERR ((_sig_func_ptr)-1) /* Error return */ ++#if __XSI_VISIBLE >= 4 ++/* https://github.com/bminor/glibc/blob/master/signal/signal.h */ ++#define SIG_HOLD ((_sig_func_ptr)2) /* Hold signal */ ++#endif + + struct _reent; + +@@ -28,6 +32,18 @@ int _raise_r (struct _reent *, int); + _sig_func_ptr signal (int, _sig_func_ptr); + int raise (int); + void psignal (int, const char *); ++#if __POSIX_VISIBLE >= 200809 ++/* https://man7.org/linux/man-pages/man0/signal.h.0p.html */ ++void psiginfo (const siginfo_t *, const char *); ++#endif ++#if __XSI_VISIBLE >= 4 ++/* https://github.com/bminor/glibc/blob/master/signal/signal.h */ ++int sighold (int); ++int sigignore (int); ++int siginterrupt (int, int); ++int sigrelse (int); ++_sig_func_ptr sigset (int, _sig_func_ptr); ++#endif + #endif + + _END_STD_C +diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h +index 77966578..248a39ff 100644 +--- a/newlib/libc/include/stdio.h ++++ b/newlib/libc/include/stdio.h +@@ -381,8 +381,8 @@ int dprintf (int, const char *__restrict, ...) + _ATTRIBUTE ((__format__ (__printf__, 2, 3))); + # endif + FILE * fmemopen (void *__restrict, size_t, const char *__restrict); +-/* getdelim - see __getdelim for now */ +-/* getline - see __getline for now */ ++ssize_t getdelim (char **__restrict, size_t *__restrict, int, FILE *__restrict); ++ssize_t getline (char **__restrict, size_t *__restrict, FILE *__restrict); + FILE * open_memstream (char **, size_t *); + int vdprintf (int, const char *__restrict, __VALIST) + _ATTRIBUTE ((__format__ (__printf__, 2, 0))); +diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h +index fd89f5ba..c8cfc9fc 100644 +--- a/newlib/libc/include/stdlib.h ++++ b/newlib/libc/include/stdlib.h +@@ -30,6 +30,8 @@ + #include + #endif + ++#include ++ + _BEGIN_STD_C + + typedef struct +@@ -62,7 +64,8 @@ typedef int (*__compar_fn_t) (const void *, const void *); + + #define RAND_MAX __RAND_MAX + +-int __locale_mb_cur_max (void); ++/* https://github.com/bminor/glibc/blob/master/stdlib/stdlib.h */ ++size_t __locale_mb_cur_max (void); + + #define MB_CUR_MAX __locale_mb_cur_max() + +@@ -155,6 +158,9 @@ int rpmatch (const char *response); + #endif + #if __XSI_VISIBLE + void setkey (const char *__key); ++int grantpt (int); ++char * ptsname (int); ++int unlockpt (int); + #endif + void srand (unsigned __seed); + double strtod (const char *__restrict __n, char **__restrict __end_PTR); +@@ -221,6 +227,10 @@ char * ecvtbuf (double, int, int*, int*, char *); + char * fcvtbuf (double, int, int*, int*, char *); + char * ecvtf (float,int,int *,int *); + #endif ++ ++#if __XSI_VISIBLE ++int posix_openpt (int); ++#endif + #ifndef __CYGWIN__ + char * __itoa (int, char *, int); + char * __utoa (unsigned, char *, int); +diff --git a/newlib/libc/include/sys/_default_fcntl.h b/newlib/libc/include/sys/_default_fcntl.h +index ce721fa2..87868abc 100644 +--- a/newlib/libc/include/sys/_default_fcntl.h ++++ b/newlib/libc/include/sys/_default_fcntl.h +@@ -23,7 +23,7 @@ extern "C" { + #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ + #define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ + #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ +-#if defined (__CYGWIN__) ++#if defined (__CYGWIN__) || defined (__DANDELION__) + #define _FBINARY 0x10000 + #define _FTEXT 0x20000 + #endif +@@ -32,7 +32,7 @@ extern "C" { + #define _FNOFOLLOW 0x100000 + #define _FDIRECTORY 0x200000 + #define _FEXECSRCH 0x400000 +-#if defined (__CYGWIN__) ++#if defined (__CYGWIN__) || defined (__DANDELION__) + #define _FTMPFILE 0x800000 + #define _FNOATIME 0x1000000 + #define _FPATH 0x2000000 +@@ -71,7 +71,7 @@ extern "C" { + #define O_DIRECT _FDIRECT + #endif + +-#if defined (__CYGWIN__) ++#if defined (__CYGWIN__) || defined (__DANDELION__) + #define O_BINARY _FBINARY + #define O_TEXT _FTEXT + #define O_DSYNC _FSYNC +@@ -189,7 +189,7 @@ struct flock { + short l_whence; /* flag to choose starting offset */ + long l_start; /* relative offset, in bytes */ + long l_len; /* length, in bytes; 0 means lock to EOF */ +- short l_pid; /* returned with F_GETLK */ ++ int l_pid; /* returned with F_GETLK */ + short l_xxx; /* reserved for future use */ + }; + #endif /* __CYGWIN__ */ +diff --git a/newlib/libc/include/sys/_pthreadtypes.h b/newlib/libc/include/sys/_pthreadtypes.h +index 75e9e1cb..81352bac 100644 +--- a/newlib/libc/include/sys/_pthreadtypes.h ++++ b/newlib/libc/include/sys/_pthreadtypes.h +@@ -85,7 +85,7 @@ typedef struct { + /* located */ + #endif + +-#if defined(_POSIX_THREAD_PRIO_PROTECT) ++#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) + /* Mutexes */ + + /* Values for blocking protocol. */ +@@ -189,6 +189,10 @@ typedef struct { + + typedef __uint32_t pthread_key_t; /* thread-specific data keys */ + ++/* https://github.com/bminor/glibc/blob/master/sysdeps/nptl/pthread.h */ ++#define PTHREAD_MUTEX_STALLED 0 ++#define PTHREAD_MUTEX_ROBUST 1 ++ + typedef struct { + int is_initialized; /* is this structure initialized? */ + int init_executed; /* has the initialization routine been run? */ +diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h +index 5dcc77a8..c327cc53 100644 +--- a/newlib/libc/include/sys/config.h ++++ b/newlib/libc/include/sys/config.h +@@ -238,8 +238,8 @@ + #include + #endif + +-#if defined(__rtems__) +-#define __FILENAME_MAX__ 255 ++#if defined(__rtems__) || defined(__DANDELION__) ++#define __FILENAME_MAX__ 64 + #define _READ_WRITE_RETURN_TYPE _ssize_t + #define __DYNAMIC_REENT__ + #endif +diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h +index 6a925c87..d9d0a63f 100644 +--- a/newlib/libc/include/sys/features.h ++++ b/newlib/libc/include/sys/features.h +@@ -420,7 +420,7 @@ extern "C" { + # define _POSIX_VERSION 199009L + #endif + +-#ifdef __CYGWIN__ ++#if defined(__CYGWIN__) || defined(__DANDELION__) + + #if __POSIX_VISIBLE >= 200809 + #define _POSIX_VERSION 200809L +@@ -454,7 +454,8 @@ extern "C" { + #define _POSIX_IPV6 200809L + #define _POSIX_JOB_CONTROL 1 + #define _POSIX_MAPPED_FILES 200809L +-/* #define _POSIX_MEMLOCK -1 */ ++/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html */ ++#define _POSIX_MEMLOCK 200809L + #define _POSIX_MEMLOCK_RANGE 200809L + #define _POSIX_MEMORY_PROTECTION 200809L + #define _POSIX_MESSAGE_PASSING 200809L +@@ -477,7 +478,8 @@ extern "C" { + #define _POSIX_THREAD_ATTR_STACKADDR 200809L + #define _POSIX_THREAD_ATTR_STACKSIZE 200809L + #define _POSIX_THREAD_CPUTIME 200809L +-/* #define _POSIX_THREAD_PRIO_INHERIT -1 */ ++/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html */ ++#define _POSIX_THREAD_PRIO_INHERIT 200809L + /* #define _POSIX_THREAD_PRIO_PROTECT -1 */ + #define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L + #define _POSIX_THREAD_PROCESS_SHARED 200809L +@@ -486,6 +488,8 @@ extern "C" { + #define _POSIX_THREADS 200809L + #define _POSIX_TIMEOUTS 200809L + #define _POSIX_TIMERS 200809L ++/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html */ ++#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1 + /* #define _POSIX_TRACE -1 */ + /* #define _POSIX_TRACE_EVENT_FILTER -1 */ + /* #define _POSIX_TRACE_INHERIT -1 */ +@@ -538,7 +542,8 @@ extern "C" { + /* #define _XOPEN_REALTIME_THREADS -1 */ + #define _XOPEN_SHM 1 + /* #define _XOPEN_STREAMS -1 */ +-/* #define _XOPEN_UNIX -1 */ ++/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html */ ++#define _XOPEN_UNIX 1 + #endif /* __XSI_VISIBLE */ + + /* +@@ -549,7 +554,7 @@ extern "C" { + */ + #define __STDC_ISO_10646__ 201806L + +-#endif /* __CYGWIN__ */ ++#endif /* __CYGWIN__ || __DANDELION__ */ + + #ifdef __cplusplus + } +diff --git a/newlib/libc/include/sys/resource.h b/newlib/libc/include/sys/resource.h +index c0a0d201..429c962f 100644 +--- a/newlib/libc/include/sys/resource.h ++++ b/newlib/libc/include/sys/resource.h +@@ -5,20 +5,55 @@ + extern "C" { + #endif + ++#include + #include + ++/* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/resource.h */ ++#define PRIO_PROCESS 0 ++#define PRIO_PGRP 1 ++#define PRIO_USER 2 ++ ++/* https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/resource.h */ ++#define RLIMIT_CPU 0 ++#define RLIMIT_FSIZE 1 ++#define RLIMIT_DATA 2 ++#define RLIMIT_STACK 3 ++#define RLIMIT_CORE 4 ++#define RLIMIT_NPROC 6 ++#define RLIMIT_NOFILE 7 ++#define RLIMIT_AS 9 ++ ++/* https://man7.org/linux/man-pages/man0/sys_resource.h.0p.html ++ * https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/resource.h ++ */ ++#ifndef _RLIM_T_DECLARED ++typedef __uint64_t rlim_t; ++#define _RLIM_T_DECLARED ++#endif ++#define RLIM_INFINITY ((rlim_t) ~((rlim_t) 0)) ++#define RLIM_SAVED_MAX RLIM_INFINITY ++#define RLIM_SAVED_CUR RLIM_INFINITY ++ + #define RUSAGE_SELF 0 /* calling process */ + #define RUSAGE_CHILDREN -1 /* terminated child processes */ + ++struct rlimit { ++ rlim_t rlim_cur; ++ rlim_t rlim_max; ++}; ++ + struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + }; + ++int getpriority (int, id_t); ++int getrlimit (int, struct rlimit*); + int getrusage (int, struct rusage*); ++int setpriority (int, id_t, int); ++int setrlimit (int, const struct rlimit*); + + #ifdef __cplusplus + } + #endif + #endif /* !_SYS_RESOURCE_H_ */ +- +diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h +index 96bf9781..2f3318d8 100644 +--- a/newlib/libc/include/sys/signal.h ++++ b/newlib/libc/include/sys/signal.h +@@ -19,11 +19,13 @@ extern "C" { + typedef __sigset_t sigset_t; + #endif + ++typedef void (*_sig_func_ptr)(int); ++ + #if defined(__CYGWIN__) + #include + #else + +-#if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 ++#if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 + + /* sigev_notify values + NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ +@@ -69,19 +71,67 @@ struct sigevent { + typedef struct { + int si_signo; /* Signal number */ + int si_code; /* Cause of the signal */ ++ /* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h */ ++ int si_errno; /* Error number */ ++ pid_t si_pid; /* Sending process ID */ ++ uid_t si_uid; /* Real user ID of sending process */ ++ void *si_addr; /* Faulting instruction/memory reference */ ++ int si_status; /* Exit value or signal */ + union sigval si_value; /* Signal value */ + } siginfo_t; ++ ++/* https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/siginfo.h */ ++#define ILL_ILLOPC 1 ++#define ILL_ILLOPN 2 ++#define ILL_ILLADR 3 ++#define ILL_ILLTRP 4 ++#define ILL_PRVOPC 5 ++#define ILL_PRVREG 6 ++#define ILL_COPROC 7 ++#define ILL_BADSTK 8 ++ ++#define FPE_INTDIV 1 ++#define FPE_INTOVF 2 ++#define FPE_FLTDIV 3 ++#define FPE_FLTOVF 4 ++#define FPE_FLTUND 5 ++#define FPE_FLTRES 6 ++#define FPE_FLTINV 7 ++#define FPE_FLTSUB 8 ++ ++#define SEGV_MAPERR 1 ++#define SEGV_ACCERR 2 ++ ++#define BUS_ADRALN 1 ++#define BUS_ADRERR 2 ++#define BUS_OBJERR 3 ++ ++#define TRAP_BRKPT 1 ++#define TRAP_TRACE 2 ++ ++#define CLD_EXITED 1 ++#define CLD_KILLED 2 ++#define CLD_DUMPED 3 ++#define CLD_TRAPPED 4 ++#define CLD_STOPPED 5 ++#define CLD_CONTINUED 6 + #endif /* defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 */ + + #if defined(__rtems__) + + /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */ + +-#define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */ +-#define SA_SIGINFO 0x2 /* Invoke the signal catching function with */ +- /* three arguments instead of one. */ ++/* https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/signal-defs.h */ ++#define SA_NOCLDSTOP 0x00000001 ++#define SA_NOCLDWAIT 0x00000002 ++#define SA_SIGINFO 0x00000004 + #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 +-#define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */ ++#define SA_ONSTACK 0x08000000 ++#endif ++#if __XSI_VISIBLE >= 4 ++#define SA_RESTART 0x10000000 ++#define SA_NODEFER 0x40000000 ++#define SA_RESETHAND 0x80000000 + #endif + + /* struct sigaction notes from POSIX: +@@ -93,8 +143,6 @@ typedef struct { + * application should not use both simultaneously. + */ + +-typedef void (*_sig_func_ptr)(int); +- + struct sigaction { + int sa_flags; /* Special flags to affect behavior of signal */ + sigset_t sa_mask; /* Additional set of signals to be blocked */ +@@ -115,16 +163,38 @@ struct sigaction { + + #else /* defined(__rtems__) */ + +-#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */ +- +-typedef void (*_sig_func_ptr)(int); ++/* https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/signal-defs.h */ ++#define SA_NOCLDSTOP 0x00000001 ++#define SA_NOCLDWAIT 0x00000002 ++#define SA_SIGINFO 0x00000004 ++#if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 ++#define SA_ONSTACK 0x08000000 ++#endif ++#if __XSI_VISIBLE >= 4 ++#define SA_RESTART 0x10000000 ++#define SA_NODEFER 0x40000000 ++#define SA_RESETHAND 0x80000000 ++#endif + ++/* https://man7.org/linux/man-pages/man0/signal.h.0p.html ++ https://man7.org/linux/man-pages/man7/signal.7.html */ + struct sigaction + { +- _sig_func_ptr sa_handler; +- sigset_t sa_mask; +- int sa_flags; ++ int sa_flags; /* Special flags to affect behavior of signal */ ++ sigset_t sa_mask; /* Additional set of signals to be blocked */ ++ /* during execution of signal-catching */ ++ /* function. */ ++ union { ++ _sig_func_ptr _handler; /* SIG_DFL, SIG_IGN, or pointer to a function */ ++#if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 ++ void (*_sigaction)( int, siginfo_t *, void * ); ++#endif ++ } _signal_handlers; + }; ++#define sa_handler _signal_handlers._handler ++#if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 ++#define sa_sigaction _signal_handlers._sigaction ++#endif + #endif /* defined(__rtems__) */ + #endif /* defined(__CYGWIN__) */ + +@@ -157,6 +227,20 @@ typedef struct sigaltstack { + size_t ss_size; /* Stack size. */ + } stack_t; + ++#if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 ++/* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/x86/sys/ucontext.h */ ++typedef struct __mcontext { ++ int __mc_placeholder; ++} mcontext_t; ++ ++typedef struct __ucontext { ++ struct __ucontext *uc_link; ++ sigset_t uc_sigmask; ++ stack_t uc_stack; ++ mcontext_t uc_mcontext; ++} ucontext_t; ++#endif ++ + #if __POSIX_VISIBLE + #define SIG_SETMASK 0 /* set mask with sigprocmask() */ + #define SIG_BLOCK 1 /* set of signals to block */ +@@ -366,7 +450,11 @@ int str2sig(const char *__restrict, int *__restrict); + #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ + #define SIGUSR1 30 /* user defined signal 1 */ + #define SIGUSR2 31 /* user defined signal 2 */ +-#define NSIG 32 /* signal 0 implied */ ++/* https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/signal.h ++ https://man7.org/linux/man-pages/man7/signal.7.html */ ++#define SIGRTMIN 32 ++#define SIGRTMAX 64 ++#define NSIG 64 /* signal 0 implied */ + #endif + #endif + +diff --git a/newlib/libc/include/sys/stat.h b/newlib/libc/include/sys/stat.h +index 98f5addb..80386094 100644 +--- a/newlib/libc/include/sys/stat.h ++++ b/newlib/libc/include/sys/stat.h +@@ -132,6 +132,10 @@ struct stat + /* Special tv_nsec values for futimens(2) and utimensat(2). */ + #define UTIME_NOW -2L + #define UTIME_OMIT -1L ++#elif defined(__DANDELION__) ++/* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h */ ++#define UTIME_NOW ((1l << 30) - 1l) ++#define UTIME_OMIT ((1l << 30) - 2l) + #endif + + int chmod (const char *__path, mode_t __mode ); +@@ -142,8 +146,10 @@ int mkfifo (const char *__path, mode_t __mode ); + int stat (const char *__restrict __path, struct stat *__restrict __sbuf ); + mode_t umask (mode_t __mask ); + +-#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) ++#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) || defined(__DANDELION__) + int lstat (const char *__restrict __path, struct stat *__restrict __buf ); ++#endif ++#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) || defined(__DANDELION__) + int mknod (const char *__path, mode_t __mode, dev_t __dev ); + #endif + +diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h +index 00901540..d04f8a28 100644 +--- a/newlib/libc/include/sys/unistd.h ++++ b/newlib/libc/include/sys/unistd.h +@@ -530,60 +530,68 @@ int unlinkat (int, const char *, int); + * confstr values per IEEE Std 1003.1, 2004 Edition + */ + +-/* Only defined on Cygwin and RTEMS for now. */ +-#if defined (__CYGWIN__) || defined(__rtems__) ++/* https://git.musl-libc.org/cgit/musl/tree/include/unistd.h */ ++#if defined (__CYGWIN__) || defined(__rtems__) || defined(__DANDELION__) + #define _CS_PATH 0 +-#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1 +-#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS +-#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS +-#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 2 +-#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS +-#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS +-#define _CS_POSIX_V7_ILP32_OFF32_LIBS 3 +-#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS +-#define _CS_XBS5_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS +-#define _CS_XBS5_ILP32_OFF32_LINTFLAGS 4 +-#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 5 +-#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS +-#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS +-#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 6 +-#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS +-#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS +-#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 7 +-#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS +-#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS +-#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 8 +-#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 9 +-#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS +-#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS +-#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 10 +-#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS +-#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS +-#define _CS_POSIX_V7_LP64_OFF64_LIBS 11 +-#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS +-#define _CS_XBS5_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS +-#define _CS_XBS5_LP64_OFF64_LINTFLAGS 12 +-#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 13 +-#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS +-#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS +-#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 14 +-#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS +-#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS +-#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 15 +-#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS +-#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS +-#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 16 +-#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 17 +-#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS +-#define _CS_XBS5_WIDTH_RESTRICTED_ENVS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS +-#define _CS_POSIX_V7_THREADS_CFLAGS 18 +-#define _CS_POSIX_V7_THREADS_LDFLAGS 19 +-#define _CS_V7_ENV 20 +-#define _CS_V6_ENV _CS_V7_ENV +-#define _CS_LFS_CFLAGS 21 +-#define _CS_LFS_LDFLAGS 22 +-#define _CS_LFS_LIBS 23 +-#define _CS_LFS_LINTFLAGS 24 ++#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1 ++#define _CS_XBS5_WIDTH_RESTRICTED_ENVS 5 ++#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5 ++#define _CS_LFS_CFLAGS 1000 ++#define _CS_LFS_LDFLAGS 1001 ++#define _CS_LFS_LIBS 1002 ++#define _CS_LFS_LINTFLAGS 1003 ++#define _CS_XBS5_ILP32_OFF32_CFLAGS 1100 ++#define _CS_XBS5_ILP32_OFF32_LDFLAGS 1101 ++#define _CS_XBS5_ILP32_OFF32_LIBS 1102 ++#define _CS_XBS5_ILP32_OFF32_LINTFLAGS 1103 ++#define _CS_XBS5_ILP32_OFFBIG_CFLAGS 1104 ++#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS 1105 ++#define _CS_XBS5_ILP32_OFFBIG_LIBS 1106 ++#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 1107 ++#define _CS_XBS5_LP64_OFF64_CFLAGS 1108 ++#define _CS_XBS5_LP64_OFF64_LDFLAGS 1109 ++#define _CS_XBS5_LP64_OFF64_LIBS 1110 ++#define _CS_XBS5_LP64_OFF64_LINTFLAGS 1111 ++#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS 1112 ++#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS 1113 ++#define _CS_XBS5_LPBIG_OFFBIG_LIBS 1114 ++#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 1115 ++#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116 ++#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117 ++#define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118 ++#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119 ++#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120 ++#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121 ++#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122 ++#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123 ++#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124 ++#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125 ++#define _CS_POSIX_V6_LP64_OFF64_LIBS 1126 ++#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127 ++#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128 ++#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129 ++#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130 ++#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131 ++#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132 ++#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133 ++#define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134 ++#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135 ++#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136 ++#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137 ++#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138 ++#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139 ++#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140 ++#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141 ++#define _CS_POSIX_V7_LP64_OFF64_LIBS 1142 ++#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143 ++#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144 ++#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145 ++#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146 ++#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147 ++#define _CS_V6_ENV 1148 ++#define _CS_V7_ENV 1149 ++#define _CS_POSIX_V7_THREADS_CFLAGS 1150 ++#define _CS_POSIX_V7_THREADS_LDFLAGS 1151 + #endif + + #ifdef __cplusplus +diff --git a/newlib/libc/include/sys/wait.h b/newlib/libc/include/sys/wait.h +index d15eec9c..cc558bbf 100644 +--- a/newlib/libc/include/sys/wait.h ++++ b/newlib/libc/include/sys/wait.h +@@ -26,9 +26,33 @@ extern "C" { + #define WTERMSIG(w) ((w) & 0x7f) + #define WSTOPSIG WEXITSTATUS + ++#if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 ++#include ++ ++/* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/waitflags.h ++ https://github.com/bminor/glibc/blob/master/bits/waitstatus.h */ ++#define WSTOPPED 2 ++#define WEXITED 4 ++#define WCONTINUED 8 ++#define WNOWAIT 0x01000000 ++#define WIFCONTINUED(w) ((w) == 0xffff) ++ ++/* https://man7.org/linux/man-pages/man2/waitpid.2.html ++ https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/types/idtype_t.h */ ++typedef enum { ++ P_ALL, ++ P_PID, ++ P_PGID ++} idtype_t; ++#endif ++ + pid_t wait (int *); + pid_t waitpid (pid_t, int *, int); + ++#if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 ++int waitid (idtype_t, id_t, siginfo_t *, int); ++#endif ++ + #ifdef _LIBC + pid_t _wait (int *); + #endif +diff --git a/newlib/libc/include/tgmath.h b/newlib/libc/include/tgmath.h +index 97dc50ea..131e2d6d 100644 +--- a/newlib/libc/include/tgmath.h ++++ b/newlib/libc/include/tgmath.h +@@ -162,9 +162,7 @@ + #define nearbyint(__x) __tg_simple(__x, nearbyint) + #define nextafter(__x, __y) __tg_simple2(__x, __y, nextafter) + /* not yet implemented even for _LDBL_EQ_DBL platforms */ +-#ifdef __CYGWIN__ + #define nexttoward(__x, __y) __tg_simplev(__x, nexttoward, __x, __y) +-#endif + #define remainder(__x, __y) __tg_simple2(__x, __y, remainder) + #define remquo(__x, __y, __z) __tg_impl_simple(__x, __x, __y, remquo, remquof, \ + remquol, __x, __y, __z) +diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h +index ed6cc70f..9da512b2 100644 +--- a/newlib/libc/include/time.h ++++ b/newlib/libc/include/time.h +@@ -32,6 +32,16 @@ + #include + #endif + ++/* https://www.man7.org/linux/man-pages/man3/strptime.3.html */ ++#if __GNU_VISIBLE ++# ifndef __TM_GMTOFF ++# define __TM_GMTOFF tm_gmtoff ++# endif ++# ifndef __TM_ZONE ++# define __TM_ZONE tm_zone ++# endif ++#endif ++ + _BEGIN_STD_C + + struct tm +@@ -104,7 +114,7 @@ void _tzset_r (struct _reent *); + + /* getdate functions */ + +-#ifdef HAVE_GETDATE ++#if defined(HAVE_GETDATE) || defined(__DANDELION__) + #if __XSI_VISIBLE >= 4 + #ifndef _REENT_ONLY + #define getdate_err (*__getdate_err()) +@@ -122,17 +132,23 @@ struct tm * getdate (const char *); + 8 invalid input specification */ + #endif /* !_REENT_ONLY */ + #endif /* __XSI_VISIBLE >= 4 */ ++#endif /* HAVE_GETDATE || __DANDELION__ */ + + #if __GNU_VISIBLE + /* getdate_r returns the error code as above */ + int getdate_r (const char *, struct tm *); + #endif /* __GNU_VISIBLE */ +-#endif /* HAVE_GETDATE */ + + /* defines for the opengroup specifications Derived from Issue 1 of the SVID. */ + #if __SVID_VISIBLE || __XSI_VISIBLE + extern __IMPORT long _timezone; + extern __IMPORT int _daylight; ++#ifndef timezone ++#define timezone _timezone ++#endif ++#ifndef daylight ++#define daylight _daylight ++#endif + #endif + #if __POSIX_VISIBLE + extern __IMPORT char *_tzname[2]; +@@ -310,4 +326,3 @@ int clock_getenable_attr (clockid_t clock_id, int *attr); + #endif + + #endif /* _TIME_H_ */ +- +diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c +index b16ec151..62986f65 100644 +--- a/newlib/libc/locale/locale.c ++++ b/newlib/libc/locale/locale.c +@@ -995,7 +995,7 @@ __get_locale_env (struct _reent *p, int category) + } + #endif /* _MB_CAPABLE */ + +-int ++size_t + __locale_mb_cur_max (void) + { + #ifdef __HAVE_LOCALE_INFO__ +diff --git a/newlib/libc/search/tfind.c b/newlib/libc/search/tfind.c +index 670f41fc..fcf85d19 100644 +--- a/newlib/libc/search/tfind.c ++++ b/newlib/libc/search/tfind.c +@@ -26,7 +26,7 @@ __RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); + /* find a node, or return 0 */ + void * + tfind (const void *vkey, /* key to be found */ +- void **vrootp, /* address of the tree root */ ++ void *const *vrootp, /* address of the tree root */ + int (*compar)(const void *, const void *)) + { + node_t **rootp = (node_t **)vrootp; +diff --git a/newlib/libc/sys/Makefile.inc b/newlib/libc/sys/Makefile.inc +index 24d8407d..c2298733 100644 +--- a/newlib/libc/sys/Makefile.inc ++++ b/newlib/libc/sys/Makefile.inc +@@ -1,3 +1,6 @@ ++if HAVE_LIBC_SYS_DANDELION_DIR ++include %D%/dandelion/Makefile.inc ++endif + if HAVE_LIBC_SYS_A29KHIF_DIR + include %D%/a29khif/Makefile.inc + endif +diff --git a/newlib/libm/ld/s_nextafterl.c b/newlib/libm/ld/s_nextafterl.c +index 9c61a436..d535417b 100644 +--- a/newlib/libm/ld/s_nextafterl.c ++++ b/newlib/libm/ld/s_nextafterl.c +@@ -77,4 +77,4 @@ nextafterl(long double x, long double y) + return ux.e; + } + +-__strong_reference(nextafterl, nexttowardl); ++/* Dandelion provides its own nexttowardl stub in libc/sys/dandelion/math_stubs.c. */ +diff --git a/newlib/libm/ld/s_nexttoward.c b/newlib/libm/ld/s_nexttoward.c +index b2a50d31..6c80af33 100644 +--- a/newlib/libm/ld/s_nexttoward.c ++++ b/newlib/libm/ld/s_nexttoward.c +@@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); + #error "Unsupported long double format" + #endif + ++#ifndef __DANDELION__ + double + nexttoward(double x, long double y) + { +@@ -70,3 +71,4 @@ nexttoward(double x, long double y) + INSERT_WORDS(x,hx,lx); + return x; + } ++#endif +diff --git a/newlib/libm/ld/s_nexttowardf.c b/newlib/libm/ld/s_nexttowardf.c +index 9ddfff96..b42439fd 100644 +--- a/newlib/libm/ld/s_nexttowardf.c ++++ b/newlib/libm/ld/s_nexttowardf.c +@@ -20,6 +20,7 @@ __FBSDID("$FreeBSD$"); + + #define LDBL_INFNAN_EXP (LDBL_MAX_EXP * 2 - 1) + ++#ifndef __DANDELION__ + float + nexttowardf(float x, long double y) + { +@@ -57,3 +58,4 @@ nexttowardf(float x, long double y) + SET_FLOAT_WORD(x,hx); + return x; + } ++#endif diff --git a/newlib_shim/patch_script b/newlib_shim/patch_script index 9f92f72..f20a756 100755 --- a/newlib_shim/patch_script +++ b/newlib_shim/patch_script @@ -19,11 +19,18 @@ then fi cp $THIS_DIR/Makefile.inc $1/newlib/libc/sys/dandelion/Makefile.inc cp $THIS_DIR/shim.c $1/newlib/libc/sys/dandelion/shim.c +cp $THIS_DIR/math_stubs.c $1/newlib/libc/sys/dandelion/math_stubs.c cp $THIS_DIR/pthread.c $1/newlib/libc/sys/dandelion/pthread.c +cp $THIS_DIR/search.c $1/newlib/libc/sys/dandelion/search.c +cp $THIS_DIR/signal_dandelion.c $1/newlib/libc/sys/dandelion/signal_dandelion.c cp $THIS_DIR/time.c $1/newlib/libc/sys/dandelion/time.c cp $THIS_DIR/unistd.c $1/newlib/libc/sys/dandelion/unistd.c cp $THIS_DIR/../include/dandelion/crt.h $1/newlib/libc/sys/dandelion/crt.h +if ! test -d $1/newlib/libc/sys/dandelion/sys + then mkdir -p $1/newlib/libc/sys/dandelion/sys +fi +cp $THIS_DIR/sys/fcntl.h $1/newlib/libc/sys/dandelion/sys/fcntl.h cd $1 autoreconf cd newlib -autoreconf \ No newline at end of file +autoreconf diff --git a/newlib_shim/pthread.c b/newlib_shim/pthread.c index d9f5783..ada283e 100644 --- a/newlib_shim/pthread.c +++ b/newlib_shim/pthread.c @@ -2,6 +2,7 @@ #include #include #include +#include #undef errno extern int errno; @@ -14,6 +15,12 @@ extern int errno; int pthread_mutexattr_init(pthread_mutexattr_t *attr) { return EINVAL; } int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) { return EINVAL; } +int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) { + (void)attr; + (void)pshared; + errno = ENOSYS; + return ENOSYS; +} int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict attr, int *restrict type) { return EINVAL; @@ -21,6 +28,32 @@ int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict attr, int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { return EINVAL; } +int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict attr, + int *restrict robust) { + (void)attr; + (void)robust; + errno = ENOSYS; + return ENOSYS; +} +int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, int robust) { + (void)attr; + (void)robust; + errno = ENOSYS; + return ENOSYS; +} +int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict attr, + int *restrict protocol) { + (void)attr; + (void)protocol; + errno = ENOSYS; + return ENOSYS; +} +int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol) { + (void)attr; + (void)protocol; + errno = ENOSYS; + return ENOSYS; +} int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr) { @@ -60,6 +93,13 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) { // since there is only 1 thread, there is no difference return pthread_mutex_trylock(mutex); } +int pthread_mutex_timedlock(pthread_mutex_t *restrict mutex, + const struct timespec *restrict timeout) { + (void)mutex; + (void)timeout; + errno = ENOSYS; + return ENOSYS; +} int pthread_mutex_unlock(pthread_mutex_t *mutex) { pthread_mutex_t current = *mutex; // check is a valid mutex @@ -72,6 +112,10 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex) { *mutex |= LOCKED; return 0; } +int pthread_mutex_consistent(pthread_mutex_t *mutex) { + errno = ENOSYS; + return ENOSYS; +} int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlockattr_t *restrict attr) { @@ -89,6 +133,29 @@ int pthread_cond_init(pthread_cond_t *restrict cond, return EAGAIN; } int pthread_cond_destroy(pthread_cond_t *cond) { return EINVAL; } +int pthread_condattr_init(pthread_condattr_t *attr) { + (void)attr; + errno = ENOSYS; + return ENOSYS; +} +int pthread_condattr_destroy(pthread_condattr_t *attr) { + (void)attr; + errno = ENOSYS; + return ENOSYS; +} +int pthread_condattr_getclock(const pthread_condattr_t *restrict attr, + clockid_t *restrict clock_id) { + (void)attr; + (void)clock_id; + errno = ENOSYS; + return ENOSYS; +} +int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id) { + (void)attr; + (void)clock_id; + errno = ENOSYS; + return ENOSYS; +} int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex) { return ENOTRECOVERABLE; @@ -101,6 +168,26 @@ int pthread_cond_timedwait(pthread_cond_t *restrict cond, int pthread_cond_signal(pthread_cond_t *cond) { return EINVAL; } int pthread_cond_broadcast(pthread_cond_t *cond) { return EINVAL; } +int pthread_barrier_init(pthread_barrier_t *barrier, + const pthread_barrierattr_t *attr, + unsigned count) { + (void)barrier; + (void)attr; + (void)count; + errno = ENOSYS; + return ENOSYS; +} +int pthread_barrier_destroy(pthread_barrier_t *barrier) { + (void)barrier; + errno = ENOSYS; + return ENOSYS; +} +int pthread_barrier_wait(pthread_barrier_t *barrier) { + (void)barrier; + errno = ENOSYS; + return ENOSYS; +} + int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { if (once_control->init_executed == 0) { init_routine(); @@ -118,6 +205,60 @@ int pthread_create(pthread_t *restrict thread, int pthread_join(pthread_t thread, void **retval) { return EINVAL; } int pthread_detach(pthread_t thread) { return EINVAL; } +int pthread_cancel(pthread_t thread) { + (void)thread; + errno = ENOSYS; + return ENOSYS; +} + +int pthread_kill(pthread_t thread, int sig) { + (void)thread; + (void)sig; + errno = ENOSYS; + return ENOSYS; +} + +int pthread_setcancelstate(int state, int *oldstate) { + (void)state; + if (oldstate != NULL) { + *oldstate = PTHREAD_CANCEL_ENABLE; + } + errno = ENOSYS; + return ENOSYS; +} + +int pthread_setcanceltype(int type, int *oldtype) { + (void)type; + if (oldtype != NULL) { + *oldtype = PTHREAD_CANCEL_DEFERRED; + } + errno = ENOSYS; + return ENOSYS; +} + +void pthread_testcancel(void) { errno = ENOSYS; } + +void pthread_exit(void *value_ptr) { + (void)value_ptr; + errno = ENOSYS; + _exit(1); +} + +void _pthread_cleanup_push(struct _pthread_cleanup_context *context, + void (*routine)(void *), void *arg) { + (void)context; + (void)routine; + (void)arg; + errno = ENOSYS; +} + +void _pthread_cleanup_pop(struct _pthread_cleanup_context *context, + int execute) { + (void)context; + (void)execute; + errno = ENOSYS; +} + // TODO replace with heap typedef struct thread_key_struct { pthread_key_t key; @@ -196,4 +337,4 @@ int pthread_key_delete(pthread_key_t key) { int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) { return ENOMEM; -} \ No newline at end of file +} diff --git a/newlib_shim/search.c b/newlib_shim/search.c new file mode 100644 index 0000000..2639a07 --- /dev/null +++ b/newlib_shim/search.c @@ -0,0 +1,38 @@ +#include +#include + +#undef errno +extern int errno; + +void insque(void *elem, void *prev) { + (void)elem; + (void)prev; + errno = ENOSYS; +} + +void *lfind(const void *key, const void *base, size_t *nelp, size_t width, + int (*compar)(const void *, const void *)) { + (void)key; + (void)base; + (void)nelp; + (void)width; + (void)compar; + errno = ENOSYS; + return NULL; +} + +void *lsearch(const void *key, void *base, size_t *nelp, size_t width, + int (*compar)(const void *, const void *)) { + (void)key; + (void)base; + (void)nelp; + (void)width; + (void)compar; + errno = ENOSYS; + return NULL; +} + +void remque(void *elem) { + (void)elem; + errno = ENOSYS; +} diff --git a/newlib_shim/shim.c b/newlib_shim/shim.c index 50deac3..1d91f09 100644 --- a/newlib_shim/shim.c +++ b/newlib_shim/shim.c @@ -1,7 +1,18 @@ #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include #include @@ -207,16 +218,331 @@ int execve(const char *name, char *const argv[], char *const env[]) { return -1; } -int fcntl(int fd, int op, ...) { return -1; } +int fcntl(int fd, int op, ...) { + (void)fd; + (void)op; + errno = ENOSYS; + return -1; +} + +void siglongjmp(sigjmp_buf env, int val) { + (void)env; + (void)val; + fprintf(stderr, "Error: siglongjmp called.\n"); + exit(val); +} + +int posix_fadvise(int fd, off_t offset, off_t len, int advice) { + (void)fd; + (void)offset; + (void)len; + (void)advice; + errno = ENOSYS; + return -1; +} + +int posix_fallocate(int fd, off_t offset, off_t len) { + (void)fd; + (void)offset; + (void)len; + errno = ENOSYS; + return -1; +} + +int clearenv(void) { + errno = ENOSYS; + return -1; +} + +ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter, + FILE *restrict stream) { + (void)lineptr; + (void)n; + (void)delimiter; + (void)stream; + errno = ENOSYS; + return -1; +} + +ssize_t getline(char **restrict lineptr, size_t *restrict n, + FILE *restrict stream) { + (void)lineptr; + (void)n; + (void)stream; + errno = ENOSYS; + return -1; +} int fork() { errno = EAGAIN; return -1; } +int grantpt(int fd) { + (void)fd; + errno = ENOSYS; + return -1; +} + +char *basename(char *path) { + (void)path; + errno = ENOSYS; + return NULL; +} + +char *dirname(char *path) { + (void)path; + errno = ENOSYS; + return NULL; +} + int getpid() { return 1; } -int gettimeofday(struct timeval *p, struct timezone *z) { return -1; } +pid_t getppid(void) { + errno = ENOSYS; + return 0; +} + +gid_t getegid(void) { + errno = ENOSYS; + return 0; +} + +uid_t geteuid(void) { + errno = ENOSYS; + return 0; +} + +int fnmatch(const char *pattern, const char *string, int flags) { + (void)pattern; + (void)string; + (void)flags; + errno = ENOSYS; + return FNM_NOMATCH; +} + +iconv_t iconv_open(const char *tocode, const char *fromcode) { + (void)tocode; + (void)fromcode; + errno = ENOSYS; + return (iconv_t)-1; +} + +size_t iconv(iconv_t cd, char **__restrict inbuf, size_t *__restrict inbytesleft, + char **__restrict outbuf, size_t *__restrict outbytesleft) { + (void)cd; + (void)inbuf; + (void)inbytesleft; + (void)outbuf; + (void)outbytesleft; + errno = ENOSYS; + return (size_t)-1; +} + +int iconv_close(iconv_t cd) { + (void)cd; + errno = ENOSYS; + return -1; +} + +FILE *popen(const char *command, const char *type) { + (void)command; + (void)type; + errno = ENOSYS; + return NULL; +} + +int pclose(FILE *stream) { + (void)stream; + errno = ENOSYS; + return -1; +} + +void flockfile(FILE *stream) { + (void)stream; + errno = ENOSYS; +} + +void funlockfile(FILE *stream) { + (void)stream; + errno = ENOSYS; +} + +int posix_spawn_file_actions_init(posix_spawn_file_actions_t *file_actions) { + (void)file_actions; + errno = ENOSYS; + return ENOSYS; +} + +int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions, + int fildes) { + (void)file_actions; + (void)fildes; + errno = ENOSYS; + return ENOSYS; +} + +int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *file_actions, + int fildes, int newfildes) { + (void)file_actions; + (void)fildes; + (void)newfildes; + errno = ENOSYS; + return ENOSYS; +} + +int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *file_actions) { + (void)file_actions; + errno = ENOSYS; + return ENOSYS; +} + +int posix_spawnp(pid_t *restrict pid, const char *restrict file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *restrict attrp, + char *const argv[restrict], + char *const envp[restrict]) { + (void)pid; + (void)file; + (void)file_actions; + (void)attrp; + (void)argv; + (void)envp; + errno = ENOSYS; + return ENOSYS; +} + +char *initstate(unsigned seed, char *state, size_t size) { + (void)seed; + (void)state; + (void)size; + errno = ENOSYS; + return NULL; +} + +char *setstate(char *state) { + (void)state; + errno = ENOSYS; + return NULL; +} + +time_t time(time_t *timer) { + errno = ENOSYS; + if (timer != NULL) { + *timer = (time_t)-1; + } + return (time_t)-1; +} + +int futimens(int fd, const struct timespec times[2]) { + (void)fd; + (void)times; + errno = ENOSYS; + return -1; +} + +int utimensat(int dirfd, const char *pathname, const struct timespec times[2], + int flags) { + (void)dirfd; + (void)pathname; + (void)times; + (void)flags; + errno = ENOSYS; + return -1; +} + +int getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t buflen, + struct passwd **result) { + (void)name; + (void)pwd; + (void)buffer; + (void)buflen; + if (result != NULL) { + *result = NULL; + } + errno = ENOSYS; + return ENOSYS; +} + +int regcomp(regex_t *restrict preg, const char *restrict pattern, int cflags) { + (void)preg; + (void)pattern; + (void)cflags; + errno = ENOSYS; + return REG_BADPAT; +} + +size_t regerror(int errcode, const regex_t *restrict preg, + char *restrict errbuf, size_t errbuf_size) { + (void)errcode; + (void)preg; + if (errbuf != NULL && errbuf_size != 0) { + errbuf[0] = '\0'; + } + errno = ENOSYS; + return 0; +} + +int regexec(const regex_t *restrict preg, const char *restrict string, + size_t nmatch, regmatch_t pmatch[restrict], int eflags) { + (void)preg; + (void)string; + (void)nmatch; + (void)pmatch; + (void)eflags; + errno = ENOSYS; + return REG_NOMATCH; +} + +void regfree(regex_t *preg) { + (void)preg; + errno = ENOSYS; +} + +pid_t waitpid(pid_t pid, int *status, int options) { + (void)pid; + (void)status; + (void)options; + errno = ENOSYS; + return -1; +} + +int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) { + (void)idtype; + (void)id; + (void)infop; + (void)options; + errno = ENOSYS; + return -1; +} + +int getpriority(int which, id_t who) { + (void)which; + (void)who; + errno = ENOSYS; + return -1; +} + +int getrlimit(int resource, struct rlimit *rlim) { + (void)resource; + (void)rlim; + errno = ENOSYS; + return -1; +} + +int getrusage(int who, struct rusage *usage) { + (void)who; + (void)usage; + errno = ENOSYS; + return -1; +} + +int gettimeofday(struct timeval *restrict p, void *restrict tz) { + (void)p; + (void)tz; + errno = ENOSYS; + return -1; +} int kill(int pid, int sig) { errno = EINVAL; @@ -228,6 +554,33 @@ int pipe(int pipefd[2]) { return -1; } +int posix_openpt(int flags) { + (void)flags; + errno = ENOSYS; + return -1; +} + +char *ptsname(int fd) { + (void)fd; + errno = ENOSYS; + return NULL; +} + +int setpriority(int which, id_t who, int prio) { + (void)which; + (void)who; + (void)prio; + errno = ENOSYS; + return -1; +} + +int setrlimit(int resource, const struct rlimit *rlim) { + (void)resource; + (void)rlim; + errno = ENOSYS; + return -1; +} + ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize) { errno = EACCES; @@ -245,9 +598,23 @@ int sigaction(int signum, const struct sigaction *_Nullable restrict act, return -1; } -long sysconf(int name) { return -1; } +long sysconf(int name) { + (void)name; + errno = ENOSYS; + return -1; +} + +clock_t times(struct tms *buf) { + (void)buf; + errno = ENOSYS; + return -1; +} -clock_t times(struct tms *buf) { return -1; } +int unlockpt(int fd) { + (void)fd; + errno = ENOSYS; + return -1; +} int wait(int *status) { errno = ECHILD; @@ -256,4 +623,4 @@ int wait(int *status) { int wordexp(const char *s, wordexp_t *p, int flags) { return WRDE_NOSPACE; } -void wordfree(wordexp_t *p) { return; } \ No newline at end of file +void wordfree(wordexp_t *p) { return; } diff --git a/newlib_shim/signal_dandelion.c b/newlib_shim/signal_dandelion.c new file mode 100644 index 0000000..c1e817d --- /dev/null +++ b/newlib_shim/signal_dandelion.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#undef sigaddset +#undef sigemptyset +#undef sigismember + +void psiginfo(const siginfo_t *info, const char *message) { + (void)info; + (void)message; +} + +int sighold(int sig) { + (void)sig; + *__errno() = ENOSYS; + return -1; +} + +int sigignore(int sig) { + (void)sig; + *__errno() = ENOSYS; + return -1; +} + +int siginterrupt(int sig, int flag) { + (void)sig; + (void)flag; + *__errno() = ENOSYS; + return -1; +} + +int sigrelse(int sig) { + (void)sig; + *__errno() = ENOSYS; + return -1; +} + +_sig_func_ptr sigset(int sig, _sig_func_ptr disp) { + (void)sig; + (void)disp; + *__errno() = ENOSYS; + return SIG_ERR; +} + +int pthread_sigmask(int how, const sigset_t *restrict set, + sigset_t *restrict oldset) { + (void)how; + (void)set; + *__errno() = ENOSYS; + return -1; +} + +int sigaddset(sigset_t *set, int signo) { + (void)set; + (void)signo; + *__errno() = ENOSYS; + return -1; +} + +int sigemptyset(sigset_t *set) { + (void)set; + *__errno() = ENOSYS; + return -1; +} + +int sigismember(const sigset_t *set, int signo) { + (void)set; + (void)signo; + *__errno() = ENOSYS; + return -1; +} + +int sigprocmask(int how, const sigset_t *restrict set, + sigset_t *restrict oldset) { + (void)how; + (void)set; + *__errno() = ENOSYS; + return -1; +} + +int sigaltstack(const stack_t *restrict ss, stack_t *restrict old_ss) { + (void)ss; + (void)old_ss; + *__errno() = ENOSYS; + return -1; +} diff --git a/newlib_shim/sys/fcntl.h b/newlib_shim/sys/fcntl.h new file mode 100644 index 0000000..d315fd2 --- /dev/null +++ b/newlib_shim/sys/fcntl.h @@ -0,0 +1,38 @@ +#ifndef _SYS_FCNTL_H_ +#define _SYS_FCNTL_H_ + +#include + +/* https://git.musl-libc.org/cgit/musl/tree/include/fcntl.h */ +#ifndef O_TTY_INIT +#define O_TTY_INIT 0 +#endif +/* https://www.gnu.org/s/gnulib/manual/html_node/fcntl_002eh.html */ +#ifndef O_DSYNC +#define O_DSYNC 0 +#endif +#ifndef O_RSYNC +#define O_RSYNC 0 +#endif +/* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/fcntl-linux.h */ +#ifndef POSIX_FADV_NORMAL +#define POSIX_FADV_NORMAL 0 +#define POSIX_FADV_RANDOM 1 +#define POSIX_FADV_SEQUENTIAL 2 +#define POSIX_FADV_WILLNEED 3 +#define POSIX_FADV_DONTNEED 4 +#define POSIX_FADV_NOREUSE 5 +#endif +/* https://github.com/bminor/glibc/blob/master/io/fcntl.h */ +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +__BEGIN_DECLS +int posix_fadvise (int, off_t, off_t, int); +int posix_fallocate (int, off_t, off_t); +__END_DECLS + +#endif /* _SYS_FCNTL_H_ */ diff --git a/newlib_shim/time.c b/newlib_shim/time.c index a75ed52..51b7883 100644 --- a/newlib_shim/time.c +++ b/newlib_shim/time.c @@ -6,6 +6,7 @@ #define _POSIX_MONOTONIC_CLOCK #define __GNU_VISIBLE 0 #include +#include #include #undef errno extern int errno; @@ -13,7 +14,8 @@ extern int errno; #if defined(__aarch64__) static uint64_t __rdtsc() { uint64_t t; - __asm volatile ("mrs %0, cntvct_el0"::"r"(thread_data)); + __asm volatile ("mrs %0, cntvct_el0" : "=r"(t)); + return t; } #elif defined(__x86_64__) static uint64_t __rdtsc() { @@ -25,6 +27,24 @@ extern int errno; #error "Unsupported architecture" #endif +static int dandelion_getdate_err; + +int *__getdate_err(void) { return &dandelion_getdate_err; } + +struct tm *getdate(const char *string) { + (void)string; + dandelion_getdate_err = 0; + errno = ENOSYS; + return NULL; +} + +int getdate_r(const char *string, struct tm *result) { + (void)string; + (void)result; + dandelion_getdate_err = 0; + errno = ENOSYS; + return -1; +} int clock_settime(clockid_t clock_id, const struct timespec *tp) { errno = EINVAL; diff --git a/newlib_shim/unistd.c b/newlib_shim/unistd.c index afcc9e5..b7b4f4e 100644 --- a/newlib_shim/unistd.c +++ b/newlib_shim/unistd.c @@ -32,7 +32,12 @@ int chroot(const char *__path) { // char * ctermid (char *__s); char * cuserid (char *__s); -// int daemon (int nochdir, int noclose); +int daemon(int nochdir, int noclose) { + (void)nochdir; + (void)noclose; + *__errno() = ENOSYS; + return -1; +} // function to duplicate file descriptor to second file number // the filedescriptors should act as one, meaning if seek is called on one of @@ -56,8 +61,18 @@ int euidaccess(const char *__path, int __mode) { // void endusershell (void); // execve is defined in newlib -// int execl (const char *__path, const char *, ...); -// int execle (const char *__path, const char *, ...); +int execl(const char *__path, const char *arg, ...) { + (void)__path; + (void)arg; + *__errno() = ENOSYS; + return -1; +} +int execle(const char *__path, const char *arg, ...) { + (void)__path; + (void)arg; + *__errno() = ENOSYS; + return -1; +} // int execlp (const char *__file, const char *, ...); // #if __MISC_VISIBLE // int execlpe (const char *__file, const char *, ...); @@ -174,7 +189,10 @@ int setgroups(int ngroups, const gid_t *grouplist) { // #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500) // void setusershell (void); // #endif -// unsigned sleep (unsigned int __seconds); +unsigned sleep(unsigned int __seconds) { + *__errno() = ENOSYS; + return __seconds; +} // #if __XSI_VISIBLE // void swab (const void *__restrict, void *__restrict, ssize_t); // #endif @@ -204,7 +222,10 @@ int usleep(useconds_t __useconds) { return 0; } // #endif // #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200809) -// pid_t vfork (void); +pid_t vfork(void) { + *__errno() = ENOSYS; + return -1; +} // #endif // #if __BSD_VISIBLE || __POSIX_VISIBLE < 200112 @@ -238,10 +259,18 @@ int symlink(const char *__name1, const char *__name2) { *__errno() = EPERM; return -1; } + +int mknod(const char *__path, mode_t __mode, dev_t __dev) { + (void)__path; + (void)__mode; + (void)__dev; + *__errno() = ENOSYS; + return -1; +} // #endif // #if __ATFILE_VISIBLE // ssize_t readlinkat (int __dirfd1, const char *__restrict __path, // char *__restrict __buf, size_t __buflen); // int symlinkat (const char *, int, const char *); // int unlinkat (int, const char *, int); -// #endif \ No newline at end of file +// #endif diff --git a/sdk_install/clang-template.cmake b/sdk_install/clang-template.cmake index f7fd75a..685593d 100644 --- a/sdk_install/clang-template.cmake +++ b/sdk_install/clang-template.cmake @@ -1,13 +1,11 @@ # compilation target --target=@TEMPLATE_TARGET@ --D_GNU_SOURCE=1 --D__GNU__ -D__unix__ --D__dandelion__ --D__rtems__ # prevent thread local storage in compilation, TODO: remove if we can provide TLS -D__thread="" -D__TM_GMTOFF=tm_gmtoff +-D__DANDELION__ +-D_POSIX_C_SOURCE=200809L # compiler flags -fPIE @@ -34,4 +32,4 @@ -ldandelion_file_system -ldandelion_runtime -ldandelion_system --lclang_rt.builtins-@ARCHITECTURE@ \ No newline at end of file +-lclang_rt.builtins-@ARCHITECTURE@ From 986f139926ce0e2d1a5381a23d8509f8078459a1 Mon Sep 17 00:00:00 2001 From: Tom Kuchler Date: Fri, 26 Jun 2026 16:30:04 +0200 Subject: [PATCH 12/16] Re-add GNU_SOURCE=1 --- sdk_install/clang-template.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk_install/clang-template.cmake b/sdk_install/clang-template.cmake index 685593d..bfa310c 100644 --- a/sdk_install/clang-template.cmake +++ b/sdk_install/clang-template.cmake @@ -6,6 +6,7 @@ -D__TM_GMTOFF=tm_gmtoff -D__DANDELION__ -D_POSIX_C_SOURCE=200809L +-D_GNU_SOURCE=1 # compiler flags -fPIE From ce117ae207b61edc3a5ddcfed609d51bb3aadb48 Mon Sep 17 00:00:00 2001 From: Tom Kuchler Date: Mon, 29 Jun 2026 10:06:49 +0200 Subject: [PATCH 13/16] Fix formatting --- .github/workflows/file_checks.yml | 4 +- file_system/devices.h | 43 +++++++-------- file_system/file_system.c | 84 +++++++++++++++--------------- file_system/file_system.h | 10 ++-- file_system/fs_implementation.c | 33 ++++++------ file_system/include/fs_interface.h | 4 +- file_system/paths.c | 4 +- newlib_shim/math_stubs.c | 2 +- newlib_shim/pthread.c | 10 ++-- newlib_shim/shim.c | 27 +++++----- newlib_shim/sys/fcntl.h | 7 +-- newlib_shim/time.c | 26 ++++----- newlib_shim/unistd.c | 8 ++- runtime/runtime.c | 32 ++++++------ system/platform/cheri/cheri.c | 3 +- system/platform/debug/debug.c | 10 ++-- 16 files changed, 157 insertions(+), 150 deletions(-) diff --git a/.github/workflows/file_checks.yml b/.github/workflows/file_checks.yml index 014a289..c4c51aa 100644 --- a/.github/workflows/file_checks.yml +++ b/.github/workflows/file_checks.yml @@ -2,10 +2,10 @@ name: Format checks on: push: - branches: [ "main" ] + branches: [ "main", "dev/staging" ] pull_request: - branches: [ "main" ] + branches: [ "main", "dev/staging" ] jobs: build: diff --git a/file_system/devices.h b/file_system/devices.h index 7d8b037..1e74128 100644 --- a/file_system/devices.h +++ b/file_system/devices.h @@ -9,31 +9,32 @@ extern void srand(unsigned int seed); extern void srandom(unsigned int seed); extern long random(void); void urandom_init(int64_t seed) { - // TODO also seed the other random functions from newlib - srand(seed); - srandom(seed); + // TODO also seed the other random functions from newlib + srand(seed); + srandom(seed); }; -size_t urandom_read(char* ptr, size_t len, int64_t offset, char options) { - // ignoring offset and flags; - size_t long_size = sizeof(long); - size_t long_interations = len / long_size; +size_t urandom_read(char *ptr, size_t len, int64_t offset, char options) { + // ignoring offset and flags; + size_t long_size = sizeof(long); + size_t long_interations = len / long_size; - long* long_ptr = (long*) ptr; - for(size_t long_index = 0; long_index < long_interations; long_index++){ - long_ptr[long_index] = random(); - } - - size_t long_offset = long_interations*long_size; - long random_num = random(); - for(size_t char_index = 0; char_index < len - long_offset; char_index++){ - ptr[long_offset + char_index] = (char)(random_num >> (8*char_index)); - } - return len; + long *long_ptr = (long *)ptr; + for (size_t long_index = 0; long_index < long_interations; long_index++) { + long_ptr[long_index] = random(); + } + + size_t long_offset = long_interations * long_size; + long random_num = random(); + for (size_t char_index = 0; char_index < len - long_offset; char_index++) { + ptr[long_offset + char_index] = (char)(random_num >> (8 * char_index)); + } + return len; }; -size_t urandom_write(char* ptr, size_t len, int64_t offset, char options) { - return 0; +size_t urandom_write(char *ptr, size_t len, int64_t offset, char options) { + return 0; }; -// TODO: implement /dev/random with the arc4random, for better but slower randomness +// TODO: implement /dev/random with the arc4random, for better but slower +// randomness #endif //__DANDELION_DEVICES__ \ No newline at end of file diff --git a/file_system/file_system.c b/file_system/file_system.c index ec24d08..835b02f 100644 --- a/file_system/file_system.c +++ b/file_system/file_system.c @@ -1,11 +1,11 @@ #include "file_system.h" -#include "devices.h" -#include "include/fs_interface.h" #include #include "dandelion/runtime.h" #include "dandelion/system/system.h" +#include "devices.h" +#include "include/fs_interface.h" #include "paths.h" OpenFile open_files[FS_MAX_FILES] = {NULL}; @@ -13,51 +13,51 @@ OpenFile open_files[FS_MAX_FILES] = {NULL}; // folders that are always present // initialize with hard links = 1 to make sure we never attempt deallocation D_File fs_root = { - .name = "/\0", - .next = NULL, - .parent = NULL, - .type = DIRECTORY, - .child = NULL, - .hard_links = 1, - .open_descripotors = 0, - .mode = 0, + .name = "/\0", + .next = NULL, + .parent = NULL, + .type = DIRECTORY, + .child = NULL, + .hard_links = 1, + .open_descripotors = 0, + .mode = 0, }; static D_File stdio_folder = { - .name = "stdio\0", - .next = NULL, - .parent = NULL, - .type = DIRECTORY, - .child = NULL, - .hard_links = 1, - .open_descripotors = 0, - .mode = 0, + .name = "stdio\0", + .next = NULL, + .parent = NULL, + .type = DIRECTORY, + .child = NULL, + .hard_links = 1, + .open_descripotors = 0, + .mode = 0, }; static D_File device_folder = { - .name = "dev\0", - .next = NULL, - .parent = NULL, - .type = DIRECTORY, - .child = NULL, - .hard_links = 1, - .open_descripotors = 0, - .mode = 0, + .name = "dev\0", + .next = NULL, + .parent = NULL, + .type = DIRECTORY, + .child = NULL, + .hard_links = 1, + .open_descripotors = 0, + .mode = 0, }; // static devices static Device urandom_device = { - .state = NULL, - .read = urandom_read, - .write = urandom_write, + .state = NULL, + .read = urandom_read, + .write = urandom_write, }; static D_File urandom_file = { - .name = "urandom\0", - .next = NULL, - .parent = NULL, - .type = DEVICE, - .device = &urandom_device, - .hard_links = 1, - .open_descripotors = 0, - .mode = S_IRUSR, + .name = "urandom\0", + .next = NULL, + .parent = NULL, + .type = DEVICE, + .device = &urandom_device, + .hard_links = 1, + .open_descripotors = 0, + .mode = S_IRUSR, }; D_File *create_file(Path *name, char *content, size_t length, uint32_t mode) { @@ -376,8 +376,8 @@ void setup_charpparray(char *data, size_t length, int *entries, if (data_index >= length) break; arguments++; - // are not at the end of the input and have a non space character so are at - // the start of an argument skip over current argument + // are not at the end of the input and have a non space character so are + // at the start of an argument skip over current argument while (data_index < length && data[data_index] != ' ') { // if is escape character, skip to end of escape if (data[data_index] == '\'' || data[data_index] == '\"') { @@ -457,13 +457,13 @@ int fs_initialize(int *argc, char ***argv, char ***environ) { if ((error = link_file_to_folder(&fs_root, &device_folder)) != 0) { return error; } - + // initialize and add urandom device urandom_init(0x39917A73ACA200E4ull); // TODO: get this from input struct if ((error = link_file_to_folder(&device_folder, &urandom_file)) != 0) { return error; } - + // create stdio folder and stdout/stderr file if ((error = link_file_to_folder(&fs_root, &stdio_folder)) != 0) { return error; @@ -685,7 +685,7 @@ int add_output_from_file(D_File *file, Path previous_path, size_t set_index) { return 0; } -int fs_terminate() { +int fs_terminate() { // go through output set names and find all files in folders that are // named after them size_t output_sets = dandelion_output_set_count(); diff --git a/file_system/file_system.h b/file_system/file_system.h index c2e1ed4..8470bfe 100644 --- a/file_system/file_system.h +++ b/file_system/file_system.h @@ -1,10 +1,10 @@ #ifndef __DANDELION_FILE_SYSTEM__ #define __DANDELION_FILE_SYSTEM__ -#include "paths.h" - #include +#include "paths.h" + #ifndef FS_NAME_LENGTH #define FS_NAME_LENGTH 64 #endif @@ -41,10 +41,10 @@ typedef struct FileChunk { typedef struct Device { // for devices that need state can store pointer to arbitrary function - void* state; + void *state; // functions a device needs to implement - size_t(*read)(char*, size_t, int64_t, char); - size_t(*write)(char*, size_t, int64_t, char); + size_t (*read)(char *, size_t, int64_t, char); + size_t (*write)(char *, size_t, int64_t, char); } Device; // Use D_File instead of File, to avoid potential naming overlap diff --git a/file_system/fs_implementation.c b/file_system/fs_implementation.c index 942e707..de1335b 100644 --- a/file_system/fs_implementation.c +++ b/file_system/fs_implementation.c @@ -1,12 +1,11 @@ -#include "file_system.h" -#include "include/fs_interface.h" -#include "paths.h" - #include #include - #include +#include "file_system.h" +#include "include/fs_interface.h" +#include "paths.h" + extern D_File fs_root; extern OpenFile open_files[]; @@ -302,8 +301,8 @@ int64_t dandelion_lseek(int file, int64_t offset, int whence) { to_advance = current->used; } // either advancing inside chunk is enough or there is no next chunk to - // advance to. That means we can take the smaller and advance by that much - // in any case. + // advance to. That means we can take the smaller and advance by that + // much in any case. to_advance = to_advance >= offset ? offset : to_advance; chunk_offset += to_advance; total_offset += to_advance; @@ -344,7 +343,7 @@ size_t dandelion_read(int file, char *ptr, size_t len, int64_t offset, return -EBADF; } - if(open_file->file->type == DEVICE){ + if (open_file->file->type == DEVICE) { size_t result = open_file->file->device->read(ptr, len, offset, options); return result; } else if (open_file->file->type != FILE) { @@ -375,7 +374,8 @@ size_t dandelion_read(int file, char *ptr, size_t len, int64_t offset, } } } else { - // check if current chunk is set, and if not if the file has data to be read + // check if current chunk is set, and if not if the file has data to be + // read if (open_file->current_chunk == NULL) { // set to file chunk if there is one open_file->offset = 0; @@ -401,8 +401,8 @@ size_t dandelion_read(int file, char *ptr, size_t len, int64_t offset, // read everythin in chunk and go to next memcpy(ptr + read_bytes, current->data + chunk_offset, readable); read_bytes += readable; - // advance to next chunk if there is one, otherwise stay at this, so we - // can see new appended chunks in the future + // advance to next chunk if there is one, otherwise stay at this, so + // we can see new appended chunks in the future if (current->next != NULL) { current = current->next; chunk_offset = 0; @@ -428,7 +428,7 @@ size_t dandelion_write(int file, char *ptr, size_t len, int64_t offset, return -EBADF; } - if(open_file->file->type == DEVICE){ + if (open_file->file->type == DEVICE) { return open_file->file->device->write(ptr, len, offset, options); } else if (open_file->file->type != FILE) { return -EINVAL; @@ -448,8 +448,9 @@ size_t dandelion_write(int file, char *ptr, size_t len, int64_t offset, current = d_file->content; // know that the file content is not NULL while (offset > 0) { - // if offset is within the current capacity make sure it is marked used - // to at least the point in offset and set the writer there + // if offset is within the current capacity make sure it is + // marked used to at least the point in offset and set the writer + // there if (offset < current->capacity) { chunk_offset = offset; current->used = offset > current->used ? offset : current->used; @@ -469,8 +470,8 @@ size_t dandelion_write(int file, char *ptr, size_t len, int64_t offset, current = current->next; } } else { - // if have no chunck already check if file has a chunck and write to that - // otherwise allocate one + // if have no chunck already check if file has a chunck and write to + // that otherwise allocate one current = open_file->current_chunk; if (current == NULL) { if (d_file->content == NULL) { diff --git a/file_system/include/fs_interface.h b/file_system/include/fs_interface.h index 5123e4e..28a0fc0 100644 --- a/file_system/include/fs_interface.h +++ b/file_system/include/fs_interface.h @@ -1,11 +1,11 @@ #ifndef _DANDELION_FS_INTERFACE_H #define _DANDELION_FS_INTERFACE_H -#include "../file_system.h" - #include #include +#include "../file_system.h" + #define EPERM 1 #define ENOENT 2 #define EBADF 9 diff --git a/file_system/paths.c b/file_system/paths.c index fd5737e..1a19d36 100644 --- a/file_system/paths.c +++ b/file_system/paths.c @@ -1,7 +1,9 @@ #include "paths.h" -#include "include/fs_interface.h" + #include +#include "include/fs_interface.h" + Path path_from_string(const char *const str) { Path path = {}; size_t index = 0; diff --git a/newlib_shim/math_stubs.c b/newlib_shim/math_stubs.c index 0816c90..80033f1 100644 --- a/newlib_shim/math_stubs.c +++ b/newlib_shim/math_stubs.c @@ -1,5 +1,5 @@ -#include #include +#include // defined by newlib, but not always avaliable in headers #undef errno diff --git a/newlib_shim/pthread.c b/newlib_shim/pthread.c index ada283e..d2c4f57 100644 --- a/newlib_shim/pthread.c +++ b/newlib_shim/pthread.c @@ -81,11 +81,12 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex) { // check it is a valid mutex if ((current & DESTROYED) == 0) return EINVAL; - // check it is locked and not recursive, to give deadlock error, since we only - // have 1 thread + // check it is locked and not recursive, to give deadlock error, since we + // only have 1 thread if ((current & LOCKED) == 0 && (current & RECURSIVE) != 0) return EDEADLK; - // is either not locked, so can just lock it, or is recursive so can relock it + // is either not locked, so can just lock it, or is recursive so can relock + // it *mutex &= ~LOCKED; return 0; } @@ -169,8 +170,7 @@ int pthread_cond_signal(pthread_cond_t *cond) { return EINVAL; } int pthread_cond_broadcast(pthread_cond_t *cond) { return EINVAL; } int pthread_barrier_init(pthread_barrier_t *barrier, - const pthread_barrierattr_t *attr, - unsigned count) { + const pthread_barrierattr_t *attr, unsigned count) { (void)barrier; (void)attr; (void)count; diff --git a/newlib_shim/shim.c b/newlib_shim/shim.c index 1d91f09..2a5371a 100644 --- a/newlib_shim/shim.c +++ b/newlib_shim/shim.c @@ -1,13 +1,14 @@ -#include +#include #include #include +#include +#include #include #include #include +#include #include #include -#include -#include #include #include #include @@ -15,8 +16,6 @@ #include #include #include - -#include #undef errno extern int errno; @@ -110,7 +109,8 @@ extern size_t dandelion_read(int file, char *ptr, size_t len, int64_t offset, char options); #define USE_OFFSET 1 #define MOVE_OFFSET 2 -_READ_WRITE_RETURN_TYPE read(int file, void *ptr, size_t len) { +_READ_WRITE_RETURN_TYPE +read(int file, void *ptr, size_t len) { return process_error(dandelion_read(file, ptr, len, 0, MOVE_OFFSET)); } ssize_t pread(int file, void *ptr, size_t len, off_t offset) { @@ -119,7 +119,8 @@ ssize_t pread(int file, void *ptr, size_t len, off_t offset) { extern size_t dandelion_write(int file, const char *ptr, size_t len, int64_t offset, char options); -_READ_WRITE_RETURN_TYPE write(int file, const void *ptr, size_t len) { +_READ_WRITE_RETURN_TYPE +write(int file, const void *ptr, size_t len) { return process_error( dandelion_write(file, (const char *)ptr, len, 0, MOVE_OFFSET)); } @@ -328,8 +329,9 @@ iconv_t iconv_open(const char *tocode, const char *fromcode) { return (iconv_t)-1; } -size_t iconv(iconv_t cd, char **__restrict inbuf, size_t *__restrict inbytesleft, - char **__restrict outbuf, size_t *__restrict outbytesleft) { +size_t iconv(iconv_t cd, char **__restrict inbuf, + size_t *__restrict inbytesleft, char **__restrict outbuf, + size_t *__restrict outbytesleft) { (void)cd; (void)inbuf; (void)inbytesleft; @@ -400,8 +402,7 @@ int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *file_actions) { int posix_spawnp(pid_t *restrict pid, const char *restrict file, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, - char *const argv[restrict], - char *const envp[restrict]) { + char *const argv[restrict], char *const envp[restrict]) { (void)pid; (void)file; (void)file_actions; @@ -451,8 +452,8 @@ int utimensat(int dirfd, const char *pathname, const struct timespec times[2], return -1; } -int getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t buflen, - struct passwd **result) { +int getpwnam_r(const char *name, struct passwd *pwd, char *buffer, + size_t buflen, struct passwd **result) { (void)name; (void)pwd; (void)buffer; diff --git a/newlib_shim/sys/fcntl.h b/newlib_shim/sys/fcntl.h index d315fd2..97c034e 100644 --- a/newlib_shim/sys/fcntl.h +++ b/newlib_shim/sys/fcntl.h @@ -14,7 +14,8 @@ #ifndef O_RSYNC #define O_RSYNC 0 #endif -/* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/fcntl-linux.h */ +/* https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/bits/fcntl-linux.h + */ #ifndef POSIX_FADV_NORMAL #define POSIX_FADV_NORMAL 0 #define POSIX_FADV_RANDOM 1 @@ -31,8 +32,8 @@ #endif __BEGIN_DECLS -int posix_fadvise (int, off_t, off_t, int); -int posix_fallocate (int, off_t, off_t); +int posix_fadvise(int, off_t, off_t, int); +int posix_fallocate(int, off_t, off_t); __END_DECLS #endif /* _SYS_FCNTL_H_ */ diff --git a/newlib_shim/time.c b/newlib_shim/time.c index 51b7883..c23be34 100644 --- a/newlib_shim/time.c +++ b/newlib_shim/time.c @@ -12,17 +12,17 @@ extern int errno; #if defined(__aarch64__) - static uint64_t __rdtsc() { - uint64_t t; - __asm volatile ("mrs %0, cntvct_el0" : "=r"(t)); - return t; - } +static uint64_t __rdtsc() { + uint64_t t; + __asm volatile("mrs %0, cntvct_el0" : "=r"(t)); + return t; +} #elif defined(__x86_64__) - static uint64_t __rdtsc() { - uint64_t t; - __asm volatile ("rdtsc": "=A"(t)); - return t; - } +static uint64_t __rdtsc() { + uint64_t t; + __asm volatile("rdtsc" : "=A"(t)); + return t; +} #else #error "Unsupported architecture" #endif @@ -51,8 +51,10 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp) { return -1; } int clock_gettime(clockid_t clock_id, struct timespec *tp) { - // TODO add static timestamp at the start to offset here and possibly fix to get actual realtime instead of offset one - // TODO check if we need to differentiate any of these and if they need setup from the dandelion side + // TODO add static timestamp at the start to offset here and possibly fix to + // get actual realtime instead of offset one + // TODO check if we need to differentiate any of these and if they need setup + // from the dandelion side static char is_initialized = 0; static uint64_t base_time; if (is_initialized == 0) { diff --git a/newlib_shim/unistd.c b/newlib_shim/unistd.c index b7b4f4e..d2f5faa 100644 --- a/newlib_shim/unistd.c +++ b/newlib_shim/unistd.c @@ -95,11 +95,9 @@ int execv(const char *__path, char *const __argv[]) { // int fchown (int __fildes, uid_t __owner, gid_t __group); // #if __ATFILE_VISIBLE -// int fchownat (int __dirfd, const char *__path, uid_t __owner, gid_t __group, -// int __flags); -// #endif -// int fexecve (int __fd, char * const __argv[], char * const __envp[]); -// long fpathconf (int __fd, int __name); +// int fchownat (int __dirfd, const char *__path, uid_t __owner, gid_t +// __group, int __flags); #endif int fexecve (int __fd, char * const +// __argv[], char * const __envp[]); long fpathconf (int __fd, int __name); int fsync(int __fd) { return 0; } int fdatasync(int __fd) { return 0; } diff --git a/runtime/runtime.c b/runtime/runtime.c index a56f5c0..8597a00 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -1,6 +1,6 @@ #include "../include/dandelion/runtime.h" -#include "../include/dandelion/system/system.h" +#include "../include/dandelion/system/system.h" #include "runtime.h" #define sysdata __dandelion_system_data @@ -183,11 +183,11 @@ static inline size_t get_sbrk_size(size_t size, size_t alignment) { /// The one at the start showing the occupation and the index of the end /// descriptor. The one at the end giving the index of the start one as well as /// occupation. The next slab can be found by indexing 1 past the start/end -/// descriptor. MAX_VALUE is used as a place holder past the last allocation, to -/// ensure we have space for a descriptor to describe how far it is to any new -/// allocation. If the new allocation is not contiguous with the current one, -/// this descriptor can be used to mark the space between the allocations as -/// occupied. +/// descriptor. MAX_VALUE is used as a place holder past the last allocation, +/// to ensure we have space for a descriptor to describe how far it is to any +/// new allocation. If the new allocation is not contiguous with the current +/// one, this descriptor can be used to mark the space between the allocations +/// as occupied. /// /// Example: /// Normal allocation @@ -216,9 +216,9 @@ void *dandelion_alloc(size_t size, size_t alignment) { local_alignment = local_alignment == 0 ? 1 : local_alignment; if (free_root == NULL) { - // add 2 size_t to ask size for minimal bookkeeping we need and alignment - // so we guarantee to get a usable allocation. Round size to multiple of - // default allocation. + // add 2 size_t to ask size for minimal bookkeeping we need and + // alignment so we guarantee to get a usable allocation. Round size to + // multiple of default allocation. size_t allocation_size = get_sbrk_size(local_size, local_alignment); free_root = dandelion_sbrk(allocation_size); if (free_root == NULL) { @@ -306,15 +306,15 @@ void *dandelion_alloc(size_t size, size_t alignment) { if (skip_indices != 0) { if (skip_indices < 3) { if (start != 0) { - // know that previous was occupied, otherwise would have been fused with - // start + // know that previous was occupied, otherwise would have been + // fused with start size_t previous_start = free_root[start - 1] & ~OCCUPIED_FLAG; free_root[previous_start] = (actual_start - 1) | OCCUPIED_FLAG; free_root[actual_start - 1] = previous_start | OCCUPIED_FLAG; } else { - // mark as occupied, this is either one or two indices. If it is one we - // write the same thing to it twice, if it is two we have an empty free - // allocation + // mark as occupied, this is either one or two indices. If it is + // one we write the same thing to it twice, if it is two we have + // an empty free allocation free_root[0] = (actual_start - 1); free_root[actual_start - 1] = 0; } @@ -339,8 +339,8 @@ void *dandelion_alloc(size_t size, size_t alignment) { free_root[actual_end + 1] = end; free_root[end] = actual_end + 1; } else { - // only one or two indices to spare before next allocation, so just extend - // this allocation + // only one or two indices to spare before next allocation, so just + // extend this allocation actual_end = end; } free_root[actual_start] = actual_end | OCCUPIED_FLAG; diff --git a/system/platform/cheri/cheri.c b/system/platform/cheri/cheri.c index a98089f..bef3ddd 100644 --- a/system/platform/cheri/cheri.c +++ b/system/platform/cheri/cheri.c @@ -1,6 +1,7 @@ -#include "../../system.h" #include +#include "../../system.h" + const void *__capability __dandelion_return_address; void __dandelion_platform_init(void) {} diff --git a/system/platform/debug/debug.c b/system/platform/debug/debug.c index e02bdf0..f3f2425 100644 --- a/system/platform/debug/debug.c +++ b/system/platform/debug/debug.c @@ -1,9 +1,9 @@ +#include +#include + #include "../../system.h" #include "dandelion/system/system.h" - #include "syscall.h" -#include -#include #define sysdata __dandelion_system_data @@ -119,7 +119,6 @@ static void *debug_alloc(size_t size) { } void __dandelion_platform_init(void) { - size_t alloc_size = 1ull << 31; void *heap_ptr = vm_alloc(alloc_size); void *heap_end = (void *)((char *)heap_ptr + alloc_size); @@ -154,7 +153,8 @@ void __dandelion_platform_init(void) { while ((dirent_read = __syscall(SYS_getdents64, in_sets_fd, &dirent_buffer, DIRENT_BUF_SIZE)) > 0) { - // have read one or more entries, need to process them before reading again + // have read one or more entries, need to process them before reading + // again for (long dirent_offset = 0; dirent_offset < dirent_read; dirent_offset += ((linux_dirent *)&dirent_buffer[dirent_offset])->d_reclen) { From aa9e5e7f6c00288945af01f53eea44d5d0a66dd5 Mon Sep 17 00:00:00 2001 From: Tom Kuchler Date: Mon, 29 Jun 2026 10:27:10 +0200 Subject: [PATCH 14/16] Fix formatting in new folders --- .github/workflows/file_checks.yml | 2 +- libc_extension/aio.c | 1 - libc_extension/crypt.c | 2 +- libc_extension/ifaddrs.c | 6 +- libc_extension/include/aio.h | 4 +- libc_extension/include/ifaddrs.h | 8 +- libc_extension/include/mntent.h | 14 +- libc_extension/include/monetary.h | 2 +- libc_extension/include/mqueue.h | 3 +- libc_extension/include/netdb.h | 173 +++--- libc_extension/include/netinet/in.h | 46 +- libc_extension/include/sys/ipc.h | 12 +- libc_extension/include/sys/mman.h | 36 +- libc_extension/include/sys/poll.h | 3 +- libc_extension/include/sys/sem.h | 16 +- libc_extension/include/sys/shm_template.h | 9 +- libc_extension/include/sys/socket.h | 506 +++++++++--------- libc_extension/include/sys/statvfs.h | 2 +- libc_extension/include/sys/termios.h | 211 ++++---- libc_extension/include/sys/uio.h | 13 +- libc_extension/include/sys/utsname_template.h | 10 +- libc_extension/include/syslog.h | 64 +-- libc_extension/include/utmpx.h | 14 +- libc_extension/monetary.c | 5 +- libc_extension/net_if.c | 2 +- libc_extension/netdb.c | 164 +++--- libc_extension/pthread.c | 4 +- libc_extension/sched.c | 4 +- libc_extension/socket.c | 263 +++++---- libc_extension/sys_mman.c | 3 +- libc_extension/sys_sem.c | 2 +- libc_extension/syslog.c | 4 +- libc_extension/uio.c | 26 +- 33 files changed, 843 insertions(+), 791 deletions(-) diff --git a/.github/workflows/file_checks.yml b/.github/workflows/file_checks.yml index c4c51aa..6f37be1 100644 --- a/.github/workflows/file_checks.yml +++ b/.github/workflows/file_checks.yml @@ -17,4 +17,4 @@ jobs: - name: C format check run: find . -iname '*.h' -o -iname '*.c' | clang-format --dry-run -Werror --files=/dev/stdin --style=LLVM # if fails run the following to automatically correct it - # find ./file_system/ ./newlib_shim/ ./runtime/ ./sdk_install/ ./system/ ./test_programs/ -iname '*.h' -o -iname '*.c' | clang-format -Werror --files=/dev/stdin --style=LLVM -i \ No newline at end of file + # find ./libc_extension/ ./file_system/ ./newlib_shim/ ./runtime/ ./sdk_install/ ./system/ ./test_programs/ -iname '*.h' -o -iname '*.c' | clang-format -Werror --files=/dev/stdin --style=LLVM -i \ No newline at end of file diff --git a/libc_extension/aio.c b/libc_extension/aio.c index 1799601..39aa3c7 100644 --- a/libc_extension/aio.c +++ b/libc_extension/aio.c @@ -1,7 +1,6 @@ #include #include - // https://man7.org/linux/man-pages/man7/aio.7.html int aio_cancel(int fd, struct aiocb *aiocbp) { diff --git a/libc_extension/crypt.c b/libc_extension/crypt.c index f762b94..e4e2be4 100644 --- a/libc_extension/crypt.c +++ b/libc_extension/crypt.c @@ -1,5 +1,5 @@ -#include #include +#include char *crypt(const char *phrase, const char *setting) { (void)phrase; diff --git a/libc_extension/ifaddrs.c b/libc_extension/ifaddrs.c index 1254563..f18e9f7 100644 --- a/libc_extension/ifaddrs.c +++ b/libc_extension/ifaddrs.c @@ -1,9 +1,9 @@ -#include #include +#include -int getifaddrs (struct ifaddrs **__ifap) { +int getifaddrs(struct ifaddrs **__ifap) { (void)__ifap; errno = ENOSYS; return -1; } -void freeifaddrs (struct ifaddrs *__ifa) { return; } +void freeifaddrs(struct ifaddrs *__ifa) { return; } diff --git a/libc_extension/include/aio.h b/libc_extension/include/aio.h index b8e6648..9ee3c25 100644 --- a/libc_extension/include/aio.h +++ b/libc_extension/include/aio.h @@ -10,9 +10,9 @@ extern "C" { #endif -/* https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/librt-ddefs.html */ +/* https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/librt-ddefs.html + */ - /* POSIX AIO cancellation status codes */ #define AIO_CANCELED 0 #define AIO_NOTCANCELED 1 diff --git a/libc_extension/include/ifaddrs.h b/libc_extension/include/ifaddrs.h index c91b73c..281f8e4 100644 --- a/libc_extension/include/ifaddrs.h +++ b/libc_extension/include/ifaddrs.h @@ -1,7 +1,7 @@ /* THIS IS A DUMMY HEADER */ #ifndef _IFADDRS_H -#define _IFADDRS_H 1 +#define _IFADDRS_H 1 #include @@ -17,11 +17,11 @@ struct ifaddrs { struct sockaddr *ifu_broadaddr; struct sockaddr *ifu_dstaddr; } ifa_ifu; - + void *ifa_data; }; -extern int getifaddrs (struct ifaddrs **__ifap); -extern void freeifaddrs (struct ifaddrs *__ifa); +extern int getifaddrs(struct ifaddrs **__ifap); +extern void freeifaddrs(struct ifaddrs *__ifa); #endif /* ifaddrs.h */ diff --git a/libc_extension/include/mntent.h b/libc_extension/include/mntent.h index 8c77b02..72f71de 100644 --- a/libc_extension/include/mntent.h +++ b/libc_extension/include/mntent.h @@ -9,14 +9,14 @@ extern "C" { /* https://codebrowser.dev/glibc/glibc/misc/mntent.h.html */ #define MNTTYPE_IGNORE "ignore" -#define MNTTYPE_NFS "nfs" -#define MNTTYPE_SWAP "swap" +#define MNTTYPE_NFS "nfs" +#define MNTTYPE_SWAP "swap" #define MNTOPT_DEFAULTS "defaults" -#define MNTOPT_RO "ro" -#define MNTOPT_RW "rw" -#define MNTOPT_SUID "suid" -#define MNTOPT_NOSUID "nosuid" -#define MNTOPT_NOAUTO "noauto" +#define MNTOPT_RO "ro" +#define MNTOPT_RW "rw" +#define MNTOPT_SUID "suid" +#define MNTOPT_NOSUID "nosuid" +#define MNTOPT_NOAUTO "noauto" struct mntent { char *mnt_fsname; diff --git a/libc_extension/include/monetary.h b/libc_extension/include/monetary.h index fc31cc9..c533c72 100644 --- a/libc_extension/include/monetary.h +++ b/libc_extension/include/monetary.h @@ -1,9 +1,9 @@ #ifndef _MONETARY_H_ #define _MONETARY_H_ +#include #include #include -#include __BEGIN_DECLS diff --git a/libc_extension/include/mqueue.h b/libc_extension/include/mqueue.h index 84c2934..b16bc86 100644 --- a/libc_extension/include/mqueue.h +++ b/libc_extension/include/mqueue.h @@ -26,8 +26,7 @@ int mq_notify(mqd_t, const struct sigevent *); mqd_t mq_open(const char *, int, ...); ssize_t mq_receive(mqd_t, char *, size_t, unsigned *); int mq_send(mqd_t, const char *, size_t, unsigned); -int mq_setattr(mqd_t, const struct mq_attr *restrict, - struct mq_attr *restrict); +int mq_setattr(mqd_t, const struct mq_attr *restrict, struct mq_attr *restrict); ssize_t mq_timedreceive(mqd_t, char *restrict, size_t, unsigned *restrict, const struct timespec *restrict); int mq_timedsend(mqd_t, const char *, size_t, unsigned, diff --git a/libc_extension/include/netdb.h b/libc_extension/include/netdb.h index 3d69519..9335407 100644 --- a/libc_extension/include/netdb.h +++ b/libc_extension/include/netdb.h @@ -1,63 +1,58 @@ -#ifndef _NETDB_H -#define _NETDB_H 1 +#ifndef _NETDB_H +#define _NETDB_H 1 -#include #include #include +#include #ifdef __cplusplus extern "C" { #endif /* Description of data base entry for a single host. */ -struct hostent -{ - char *h_name; /* Official name of host. */ - char **h_aliases; /* Alias list. */ - int h_addrtype; /* Host address type. */ - int h_length; /* Length of address. */ - char **h_addr_list; /* List of addresses from name server. */ +struct hostent { + char *h_name; /* Official name of host. */ + char **h_aliases; /* Alias list. */ + int h_addrtype; /* Host address type. */ + int h_length; /* Length of address. */ + char **h_addr_list; /* List of addresses from name server. */ }; /* Description of data base entry for a single network. NOTE: here a poor assumption is made. The network number is expected to fit into an unsigned long int variable. */ -struct netent -{ - char *n_name; /* Official name of network. */ - char **n_aliases; /* Alias list. */ - int n_addrtype; /* Net address type. */ - uint32_t n_net; /* Network number. */ +struct netent { + char *n_name; /* Official name of network. */ + char **n_aliases; /* Alias list. */ + int n_addrtype; /* Net address type. */ + uint32_t n_net; /* Network number. */ }; /* Description of data base entry for a single service. */ -struct protoent -{ - char *p_name; /* Official protocol name. */ - char **p_aliases; /* Alias list. */ - int p_proto; /* Protocol number. */ +struct protoent { + char *p_name; /* Official protocol name. */ + char **p_aliases; /* Alias list. */ + int p_proto; /* Protocol number. */ }; /* Description of data base entry for a single service. */ -struct servent -{ - char *s_name; /* Official service name. */ - char **s_aliases; /* Alias list. */ - int s_port; /* Port number. */ - char *s_proto; /* Protocol to use. */ +struct servent { + char *s_name; /* Official service name. */ + char **s_aliases; /* Alias list. */ + int s_port; /* Port number. */ + char *s_proto; /* Protocol to use. */ }; -# define IPPORT_RESERVED 1024 +#define IPPORT_RESERVED 1024 extern int h_errno; -# define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */ -# define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL. */ -# define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */ -# define NO_DATA 4 /* Valid name, no data record of requested type. */ +#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */ +#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL. */ +#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */ +#define NO_DATA 4 /* Valid name, no data record of requested type. */ -struct addrinfo -{ +struct addrinfo { int ai_flags; int ai_family; int ai_socktype; @@ -69,65 +64,65 @@ struct addrinfo }; /* https://sources.debian.org/src/glibc/2.43-1/resolv/netdb.h */ -# define AI_PASSIVE 0x0001 -# define AI_CANONNAME 0x0002 -# define AI_NUMERICHOST 0x0004 -# define AI_V4MAPPED 0x0008 -# define AI_ALL 0x0010 -# define AI_ADDRCONFIG 0x0020 -# define AI_NUMERICSERV 0x0400 +#define AI_PASSIVE 0x0001 +#define AI_CANONNAME 0x0002 +#define AI_NUMERICHOST 0x0004 +#define AI_V4MAPPED 0x0008 +#define AI_ALL 0x0010 +#define AI_ADDRCONFIG 0x0020 +#define AI_NUMERICSERV 0x0400 /* https://git.musl-libc.org/cgit/musl/tree/include/netdb.h */ - # define NI_NUMERICHOST 0x0001 - # define NI_NUMERICSERV 0x0002 -# define NI_NOFQDN 0x0004 -# define NI_NAMEREQD 0x0008 -# define NI_DGRAM 0x0010 -# define NI_NUMERICSCOPE 0x000000100 +#define NI_NUMERICHOST 0x0001 +#define NI_NUMERICSERV 0x0002 +#define NI_NOFQDN 0x0004 +#define NI_NAMEREQD 0x0008 +#define NI_DGRAM 0x0010 +#define NI_NUMERICSCOPE 0x000000100 /* https://sources.debian.org/src/glibc/2.43-1/resolv/netdb.h */ -# define EAI_BADFLAGS -1 -# define EAI_NONAME -2 -# define EAI_AGAIN -3 -# define EAI_FAIL -4 -# define EAI_FAMILY -6 -# define EAI_SOCKTYPE -7 -# define EAI_SERVICE -8 -# define EAI_MEMORY -10 -# define EAI_SYSTEM -11 -# define EAI_OVERFLOW -12 - -extern void endhostent (void); -extern void endnetent (void); -extern void endprotoent (void); -extern void endservent (void); -extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len, int __type); -extern struct hostent *gethostbyname (const char *__name); -extern struct hostent *gethostent (void); -extern struct netent *getnetbyaddr (uint32_t __net, int __type); -extern struct netent *getnetbyname (const char *__name); -extern struct netent *getnetent (void); -extern struct protoent *getprotobyname (const char *__name); -extern struct protoent *getprotobynumber (int __proto); -extern struct protoent *getprotoent (void); -extern struct servent *getservbyname (const char *__name, const char *__proto); -extern struct servent *getservbyport (int __port, const char *__proto); -extern struct servent *getservent (void); -extern void sethostent (int __stay_open); -extern void setnetent (int __stay_open); -extern void setprotoent (int __stay_open); -extern void setservent (int __stay_open); -extern void freeaddrinfo (struct addrinfo *__ai); -extern int getaddrinfo (const char *__restrict __name, - const char *__restrict __service, - const struct addrinfo *__restrict __req, - struct addrinfo **__restrict __pai); -extern int getnameinfo (const struct sockaddr *__restrict __sa, - socklen_t __salen, - char *__restrict __host, socklen_t __hostlen, - char *__restrict __serv, socklen_t __servlen, - int __flags); -extern const char *gai_strerror (int __ecode); +#define EAI_BADFLAGS -1 +#define EAI_NONAME -2 +#define EAI_AGAIN -3 +#define EAI_FAIL -4 +#define EAI_FAMILY -6 +#define EAI_SOCKTYPE -7 +#define EAI_SERVICE -8 +#define EAI_MEMORY -10 +#define EAI_SYSTEM -11 +#define EAI_OVERFLOW -12 + +extern void endhostent(void); +extern void endnetent(void); +extern void endprotoent(void); +extern void endservent(void); +extern struct hostent *gethostbyaddr(const void *__addr, __socklen_t __len, + int __type); +extern struct hostent *gethostbyname(const char *__name); +extern struct hostent *gethostent(void); +extern struct netent *getnetbyaddr(uint32_t __net, int __type); +extern struct netent *getnetbyname(const char *__name); +extern struct netent *getnetent(void); +extern struct protoent *getprotobyname(const char *__name); +extern struct protoent *getprotobynumber(int __proto); +extern struct protoent *getprotoent(void); +extern struct servent *getservbyname(const char *__name, const char *__proto); +extern struct servent *getservbyport(int __port, const char *__proto); +extern struct servent *getservent(void); +extern void sethostent(int __stay_open); +extern void setnetent(int __stay_open); +extern void setprotoent(int __stay_open); +extern void setservent(int __stay_open); +extern void freeaddrinfo(struct addrinfo *__ai); +extern int getaddrinfo(const char *__restrict __name, + const char *__restrict __service, + const struct addrinfo *__restrict __req, + struct addrinfo **__restrict __pai); +extern int getnameinfo(const struct sockaddr *__restrict __sa, + socklen_t __salen, char *__restrict __host, + socklen_t __hostlen, char *__restrict __serv, + socklen_t __servlen, int __flags); +extern const char *gai_strerror(int __ecode); #ifdef __cplusplus } diff --git a/libc_extension/include/netinet/in.h b/libc_extension/include/netinet/in.h index 9ec374c..68c477d 100644 --- a/libc_extension/include/netinet/in.h +++ b/libc_extension/include/netinet/in.h @@ -1,8 +1,8 @@ #ifndef _NETINET_IN_H_ #define _NETINET_IN_H_ -#include #include +#include #include /* https://git.musl-libc.org/cgit/musl/tree/include/netinet/in.h */ @@ -54,8 +54,18 @@ extern const struct in6_addr in6addr_any; extern const struct in6_addr in6addr_loopback; /* https://sources.debian.org/src/glibc/2.41-7/inet/netinet/in.h/ */ -#define IN6ADDR_ANY_INIT { { { 0 } } } -#define IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } } } +#define IN6ADDR_ANY_INIT \ + { \ + { \ + { 0 } \ + } \ + } +#define IN6ADDR_LOOPBACK_INIT \ + { \ + { \ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } \ + } \ + } /* https://git.musl-libc.org/cgit/musl/tree/include/netinet/in.h */ #define IPV6_UNICAST_HOPS 16 @@ -66,32 +76,32 @@ extern const struct in6_addr in6addr_loopback; #define IPV6_LEAVE_GROUP 21 #define IPV6_V6ONLY 26 -#define IN6_IS_ADDR_UNSPECIFIED(a) \ - ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ (a)->s6_addr32[2] == 0 && (a)->s6_addr32[3] == 0) -#define IN6_IS_ADDR_LOOPBACK(a) \ - ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ +#define IN6_IS_ADDR_LOOPBACK(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ (a)->s6_addr32[2] == 0 && (a)->s6_addr32[3] == htonl(1)) #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) -#define IN6_IS_ADDR_LINKLOCAL(a) \ +#define IN6_IS_ADDR_LINKLOCAL(a) \ ((a)->s6_addr[0] == 0xfe && ((a)->s6_addr[1] & 0xc0) == 0x80) -#define IN6_IS_ADDR_SITELOCAL(a) \ +#define IN6_IS_ADDR_SITELOCAL(a) \ ((a)->s6_addr[0] == 0xfe && ((a)->s6_addr[1] & 0xc0) == 0xc0) -#define IN6_IS_ADDR_V4MAPPED(a) \ - ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ (a)->s6_addr32[2] == htonl(0xffff)) -#define IN6_IS_ADDR_V4COMPAT(a) \ - ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((a)->s6_addr32[0] == 0 && (a)->s6_addr32[1] == 0 && \ (a)->s6_addr32[2] == 0 && ntohl((a)->s6_addr32[3]) > 1) -#define IN6_IS_ADDR_MC_NODELOCAL(a) \ +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x1) -#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x2) -#define IN6_IS_ADDR_MC_SITELOCAL(a) \ +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x5) -#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0x8) -#define IN6_IS_ADDR_MC_GLOBAL(a) \ +#define IN6_IS_ADDR_MC_GLOBAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && ((a)->s6_addr[1] & 0xf) == 0xe) #endif /* _NETINET_IN_H_ */ diff --git a/libc_extension/include/sys/ipc.h b/libc_extension/include/sys/ipc.h index 96e4e76..a73e06b 100644 --- a/libc_extension/include/sys/ipc.h +++ b/libc_extension/include/sys/ipc.h @@ -16,15 +16,15 @@ struct ipc_perm { }; /* https://git.musl-libc.org/cgit/musl/tree/include/sys/ipc.h */ -#define IPC_CREAT 01000 -#define IPC_EXCL 02000 -#define IPC_NOWAIT 04000 +#define IPC_CREAT 01000 +#define IPC_EXCL 02000 +#define IPC_NOWAIT 04000 #define IPC_PRIVATE ((key_t)0) /* https://github.com/torvalds/linux/blob/master/include/uapi/linux/ipc.h */ -#define IPC_RMID 0 -#define IPC_SET 1 -#define IPC_STAT 2 +#define IPC_RMID 0 +#define IPC_SET 1 +#define IPC_STAT 2 key_t ftok(const char *, int); diff --git a/libc_extension/include/sys/mman.h b/libc_extension/include/sys/mman.h index 1c1bc31..6ec37c6 100644 --- a/libc_extension/include/sys/mman.h +++ b/libc_extension/include/sys/mman.h @@ -8,36 +8,36 @@ extern "C" { #endif /* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ -#define PROT_NONE 0x0 -#define PROT_READ 0x1 -#define PROT_WRITE 0x2 -#define PROT_EXEC 0x4 +#define PROT_NONE 0x0 +#define PROT_READ 0x1 +#define PROT_WRITE 0x2 +#define PROT_EXEC 0x4 /* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ -#define MAP_SHARED 0x01 -#define MAP_PRIVATE 0x02 -#define MAP_FIXED 0x10 -#define MAP_ANON 0x20 +#define MAP_SHARED 0x01 +#define MAP_PRIVATE 0x02 +#define MAP_FIXED 0x10 +#define MAP_ANON 0x20 #define MAP_ANONYMOUS MAP_ANON /* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ #define MAP_FAILED ((void *)-1) /* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ -#define MS_ASYNC 1 -#define MS_INVALIDATE 2 -#define MS_SYNC 4 +#define MS_ASYNC 1 +#define MS_INVALIDATE 2 +#define MS_SYNC 4 /* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ -#define MCL_CURRENT 1 -#define MCL_FUTURE 2 +#define MCL_CURRENT 1 +#define MCL_FUTURE 2 /* https://git.musl-libc.org/cgit/musl/tree/include/sys/mman.h */ -#define POSIX_MADV_NORMAL 0 -#define POSIX_MADV_RANDOM 1 -#define POSIX_MADV_SEQUENTIAL 2 -#define POSIX_MADV_WILLNEED 3 -#define POSIX_MADV_DONTNEED 4 +#define POSIX_MADV_NORMAL 0 +#define POSIX_MADV_RANDOM 1 +#define POSIX_MADV_SEQUENTIAL 2 +#define POSIX_MADV_WILLNEED 3 +#define POSIX_MADV_DONTNEED 4 void *mmap(void *, size_t, int, int, int, off_t); int mprotect(void *, size_t, int); diff --git a/libc_extension/include/sys/poll.h b/libc_extension/include/sys/poll.h index 525a7b4..82fec0a 100644 --- a/libc_extension/include/sys/poll.h +++ b/libc_extension/include/sys/poll.h @@ -15,7 +15,8 @@ struct pollfd { short revents; }; -/* https://sources.debian.org/src/glibc/2.43-1/sysdeps/unix/sysv/linux/bits/poll.h */ +/* https://sources.debian.org/src/glibc/2.43-1/sysdeps/unix/sysv/linux/bits/poll.h + */ #define POLLIN 0x001 #define POLLPRI 0x002 #define POLLOUT 0x004 diff --git a/libc_extension/include/sys/sem.h b/libc_extension/include/sys/sem.h index 7805929..c64935b 100644 --- a/libc_extension/include/sys/sem.h +++ b/libc_extension/include/sys/sem.h @@ -9,14 +9,14 @@ extern "C" { #endif /* https://github.com/torvalds/linux/blob/master/include/uapi/linux/sem.h */ -#define SEM_UNDO 0x1000 -#define GETNCNT 14 -#define GETPID 11 -#define GETVAL 12 -#define GETALL 13 -#define GETZCNT 15 -#define SETVAL 16 -#define SETALL 17 +#define SEM_UNDO 0x1000 +#define GETNCNT 14 +#define GETPID 11 +#define GETVAL 12 +#define GETALL 13 +#define GETZCNT 15 +#define SETVAL 16 +#define SETALL 17 struct semid_ds { struct ipc_perm sem_perm; diff --git a/libc_extension/include/sys/shm_template.h b/libc_extension/include/sys/shm_template.h index 31a557a..1f76a07 100644 --- a/libc_extension/include/sys/shm_template.h +++ b/libc_extension/include/sys/shm_template.h @@ -11,11 +11,12 @@ extern "C" { typedef unsigned long shmatt_t; /* https://github.com/torvalds/linux/blob/master/include/uapi/linux/shm.h */ -#define SHM_RDONLY 010000 -#define SHM_RND 020000 +#define SHM_RDONLY 010000 +#define SHM_RND 020000 -/* https://refspecs.linuxfoundation.org/LSB_2.0.1/LSB-Core-AMD64/LSB-Core-AMD64.diff.pdf */ -#define SHMLBA @PAGE_SIZE@ +/* https://refspecs.linuxfoundation.org/LSB_2.0.1/LSB-Core-AMD64/LSB-Core-AMD64.diff.pdf + */ +#define SHMLBA @PAGE_SIZE @ struct shmid_ds { struct ipc_perm shm_perm; diff --git a/libc_extension/include/sys/socket.h b/libc_extension/include/sys/socket.h index da9463e..105e214 100644 --- a/libc_extension/include/sys/socket.h +++ b/libc_extension/include/sys/socket.h @@ -1,5 +1,5 @@ -#ifndef _SYS_SOCKET_H -#define _SYS_SOCKET_H 1 +#ifndef _SYS_SOCKET_H +#define _SYS_SOCKET_H 1 #ifdef __cplusplus extern "C" { @@ -15,308 +15,304 @@ typedef unsigned int socklen_t; typedef unsigned short int sa_family_t; /* Structure describing a generic socket address. */ -struct sockaddr -{ - sa_family_t sa_family; /* Common data: address family and length. */ - char sa_data[14]; /* Address data. */ +struct sockaddr { + sa_family_t sa_family; /* Common data: address family and length. */ + char sa_data[14]; /* Address data. */ }; /* Structure large enough to hold any socket address (with the historical exception of AF_UNIX). */ -struct sockaddr_storage -{ - sa_family_t ss_family; /* Address family, etc. */ - char __ss_padding[(128 - (sizeof (unsigned short int)) - sizeof (unsigned long int))]; - unsigned long int __ss_align; /* Force desired alignment. */ +struct sockaddr_storage { + sa_family_t ss_family; /* Address family, etc. */ + char __ss_padding[(128 - (sizeof(unsigned short int)) - + sizeof(unsigned long int))]; + unsigned long int __ss_align; /* Force desired alignment. */ }; /* Structure describing messages sent by `sendmsg' and received by `recvmsg'. */ -struct msghdr -{ - void *msg_name; /* Address to send to/receive from. */ - socklen_t msg_namelen; /* Length of address data. */ +struct msghdr { + void *msg_name; /* Address to send to/receive from. */ + socklen_t msg_namelen; /* Length of address data. */ - struct iovec *msg_iov; /* Vector of data to send/receive into. */ - int msg_iovlen; /* Number of elements in the vector. */ + struct iovec *msg_iov; /* Vector of data to send/receive into. */ + int msg_iovlen; /* Number of elements in the vector. */ - void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ - socklen_t msg_controllen; /* Ancillary data buffer length. */ + void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ + socklen_t msg_controllen; /* Ancillary data buffer length. */ - int msg_flags; /* Flags on received message. */ + int msg_flags; /* Flags on received message. */ }; /* Structure used for storage of ancillary data object information. */ -struct cmsghdr -{ - socklen_t cmsg_len; /* Length of data in cmsg_data plus header. */ - int cmsg_level; /* Originating protocol. */ - int cmsg_type; /* Protocol specific type. */ +struct cmsghdr { + socklen_t cmsg_len; /* Length of data in cmsg_data plus header. */ + int cmsg_level; /* Originating protocol. */ + int cmsg_type; /* Protocol specific type. */ }; -struct linger -{ - int l_onoff; - int l_linger; +struct linger { + int l_onoff; + int l_linger; }; /* Types of sockets. */ -enum __socket_type -{ - SOCK_STREAM = 1, /* Sequenced, reliable, connection-based - byte streams. */ +enum __socket_type { + SOCK_STREAM = 1, /* Sequenced, reliable, connection-based + byte streams. */ #define SOCK_STREAM SOCK_STREAM - SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams - of fixed maximum length. */ + SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams + of fixed maximum length. */ #define SOCK_DGRAM SOCK_DGRAM - SOCK_RAW = 3, /* Raw protocol interface. */ + SOCK_RAW = 3, /* Raw protocol interface. */ #define SOCK_RAW SOCK_RAW - SOCK_RDM = 4, /* Reliably-delivered messages. */ + SOCK_RDM = 4, /* Reliably-delivered messages. */ #define SOCK_RDM SOCK_RDM - SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based, - datagrams of fixed maximum length. */ + SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based, + datagrams of fixed maximum length. */ #define SOCK_SEQPACKET SOCK_SEQPACKET - SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */ + SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */ #define SOCK_DCCP SOCK_DCCP - SOCK_PACKET = 10, /* Linux specific way of getting packets - at the dev level. For writing rarp and - other similar things on the user level. */ + SOCK_PACKET = 10, /* Linux specific way of getting packets + at the dev level. For writing rarp and + other similar things on the user level. */ #define SOCK_PACKET SOCK_PACKET /* Flags to be ORed into the type parameter of socket and socketpair and used for the flags parameter of paccept. */ - SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the - new descriptor(s). */ + SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the + new descriptor(s). */ #define SOCK_CLOEXEC SOCK_CLOEXEC - SOCK_NONBLOCK = 00004000 /* Atomically mark descriptor(s) as - non-blocking. */ + SOCK_NONBLOCK = 00004000 /* Atomically mark descriptor(s) as + non-blocking. */ #define SOCK_NONBLOCK SOCK_NONBLOCK }; /* Protocol families. */ -#define PF_UNSPEC 0 /* Unspecified. */ -#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ -#define PF_UNIX PF_LOCAL /* POSIX name for PF_LOCAL. */ -#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ -#define PF_INET 2 /* IP protocol family. */ -#define PF_AX25 3 /* Amateur Radio AX.25. */ -#define PF_IPX 4 /* Novell Internet Protocol. */ -#define PF_APPLETALK 5 /* Appletalk DDP. */ -#define PF_NETROM 6 /* Amateur radio NetROM. */ -#define PF_BRIDGE 7 /* Multiprotocol bridge. */ -#define PF_ATMPVC 8 /* ATM PVCs. */ -#define PF_X25 9 /* Reserved for X.25 project. */ -#define PF_INET6 10 /* IP version 6. */ -#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */ -#define PF_DECnet 12 /* Reserved for DECnet project. */ -#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */ -#define PF_SECURITY 14 /* Security callback pseudo AF. */ -#define PF_KEY 15 /* PF_KEY key management API. */ -#define PF_NETLINK 16 -#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */ -#define PF_PACKET 17 /* Packet family. */ -#define PF_ASH 18 /* Ash. */ -#define PF_ECONET 19 /* Acorn Econet. */ -#define PF_ATMSVC 20 /* ATM SVCs. */ -#define PF_RDS 21 /* RDS sockets. */ -#define PF_SNA 22 /* Linux SNA Project */ -#define PF_IRDA 23 /* IRDA sockets. */ -#define PF_PPPOX 24 /* PPPoX sockets. */ -#define PF_WANPIPE 25 /* Wanpipe API sockets. */ -#define PF_LLC 26 /* Linux LLC. */ -#define PF_IB 27 /* Native InfiniBand address. */ -#define PF_MPLS 28 /* MPLS. */ -#define PF_CAN 29 /* Controller Area Network. */ -#define PF_TIPC 30 /* TIPC sockets. */ -#define PF_BLUETOOTH 31 /* Bluetooth sockets. */ -#define PF_IUCV 32 /* IUCV sockets. */ -#define PF_RXRPC 33 /* RxRPC sockets. */ -#define PF_ISDN 34 /* mISDN sockets. */ -#define PF_PHONET 35 /* Phonet sockets. */ -#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */ -#define PF_CAIF 37 /* CAIF sockets. */ -#define PF_ALG 38 /* Algorithm sockets. */ -#define PF_NFC 39 /* NFC sockets. */ -#define PF_VSOCK 40 /* vSockets. */ -#define PF_KCM 41 /* Kernel Connection Multiplexor. */ -#define PF_QIPCRTR 42 /* Qualcomm IPC Router. */ -#define PF_SMC 43 /* SMC sockets. */ -#define PF_XDP 44 /* XDP sockets. */ -#define PF_MCTP 45 /* Management component transport protocol. */ -#define PF_MAX 46 /* For now.. */ +#define PF_UNSPEC 0 /* Unspecified. */ +#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ +#define PF_UNIX PF_LOCAL /* POSIX name for PF_LOCAL. */ +#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ +#define PF_INET 2 /* IP protocol family. */ +#define PF_AX25 3 /* Amateur Radio AX.25. */ +#define PF_IPX 4 /* Novell Internet Protocol. */ +#define PF_APPLETALK 5 /* Appletalk DDP. */ +#define PF_NETROM 6 /* Amateur radio NetROM. */ +#define PF_BRIDGE 7 /* Multiprotocol bridge. */ +#define PF_ATMPVC 8 /* ATM PVCs. */ +#define PF_X25 9 /* Reserved for X.25 project. */ +#define PF_INET6 10 /* IP version 6. */ +#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */ +#define PF_DECnet 12 /* Reserved for DECnet project. */ +#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */ +#define PF_SECURITY 14 /* Security callback pseudo AF. */ +#define PF_KEY 15 /* PF_KEY key management API. */ +#define PF_NETLINK 16 +#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */ +#define PF_PACKET 17 /* Packet family. */ +#define PF_ASH 18 /* Ash. */ +#define PF_ECONET 19 /* Acorn Econet. */ +#define PF_ATMSVC 20 /* ATM SVCs. */ +#define PF_RDS 21 /* RDS sockets. */ +#define PF_SNA 22 /* Linux SNA Project */ +#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_PPPOX 24 /* PPPoX sockets. */ +#define PF_WANPIPE 25 /* Wanpipe API sockets. */ +#define PF_LLC 26 /* Linux LLC. */ +#define PF_IB 27 /* Native InfiniBand address. */ +#define PF_MPLS 28 /* MPLS. */ +#define PF_CAN 29 /* Controller Area Network. */ +#define PF_TIPC 30 /* TIPC sockets. */ +#define PF_BLUETOOTH 31 /* Bluetooth sockets. */ +#define PF_IUCV 32 /* IUCV sockets. */ +#define PF_RXRPC 33 /* RxRPC sockets. */ +#define PF_ISDN 34 /* mISDN sockets. */ +#define PF_PHONET 35 /* Phonet sockets. */ +#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */ +#define PF_CAIF 37 /* CAIF sockets. */ +#define PF_ALG 38 /* Algorithm sockets. */ +#define PF_NFC 39 /* NFC sockets. */ +#define PF_VSOCK 40 /* vSockets. */ +#define PF_KCM 41 /* Kernel Connection Multiplexor. */ +#define PF_QIPCRTR 42 /* Qualcomm IPC Router. */ +#define PF_SMC 43 /* SMC sockets. */ +#define PF_XDP 44 /* XDP sockets. */ +#define PF_MCTP 45 /* Management component transport protocol. */ +#define PF_MAX 46 /* For now.. */ /* Address families. */ -#define AF_UNSPEC PF_UNSPEC -#define AF_LOCAL PF_LOCAL -#define AF_UNIX PF_UNIX -#define AF_FILE PF_FILE -#define AF_INET PF_INET -#define AF_AX25 PF_AX25 -#define AF_IPX PF_IPX -#define AF_APPLETALK PF_APPLETALK -#define AF_NETROM PF_NETROM -#define AF_BRIDGE PF_BRIDGE -#define AF_ATMPVC PF_ATMPVC -#define AF_X25 PF_X25 -#define AF_INET6 PF_INET6 -#define AF_ROSE PF_ROSE -#define AF_DECnet PF_DECnet -#define AF_NETBEUI PF_NETBEUI -#define AF_SECURITY PF_SECURITY -#define AF_KEY PF_KEY -#define AF_NETLINK PF_NETLINK -#define AF_ROUTE PF_ROUTE -#define AF_PACKET PF_PACKET -#define AF_ASH PF_ASH -#define AF_ECONET PF_ECONET -#define AF_ATMSVC PF_ATMSVC -#define AF_RDS PF_RDS -#define AF_SNA PF_SNA -#define AF_IRDA PF_IRDA -#define AF_PPPOX PF_PPPOX -#define AF_WANPIPE PF_WANPIPE -#define AF_LLC PF_LLC -#define AF_IB PF_IB -#define AF_MPLS PF_MPLS -#define AF_CAN PF_CAN -#define AF_TIPC PF_TIPC -#define AF_BLUETOOTH PF_BLUETOOTH -#define AF_IUCV PF_IUCV -#define AF_RXRPC PF_RXRPC -#define AF_ISDN PF_ISDN -#define AF_PHONET PF_PHONET -#define AF_IEEE802154 PF_IEEE802154 -#define AF_CAIF PF_CAIF -#define AF_ALG PF_ALG -#define AF_NFC PF_NFC -#define AF_VSOCK PF_VSOCK -#define AF_KCM PF_KCM -#define AF_QIPCRTR PF_QIPCRTR -#define AF_SMC PF_SMC -#define AF_XDP PF_XDP -#define AF_MCTP PF_MCTP -#define AF_MAX PF_MAX +#define AF_UNSPEC PF_UNSPEC +#define AF_LOCAL PF_LOCAL +#define AF_UNIX PF_UNIX +#define AF_FILE PF_FILE +#define AF_INET PF_INET +#define AF_AX25 PF_AX25 +#define AF_IPX PF_IPX +#define AF_APPLETALK PF_APPLETALK +#define AF_NETROM PF_NETROM +#define AF_BRIDGE PF_BRIDGE +#define AF_ATMPVC PF_ATMPVC +#define AF_X25 PF_X25 +#define AF_INET6 PF_INET6 +#define AF_ROSE PF_ROSE +#define AF_DECnet PF_DECnet +#define AF_NETBEUI PF_NETBEUI +#define AF_SECURITY PF_SECURITY +#define AF_KEY PF_KEY +#define AF_NETLINK PF_NETLINK +#define AF_ROUTE PF_ROUTE +#define AF_PACKET PF_PACKET +#define AF_ASH PF_ASH +#define AF_ECONET PF_ECONET +#define AF_ATMSVC PF_ATMSVC +#define AF_RDS PF_RDS +#define AF_SNA PF_SNA +#define AF_IRDA PF_IRDA +#define AF_PPPOX PF_PPPOX +#define AF_WANPIPE PF_WANPIPE +#define AF_LLC PF_LLC +#define AF_IB PF_IB +#define AF_MPLS PF_MPLS +#define AF_CAN PF_CAN +#define AF_TIPC PF_TIPC +#define AF_BLUETOOTH PF_BLUETOOTH +#define AF_IUCV PF_IUCV +#define AF_RXRPC PF_RXRPC +#define AF_ISDN PF_ISDN +#define AF_PHONET PF_PHONET +#define AF_IEEE802154 PF_IEEE802154 +#define AF_CAIF PF_CAIF +#define AF_ALG PF_ALG +#define AF_NFC PF_NFC +#define AF_VSOCK PF_VSOCK +#define AF_KCM PF_KCM +#define AF_QIPCRTR PF_QIPCRTR +#define AF_SMC PF_SMC +#define AF_XDP PF_XDP +#define AF_MCTP PF_MCTP +#define AF_MAX PF_MAX /* https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h */ -#define SO_DEBUG 1 -#define SO_REUSEADDR 2 -#define SO_TYPE 3 -#define SO_ERROR 4 -#define SO_DONTROUTE 5 -#define SO_BROADCAST 6 -#define SO_SNDBUF 7 -#define SO_RCVBUF 8 -#define SO_KEEPALIVE 9 -#define SO_OOBINLINE 10 -#define SO_LINGER 13 -#define SO_RCVLOWAT 18 -#define SO_SNDLOWAT 19 -#define SO_RCVTIMEO 20 -#define SO_SNDTIMEO 21 -#define SO_ACCEPTCONN 30 -#define SOL_SOCKET 1 -#define SOMAXCONN 128 +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_LINGER 13 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#define SO_ACCEPTCONN 30 +#define SOL_SOCKET 1 +#define SOMAXCONN 128 -#define SHUT_RD 0 -#define SHUT_WR 1 -#define SHUT_RDWR 2 +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 /* Bits in the FLAGS argument to `send', `recv', et al. */ -enum - { - MSG_OOB = 0x01, /* Process out-of-band data. */ -#define MSG_OOB MSG_OOB - MSG_PEEK = 0x02, /* Peek at incoming messages. */ -#define MSG_PEEK MSG_PEEK - MSG_DONTROUTE = 0x04, /* Don't use local routing. */ -#define MSG_DONTROUTE MSG_DONTROUTE - MSG_CTRUNC = 0x08, /* Control data lost before delivery. */ -#define MSG_CTRUNC MSG_CTRUNC - MSG_PROXY = 0x10, /* Supply or ask second address. */ -#define MSG_PROXY MSG_PROXY - MSG_TRUNC = 0x20, -#define MSG_TRUNC MSG_TRUNC - MSG_DONTWAIT = 0x40, /* Nonblocking IO. */ -#define MSG_DONTWAIT MSG_DONTWAIT - MSG_EOR = 0x80, /* End of record. */ -#define MSG_EOR MSG_EOR - MSG_WAITALL = 0x100, /* Wait for a full request. */ -#define MSG_WAITALL MSG_WAITALL - MSG_FIN = 0x200, -#define MSG_FIN MSG_FIN - MSG_SYN = 0x400, -#define MSG_SYN MSG_SYN - MSG_CONFIRM = 0x800, /* Confirm path validity. */ -#define MSG_CONFIRM MSG_CONFIRM - MSG_RST = 0x1000, -#define MSG_RST MSG_RST - MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */ -#define MSG_ERRQUEUE MSG_ERRQUEUE - MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */ -#define MSG_NOSIGNAL MSG_NOSIGNAL - MSG_MORE = 0x8000, /* Sender will send more. */ -#define MSG_MORE MSG_MORE - MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/ -#define MSG_WAITFORONE MSG_WAITFORONE - MSG_BATCH = 0x40000, /* sendmmsg: more messages coming. */ -#define MSG_BATCH MSG_BATCH - MSG_ZEROCOPY = 0x4000000, /* Use user data in kernel path. */ -#define MSG_ZEROCOPY MSG_ZEROCOPY - MSG_FASTOPEN = 0x20000000, /* Send data in TCP SYN. */ -#define MSG_FASTOPEN MSG_FASTOPEN +enum { + MSG_OOB = 0x01, /* Process out-of-band data. */ +#define MSG_OOB MSG_OOB + MSG_PEEK = 0x02, /* Peek at incoming messages. */ +#define MSG_PEEK MSG_PEEK + MSG_DONTROUTE = 0x04, /* Don't use local routing. */ +#define MSG_DONTROUTE MSG_DONTROUTE + MSG_CTRUNC = 0x08, /* Control data lost before delivery. */ +#define MSG_CTRUNC MSG_CTRUNC + MSG_PROXY = 0x10, /* Supply or ask second address. */ +#define MSG_PROXY MSG_PROXY + MSG_TRUNC = 0x20, +#define MSG_TRUNC MSG_TRUNC + MSG_DONTWAIT = 0x40, /* Nonblocking IO. */ +#define MSG_DONTWAIT MSG_DONTWAIT + MSG_EOR = 0x80, /* End of record. */ +#define MSG_EOR MSG_EOR + MSG_WAITALL = 0x100, /* Wait for a full request. */ +#define MSG_WAITALL MSG_WAITALL + MSG_FIN = 0x200, +#define MSG_FIN MSG_FIN + MSG_SYN = 0x400, +#define MSG_SYN MSG_SYN + MSG_CONFIRM = 0x800, /* Confirm path validity. */ +#define MSG_CONFIRM MSG_CONFIRM + MSG_RST = 0x1000, +#define MSG_RST MSG_RST + MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */ +#define MSG_ERRQUEUE MSG_ERRQUEUE + MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */ +#define MSG_NOSIGNAL MSG_NOSIGNAL + MSG_MORE = 0x8000, /* Sender will send more. */ +#define MSG_MORE MSG_MORE + MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/ +#define MSG_WAITFORONE MSG_WAITFORONE + MSG_BATCH = 0x40000, /* sendmmsg: more messages coming. */ +#define MSG_BATCH MSG_BATCH + MSG_ZEROCOPY = 0x4000000, /* Use user data in kernel path. */ +#define MSG_ZEROCOPY MSG_ZEROCOPY + MSG_FASTOPEN = 0x20000000, /* Send data in TCP SYN. */ +#define MSG_FASTOPEN MSG_FASTOPEN - MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file - descriptor received through - SCM_RIGHTS. */ + MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file + descriptor received through + SCM_RIGHTS. */ #define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC - }; +}; /* https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h */ -#define CMSG_DATA(cmsg) \ - ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1)) -#define CMSG_NXTHDR(mhdr, cmsg) \ - ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \ - (((((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)) + \ - sizeof(struct cmsghdr)) >= \ - ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen) - \ - (unsigned char *)(cmsg)) \ - ? 0 : (struct cmsghdr *)((unsigned char *)(cmsg) + \ - (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)))) -#define CMSG_FIRSTHDR(mhdr) \ - ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? \ - (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0) -#define CMSG_ALIGN(len) \ - (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) -#define CMSG_SPACE(len) \ - (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr))) -#define CMSG_LEN(len) \ - (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) +#define CMSG_DATA(cmsg) ((unsigned char *)(((struct cmsghdr *)(cmsg)) + 1)) +#define CMSG_NXTHDR(mhdr, cmsg) \ + ((cmsg)->cmsg_len < sizeof(struct cmsghdr) || \ + (((((cmsg)->cmsg_len + sizeof(long) - 1) & \ + ~(long)(sizeof(long) - 1)) + \ + sizeof(struct cmsghdr)) >= \ + ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen) - \ + (unsigned char *)(cmsg)) \ + ? 0 \ + : (struct cmsghdr *)((unsigned char *)(cmsg) + \ + (((cmsg)->cmsg_len + sizeof(long) - 1) & \ + ~(long)(sizeof(long) - 1)))) +#define CMSG_FIRSTHDR(mhdr) \ + ((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) \ + ? (struct cmsghdr *)(mhdr)->msg_control \ + : (struct cmsghdr *)0) +#define CMSG_ALIGN(len) \ + (((len) + sizeof(size_t) - 1) & (size_t) ~(sizeof(size_t) - 1)) +#define CMSG_SPACE(len) (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr))) +#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) /* https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h */ -#define SCM_RIGHTS 0x01 +#define SCM_RIGHTS 0x01 -extern int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len); -extern int bind (int __fd, const struct sockaddr *__addr, socklen_t __len); -extern int connect (int __fd, const struct sockaddr *__addr, socklen_t __len); -extern int getpeername (int __fd, struct sockaddr *__addr, socklen_t *__len); -extern int getsockname (int __fd, struct sockaddr *__addr, socklen_t *__len); -extern int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen); -extern int listen (int __fd, int __n); -extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags); -extern ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr *__addr, - socklen_t *__addr_len); -extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags); -extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags); -extern ssize_t sendmsg (int __fd, const struct msghdr *__message, int __flags); -extern ssize_t sendto (int __fd, const void *__buf, size_t __n, int __flags, - const struct sockaddr *__addr, socklen_t __addr_len); -extern int setsockopt (int __fd, int __level, int __optname, const void *__optval, - socklen_t __optlen); -extern int shutdown (int __fd, int __how); -extern int socket (int __domain, int __type, int __protocol); -extern int sockatmark (int __fd); -extern int socketpair (int __domain, int __type, int __protocol, int __fds[2]); +extern int accept(int __fd, struct sockaddr *__addr, socklen_t *__addr_len); +extern int bind(int __fd, const struct sockaddr *__addr, socklen_t __len); +extern int connect(int __fd, const struct sockaddr *__addr, socklen_t __len); +extern int getpeername(int __fd, struct sockaddr *__addr, socklen_t *__len); +extern int getsockname(int __fd, struct sockaddr *__addr, socklen_t *__len); +extern int getsockopt(int __fd, int __level, int __optname, void *__optval, + socklen_t *__optlen); +extern int listen(int __fd, int __n); +extern ssize_t recv(int __fd, void *__buf, size_t __n, int __flags); +extern ssize_t recvfrom(int __fd, void *__buf, size_t __n, int __flags, + struct sockaddr *__addr, socklen_t *__addr_len); +extern ssize_t recvmsg(int __fd, struct msghdr *__message, int __flags); +extern ssize_t send(int __fd, const void *__buf, size_t __n, int __flags); +extern ssize_t sendmsg(int __fd, const struct msghdr *__message, int __flags); +extern ssize_t sendto(int __fd, const void *__buf, size_t __n, int __flags, + const struct sockaddr *__addr, socklen_t __addr_len); +extern int setsockopt(int __fd, int __level, int __optname, + const void *__optval, socklen_t __optlen); +extern int shutdown(int __fd, int __how); +extern int socket(int __domain, int __type, int __protocol); +extern int sockatmark(int __fd); +extern int socketpair(int __domain, int __type, int __protocol, int __fds[2]); #ifdef __cplusplus } diff --git a/libc_extension/include/sys/statvfs.h b/libc_extension/include/sys/statvfs.h index 9677900..7bb592d 100644 --- a/libc_extension/include/sys/statvfs.h +++ b/libc_extension/include/sys/statvfs.h @@ -5,8 +5,8 @@ extern "C" { #endif -#include #include +#include #define ST_RDONLY 1 #define ST_NOSUID 2 diff --git a/libc_extension/include/sys/termios.h b/libc_extension/include/sys/termios.h index fd3371c..3a93f18 100644 --- a/libc_extension/include/sys/termios.h +++ b/libc_extension/include/sys/termios.h @@ -11,7 +11,8 @@ typedef unsigned char cc_t; typedef unsigned int speed_t; typedef unsigned int tcflag_t; -/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-struct.h.html */ +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-struct.h.html + */ #define NCCS 32 struct termios { @@ -25,109 +26,114 @@ struct termios { speed_t c_ospeed; }; -/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_cc.h.html */ -#define VINTR 0 -#define VQUIT 1 -#define VERASE 2 -#define VKILL 3 -#define VEOF 4 -#define VTIME 5 -#define VMIN 6 -#define VSTART 8 -#define VSTOP 9 -#define VSUSP 10 -#define VEOL 11 +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_cc.h.html + */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 -/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_iflag.h.html */ -#define IGNBRK 0000001 -#define BRKINT 0000002 -#define IGNPAR 0000004 -#define PARMRK 0000010 -#define INPCK 0000020 -#define ISTRIP 0000040 -#define INLCR 0000100 -#define IGNCR 0000200 -#define ICRNL 0000400 -#define IXON 0002000 -#define IXANY 0004000 -#define IXOFF 0010000 +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_iflag.h.html + */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 -/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_oflag.h.html */ -#define OPOST 0000001 -#define ONLCR 0000004 -#define OCRNL 0000010 -#define ONOCR 0000020 -#define ONLRET 0000040 -#define OFILL 0000100 -#define OFDEL 0000200 -#define NLDLY 0000400 -#define NL0 0000000 -#define NL1 0000400 -#define CRDLY 0003000 -#define CR0 0000000 -#define CR1 0001000 -#define CR2 0002000 -#define CR3 0003000 -#define TABDLY 0014000 -#define TAB0 0000000 -#define TAB1 0004000 -#define TAB2 0010000 -#define TAB3 0014000 -#define BSDLY 0020000 -#define BS0 0000000 -#define BS1 0020000 -#define FFDLY 0100000 -#define FF0 0000000 -#define FF1 0100000 -#define VTDLY 0040000 -#define VT0 0000000 -#define VT1 0040000 +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_oflag.h.html + */ +#define OPOST 0000001 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 /* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios.h.html * https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_cflag.h.html */ -#define B0 0000000 -#define B50 0000001 -#define B75 0000002 -#define B110 0000003 -#define B134 0000004 -#define B150 0000005 -#define B200 0000006 -#define B300 0000007 -#define B600 0000010 -#define B1200 0000011 -#define B1800 0000012 -#define B2400 0000013 -#define B4800 0000014 -#define B9600 0000015 -#define B19200 0000016 -#define B38400 0000017 -#define CSIZE 0000060 -#define CS5 0000000 -#define CS6 0000020 -#define CS7 0000040 -#define CS8 0000060 -#define CSTOPB 0000100 -#define CREAD 0000200 -#define PARENB 0000400 -#define PARODD 0001000 -#define HUPCL 0002000 -#define CLOCAL 0004000 +#define B0 0000000 +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 -/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_lflag.h.html */ -#define ISIG 0000001 -#define ICANON 0000002 -#define ECHO 0000010 -#define ECHOE 0000020 -#define ECHOK 0000040 -#define ECHONL 0000100 -#define NOFLSH 0000200 -#define TOSTOP 0000400 -#define IEXTEN 0100000 +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-c_lflag.h.html + */ +#define ISIG 0000001 +#define ICANON 0000002 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define IEXTEN 0100000 -/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-tcflow.h.html */ +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios-tcflow.h.html + */ #ifndef TCSANOW -#define TCSANOW 0 +#define TCSANOW 0 #endif #ifndef TCSADRAIN #define TCSADRAIN 1 @@ -135,13 +141,14 @@ struct termios { #ifndef TCSAFLUSH #define TCSAFLUSH 2 #endif -/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios.h.html */ -#define TCOOFF 0 -#define TCOON 1 -#define TCIOFF 2 -#define TCION 3 -#define TCIFLUSH 0 -#define TCOFLUSH 1 +/* https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/bits/termios.h.html + */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 +#define TCIFLUSH 0 +#define TCOFLUSH 1 #define TCIOFLUSH 2 speed_t cfgetispeed(const struct termios *); diff --git a/libc_extension/include/sys/uio.h b/libc_extension/include/sys/uio.h index 4ddeced..1cc9107 100644 --- a/libc_extension/include/sys/uio.h +++ b/libc_extension/include/sys/uio.h @@ -1,13 +1,12 @@ #ifndef _SYS_UIO_H -#define _SYS_UIO_H 1 +#define _SYS_UIO_H 1 #include /* Structure for scatter/gather I/O. */ -struct iovec -{ - void *iov_base; /* Pointer to data. */ - size_t iov_len; /* Length of data. */ +struct iovec { + void *iov_base; /* Pointer to data. */ + size_t iov_len; /* Length of data. */ }; /* Read data from file descriptor FD, and put the result in the @@ -18,7 +17,7 @@ struct iovec This function is a cancellation point and therefore not marked with __THROW. */ -extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count); +extern ssize_t readv(int __fd, const struct iovec *__iovec, int __count); /* Write data pointed by the buffers described by IOVEC, which is a vector of COUNT 'struct iovec's, to file descriptor FD. @@ -28,6 +27,6 @@ extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count); This function is a cancellation point and therefore not marked with __THROW. */ -extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count); +extern ssize_t writev(int __fd, const struct iovec *__iovec, int __count); #endif // _SYS_UIO_H diff --git a/libc_extension/include/sys/utsname_template.h b/libc_extension/include/sys/utsname_template.h index 802039a..092b2b8 100644 --- a/libc_extension/include/sys/utsname_template.h +++ b/libc_extension/include/sys/utsname_template.h @@ -9,11 +9,11 @@ extern "C" { * https://sources.debian.org/src/glibc/2.41-12/sysdeps/unix/sysv/linux/bits/utsname.h/ */ struct utsname { - char sysname[@UTSNAME_FIELD_SIZE@]; - char nodename[@UTSNAME_FIELD_SIZE@]; - char release[@UTSNAME_FIELD_SIZE@]; - char version[@UTSNAME_FIELD_SIZE@]; - char machine[@UTSNAME_FIELD_SIZE@]; + char sysname[@UTSNAME_FIELD_SIZE @]; + char nodename[@UTSNAME_FIELD_SIZE @]; + char release[@UTSNAME_FIELD_SIZE @]; + char version[@UTSNAME_FIELD_SIZE @]; + char machine[@UTSNAME_FIELD_SIZE @]; }; int uname(struct utsname *); diff --git a/libc_extension/include/syslog.h b/libc_extension/include/syslog.h index ddfe49e..b618f19 100644 --- a/libc_extension/include/syslog.h +++ b/libc_extension/include/syslog.h @@ -6,43 +6,43 @@ extern "C" { #endif /* https://codebrowser.dev/glibc/glibc/misc/sys/syslog.h.html */ -#define LOG_PID 0x01 -#define LOG_CONS 0x02 -#define LOG_ODELAY 0x04 -#define LOG_NDELAY 0x08 -#define LOG_NOWAIT 0x10 +#define LOG_PID 0x01 +#define LOG_CONS 0x02 +#define LOG_ODELAY 0x04 +#define LOG_NDELAY 0x08 +#define LOG_NOWAIT 0x10 /* https://codebrowser.dev/glibc/glibc/misc/sys/syslog.h.html */ -#define LOG_KERN (0 << 3) -#define LOG_USER (1 << 3) -#define LOG_MAIL (2 << 3) -#define LOG_DAEMON (3 << 3) -#define LOG_AUTH (4 << 3) -#define LOG_SYSLOG (5 << 3) -#define LOG_LPR (6 << 3) -#define LOG_NEWS (7 << 3) -#define LOG_UUCP (8 << 3) -#define LOG_CRON (9 << 3) +#define LOG_KERN (0 << 3) +#define LOG_USER (1 << 3) +#define LOG_MAIL (2 << 3) +#define LOG_DAEMON (3 << 3) +#define LOG_AUTH (4 << 3) +#define LOG_SYSLOG (5 << 3) +#define LOG_LPR (6 << 3) +#define LOG_NEWS (7 << 3) +#define LOG_UUCP (8 << 3) +#define LOG_CRON (9 << 3) #define LOG_AUTHPRIV (10 << 3) -#define LOG_FTP (11 << 3) -#define LOG_LOCAL0 (16 << 3) -#define LOG_LOCAL1 (17 << 3) -#define LOG_LOCAL2 (18 << 3) -#define LOG_LOCAL3 (19 << 3) -#define LOG_LOCAL4 (20 << 3) -#define LOG_LOCAL5 (21 << 3) -#define LOG_LOCAL6 (22 << 3) -#define LOG_LOCAL7 (23 << 3) +#define LOG_FTP (11 << 3) +#define LOG_LOCAL0 (16 << 3) +#define LOG_LOCAL1 (17 << 3) +#define LOG_LOCAL2 (18 << 3) +#define LOG_LOCAL3 (19 << 3) +#define LOG_LOCAL4 (20 << 3) +#define LOG_LOCAL5 (21 << 3) +#define LOG_LOCAL6 (22 << 3) +#define LOG_LOCAL7 (23 << 3) /* https://codebrowser.dev/glibc/glibc/misc/sys/syslog.h.html */ -#define LOG_EMERG 0 -#define LOG_ALERT 1 -#define LOG_CRIT 2 -#define LOG_ERR 3 -#define LOG_WARNING 4 -#define LOG_NOTICE 5 -#define LOG_INFO 6 -#define LOG_DEBUG 7 +#define LOG_EMERG 0 +#define LOG_ALERT 1 +#define LOG_CRIT 2 +#define LOG_ERR 3 +#define LOG_WARNING 4 +#define LOG_NOTICE 5 +#define LOG_INFO 6 +#define LOG_DEBUG 7 #define LOG_MASK(pri) (1 << (pri)) diff --git a/libc_extension/include/utmpx.h b/libc_extension/include/utmpx.h index 7138e56..2cf1940 100644 --- a/libc_extension/include/utmpx.h +++ b/libc_extension/include/utmpx.h @@ -22,14 +22,14 @@ struct utmpx { }; /* https://codebrowser.dev/glibc/glibc/sysdeps/gnu/bits/utmpx.h.html */ -#define EMPTY 0 -#define BOOT_TIME 2 -#define NEW_TIME 3 -#define OLD_TIME 4 -#define INIT_PROCESS 5 +#define EMPTY 0 +#define BOOT_TIME 2 +#define NEW_TIME 3 +#define OLD_TIME 4 +#define INIT_PROCESS 5 #define LOGIN_PROCESS 6 -#define USER_PROCESS 7 -#define DEAD_PROCESS 8 +#define USER_PROCESS 7 +#define DEAD_PROCESS 8 void endutxent(void); struct utmpx *getutxent(void); diff --git a/libc_extension/monetary.c b/libc_extension/monetary.c index c49828d..08100c3 100644 --- a/libc_extension/monetary.c +++ b/libc_extension/monetary.c @@ -1,7 +1,8 @@ -#include #include +#include // https://man7.org/linux/man-pages/man0/monetary.h.0p.html -ssize_t strfmon(char *restrict s, size_t max, const char *restrict format, ...) { +ssize_t strfmon(char *restrict s, size_t max, const char *restrict format, + ...) { (void)s; (void)max; (void)format; diff --git a/libc_extension/net_if.c b/libc_extension/net_if.c index b05dc5e..e8dc84d 100644 --- a/libc_extension/net_if.c +++ b/libc_extension/net_if.c @@ -1,5 +1,5 @@ -#include #include +#include void if_freenameindex(struct if_nameindex *ptr) { (void)ptr; diff --git a/libc_extension/netdb.c b/libc_extension/netdb.c index a86c1de..48311fe 100644 --- a/libc_extension/netdb.c +++ b/libc_extension/netdb.c @@ -1,130 +1,126 @@ -#include #include +#include int h_errno; -void endhostent (void) {} +void endhostent(void) {} -void endnetent (void) {} +void endnetent(void) {} -void endprotoent (void) {} +void endprotoent(void) {} -void endservent (void) {} +void endservent(void) {} -struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len, int __type) { - (void)__addr; - (void)__len; - (void)__type; - errno = ENOSYS; - return 0; +struct hostent *gethostbyaddr(const void *__addr, __socklen_t __len, + int __type) { + (void)__addr; + (void)__len; + (void)__type; + errno = ENOSYS; + return 0; } -struct hostent *gethostbyname (const char *__name) { - (void)__name; - errno = ENOSYS; - return 0; +struct hostent *gethostbyname(const char *__name) { + (void)__name; + errno = ENOSYS; + return 0; } -struct hostent *gethostent (void) { - errno = ENOSYS; - return 0; +struct hostent *gethostent(void) { + errno = ENOSYS; + return 0; } -struct netent *getnetbyaddr (uint32_t __net, int __type) { - (void)__net; - (void)__type; - errno = ENOSYS; - return 0; +struct netent *getnetbyaddr(uint32_t __net, int __type) { + (void)__net; + (void)__type; + errno = ENOSYS; + return 0; } -struct netent *getnetbyname (const char *__name) { - (void)__name; - errno = ENOSYS; - return 0; +struct netent *getnetbyname(const char *__name) { + (void)__name; + errno = ENOSYS; + return 0; } -struct netent *getnetent (void) { - errno = ENOSYS; - return 0; +struct netent *getnetent(void) { + errno = ENOSYS; + return 0; } -struct protoent *getprotobyname (const char *__name) { - (void)__name; - errno = ENOSYS; - return 0; +struct protoent *getprotobyname(const char *__name) { + (void)__name; + errno = ENOSYS; + return 0; } -struct protoent *getprotobynumber (int __proto) { - (void)__proto; - errno = ENOSYS; - return 0; +struct protoent *getprotobynumber(int __proto) { + (void)__proto; + errno = ENOSYS; + return 0; } -struct protoent *getprotoent (void) { - errno = ENOSYS; - return 0; +struct protoent *getprotoent(void) { + errno = ENOSYS; + return 0; } -struct servent *getservbyname (const char *__name, const char *__proto) { - (void)__name; - (void)__proto; - errno = ENOSYS; - return 0; +struct servent *getservbyname(const char *__name, const char *__proto) { + (void)__name; + (void)__proto; + errno = ENOSYS; + return 0; } -struct servent *getservbyport (int __port, const char *__proto) { - (void)__port; - (void)__proto; - errno = ENOSYS; - return 0; +struct servent *getservbyport(int __port, const char *__proto) { + (void)__port; + (void)__proto; + errno = ENOSYS; + return 0; } -struct servent *getservent (void) { - errno = ENOSYS; - return 0; +struct servent *getservent(void) { + errno = ENOSYS; + return 0; } -void sethostent (int __stay_open) {} +void sethostent(int __stay_open) {} -void setnetent (int __stay_open) {} +void setnetent(int __stay_open) {} -void setprotoent (int __stay_open) {} +void setprotoent(int __stay_open) {} -void setservent (int __stay_open) {} +void setservent(int __stay_open) {} -void freeaddrinfo(struct addrinfo *__ai) { - (void)__ai; -} +void freeaddrinfo(struct addrinfo *__ai) { (void)__ai; } -int getaddrinfo(const char *__restrict __name, - const char *__restrict __service, +int getaddrinfo(const char *__restrict __name, const char *__restrict __service, const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai) { - (void)__name; - (void)__service; - (void)__req; - (void)__pai; - errno = ENOSYS; - return EAI_SYSTEM; + (void)__name; + (void)__service; + (void)__req; + (void)__pai; + errno = ENOSYS; + return EAI_SYSTEM; } -int getnameinfo(const struct sockaddr *__restrict __sa, - socklen_t __salen, +int getnameinfo(const struct sockaddr *__restrict __sa, socklen_t __salen, char *__restrict __host, socklen_t __hostlen, - char *__restrict __serv, socklen_t __servlen, - int __flags) { - (void)__sa; - (void)__salen; - (void)__host; - (void)__hostlen; - (void)__serv; - (void)__servlen; - (void)__flags; - errno = ENOSYS; - return EAI_SYSTEM; + char *__restrict __serv, socklen_t __servlen, int __flags) { + (void)__sa; + (void)__salen; + (void)__host; + (void)__hostlen; + (void)__serv; + (void)__servlen; + (void)__flags; + errno = ENOSYS; + return EAI_SYSTEM; } const char *gai_strerror(int __ecode) { - (void)__ecode; - return "address resolution is not supported"; + (void)__ecode; + return "address resolution is not supported"; } diff --git a/libc_extension/pthread.c b/libc_extension/pthread.c index 041566f..aae6166 100644 --- a/libc_extension/pthread.c +++ b/libc_extension/pthread.c @@ -1,7 +1,7 @@ -#include #include +#include -int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) { +int pthread_rwlock_destroy(pthread_rwlock_t *__rwlock) { (void)__rwlock; errno = ENOSYS; return -1; diff --git a/libc_extension/sched.c b/libc_extension/sched.c index d511db8..8d3be95 100644 --- a/libc_extension/sched.c +++ b/libc_extension/sched.c @@ -1,7 +1,7 @@ -#include #include +#include -int sched_yield (void) { +int sched_yield(void) { errno = ENOSYS; return -1; } diff --git a/libc_extension/socket.c b/libc_extension/socket.c index d87c676..5606841 100644 --- a/libc_extension/socket.c +++ b/libc_extension/socket.c @@ -1,110 +1,159 @@ -#include #include +#include -int accept (int __fd, struct sockaddr *__addr, socklen_t *__addr_len) { - (void)__fd; (void)__addr; (void)__addr_len; - errno = ENOSYS; - return -1; -} - -int bind (int __fd, const struct sockaddr *__addr, socklen_t __len) { - (void)__fd; (void)__addr; (void)__len; - errno = ENOSYS; - return -1; -} - -int connect (int __fd, const struct sockaddr *__addr, socklen_t __len) { - (void)__fd; (void)__addr; (void)__len; - errno = ENOSYS; - return -1; -} - -int getpeername (int __fd, struct sockaddr *__addr, socklen_t *__len) { - (void)__fd; (void)__addr; (void)__len; - errno = ENOSYS; - return -1; -} - -int getsockname (int __fd, struct sockaddr *__addr, socklen_t *__len) { - (void)__fd; (void)__addr; (void)__len; - errno = ENOSYS; - return -1; -} - -int getsockopt (int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen) { - (void)__fd; (void)__level; (void)__optname; (void)__optval; (void)__optlen; - errno = ENOSYS; - return -1; -} - -int listen (int __fd, int __n) { - (void)__fd; (void)__n; - errno = ENOSYS; - return -1; -} - -ssize_t recv (int __fd, void *__buf, size_t __n, int __flags) { - (void)__fd; (void)__buf; (void)__n; (void)__flags; - errno = ENOSYS; - return -1; -} - -ssize_t recvfrom (int __fd, void *__buf, size_t __n, int __flags, struct sockaddr *__addr, socklen_t *__addr_len) { - (void)__fd; (void)__buf; (void)__n; (void)__flags; (void)__addr; (void)__addr_len; - errno = ENOSYS; - return -1; -} - -ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags) { - (void)__fd; (void)__message; (void)__flags; - errno = ENOSYS; - return -1; -} - -ssize_t send (int __fd, const void *__buf, size_t __n, int __flags) { - (void)__fd; (void)__buf; (void)__n; (void)__flags; - errno = ENOSYS; - return -1; -} - -ssize_t sendmsg (int __fd, const struct msghdr *__message, int __flags) { - (void)__fd; (void)__message; (void)__flags; - errno = ENOSYS; - return -1; -} - -ssize_t sendto (int __fd, const void *__buf, size_t __n, int __flags, const struct sockaddr *__addr, socklen_t __addr_len) { - (void)__fd; (void)__buf; (void)__n; (void)__flags; (void)__addr; (void)__addr_len; - errno = ENOSYS; - return -1; -} - -int setsockopt (int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen) { - (void)__fd; (void)__level; (void)__optname; (void)__optval; (void)__optlen; - errno = ENOSYS; - return -1; -} - -int shutdown (int __fd, int __how) { - (void)__fd; (void)__how; - errno = ENOSYS; - return -1; -} - -int socket (int __domain, int __type, int __protocol) { - (void)__domain; (void)__type; (void)__protocol; - errno = ENOSYS; - return -1; -} - -int sockatmark (int __fd) { - (void)__fd; - errno = ENOSYS; - return -1; -} - -int socketpair (int __domain, int __type, int __protocol, int __fds[2]) { - (void)__domain; (void)__type; (void)__protocol; (void)__fds; - errno = ENOSYS; - return -1; +int accept(int __fd, struct sockaddr *__addr, socklen_t *__addr_len) { + (void)__fd; + (void)__addr; + (void)__addr_len; + errno = ENOSYS; + return -1; +} + +int bind(int __fd, const struct sockaddr *__addr, socklen_t __len) { + (void)__fd; + (void)__addr; + (void)__len; + errno = ENOSYS; + return -1; +} + +int connect(int __fd, const struct sockaddr *__addr, socklen_t __len) { + (void)__fd; + (void)__addr; + (void)__len; + errno = ENOSYS; + return -1; +} + +int getpeername(int __fd, struct sockaddr *__addr, socklen_t *__len) { + (void)__fd; + (void)__addr; + (void)__len; + errno = ENOSYS; + return -1; +} + +int getsockname(int __fd, struct sockaddr *__addr, socklen_t *__len) { + (void)__fd; + (void)__addr; + (void)__len; + errno = ENOSYS; + return -1; +} + +int getsockopt(int __fd, int __level, int __optname, void *__optval, + socklen_t *__optlen) { + (void)__fd; + (void)__level; + (void)__optname; + (void)__optval; + (void)__optlen; + errno = ENOSYS; + return -1; +} + +int listen(int __fd, int __n) { + (void)__fd; + (void)__n; + errno = ENOSYS; + return -1; +} + +ssize_t recv(int __fd, void *__buf, size_t __n, int __flags) { + (void)__fd; + (void)__buf; + (void)__n; + (void)__flags; + errno = ENOSYS; + return -1; +} + +ssize_t recvfrom(int __fd, void *__buf, size_t __n, int __flags, + struct sockaddr *__addr, socklen_t *__addr_len) { + (void)__fd; + (void)__buf; + (void)__n; + (void)__flags; + (void)__addr; + (void)__addr_len; + errno = ENOSYS; + return -1; +} + +ssize_t recvmsg(int __fd, struct msghdr *__message, int __flags) { + (void)__fd; + (void)__message; + (void)__flags; + errno = ENOSYS; + return -1; +} + +ssize_t send(int __fd, const void *__buf, size_t __n, int __flags) { + (void)__fd; + (void)__buf; + (void)__n; + (void)__flags; + errno = ENOSYS; + return -1; +} + +ssize_t sendmsg(int __fd, const struct msghdr *__message, int __flags) { + (void)__fd; + (void)__message; + (void)__flags; + errno = ENOSYS; + return -1; +} + +ssize_t sendto(int __fd, const void *__buf, size_t __n, int __flags, + const struct sockaddr *__addr, socklen_t __addr_len) { + (void)__fd; + (void)__buf; + (void)__n; + (void)__flags; + (void)__addr; + (void)__addr_len; + errno = ENOSYS; + return -1; +} + +int setsockopt(int __fd, int __level, int __optname, const void *__optval, + socklen_t __optlen) { + (void)__fd; + (void)__level; + (void)__optname; + (void)__optval; + (void)__optlen; + errno = ENOSYS; + return -1; +} + +int shutdown(int __fd, int __how) { + (void)__fd; + (void)__how; + errno = ENOSYS; + return -1; +} + +int socket(int __domain, int __type, int __protocol) { + (void)__domain; + (void)__type; + (void)__protocol; + errno = ENOSYS; + return -1; +} + +int sockatmark(int __fd) { + (void)__fd; + errno = ENOSYS; + return -1; +} + +int socketpair(int __domain, int __type, int __protocol, int __fds[2]) { + (void)__domain; + (void)__type; + (void)__protocol; + (void)__fds; + errno = ENOSYS; + return -1; } diff --git a/libc_extension/sys_mman.c b/libc_extension/sys_mman.c index 3cec4ea..5479160 100644 --- a/libc_extension/sys_mman.c +++ b/libc_extension/sys_mman.c @@ -1,7 +1,8 @@ #include #include -void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { +void *mmap(void *addr, size_t length, int prot, int flags, int fd, + off_t offset) { (void)addr; (void)length; (void)prot; diff --git a/libc_extension/sys_sem.c b/libc_extension/sys_sem.c index a204b0e..e017df7 100644 --- a/libc_extension/sys_sem.c +++ b/libc_extension/sys_sem.c @@ -1,6 +1,6 @@ #include -#include #include +#include int semctl(int semid, int semnum, int cmd, ...) { va_list ap; diff --git a/libc_extension/syslog.c b/libc_extension/syslog.c index 5dc80eb..5f2abd9 100644 --- a/libc_extension/syslog.c +++ b/libc_extension/syslog.c @@ -1,9 +1,7 @@ #include #include -void closelog(void) { - errno = ENOSYS; -} +void closelog(void) { errno = ENOSYS; } void openlog(const char *ident, int option, int facility) { (void)ident; diff --git a/libc_extension/uio.c b/libc_extension/uio.c index 8dec4a8..46e0065 100644 --- a/libc_extension/uio.c +++ b/libc_extension/uio.c @@ -1,18 +1,18 @@ -#include #include +#include -ssize_t readv (int __fd, const struct iovec *__iovec, int __count) { - (void)__fd; - (void)__iovec; - (void)__count; - errno = ENOSYS; - return -1; +ssize_t readv(int __fd, const struct iovec *__iovec, int __count) { + (void)__fd; + (void)__iovec; + (void)__count; + errno = ENOSYS; + return -1; } -ssize_t writev (int __fd, const struct iovec *__iovec, int __count) { - (void)__fd; - (void)__iovec; - (void)__count; - errno = ENOSYS; - return -1; +ssize_t writev(int __fd, const struct iovec *__iovec, int __count) { + (void)__fd; + (void)__iovec; + (void)__count; + errno = ENOSYS; + return -1; } From 48a5a5e70e5c55c1fd9b918c55ea55acba416a2a Mon Sep 17 00:00:00 2001 From: Tom Kuchler Date: Mon, 29 Jun 2026 11:00:32 +0200 Subject: [PATCH 15/16] Try fix restrict keyword --- libc_extension/include/aio.h | 4 ++-- libc_extension/include/arpa/inet.h | 4 ++-- libc_extension/include/dlfcn.h | 2 +- libc_extension/include/monetary.h | 13 +++++++++++-- libc_extension/include/mqueue.h | 7 ++++--- libc_extension/include/semaphore.h | 4 ++-- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/libc_extension/include/aio.h b/libc_extension/include/aio.h index 9ee3c25..9520216 100644 --- a/libc_extension/include/aio.h +++ b/libc_extension/include/aio.h @@ -41,8 +41,8 @@ int aio_read(struct aiocb *); ssize_t aio_return(struct aiocb *); int aio_suspend(const struct aiocb *const[], int, const struct timespec *); int aio_write(struct aiocb *); -int lio_listio(int, struct aiocb *restrict const[restrict], int, - struct sigevent *restrict); +int lio_listio(int, struct aiocb *__restrict const[__restrict], int, + struct sigevent *__restrict); #ifdef __cplusplus } diff --git a/libc_extension/include/arpa/inet.h b/libc_extension/include/arpa/inet.h index eca9376..b0edc0b 100644 --- a/libc_extension/include/arpa/inet.h +++ b/libc_extension/include/arpa/inet.h @@ -28,8 +28,8 @@ uint16_t ntohs(uint16_t); in_addr_t inet_addr(const char *); char *inet_ntoa(struct in_addr); -const char *inet_ntop(int, const void *restrict, char *restrict, socklen_t); -int inet_pton(int, const char *restrict, void *restrict); +const char *inet_ntop(int, const void *__restrict, char *__restrict, socklen_t); +int inet_pton(int, const char *__restrict, void *__restrict); #ifdef __cplusplus } diff --git a/libc_extension/include/dlfcn.h b/libc_extension/include/dlfcn.h index 33128dd..a671908 100644 --- a/libc_extension/include/dlfcn.h +++ b/libc_extension/include/dlfcn.h @@ -14,7 +14,7 @@ extern "C" { int dlclose(void *); char *dlerror(void); void *dlopen(const char *, int); -void *dlsym(void *restrict, const char *restrict); +void *dlsym(void *__restrict, const char *__restrict); #ifdef __cplusplus } diff --git a/libc_extension/include/monetary.h b/libc_extension/include/monetary.h index c533c72..5dd67be 100644 --- a/libc_extension/include/monetary.h +++ b/libc_extension/include/monetary.h @@ -5,11 +5,20 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + __BEGIN_DECLS -ssize_t strfmon(char *restrict, size_t, const char *restrict, ...); -ssize_t strfmon_l(char *restrict, size_t, locale_t, const char *restrict, ...); +ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...); +ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, + ...); __END_DECLS +#ifdef __cplusplus +} +#endif + #endif /* _MONETARY_H_ */ diff --git a/libc_extension/include/mqueue.h b/libc_extension/include/mqueue.h index b16bc86..3678c88 100644 --- a/libc_extension/include/mqueue.h +++ b/libc_extension/include/mqueue.h @@ -26,9 +26,10 @@ int mq_notify(mqd_t, const struct sigevent *); mqd_t mq_open(const char *, int, ...); ssize_t mq_receive(mqd_t, char *, size_t, unsigned *); int mq_send(mqd_t, const char *, size_t, unsigned); -int mq_setattr(mqd_t, const struct mq_attr *restrict, struct mq_attr *restrict); -ssize_t mq_timedreceive(mqd_t, char *restrict, size_t, unsigned *restrict, - const struct timespec *restrict); +int mq_setattr(mqd_t, const struct mq_attr *__restrict, + struct mq_attr *__restrict); +ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, + const struct timespec *__restrict); int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *); int mq_unlink(const char *); diff --git a/libc_extension/include/semaphore.h b/libc_extension/include/semaphore.h index ec33bbb..8f49bd9 100644 --- a/libc_extension/include/semaphore.h +++ b/libc_extension/include/semaphore.h @@ -16,11 +16,11 @@ typedef struct { int sem_close(sem_t *); int sem_destroy(sem_t *); -int sem_getvalue(sem_t *restrict, int *restrict); +int sem_getvalue(sem_t *__restrict, int *__restrict); int sem_init(sem_t *, int, unsigned); sem_t *sem_open(const char *, int, ...); int sem_post(sem_t *); -int sem_timedwait(sem_t *restrict, const struct timespec *restrict); +int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict); int sem_trywait(sem_t *); int sem_unlink(const char *); int sem_wait(sem_t *); From 9299074aeff7bb49138f56748d84b3ab4009b7c0 Mon Sep 17 00:00:00 2001 From: Tom Kuchler Date: Mon, 29 Jun 2026 11:08:33 +0200 Subject: [PATCH 16/16] Fix template file --- libc_extension/CMakeLists.txt | 2 +- .../sys/{utsname_template.h => utsname.template} | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) rename libc_extension/include/sys/{utsname_template.h => utsname.template} (63%) diff --git a/libc_extension/CMakeLists.txt b/libc_extension/CMakeLists.txt index 0f65896..eb5a8aa 100644 --- a/libc_extension/CMakeLists.txt +++ b/libc_extension/CMakeLists.txt @@ -10,7 +10,7 @@ configure_file( ) # Render sys/utsname.h from the source template so field sizes track the configured UTSNAME_FIELD_SIZE. configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/include/sys/utsname_template.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/sys/utsname.template ${LIBC_EXTENSION_GENERATED_INCLUDE_DIR}/sys/utsname.h @ONLY ) diff --git a/libc_extension/include/sys/utsname_template.h b/libc_extension/include/sys/utsname.template similarity index 63% rename from libc_extension/include/sys/utsname_template.h rename to libc_extension/include/sys/utsname.template index 092b2b8..802039a 100644 --- a/libc_extension/include/sys/utsname_template.h +++ b/libc_extension/include/sys/utsname.template @@ -9,11 +9,11 @@ extern "C" { * https://sources.debian.org/src/glibc/2.41-12/sysdeps/unix/sysv/linux/bits/utsname.h/ */ struct utsname { - char sysname[@UTSNAME_FIELD_SIZE @]; - char nodename[@UTSNAME_FIELD_SIZE @]; - char release[@UTSNAME_FIELD_SIZE @]; - char version[@UTSNAME_FIELD_SIZE @]; - char machine[@UTSNAME_FIELD_SIZE @]; + char sysname[@UTSNAME_FIELD_SIZE@]; + char nodename[@UTSNAME_FIELD_SIZE@]; + char release[@UTSNAME_FIELD_SIZE@]; + char version[@UTSNAME_FIELD_SIZE@]; + char machine[@UTSNAME_FIELD_SIZE@]; }; int uname(struct utsname *);