public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* __sync_bool_compare_and_swap() With a Pointer
@ 2012-11-19  5:10 Hei Chan
  2012-11-19  5:42 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Hei Chan @ 2012-11-19  5:10 UTC (permalink / raw)
  To: gcc-help

Hi,

According to http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html, __sync_bool_compare_and_swap() supports int, long, long long, and their unsigned counterparts, and GCC will allow any integral scalar or pointer type that is 1, 2, 4 or 8 bytes in length.

I wonder in what situation the pointer type won't be 1, 2, 4 or 8 bytes in length.  Let's say I am running on a 64-bit Intel CPU.


Thanks in advance.


Cheers,
Hei

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: __sync_bool_compare_and_swap() With a Pointer
  2012-11-19  5:10 __sync_bool_compare_and_swap() With a Pointer Hei Chan
@ 2012-11-19  5:42 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2012-11-19  5:42 UTC (permalink / raw)
  To: Hei Chan; +Cc: gcc-help

On Sun, Nov 18, 2012 at 9:10 PM, Hei Chan <structurechart@yahoo.com> wrote:
>
> According to http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html, __sync_bool_compare_and_swap() supports int, long, long long, and their unsigned counterparts, and GCC will allow any integral scalar or pointer type that is 1, 2, 4 or 8 bytes in length.
>
> I wonder in what situation the pointer type won't be 1, 2, 4 or 8 bytes in length.  Let's say I am running on a 64-bit Intel CPU.

On a 64-bit Intel CPU pointer types will always be either 4 or 8 bytes
(4 bytes if using x32).

Remember that GCC supports many different targets.  In any case the
sentence does not imply that there will ever be a pointer type that is
not 1, 2, 4 or 8 bytes (though of course there will be if GCC ever
supports a 128-bit machine).  The sentence also refers to integral
types, and GCC supports integral types larger than 8 bytes on some
processors, e.g., __int128_t on x86_64.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-19  5:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-19  5:10 __sync_bool_compare_and_swap() With a Pointer Hei Chan
2012-11-19  5:42 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).