[libdispatch-dev] [PATCH 09/17] portability

Joakim Johansson jocke at tbricks.com
Wed Oct 28 11:03:22 PDT 2009


I agree, it would be a good change for robustness, on Solaris 10 it is  
not a scalar even - I had the following code in my local porting tree  
while still figuring things out for later revisiting:

-------------

static void
_dispatch_posix_semaphore_create(sem_t *s4)
{
	int ret;

/*
    Commented this out for Solaris port, as sem_t is a structure on  
solaris and not a scalar.
    This check seems unclear semantically, as it assumes that sem_t is  
of a certain type.

    if (*s4) {
		return;
	}
*/
	ret = sem_init(s4, 0, 0);
	dispatch_assume_zero(ret);
}
-------------


Joakim


On 28 okt 2009, at 18.41, Robert Watson wrote:

>
> On Sun, 18 Oct 2009, Paolo Bonzini wrote:
>
>> - sem_t is not a scalar under Linux, check if initialized with memcmp
>
> With the assumpion that sem_t was a pointer, I was OK with the  
> current code (as it made similar assumptions to the Mach semaphore  
> parts).  However, with other possible interpretations of sem_t, I'm  
> less comfortable with the assumption that a value of zero reflects  
> an invalid (or rather, unallocated) semaphore, since it could well  
> be a valid semaphore ID if semaphores are file descriptors.  Any  
> chance I could convince you to refactor the code to eliminate this  
> assumption (perhaps an explicit "allocated" flag?).
>
> Robert
> _______________________________________________
> libdispatch-dev mailing list
> libdispatch-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev




More information about the libdispatch-dev mailing list