PDCLib: Platform configs required

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

PDCLib: Platform configs required

Post by Solar »

In the past, I have recieved several offers to help with PDCLib. I have always turned them down so far. Now there are two rather specific things that would indeed help me getting forward towards a v0.5 release.

The current working branch is located at https://negix.net/svn/pdclib/branches/stdio_rewrite - and with "make links", "make all", "make tests", and "make regtests" you'll get a completely clean run - no compiler warnings, no unexpected errors from the testdrivers.

That is, on a 32-bit Linux.

On a 64-bit Linux, you'll get warnings and errors resulting from different type widths - e.g., long being 8 byte instead of 4 byte as stated in _PDCLIB_config.h.

I would be much obliged if someone would go through the sources and fix those problems, so I could provide a 64-bit Linux example config in addition to the existing 32-bit one. I could do it myself, but given the very little time I find to work on PDCLib these days I'd really welcome the help here.

Access to the repository is read-only; you can provide fixes, hints, or patches in any way you like; diff output sent to solar (at) rootdirectory dot de would be preferred.

Thank you!
Last edited by Solar on Fri Oct 24, 2008 12:50 am, edited 1 time in total.
Every good solution is obvious once you've found it.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: PDCLib: Platform configs required

Post by 01000101 »

I can probably help you out with this as I'm going through my own personal libraries and creating the rift between 32 and 64 bit types just for standardization and such. I'll take a look at it tomorrow when I have more time (it is quite late here ATM).
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PDCLib: Platform configs required

Post by Solar »

If someone is bored, a config for Cygwin would also be welcome. I've been doing some work recently on other machines than my own laptop, and found that the "example" platform config isn't as portable as I thought it to be. ;-)
Every good solution is obvious once you've found it.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: PDCLib: Platform configs required

Post by quok »

Solar, out of curiousity, what version of GCC were you using? I just attempted compiling with GCC 4.3.1 (32-bit) and got a few warnings, but they're easily fixed.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PDCLib: Platform configs required

Post by Solar »

The latest stable on Ubuntu is v4.2.4, on Gentoo it's 4.1.2. Since I don't use packages not marked stable unless absolutely necessary, that's what I'm using ATM.
Every good solution is obvious once you've found it.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: PDCLib: Platform configs required

Post by quok »

Solar wrote:The latest stable on Ubuntu is v4.2.4, on Gentoo it's 4.1.2. Since I don't use packages not marked stable unless absolutely necessary, that's what I'm using ATM.
Ah, that explains why I get warnings with GCC 4.3.1, which is what OpenSUSE 11.0 uses, and what is on my Debian Testing box.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PDCLib: Platform configs required

Post by Solar »

Reviving this from the graveyard of time...

By now, there is a 64bit _PDCLIB_config.h available. Unpacking the current branch, calling "make links", copying ./platform/example_64/internals/_PDCLIB_config.h to ./internals, and calling "make pdclib.a" compiles cleanly.

The problem is, the stdarg macros defined in _PDCLIB_config.h, which work just fine on x86, fail dismally on x86_64. Actually, the test driver for them hangs. (And the test driver for malloc(), which relies on stdarg.h, reports false negatives.)

I want to focus on other things for now (like, getting v0.5 done this year), so I would very much welcome it if somebody could check this out, and submit a x86_64 stdarg implementation under Public Domain terms.

Any takers?

PS: Of course I could simply use the GCC builtins. The v1.0 release of the Library will contain appropriate configs for popular compilers, making use of builtins where possible. But the idea behind the "example" platforms is to provide a generic solution that works on as many platforms / compilers as possible.
Every good solution is obvious once you've found it.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: PDCLib: Platform configs required

Post by Combuster »

The problem here is the register calling convention. I don't know how to create a load of macros that determine which register to start, when to switch to the stack, and then I'm not even talking about creating compiler-independent assembly to read register X and sort out the different calling conventions per platform... (see Wikipedia for the details)

Bottom line: I don't believe that you can make a portable stdargs for any register-calling-convention machine.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PDCLib: Platform configs required

Post by Solar »

Combuster wrote:The problem here is the register calling convention...
Yikes! I didn't know that, as I've never toyed with the x86_64 architecture so far.

OK, that's a dead case then. I'll just add the compiler builtins to the config.

Thanks for the info!
Every good solution is obvious once you've found it.
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: PDCLib: Platform configs required

Post by ru2aqare »

Combuster wrote:The problem here is the register calling convention. I don't know how to create a load of macros that determine which register to start, when to switch to the stack, and then I'm not even talking about creating compiler-independent assembly to read register X and sort out the different calling conventions per platform... (see Wikipedia for the details)
I believe most x64 compilers will store arguments back to the stack if they detect that it's address is taken (well at least msvc does this). So I don't think register calling conventions would be that much of an obstacle.
whowhatwhere
Member
Member
Posts: 199
Joined: Sat Jun 28, 2008 6:44 pm

Re: PDCLib: Platform configs required

Post by whowhatwhere »

ru2aqare wrote:
Combuster wrote:The problem here is the register calling convention. I don't know how to create a load of macros that determine which register to start, when to switch to the stack, and then I'm not even talking about creating compiler-independent assembly to read register X and sort out the different calling conventions per platform... (see Wikipedia for the details)
I believe most x64 compilers will store arguments back to the stack if they detect that it's address is taken (well at least msvc does this). So I don't think register calling conventions would be that much of an obstacle.
The calling convention is described quite accurately in the SVR.4 docs.

SVR4/i386 (Original SCO Document): http://www.sco.com/developers/devspecs/abi386-4.pdf
SVR4/i386 (x86-64 supplement): http://www.x86-64.org/documentation/abi.pdf
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: PDCLib: Platform configs required

Post by JamesM »

ru2aqare wrote:
Combuster wrote:The problem here is the register calling convention. I don't know how to create a load of macros that determine which register to start, when to switch to the stack, and then I'm not even talking about creating compiler-independent assembly to read register X and sort out the different calling conventions per platform... (see Wikipedia for the details)
I believe most x64 compilers will store arguments back to the stack if they detect that it's address is taken (well at least msvc does this). So I don't think register calling conventions would be that much of an obstacle.
Correct, the x86-64 calling convention requires a stack address for every argument given, as a spill location. So you could possibly do:

Code: Select all

asm volatile("" : : : "rdi,rsi,rdx,rcx");
To force them to be spilled back to memory. GCC shouldn't create another temporary for them as the shadow space is available...

YMMV, I'd objdump it first!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: PDCLib: Platform configs required

Post by Combuster »

The windows calling convention indeed specifies register spilling space. However, the System V ABI document listed has different semantics, and doesn't define any spilling area. Both of which agrees with Wikipedia, which I already referenced above.

Still, the need for a platform-specific method of either grabbing the registers, or forcing them onto the stack will not help PDClib...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: PDCLib: Platform configs required

Post by Solar »

Well, if the generic implementation doesn't cover x86_64, that's not a problem really. I develop on a 32bit system, and the example platform is primarily for allowing me to actually compile and test the stuff. In the end, the respective platform/toolchain implementations will get their own configs anyway, and until then I'll simply cheat and use the GCC builtins when working on a 64bit platform.

Oh, and by the way... v0.5 is bound to be released soon.

Yes, really, this time. ;-)
Every good solution is obvious once you've found it.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: PDCLib: Platform configs required

Post by Combuster »

Solar wrote:Oh, and by the way... v0.5 is bound to be released soon.

Yes, really, this time. ;-)
:D

/me realises the distance factor messing up the "buying a beer" idea....
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply