Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jan 2000 08:01:49 -0500
From:      "Mikhail Evstiounin" <evstiounin@adelphia.net>
To:        <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Giving a sighandler more information
Message-ID:  <00eb01bf5dc6$5adffe00$fc353018@evstiouninadelphia.net.pit.adelphia.net>

next in thread | raw e-mail | index | archive | help

-----Original Message-----
From: Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de>
To: freebsd-questions@FreeBSD.ORG <freebsd-questions@FreeBSD.ORG>
Date: Wednesday, January 12, 2000 11:42 PM
Subject: Re: Giving a sighandler more information


>Mikhail Evstiounin <evstiounin@adelphia.net> wrote in
list.freebsd-questions:
> > From: Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de>
> >>Laurence Berland <stuyman@confusion.net> wrote in
list.freebsd-questions:
> >> > Followup question: is a sig_atomic_t appropriate to hold the value of
a
> >> > FILE * ?
> >>
> >>No.  It is only guaranteed to be large enough to hold an int.
> >>Of course, on intel PCs, a pointer has the same size as an int,
> >>but not on other platforms (e.g. the Alpha).  Therefore,
> >>portable programs cannot store a pointer in a sig_atomic_t.
> >
> > Sorry, guys, but it requirenments of ANSI that
sizeof(void*)==sizeof(int).
>
>No!  A program which assumes that an int is large enough to
>store a pointer is BROKEN.  See this simple test program:


Oliver, IT'S A REQUIRIMENTS OF  THE STANDARD!!! - NOT MY WISH!!!
And Alpha compiler just plain violates this standard (BTW, didn't check
recent
C standard - C99 or C98). This requirement was in there for the purpose -
portability.

>
>   #include <stdio.h>
>   int main (int argc, char *argv[]) {
>           printf("sizeof(int)   == %d\n", sizeof(int));
>           printf("sizeof(void*) == %d\n", sizeof(void*));
>           return 0;
>   }
>
>On an Alpha (64bit), the result is:
>
>   sizeof(int)   == 4
>   sizeof(void*) == 8
>
>That was compiled with DEC's C compiler in -std1 mode.  This
>is one of the most ANSI/ISO-compliant compilers that I'm aware
>of.  (Note that gcc is not that ANSI-compliant.)
>

Agreed. This is a real life. But take a look at the standard:
sizeof(short)<=sizeof(int)<=sizeof(long) and sizeof(void*)==sizeof(int).
GCC team is very accurate - if they know that they have something
incompatible
with ANSI standard they always tell it - there is a whole document in
distributuive
that states what is different and why GCC team thinks it should be
different.

> > and question does it mean that alpha integer is 32 bit, or pointer has
more
> > than 64?
>
>See above.  ints are 32 bits, pointers are 64 bits.


Thanx.

>And this is perfectly within ANSI spec.


My reading of ANSI is slightly different. As someone who participate in
writing of 5
compilers I worked with standards a lot. But I didn't do it anymore since
1995.
And since then C commmitte added a lot of stuff to new standard. Could you
point me to the ANSI standard you are refence to? I was talking about, I
believe,
C89.

>
>Regards
>   Oliver
>
>--
>Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany
>(Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de)
>
>"In jedem Stück Kohle wartet ein Diamant auf seine Geburt"
>                                         (Terry Pratchett)
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-questions" in the body of the message



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00eb01bf5dc6$5adffe00$fc353018>