linux_time.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* $OpenBSD: linux_time.h,v 1.4 2013/10/25 04:51:39 guenther Exp $ */
  2. /*
  3. * Copyright (c) 2011 Paul Irofti <pirofti@openbsd.org>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef _LINUX_TIME_H_
  18. #define _LINUX_TIME_H_
  19. /* BSD to linux can fail with EOVERFLOW */
  20. int bsd_to_linux_timespec(struct linux_timespec *,
  21. const struct timespec *);
  22. int bsd_to_linux_itimerval(struct linux_itimerval *,
  23. const struct itimerval *);
  24. /* linux to BSD can't fail for time_t-based stuff, but can for clockid_t */
  25. void linux_to_bsd_timespec(struct timespec *,
  26. const struct linux_timespec *);
  27. void linux_to_bsd_itimerval(struct itimerval *,
  28. const struct linux_itimerval *);
  29. int linux_to_bsd_clockid(clockid_t *, clockid_t);
  30. /* the timespec conversion functions also handle timeval */
  31. static inline int
  32. bsd_to_linux_timeval(struct linux_timeval *ltp, const struct timeval *ntp)
  33. {
  34. return (bsd_to_linux_timespec((void *)ltp, (const void *)ntp));
  35. }
  36. static inline void
  37. linux_to_bsd_timeval(struct timeval *ntp, const struct linux_timeval *ltp)
  38. {
  39. linux_to_bsd_timespec((void *)ntp, (const void *)ltp);
  40. }
  41. #endif