Commit | Line | Data |
---|---|---|
ebac4655 JA |
1 | #ifndef ARCH_S390_H |
2 | #define ARCH_S390_H | |
3 | ||
4 | #define ARCH (arch_s390) | |
5 | ||
6 | #ifndef __NR_ioprio_set | |
7 | #define __NR_ioprio_set 282 | |
8 | #define __NR_ioprio_get 283 | |
9 | #endif | |
10 | ||
11 | #ifndef __NR_fadvise64 | |
12 | #define __NR_fadvise64 253 | |
13 | #endif | |
14 | ||
9a9c63f1 JA |
15 | #ifndef __NR_sys_splice |
16 | #define __NR_sys_splice 306 | |
17 | #define __NR_sys_tee 308 | |
18 | #define __NR_sys_vmsplice 309 | |
19 | #endif | |
20 | ||
b12ebc65 | 21 | #define nop asm volatile ("diag 0,0,68" : : : "memory") |
db6defc7 | 22 | #define read_barrier() asm volatile("bcr 15,0" : : : "memory") |
44c47feb | 23 | #define write_barrier() asm volatile("bcr 15,0" : : : "memory") |
ebac4655 | 24 | |
69ebbd39 JA |
25 | typedef struct { |
26 | volatile unsigned int lock; | |
27 | } spinlock_t; | |
28 | ||
29 | static inline int | |
30 | _raw_compare_and_swap(volatile unsigned int *lock, | |
31 | unsigned int old, unsigned int new) | |
32 | { | |
33 | __asm__ __volatile__( | |
34 | " cs %0,%3,0(%4)" | |
35 | : "=d" (old), "=m" (*lock) | |
36 | : "0" (old), "d" (new), "a" (lock), "m" (*lock) | |
37 | : "cc", "memory" ); | |
38 | ||
39 | return old; | |
40 | } | |
41 | ||
42 | static inline void spin_lock(spinlock_t *lock) | |
43 | { | |
44 | if (!_raw_compare_and_swap(&lock->lock, 0, 0x80000000)) | |
45 | return; | |
46 | ||
47 | while (1) { | |
48 | if (lock->lock) | |
49 | continue; | |
50 | if (!_raw_compare_and_swap(&lock->lock, 0, 0x80000000)) | |
51 | break; | |
52 | } | |
53 | } | |
54 | ||
55 | static inline void spin_unlock(spinlock_t *lock) | |
56 | { | |
57 | _raw_compare_and_swap(&lock->lock, 0x80000000, 0); | |
58 | } | |
59 | ||
ebac4655 | 60 | #endif |