ObjFW  Diff

Differences From Artifact [50acc02363]:

  • File src/atomic.h — part of check-in [0c3e3da576] at 2016-07-30 23:29:38 on branch trunk — atomic.h: Use the OSAtomic variant without barrier

    This matches what the assembly versions does. However, the __sync_*
    versions still use the barrier, but unfortunately, no version without it
    is provided. The only way around this would be to use the new __atomic_*
    that has been added in GCC 4.7. (user: js, size: 20052) [annotate] [blame] [check-ins using]

To Artifact [0145f59683]:


964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
	return OSAtomicCompareAndSwapPtr(o, n, p);
#else
# error of_atomic_ptr_cmpswap not implemented!
#endif
}

static OF_INLINE void
of_memory_barrier(void)
{
#if !defined(OF_HAVE_THREADS)
	/* nop */
#elif defined(OF_X86_64_ASM)
	__asm__ __volatile__ (
	    "mfence" ::: "memory"
	);







|







964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
	return OSAtomicCompareAndSwapPtr(o, n, p);
#else
# error of_atomic_ptr_cmpswap not implemented!
#endif
}

static OF_INLINE void
of_memory_barrier_sync(void)
{
#if !defined(OF_HAVE_THREADS)
	/* nop */
#elif defined(OF_X86_64_ASM)
	__asm__ __volatile__ (
	    "mfence" ::: "memory"
	);
990
991
992
993
994
995
996


997

998

999












1000
1001
1002
1003
1004



1005

1006
1007
1008
	OSMemoryBarrier();
#else
# error of_memory_barrier not implemented!
#endif
}

static OF_INLINE void


of_memory_enter_barrier(void)

{

	of_memory_barrier();












}

static OF_INLINE void
of_memory_leave_barrier(void)
{



	of_memory_barrier();

}

OF_ASSUME_NONNULL_END







>
>
|
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>



|

>
>
>
|
>



990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
	OSMemoryBarrier();
#else
# error of_memory_barrier not implemented!
#endif
}

static OF_INLINE void
of_memory_barrier_enter(void)
{
	of_memory_barrier_sync();
}

static OF_INLINE void
of_memory_barrier_exit(void)
{
	of_memory_barrier_sync();
}

static OF_INLINE void
of_memory_barrier_producer(void)
{
#if defined(OF_X86_64_ASM)
	__asm__ __volatile__ ("sfence" ::: "memory");
#else
	of_memory_barrier_sync();
#endif
}

static OF_INLINE void
of_memory_barrier_consumer(void)
{
#if defined(OF_X86_64_ASM)
	__asm__ __volatile__ ("lfence" ::: "memory");
#else
	of_memory_barrier_sync();
#endif
}

OF_ASSUME_NONNULL_END