From e061b6da5ee46a334169d4e6a52e49857ae22f55 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 26 Apr 2024 17:42:44 -0400 Subject: config: Move .c files into config/{use,has} subdirectories --- config/has/acl-get-entry.c | 8 ++++++++ config/has/acl-get-file.c | 8 ++++++++ config/has/acl-get-tag-type.c | 10 ++++++++++ config/has/acl-is-trivial-np.c | 12 ++++++++++++ config/has/acl-trivial.c | 8 ++++++++ config/has/aligned-alloc.c | 8 ++++++++ config/has/confstr.c | 9 +++++++++ config/has/extattr-get-file.c | 10 ++++++++++ config/has/extattr-get-link.c | 10 ++++++++++ config/has/extattr-list-file.c | 10 ++++++++++ config/has/extattr-list-link.c | 10 ++++++++++ config/has/fdclosedir.c | 8 ++++++++ config/has/getdents.c | 10 ++++++++++ config/has/getdents64-syscall.c | 12 ++++++++++++ config/has/getdents64.c | 10 ++++++++++ config/has/getprogname-gnu.c | 9 +++++++++ config/has/getprogname.c | 9 +++++++++ config/has/max-align-t.c | 8 ++++++++ config/has/pipe2.c | 10 ++++++++++ config/has/posix-spawn-addfchdir-np.c | 11 +++++++++++ config/has/posix-spawn-addfchdir.c | 11 +++++++++++ config/has/st-acmtim.c | 12 ++++++++++++ config/has/st-acmtimespec.c | 12 ++++++++++++ config/has/st-birthtim.c | 9 +++++++++ config/has/st-birthtimespec.c | 9 +++++++++ config/has/st-flags.c | 9 +++++++++ config/has/statx-syscall.c | 13 +++++++++++++ config/has/statx.c | 11 +++++++++++ config/has/strerror-l.c | 11 +++++++++++ config/has/strerror-r-gnu.c | 11 +++++++++++ config/has/strerror-r-posix.c | 11 +++++++++++ config/has/tm-gmtoff.c | 9 +++++++++ config/has/uselocale.c | 9 +++++++++ 33 files changed, 327 insertions(+) create mode 100644 config/has/acl-get-entry.c create mode 100644 config/has/acl-get-file.c create mode 100644 config/has/acl-get-tag-type.c create mode 100644 config/has/acl-is-trivial-np.c create mode 100644 config/has/acl-trivial.c create mode 100644 config/has/aligned-alloc.c create mode 100644 config/has/confstr.c create mode 100644 config/has/extattr-get-file.c create mode 100644 config/has/extattr-get-link.c create mode 100644 config/has/extattr-list-file.c create mode 100644 config/has/extattr-list-link.c create mode 100644 config/has/fdclosedir.c create mode 100644 config/has/getdents.c create mode 100644 config/has/getdents64-syscall.c create mode 100644 config/has/getdents64.c create mode 100644 config/has/getprogname-gnu.c create mode 100644 config/has/getprogname.c create mode 100644 config/has/max-align-t.c create mode 100644 config/has/pipe2.c create mode 100644 config/has/posix-spawn-addfchdir-np.c create mode 100644 config/has/posix-spawn-addfchdir.c create mode 100644 config/has/st-acmtim.c create mode 100644 config/has/st-acmtimespec.c create mode 100644 config/has/st-birthtim.c create mode 100644 config/has/st-birthtimespec.c create mode 100644 config/has/st-flags.c create mode 100644 config/has/statx-syscall.c create mode 100644 config/has/statx.c create mode 100644 config/has/strerror-l.c create mode 100644 config/has/strerror-r-gnu.c create mode 100644 config/has/strerror-r-posix.c create mode 100644 config/has/tm-gmtoff.c create mode 100644 config/has/uselocale.c (limited to 'config/has') diff --git a/config/has/acl-get-entry.c b/config/has/acl-get-entry.c new file mode 100644 index 0000000..3cce771 --- /dev/null +++ b/config/has/acl-get-entry.c @@ -0,0 +1,8 @@ +#include +#include + +int main(void) { + acl_t acl = acl_get_file(".", ACL_TYPE_DEFAULT); + acl_entry_t entry; + return acl_get_entry(acl, ACL_FIRST_ENTRY, &entry); +} diff --git a/config/has/acl-get-file.c b/config/has/acl-get-file.c new file mode 100644 index 0000000..89fbf23 --- /dev/null +++ b/config/has/acl-get-file.c @@ -0,0 +1,8 @@ +#include +#include +#include + +int main(void) { + acl_t acl = acl_get_file(".", ACL_TYPE_DEFAULT); + return acl == (acl_t)NULL; +} diff --git a/config/has/acl-get-tag-type.c b/config/has/acl-get-tag-type.c new file mode 100644 index 0000000..2901956 --- /dev/null +++ b/config/has/acl-get-tag-type.c @@ -0,0 +1,10 @@ +#include +#include +#include + +int main(void) { + acl_entry_t entry; + memset(&entry, 0, sizeof(entry)); + acl_tag_t tag; + return acl_get_tag_type(entry, &tag); +} diff --git a/config/has/acl-is-trivial-np.c b/config/has/acl-is-trivial-np.c new file mode 100644 index 0000000..9ca9fc7 --- /dev/null +++ b/config/has/acl-is-trivial-np.c @@ -0,0 +1,12 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include + +int main(void) { + acl_t acl = acl_get_fd(3); + int trivial; + acl_is_trivial_np(acl, &trivial); + return 0; +} diff --git a/config/has/acl-trivial.c b/config/has/acl-trivial.c new file mode 100644 index 0000000..7efc838 --- /dev/null +++ b/config/has/acl-trivial.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + return acl_trivial("."); +} diff --git a/config/has/aligned-alloc.c b/config/has/aligned-alloc.c new file mode 100644 index 0000000..4460038 --- /dev/null +++ b/config/has/aligned-alloc.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + return !aligned_alloc(_Alignof(void *), sizeof(void *)); +} diff --git a/config/has/confstr.c b/config/has/confstr.c new file mode 100644 index 0000000..58280b4 --- /dev/null +++ b/config/has/confstr.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + confstr(_CS_PATH, NULL, 0); + return 0; +} diff --git a/config/has/extattr-get-file.c b/config/has/extattr-get-file.c new file mode 100644 index 0000000..ac9cf96 --- /dev/null +++ b/config/has/extattr-get-file.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include +#include + +int main(void) { + return extattr_get_file("file", EXTATTR_NAMESPACE_USER, "xattr", NULL, 0); +} diff --git a/config/has/extattr-get-link.c b/config/has/extattr-get-link.c new file mode 100644 index 0000000..c35be5b --- /dev/null +++ b/config/has/extattr-get-link.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include +#include + +int main(void) { + return extattr_get_link("link", EXTATTR_NAMESPACE_USER, "xattr", NULL, 0); +} diff --git a/config/has/extattr-list-file.c b/config/has/extattr-list-file.c new file mode 100644 index 0000000..e68a8bb --- /dev/null +++ b/config/has/extattr-list-file.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include +#include + +int main(void) { + return extattr_list_file("file", EXTATTR_NAMESPACE_USER, NULL, 0); +} diff --git a/config/has/extattr-list-link.c b/config/has/extattr-list-link.c new file mode 100644 index 0000000..49f0ec2 --- /dev/null +++ b/config/has/extattr-list-link.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include +#include + +int main(void) { + return extattr_list_link("link", EXTATTR_NAMESPACE_USER, NULL, 0); +} diff --git a/config/has/fdclosedir.c b/config/has/fdclosedir.c new file mode 100644 index 0000000..f4ad1f5 --- /dev/null +++ b/config/has/fdclosedir.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + return fdclosedir(opendir(".")); +} diff --git a/config/has/getdents.c b/config/has/getdents.c new file mode 100644 index 0000000..d0d4228 --- /dev/null +++ b/config/has/getdents.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct dirent de; + getdents(3, &de, 1024); + return 0; +} diff --git a/config/has/getdents64-syscall.c b/config/has/getdents64-syscall.c new file mode 100644 index 0000000..4838c14 --- /dev/null +++ b/config/has/getdents64-syscall.c @@ -0,0 +1,12 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include +#include + +int main(void) { + struct dirent64 de; + syscall(SYS_getdents64, 3, &de, 1024); + return 0; +} diff --git a/config/has/getdents64.c b/config/has/getdents64.c new file mode 100644 index 0000000..1abf36d --- /dev/null +++ b/config/has/getdents64.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct dirent64 de; + getdents64(3, &de, 1024); + return 0; +} diff --git a/config/has/getprogname-gnu.c b/config/has/getprogname-gnu.c new file mode 100644 index 0000000..6b97c5e --- /dev/null +++ b/config/has/getprogname-gnu.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + const char *str = program_invocation_short_name; + return str[0]; +} diff --git a/config/has/getprogname.c b/config/has/getprogname.c new file mode 100644 index 0000000..83dc8e8 --- /dev/null +++ b/config/has/getprogname.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + const char *str = getprogname(); + return str[0]; +} diff --git a/config/has/max-align-t.c b/config/has/max-align-t.c new file mode 100644 index 0000000..96165ce --- /dev/null +++ b/config/has/max-align-t.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + return _Alignof(max_align_t); +} diff --git a/config/has/pipe2.c b/config/has/pipe2.c new file mode 100644 index 0000000..4cb43b5 --- /dev/null +++ b/config/has/pipe2.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include + +int main(void) { + int fds[2]; + return pipe2(fds, O_CLOEXEC); +} diff --git a/config/has/posix-spawn-addfchdir-np.c b/config/has/posix-spawn-addfchdir-np.c new file mode 100644 index 0000000..b870a53 --- /dev/null +++ b/config/has/posix-spawn-addfchdir-np.c @@ -0,0 +1,11 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + posix_spawn_file_actions_t actions; + posix_spawn_file_actions_init(&actions); + posix_spawn_file_actions_addfchdir_np(&actions, 3); + return 0; +} diff --git a/config/has/posix-spawn-addfchdir.c b/config/has/posix-spawn-addfchdir.c new file mode 100644 index 0000000..c52ff81 --- /dev/null +++ b/config/has/posix-spawn-addfchdir.c @@ -0,0 +1,11 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + posix_spawn_file_actions_t actions; + posix_spawn_file_actions_init(&actions); + posix_spawn_file_actions_addfchdir(&actions, 3); + return 0; +} diff --git a/config/has/st-acmtim.c b/config/has/st-acmtim.c new file mode 100644 index 0000000..d687ab0 --- /dev/null +++ b/config/has/st-acmtim.c @@ -0,0 +1,12 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct stat sb = {0}; + unsigned int a = sb.st_atim.tv_sec; + unsigned int c = sb.st_ctim.tv_sec; + unsigned int m = sb.st_mtim.tv_sec; + return a + c + m; +} diff --git a/config/has/st-acmtimespec.c b/config/has/st-acmtimespec.c new file mode 100644 index 0000000..f747bc0 --- /dev/null +++ b/config/has/st-acmtimespec.c @@ -0,0 +1,12 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct stat sb = {0}; + unsigned int a = sb.st_atimespec.tv_sec; + unsigned int c = sb.st_ctimespec.tv_sec; + unsigned int m = sb.st_mtimespec.tv_sec; + return a + c + m; +} diff --git a/config/has/st-birthtim.c b/config/has/st-birthtim.c new file mode 100644 index 0000000..4964571 --- /dev/null +++ b/config/has/st-birthtim.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct stat sb = {0}; + return sb.st_birthtim.tv_sec; +} diff --git a/config/has/st-birthtimespec.c b/config/has/st-birthtimespec.c new file mode 100644 index 0000000..91a613f --- /dev/null +++ b/config/has/st-birthtimespec.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct stat sb = {0}; + return sb.st_birthtimespec.tv_sec; +} diff --git a/config/has/st-flags.c b/config/has/st-flags.c new file mode 100644 index 0000000..b1d0c32 --- /dev/null +++ b/config/has/st-flags.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct stat sb = {0}; + return sb.st_flags; +} diff --git a/config/has/statx-syscall.c b/config/has/statx-syscall.c new file mode 100644 index 0000000..87ec869 --- /dev/null +++ b/config/has/statx-syscall.c @@ -0,0 +1,13 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include +#include +#include + +int main(void) { + struct statx sb; + syscall(SYS_statx, AT_FDCWD, ".", 0, STATX_BASIC_STATS, &sb); + return 0; +} diff --git a/config/has/statx.c b/config/has/statx.c new file mode 100644 index 0000000..65f1674 --- /dev/null +++ b/config/has/statx.c @@ -0,0 +1,11 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include + +int main(void) { + struct statx sb; + statx(AT_FDCWD, ".", 0, STATX_BASIC_STATS, &sb); + return 0; +} diff --git a/config/has/strerror-l.c b/config/has/strerror-l.c new file mode 100644 index 0000000..3dcc4d7 --- /dev/null +++ b/config/has/strerror-l.c @@ -0,0 +1,11 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include +#include + +int main(void) { + locale_t locale = duplocale(LC_GLOBAL_LOCALE); + return !strerror_l(ENOMEM, locale); +} diff --git a/config/has/strerror-r-gnu.c b/config/has/strerror-r-gnu.c new file mode 100644 index 0000000..26ca0ee --- /dev/null +++ b/config/has/strerror-r-gnu.c @@ -0,0 +1,11 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include + +int main(void) { + char buf[256]; + // Check that strerror_r() returns a pointer + return *strerror_r(ENOMEM, buf, sizeof(buf)); +} diff --git a/config/has/strerror-r-posix.c b/config/has/strerror-r-posix.c new file mode 100644 index 0000000..41b2d30 --- /dev/null +++ b/config/has/strerror-r-posix.c @@ -0,0 +1,11 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include + +int main(void) { + char buf[256]; + // Check that strerror_r() returns an integer + return 2 * strerror_r(ENOMEM, buf, sizeof(buf)); +} diff --git a/config/has/tm-gmtoff.c b/config/has/tm-gmtoff.c new file mode 100644 index 0000000..543df48 --- /dev/null +++ b/config/has/tm-gmtoff.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + struct tm tm = {0}; + return tm.tm_gmtoff; +} diff --git a/config/has/uselocale.c b/config/has/uselocale.c new file mode 100644 index 0000000..a712ff8 --- /dev/null +++ b/config/has/uselocale.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include + +int main(void) { + locale_t locale = uselocale((locale_t)0); + return locale == LC_GLOBAL_LOCALE; +} -- cgit v1.2.3