ObjFW  Check-in [dc1ba0558c]

Overview
Comment:OFOnce: Avoid full memory barrier
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 1.1
Files: files | file ages | folders
SHA3-256: dc1ba0558c8c329d526051b8a1d738bd9ab2534e4f9cd4b39f8f7d87d2c2ec43
User & Date: js on 2024-09-04 23:27:45
Other Links: branch diff | manifest | tags
Context
2024-09-04
23:30
OFMemoryBarrier: Use sync on PowerPC check-in: 5b00004344 user: js tags: 1.1
23:27
OFOnce: Avoid full memory barrier check-in: dc1ba0558c user: js tags: 1.1
23:27
OFOnce: Avoid full memory barrier check-in: 12b72a02a0 user: js tags: trunk
2024-08-31
00:15
objfw-config: Don't reproduce flags from configure check-in: 0050fce022 user: js tags: 1.1
Changes

Modified src/OFOnce.m from [06c9cd7dc5] to [6e21212113].

45
46
47
48
49
50
51
52
53
54
55

56


57
58
59
60
61
62
63
	pthread_once(control, function);
#elif defined(OF_HAVE_ATOMIC_OPS)
	/* Avoid atomic operations in case it's already done. */
	if (*control == 2)
		return;

	if (OFAtomicIntCompareAndSwap(control, 0, 1)) {
		function();

		OFMemoryBarrier();


		OFAtomicIntIncrease(control);


	} else
		while (*control == 1)
			OFYieldThread();
#elif defined(OF_AMIGAOS)
	bool run = false;

	/* Avoid Forbid() in case it's already done. */







<
<
|

>

>
>







45
46
47
48
49
50
51


52
53
54
55
56
57
58
59
60
61
62
63
64
	pthread_once(control, function);
#elif defined(OF_HAVE_ATOMIC_OPS)
	/* Avoid atomic operations in case it's already done. */
	if (*control == 2)
		return;

	if (OFAtomicIntCompareAndSwap(control, 0, 1)) {


		OFAcquireMemoryBarrier();

		function();
		OFAtomicIntIncrease(control);

		OFReleaseMemoryBarrier();
	} else
		while (*control == 1)
			OFYieldThread();
#elif defined(OF_AMIGAOS)
	bool run = false;

	/* Avoid Forbid() in case it's already done. */