Module: xenomai-2.6 Branch: master Commit: d6127b245ed9876ce4153bac2996d88d0d7355c6 URL: http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=d6127b245ed9876ce4153bac2996d88d0d7355c6
Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org> Date: Mon Jul 29 00:01:18 2013 +0200 posix: wrap open64 --- configure | 2 +- configure.in | 2 +- include/posix/fcntl.h | 2 + src/include/xeno_config.h.in | 3 ++ src/skins/posix/posix.wrappers | 1 + src/skins/posix/rtdm.c | 42 ++++++++++++++++++++++++++++++++++++++- src/skins/posix/wrappers.c | 17 ++++++++++++++++ 7 files changed, 65 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 29e82c5..0c8dd57 100755 --- a/configure +++ b/configure @@ -12527,7 +12527,7 @@ done save_LIBS="$LIBS" LIBS="$LIBS -lrt -lpthread" -for ac_func in shm_open shm_unlink mmap64 ftruncate64 pthread_mutexattr_setprotocol pthread_condattr_setclock pthread_spin_lock fork +for ac_func in shm_open shm_unlink open64 mmap64 ftruncate64 pthread_mutexattr_setprotocol pthread_condattr_setclock pthread_spin_lock fork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.in b/configure.in index edfc3cc..b6a1ac7 100644 --- a/configure.in +++ b/configure.in @@ -392,7 +392,7 @@ AC_CHECK_HEADERS(mqueue.h) dnl Check for presence of some routines we need save_LIBS="$LIBS" LIBS="$LIBS -lrt -lpthread" -AC_CHECK_FUNCS([shm_open shm_unlink mmap64 ftruncate64 pthread_mutexattr_setprotocol pthread_condattr_setclock pthread_spin_lock fork]) +AC_CHECK_FUNCS([shm_open shm_unlink open64 mmap64 ftruncate64 pthread_mutexattr_setprotocol pthread_condattr_setclock pthread_spin_lock fork]) LIBS="$save_LIBS" dnl diff --git a/include/posix/fcntl.h b/include/posix/fcntl.h index 88a4d82..bfa17f0 100644 --- a/include/posix/fcntl.h +++ b/include/posix/fcntl.h @@ -50,6 +50,8 @@ extern "C" { int __real_open(const char *path, int oflag, ...); +int __real_open64(const char *path, int oflag, ...); + #ifdef __cplusplus } #endif diff --git a/src/include/xeno_config.h.in b/src/include/xeno_config.h.in index b392915..7391132 100644 --- a/src/include/xeno_config.h.in +++ b/src/include/xeno_config.h.in @@ -86,6 +86,9 @@ /* config */ #undef HAVE_OLD_SETAFFINITY +/* Define to 1 if you have the `open64' function. */ +#undef HAVE_OPEN64 + /* Define to 1 if you have the `pthread_condattr_setclock' function. */ #undef HAVE_PTHREAD_CONDATTR_SETCLOCK diff --git a/src/skins/posix/posix.wrappers b/src/skins/posix/posix.wrappers index fbec984..db73a14 100644 --- a/src/skins/posix/posix.wrappers +++ b/src/skins/posix/posix.wrappers @@ -56,6 +56,7 @@ --wrap mq_timedreceive --wrap mq_notify --wrap open +--wrap open64 --wrap socket --wrap close --wrap ioctl diff --git a/src/skins/posix/rtdm.c b/src/skins/posix/rtdm.c index 919aa40..5840c64 100644 --- a/src/skins/posix/rtdm.c +++ b/src/skins/posix/rtdm.c @@ -39,10 +39,10 @@ static inline int set_errno(int ret) return -1; } -int __wrap_open(const char *path, int oflag, ...) +static int sys_rtdm_open(const char *path, int oflag) { - int ret, oldtype; const char *rtdm_path = path; + int ret, oldtype; pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); @@ -56,6 +56,15 @@ int __wrap_open(const char *path, int oflag, ...) if (ret >= 0) ret += __pse51_rtdm_fd_start; + + return ret; +} + +int __wrap_open(const char *path, int oflag, ...) +{ + int ret = sys_rtdm_open(path, oflag); + if (ret >= 0) + return ret; else if (ret == -ENODEV || ret == -ENOSYS) { va_list ap; @@ -78,6 +87,35 @@ int __wrap_open(const char *path, int oflag, ...) return ret; } +int __wrap_open64(const char *path, int oflag, ...) +{ + int ret = sys_rtdm_open(path, oflag); + if (ret >= 0) + return ret; +#ifdef HAVE_OPEN64 + else if (ret == -ENODEV || ret == -ENOSYS) { + va_list ap; + + va_start(ap, oflag); + + ret = __real_open64(path, oflag, va_arg(ap, mode_t)); + + va_end(ap); + + if (ret >= __pse51_rtdm_fd_start) { + __real_close(ret); + errno = EMFILE; + ret = -1; + } +#endif + } else { + errno = -ret; + ret = -1; + } + + return ret; +} + int __wrap_socket(int protocol_family, int socket_type, int protocol) { int ret; diff --git a/src/skins/posix/wrappers.c b/src/skins/posix/wrappers.c index 549e934..3744eb7 100644 --- a/src/skins/posix/wrappers.c +++ b/src/skins/posix/wrappers.c @@ -118,6 +118,23 @@ int __real_open(const char *path, int oflag, ...) return open(path, oflag); } +#ifdef HAVE_OPEN64 +__attribute__ ((weak)) +int __real_open64(const char *path, int oflag, ...) +{ + va_list ap; + mode_t mode; + + if (oflag & O_CREAT) { + va_start(ap, oflag); + mode = va_arg(ap, mode_t); + va_end(ap); + return open64(path, oflag, mode); + } else + return open64(path, oflag); +} +#endif + __attribute__ ((weak)) int __real_socket(int protocol_family, int socket_type, int protocol) { _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git