blob: 20a5ad62509b8f5f98a4ad6cffe3c5f72983785f (
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
82
83
84
85
86
87
88
89
90
91
92
|
//============================================================
//
// osinline.h - GNU C inline functions
//
//============================================================
#ifndef __OSINLINE__
#define __OSINLINE__
#include "eminline.h"
//============================================================
// INLINE FUNCTIONS
//============================================================
#if defined(__i386__) || defined(__x86_64__)
INLINE void ATTR_FORCE_INLINE
osd_yield_processor(void)
{
__asm__ __volatile__ ( " rep ; nop ;" );
}
#if defined(__x86_64__)
//============================================================
// osd_exchange64
//============================================================
INLINE INT64 ATTR_UNUSED ATTR_NONNULL(1) ATTR_FORCE_INLINE
_osd_exchange64(INT64 volatile *ptr, INT64 exchange)
{
register INT64 ret;
__asm__ __volatile__ (
" lock ; xchg %[exchange], %[ptr] ;"
: [ptr] "+m" (*ptr)
, [ret] "=r" (ret)
: [exchange] "1" (exchange)
);
return ret;
}
#define osd_exchange64 _osd_exchange64
#endif /* __x86_64__ */
#elif defined(__ppc__) || defined (__PPC__) || defined(__ppc64__) || defined(__PPC64__)
INLINE void ATTR_FORCE_INLINE
osd_yield_processor(void)
{
__asm__ __volatile__ ( " nop \n nop \n" );
}
#if defined(__ppc64__) || defined(__PPC64__)
//============================================================
// osd_exchange64
//============================================================
INLINE INT64 ATTR_UNUSED ATTR_NONNULL(1) ATTR_FORCE_INLINE
_osd_exchange64(INT64 volatile *ptr, INT64 exchange)
{
register INT64 ret;
__asm__ __volatile__ (
"1: ldarx %[ret], 0, %[ptr] \n"
" stdcx. %[exchange], 0, %[ptr] \n"
" bne- 1b \n"
: [ret] "=&r" (ret)
: [ptr] "r" (ptr)
, [exchange] "r" (exchange)
: "cr0"
);
return ret;
}
#define osd_exchange64 _osd_exchange64
#endif /* __ppc64__ || __PPC64__ */
#else
#error "no matching assembler implementations found - please compile with NOASM=1"
#endif
#endif /* __OSINLINE__ */
|