diff --git a/stdlib/public/Platform/CMakeLists.txt b/stdlib/public/Platform/CMakeLists.txt index 6b878c8cded8c..31419b092c057 100644 --- a/stdlib/public/Platform/CMakeLists.txt +++ b/stdlib/public/Platform/CMakeLists.txt @@ -161,8 +161,9 @@ add_swift_target_library(swiftMusl ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OV ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} ${swift_platform_compile_flags} LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" - TARGET_SDKS MUSL - INSTALL_IN_COMPONENT sdk-overlay) + TARGET_SDKS LINUX_STATIC + INSTALL_IN_COMPONENT sdk-overlay + DEPENDS musl_modulemap) add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY ${swift_platform_sources} @@ -198,6 +199,80 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE TARGET_SDKS WINDOWS INSTALL_IN_COMPONENT sdk-overlay) +foreach(sdk ${SWIFT_SDKS}) + # Add more platforms supporting Musl to these checks, + if(NOT "${sdk}" STREQUAL "LINUX_STATIC") + continue() + endif() + + set(musl_modulemap "musl.modulemap") + set(musl_header "SwiftMusl.h") + + foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES}) + set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}") + set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}") + set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}") + + set(musl_modulemap_out "${module_dir}/${musl_modulemap}") + set(musl_modulemap_out_static "${module_dir_static}/${musl_modulemap}") + set(musl_header_out "${module_dir}/${musl_header}") + set(musl_header_out_static "${module_dir_static}/${musl_header}") + + add_custom_command_target( + copy_musl_modulemap + COMMAND + "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir} + COMMAND + "${CMAKE_COMMAND}" "-E" "copy" + ${CMAKE_CURRENT_LIST_DIR}/${musl_modulemap} + ${musl_modulemap_out} + COMMAND + "${CMAKE_COMMAND}" "-E" "copy" + ${CMAKE_CURRENT_LIST_DIR}/${musl_header} + ${musl_header_out} + OUTPUT ${musl_modulemap_out} ${musl_header_out} + COMMENT "Copying Musl modulemap to resources") + + list(APPEND musl_modulemap_target_list ${copy_musl_modulemap}) + + if(SWIFT_BUILD_STATIC_STDLIB OR SWIFT_SDK_${sdk}_STATIC_ONLY) + add_custom_command_target( + copy_musl_modulemap_static + COMMAND + "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static} + COMMAND + "${CMAKE_COMMAND}" "-E" "copy" + ${CMAKE_CURRENT_LIST_DIR}/${musl_modulemap} + ${musl_modulemap_out_static} + COMMAND + "${CMAKE_COMMAND}" "-E" "copy" + ${CMAKE_CURRENT_LIST_DIR}/${musl_header} + ${musl_header_out_static} + OUTPUT ${musl_modulemap_out_static} ${musl_header_out_static} + COMMENT "Copying Musl modulemap to static resources") + + list(APPEND musl_modulemap_target_list ${copy_musl_modulemap_static}) + + swift_install_in_component(FILES "${musl_modulemap_out_static}" + DESTINATION "lib/swift_static/${arch_subdir}" + COMPONENT sdk-overlay) + swift_install_in_component(FILES "${musl_header_out_static}" + DESTINATION "lib/swift_static/${arch_subdir}" + COMPONENT sdk-overlay) + endif() + + swift_install_in_component(FILES "${musl_modulemap_out}" + DESTINATION "lib/swift/${arch_subdir}" + COMPONENT sdk-overlay) + swift_install_in_component(FILES "${musl_header_out}" + DESTINATION "lib/swift/${arch_subdir}" + COMPONENT sdk-overlay) + endforeach() +endforeach() +add_custom_target(musl_modulemap DEPENDS ${musl_modulemap_target_list}) +set_property(TARGET musl_modulemap PROPERTY FOLDER "Miscellaneous") +add_dependencies(sdk-overlay musl_modulemap) + set(glibc_modulemap_target_list) foreach(sdk ${SWIFT_SDKS}) if(NOT "${sdk}" STREQUAL "LINUX" AND @@ -238,7 +313,7 @@ foreach(sdk ${SWIFT_SDKS}) FLAGS "-DCMAKE_SDK=${sdk}") list(APPEND glibc_modulemap_target_list ${glibc_header_target}) - if(SWIFT_BUILD_STATIC_STDLIB) + if(SWIFT_BUILD_STATIC_STDLIB OR SWIFT_SDK_${sdk}_STATIC_ONLY) add_custom_command_target( copy_glibc_modulemap_header_static COMMAND @@ -287,7 +362,7 @@ foreach(sdk ${SWIFT_SDKS}) DESTINATION "lib/swift/${arch_subdir}" COMPONENT sdk-overlay) - if(SWIFT_BUILD_STATIC_STDLIB) + if(SWIFT_BUILD_STATIC_STDLIB OR SWIFT_SDK_${sdk}_STATIC_ONLY) swift_install_in_component(FILES "${glibc_modulemap_out}" DESTINATION "lib/swift_static/${arch_subdir}" COMPONENT sdk-overlay) diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift index a3e8f439fe44c..0c2d63a0cffdb 100644 --- a/stdlib/public/Platform/Platform.swift +++ b/stdlib/public/Platform/Platform.swift @@ -344,7 +344,9 @@ public var SIG_IGN: sig_t { return unsafeBitCast(1, to: sig_t.self) } public var SIG_ERR: sig_t { return unsafeBitCast(-1, to: sig_t.self) } public var SIG_HOLD: sig_t { return unsafeBitCast(3, to: sig_t.self) } #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Haiku) +#if !canImport(SwiftMusl) public typealias sighandler_t = __sighandler_t +#endif public var SIG_DFL: sighandler_t? { return nil } public var SIG_IGN: sighandler_t { @@ -487,7 +489,7 @@ extension Duration { public var environ: UnsafeMutablePointer?> { return _swift_stdlib_getEnviron() } -#elseif os(Linux) +#elseif os(Linux) && !canImport(SwiftMusl) public var environ: UnsafeMutablePointer?> { return __environ } diff --git a/stdlib/public/Platform/SwiftMusl.h b/stdlib/public/Platform/SwiftMusl.h new file mode 100644 index 0000000000000..4605812b9d68c --- /dev/null +++ b/stdlib/public/Platform/SwiftMusl.h @@ -0,0 +1,187 @@ +//===--- SwiftMusl.h ------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/stdlib/public/Platform/musl.modulemap b/stdlib/public/Platform/musl.modulemap index 18fe29972c3e6..b7f0d67bc5bb4 100644 --- a/stdlib/public/Platform/musl.modulemap +++ b/stdlib/public/Platform/musl.modulemap @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,102 +10,994 @@ // //===----------------------------------------------------------------------===// -module SwiftMusl [system] { - header "stdc-predef.h" +// Note that this module map requires some changes to the Musl headers in order +// for it to work. Specifically: +// +// - The types need to be broken out of into individual files +// in . +// +// - The definitions included in need to be broken out into +// . +// +// - A _modules directory needs to be created; for each of the files mentioned +// in _modules below there should be a header that looks like +// +// #if !__building_module(stdc_foo) +// #error "Do not include this header directly, include instead" +// #endif +// #include +// +// This is so that the replacement headers from Clang and Libc++ work as +// expected. + +module _musl [system] { + config_macros _GNU_SOURCE, _BSD_SOURCE, _XOPEN_SOURCE, _POSIX_SOURCE, _POSIX_C_SOURCE, _LARGEFILE64_SOURCE, _ALL_SOURCE, _DEFAULT_SOURCE, __STRICT_ANSI__ + header "features.h" - // C standard library + header "bits/musldefs.h" + + exclude header "bits/alltypes.h" + + // Type declarations live in bits + module types { + umbrella "bits/types" + module * { + export * + } + } +} + +// Headers that can be overridden by Clang or libc++; in this case what we do is +// we create an underscored module to wrap the actual header, then have the +// module with the nicer name include a forwarding header from _modules. This +// ensures that e.g. `import float_h` will result in pulling in the Clang +// or libc++ versions as expected. + +module _assert [system] { + textual header "assert.h" +} +module assert_h [system] { + header "_modules/assert_h.h" + export * +} + +module _complex [system] { header "complex.h" + export * +} +module complex_h [system] { + header "_modules/complex_h.h" + export * +} + +module _ctype [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "ctype.h" + export * +} +module ctype_h [system] { + header "_modules/ctype_h.h" + export * +} + +module _errno [system] { + config_macros _GNU_SOURCE header "errno.h" + export * +} +module errno_h [system] { + header "_modules/errno_h.h" + export * +} + +module _fenv [system] { header "fenv.h" + export * +} +module fenv_h [system] { + header "_modules/fenv_h.h" + export * +} + +module _float [system] { header "float.h" + export * +} +module float_h [system] { + header "_modules/float_h.h" + export * +} + +module _inttypes [system] { header "inttypes.h" + export * +} +module inttypes_h [system] { + header "_modules/inttypes_h.h" + use stdint_h + export * +} + +module _iso646 [system] { header "iso646.h" + export * +} +module iso646_h [system] { + header "_modules/iso646_h.h" + export * +} + +module _limits [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "limits.h" + export * +} +module limits_h [system] { + header "_modules/limits_h.h" + export * +} + +module _locale [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "locale.h" + export * +} +module locale_h [system] { + header "_modules/locale_h.h" + export * +} + +module _math [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _XOPEN_SOURCE header "math.h" - header "pty.h" + export * +} +module math_h [system] { + header "_modules/math_h.h" + export * +} + +module _setjmp [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "setjmp.h" - header "signal.h" + export * +} +module setjmp_h [system] { + header "_modules/setjmp_h.h" + export * +} + +module _stdalign [system] { + header "stdalign.h" + export * +} +module stdalign_h [system] { + header "_modules/stdalign_h.h" + export * +} + +module _stdarg [system] { header "stdarg.h" + export * +} +module stdarg_h [system] { + header "_modules/stdarg_h.h" + export * +} + +module _stdatomic [system] { + header "stdatomic.h" + export * +} +module stdatomic_h [system] { + header "_modules/stdatomic_h.h" + export * +} + +module _stdbool [system] { header "stdbool.h" + export * +} +module stdbool_h [system] { + header "_modules/stdbool_h.h" + export * +} + +module _stddef [system] { header "stddef.h" + export * +} +module stddef_h [system] { + header "_modules/stddef_h.h" + export * +} + +module _stdint [system] { header "stdint.h" + export * +} +module stdint_h [system] { + header "_modules/stdint_h.h" + export * +} + +module _stdio [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "stdio.h" + export * +} +module stdio_h [system] { + header "_modules/stdio_h.h" + export * +} + +module _stdlib [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "stdlib.h" + export * +} +module stdlib_h [system] { + header "_modules/stdlib_h.h" + export * +} + +module _string [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "string.h" + export * +} +module string_h [system] { + header "_modules/string_h.h" + export * +} + +module _tgmath [system] { header "tgmath.h" + export * +} +module tgmath_h [system] { + header "_modules/tgmath_h.h" + export * +} + +module _uchar [system] { + header "uchar.h" + export * +} +module uchar_h [system] { + header "_modules/uchar_h.h" + export * +} + +module _wchar [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE + header "wchar.h" + export * +} +module wchar_h [system] { + header "_modules/wchar_h.h" + export * +} + +module _wctype [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE + header "wctype.h" + export * +} +module wctype_h [system] { + header "_modules/wctype_h.h" + export * +} + +// C library headers +module time_h [system] { + config_macros _POSIX_SOURCE, _POSIX_C_SOURCE, _XOPEN_SOURCE, _GNU_SOURCE, _BSD_SOURCE header "time.h" - header "utmp.h" + export * +} + +module signal_h [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE + header "signal.h" + export * +} + +module stdnoreturn_h [system] { + header "stdnoreturn.h" + export * +} + +module threads_h [system] { + header "threads.h" + export * +} - // POSIX +// POSIX +module posix_aio [system] { + config_macros _LARGEFILE64_SOURCE header "aio.h" + export * +} + +module arpa_inet [system] { header "arpa/inet.h" + export * +} + +// Non-POSIX +module arpa_ftp [system] { + header "arpa/ftp.h" + export * +} +module arpa_nameser [system] { + header "arpa/nameser.h" + export * +} +module arpa_nameser_compat [system] { + header "arpa/nameser_compat.h" + export * +} +module arpa_telnet [system] { + header "arpa/telnet.h" + export * +} +module arpa_tftp [system] { + header "arpa/tftp.h" + export * +} + +// POSIX +module posix_cpio [system] { header "cpio.h" + export * +} +module posix_dirent [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE, _XOPEN_SOURCE header "dirent.h" + export * +} +module posix_dlfcn [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "dlfcn.h" + export * + + link "dl" +} +module posix_fcntl [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "fcntl.h" + export * +} +module posix_fmtmsg [system] { header "fmtmsg.h" + export * +} +module posix_fnmatch [system] { header "fnmatch.h" + export * +} +module posix_ftw [system] { + config_macros _LARGEFILE64_SOURCE header "ftw.h" + export * +} +module posix_glob [system] { + config_macros _LARGEFILE64_SOURCE header "glob.h" + export * +} +module posix_grp [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _XOPEN_SOURCE header "grp.h" + export * +} +module posix_iconv [system] { header "iconv.h" - header "ifaddrs.h" + export * +} +module posix_langinfo [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "langinfo.h" + export * +} +module posix_libgen [system] { header "libgen.h" - header "link.h" + export * +} +module posix_monetary [system] { header "monetary.h" + export * +} +module posix_mqueue [system] { + header "mqueue.h" + export * +} + +// POSIX +module net_if [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "net/if.h" + export * +} + +// Non-POSIX +module fts [system] { + header "fts.h" + export * + + link "fts" +} + +module net_ethernet [system] { + header "net/ethernet.h" + // Include here because these two headers circularly + // depend on one another + header "netinet/if_ether.h" + export * +} +module net_if_arp [system] { + header "net/if_arp.h" + export * +} +module net_route [system] { + header "net/route.h" + export * +} + +// POSIX +module posix_netdb [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "netdb.h" + export * +} + +// POSIX +module netinet_in [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "netinet/in.h" + export * +} +module netinet_tcp [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "netinet/tcp.h" + export * +} + +// Non-POSIX +module netinet_ether [system] { + header "netinet/ether.h" + export * +} +module netinet_icmp6 [system] { + header "netinet/icmp6.h" + export * +} +// Can't have this one as a module because of the circular dependency +// between netinet/if_ether.h and net/ethernet.h +// +// module netinet_if_ether [system] { +// header "netinet/if_ether.h" +// export * +// } +module netinet_igmp [system] { + header "netinet/igmp.h" + export * +} +module netinet_in_systm [system] { + header "netinet/in_systm.h" + export * +} +module netinet_ip [system] { + header "netinet/ip.h" + export * +} +module netinet_ip6 [system] { + header "netinet/ip6.h" + export * +} +module netinet_ip_icmp [system] { + header "netinet/ip_icmp.h" + export * +} +module netinet_udp [system] { + config_macros _GNU_SOURCE + header "netinet/udp.h" + export * +} + +// POSIX +module posix_nl_types [system] { header "nl_types.h" + export * +} +module posix_poll [system] { + config_macros _GNU_SOURCE header "poll.h" + export * +} +module posix_pthread [system] { + config_macros _GNU_SOURCE header "pthread.h" + export * + + link "pthread" +} +module posix_pwd [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _XOPEN_SOURCE header "pwd.h" + export * +} +module posix_regex [system] { header "regex.h" + export * +} +module posix_sched [system] { + config_macros _GNU_SOURCE header "sched.h" + export * +} +module posix_search [system] { + config_macros _GNU_SOURCE header "search.h" + export * +} +module posix_semaphore [system] { header "semaphore.h" + export * +} +module posix_spawn [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "spawn.h" + export * +} +module posix_strings [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "strings.h" - header "sys/file.h" - header "sys/inotify.h" - header "sys/ioctl.h" + export * +} +module posix_stropts [system] { + header "stropts.h" + export * +} + +// POSIX +module sys_ipc [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "sys/ipc.h" + export * +} +module sys_mman [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE header "sys/mman.h" - header "sys/mount.h" + export * +} +module sys_msg [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "sys/msg.h" + export * +} +module sys_resource [system] { + config_macros _GNU_SOURCE, _LARGEFILE64_SOURCE header "sys/resource.h" + export * +} +module sys_select [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "sys/select.h" + export * +} +module sys_sem [system] { + config_macros _GNU_SOURCE header "sys/sem.h" - header "sys/sendfile.h" + export * +} +module sys_shm [system] { + config_macros _GNU_SOURCE header "sys/shm.h" + export * +} +module sys_socket [system] { + config_macros _GNU_SOURCE header "sys/socket.h" + export * +} +module sys_stat [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE, _XOPEN_SOURCE header "sys/stat.h" + export * +} +module sys_statvfs [system] { + config_macros _LARGEFILE64_SOURCE header "sys/statvfs.h" + export * +} +module sys_time [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "sys/time.h" + export * +} +module sys_times [system] { header "sys/times.h" + export * +} +module sys_types [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE header "sys/types.h" + export * +} +module sys_uio [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE header "sys/uio.h" + export * +} +module sys_un [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "sys/un.h" - header "sys/user.h" + export * +} +module sys_utsname [system] { + config_macros _GNU_SOURCE header "sys/utsname.h" + export * +} +module sys_wait [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE header "sys/wait.h" - header "sysexits.h" + export * +} + +// Non-POSIX +module sys_acct [system] { + header "sys/acct.h" + export * +} +module sys_auxv [system] { + header "sys/auxv.h" + export * +} +module sys_cachectl [system] { + header "sys/cachectl.h" + export * +} +module sys_dir [system] { + header "sys/dir.h" + export * +} +module sys_epoll [system] { + header "sys/epoll.h" + export * +} +module sys_eventfd [system] { + header "sys/eventfd.h" + export * +} +module sys_fanotify [system] { + header "sys/fanotify.h" + export * +} +module sys_file [system] { + header "sys/file.h" + export * +} +module sys_fsuid [system] { + header "sys/fsuid.h" + export * +} +module sys_inotify [system] { + header "sys/inotify.h" + export * +} +module sys_ioctl [system] { + header "sys/ioctl.h" + export * +} +module sys_io [system] { + header "sys/io.h" + export * +} +module sys_klog [system] { + header "sys/klog.h" + export * +} +module sys_membarrier [system] { + header "sys/membarrier.h" + export * +} +module sys_mount [system] { + header "sys/mount.h" + export * +} +module sys_mtio [system] { + header "sys/mtio.h" + export * +} +module sys_param [system] { + header "sys/param.h" + export * +} +module sys_personality [system] { + header "sys/personality.h" + export * +} +module sys_prctl [system] { + header "sys/prctl.h" + export * +} +module sys_procfs [system] { + header "sys/procfs.h" + export * +} +module sys_ptrace [system] { + header "sys/ptrace.h" + export * +} +module sys_quota [system] { + header "sys/quota.h" + export * +} +module sys_random [system] { + header "sys/random.h" + export * +} +module sys_reboot [system] { + header "sys/reboot.h" + export * +} +module sys_reg [system] { + header "sys/reg.h" + export * +} +module sys_sendfile [system] { + config_macros _LARGEFILE64_SOURCE + header "sys/sendfile.h" + export * +} +module sys_signalfd [system] { + header "sys/signalfd.h" + export * +} +module sys_statfs [system] { + config_macros _LARGEFILE64_SOURCE + header "sys/statfs.h" + export * +} +module sys_stropts [system] { + header "sys/stropts.h" + export * +} +module sys_swap [system] { + header "sys/swap.h" + export * +} +module sys_syscall [system] { + header "sys/syscall.h" + export * +} +module sys_sysinfo [system] { + header "sys/sysinfo.h" + export * +} +module sys_syslog [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE + header "sys/syslog.h" + export * +} +module sys_sysmacros [system] { + header "sys/sysmacros.h" + export * +} +module sys_timeb [system] { + header "sys/timeb.h" + export * +} +module sys_timerfd [system] { + header "sys/timerfd.h" + export * +} +module sys_timex [system] { + header "sys/timex.h" + export * +} +module sys_ttydefaults [system] { + header "sys/ttydefaults.h" + export * +} +module sys_ucontext [system] { + config_macros _GNU_SOURCE, _BSD_SOURCE + header "sys/ucontext.h" + export * +} +module sys_user [system] { + header "sys/user.h" + export * +} +module sys_vfs [system] { + header "sys/vfs.h" + export * +} +module sys_xattr [system] { + header "sys/xattr.h" + export * +} + +// POSIX +module posix_syslog [system] { header "syslog.h" + export * +} +module posix_tar [system] { header "tar.h" + export * +} +module posix_termios [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "termios.h" - header "ulimit.h" + export * +} +module posix_ucontext [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE + header "ucontext.h" + export * +} +module posix_unistd [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE, _LARGEFILE64_SOURCE, _XOPEN_SOURCE header "unistd.h" + export * +} +module posix_ulimit [system] { + header "ulimit.h" + export * +} +module posix_utime [system] { header "utime.h" + export * +} +module posix_utmpx [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE header "utmpx.h" + export * +} + +// Other, non-standard headers +module linux_alloca [system] { + header "alloca.h" + export * +} +module linux_ar [system] { + header "ar.h" + export * +} +module linux_byteswap [system] { + header "byteswap.h" + export * +} +module linux_crypt [system] { + header "crypt.h" + export * +} +module linux_elf [system] { + header "elf.h" + export * +} +module linux_endian [system] { + config_macros _BSD_SOURCE, _GNU_SOURCE + header "endian.h" + export * +} +module linux_err [system] { + header "err.h" + export * +} +module linux_getopt [system] { + header "getopt.h" + export * +} +module linux_ifaddrs [system] { + header "ifaddrs.h" + export * +} +module linux_lastlog [system] { + header "lastlog.h" + export * +} +module linux_libintl [system] { + header "libintl.h" + export * +} +module linux_link [system] { + header "link.h" + export * +} +module linux_malloc [system] { + header "malloc.h" + export * +} +module linux_memory [system] { + header "memory.h" + export * +} +module linux_mntent [system] { + header "mntent.h" + export * +} +module linux_netpacket [system] { + header "netpacket/packet.h" + export * +} +module linux_paths [system] { + header "paths.h" + export * +} +module linux_pty [system] { + header "pty.h" + export * +} +module linux_resolv [system] { + header "resolv.h" + export * + + link "resolv" +} +module linux_scsi [system] { + header "scsi/scsi.h" + header "scsi/scsi_ioctl.h" + header "scsi/sg.h" + export * +} +module linux_shadow [system] { + header "shadow.h" + export * +} +module linux_stdio_ext [system] { + header "stdio_ext.h" + export * +} +module linux_syscall [system] { + header "syscall.h" + export * +} +module linux_sysexits [system] { + header "sysexits.h" + export * +} +module linux_utmp [system] { + header "utmp.h" + export * +} +module linux_values [system] { + header "values.h" + export * +} +module linux_unwind [system] { + header "unwind.h" + export * +} +module linux_wordexp [system] { header "wordexp.h" + export * +} - // 's use of NDEBUG requires textual inclusion. - textual header "assert.h" +module linux_excludes [system] { + // Linux redirection headers + exclude header "sys/kd.h" + exclude header "sys/soundcard.h" + exclude header "sys/vt.h" + + // Redirection headers + exclude header "sys/termios.h" + exclude header "sys/fcntl.h" + exclude header "sys/errno.h" + exclude header "sys/poll.h" + exclude header "sys/signal.h" + exclude header "wait.h" +} + +// START SWIFT ONLY +// This is for Swift; it includes all the (modular) Musl headers +module SwiftMusl [system] { + header "SwiftMusl.h" export * } +// END SWIFT ONLY