[fpc-devel] Why FreeBSD sem_init() works different to Linux?

Sven Barth pascaldragon at googlemail.com
Mon Feb 4 14:54:10 CET 2013


Am 04.02.2013 13:40, schrieb Henry Vermaak:
> On Mon, Feb 04, 2013 at 11:47:48AM +0000, Graeme Geldenhuys wrote:
>> Hi,
>>
>> I found another problem with Semaphores between FreeBSD and Linux.
>>
>> Attached is my test project. Again, it is similar code used in tiOPF.
>>
>> For some reason under FreeBSD, it *always* zeros the variable that holds
>> the Max Pool Size value passed in to sem_init()'s third parameter. This
>> means that if I try and us that variable anywhere after the sem_init()
>> call, like when I want to destroy the semaphore, I can't because the
>> variable now holds the value 0.
> FPC's definition of the semaphore struct is probably wrong for FreeBSD.
> Currently, it's:
>
> sem_t = cint;
You are in so far right that the declaration is incorrect, but in trunk 
it looks like this:

=== code begin ===

sem_t_rec = record end;
sem_t = ^sem_t_rec;

=== code end ===

So that it resembles the declaration of sem_t in the headers of FreeBSD 7:

=== code begin ===

typedef struct sem * sem_t;

=== code end ===

Nevertheless this needs to be changed...

Regards,
Sven



More information about the fpc-devel mailing list