Page 1 of 1

Argument Counting in 64 Bit

Posted: Wed Nov 07, 2007 10:33 am
by AJ
Hi,

I am trying to implement a version of printf in my 64 bit kernel. Only problem is, the old version kind of relied on the variable number of arguments being on the stack. By default, GCC in 64 bit uses registers and the stack for argument passing. d'oh!

This means that my nice old function which incremented through the stack no longer works. Moreove, supplying the __stdcall attribute gets ignored by the compiler.

Does anyone have a neat way to deal with this (rather than having to remember which aregument I am on, and manually loading the data from each individual register?)

Cheers,
Adam

Posted: Wed Nov 07, 2007 5:15 pm
by cg123
I just used __builtin_va_arg and the like.

Posted: Thu Nov 08, 2007 2:27 am
by os64dev
I've build the x86_64 cross compiler and can use the #include <stdarg.h> and use the va_XXX macros without any problem.

Posted: Thu Nov 08, 2007 4:39 am
by AJ
Thanks - I'll have a look (at the moment I am using absolutely no headers/code that I haven't written myself).

Cheers for the advice,
Adam

Posted: Thu Nov 08, 2007 4:56 am
by AJ
Yep - it worked. What a plonker - I didn't remember one of the first things I read about devving a kernel in C which is that there are some headers which do not require special cross compiling to work in a freestanding environment - I'm almost tempted to add to the stupid mistakes thread :roll:

Cheers,
Adam

Posted: Thu Nov 22, 2007 3:41 pm
by mystran
AJ wrote:Yep - it worked. What a plonker - I didn't remember one of the first things I read about devving a kernel in C which is that there are some headers which do not require special cross compiling to work in a freestanding environment - I'm almost tempted to add to the stupid mistakes thread :roll:

Cheers,
Adam
Your signature link says 403 btw..

Posted: Fri Nov 23, 2007 2:39 am
by AJ
Yes - thanks. I have been fiddling with my site trying to get wiki-type software working to make editing quicker. Then, I got sidetracked with Caracal Boot Loader and the 'site' has been like that for a couple of weeks...you know how it is!

I hope to get something useable back up in the next few weeks.

Cheers,
Adam

[EDIT: While I'm on this topic, if anyone knows if it's possible to get any kind of SVN repository working on a 1and1 hosted web site with no root access (Linux home package), I would be most grateful to know how![/EDIT]

Posted: Fri Nov 23, 2007 5:18 am
by Brynet-Inc
AJ wrote:While I'm on this topic, if anyone knows if it's possible to get any kind of SVN repository working on a 1and1 hosted web site with no root access (Linux home package), I would be most grateful to know how!
Subversion can either operate as an Apache 2 module, or a stand-alone server "svnserve".

Unfortunately, most "shared hosting" providers will not allow you to use 3rd party software on their servers.