fcntl.h (2226B)
1 /* -*-comment-start: "//";comment-end:""-*- 2 * GNU Mes --- Maxwell Equations of Software 3 * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> 4 * Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com> 5 * Copyright © 2023 Emily Trau <emily@downunderctf.com> 6 * 7 * This file is part of GNU Mes. 8 * 9 * GNU Mes is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 3 of the License, or (at 12 * your option) any later version. 13 * 14 * GNU Mes is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 #ifndef __MES_FCNTL_H 23 #define __MES_FCNTL_H 1 24 25 #if SYSTEM_LIBC 26 #ifndef _GNU_SOURCE 27 #define _GNU_SOURCE 28 #endif 29 #undef __MES_FCNTL_H 30 #include_next <fcntl.h> 31 32 #else // ! SYSTEM_LIBC 33 34 // *INDENT-OFF* 35 #if __linux__ 36 #define O_RDONLY 0 37 #define O_WRONLY 1 38 #define O_RDWR 2 39 #define O_CREAT 0x40 40 #define O_EXCL 0x80 41 #define O_TRUNC 0x200 42 #define O_APPEND 0x400 43 44 #ifdef __arm__ 45 #define O_DIRECTORY 0x4000 46 #define O_TMPFILE 0x404000 47 #else 48 #define O_DIRECTORY 0x10000 49 #define O_TMPFILE 0x410000 50 #endif 51 52 #define AT_FDCWD -100 53 #define AT_SYMLINK_NOFOLLOW 0x100 54 #define AT_REMOVEDIR 0x200 55 56 #elif __GNU__ 57 #define O_RDONLY 1 58 #define O_WRONLY 2 59 #define O_RDWR 3 60 #define O_CREAT 0x10 61 #define O_APPEND 0x100 62 #define O_TRUNC 0x10000 63 #else 64 #error platform not supported 65 #endif 66 // *INDENT-ON* 67 68 #define FD_CLOEXEC 1 69 70 #define F_DUPFD 0 71 #define F_GETFD 1 72 #define F_SETFD 2 73 #define F_GETFL 3 74 #define F_SETFL 4 75 76 #define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode) 77 int dup (int old); 78 int dup2 (int old, int new); 79 80 #if !__M2__ 81 int fcntl (int filedes, int command, ...); 82 int open (char const *s, int flags, ...); 83 #endif 84 85 #endif // ! SYSTEM_LIBC 86 87 #endif // __MES_FCNTL_H