timer_routines.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Helper code for POSIX timer implementation on NPTL.
  2. Copyright (C) 2000-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If
  14. not, see <https://www.gnu.org/licenses/>. */
  15. #ifndef _TIMER_ROUTINES_H
  16. #define _TIMER_ROUTINES_H 1
  17. #include <internaltypes.h>
  18. #include <string.h>
  19. /* Compare two pthread_attr_t thread attributes for exact equality.
  20. Returns 1 if they are equal, otherwise zero if they are not equal
  21. or contain illegal values. This version is NPTL-specific for
  22. performance reason. One could use the access functions to get the
  23. values of all the fields of the attribute structure. */
  24. static inline int
  25. thread_attr_compare (const pthread_attr_t *left, const pthread_attr_t *right)
  26. {
  27. struct pthread_attr *ileft = (struct pthread_attr *) left;
  28. struct pthread_attr *iright = (struct pthread_attr *) right;
  29. return (ileft->flags == iright->flags
  30. && ileft->schedpolicy == iright->schedpolicy
  31. && (ileft->schedparam.sched_priority
  32. == iright->schedparam.sched_priority)
  33. && ileft->guardsize == iright->guardsize
  34. && ileft->stackaddr == iright->stackaddr
  35. && ileft->stacksize == iright->stacksize
  36. && ((ileft->cpuset == NULL && iright->cpuset == NULL)
  37. || (ileft->cpuset != NULL && iright->cpuset != NULL
  38. && ileft->cpusetsize == iright->cpusetsize
  39. && memcmp (ileft->cpuset, iright->cpuset,
  40. ileft->cpusetsize) == 0)));
  41. }
  42. #endif /* timer_routines.h */