Gnu cpp bug or feature?
I just discovered that the gnu cpp doesn't allow * and = to be concatenated. What I am trying to do is the following:
#ifdef __LP64__
#define ADDIB addib,*
#else
#define ADDIB addib,
#endif
I then would use the above defines throughout some assembly functions, e.g.:
ADDIB> -1,%r1,1b
ADDIB= -1,%arg3,fdoneloopIf __LP64__ is defined, the above two examples wind up expanding to:
addib,*> -1,%r1,1b
addib,* = -1,%arg3,fdoneloopThe first example expands as I would expect, but the second example winds up being a syntax error, because it should have been expanded to:
addib,*= -1,%arg3,fdoneloop
Anyway, I prefer to write the code this way rather than sprinkling #ifdef __LP64__'s throughout the code, or using two different copies of the functions. I imagine that gnu cpp must be trying to avoid creating the C *= operator by mistake, but I don't believe there is any standard that requires this. I know that the above examples work on HP-UX (not that HP-UX sets the standard).
It just seems strange to me for gnu cpp to special case this particular sequence. Is there a good reason for this behaviour, or is this a bug?
John Marvin
[email protected]
Quoted 3 lines · John Marvin
I just discovered that the gnu cpp doesn't allow * and = to be concatenated. What I am trying to do is the following:
GNU cpp does do some slightly strange things to avoid accidentally creating C tokens. However, you should be able to work around this behaviour by using the ## operator. try...
Quoted 2 lines
ADDIB> -1,%r1,1b
ADDIB= -1,%arg3,fdoneloopADDIB##>
ADDIB##=
instead?
Signature · 1 line
Revolutions do not require corporate support.
Quoted 8 lines · Matthew Wilcox
Quoted 3 lines · John Marvin
I just discovered that the gnu cpp doesn't allow * and = to be concatenated. What I am trying to do is the following:
GNU cpp does do some slightly strange things to avoid accidentally creating C tokens. However, you should be able to work around this behaviour by using the ## operator. try...
ok, this problem is now fixed. Our Makefiles have been broken for a _long_ time, so -traditional was not being passed to cpp. Now that it is, it will no longer have this behaviour.
This has some downsides; some macro definitions no longer work the way you expect them to if you've been brough up on ansi c, like i was. in particular, multiline #defines no longer seem to work, and token concatenation with ## no longer works. Fix the former with #ifndef __ASSEMBLY__ ... #endif around the macros which don't work and fix the latter by replacing:
#define ENTRY_SAME(_name_) sys_ ## _name_
with
#define ENTRY_SAME(_name_) sys_/**/_name_
of course, this won't work with the cpp in ANSI mode, so if this is in a header file, you'll need to #ifdef __ASSEMBLY__ #else #endif your way around it. fortunately the only example which needed it so far was syscall.S, not a header file.
as far as I can tell, everything now seems to be working; i recommend only fixing things as we run into problems with this. John, do you want to change back to the ADDIB= form now, leave it as it is, or have me do it?
Quoted 2 lines
Quoted 2 lines
ADDIB> -1,%r1,1b ADDIB= -1,%arg3,fdoneloop
Signature · 1 line
Revolutions do not require corporate support.