www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDIyNzIyXSBOZXc6IEltcG9ydEM6IHBhcnNlciBkb2Vz?=

https://issues.dlang.org/show_bug.cgi?id=22722

          Issue ID: 22722
           Summary: ImportC: parser doesn’t understand `asm volatile`
                    syntax
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

<dispatch/dispatch.h> on macOS, which is included by
<CoreFoundation/CoreFoundation.h>, has an inline function which has a macro
defined:

#define dispatch_compiler_barrier()  __asm__ __volatile__("" ::: "memory”)

Where it is used, it is expanded to:

typedef void (*dispatch_function_t)(void *);
typedef intptr_t dispatch_once_t;

extern void dispatch_once_f(dispatch_once_t *predicate, void * context,
dispatch_function_t function);

static inline /* several attributes omitted */
void
_dispatch_once_f(dispatch_once_t *predicate, void * context,
dispatch_function_t function)                                                
{
 if (__builtin_expect((*predicate), (~0l)) != ~0l) {
  dispatch_once_f(predicate, context, function);                               
 } else {                                                                      
  asm volatile("" ::: "memory");                                               
 }
 __builtin_assume(*predicate == ~0l);
}

gcc docs on the use of volatile with asm:
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile

--
Jan 31 2022