trunk/src/osd/modules/sync/work_osd.c
| r242747 | r242748 | |
| 76 | 76 | #define end_timing(v) do { } while (0) |
| 77 | 77 | #endif |
| 78 | 78 | |
| 79 | | // TODO: move this in a common place |
| 80 | | #if defined(OSD_WINDOWS) |
| 81 | | #if __GNUC__ && defined(__i386__) && !defined(__x86_64) |
| 82 | | #undef YieldProcessor |
| 83 | | #endif |
| 84 | | |
| 85 | | #ifndef YieldProcessor |
| 86 | | #ifdef __GNUC__ |
| 87 | | INLINE void osd_yield_processor(void) |
| 88 | | { |
| 89 | | __asm__ __volatile__ ( "rep; nop" ); |
| 90 | | } |
| 91 | | #else |
| 92 | | INLINE void osd_yield_processor(void) |
| 93 | | { |
| 94 | | __asm { rep nop } |
| 95 | | } |
| 96 | | #endif |
| 97 | | #else |
| 98 | | #define osd_yield_processor YieldProcessor |
| 99 | | #endif |
| 100 | | #endif |
| 101 | | |
| 102 | 79 | template<typename _PtrType> |
| 103 | 80 | static void spin_while(const volatile _PtrType * volatile ptr, const _PtrType val, const osd_ticks_t timeout, const int invert = 0) |
| 104 | 81 | { |
| 105 | 82 | osd_ticks_t stopspin = osd_ticks() + timeout; |
| 106 | 83 | |
| 107 | | #if defined(OSD_WINDOWS) |
| 108 | | while (((*ptr == val) ^ invert) && osd_ticks() < stopspin) |
| 109 | | osd_yield_processor(); |
| 110 | | #else |
| 111 | 84 | do { |
| 112 | 85 | int spin = 10000; |
| 113 | 86 | while (--spin) |
| 114 | 87 | { |
| 115 | | //osd_yield_processor(); |
| 116 | 88 | if ((*ptr == val) ^ invert) |
| 117 | 89 | return; |
| 118 | 90 | } |
| 119 | 91 | } while (((*ptr == val) ^ invert) && osd_ticks() < stopspin); |
| 120 | | #endif |
| 121 | 92 | } |
| 122 | 93 | |
| 123 | 94 | template<typename _PtrType> |