xref: /dragonfly/contrib/libpcap/ftmacros.h (revision ea16f64e)
13a289941SAaron LI /*
23a289941SAaron LI  * Copyright (c) 1994, 1995, 1996
33a289941SAaron LI  *	The Regents of the University of California.  All rights reserved.
43a289941SAaron LI  *
53a289941SAaron LI  * Redistribution and use in source and binary forms, with or without
63a289941SAaron LI  * modification, are permitted provided that the following conditions
73a289941SAaron LI  * are met:
83a289941SAaron LI  * 1. Redistributions of source code must retain the above copyright
93a289941SAaron LI  *    notice, this list of conditions and the following disclaimer.
103a289941SAaron LI  * 2. Redistributions in binary form must reproduce the above copyright
113a289941SAaron LI  *    notice, this list of conditions and the following disclaimer in the
123a289941SAaron LI  *    documentation and/or other materials provided with the distribution.
133a289941SAaron LI  * 3. All advertising materials mentioning features or use of this software
143a289941SAaron LI  *    must display the following acknowledgement:
153a289941SAaron LI  *	This product includes software developed by the Computer Systems
163a289941SAaron LI  *	Engineering Group at Lawrence Berkeley Laboratory.
173a289941SAaron LI  * 4. Neither the name of the University nor of the Laboratory may be used
183a289941SAaron LI  *    to endorse or promote products derived from this software without
193a289941SAaron LI  *    specific prior written permission.
203a289941SAaron LI  *
213a289941SAaron LI  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
223a289941SAaron LI  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
233a289941SAaron LI  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
243a289941SAaron LI  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
253a289941SAaron LI  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
263a289941SAaron LI  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
273a289941SAaron LI  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
283a289941SAaron LI  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
293a289941SAaron LI  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
303a289941SAaron LI  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
313a289941SAaron LI  * SUCH DAMAGE.
323a289941SAaron LI  */
333a289941SAaron LI 
343a289941SAaron LI #ifndef ftmacros_h
353a289941SAaron LI #define	ftmacros_h
363a289941SAaron LI 
373a289941SAaron LI /*
383a289941SAaron LI  * Define some feature test macros to make sure that everything we want
393a289941SAaron LI  * to be declared gets declared.
403a289941SAaron LI  *
413a289941SAaron LI  * On some UN*Xes we need to force strtok_r() to be declared.
423a289941SAaron LI  * We do *NOT* want to define _POSIX_C_SOURCE, as that tends
433a289941SAaron LI  * to make non-POSIX APIs that we use unavailable.
443a289941SAaron LI  * XXX - is there no portable way to say "please pollute the
453a289941SAaron LI  * namespace to the maximum extent possible"?
463a289941SAaron LI  */
473a289941SAaron LI #if defined(sun) || defined(__sun)
483a289941SAaron LI   #define __EXTENSIONS__
493a289941SAaron LI 
503a289941SAaron LI   /*
513a289941SAaron LI    * We also need to define _XPG4_2 in order to get
523a289941SAaron LI    * the Single UNIX Specification version of
533a289941SAaron LI    * recvmsg().
543a289941SAaron LI    */
553a289941SAaron LI   #define _XPG4_2
563a289941SAaron LI #elif defined(_hpux) || defined(hpux) || defined(__hpux)
573a289941SAaron LI   #define _REENTRANT
583a289941SAaron LI 
593a289941SAaron LI   /*
603a289941SAaron LI    * We need this to get the versions of socket functions that
613a289941SAaron LI    * use socklen_t.  Define it only if it's not already defined,
623a289941SAaron LI    * so we don't get redefiniton warnings.
633a289941SAaron LI    */
643a289941SAaron LI   #ifndef _XOPEN_SOURCE_EXTENDED
653a289941SAaron LI     #define _XOPEN_SOURCE_EXTENDED
663a289941SAaron LI   #endif
673a289941SAaron LI 
683a289941SAaron LI   /*
693a289941SAaron LI    * XXX - the list of PA-RISC options for GCC makes it sound as if
703a289941SAaron LI    * building code that uses a particular vintage of UNIX API/ABI
713a289941SAaron LI    * is complicated:
723a289941SAaron LI    *
733a289941SAaron LI    *    https://gcc.gnu.org/onlinedocs/gcc/HPPA-Options.html
743a289941SAaron LI    *
753a289941SAaron LI    * See the description of the -munix flag.
763a289941SAaron LI    *
773a289941SAaron LI    * We probably want libpcap to work with programs built for any
783a289941SAaron LI    * UN*X standard.  I'm not sure whether that's possible and, if
793a289941SAaron LI    * it is, what sort of stuff it'd have to do.
803a289941SAaron LI    *
813a289941SAaron LI    * It might also be a requirement that we build with a special
823a289941SAaron LI    * flag to allow the library to be used with threaded code, at
833a289941SAaron LI    * least with HP's C compiler; hopefully doing so won't make it
843a289941SAaron LI    * *not* work with *un*-threaded code.
853a289941SAaron LI    */
86*ea16f64eSAntonio Huete Jimenez #else
873a289941SAaron LI   /*
883a289941SAaron LI    * Turn on _GNU_SOURCE to get everything GNU libc has to offer,
89*ea16f64eSAntonio Huete Jimenez    * including asprintf(), if we're using GNU libc.
903a289941SAaron LI    *
913a289941SAaron LI    * Unfortunately, one thing it has to offer is a strerror_r()
923a289941SAaron LI    * that's not POSIX-compliant, but we deal with that in
933a289941SAaron LI    * pcap_fmt_errmsg_for_errno().
94*ea16f64eSAntonio Huete Jimenez    *
95*ea16f64eSAntonio Huete Jimenez    * We don't limit this to, for example, Linux and Cygwin, because
96*ea16f64eSAntonio Huete Jimenez    * this might, for example, be GNU/HURD or one of Debian's kFreeBSD
97*ea16f64eSAntonio Huete Jimenez    * OSes ("GNU/FreeBSD").
983a289941SAaron LI    */
993a289941SAaron LI   #define _GNU_SOURCE
1003a289941SAaron LI 
1013a289941SAaron LI   /*
1023a289941SAaron LI    * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get
1033a289941SAaron LI    * the BSD u_XXX types, such as u_int and u_short, defined.  We
1043a289941SAaron LI    * define _DEFAULT_SOURCE first, so that newer versions of GNU libc
1053a289941SAaron LI    * don't whine about _BSD_SOURCE being deprecated; we still have
1063a289941SAaron LI    * to define _BSD_SOURCE to handle older versions of GNU libc that
1073a289941SAaron LI    * don't support _DEFAULT_SOURCE.
108*ea16f64eSAntonio Huete Jimenez    *
109*ea16f64eSAntonio Huete Jimenez    * But, if it's already defined, don't define it, so that we don't
110*ea16f64eSAntonio Huete Jimenez    * get a warning of it being redefined if it's defined as, for
111*ea16f64eSAntonio Huete Jimenez    * example, 1.
1123a289941SAaron LI    */
113*ea16f64eSAntonio Huete Jimenez   #ifndef _DEFAULT_SOURCE
1143a289941SAaron LI     #define _DEFAULT_SOURCE
115*ea16f64eSAntonio Huete Jimenez   #endif
116*ea16f64eSAntonio Huete Jimenez   /* Avoid redefining _BSD_SOURCE if it's already defined as for ex. 1 */
117*ea16f64eSAntonio Huete Jimenez   #ifndef _BSD_SOURCE
1183a289941SAaron LI     #define _BSD_SOURCE
1193a289941SAaron LI   #endif
120*ea16f64eSAntonio Huete Jimenez #endif
1213a289941SAaron LI 
1223a289941SAaron LI #endif
123