atomic: Fight with all the assemblers that don't like REP NOP. :/
authorRyan C. Gordon <icculus@icculus.org>
Mon, 25 Jun 2018 16:34:16 -0400
changeset 12039ecc19ca324f7
parent 12038 2d871b0d5c34
child 12040 58425859a4e5
atomic: Fight with all the assemblers that don't like REP NOP. :/
src/atomic/SDL_spinlock.c
     1.1 --- a/src/atomic/SDL_spinlock.c	Mon Jun 25 15:58:35 2018 -0400
     1.2 +++ b/src/atomic/SDL_spinlock.c	Mon Jun 25 16:34:16 2018 -0400
     1.3 @@ -122,12 +122,13 @@
     1.4  
     1.5  /* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
     1.6  #if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
     1.7 -    #define PAUSE_INSTRUCTION() __asm__ __volatile__("rep nop\n")
     1.8 +    #define PAUSE_INSTRUCTION() __asm__ __volatile__("pause\n")  /* Clang lets you do REP NOP, GCC wants PAUSE. */
     1.9  #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
    1.10 -    #define PAUSE_INSRUCTION() _mm_pause()  /* this is actually "rep nop" and not a SIMD instruction. */
    1.11 +    #define PAUSE_INSRUCTION() _mm_pause()  /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */
    1.12  #elif defined(__WATCOMC__) && defined(__386__)
    1.13 +    /* watcom assembler won't let you do PAUSE, but refuses REP NOP as an invalid combination. Hardcode the bytes. */
    1.14      extern _inline void PAUSE_INSTRUCTION(void);
    1.15 -    #pragma aux PAUSE_INSTRUCTION = "rep nop"
    1.16 +    #pragma aux PAUSE_INSTRUCTION = "db 0f3h,90h"
    1.17  #else
    1.18      #define PAUSE_INSTRUCTION()
    1.19  #endif