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 // TODO: should this be in bionic? (glibc does this, even though it's not quite right.) 54 #define O_RSYNC O_SYNC 55 56 __BEGIN_DECLS 57 58 /* From NetBSD <grp.h> and <pwd.h>. */ 59 char* group_from_gid(gid_t gid, int noname); 60 int uid_from_user(const char* name, uid_t* uid); 61 char* user_from_uid(uid_t uid, int noname); 62 63 /* From NetBSD <stdlib.h>. */ 64 #define HN_DECIMAL 0x01 65 #define HN_NOSPACE 0x02 66 #define HN_B 0x04 67 #define HN_DIVISOR_1000 0x08 68 #define HN_GETSCALE 0x10 69 #define HN_AUTOSCALE 0x20 70 int humanize_number(char *, size_t, int64_t, const char *, int, int); 71 int dehumanize_number(const char *, int64_t *); 72 char *getbsize(int *, long *); 73 long long strsuftoll(const char *, const char *, long long, long long); 74 long long strsuftollx(const char *, const char *, long long, long long, 75 char *, size_t); 76 77 /* From NetBSD <string.h>. */ 78 void strmode(mode_t, char*); 79 80 /* From NetBSD <sys/param.h>. */ 81 #define MAXBSIZE 65536 82 83 /* From NetBSD <sys/stat.h>. */ 84 #define DEFFILEMODE (S_IRUSR | S_IWUSR) 85 86 /* From NetBSD <unistd.h>. */ 87 void swab(const void * __restrict, void * __restrict, ssize_t); 88 89 /* From NetBSD <util.h>. */ 90 int raise_default_signal(int); 91 92 __END_DECLS 93