public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Asm style
  2001-11-21 23:07 vda
@ 2001-11-21 21:21 ` Ben Collins
  0 siblings, 0 replies; 7+ messages in thread
From: Ben Collins @ 2001-11-21 21:21 UTC (permalink / raw)
  To: vda; +Cc: linux-kernel

On Wed, Nov 21, 2001 at 11:07:03PM +0000, vda wrote:
> I'm using GCC 3.0.1 and seeing "multi-line literals are deprecated".
> Since a patch is necessary for that (and someone submitted it already)
> I'd like to hear from big kernel guys what asm statement style to use:
> 	asm(
> "		cmd	r,r\n"
> "lbl:		cmd	r,r\n"
> "		cmd	r,r\n"
> 		: spec
> 		: spec
> 	);
> [variable width for labels? I don't like it] or
> 	asm(
> 	"	cmd	r,r\n"
> 	"lbl:	cmd	r,r\n"
> 	"	cmd	r,r\n"
> 		: spec
> 		: spec
> 	);
> [better. But \n's are ugly] or
> #define NL "\n"
> 	asm(
> 	"	cmd	r,r" NL
> 	"lbl:	cmd	r,r" NL
> 	"	cmd	r,r" NL
> 		: spec
> 		: spec
> 	);

There's also:

	asm("\
	cmd	r,r\n\
lbl:	cmd	r,r\n\
	cmd	r,r\n" : spec : spec);


Or something similar (the trailing "\" added for continuation). Probably
the easiest way to patch existing asm.

-- 
 .----------=======-=-======-=========-----------=====------------=-=-----.
/                   Ben Collins    --    Debian GNU/Linux                  \
`  bcollins@debian.org  --  bcollins@openldap.org  --  bcollins@linux.com  '
 `---=========------=======-------------=-=-----=-===-======-------=--=---'

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

* Re: Asm style
       [not found] <01112123070300.05447@manta.suse.lists.linux.kernel>
@ 2001-11-21 21:23 ` Andi Kleen
  0 siblings, 0 replies; 7+ messages in thread
From: Andi Kleen @ 2001-11-21 21:23 UTC (permalink / raw)
  To: vda; +Cc: linux-kernel

vda <vda@port.imtp.ilyichevsk.odessa.ua> writes:

> I'm using GCC 3.0.1 and seeing "multi-line literals are deprecated".
> Since a patch is necessary for that (and someone submitted it already)

The best patch for this IMHO would be to just remove the stupid warning
from gcc. It's obvious that whoever added it has never used gcc inline
assembly.

If they want to remove multi-line strings they need to supply a way to
write inline assembly without strings first. Both solutions below
are very error prone and ugly.

Failing that:

