| 1 | // SPDX-FileCopyrightText: 2015 Michael Jeanson <mjeanson@efficios.com> |
| 2 | // |
| 3 | // SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 | |
| 5 | #ifndef _COMPAT_GETCPU_H |
| 6 | #define _COMPAT_GETCPU_H |
| 7 | |
| 8 | #if defined(HAVE_SCHED_GETCPU) |
| 9 | #include <sched.h> |
| 10 | |
| 11 | static inline |
| 12 | int urcu_sched_getcpu(void) |
| 13 | { |
| 14 | return sched_getcpu(); |
| 15 | } |
| 16 | #elif defined(HAVE_GETCPUID) |
| 17 | #include <sys/processor.h> |
| 18 | |
| 19 | static inline |
| 20 | int urcu_sched_getcpu(void) |
| 21 | { |
| 22 | return (int) getcpuid(); |
| 23 | } |
| 24 | #else |
| 25 | |
| 26 | static inline |
| 27 | int urcu_sched_getcpu(void) |
| 28 | { |
| 29 | return -1; |
| 30 | } |
| 31 | #endif |
| 32 | |
| 33 | #endif /* _COMPAT_GETCPU_H */ |