Argument Counting in 64 Bit

Programming, for all ages and all languages.
Post Reply
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Argument Counting in 64 Bit

Post 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
cg123
Member
Member
Posts: 41
Joined: Wed Sep 27, 2006 2:34 pm

Post by cg123 »

I just used __builtin_va_arg and the like.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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.
Author of COBOS
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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..
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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]
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply