Re: Atomic operations in 32 and 64 bit platforms
- From: "H. Peter Anvin" <hpa@xxxxxxxxx>
- Date: Wed, 30 Jul 2008 14:30:24 -0700
Rod Pemberton wrote:
"H. Peter Anvin" <hpa@xxxxxxxxx> wrote in message
news:488FBE95.6040104@xxxxxxxxxxxx
Rod Pemberton wrote:And, parameter passing order is also an evaluation.No, it's not. The C compiler is perfectly free to generate the
parameters in any order ..., as long as it (a) ends
up in the right order in the end, and (b) doesn't violate sequence points.
How exactly does the inanimate compiler "decide" what order that is? (It's
programmed by a programmer after he/she made a decision about what order
should be used under what circumstances.) And, how can you not call the
resulting decision about that order an evaluation?
That's not exactly true, as frequently the order is decided by the scheduler inside the compiler and can be different for each instance, but let me rephrase this to perhaps make you happier:
"The author of the compiler can pick whatever order he believes is better."
What that means is that if you do something like this:
#include <stdio.h>
static int foo(void)
{
static int n = 0;
return ++n;
}
int main(void)
{
printf("%d %d\n", foo(), foo());
return 0;
}
.... you could get either "1 2" or "2 1" output; either is legal.
-hpa
.
- References:
- Re: Atomic operations in 32 and 64 bit platforms
- From: Phil Carmody
- Re: Atomic operations in 32 and 64 bit platforms
- From: Rod Pemberton
- Re: Atomic operations in 32 and 64 bit platforms
- From: H. Peter Anvin
- Re: Atomic operations in 32 and 64 bit platforms
- From: Rod Pemberton
- Re: Atomic operations in 32 and 64 bit platforms
- Prev by Date: Re: Vectors (cpu type idea)
- Next by Date: Re: prova
- Previous by thread: Re: Atomic operations in 32 and 64 bit platforms
- Next by thread: Re: Atomic operations in 32 and 64 bit platforms
- Index(es):
Relevant Pages
|