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