public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: varargs ABI & PPC (problems porting cdrecord to Linux-ppc)
@ 1998-02-18 14:54 Joerg Schilling
  0 siblings, 0 replies; 4+ messages in thread
From: Joerg Schilling @ 1998-02-18 14:54 UTC (permalink / raw)
  To: geoffk, schilling
  Cc: Heiko_Eissfeldt%DeTeCSM, egcs-bugs, egcs, heiko, libc-hacker

From geoffk@discus.anu.edu.au Wed Feb 18 05:41:31 1998

>> Date: Tue, 17 Feb 1998 16:55:55 +0100
>> From: schilling@fokus.gmd.de (Joerg Schilling)

>> It would be nice if GCC could add the va_copy() Solaris varargs enhancement
>> in future.

>This is in egcs (all released versions) and gcc 2.8.0, and has been
>for about a year.

>va_copy will probably be part of the new ISO C standard.

>In egcs, etc., it might have underscores in front of it (__va_copy).
>This is because a previous draft of the new ISO C standard had these.
>I'm not sure if it is worth changing it until the standard becomes
>final; it might change back :-(.

Thank you for your reply. It is sometimes hard to get reasonable 
research from the owners of systems I have no access to.

If it is guaranteed that __va_copy() is always a macro so I can
#ifdef, it is no problem for me.

Joerg

http://www.fokus.gmd.de/usr/schilling	ftp://ftp.fokus.gmd.de/pub/unix

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

* Re: varargs ABI & PPC (problems porting cdrecord to Linux-ppc)
  1998-02-17 23:59 ` Geoffrey KEATING
@ 1998-02-18 14:54   ` Ulrich Drepper
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 1998-02-18 14:54 UTC (permalink / raw)
  To: Geoffrey KEATING
  Cc: Joerg Schilling, egcs-bugs, egcs, libc-hacker,
	Heiko_Eissfeldt%DeTeCSM, heiko

Geoffrey KEATING <geoffk@discus.anu.edu.au> writes:

> In egcs, etc., it might have underscores in front of it (__va_copy).
> This is because a previous draft of the new ISO C standard had these.
> I'm not sure if it is worth changing it until the standard becomes
> final; it might change back :-(.

The __va_copy name should remain in place and once we have a ISO C 9x
ready compiler and an appropriate preprocessor macro we can define
va_copy based on __va_copy easily when in c9x mode.

-- Uli
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

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

* Re: varargs ABI & PPC (problems porting cdrecord to Linux-ppc)
  1998-02-17 14:38 Joerg Schilling
@ 1998-02-17 23:59 ` Geoffrey KEATING
  1998-02-18 14:54   ` Ulrich Drepper
  0 siblings, 1 reply; 4+ messages in thread
From: Geoffrey KEATING @ 1998-02-17 23:59 UTC (permalink / raw)
  To: Joerg Schilling
  Cc: egcs-bugs, egcs, libc-hacker, Heiko_Eissfeldt%DeTeCSM, heiko

> Date: Tue, 17 Feb 1998 16:55:55 +0100
> From: schilling@fokus.gmd.de (Joerg Schilling)

> It would be nice if GCC could add the va_copy() Solaris varargs enhancement
> in future.

This is in egcs (all released versions) and gcc 2.8.0, and has been
for about a year.

va_copy will probably be part of the new ISO C standard.

In egcs, etc., it might have underscores in front of it (__va_copy).
This is because a previous draft of the new ISO C standard had these.
I'm not sure if it is worth changing it until the standard becomes
final; it might change back :-(.

--
Geoff Keating <Geoff.Keating@anu.edu.au>

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

* varargs ABI & PPC (problems porting cdrecord to Linux-ppc)
@ 1998-02-17 14:38 Joerg Schilling
  1998-02-17 23:59 ` Geoffrey KEATING
  0 siblings, 1 reply; 4+ messages in thread
From: Joerg Schilling @ 1998-02-17 14:38 UTC (permalink / raw)
  To: drepper, egcs-bugs, egcs, libc-hacker; +Cc: Heiko_Eissfeldt%DeTeCSM, heiko

While porting cdreocrd to Linux-ppc, I found a problem that is related to
the fact that Linux-ppc uses the SVr4 varargs ABI.

I append the README.ppc that I wrote for this reason to illustrate the problem.

It would be nice if GCC could add the va_copy() Solaris varargs enhancement
in future.

Joerg


/*--------------------------------------------------------------------------*/
If your system uses the SVr4 ABI (designed by Motorola), you will only
be able to compile my library files lib/format.c and lib/getargs.c if your
C-compiler supports the macro va_copy() from stdarg.h.

Mach/Next STep/Apple Rhapsody on ppc use a 'void *' for the type va_list
so you don't need to make changes on these systems.

Solaris/ppc (made in 1992) is the first UNIX implementation for the PPC.
It includes the va_copy() macro that allows you to assign a C object of the
type va_list in a system independant way.

Linux/ppc uses exactly the same construct as Solaris for the type va_list
but unfortunately does not include the macro va_copy().

Here is what Solaris /usr/include/sys/varargs.h looks like:

/*
 * va_copy is a Solaris extension to provide a portable way to perform
 * a variable argument list ``bookmarking'' function.
 */
#if defined(__ppc)
#define	va_copy(to, from)	((to)[0] = (from)[0])
#else
#define	va_copy(to, from)	((to) = (from))
#endif

If you don't have this, you will never be able to compile recent printf()
implementations that allow you to have localized commands that need to
exchange the positions of arguments in different languages. If you don't
know this feature, here is a simple example:

main()
{
	printf("'%1$s' '%2$i'\n",	"test",	8);
	printf("'%2$s' '%1$i'\n",	8,	"test");
}

Will print:

'test' '8'
'test' '8'


To be able to compile my lib/format.c and lib/getargs.c on a OS
implementation that uses an array for va_list, you will need
this va_copy() enhancement too.

The files mentioned above already compile on a PPC Apple Rhapsody system.
But as mentioned before, Rhapsody uses a void * for va_list (maybe because
Apple includes badly designed international printf code from BSD 4.4
that requires va_list to be void * to work).

GCC
===

To be able to compile a SVr4 compliant printf, or my files lib/format.c and
lib/getargs.c with GCC, you will need to add the following definition 
to va-ppc.h :

/usr/lib/gcc-lib/*-linux-gnulibc1/2.*/include/va-ppc.h

#define	va_copy(to, from)	((to)[0] = (from)[0])

and to all other va-*.h files:

#define	va_copy(to, from)	((to) = (from))

This problem has been mailed to the egcs/GCC folks too.

Joerg

http://www.fokus.gmd.de/usr/schilling	ftp://ftp.fokus.gmd.de/pub/unix



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

end of thread, other threads:[~1998-02-18 14:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-18 14:54 varargs ABI & PPC (problems porting cdrecord to Linux-ppc) Joerg Schilling
  -- strict thread matches above, loose matches on Subject: below --
1998-02-17 14:38 Joerg Schilling
1998-02-17 23:59 ` Geoffrey KEATING
1998-02-18 14:54   ` Ulrich Drepper

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).