[fpc-devel] how to get same pthreads code to compile between Linux and FreeBSD
Marco van de Voort
marcov at stack.nl
Sun Feb 3 19:08:34 CET 2013
In our previous episode, Graeme Geldenhuys said:
> In FreeBSD sem_t is pointer. Isn't that what psem_t is for?
No. That is a pointer to sem_t. It doesn't specify what sem_t should be.
struct sem;
typedef struct sem * sem_t;
_sem_ is the record, sem_t is a pointer.
> So under
> FreeBSD sem_t should be defined as
> sem_t_rec = record
> end;
> sem_t = sem_t_rec;
> psem_t = ^sem_t;
> I would expect unix-types / posix-types supposed to be defined the same
> in all such related OSes (eg: *BSD, Linux, MacOSX, Haiku, *nix)?
The reality is afaik that sem_t is abstract in POSIX. Keep in mind that
POSIX is not an API, but more a set of common requirements for an api.
Assuming the type should not be
necessary. The VAR variants are probably leftovers from 1.0.x when headers
were pascalized as much as possible.
During the *nix RTL reform of what would become 2.0 I insisted to at least
have the pointer variant alongside of the 1.0.x declarations (to make
examples in C translate 1:1)
The resulting overloading can cause problems. It can be reduced by
deprecating the original pascallized versions, and removing them in some
future version.
More information about the fpc-devel
mailing list