Maybe not.
In manual
int futex(int *uaddr, int op, int val, const struct timespec *timeout,
int *uaddr2, int val3);
The uaddr argument needs to point to an aligned integer which stores the counter. The operation to execute is passed via the op argument, along with a value val.
Your atomic_int
should be aligned.
In gcc 4.7.2 (which on Fedora 18), file: /usr/include/c++/4.7.2/bits/atomic_base.h
// Base types for atomics.
template<typename _IntTp>
struct __atomic_base;
...
/// atomic_int
typedef __atomic_base<int> atomic_int;
...
template<typename _ITp>
struct __atomic_base
{
private:
typedef _ITp __int_type;
__int_type _M_i;
// some operations
...
atomic_int
is just a wrapper of data __int_type _M_i;
where __int_type
is the template parameter you pass in. So it's an integer. And the struct is not guaranteed aligned in cross platform.