This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH 3/3] Use latest <semaphore.h> from FreeBSD for RTEMS
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: newlib at sourceware dot org
- Date: Wed, 11 Mar 2015 13:17:11 +0100 (CET)
- Subject: Re: [PATCH 3/3] Use latest <semaphore.h> from FreeBSD for RTEMS
- Authentication-results: sourceware.org; auth=none
- References: <1425906188-22578-1-git-send-email-sebastian dot huber at embedded-brains dot de> <1425906188-22578-3-git-send-email-sebastian dot huber at embedded-brains dot de> <20150311103330 dot GU5732 at calimero dot vinschen dot de>
----- UrsprÃngliche Mail -----
> Von: "Corinna Vinschen" <vinschen@redhat.com>
> An: newlib@sourceware.org
> Gesendet: Mittwoch, 11. MÃrz 2015 11:33:30
> Betreff: Re: [PATCH 3/3] Use latest <semaphore.h> from FreeBSD for RTEMS
> Hi Sebastian,
>
> On Mar 9 14:03, Sebastian Huber wrote:
>> Import the latest <semaphore.h> from FreeBSD and adjust it for RTEMS.
>> The OpenMP support from GCC (libgomp) needs a <semaphore.h>.
>
> Apart from the maverick implementation in libc/sys/linux, we don't
> have any semaphore implementation. This, plus the fact that the
> type of sem_t is implementaiton-specific, makes me a bit reluctant
> to include this header in newlib. On some systems sizeof(sem_t)
> is pointer sized.
>
> If we add semaphore.h, we should make the definition of sem_t
> conditional somehow, so e.g. Cygwin can reuse this file, removing its
> own.
Since this file is located in the RTEMS specific header file directory
libc/sys/rtems/include/semaphore.h
there should be no disturbance for other systems? We also have a <pthread.h> in Newlib without an implementation in Newlib. During GCC build only Newlib and GCC headers are present, so how else should I build the libgomp?
>
> Kind of like this:
>
>> +#ifndef _SEMAPHORE_H_
>> +#define _SEMAPHORE_H_
>> +
>> +#include <sys/cdefs.h>
>> +#include <sys/_types.h>
>> +
> #ifdef __CYGWIN__
> #ifndef __INSIDE_CYGWIN__
> #endif
> #elif defined (...)
> [...]
> #else
> /* Fallback, as on BSDs */
>> +typedef __uint32_t sem_t;
> #endif
>
>> +
>> +#define SEM_FAILED ((sem_t *)0)
>> +#define SEM_VALUE_MAX (__INT_MAX__ * 2U + 1U)
>
> Should the definition of SEM_VALUE_MAX be __BSD_VISIBLE? It's not a
> definition required or even mentioned in POSIX.
We have a {SEM_VALUE_MAX} here:
http://pubs.opengroup.org/onlinepubs/009695399/functions/sem_open.html
Is this not a define? In FreeBSD it is not covered by __BSD_VISIBLE.