tech-userlevel: Re: pcc?

Subject: Re: pcc?
To: None <tech-userlevel@NetBSD.org>
From: Anders Magnusson <ragge@ludd.ltu.se>
List: tech-userlevel
Date: 12/29/2007 17:03:58
--%--multipart-mixed-boundary-1.18150.1198944238--%
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
> 
> 
> I'm running NetBSD-4 with modified cdefs.h
> and pcc fails like this.
> But I don't see any changes related to pcc in HEAD's stdarg.h.
> Any comments?
> 
Yes, I haven't checked it in yet. I added builtins for the stdarg stuff
to the compiler a while ago, and will check in the fixes together with
some more that I have pending. Some more debugging to do first, though.
You until then patch your i386/stdarg.h with the patch provided.
-- Ragge
> 0 ~> cat main.c 
> #include <stdarg.h>
> #include <stdio.h>
> 
> void my_log (const char *format, ... )
> {
> va_list ap;
> 
> va_start (ap, format);
> vprintf (format, ap);
> va_end (ap);
> }
> 
> int main ()
> {
> my_log ("Hello World!\n");
> return 0;
> }
> 0 ~> gcc -o main main.c && ./main
> Hello World!
> 0 ~> pcc -o main main.c && ./main 
> main.o: In function `my_log':
> : undefined reference to `__builtin_next_arg'
> 1 ~>
> 
> -- 
> Best regards, Aleksey Cheusov.
> 
--%--multipart-mixed-boundary-1.18150.1198944238--%
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: ascii text
Content-Disposition: attachment; filename="stdarg.h.diff"
*** stdarg.h.orig	Fri Jul 27 12:39:20 2007
--- stdarg.h	Fri Jul 27 18:45:00 2007
***************
*** 56,63 ****
--- 56,68 ----
 #define	__va_size(type) \
 	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
 
+ #ifdef __PCC__
+ #define va_start(ap, last) \
+ 	((ap) = (va_list)(&last) + (sizeof(last) < 4 ? 4 : sizeof(last)))
+ #else
 #define	va_start(ap, last) \
 	((ap) = (va_list)__builtin_next_arg(last))
+ #endif
 
 #define	va_arg(ap, type) \
 	(*(type *)(void *)((ap) += __va_size(type), (ap) - __va_size(type)))
--%--multipart-mixed-boundary-1.18150.1198944238--%--

AltStyle によって変換されたページ (->オリジナル) /