‘SIG_SETMASK’ and -std=c99

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

‘SIG_SETMASK’ and -std=c99

marco atzeri-4
building again hdf5-1.8.18 on latest cygwin I hit

error: ‘SIG_SETMASK’ undeclared

removing  "-std=c99" from CFLAGS solves the issue.

As before the "-std=c99" was not causing any problem , it is not clear
to me if the current behavior is correct or a side effect of latest
cygwin header reshuffle.

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ‘SIG_SETMASK’ and -std=c99

Achim Gratz
Marco Atzeri writes:
> building again hdf5-1.8.18 on latest cygwin I hit
>
> error: ‘SIG_SETMASK’ undeclared
>
> removing  "-std=c99" from CFLAGS solves the issue.

https://stackoverflow.com/questions/20849917/invalid-signal-processing-library-in-linux

> As before the "-std=c99" was not causing any problem , it is not clear
> to me if the current behavior is correct or a side effect of latest
> cygwin header reshuffle.

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.


Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs

--
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ‘SIG_SETMASK’ and -std=c99

marco atzeri-4
On 06/08/2017 11:44, Achim Gratz wrote:
> Marco Atzeri writes:
>> building again hdf5-1.8.18 on latest cygwin I hit
>>
>> error: ‘SIG_SETMASK’ undeclared
>>
>> removing  "-std=c99" from CFLAGS solves the issue.
>
> https://stackoverflow.com/questions/20849917/invalid-signal-processing-library-in-linux

That is not very informative as signal.h is in C99.
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf

however SIG_SETMASK is not
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html

>
>> As before the "-std=c99" was not causing any problem , it is not clear
>> to me if the current behavior is correct or a side effect of latest
>> cygwin header reshuffle.
>
> 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.


> Regards,
> Achim.

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ‘SIG_SETMASK’ and -std=c99

Ken Brown-6
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):

$ cat test.c
#include <signal.h>
#include <stdio.h>

int
main ()
{
#ifdef SIG_SETMASK
   printf ("SIG_SETMASK is defined.\n");
#else
   printf ("SIG_SETMASK is not defined.\n");
#endif
}

$ gcc -o test test.c

$ gcc -std=c99 -o test_c99 test.c

$ ./test
SIG_SETMASK is defined.

$ ./test_c99
SIG_SETMASK is not defined.

Ken

--
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ‘SIG_SETMASK’ and -std=c99

marco atzeri-4
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ‘SIG_SETMASK’ and -std=c99

Ken Brown-6
On 8/6/2017 12:59 PM, Marco Atzeri wrote:
> hdf5 seems wrong to use sigsetjmp and C99 but Cygwin seems to
> have a consistency issue.

I think you're right that Cygwin shouldn't declare or define sigsetjmp
under -std=c99.  Here's a simple test:

$ cat test.c
#include <setjmp.h>

int
main ()
{
   sigjmp_buf env;
   sigsetjmp (env, 0);
}

On Cygwin:

$ gcc -std=c99 test.c
In file included from /usr/include/setjmp.h:10:0,
                  from test.c:1:
test.c: In function ‘main’:
test.c:7:3: error: ‘SIG_SETMASK’ undeclared (first use in this function)
    sigsetjmp (env, 0);
    ^

On Linux:

$ gcc -std=c99 test.c
test.c: In function ‘main’:
test.c:6:3: error: unknown type name ‘sigjmp_buf’
    sigjmp_buf env;
    ^
test.c:7:3: warning: implicit declaration of function ‘sigsetjmp’
[-Wimplicit-function-declaration]
    sigsetjmp (env, 0);
    ^

Ken

--
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ‘SIG_SETMASK’ and -std=c99

Ken Brown-6
On 8/6/2017 4:43 PM, Ken Brown wrote:

> On 8/6/2017 12:59 PM, Marco Atzeri wrote:
>> hdf5 seems wrong to use sigsetjmp and C99 but Cygwin seems to
>> have a consistency issue.
>
> I think you're right that Cygwin shouldn't declare or define sigsetjmp
> under -std=c99.  Here's a simple test:
>
> $ cat test.c
> #include <setjmp.h>
>
> int
> main ()
> {
>    sigjmp_buf env;
>    sigsetjmp (env, 0);
> }
>
> On Cygwin:
>
> $ gcc -std=c99 test.c
> In file included from /usr/include/setjmp.h:10:0,
>                   from test.c:1:
> test.c: In function ‘main’:
> test.c:7:3: error: ‘SIG_SETMASK’ undeclared (first use in this function)
>     sigsetjmp (env, 0);
>     ^
>
> On Linux:
>
> $ gcc -std=c99 test.c
> test.c: In function ‘main’:
> test.c:6:3: error: unknown type name ‘sigjmp_buf’
>     sigjmp_buf env;
>     ^
> test.c:7:3: warning: implicit declaration of function ‘sigsetjmp’
> [-Wimplicit-function-declaration]
>     sigsetjmp (env, 0);

I've submitted a patch
(https://cygwin.com/ml/cygwin-patches/2017-q3/msg00014.html) which makes
the behavior on Cygwin the same as on Linux.

Ken


--
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

Loading...