blob: b783beff4f8b7186d72925a0f03070df3fd2ba55 (
plain) (
blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
* File: common_timers.h
*
* Keep all the common defines/checks for the timer tests here
*/
#ifndef __COMMON_TIMERS_H__
#define __COMMON_TIMERS_H__
#include "config.h"
#include "lapi/syscalls.h"
#include "lapi/posix_clocks.h"
#ifndef NSEC_PER_SEC
#define NSEC_PER_SEC (1000000000L)
#endif
static const clock_t clock_list[] = {
CLOCK_REALTIME,
CLOCK_MONOTONIC,
CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID,
CLOCK_BOOTTIME,
CLOCK_BOOTTIME_ALARM,
CLOCK_REALTIME_ALARM,
CLOCK_TAI,
};
/* CLOCKS_DEFINED is the number of clock sources defined for sure */
#define CLOCKS_DEFINED (sizeof(clock_list) / sizeof(*clock_list))
/* MAX_CLOCKS is the maximum number of clock sources supported by kernel */
#define MAX_CLOCKS 16
#define CLOCK_TO_STR(def_name) \
case def_name: \
return #def_name;
static inline const char *get_clock_str(const int clock_id)
{
switch (clock_id) {
CLOCK_TO_STR(CLOCK_REALTIME);
CLOCK_TO_STR(CLOCK_MONOTONIC);
CLOCK_TO_STR(CLOCK_PROCESS_CPUTIME_ID);
CLOCK_TO_STR(CLOCK_THREAD_CPUTIME_ID);
CLOCK_TO_STR(CLOCK_BOOTTIME);
CLOCK_TO_STR(CLOCK_BOOTTIME_ALARM);
CLOCK_TO_STR(CLOCK_REALTIME_ALARM);
CLOCK_TO_STR(CLOCK_TAI);
default:
return "CLOCK_!?!?!?";
}
}
static inline int possibly_unsupported(clock_t clock)
{
switch (clock) {
case CLOCK_BOOTTIME:
case CLOCK_BOOTTIME_ALARM:
case CLOCK_REALTIME_ALARM:
case CLOCK_TAI:
return 1;
default:
return 0;
}
}
static inline int have_cputime_timers(void)
{
return tst_kvercmp(2, 6, 12) >= 0;
}
#include "lapi/syscalls.h"
#include <time.h>
#include <unistd.h>
/* timer_t in kernel(int) is different from Glibc definition(void*).
* Use the kernel definition for syscall tests
*/
typedef int kernel_timer_t;
#endif
|