Solaris portability - PATCH - getprogname shim support
Falling back to retrieving program name for libdispatch debug file using getexecname() for Solaris. Also made the fallback getprogname function return a ‘const’ string to the program name to avoid warnings. Cheers, Joakim octo.tbricks.com:gcd/gcd/trunk> svn up At revision 188. octo.tbricks.com:gcd/gcd/trunk> svn diff Index: configure.ac =================================================================== --- configure.ac (revision 188) +++ configure.ac (working copy) @@ -193,7 +193,7 @@ AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]]) AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]]) AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]]) -AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf getprogname]) +AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf getprogname getexecname]) AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED], [have_posix_spawn_start_suspended=true], Index: src/shims/getprogname.h =================================================================== --- src/shims/getprogname.h (revision 188) +++ src/shims/getprogname.h (working copy) @@ -23,15 +23,19 @@ #define __DISPATCH_SHIMS_GETPROGNAME__ #ifndef HAVE_GETPROGNAME -static inline char * + +static inline const char * getprogname(void) { # if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME return program_invocation_short_name; +#elif HAVE_GETEXECNAME + return getexecname(); # else # error getprogname(3) is not available on this platform # endif } + #endif /* HAVE_GETPROGNAME */ #endif /* __DISPATCH_SHIMS_GETPROGNAME__ */ octo.tbricks.com:gcd/gcd/trunk>
On 07/23/2010 11:11 AM, Joakim Johansson wrote:
Falling back to retrieving program name for libdispatch debug file using getexecname() for Solaris.
Also made the fallback getprogname function return a ‘const’ string to the program name to avoid warnings.
As an alternative, I solved a lot of libdispatch portability problems on Linux by using libbsd: http://libbsd.freedesktop.org/wiki/ It includes getprogname(), fgetln(), the <sys/queue.h> macros, and arc4random(). Not sure if this has been ported to Solaris, but it might be helpful. - Mark
Thanks for the pointer - unfortunately it seems to be Linux only. The good news is that the main libdispatch sources now build and link on solaris when built together with my local bastardized stubbed out version of libkqueue - with a single problem in configure.ac in one of the m4 scripts for libdispatch - hope to sort that out next week. I'll try to see if I can polish things up and give you some patches for libkqueue as well. What remains now is also to get a few of the libdispatch unit tests portable as well, but I've now managed to compile, link and run over half of them with some success... :-) The bulk of the work after that will be to get libkqueue robust on solaris. Of course, there is also that little matter of testing and debugging the full solution :-)! Cheers, Joakim This email was sent from my iPhone, so it may be unusually terse. On 24 jul 2010, at 00:55, Mark Heily <mark@heily.com> wrote:
On 07/23/2010 11:11 AM, Joakim Johansson wrote:
Falling back to retrieving program name for libdispatch debug file using getexecname() for Solaris.
Also made the fallback getprogname function return a ‘const’ string to the program name to avoid warnings.
As an alternative, I solved a lot of libdispatch portability problems on Linux by using libbsd:
http://libbsd.freedesktop.org/wiki/
It includes getprogname(), fgetln(), the <sys/queue.h> macros, and arc4random().
Not sure if this has been ported to Solaris, but it might be helpful.
- Mark
_______________________________________________ libdispatch-dev mailing list libdispatch-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
On Sat, 24 Jul 2010, Joakim Johansson wrote:
The bulk of the work after that will be to get libkqueue robust on solaris.
I think I wouldn't be incorrect in saying that kqueue is the epicentre of GCD, and Apple's minor tweaks to the kqueue API (now also adopted in FreeBSD) were critical to its success there. The lack of kqueue or similarly capable solutions on other operating systems is the primary barrier to portability. One thing clearly missing from the current libdispatch API, possibly because kqueue on Mac OS X doesn't support it, is an async I/O interface: i.e., do this I/O and call me back when you're done, vs do this I/O and call me back if there's more data to read/can be written. Mac OS X's kqueue doesn't support POSIX async I/O as an event source, but the FreeBSD version of kqueue does. I'm actually unsure if Mac OS X supports POSIX async I/O at all, now that I think about it. In any case, it would be neat to teach GCD about that on supporting platforms. Robert
On 07/23/2010 10:44 PM, Joakim Johansson wrote:
The bulk of the work after that will be to get libkqueue robust on solaris.
I've started working on this, and the trunk of libkqueue now compiles on Solaris. Most of the functionality is broken, but it's a start. The "event ports" subsystem of Solaris is very similar to kqueue, and I expect the rest of the porting effort to go pretty smoothly. There's a couple of obstacles: 1. Solaris ships with GCC 3.4 which doesn't have atomic builtins 2. OpenSolaris has an equivalent to EVFILT_VNODE but Solaris doesn't. I'm hoping to release libkqueue 0.9 with Solaris support in the next few weeks. Regards, - Mark
participants (3)
-
Joakim Johansson
-
Mark Heily
-
Robert Watson