[fpc-devel] Two small patchs to fix errors when building under BeOS/Haiku

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Jan 1 20:47:36 CET 2005

On 30 Mar 2008, at 23:08, Olivier Coursière wrote:
> - one fix a problem in rtl/beos/tthread.inc  
> (rtl_beos_tthread.inc_30_03_2008.diff)

You may want to look at cSemaphorePost in rtl/unix/cthreads.pp in the  
case that has_sem_init and has_sem_open are *not* defined. It uses  
this in that case:

procedure cSemaphorePost(const FSem: Pointer);
   writeres: cint;
   err: cint;
   b : byte;
     writeres:=fpwrite(PFilDes(FSem)^[1], b, 1);
   until (writeres<>-1) or ((err<>ESysEINTR) and (err<>ESysEAgain));

The reason is that (on generic unixes at least) the write can be  
interrupted for varying reasons, so you have to keep trying until it  
either succeeds, or terminates with a real error. The same situation  
may exist on Haiku. You have to do things similarly when reading from  
the pipe. Also, if Kaiku has sem_init/sem_destroy or sem_open/ 
sem_close, you can use the semaphore implementation for those also  
from cthreads.


More information about the fpc-devel mailing list