forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PS2SDK's printf: double->float ?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Sep 12, 2004 12:25 am    Post subject: PS2SDK's printf: double->float ? Reply with quote

After some IRC discussions, it came up that "doubles are evil for the PS2", and I think that nobody will really argue about that.

What is to argue now, is the fact that the xprintf.c code from ps2sdk internally and externally use doubles. The internal part could be changed quite quickly without too much side effect.

But the external part is the line va_arg(ap,double). Well, I have to admit I have quite no knowledge about how va_arg will work actually. I do think that it shouldn't cause any trouble, and since that it's a gcc's builtin, it should behave nicely. But I am a bit clueless, and I don't even know if my tests would be relevant.

So, before changing the doubles to float inside xprintf.c (or maybe, to be a little bit nicer, having a #define which will default to float, permitting people to change that using some CFLAGS's -D on the command line), I'd like to know if it would break things or not ? Again, I don't know if any of my tests are relevant, and I don't like the idea "let's change it, and wait for people's complains" :P
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sun Sep 12, 2004 2:51 am    Post subject: Reply with quote

AFAIK you will have to hack GCC to prevent it from promoting float arguments to vararg functions to doubles.
_________________
"He was warned..."
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Sep 12, 2004 3:28 am    Post subject: Reply with quote

After some hacks and code readings, I came to the same conclusion...

Now, what good of an idea would it be ? Do people think that we should definitively get rid of doubles in the __builtin_va_arg function of gcc ? Or shall I try to do that silently ?
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sun Sep 12, 2004 4:26 am    Post subject: Reply with quote

IMO the best thing would be to turn it into an compiler option, e.g. -fno-promote-float-varargs or something.
_________________
"He was warned..."
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Sep 12, 2004 5:04 am    Post subject: Reply with quote

Hum, yeah, but, it wouldn't be much of a safe situation ? Well, I have to investigate it a bit further...
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Sep 12, 2004 10:45 pm    Post subject: Reply with quote

On a side note, I found this piece of documentation which may be of interest (not directly related to the topic, but may be of interest since I am poking stdio/stdlib lately...)

Quote:
VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end.
Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls
corresponding to the list of fixed arguments. Then use va_arg
normally to get the variable arguments, or pass your va_list object
around. You do not declare the va_list yourself; VA_OPEN does it
for you.

Here is a complete example:

Code:
        int
        printf VPARAMS ((const char *format, ...))
        {
           int result;

           VA_OPEN (ap, format);
           VA_FIXEDARG (ap, const char *, format);

           result = vfprintf (stdout, format, ap);
           VA_CLOSE (ap);

           return result;
        }


_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group