Add support for 64-bit integers to g_atomic_int*
@nirbheek
Submitted by Nirbheek Chauhan Link to original bug (#754182)
Description
The gatomic documentation says:
There is no support for 64bit operations on platforms with 32bit pointers because it is not generally possible to perform these operations atomically.
This is incorrect. The underlying gcc API[1] and the Windows API[2] used by g_atomic_int* already support 64-bit integers, and gcc falls back to a slower function with the same guarantees[3]. Hence, the GCC API guarantees atomicity for 64-bit aligned integers on 32-bit platforms as defined by Intel, and the Windows API guarantees the same.
The exact same implementation that is currently used for 32-bit integers would also work for 64-bit (long long) integers.
-
“GCC allows any integral scalar or pointer type that is 1, 2, 4 or 8 bytes in length”, https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins
-
“Performs an atomic addition operation on the specified LONGLONG values”, https://msdn.microsoft.com/en-us/library/windows/desktop/ms686360%28v=vs.85%29.aspx#interlocked_functions
-
“If a particular operation cannot be implemented on the target processor, a warning is generated and a call an external function is generated.”, https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins