summaryrefslogtreecommitdiffstats
path: root/librt/timer_create.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 16:47:01 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 16:47:01 +0000
commit62a21af8006ab04282fdc354c5b4dc765f56d058 (patch)
tree568761d58289238aa14cced3f0010809d4d28c00 /librt/timer_create.c
parentef250238dc1572caf859c2b64652f9cdfb0d9e42 (diff)
downloaduClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.bz2
uClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.xz
BIG BIG commit: all left files merged from trunk [rev 22714]. Currenntly NPTL sh4 port build and work fine. All committed to allow Khem Ray working on a working branch to integrate the ARM nptl port. MIPS nptl port not tested but should still building and working fine. There are some other part non yet merged with trunk (misc/internals and some headers file that need some more work). Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'librt/timer_create.c')
-rw-r--r--librt/timer_create.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/librt/timer_create.c b/librt/timer_create.c
index cbd7bb615..6aca5fffb 100644
--- a/librt/timer_create.c
+++ b/librt/timer_create.c
@@ -19,54 +19,53 @@
#define __NR___syscall_timer_create __NR_timer_create
static inline _syscall3(int, __syscall_timer_create, clockid_t, clock_id,
- struct sigevent *, evp, kernel_timer_t *, ktimerid);
+ struct sigevent *, evp, kernel_timer_t *, ktimerid);
/* Create a per-process timer */
-int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
+int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t * timerid)
{
- int retval;
- kernel_timer_t ktimerid;
- struct sigevent local_evp;
- struct timer *newp;
+ int retval;
+ kernel_timer_t ktimerid;
+ struct sigevent default_evp;
+ struct timer *newp;
- /* Notification via a thread is not supported yet */
- if (__builtin_expect(evp->sigev_notify == SIGEV_THREAD, 1))
- return -1;
+ if (evp == NULL) {
+ /*
+ * The kernel has to pass up the timer ID which is a userlevel object.
+ * Therefore we cannot leave it up to the kernel to determine it.
+ */
+ default_evp.sigev_notify = SIGEV_SIGNAL;
+ default_evp.sigev_signo = SIGALRM;
+ evp = &default_evp;
+ }
- /*
- * We avoid allocating too much memory by basically using
- * struct timer as a derived class with the first two elements
- * being in the superclass. We only need these two elements here.
- */
- newp = (struct timer *) malloc(offsetof(struct timer, thrfunc));
- if (newp == NULL)
- return -1; /* No memory */
+ /* Notification via a thread is not supported yet */
+ if (__builtin_expect(evp->sigev_notify == SIGEV_THREAD, 1))
+ return -1;
- if (evp == NULL) {
/*
- * The kernel has to pass up the timer ID which is a userlevel object.
- * Therefore we cannot leave it up to the kernel to determine it.
+ * We avoid allocating too much memory by basically using
+ * struct timer as a derived class with the first two elements
+ * being in the superclass. We only need these two elements here.
*/
- local_evp.sigev_notify = SIGEV_SIGNAL;
- local_evp.sigev_signo = SIGALRM;
- local_evp.sigev_value.sival_ptr = newp;
+ newp = malloc(offsetof(struct timer, thrfunc));
+ if (newp == NULL)
+ return -1; /* No memory */
+ default_evp.sigev_value.sival_ptr = newp;
- evp = &local_evp;
- }
+ retval = __syscall_timer_create(clock_id, evp, &ktimerid);
+ if (retval != -1) {
+ newp->sigev_notify = evp->sigev_notify;
+ newp->ktimerid = ktimerid;
- retval = __syscall_timer_create(clock_id, evp, &ktimerid);
- if (retval != -1) {
- newp->sigev_notify = (evp != NULL ? evp->sigev_notify : SIGEV_SIGNAL);
- newp->ktimerid = ktimerid;
+ *timerid = (timer_t) newp;
+ } else {
+ /* Cannot allocate the timer, fail */
+ free(newp);
+ retval = -1;
+ }
- *timerid = (timer_t) newp;
- } else {
- /* Cannot allocate the timer, fail */
- free(newp);
- retval = -1;
- }
-
- return retval;
+ return retval;
}
#endif