This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: RFA: SIG_ERR in libf2c/libU77


Zack Weinberg <zackw@stanford.edu> wrote:

> Sorry, no, this is not portable to systems that do define SIG_ERR.
> SIG_ERR is specified by C99 7.14p3 (and C89) merely as a constant
> expression of suitable type to be compared to the return value of
> signal.  It is not required to be (void (*)(int)) -1.
>
> (Incidentally, you cannot make a legitimate argument for portability
> based on what is or isn't a system call on one particular platform.)

First, before you start thinking that my argument is based on signal being a
syscall on 4.3BSD, it isn't. (signal is not a syscall on 4.3BSD, it's a wrapper
around the BSD sigvec syscall.) With this out of the way, my actual reasoning
was that signal *was* a syscall when it first saw the light of day, so whatever
the paperheads and their standards say, it has always returned -1 on error from
day 0.

> Better you should insert
>
> #ifndef SIG_ERR
> #define SIG_ERR ((sig_type) -1)
> #endif
>
> right after the line that reads
>
> typedef RETSIGTYPE (*sig_type) ();

That's what I thought first, but if you look closely, just inserting those
lines where you suggest might not work the way you want. Look at the hair just
below dealing with KR_headers. The net effect of this hair is that if one does
what you suggest, the check for whether SIG_ERR is defined or not comes before
#include <signal.h>. I have no idea (and don't care) where the "standards" say
SIG_ERR is supposed to be defined, but if it's in <signal.h> your solution
probably won't do what you want (support broken but standards-compliant systems
with SIG_ERR != -1).

-- 
Michael Sokolov
Public Service Agent
International Engineering and Science Task Force

1351 VINE AVE APT 27		Phone: +1-714-738-5409
FULLERTON CA 92833-4291 USA	(home office)

E-mail: msokolov@ivan.Harhan.ORG (ARPA TCP/SMTP)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]