1 /*
2  * Copyright (C) 2014, The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #include <stdbool.h>
30 #include <sys/types.h>
31 
32 /* We want chown to support user.group as well as user:group. */
33 #define SUPPORT_DOT
34 
35 /* We don't localize /system/bin! */
36 #define WITHOUT_NLS
37 
38 // NetBSD uses _DIAGASSERT to null-check arguments and the like.
39 #include <assert.h>
40 #define _DIAGASSERT(e) ((e) ? (void) 0 : __assert2(__FILE__, __LINE__, __func__, #e))
41 
42 // TODO: update our <sys/cdefs.h> to support this properly.
43 #define __type_fit(t, a) (0 == 0)
44 
45 // TODO: should this be in our <sys/cdefs.h>?
46 #define __arraycount(a) (sizeof(a) / sizeof(a[0]))
47 
48 // This at least matches GNU dd(1) behavior.
49 #define SIGINFO SIGUSR1
50 
51 #define S_ISWHT(x) false
52 
53 __BEGIN_DECLS
54 
55 /* From NetBSD <stdlib.h>. */
56 #define HN_DECIMAL              0x01
57 #define HN_NOSPACE              0x02
58 #define HN_B                    0x04
59 #define HN_DIVISOR_1000         0x08
60 #define HN_GETSCALE             0x10
61 #define HN_AUTOSCALE            0x20
62 int	humanize_number(char *, size_t, int64_t, const char *, int, int);
63 int	dehumanize_number(const char *, int64_t *);
64 char	*getbsize(int *, long *);
65 long long strsuftoll(const char *, const char *, long long, long long);
66 long long strsuftollx(const char *, const char *, long long, long long,
67 			char *, size_t);
68 
69 /* From NetBSD <string.h>. */
70 void strmode(mode_t, char*);
71 
72 /* From NetBSD <sys/param.h>. */
73 #define MAXBSIZE 65536
74 
75 /* From NetBSD <sys/stat.h>. */
76 #define DEFFILEMODE (S_IRUSR | S_IWUSR)
77 
78 /* From NetBSD <unistd.h>. */
79 void	swab(const void * __restrict, void * __restrict, ssize_t);
80 
81 /* From NetBSD <util.h>. */
82 int		raise_default_signal(int);
83 
84 __END_DECLS
85