Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-01

Two small patchs to fix errors when building under BeOS/Haiku

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Olivier Coursière

Hi,

Here is a couple of patch to fix the build :

- one fix a problem in rtl/beos/tthread.inc
(rtl_beos_tthread.inc_30_03_2008.diff)
- one fix a problem in the packages build system : some dependencies required by fcl-db were not built correctly (packages_30_03_2008.diff).

Olivier

Reply by email

Jonas Maebe
to Olivier Coursière
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);
var
   writeres: cint;
   err: cint;
   b : byte;
begin
   b:=0;
   repeat
     writeres:=fpwrite(PFilDes(FSem)^[1], b, 1);
     err:=fpgeterrno;
   until (writeres-1) or ((errESysEINTR) and (errESysEAgain));
end;

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.

Jonas

Reply by email

Olivier Coursière
to Jonas Maebe

In fact, threading is not yet supposed to work under BeOS. It is just a quick fix to compile. A native BeOS threading implementation would be great as it is one key point under BeOS. But i am not yet there. Haiku has a better posix layer, so cthreads could be an option. But i haven't tried this yet.

Olivier

Jonas Maebe wrote 35 lines
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); var writeres: cint; err: cint; b : byte; begin b:=0; repeat writeres:=fpwrite(PFilDes(FSem)^[1], b, 1); err:=fpgeterrno; until (writeres-1) or ((errESysEINTR) and (errESysEAgain)); end; 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. Jonas_______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email