Re: ‘SIG_SETMASK’ and -std=c99

Marco Atzeri marco.atzeri@gmail.com
Sun Aug 6 17:00:00 GMT 2017


On 06/08/2017 18:16, Ken Brown wrote:
> On 8/6/2017 10:51 AM, Marco Atzeri wrote:
>> On 06/08/2017 11:44, Achim Gratz wrote:
>>> The "-std=c*" options are not meant to expose any symbols that are not
>>> defined in the respective C standard.  You almost always want to use
>>> "-std=gnu*" instead if you target POSIX-y systems.
>>
>> formally you are right. However it seems that Cygwin is now
>> more stringent than Linux where this problem does not arise.
>
> That's not what I see on Linux (Scientific Linux 7.2):
>

thanks Ken for the check.

I should have reported the full error

error: ‘SIG_SETMASK’ undeclared (first use in this function)
      #define HDsigsetjmp(J,N)  sigsetjmp(J,N)


from the macro definition in
/usr/include/machine/setjmp.h

It seems sigsetjmp is export anyway and using SIG_SETMASK

---------------------------------------------------
#ifdef __CYGWIN__
/* Per POSIX, siglongjmp has to be implemented as function.  Cygwin
    provides functions for both, siglongjmp and sigsetjmp since 2.2.0. */
extern void siglongjmp (sigjmp_buf, int) __attribute__ ((__noreturn__));
extern int sigsetjmp (sigjmp_buf, int);
#endif

#if defined(__GNUC__)

#define sigsetjmp(env, savemask) \
             __extension__ \
             ({ \
               sigjmp_buf *_sjbuf = &(env); \
               ((*_sjbuf)[_SAVEMASK] = savemask,\
               __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + 
_SIGMASK)),\
               setjmp (*_sjbuf)); \
             })

#define siglongjmp(env, val) \
             __extension__ \
             ({ \
               sigjmp_buf *_sjbuf = &(env); \
               ((((*_sjbuf)[_SAVEMASK]) ? \
                __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + 
_SIGMASK), 0)\
                : 0), \
                longjmp (*_sjbuf, val)); \
             })

#else /* !__GNUC__ */

#define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
                __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + 
_SIGMASK)),\
                setjmp (env))

#define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
                __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + 
_SIGMASK), 0):0),\
                longjmp (env, val))

#endif

------------------------------------------------------

hdf5 seems wrong to use sigsetjmp and C99 but Cygwin seems to
have a consistency issue.

Regards
Marco


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list