svn commit: r238907 - projects/calloutng/sys/kern
Dimitry Andric
dim at FreeBSD.org
Tue Sep 18 10:16:00 UTC 2012
On 2012-09-18 02:13, Attilio Rao wrote:
> On Thu, Aug 2, 2012 at 9:56 PM, Attilio Rao <attilio at freebsd.org> wrote:
>> On 7/30/12, John Baldwin <jhb at freebsd.org> wrote:
...
>> While here, did you consider also:
>> - Abstracting compiler_memory_barrier() into a MI, compiler dependent function?
>
> So what do you think about this patch? (Please double-check the GIT log).
...
> diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
> index 8224672..fc6a75f 100644
> --- a/sys/sys/cdefs.h
> +++ b/sys/sys/cdefs.h
> @@ -114,6 +114,13 @@
> #endif
>
> /*
> + * Compiler memory barriers, specific to gcc and clang.
> + */
> +#if defined(__GNUC__)
> +#define __compiler_membar() __asm __volatile(" " : : : "memory")
> +#endif
> +
> +/*
> * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
> * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
> * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
Please use gcc's __sync_synchronize() builtin[1] instead, which is
specifically for this purpose. Clang also supports it.
The builtin will emit actual memory barrier instructions, if the target
architecture supports it, otherwise it will emit the same asm statement
you show above. See contrib/gcc/builtins.c, around line 5584, function
expand_builtin_synchronize().
-Dimitry
[1]: <http://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html#index-g_t_005f_005fsync_005fsynchronize-2843>
More information about the svn-src-projects
mailing list