Changeset ca4c6ec1 in mainline


Ignore:
Timestamp:
2012-08-31T10:18:53Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f8cbe2c
Parents:
a3da2b2
Message:

libposix: replace macro with function (open())

Location:
uspace/lib/posix
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/include/posix/fcntl.h

    ra3da2b2 rca4c6ec1  
    7272#define FD_CLOEXEC         1 /* Close on exec. */
    7373
    74 #undef open
    75 #define open(path, ...) \
    76         ({ \
    77                 int rc = open(path, ##__VA_ARGS__); \
    78                 if (rc < 0) { \
    79                         errno = -rc; \
    80                         rc = -1; \
    81                 } \
    82                 rc; \
    83         })
    84 
     74extern int posix_open(const char *pathname, int flags, ...);
    8575extern int posix_fcntl(int fd, int cmd, ...);
    8676
    8777#ifndef LIBPOSIX_INTERNAL
    8878        #define fcntl posix_fcntl
     79        #define open posix_open
    8980#endif
    9081
  • uspace/lib/posix/source/fcntl.c

    ra3da2b2 rca4c6ec1  
    9595}
    9696
     97/**
     98 * Open, possibly create, a file.
     99 *
     100 * @param pathname Path to the file.
     101 * @param flags Access mode flags.
     102 */
     103int posix_open(const char *pathname, int flags, ...)
     104{
     105        mode_t mode = 0;
     106        if ((flags & O_CREAT) > 0) {
     107                va_list args;
     108                va_start(args, flags);
     109                mode = va_arg(args, mode_t);
     110                va_end(args);
     111        }
     112
     113        int rc = open(pathname, flags, mode);
     114        if (rc < 0) {
     115                errno = -rc;
     116                rc = -1;
     117        }
     118
     119        return rc;
     120}
     121
    97122/** @}
    98123 */
Note: See TracChangeset for help on using the changeset viewer.