Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Mar 2001 15:33:52 -0800
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Alfred Perlstein <bright@wintelcom.net>
Cc:        Farooq Mela <fmela0@sm.socccd.cc.ca.us>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: pthread_exit proto
Message-ID:  <20010304153352.A8837@Odin.AC.HMC.Edu>
In-Reply-To: <20010304115811.Q8663@fw.wintelcom.net>; from bright@wintelcom.net on Sun, Mar 04, 2001 at 11:58:11AM -0800
References:  <3AA29546.7D709D6@sm.socccd.cc.ca.us> <20010304115811.Q8663@fw.wintelcom.net>

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

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Mar 04, 2001 at 11:58:11AM -0800, Alfred Perlstein wrote:
> using send-pr:
> http://www.freebsd.org/support.html#gnats
>=20
> Is '__dead2' a GNU C thing?  or is in any sort of standard?
>=20
> Generally there's some resistance to putting GNU C specific
> code into the base system, is there a portable way to do this?

__dead2 is the FreeBSD (BSD?) way of writing this.  It's an attempt to
do so in a way that can be compiler independent, but in reality it's
not.  Microsoft supports something like __dead2, but places the modifer
before the delceration in an __declspec() macro so __dead2 won't work.
They do not provide any format string checking at all.  Other vendors
(Sun and SGI for example) provide format string checking via magic
comments on the line before the function, but no support for functions
that don't return.  As someone else pointed out, some compilers provide
this via the #pragma stuff, but you can't use any pragmas but the ones
defined by the ANSI/ISO standard in portable code and you can't use
#ifdef's to shield them.  Since we're already using __dead2 and
__printflike type things all over the source, we might as well keep
doing so, but fundamentaly this stuff is GCC specific.  ANSI/ISO screwed
us on this one. :-(  Either the GCC or Microsoft option would be fine,
but without a standard we're pretty screwed.  I've got code that gets
developed with both GCC and Visual C compilers which least to crap like
this:

/*
 * GCC (and some other compilers) define '__attribute__'; we're using this
 * macro to alert the compiler to flag inconsistencies in printf/scanf-like
 * function calls.  Just in case '__attribute__' isn't defined, make a dumm=
y.
 * G++ doesn't accept it anyway.
 */
#if !defined(__GNUC__) && !defined(__attribute__)
#define __attribute__(p) /* nothing */
#endif
/*
 * Microsoft and Borland use __declspec for purposes similar to GCC's
 * __attribute__ support.  Unfortunatly, the use it before the
 * decleration rather then after it so we need to define it seperatly.
 * Also, they don't support printf or scanf format checking.
 */
#if !((defined(_MSC_VER) && defined(_WIN32)) || (defined(__BORLANDC__)
&& define
d(__WIN32__)))
#define __declspec(p) /* nothing */
#endif

__declspec(noreturn)
void casp_error(const char *format, ...)
         __attribute__ ((__noreturn__))
        __attribute__ ((__format__ (__printf__, 1, 2)));

Actually, that should probably have a magic comment as well so support
SGI and Sun format checking, but I just couldn't bring my self to add
that as well since those are operation platforms not dev platforms.

-- Brooks

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--PNTmBPCT7hxwcZjr
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6otDfXY6L6fI4GtQRAgMuAJ9Xg2+YL9SfI5YN5BrOQ6CcHsd7fQCeLxlJ
ekT3dpuA7OdN/4BBp5oQwX4=
=pjS/
-----END PGP SIGNATURE-----

--PNTmBPCT7hxwcZjr--

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010304153352.A8837>