Re: [PATCH 03/13] Rewrite virAtomic APIs using GLib's atomic ops code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<...>

> +
> +#  define virAtomicIntGet(atomic)                                       \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ *(atomic) : 0);                     \
> +            __sync_synchronize ();                                      \
> +            (int) *(atomic);                                            \
> +        }))
> +#  define virAtomicIntSet(atomic, newval)                               \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ (newval) : 0);                      \
> +            *(atomic) = (newval);                                       \
> +            __sync_synchronize ();                                      \
> +        }))
> +#  define virAtomicIntInc(atomic)                                       \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ *(atomic) : 0);                     \
> +            (void) __sync_fetch_and_add ((atomic), 1);                  \
> +        }))
> +#  define virAtomicIntDecAndTest(atomic)                                \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ *(atomic) : 0);                     \
> +            __sync_fetch_and_sub ((atomic), 1) == 1;                    \
> +        }))
> +#  define virAtomicIntCompareExchange(atomic, oldval, newval)           \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 0);           \
> +            (bool) __sync_bool_compare_and_swap ((atomic), (oldval), (newval)); \
> +                           }))
> +#  define virAtomicIntAdd(atomic, val)                                  \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ (val) : 0);                         \
> +            (int) __sync_fetch_and_add ((atomic), (val));               \
> +        }))
> +#  define virAtomicIntAnd(atomic, val)                                  \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ (val) : 0);                         \
> +            (unsigned int) __sync_fetch_and_and ((atomic), (val));      \
> +        }))
> +#  define virAtomicIntOr(atomic, val)                                   \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \
> +            (void) (0 ? *(atomic) ^ (val) : 0);                         \
> +            (unsigned int) __sync_fetch_and_or ((atomic), (val));       \
> +        }))
> +#  define virAtomicIntXor(atomic, val)                                  \
> +    (__extension__ ({                                                   \
> +            verify (sizeof(*(atomic)) == sizeof(int));                  \


The `verify' lines cause building warnings:

cc1: warnings being treated as errors
util/virobject.c: In function 'virClassNew':
util/virobject.c:74:99: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]
util/virobject.c: In function 'virObjectNew':
util/virobject.c:112:84: error: nested extern declaration of '_gl_verify_function3' [-Wnested-externs]
util/virobject.c: In function 'virObjectUnref':
util/virobject.c:138:100: error: nested extern declaration of '_gl_verify_function4' [-Wnested-externs]
util/virobject.c: In function 'virObjectRef':
util/virobject.c:170:84: error: nested extern declaration of '_gl_verify_function5' [-Wnested-externs]


> +            (void) (0 ? *(atomic) ^ (val) : 0);                         \
> +            (unsigned int) __sync_fetch_and_xor ((atomic), (val));      \
> +        }))
> +

-- 
Thanks,
Hu Tao

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]