[fpc-pascal] Semaphore

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Feb 12 15:05:30 CET 2008

On 12 Feb 2008, at 14:54, Damien Gerard wrote:

> Le Feb 12, 2008 à 2:44 PM, Jonas Maebe a écrit :
>> No, you can't, because sem_init does not exist on Mac OS X. Use the  
>> RTL implementation, it works on all platforms. Further, the above  
>> code looks buggy because it always calls sem_destroy for  
>> FSemaphore, even it was not allocated (and that may cause the  
>> program to crash, depending on the contents of FSemaphore at that  
>> point and the implementation of sem_init).
> sem_* don't came from pthreads ?

"The sem_init() function is part of the Semaphores option and need not  
be available on all implementations"

> Under OS X you can do
> {$ifdef unix}
> uses
> cthreads;
> {$endif}
> I thought it would follow the same behavior. But I agree RTL is my  
> friend :)

cthreads is not required to directly call any posix routines. It is  
required to call the RTL versions of the thread-related routines;


More information about the fpc-pascal mailing list