> 	asm(
> 	"	cmd	r,r\n"
> 	"lbl:	cmd	r,r\n"
> 	"	cmd	r,r\n"

Is bearable with some pains.


> #define NL "\n"
> 	asm(
> 	"	cmd	r,r" NL
> 	"lbl:	cmd	r,r" NL

Is also bearable, but needs agreement (needs a central #define) 

-Andi


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

* Asm style
@ 2001-11-21 23:07 vda
  2001-11-21 21:21 ` Ben Collins
  0 siblings, 1 reply; 7+ messages in thread
From: vda @ 2001-11-21 23:07 UTC (permalink / raw)
  To: linux-kernel

I'm using GCC 3.0.1 and seeing "multi-line literals are deprecated".
Since a patch is necessary for that (and someone submitted it already)
I'd like to hear from big kernel guys what asm statement style to use:
	asm(
"		cmd	r,r\n"
"lbl:		cmd	r,r\n"
"		cmd	r,r\n"
		: spec
		: spec
	);
[variable width for labels? I don't like it] or
	asm(
	"	cmd	r,r\n"
	"lbl:	cmd	r,r\n"
	"	cmd	r,r\n"
		: spec
		: spec
	);
[better. But \n's are ugly] or
#define NL "\n"
	asm(
	"	cmd	r,r" NL
	"lbl:	cmd	r,r" NL
	"	cmd	r,r" NL
		: spec
		: spec
	);
[I like this: \n doesn't interfere with args]
or what?
--
vda

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

* Re: Asm style
  2001-11-22 12:43   ` Asm style Giacomo Catenazzi
@ 2001-11-22  9:27     ` ncw
  0 siblings, 0 replies; 7+ messages in thread
From: ncw @ 2001-11-22  9:27 UTC (permalink / raw)
  To: linux-kernel

Giacomo Catenazzi wrote:
>  Ben Collins wrote:
> > There's also:
> > 
> > 	asm("\
> > 	cmd	r,r\n\
> > lbl:	cmd	r,r\n\
> > 	cmd	r,r\n" : spec : spec);
> > 
> > 
> > Or something similar (the trailing "\" added for continuation). Probably
> > the easiest way to patch existing asm.
>  
>  not ANSI C. The trailing \ is understood only in marco definitions
>  (and outside strings)

gcc begs to differ

/* z.c */
#include <stdio.h>

int main(void)
{
    printf("This is a string\n\
with continuation characters\n");
    return 0;
}

$ gcc -Wall -pedantic -ansi z.c -o z
[silence]

Remove the \ and you get

z.c:5: warning: string constant runs past end of line
z.c: In function `main':
z.c:5: warning: ANSI C forbids newline in string constant

You are correct in thinking it is something to do with pre-processor -
it deals with these continuation lines eg,

$ gcc -E -Wall -pedantic -ansi z.c

Gives
[snip stdio etc]
int main(void)
{
    printf("This is a string\nwith continuation characters\n");

    return 0;
}

-- 
Nick Craig-Wood
ncw@axis.demon.co.uk

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

* Re: Asm style
  2001-11-22 14:29   ` Giacomo Catenazzi
@ 2001-11-22 11:31     ` Jakub Jelinek
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Jelinek @ 2001-11-22 11:31 UTC (permalink / raw)
  To: Giacomo Catenazzi; +Cc: ncw, linux-kernel

On Thu, Nov 22, 2001 at 03:29:07PM +0100, Giacomo Catenazzi wrote:
> gcc should warn in both case (when calling it with -pedantic -ansi).
> But forget my comment:
> Talking about ANSI C for asm construct doen't make much sense.

It should not warn.
Please read ISO C99 5.1.1.2:
2.  Each instance of a backslash character (\) immediately followed by a new-line
    character is deleted, splicing physical source lines to form logical source lines.
    Only the last backslash on any physical source line shall be eligible for being part
    of such a splice. A source file that is not empty shall end in a new-line character,
    which shall not be immediately preceded by a backslash character before any such
    splicing takes place.
This happens even before tokenizing (and before macro expansion too).

	Jakub

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

* Re: Asm style
       [not found] ` <fa.cbkkrrv.m72ejr@ifi.uio.no>
@ 2001-11-22 12:43   ` Giacomo Catenazzi
  2001-11-22  9:27     ` ncw
  0 siblings, 1 reply; 7+ messages in thread
From: Giacomo Catenazzi @ 2001-11-22 12:43 UTC (permalink / raw)
  To: Ben Collins; +Cc: vda, linux-kernel

Ben Collins wrote:
> 
> There's also:
> 
> 	asm("\
> 	cmd	r,r\n\
> lbl:	cmd	r,r\n\
> 	cmd	r,r\n" : spec : spec);
> 
> 
> Or something similar (the trailing "\" added for continuation). Probably
> the easiest way to patch existing asm.
> 

not ANSI C. The trailing \ is understood only in marco definitions
(and outside strings)

	giacomo




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

* Re: Asm style
       [not found] ` <fa.njuqm5v.100c5ak@ifi.uio.no>
@ 2001-11-22 14:29   ` Giacomo Catenazzi
  2001-11-22 11:31     ` Jakub Jelinek
  0 siblings, 1 reply; 7+ messages in thread
From: Giacomo Catenazzi @ 2001-11-22 14:29 UTC (permalink / raw)
  To: ncw; +Cc: linux-kernel

ncw@axis.demon.co.uk wrote:
> Giacomo Catenazzi wrote:
>> 
>> not ANSI C. The trailing \ is understood only in marco definitions
>> (and outside strings)
>> 
> gcc begs to differ
> 
> /* z.c */
> #include <stdio.h>
> 
> int main(void)
> {
>     printf("This is a string\n\
> with continuation characters\n");
>     return 0;
> }
> 
> $ gcc -Wall -pedantic -ansi z.c -o z
> [silence]
> 
> Remove the \ and you get
> 
> z.c:5: warning: string constant runs past end of line
> z.c: In function `main':
> z.c:5: warning: ANSI C forbids newline in string constant
> 

gcc should warn in both case (when calling it with -pedantic -ansi).
But forget my comment:
Talking about ANSI C for asm construct doen't make much sense.

If gcc people will maintain (in long future) the syntax of
trailing \ + NL, I agree to use it into kernel.

	giacomo



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

end of thread, other threads:[~2001-11-22 11:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fa.d6k3juv.16q3on@ifi.uio.no>
     [not found] ` <fa.cbkkrrv.m72ejr@ifi.uio.no>
2001-11-22 12:43   ` Asm style Giacomo Catenazzi
2001-11-22  9:27     ` ncw
     [not found] <fa.derh1nv.1h0ai0b@ifi.uio.no>
     [not found] ` <fa.njuqm5v.100c5ak@ifi.uio.no>
2001-11-22 14:29   ` Giacomo Catenazzi
2001-11-22 11:31     ` Jakub Jelinek
2001-11-21 23:07 vda
2001-11-21 21:21 ` Ben Collins
     [not found] <01112123070300.05447@manta.suse.lists.linux.kernel>
2001-11-21 21:23 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox