xref: /minix3/external/bsd/pkg_install/dist/lib/defs.h (revision a824f5a1008ee67499d167f8c48e64aae26960ca)
1*a824f5a1SJean-Baptiste Boric /* $NetBSD: defs.h,v 1.3 2012/02/21 18:36:17 wiz Exp $ */
2*a824f5a1SJean-Baptiste Boric 
3*a824f5a1SJean-Baptiste Boric /*-
4*a824f5a1SJean-Baptiste Boric  * Copyright (c) 1999,2000,2009 The NetBSD Foundation, Inc.
5*a824f5a1SJean-Baptiste Boric  * All rights reserved.
6*a824f5a1SJean-Baptiste Boric  *
7*a824f5a1SJean-Baptiste Boric  * This code is derived from software contributed to The NetBSD Foundation
8*a824f5a1SJean-Baptiste Boric  * by Alistair Crooks (agc@NetBSD.org)
9*a824f5a1SJean-Baptiste Boric  *
10*a824f5a1SJean-Baptiste Boric  * Redistribution and use in source and binary forms, with or without
11*a824f5a1SJean-Baptiste Boric  * modification, are permitted provided that the following conditions
12*a824f5a1SJean-Baptiste Boric  * are met:
13*a824f5a1SJean-Baptiste Boric  * 1. Redistributions of source code must retain the above copyright
14*a824f5a1SJean-Baptiste Boric  *    notice, this list of conditions and the following disclaimer.
15*a824f5a1SJean-Baptiste Boric  * 2. Redistributions in binary form must reproduce the above copyright
16*a824f5a1SJean-Baptiste Boric  *    notice, this list of conditions and the following disclaimer in the
17*a824f5a1SJean-Baptiste Boric  *    documentation and/or other materials provided with the distribution.
18*a824f5a1SJean-Baptiste Boric  *
19*a824f5a1SJean-Baptiste Boric  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*a824f5a1SJean-Baptiste Boric  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*a824f5a1SJean-Baptiste Boric  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*a824f5a1SJean-Baptiste Boric  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*a824f5a1SJean-Baptiste Boric  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*a824f5a1SJean-Baptiste Boric  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*a824f5a1SJean-Baptiste Boric  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*a824f5a1SJean-Baptiste Boric  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*a824f5a1SJean-Baptiste Boric  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*a824f5a1SJean-Baptiste Boric  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*a824f5a1SJean-Baptiste Boric  * POSSIBILITY OF SUCH DAMAGE.
30*a824f5a1SJean-Baptiste Boric  */
31*a824f5a1SJean-Baptiste Boric #ifndef DEFS_H_
32*a824f5a1SJean-Baptiste Boric #define DEFS_H_
33*a824f5a1SJean-Baptiste Boric 
34*a824f5a1SJean-Baptiste Boric #if HAVE_CONFIG_H
35*a824f5a1SJean-Baptiste Boric #include "config.h"
36*a824f5a1SJean-Baptiste Boric #endif
37*a824f5a1SJean-Baptiste Boric #include <nbcompat.h>
38*a824f5a1SJean-Baptiste Boric #if HAVE_ERR_H
39*a824f5a1SJean-Baptiste Boric #include <err.h>
40*a824f5a1SJean-Baptiste Boric #endif
41*a824f5a1SJean-Baptiste Boric #if HAVE_STDLIB_H
42*a824f5a1SJean-Baptiste Boric #include <stdlib.h>
43*a824f5a1SJean-Baptiste Boric #endif
44*a824f5a1SJean-Baptiste Boric #if HAVE_STRING_H
45*a824f5a1SJean-Baptiste Boric #include <string.h>
46*a824f5a1SJean-Baptiste Boric #endif
47*a824f5a1SJean-Baptiste Boric 
48*a824f5a1SJean-Baptiste Boric #ifndef MIN
49*a824f5a1SJean-Baptiste Boric #define MIN(a,b)	(((a) < (b)) ? (a) : (b))
50*a824f5a1SJean-Baptiste Boric #endif
51*a824f5a1SJean-Baptiste Boric 
52*a824f5a1SJean-Baptiste Boric #ifndef MAX
53*a824f5a1SJean-Baptiste Boric #define MAX(a,b)	(((a) > (b)) ? (a) : (b))
54*a824f5a1SJean-Baptiste Boric #endif
55*a824f5a1SJean-Baptiste Boric 
56*a824f5a1SJean-Baptiste Boric /*
57*a824f5a1SJean-Baptiste Boric  * Some systems such as OpenBSD-3.6 do not provide PRIu64.
58*a824f5a1SJean-Baptiste Boric  * Others such as AIX-4.3.2 have a broken PRIu64 which includes
59*a824f5a1SJean-Baptiste Boric  * a leading "%".
60*a824f5a1SJean-Baptiste Boric  */
61*a824f5a1SJean-Baptiste Boric #ifdef NEED_PRI_MACRO
62*a824f5a1SJean-Baptiste Boric #  if SIZEOF_INT == 8
63*a824f5a1SJean-Baptiste Boric #    define MY_PRIu64 "u"
64*a824f5a1SJean-Baptiste Boric #  elif SIZEOF_LONG == 8
65*a824f5a1SJean-Baptiste Boric #    define MY_PRIu64 "lu"
66*a824f5a1SJean-Baptiste Boric #  elif SIZEOF_LONG_LONG == 8
67*a824f5a1SJean-Baptiste Boric #    define MY_PRIu64 "llu"
68*a824f5a1SJean-Baptiste Boric #  else
69*a824f5a1SJean-Baptiste Boric #    error "unable to find a suitable PRIu64"
70*a824f5a1SJean-Baptiste Boric #  endif
71*a824f5a1SJean-Baptiste Boric #else
72*a824f5a1SJean-Baptiste Boric #  define MY_PRIu64 PRIu64
73*a824f5a1SJean-Baptiste Boric #endif
74*a824f5a1SJean-Baptiste Boric 
75*a824f5a1SJean-Baptiste Boric #endif /* !DEFS_H_ */
76