The friendly Operating System for the Internet of Things
fcntl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Eistec AB
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef DOXYGEN
21 #if defined(CPU_NATIVE) || MODULE_NEWLIB || defined(BOARD_MIPS_MALTA)
22 /* If building on native or newlib we need to use the system header instead */
23 #pragma GCC system_header
24 /* without the GCC pragma above #include_next will trigger a pedantic error */
25 #include_next <fcntl.h>
26 #else
27 #ifndef FCNTL_H_
28 #define FCNTL_H_
29 
30 #include <sys/types.h> /* for mode_t, off_t */
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /* Constants used for the flags in fcntl and open */
37 /* The names of the constants are defined by POSIX but most of these numbers
38  * were chosen somewhat arbitrarily */
39 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
40 #define O_RDONLY 0 /* Read only */
41 #define O_WRONLY 1 /* Write only */
42 #define O_RDWR 2 /* Read+write */
43 #define O_APPEND 0x0008 /* Set append mode */
44 #define O_CREAT 0x0010 /* Create file if it does not exist */
45 #define O_TRUNC 0x0020 /* Truncate flag */
46 #define O_EXCL 0x0040 /* Exclusive use flag */
47 
48 #define F_DUPFD 0 /* Duplicate file descriptor */
49 #define F_GETFD 1 /* Get file descriptor flags */
50 #define F_SETFD 2 /* Set file descriptor flags */
51 #define F_GETFL 3 /* Get file status flags */
52 #define F_SETFL 4 /* Set file status flags */
53 #define F_GETOWN 5 /* Get owner */
54 #define F_SETOWN 6 /* Set owner */
55 #define F_GETLK 7 /* Get record-locking information */
56 #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
57 #define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
58 
59 #define FD_CLOEXEC 1 /* Close the file descriptor upon execution of an exec family function */
60 
61 int creat(const char *, mode_t);
62 int fcntl(int, int, ...);
63 int open(const char *, int, ...);
64 int openat(int, const char *, int, ...);
65 int posix_fadvise(int, off_t, off_t, int);
66 int posix_fallocate(int, off_t, off_t);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* FCNTL_H_ */
73 
74 #endif /* CPU_NATIVE */
75 
76 #endif /* DOXYGEN */
77