2 * Copyright © 2005 Aurelien Jarno
3 * Copyright © 2006 Robert Millan
4 * Copyright © 2008-2011 Guillem Jover <guillem@hadrons.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include_next <stdlib.h>
35 /* For compatibility with NetBSD, which defines humanize_number here. */
39 #include <bsd/libutil.h>
42 #ifndef LIBBSD_STDLIB_H
43 #define LIBBSD_STDLIB_H
45 #include <sys/cdefs.h>
50 u_int32_t arc4random();
51 void arc4random_stir();
52 void arc4random_addrandom(u_char *dat, int datlen);
53 void arc4random_buf(void *_buf, size_t n);
54 u_int32_t arc4random_uniform(u_int32_t upper_bound);
56 int dehumanize_number(const char *str, int64_t *size);
58 const char *getprogname(void);
59 void setprogname(const char *);
61 int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
62 int mergesort(void *base, size_t nmemb, size_t size,
63 int (*cmp)(const void *, const void *));
64 int radixsort(const unsigned char **base, int nmemb,
65 const unsigned char *table, unsigned endbyte);
66 int sradixsort(const unsigned char **base, int nmemb,
67 const unsigned char *table, unsigned endbyte);
69 void *reallocf(void *ptr, size_t size);
70 void *reallocarray(void *ptr, size_t nmemb, size_t size);
72 long long strtonum(const char *nptr, long long minval, long long maxval,
75 char *getbsize(int *headerlenp, long *blocksizep);