I
Ian Collins
And with ridiculous comments like that from you, who I thought better
of, is it any wonder?
I stand by the comment and the archive of this group will back it up.
And with ridiculous comments like that from you, who I thought better
of, is it any wonder?
Mok-Kong Shen said:That seems not to be true in case of e.g. ADA.
ADA is in a very different market than C. ADA is being used in cases
where it is quite probable that the conditions for acceptance of a
program include verification that the compiler is certified to follow
the standard.
When I implemented rotate ops, they worked on 8, 16 or 32 bits depending on the
type of the left operand, as you might expect.
This causes a problem in C because intermediate results must be ints.
But this is responsible for all sorts of other problems too: eg.:
char c=0xC0;
int a = c<<1;
Should a be 0x80 or 0x180? There is a case for both results.
I think the main requirements will be to rotate entire bytes, shorts and ints,
rather than either the bottom N bits of a value, or an arbitrary bitfield. The
latter are always possible via the normal bit operations.
I think you've got that back to front: usually the source code uses the
simplest, most obvious expression, while the compiler generates the nightmare
code needed to achieve it.
If it's that critical then rotates can be implemented as built-in functions with
3 operands: value to rotate, shift count, and field width.
> I wouldn't object to
that, although it would be nice to be able to write:
a rol=1;
instead of:
a = rotateleft(a,1,32);
Ian Collins said:I don't think it is possible to get Jacob to engage in a technical
debate, he appears to take any disagreement with is position as a
personal insult.
Seebs said:Could be. I have no idea. Since I haven't actually seen or heard of
anyone using Fortran for new code since the 70s, the question has been of
very little interest to me.
Rui said:Can you point out what libraries were written in the C programming language whose developers not
only had the need to implement any form of bit rotation but also complained that the C programming
language should be changed in order to offer that feature in the core language?
Seebs said:What about them, I guess? Lots of compilers generate rotate instructions
when they're appropriate, on hardware which has them. Not all hardware
has them.
The fact that lots of compilers generate shows that an essential need
has been identified by a number of compiler writers but that would also
mean that maybe some compiler writers may have missed that. On hardware
that does not have the rotation instructions, the compiler writer can
implement with shifts (in which case it saves the user the trouble to
write the shifts himself). Anyway, I consider it a rather unusual and
lucky result that the compiler writers have reacted to this issue.
(They normally have no knowledge of users' programs and presumably must
have obtained some suggestions from the users.)
As I am writing a new code in Fortran (with C parts), you will not be able
to claim that anymore ;-)
Nobody said:Not even that.
Some implementations may provide it, but C itself doesn't, due to the
reliance upon the "abstract machine" concept.
To have the C language support memory-mapped hardware, the standard would
need to either more precisely define the meaning of "volatile" or add
memory barriers.
Kenny said:Fortran, OTOH, still at least tries to be a desktop
language.
Seebs said:Could be. I have no idea. Since I haven't actually seen or heard of
anyone using Fortran for new code since the 70s, the question has been of
very little interest to me.
Mok-Kong Shen said:It's my (though maybe wrong) impression that the standard of Fortran
is changing at a higher speed than C.
I don't know what gave you that idea. Fortran was and still is an
engineer's programming language, designed and intended to be used to
develop number crunching applications. The recent changes made to
Fortran were basically adding support for OO programming and enhancing
it's support for parallel processing. That means that a programming
language which was designed for and lives in the realm of HPC got
tweaked to better serve it's domain. Where did you get the idea that
Fortran was ever a "desktop language", particularly when compared to C?
Do you seriously think that compiler writer don't benchmark real
programs?
William Ahern said:Except memory barriers are being standardized for C1x in stdatomic.h. See
e.g. atomic_thread_fence() and atomic_signal_fence() at N1425 7.16.3.
Although they're defined in terms of threads and signals, so their
behavior
might be undefined w/r/t memory maps in general.
The actual atomic ops also take a memory order parameter.
The fact that lots of compilers generate shows that an essential need
has been identified by a number of compiler writers but that would also
mean that maybe some compiler writers may have missed that. On hardware
that does not have the rotation instructions, the compiler writer can
implement with shifts (in which case it saves the user the trouble to
write the shifts himself). Anyway, I consider it a rather unusual and
lucky result that the compiler writers have reacted to this issue.
(They normally have no knowledge of users' programs and presumably must
have obtained some suggestions from the users.)
Rui said:Technical standards change when there is a honest, rational and reasonable need for them to change.
If no one can think of a reasonable issue and come up with a reasonable proposal to tackle that
issue then there is absolutely no reason to change stuff. Change for the sake of changing doesn't
do anyone any good. This isn't supposed to be a competition.
Since many of these are very HW specific (for example a write barrier as
opposed to a fence - and there are slew of different HW-specific atomic
operations) I can only wonder why they would want to "standardize" these
built-in functions. Perhaps the clue is that they are specific to threads
and signals.
Ian Collins said:These will follow the atomics in C++0x which are supported in recent gcc
versions, see http://gcc.gnu.org/wiki/Atomic.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.