From 30ccac4b4397871b553b7cb5ef6c4ee5334664e9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 4 Oct 2014 06:44:57 -0600 Subject: Implement creat() as a macro --- nuttx/include/fcntl.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'nuttx/include') diff --git a/nuttx/include/fcntl.h b/nuttx/include/fcntl.h index 381cf5cad..7671c0aca 100644 --- a/nuttx/include/fcntl.h +++ b/nuttx/include/fcntl.h @@ -128,6 +128,13 @@ #define DN_RENAME 4 /* A file was renamed */ #define DN_ATTRIB 5 /* Attributes of a file were changed */ +/* int creat(const char *path, mode_t mode); + * + * is equivalent to open with O_WRONLY|O_CREAT|O_TRUNC. + */ + +#define creat(path, mode) open(path, O_WRONLY|O_CREAT|O_TRUNC, mode) + /******************************************************************************** * Public Type Definitions ********************************************************************************/ @@ -143,10 +150,6 @@ struct flock pid_t l_pid; /* PID of process blocking our lock (F_GETLK only) */ }; -/******************************************************************************** - * Public Variables - ********************************************************************************/ - /******************************************************************************** * Public Function Prototypes ********************************************************************************/ @@ -154,16 +157,20 @@ struct flock #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #endif +/******************************************************************************** + * Public Data + ********************************************************************************/ + /* POSIX-like File System Interfaces */ -EXTERN int creat(const char *path, mode_t mode); -EXTERN int open(const char *path, int oflag, ...); -EXTERN int fcntl(int fd, int cmd, ...); +int open(const char *path, int oflag, ...); +int fcntl(int fd, int cmd, ...); #undef EXTERN #if defined(__cplusplus) -- cgit v1.2.3