xref: /netbsd-src/external/bsd/tcpdump/dist/ftmacros.h (revision c41df9f6167ea7cd2f761f0a97783c8267cb8847)
1d881c474Schristos /*
2d881c474Schristos  * Copyright (c) 1994, 1995, 1996
3d881c474Schristos  *	The Regents of the University of California.  All rights reserved.
4d881c474Schristos  *
5d881c474Schristos  * Redistribution and use in source and binary forms, with or without
6d881c474Schristos  * modification, are permitted provided that the following conditions
7d881c474Schristos  * are met:
8d881c474Schristos  * 1. Redistributions of source code must retain the above copyright
9d881c474Schristos  *    notice, this list of conditions and the following disclaimer.
10d881c474Schristos  * 2. Redistributions in binary form must reproduce the above copyright
11d881c474Schristos  *    notice, this list of conditions and the following disclaimer in the
12d881c474Schristos  *    documentation and/or other materials provided with the distribution.
13d881c474Schristos  * 3. All advertising materials mentioning features or use of this software
14d881c474Schristos  *    must display the following acknowledgement:
15d881c474Schristos  *	This product includes software developed by the Computer Systems
16d881c474Schristos  *	Engineering Group at Lawrence Berkeley Laboratory.
17d881c474Schristos  * 4. Neither the name of the University nor of the Laboratory may be used
18d881c474Schristos  *    to endorse or promote products derived from this software without
19d881c474Schristos  *    specific prior written permission.
20d881c474Schristos  *
21d881c474Schristos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22d881c474Schristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23d881c474Schristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24d881c474Schristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25d881c474Schristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26d881c474Schristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27d881c474Schristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28d881c474Schristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29d881c474Schristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30d881c474Schristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31d881c474Schristos  * SUCH DAMAGE.
32d881c474Schristos  */
33d881c474Schristos 
34d881c474Schristos #ifndef ftmacros_h
35d881c474Schristos #define	ftmacros_h
36d881c474Schristos 
37d881c474Schristos /*
38d881c474Schristos  * Define some feature test macros to make sure that everything we want
39d881c474Schristos  * to be declared gets declared.
40d881c474Schristos  *
41d881c474Schristos  * On some UN*Xes we need to force strtok_r() to be declared.
42d881c474Schristos  * We do *NOT* want to define _POSIX_C_SOURCE, as that tends
43d881c474Schristos  * to make non-POSIX APIs that we use unavailable.
44d881c474Schristos  * XXX - is there no portable way to say "please pollute the
45d881c474Schristos  * namespace to the maximum extent possible"?
46d881c474Schristos  */
47d881c474Schristos #if defined(sun) || defined(__sun)
48d881c474Schristos   /*
49d881c474Schristos    * On Solaris Clang defines __EXTENSIONS__ automatically.
50d881c474Schristos    */
51d881c474Schristos   #ifndef __EXTENSIONS__
52d881c474Schristos     #define __EXTENSIONS__
53d881c474Schristos   #endif
54d881c474Schristos 
55d881c474Schristos   /*
56d881c474Schristos    * We also need to define _XPG4_2 in order to get
57d881c474Schristos    * the Single UNIX Specification version of
58d881c474Schristos    * recvmsg().
59d881c474Schristos    */
60d881c474Schristos   #define _XPG4_2
61d881c474Schristos #elif defined(_hpux) || defined(hpux) || defined(__hpux)
62d881c474Schristos   #define _REENTRANT
63d881c474Schristos 
64d881c474Schristos   /*
65d881c474Schristos    * We need this to get the versions of socket functions that
66d881c474Schristos    * use socklen_t.  Define it only if it's not already defined,
67*c41df9f6Schristos    * so we don't get redefinition warnings.
68d881c474Schristos    */
69d881c474Schristos   #ifndef _XOPEN_SOURCE_EXTENDED
70d881c474Schristos     #define _XOPEN_SOURCE_EXTENDED
71d881c474Schristos   #endif
72d881c474Schristos 
73d881c474Schristos   /*
74d881c474Schristos    * XXX - the list of PA-RISC options for GCC makes it sound as if
75d881c474Schristos    * building code that uses a particular vintage of UNIX API/ABI
76d881c474Schristos    * is complicated:
77d881c474Schristos    *
78d881c474Schristos    *    https://gcc.gnu.org/onlinedocs/gcc/HPPA-Options.html
79d881c474Schristos    *
80d881c474Schristos    * See the description of the -munix flag.
81d881c474Schristos    *
82d881c474Schristos    * We probably want libpcap to work with programs built for any
83d881c474Schristos    * UN*X standard.  I'm not sure whether that's possible and, if
84d881c474Schristos    * it is, what sort of stuff it'd have to do.
85d881c474Schristos    *
86d881c474Schristos    * It might also be a requirement that we build with a special
87d881c474Schristos    * flag to allow the library to be used with threaded code, at
88d881c474Schristos    * least with HP's C compiler; hopefully doing so won't make it
89d881c474Schristos    * *not* work with *un*-threaded code.
90d881c474Schristos    */
91d881c474Schristos #else
92d881c474Schristos   /*
93d881c474Schristos    * Turn on _GNU_SOURCE to get everything GNU libc has to offer,
94d881c474Schristos    * including asprintf(), if we're using GNU libc.
95d881c474Schristos    *
96d881c474Schristos    * Unfortunately, one thing it has to offer is a strerror_r()
97d881c474Schristos    * that's not POSIX-compliant, but we deal with that in
98d881c474Schristos    * pcap_fmt_errmsg_for_errno().
99d881c474Schristos    *
100d881c474Schristos    * We don't limit this to, for example, Linux and Cygwin, because
101d881c474Schristos    * this might, for example, be GNU/HURD or one of Debian's kFreeBSD
102d881c474Schristos    * OSes ("GNU/FreeBSD").
103d881c474Schristos    */
104d881c474Schristos   #define _GNU_SOURCE
105d881c474Schristos 
106d881c474Schristos   /*
107d881c474Schristos    * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get
108d881c474Schristos    * the BSD u_XXX types, such as u_int and u_short, defined.  We
109d881c474Schristos    * define _DEFAULT_SOURCE first, so that newer versions of GNU libc
110d881c474Schristos    * don't whine about _BSD_SOURCE being deprecated; we still have
111d881c474Schristos    * to define _BSD_SOURCE to handle older versions of GNU libc that
112d881c474Schristos    * don't support _DEFAULT_SOURCE.
113d881c474Schristos    *
114d881c474Schristos    * But, if it's already defined, don't define it, so that we don't
115d881c474Schristos    * get a warning of it being redefined if it's defined as, for
116d881c474Schristos    * example, 1.
117d881c474Schristos    */
118d881c474Schristos   #ifndef _DEFAULT_SOURCE
119d881c474Schristos     #define _DEFAULT_SOURCE
120d881c474Schristos   #endif
121d881c474Schristos   /* Avoid redefining _BSD_SOURCE if it's already defined as for ex. 1 */
122d881c474Schristos   #ifndef _BSD_SOURCE
123d881c474Schristos     #define _BSD_SOURCE
124d881c474Schristos   #endif
125d881c474Schristos #endif
126d881c474Schristos 
127d881c474Schristos #endif
128