Elliott Hughes | 13da600 | 2025-02-03 10:42:13 -0800 | [diff] [blame] | 1 | // Copyright (C) 2017 The Android Open Source Project |
| 2 | // SPDX-License-Identifier: BSD-2-Clause |
Elliott Hughes | 21b56eb | 2017-10-20 17:57:17 -0700 | [diff] [blame] | 3 | |
| 4 | #include <fcntl.h> |
| 5 | |
| 6 | #include "header_checks.h" |
| 7 | |
| 8 | static void fcntl_h() { |
| 9 | MACRO(F_DUPFD); |
| 10 | MACRO(F_DUPFD_CLOEXEC); |
| 11 | MACRO(F_GETFD); |
| 12 | MACRO(F_SETFD); |
| 13 | MACRO(F_GETFL); |
| 14 | MACRO(F_SETFL); |
| 15 | MACRO(F_GETLK); |
| 16 | MACRO(F_SETLK); |
| 17 | MACRO(F_SETLKW); |
| 18 | MACRO(F_GETOWN); |
| 19 | MACRO(F_SETOWN); |
| 20 | |
| 21 | MACRO(FD_CLOEXEC); |
| 22 | |
| 23 | MACRO(F_RDLCK); |
| 24 | MACRO(F_UNLCK); |
| 25 | MACRO(F_WRLCK); |
| 26 | |
| 27 | MACRO(SEEK_SET); |
| 28 | MACRO(SEEK_CUR); |
| 29 | MACRO(SEEK_END); |
| 30 | |
| 31 | MACRO(O_CLOEXEC); |
| 32 | MACRO(O_CREAT); |
| 33 | MACRO(O_DIRECTORY); |
| 34 | MACRO(O_EXCL); |
| 35 | MACRO(O_NOCTTY); |
| 36 | MACRO(O_NOFOLLOW); |
| 37 | MACRO(O_TRUNC); |
| 38 | #if !defined(__linux__) |
| 39 | MACRO(O_TTY_INIT); |
| 40 | #endif |
| 41 | |
| 42 | MACRO(O_APPEND); |
| 43 | MACRO(O_DSYNC); |
| 44 | MACRO(O_NONBLOCK); |
| 45 | MACRO(O_RSYNC); |
| 46 | MACRO(O_SYNC); |
| 47 | |
| 48 | MACRO(O_ACCMODE); |
| 49 | |
| 50 | #if !defined(__linux__) |
| 51 | MACRO(O_EXEC); |
| 52 | #endif |
| 53 | MACRO(O_RDONLY); |
| 54 | MACRO(O_RDWR); |
| 55 | #if !defined(__linux__) |
| 56 | MACRO(O_SEARCH); |
| 57 | #endif |
| 58 | MACRO(O_WRONLY); |
| 59 | |
| 60 | // POSIX: "The <fcntl.h> header shall define the symbolic constants for |
| 61 | // file modes for use as values of mode_t as described in <sys/stat.h>." |
Colin Cross | b6830ca | 2023-01-18 15:55:48 -0800 | [diff] [blame] | 62 | // Musl only defines the file mode bits (S_IFUSR, etc.) and not the file |
| 63 | // type bits (S_IFMT, etc.). |
| 64 | #if !defined(ANDROID_HOST_MUSL) |
Elliott Hughes | 21b56eb | 2017-10-20 17:57:17 -0700 | [diff] [blame] | 65 | #include "sys_stat_h_mode_constants.h" |
Colin Cross | b6830ca | 2023-01-18 15:55:48 -0800 | [diff] [blame] | 66 | #endif |
Elliott Hughes | 21b56eb | 2017-10-20 17:57:17 -0700 | [diff] [blame] | 67 | |
| 68 | MACRO(AT_FDCWD); |
| 69 | #if !defined(__BIONIC__) // See comment in "faccessat.cpp". |
| 70 | MACRO(AT_EACCESS); |
| 71 | #endif |
| 72 | MACRO(AT_SYMLINK_NOFOLLOW); |
| 73 | MACRO(AT_REMOVEDIR); |
| 74 | |
| 75 | MACRO(POSIX_FADV_DONTNEED); |
| 76 | MACRO(POSIX_FADV_NOREUSE); |
| 77 | MACRO(POSIX_FADV_NORMAL); |
| 78 | MACRO(POSIX_FADV_RANDOM); |
| 79 | MACRO(POSIX_FADV_SEQUENTIAL); |
| 80 | MACRO(POSIX_FADV_WILLNEED); |
| 81 | |
| 82 | TYPE(struct flock); |
| 83 | STRUCT_MEMBER(struct flock, short, l_type); |
| 84 | STRUCT_MEMBER(struct flock, short, l_whence); |
| 85 | STRUCT_MEMBER(struct flock, off_t, l_start); |
| 86 | STRUCT_MEMBER(struct flock, off_t, l_len); |
| 87 | STRUCT_MEMBER(struct flock, pid_t, l_pid); |
| 88 | |
| 89 | TYPE(mode_t); |
| 90 | TYPE(off_t); |
| 91 | TYPE(pid_t); |
| 92 | |
| 93 | FUNCTION(creat, int (*f)(const char*, mode_t)); |
| 94 | FUNCTION(fcntl, int (*f)(int, int, ...)); |
| 95 | FUNCTION(open, int (*f)(const char*, int, ...)); |
| 96 | FUNCTION(openat, int (*f)(int, const char*, int, ...)); |
| 97 | FUNCTION(posix_fadvise, int (*f)(int, off_t, off_t, int)); |
| 98 | FUNCTION(posix_fallocate, int (*f)(int, off_t, off_t)); |
| 99 | } |