199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1990, 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 3. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _STDLIB_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _STDLIB_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/cdefs.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/_null.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/_types.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _RUNE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __rune_t rune_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _RUNE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SIZE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __size_t size_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SIZE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef __cplusplus
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _WCHAR_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef ___wchar_t wchar_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _WCHAR_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int quot; /* quotient */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int rem; /* remainder */
199767f8919635c4928607450d9e0abb932109ceToomas Soome} div_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct {
199767f8919635c4928607450d9e0abb932109ceToomas Soome long quot;
199767f8919635c4928607450d9e0abb932109ceToomas Soome long rem;
199767f8919635c4928607450d9e0abb932109ceToomas Soome} ldiv_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EXIT_FAILURE 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EXIT_SUCCESS 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define RAND_MAX 0x7ffffffd
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome__BEGIN_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _XLOCALE_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <xlocale/_stdlib.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern int __mb_cur_max;
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern int ___mb_cur_max(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MB_CUR_MAX (___mb_cur_max())
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome_Noreturn void abort(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint abs(int) __pure2;
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint atexit(void (*)(void));
199767f8919635c4928607450d9e0abb932109ceToomas Soomedouble atof(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint atoi(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong atol(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *bsearch(const void *, const void *, size_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome size_t, int (*)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *calloc(size_t, size_t) __malloc_like __result_use_check
199767f8919635c4928607450d9e0abb932109ceToomas Soome __alloc_size(1) __alloc_size(2);
199767f8919635c4928607450d9e0abb932109ceToomas Soomediv_t div(int, int) __pure2;
199767f8919635c4928607450d9e0abb932109ceToomas Soome_Noreturn void exit(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid free(void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *getenv(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong labs(long) __pure2;
199767f8919635c4928607450d9e0abb932109ceToomas Soomeldiv_t ldiv(long, long) __pure2;
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mblen(const char *, size_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomesize_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid qsort(void *, size_t, size_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint rand(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *realloc(void *, size_t) __result_use_check __alloc_size(2);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid srand(unsigned);
199767f8919635c4928607450d9e0abb932109ceToomas Soomedouble strtod(const char * __restrict, char ** __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soomefloat strtof(const char * __restrict, char ** __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong strtol(const char * __restrict, char ** __restrict, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong double
199767f8919635c4928607450d9e0abb932109ceToomas Soome strtold(const char * __restrict, char ** __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeunsigned long
199767f8919635c4928607450d9e0abb932109ceToomas Soome strtoul(const char * __restrict, char ** __restrict, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint system(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint wctomb(char *, wchar_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomesize_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Functions added in C99 which we make conditionally available in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * BSD^C89 namespace if the compiler supports `long long'.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The #if test is more complicated than it ought to be because
199767f8919635c4928607450d9e0abb932109ceToomas Soome * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
199767f8919635c4928607450d9e0abb932109ceToomas Soome * is not supported in the compilation environment (which therefore means
199767f8919635c4928607450d9e0abb932109ceToomas Soome * that it can't really be ISO C99).
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (The only other extension made by C99 in thie header is _Exit().)
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __ISO_C_VISIBLE >= 1999
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __LONG_LONG_SUPPORTED
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* LONGLONG */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct {
199767f8919635c4928607450d9e0abb932109ceToomas Soome long long quot;
199767f8919635c4928607450d9e0abb932109ceToomas Soome long long rem;
199767f8919635c4928607450d9e0abb932109ceToomas Soome} lldiv_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* LONGLONG */
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong long
199767f8919635c4928607450d9e0abb932109ceToomas Soome atoll(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* LONGLONG */
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong long
199767f8919635c4928607450d9e0abb932109ceToomas Soome llabs(long long) __pure2;
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* LONGLONG */
199767f8919635c4928607450d9e0abb932109ceToomas Soomelldiv_t lldiv(long long, long long) __pure2;
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* LONGLONG */
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong long
199767f8919635c4928607450d9e0abb932109ceToomas Soome strtoll(const char * __restrict, char ** __restrict, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* LONGLONG */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeunsigned long long
199767f8919635c4928607450d9e0abb932109ceToomas Soome strtoull(const char * __restrict, char ** __restrict, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __LONG_LONG_SUPPORTED */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome_Noreturn void _Exit(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __ISO_C_VISIBLE >= 1999 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If we're in a mode greater than C99, expose C11 functions.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome __alloc_size(2);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint at_quick_exit(void (*)(void));
199767f8919635c4928607450d9e0abb932109ceToomas Soome_Noreturn void
199767f8919635c4928607450d9e0abb932109ceToomas Soome quick_exit(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __ISO_C_VISIBLE >= 2011 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Extensions made by POSIX relative to C.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *realpath(const char * __restrict, char * __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 199506
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint rand_r(unsigned *); /* (TSF) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint posix_memalign(void **, size_t, size_t) __nonnull(1) __alloc_align(2)
199767f8919635c4928607450d9e0abb932109ceToomas Soome __alloc_size(3); /* (ADV) */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint setenv(const char *, const char *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint unsetenv(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint getsubopt(char **, char *const *, char **);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _MKDTEMP_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *mkdtemp(char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _MKDTEMP_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _MKSTEMP_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mkstemp(char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _MKSTEMP_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The only changes to the XSI namespace in revision 6 were the deletion
199767f8919635c4928607450d9e0abb932109ceToomas Soome * of the ttyslot() and valloc() functions, which FreeBSD never declared
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FreeBSD also does not have, and mktemp(), are to be deleted.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __XSI_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong a64l(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomedouble drand48(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* char *ecvt(double, int, int * __restrict, int * __restrict); */
199767f8919635c4928607450d9e0abb932109ceToomas Soomedouble erand48(unsigned short[3]);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* char *fcvt(double, int, int * __restrict, int * __restrict); */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* char *gcvt(double, int, int * __restrict, int * __restrict); */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint grantpt(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *initstate(unsigned long /* XSI requires u_int */, char *, long);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong jrand48(unsigned short[3]);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *l64a(long);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid lcong48(unsigned short[7]);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong lrand48(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if !defined(_MKTEMP_DECLARED) && (__BSD_VISIBLE || __XSI_VISIBLE <= 600)
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *mktemp(char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _MKTEMP_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong mrand48(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong nrand48(unsigned short[3]);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint posix_openpt(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *ptsname(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint putenv(char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong random(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeunsigned short
199767f8919635c4928607450d9e0abb932109ceToomas Soome *seed48(unsigned short[3]);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SETKEY_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint setkey(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SETKEY_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *setstate(/* const */ char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid srand48(long);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid srandom(unsigned long);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint unlockpt(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __XSI_VISIBLE */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern const char *malloc_conf;
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern void (*malloc_message)(void *, const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The alloca() function can't be implemented in C, and on some
199767f8919635c4928607450d9e0abb932109ceToomas Soome * platforms it can't be implemented at all as a callable function.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The GNU C compiler provides a built-in alloca() which we can use;
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in all other cases, provide a prototype, mainly to pacify various
199767f8919635c4928607450d9e0abb932109ceToomas Soome * incarnations of lint. On platforms where alloca() is not in libc,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * programs which use it will fail to link when compiled with non-GNU
199767f8919635c4928607450d9e0abb932109ceToomas Soome * compilers.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#undef alloca /* some GNU bits try to get cute and define this on their own */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define alloca(sz) __builtin_alloca(sz)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#elif defined(lint)
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *alloca(size_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid abort2(const char *, int, void **) __dead2;
199767f8919635c4928607450d9e0abb932109ceToomas Soome__uint32_t
199767f8919635c4928607450d9e0abb932109ceToomas Soome arc4random(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid arc4random_addrandom(unsigned char *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid arc4random_buf(void *, size_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid arc4random_stir(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soome__uint32_t
199767f8919635c4928607450d9e0abb932109ceToomas Soome arc4random_uniform(__uint32_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __BLOCKS__
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint atexit_b(void (^)(void));
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *bsearch_b(const void *, const void *, size_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome size_t, int (^)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *getbsize(int *, long *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* getcap(3) functions */
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *cgetcap(char *, const char *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetclose(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetent(char **, char **, const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetfirst(char **, char **);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetmatch(const char *, const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetnext(char **, char **);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetnum(char *, const char *, long *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetset(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetstr(char *, const char *, char **);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint cgetustr(char *, const char *, char **);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint daemon(int, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *devname(__dev_t, __mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *devname_r(__dev_t, __mode_t, char *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *fdevname(int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *fdevname_r(int, char *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint getloadavg(double [], int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeconst char *
199767f8919635c4928607450d9e0abb932109ceToomas Soome getprogname(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __BLOCKS__
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint heapsort_b(void *, size_t, size_t, int (^)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid qsort_b(void *, size_t, size_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (^)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint l64a_r(long, char *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __BLOCKS__
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mergesort_b(void *, size_t, size_t, int (^)(const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mkostemp(char *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mkostemps(char *, int, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid qsort_r(void *, size_t, size_t, void *,
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*)(void *, const void *, const void *));
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint radixsort(const unsigned char **, int, const unsigned char *,
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
199767f8919635c4928607450d9e0abb932109ceToomas Soome __alloc_size(3);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid *reallocf(void *, size_t) __alloc_size(2);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint rpmatch(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid setprogname(const char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint sradixsort(const unsigned char **, int, const unsigned char *,
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid sranddev(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid srandomdev(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomelong long
199767f8919635c4928607450d9e0abb932109ceToomas Soome strtonum(const char *, long long, long long, const char **);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Deprecated interfaces, to be removed in FreeBSD 6.0. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome__int64_t
199767f8919635c4928607450d9e0abb932109ceToomas Soome strtoq(const char *, char **, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome__uint64_t
199767f8919635c4928607450d9e0abb932109ceToomas Soome strtouq(const char *, char **, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern char *suboptarg; /* getsubopt(3) external variable */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __BSD_VISIBLE */
199767f8919635c4928607450d9e0abb932109ceToomas Soome__END_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_STDLIB_H_ */