File: rt-get_cpu.h

package info (click to toggle)
rt-tests 1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 708 kB
  • ctags: 1,268
  • sloc: ansic: 8,836; python: 480; makefile: 183
file content (29 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef __RT_GET_CPU_H
#define __RT_GET_CPU_H
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>   /* For SYS_xxx definitions */
#include <sched.h>
#include <dlfcn.h>
#ifdef __NR_getcpu
static inline int get_cpu_setup(void) { return 0; }
static inline int get_cpu(void)
{
        int c,s;
	/* Show the source of get_cpu */
#ifdef DEBUG
	fprintf(stderr, "__NR_getcpu\n");
#endif
        s = syscall(__NR_getcpu, &c, NULL, NULL);
        return (s == -1) ? s : c;
}
#else
#include <utmpx.h>
static inline int get_cpu_setup(void) { return 0; }
static inline int get_cpu(void) { return sched_getcpu(); }
#endif

#endif	/* __RT_GET_CPU_H */