At 11:55 PM +0200 6/20/03, Jens Rieks wrote:
> (Which in itself tickles and scares the bejesus out of me.) Is there a
 good way of finding the standard C library on a Unix system other than
 hard-wiring it in like this?
Yes. Parrot is linked with the standard C library. You can get a handle for
the own executable by passing a NULL pointer to dlopen. You can also use this
handle to call libc functions.

That's an interesting trick, albeit a very platform-dependent one. I can see adding in support for getting a handle on the current executable (though this is one of the cases where things may behave differently under the interpreter and as a compiled standalope app)


Given all this, I think that an alternate version of loadlib to open the current application is in order. (I'd say it should be a library routine, but since loadlib is already an op it seems in order) Perhaps loadlib with only one argument should give a handle on the current app, with callouts to a platform-specific loading routine. (The dlopen trick won't work on OS X right now, as well as Win32, since we fake out dlopen)

You can not pass a NULL pointer to loadlib at the moment, this small hacks
"converts" an empty string to a NULL pointer to pass it to Parror_dlopen:

I've put in an alternate hack, one that returns NULL from string_to_cstring if passed in a NULL string pointer.
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to