Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: fusl/include/sched.h

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef _SCHED_H 1 #ifndef _SCHED_H
2 #define _SCHED_H 2 #define _SCHED_H
3 #ifdef __cplusplus 3 #ifdef __cplusplus
4 extern "C" { 4 extern "C" {
5 #endif 5 #endif
6 6
7 #include <features.h> 7 #include <features.h>
8 8
9 #define __NEED_struct_timespec 9 #define __NEED_struct_timespec
10 #define __NEED_pid_t 10 #define __NEED_pid_t
11 #define __NEED_time_t 11 #define __NEED_time_t
12 12
13 #ifdef _GNU_SOURCE 13 #ifdef _GNU_SOURCE
14 #define __NEED_size_t 14 #define __NEED_size_t
15 #endif 15 #endif
16 16
17 #include <bits/alltypes.h> 17 #include <bits/alltypes.h>
18 18
19 struct sched_param { 19 struct sched_param {
20 » int sched_priority; 20 int sched_priority;
21 » int sched_ss_low_priority; 21 int sched_ss_low_priority;
22 » struct timespec sched_ss_repl_period; 22 struct timespec sched_ss_repl_period;
23 » struct timespec sched_ss_init_budget; 23 struct timespec sched_ss_init_budget;
24 » int sched_ss_max_repl; 24 int sched_ss_max_repl;
25 }; 25 };
26 26
27 int sched_get_priority_max(int); 27 int sched_get_priority_max(int);
28 int sched_get_priority_min(int); 28 int sched_get_priority_min(int);
29 int sched_getparam(pid_t, struct sched_param *); 29 int sched_getparam(pid_t, struct sched_param*);
30 int sched_getscheduler(pid_t); 30 int sched_getscheduler(pid_t);
31 int sched_rr_get_interval(pid_t, struct timespec *); 31 int sched_rr_get_interval(pid_t, struct timespec*);
32 int sched_setparam(pid_t, const struct sched_param *); 32 int sched_setparam(pid_t, const struct sched_param*);
33 int sched_setscheduler(pid_t, int, const struct sched_param *); 33 int sched_setscheduler(pid_t, int, const struct sched_param*);
34 int sched_yield(void); 34 int sched_yield(void);
35 35
36 #define SCHED_OTHER 0 36 #define SCHED_OTHER 0
37 #define SCHED_FIFO 1 37 #define SCHED_FIFO 1
38 #define SCHED_RR 2 38 #define SCHED_RR 2
39 #define SCHED_BATCH 3 39 #define SCHED_BATCH 3
40 #define SCHED_IDLE 5 40 #define SCHED_IDLE 5
41 #define SCHED_DEADLINE 6 41 #define SCHED_DEADLINE 6
42 #define SCHED_RESET_ON_FORK 0x40000000 42 #define SCHED_RESET_ON_FORK 0x40000000
43 43
44 #ifdef _GNU_SOURCE 44 #ifdef _GNU_SOURCE
45 #define CSIGNAL»» 0x000000ff 45 #define CSIGNAL 0x000000ff
46 #define CLONE_VM» 0x00000100 46 #define CLONE_VM 0x00000100
47 #define CLONE_FS» 0x00000200 47 #define CLONE_FS 0x00000200
48 #define CLONE_FILES» 0x00000400 48 #define CLONE_FILES 0x00000400
49 #define CLONE_SIGHAND» 0x00000800 49 #define CLONE_SIGHAND 0x00000800
50 #define CLONE_PTRACE» 0x00002000 50 #define CLONE_PTRACE 0x00002000
51 #define CLONE_VFORK» 0x00004000 51 #define CLONE_VFORK 0x00004000
52 #define CLONE_PARENT» 0x00008000 52 #define CLONE_PARENT 0x00008000
53 #define CLONE_THREAD» 0x00010000 53 #define CLONE_THREAD 0x00010000
54 #define CLONE_NEWNS» 0x00020000 54 #define CLONE_NEWNS 0x00020000
55 #define CLONE_SYSVSEM» 0x00040000 55 #define CLONE_SYSVSEM 0x00040000
56 #define CLONE_SETTLS» 0x00080000 56 #define CLONE_SETTLS 0x00080000
57 #define CLONE_PARENT_SETTID» 0x00100000 57 #define CLONE_PARENT_SETTID 0x00100000
58 #define CLONE_CHILD_CLEARTID» 0x00200000 58 #define CLONE_CHILD_CLEARTID 0x00200000
59 #define CLONE_DETACHED» 0x00400000 59 #define CLONE_DETACHED 0x00400000
60 #define CLONE_UNTRACED» 0x00800000 60 #define CLONE_UNTRACED 0x00800000
61 #define CLONE_CHILD_SETTID» 0x01000000 61 #define CLONE_CHILD_SETTID 0x01000000
62 #define CLONE_NEWUTS» 0x04000000 62 #define CLONE_NEWUTS 0x04000000
63 #define CLONE_NEWIPC» 0x08000000 63 #define CLONE_NEWIPC 0x08000000
64 #define CLONE_NEWUSER» 0x10000000 64 #define CLONE_NEWUSER 0x10000000
65 #define CLONE_NEWPID» 0x20000000 65 #define CLONE_NEWPID 0x20000000
66 #define CLONE_NEWNET» 0x40000000 66 #define CLONE_NEWNET 0x40000000
67 #define CLONE_IO» 0x80000000 67 #define CLONE_IO 0x80000000
68 int clone (int (*)(void *), void *, int, void *, ...); 68 int clone(int (*)(void*), void*, int, void*, ...);
69 int unshare(int); 69 int unshare(int);
70 int setns(int, int); 70 int setns(int, int);
71 71
72 void *memcpy(void *__restrict, const void *__restrict, size_t); 72 void* memcpy(void* __restrict, const void* __restrict, size_t);
73 int memcmp(const void *, const void *, size_t); 73 int memcmp(const void*, const void*, size_t);
74 void *calloc(size_t, size_t); 74 void* calloc(size_t, size_t);
75 void free(void *); 75 void free(void*);
76 76
77 typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t; 77 typedef struct cpu_set_t {
78 int __sched_cpucount(size_t, const cpu_set_t *); 78 unsigned long __bits[128 / sizeof(long)];
79 int sched_getaffinity(pid_t, size_t, cpu_set_t *); 79 } cpu_set_t;
80 int sched_setaffinity(pid_t, size_t, const cpu_set_t *); 80 int __sched_cpucount(size_t, const cpu_set_t*);
81 int sched_getaffinity(pid_t, size_t, cpu_set_t*);
82 int sched_setaffinity(pid_t, size_t, const cpu_set_t*);
81 83
82 #define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \ 84 #define __CPU_op_S(i, size, set, op) \
83 » ((set)->__bits[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) ) 85 ((i) / 8U >= (size) ? 0 : ((set)->__bits[(i) / 8 / sizeof(long)] op( \
86 1UL << ((i) % (8 * sizeof(long))))))
84 87
85 #define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=) 88 #define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
86 #define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~) 89 #define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &= ~)
87 #define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &) 90 #define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
88 91
89 #define __CPU_op_func_S(func, op) \ 92 #define __CPU_op_func_S(func, op) \
90 static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \ 93 static __inline void __CPU_##func##_S(size_t __size, cpu_set_t* __dest, \
91 » const cpu_set_t *__src1, const cpu_set_t *__src2) \ 94 const cpu_set_t* __src1, \
92 { \ 95 const cpu_set_t* __src2) { \
93 » size_t __i; \ 96 size_t __i; \
94 » for (__i=0; __i<__size/sizeof(long); __i++) \ 97 for (__i = 0; __i < __size / sizeof(long); __i++) \
95 » » __dest->__bits[__i] = __src1->__bits[__i] \ 98 __dest->__bits[__i] = __src1->__bits[__i] op __src2->__bits[__i]; \
96 » » » op __src2->__bits[__i] ; \ 99 }
97 }
98 100
99 __CPU_op_func_S(AND, &) 101 __CPU_op_func_S(AND, &) __CPU_op_func_S(OR, |) __CPU_op_func_S(XOR, ^)
100 __CPU_op_func_S(OR, |)
101 __CPU_op_func_S(XOR, ^)
102 102
103 #define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d) 103 #define CPU_AND_S(a, b, c, d) __CPU_AND_S(a, b, c, d)
104 #define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d) 104 #define CPU_OR_S(a, b, c, d) __CPU_OR_S(a, b, c, d)
105 #define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d) 105 #define CPU_XOR_S(a, b, c, d) __CPU_XOR_S(a, b, c, d)
106 106
107 #define CPU_COUNT_S(size,set) __sched_cpucount(size,set) 107 #define CPU_COUNT_S(size, set) __sched_cpucount(size, set)
108 #define CPU_ZERO_S(size,set) memset(set,0,size) 108 #define CPU_ZERO_S(size, set) memset(set, 0, size)
109 #define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size)) 109 #define CPU_EQUAL_S(size, set1, set2) (!memcmp(set1, set2, size))
110 110
111 #define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \ 111 #define CPU_ALLOC_SIZE(n) \
112 » + ((n)%(8*sizeof(long)) + 8*sizeof(long)-1)/(8*sizeof(long)) ) ) 112 (sizeof(long) * \
113 #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) 113 ((n) / (8 * sizeof(long)) + \
114 ((n) % (8 * sizeof(long)) + 8 * sizeof(long) - 1) / (8 * sizeof(long))))
115 #define CPU_ALLOC(n) ((cpu_set_t*)calloc(1, CPU_ALLOC_SIZE(n)))
114 #define CPU_FREE(set) free(set) 116 #define CPU_FREE(set) free(set)
115 117
116 #define CPU_SETSIZE 128 118 #define CPU_SETSIZE 128
117 119
118 #define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set) 120 #define CPU_SET(i, set) CPU_SET_S(i, sizeof(cpu_set_t), set)
119 #define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set) 121 #define CPU_CLR(i, set) CPU_CLR_S(i, sizeof(cpu_set_t), set)
120 #define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set) 122 #define CPU_ISSET(i, set) CPU_ISSET_S(i, sizeof(cpu_set_t), set)
121 #define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2) 123 #define CPU_AND(d, s1, s2) CPU_AND_S(sizeof(cpu_set_t), d, s1, s2)
122 #define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2) 124 #define CPU_OR(d, s1, s2) CPU_OR_S(sizeof(cpu_set_t), d, s1, s2)
123 #define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2) 125 #define CPU_XOR(d, s1, s2) CPU_XOR_S(sizeof(cpu_set_t), d, s1, s2)
124 #define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set) 126 #define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t), set)
125 #define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) 127 #define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t), set)
126 #define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2) 128 #define CPU_EQUAL(s1, s2) CPU_EQUAL_S(sizeof(cpu_set_t), s1, s2)
127 129
128 #endif 130 #endif
129 131
130 #ifdef __cplusplus 132 #ifdef __cplusplus
131 } 133 }
132 #endif 134 #endif
133 #endif 135 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698