timer_delete.c 635 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * timer_delete.c - delete a per-process timer.
  3. */
  4. #include <errno.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include <sys/syscall.h>
  8. #include "kernel-posix-timers.h"
  9. #ifdef __NR_timer_delete
  10. #define __NR___syscall_timer_delete __NR_timer_delete
  11. static __inline__ _syscall1(int, __syscall_timer_delete, kernel_timer_t, ktimerid);
  12. /* Delete a per-process timer */
  13. int timer_delete(timer_t timerid)
  14. {
  15. int res;
  16. struct timer *kt = (struct timer *)timerid;
  17. /* Delete the kernel timer object */
  18. res = __syscall_timer_delete(kt->ktimerid);
  19. if (res == 0) {
  20. free(kt); /* Free the memory */
  21. return 0;
  22. }
  23. return -1;
  24. }
  25. #endif