Elliott Hughes | 21b56eb | 2017-10-20 17:57:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in |
| 12 | * the documentation and/or other materials provided with the |
| 13 | * distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | * SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #include <fcntl.h> |
| 30 | |
| 31 | #include "header_checks.h" |
| 32 | |
| 33 | static void fcntl_h() { |
| 34 | MACRO(F_DUPFD); |
| 35 | MACRO(F_DUPFD_CLOEXEC); |
| 36 | MACRO(F_GETFD); |
| 37 | MACRO(F_SETFD); |
| 38 | MACRO(F_GETFL); |
| 39 | MACRO(F_SETFL); |
| 40 | MACRO(F_GETLK); |
| 41 | MACRO(F_SETLK); |
| 42 | MACRO(F_SETLKW); |
| 43 | MACRO(F_GETOWN); |
| 44 | MACRO(F_SETOWN); |
| 45 | |
| 46 | MACRO(FD_CLOEXEC); |
| 47 | |
| 48 | MACRO(F_RDLCK); |
| 49 | MACRO(F_UNLCK); |
| 50 | MACRO(F_WRLCK); |
| 51 | |
| 52 | MACRO(SEEK_SET); |
| 53 | MACRO(SEEK_CUR); |
| 54 | MACRO(SEEK_END); |
| 55 | |
| 56 | MACRO(O_CLOEXEC); |
| 57 | MACRO(O_CREAT); |
| 58 | MACRO(O_DIRECTORY); |
| 59 | MACRO(O_EXCL); |
| 60 | MACRO(O_NOCTTY); |
| 61 | MACRO(O_NOFOLLOW); |
| 62 | MACRO(O_TRUNC); |
| 63 | #if !defined(__linux__) |
| 64 | MACRO(O_TTY_INIT); |
| 65 | #endif |
| 66 | |
| 67 | MACRO(O_APPEND); |
| 68 | MACRO(O_DSYNC); |
| 69 | MACRO(O_NONBLOCK); |
| 70 | MACRO(O_RSYNC); |
| 71 | MACRO(O_SYNC); |
| 72 | |
| 73 | MACRO(O_ACCMODE); |
| 74 | |
| 75 | #if !defined(__linux__) |
| 76 | MACRO(O_EXEC); |
| 77 | #endif |
| 78 | MACRO(O_RDONLY); |
| 79 | MACRO(O_RDWR); |
| 80 | #if !defined(__linux__) |
| 81 | MACRO(O_SEARCH); |
| 82 | #endif |
| 83 | MACRO(O_WRONLY); |
| 84 | |
| 85 | // POSIX: "The <fcntl.h> header shall define the symbolic constants for |
| 86 | // 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] | 87 | // Musl only defines the file mode bits (S_IFUSR, etc.) and not the file |
| 88 | // type bits (S_IFMT, etc.). |
| 89 | #if !defined(ANDROID_HOST_MUSL) |
Elliott Hughes | 21b56eb | 2017-10-20 17:57:17 -0700 | [diff] [blame] | 90 | #include "sys_stat_h_mode_constants.h" |
Colin Cross | b6830ca | 2023-01-18 15:55:48 -0800 | [diff] [blame] | 91 | #endif |
Elliott Hughes | 21b56eb | 2017-10-20 17:57:17 -0700 | [diff] [blame] | 92 | |
| 93 | MACRO(AT_FDCWD); |
| 94 | #if !defined(__BIONIC__) // See comment in "faccessat.cpp". |
| 95 | MACRO(AT_EACCESS); |
| 96 | #endif |
| 97 | MACRO(AT_SYMLINK_NOFOLLOW); |
| 98 | MACRO(AT_REMOVEDIR); |
| 99 | |
| 100 | MACRO(POSIX_FADV_DONTNEED); |
| 101 | MACRO(POSIX_FADV_NOREUSE); |
| 102 | MACRO(POSIX_FADV_NORMAL); |
| 103 | MACRO(POSIX_FADV_RANDOM); |
| 104 | MACRO(POSIX_FADV_SEQUENTIAL); |
| 105 | MACRO(POSIX_FADV_WILLNEED); |
| 106 | |
| 107 | TYPE(struct flock); |
| 108 | STRUCT_MEMBER(struct flock, short, l_type); |
| 109 | STRUCT_MEMBER(struct flock, short, l_whence); |
| 110 | STRUCT_MEMBER(struct flock, off_t, l_start); |
| 111 | STRUCT_MEMBER(struct flock, off_t, l_len); |
| 112 | STRUCT_MEMBER(struct flock, pid_t, l_pid); |
| 113 | |
| 114 | TYPE(mode_t); |
| 115 | TYPE(off_t); |
| 116 | TYPE(pid_t); |
| 117 | |
| 118 | FUNCTION(creat, int (*f)(const char*, mode_t)); |
| 119 | FUNCTION(fcntl, int (*f)(int, int, ...)); |
| 120 | FUNCTION(open, int (*f)(const char*, int, ...)); |
| 121 | FUNCTION(openat, int (*f)(int, const char*, int, ...)); |
| 122 | FUNCTION(posix_fadvise, int (*f)(int, off_t, off_t, int)); |
| 123 | FUNCTION(posix_fallocate, int (*f)(int, off_t, off_t)); |
| 124 | } |