|
@@ -19,54 +19,54 @@
|
|
|
|
|
|
#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);
|
|
|
|
|
|
|
|
|
-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 local_evp;
|
|
|
+ struct timer *newp;
|
|
|
|
|
|
-
|
|
|
- if (__builtin_expect(evp->sigev_notify == SIGEV_THREAD, 1))
|
|
|
- return -1;
|
|
|
+
|
|
|
+ if (__builtin_expect(evp->sigev_notify == SIGEV_THREAD, 1))
|
|
|
+ return -1;
|
|
|
|
|
|
-
|
|
|
- * 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;
|
|
|
-
|
|
|
- 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 = (struct timer *)malloc(offsetof(struct timer, thrfunc));
|
|
|
+ if (newp == NULL)
|
|
|
+ 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.
|
|
|
+ */
|
|
|
+ local_evp.sigev_notify = SIGEV_SIGNAL;
|
|
|
+ local_evp.sigev_signo = SIGALRM;
|
|
|
+ local_evp.sigev_value.sival_ptr = newp;
|
|
|
|
|
|
- evp = &local_evp;
|
|
|
- }
|
|
|
+ evp = &local_evp;
|
|
|
+ }
|
|
|
|
|
|
- retval = __syscall_timer_create(clock_id, evp, &ktimerid);
|
|
|
- if (retval != -1) {
|
|
|
- newp->sigev_notify = (evp != NULL ? evp->sigev_notify : SIGEV_SIGNAL);
|
|
|
- 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 {
|
|
|
-
|
|
|
- free(newp);
|
|
|
- retval = -1;
|
|
|
- }
|
|
|
+ *timerid = (timer_t) newp;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ free(newp);
|
|
|
+ retval = -1;
|
|
|
+ }
|
|
|
|
|
|
- return retval;
|
|
|
+ return retval;
|
|
|
}
|
|
|
|
|
|
#endif
|