[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: 605b18bbbf2cf942e1952c73f482ef0b8c00fd19 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=605b18bbbf2cf942e1952c73f482ef0b8c00fd19 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 8dd28fb..0507786 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -529,3 +529,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: 5d2f6759dec941f23c404d5d8518559f2bad28fd URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5d2f6759dec941f23c404d5d8518559f2bad28fd Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 8dd28fb..0507786 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -529,3 +529,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: 6b0f633498d7429aed8576730fe11badedb3184e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6b0f633498d7429aed8576730fe11badedb3184e Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 8dd28fb..0507786 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -529,3 +529,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: ccf41b7985cccb62fb7cba9cc67ae832fb0e6cae URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ccf41b7985cccb62fb7cba9cc67ae832fb0e6cae Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 51f470f..b7e6271 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -526,3 +526,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: ae7fac3cc87f85b4242f65bedef93ecf004f9a15 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ae7fac3cc87f85b4242f65bedef93ecf004f9a15 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 51f470f..b7e6271 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -526,3 +526,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: c4cf13c420fc86834e7ddd08f21e93de44356df6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c4cf13c420fc86834e7ddd08f21e93de44356df6 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: 16e10e5e9edc2c92159b9b0c2acf8e7c9558f477 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=16e10e5e9edc2c92159b9b0c2acf8e7c9558f477 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index fc9d790..fa7fbcb 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -541,6 +541,12 @@ unsigned int __real_sleep(unsigned int seconds) } __weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} + +__weak int __real___cxa_guard_acquire(__guard *g) { return __cxa_guard_acquire(g); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: b20f4a2dc0b3627c821af18efcbb45ca1e609291 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b20f4a2dc0b3627c821af18efcbb45ca1e609291 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index f8bda39..91bd5ef 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -108,6 +108,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index fc9d790..fa7fbcb 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -541,6 +541,12 @@ unsigned int __real_sleep(unsigned int seconds) } __weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} + +__weak int __real___cxa_guard_acquire(__guard *g) { return __cxa_guard_acquire(g); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: a0981fb6c607eaf59492a596c4b15e7097590508 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a0981fb6c607eaf59492a596c4b15e7097590508 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: bb7cb06bf80aa193d68906f30131b50d4b8f27a7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bb7cb06bf80aa193d68906f30131b50d4b8f27a7 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: 7e4085d689a45433c9133a937cd4bfc9cbb2bfbf URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7e4085d689a45433c9133a937cd4bfc9cbb2bfbf Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-3 Branch: next Commit: cd73d2a1dbab5622028fcee098a4c8461aa34e82 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cd73d2a1dbab5622028fcee098a4c8461aa34e82 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-jki Branch: for-forge Commit: 9396f1c12d31fad018fa90570c78e1ecfc1d9b13 URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=9396f1c12d31fad018fa90570c78e1ecfc1d9b13 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-jki Branch: for-forge Commit: 0c4a68a799988b6dbb16b1cca3fd29a3c8a19575 URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=0c4a68a799988b6dbb16b1cca3fd29a3c8a19575 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-jki Branch: for-forge Commit: 621a3642aab410a7a231d262556e9e89fd86dabf URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=621a3642aab410a7a231d262556e9e89fd86dabf Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-jki Branch: for-forge Commit: 6dc559c3555100482bb19be34e5435db6ce15dba URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=6dc559c3555100482bb19be34e5435db6ce15dba Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep
Module: xenomai-jki Branch: for-forge Commit: ec9a8c81944d4a3e3f50af314fa58ade68dd28c2 URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=ec9a8c81944d4a3e3f50af314fa58ade68dd28c2 Author: Jan KiszkaDate: Mon May 30 14:58:07 2016 +0200 lib/cobalt: Provide RT-capable usleep User may expect this (probably last) sleeping service to be available under Cobalt just like sleep, nanosleep & Co. Signed-off-by: Jan Kiszka --- include/cobalt/unistd.h|2 ++ lib/cobalt/clock.c | 14 ++ lib/cobalt/cobalt.wrappers |1 + lib/cobalt/wrappers.c |6 ++ 4 files changed, 23 insertions(+) diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h index 8ad2b40..fe3992a 100644 --- a/include/cobalt/unistd.h +++ b/include/cobalt/unistd.h @@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes)); COBALT_DECL(unsigned int, sleep(unsigned int seconds)); +COBALT_DECL(int, usleep(useconds_t usec)); + #ifdef __cplusplus } #endif diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c index 0450019..7b4ef54 100644 --- a/lib/cobalt/clock.c +++ b/lib/cobalt/clock.c @@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds)) return 0; } +/* @apitags{thread-unrestricted, switch-primary} */ + +COBALT_IMPL(int, usleep, (useconds_t usec)) +{ + struct timespec rqt; + + if (cobalt_get_current_fast() == XN_NO_HANDLE) + return __STD(usleep(usec)); + + rqt.tv_sec = usec / 100; + rqt.tv_nsec = (usec % 100) * 1000; + return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL)); +} + /* @apitags{unrestricted} */ COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz)) diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 19153ae..bf7a810 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -110,6 +110,7 @@ --wrap sigqueue --wrap kill --wrap sleep +--wrap usleep --wrap mmap --wrap mmap64 --wrap time diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 1f1664e..43ca630 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -538,3 +538,9 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real_usleep(useconds_t usec) +{ + return usleep(usec); +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git