2008-07-09 06:16:20 +02:00
|
|
|
/*
|
2009-05-20 04:20:21 +02:00
|
|
|
* Copyright © 2005 Aurelien Jarno
|
|
|
|
* Copyright © 2006 Robert Millan
|
2012-03-23 10:31:42 +01:00
|
|
|
* Copyright © 2008-2011 Guillem Jover <guillem@hadrons.org>
|
2008-07-09 06:16:20 +02:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2011-05-25 07:36:19 +02:00
|
|
|
#ifdef LIBBSD_OVERLAY
|
2011-02-23 14:04:57 +01:00
|
|
|
#include_next <stdlib.h>
|
|
|
|
#else
|
2006-03-17 20:55:21 +01:00
|
|
|
#include <stdlib.h>
|
2011-02-23 14:04:57 +01:00
|
|
|
#endif
|
2006-03-17 20:55:21 +01:00
|
|
|
|
2009-10-24 00:17:57 +02:00
|
|
|
/* For compatibility with NetBSD, which defines humanize_number here. */
|
2011-05-25 07:36:19 +02:00
|
|
|
#ifdef LIBBSD_OVERLAY
|
2009-10-24 00:17:57 +02:00
|
|
|
#include <libutil.h>
|
2011-02-23 14:04:57 +01:00
|
|
|
#else
|
|
|
|
#include <bsd/libutil.h>
|
|
|
|
#endif
|
2009-10-24 00:17:57 +02:00
|
|
|
|
2012-01-03 05:39:22 +01:00
|
|
|
#ifndef LIBBSD_STDLIB_H
|
|
|
|
#define LIBBSD_STDLIB_H
|
|
|
|
|
2018-03-06 01:41:35 +01:00
|
|
|
#ifdef LIBBSD_OVERLAY
|
2012-01-03 05:39:22 +01:00
|
|
|
#include <sys/cdefs.h>
|
2018-03-06 01:41:35 +01:00
|
|
|
#else
|
|
|
|
#include <bsd/sys/cdefs.h>
|
|
|
|
#endif
|
2012-01-03 05:39:22 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2009-05-25 09:25:13 +02:00
|
|
|
__BEGIN_DECLS
|
2022-10-05 12:08:31 +02:00
|
|
|
#if !defined(__GLIBC__) || \
|
|
|
|
!__GLIBC_PREREQ(2, 36) || \
|
|
|
|
!defined(_DEFAULT_SOURCE)
|
2014-08-12 12:32:34 +02:00
|
|
|
uint32_t arc4random(void);
|
2011-02-22 20:44:21 +01:00
|
|
|
void arc4random_buf(void *_buf, size_t n);
|
2014-08-12 12:32:34 +02:00
|
|
|
uint32_t arc4random_uniform(uint32_t upper_bound);
|
2022-10-05 12:08:31 +02:00
|
|
|
#endif
|
|
|
|
void arc4random_stir(void);
|
|
|
|
void arc4random_addrandom(unsigned char *dat, int datlen);
|
2009-12-11 23:12:26 +01:00
|
|
|
|
2009-10-24 00:17:57 +02:00
|
|
|
int dehumanize_number(const char *str, int64_t *size);
|
|
|
|
|
2010-01-21 14:34:55 +01:00
|
|
|
const char *getprogname(void);
|
|
|
|
void setprogname(const char *);
|
2005-12-20 21:29:47 +01:00
|
|
|
|
2020-09-20 03:32:57 +02:00
|
|
|
int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
2011-02-25 18:17:16 +01:00
|
|
|
int mergesort(void *base, size_t nmemb, size_t size,
|
|
|
|
int (*cmp)(const void *, const void *));
|
2011-02-25 18:48:10 +01:00
|
|
|
int radixsort(const unsigned char **base, int nmemb,
|
|
|
|
const unsigned char *table, unsigned endbyte);
|
|
|
|
int sradixsort(const unsigned char **base, int nmemb,
|
|
|
|
const unsigned char *table, unsigned endbyte);
|
2006-03-29 15:55:22 +02:00
|
|
|
|
2010-07-30 08:00:41 +02:00
|
|
|
void *reallocf(void *ptr, size_t size);
|
2018-03-06 01:39:45 +01:00
|
|
|
#if !defined(__GLIBC__) || \
|
2022-10-05 02:05:46 +02:00
|
|
|
!__GLIBC_PREREQ(2, 26) || \
|
2022-10-05 12:08:31 +02:00
|
|
|
(__GLIBC_PREREQ(2, 26) && !__GLIBC_PREREQ(2, 29) && !defined(_GNU_SOURCE)) || \
|
|
|
|
(__GLIBC_PREREQ(2, 29) && !defined(_DEFAULT_SOURCE))
|
2014-06-27 02:05:11 +02:00
|
|
|
void *reallocarray(void *ptr, size_t nmemb, size_t size);
|
2017-09-02 19:55:50 +02:00
|
|
|
#endif
|
2020-12-31 11:46:03 +01:00
|
|
|
void *recallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size);
|
|
|
|
void freezero(void *ptr, size_t size);
|
2010-07-30 08:00:41 +02:00
|
|
|
|
2009-10-11 21:07:53 +02:00
|
|
|
long long strtonum(const char *nptr, long long minval, long long maxval,
|
|
|
|
const char **errstr);
|
2014-06-26 21:32:11 +02:00
|
|
|
|
|
|
|
char *getbsize(int *headerlenp, long *blocksizep);
|
2009-05-25 09:25:13 +02:00
|
|
|
__END_DECLS
|
2008-07-09 08:07:03 +02:00
|
|
|
|
2005-12-20 21:29:47 +01:00
|
|
|
#endif
|