I am compiling dbus 1.5.6 on Solaris 9 Sparc with Sun Studio 12 and encountered a compilation error about missing CMSG_SPACE and CMSG_LEN:
Undefined first referenced
symbol in file
These tiny definitions in dbus/dbus-sysdeps-unix.c fix the issue:
#define CMSG_SPACE(l) ((size_t)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l)))
#define CMSG_LEN(l) ((size_t)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l))
Best regards -- Dago
A slightly better fix is posted here: http://wiki.opencsw.org/porting-faq#toc10
In the version you linked:
# ifdef __sun__
# define CMSG_ALIGN _CMSG_DATA_ALIGN
# define CMSG_ALIGN(len) (((len)+sizeof(long)-1) & ~(sizeof(long)-1))
the _CMSG_DATA_ALIGN macro is only assumed to be present if __sun__ is defined, which (according to that porting FAQ) is only the case under gcc, and not under Sun Studio. Should we be looking for __sun there, too?
I'd prefer to only enable this workaround on Solaris for the moment, unless/until someone reports that it affects some other OS. The generic code path (aligning to the next 'long' boundary) looks a bit suspicious to me - on LP64 platforms, a kernel could equally well be expecting 32-bit alignment - but I'd be OK with using it on Solaris.
I'll attach a patch in a moment.
Created attachment 50480 [details] [review]
On Solaris, define CMSG_ALIGN, CMSG_LEN, CMSG_SPACE if undefined
This patch is against dbus-1.4 but should apply equally well to master.
Dago, does this look OK to you / work correctly on Solaris 9?
However, I note that according to Wikipedia, Solaris 10 is 6 years old (and is the first version to work on x86-64, which seems like a reasonable milestone for "still relevant"), and Solaris *11* (Express) is nearly a year old. I'm not entirely convinced we should be merging patches to work around deficiencies of a superseded, 8 year old libc... defining subtleties of the kernel/userland cmsg interface is surely the OS's job, not ours?
Yes, the patch applies cleanly and works. Thanks!
Solaris 9 is still fully supported with a basic support contract and Solaris 11 has not been released at all apart from the "express" developer beta. Blaming the os vendor may be essentially right, but it doesn't help when people try to build the software. Working around os problems is not that unusual in ensuring portability :-)
Fixed in git for 1.4.16 and 1.5.8, thanks