xref: /minix3/libexec/ld.elf_so/rtldenv.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: rtldenv.h,v 1.12 2013/05/06 08:02:20 skrll Exp $	 */
2e83f7ba2SBen Gras 
3e83f7ba2SBen Gras /*
4e83f7ba2SBen Gras  * Copyright 1996 Matt Thomas <matt@3am-software.com>
5e83f7ba2SBen Gras  * All rights reserved.
6e83f7ba2SBen Gras  *
7e83f7ba2SBen Gras  * Redistribution and use in source and binary forms, with or without
8e83f7ba2SBen Gras  * modification, are permitted provided that the following conditions
9e83f7ba2SBen Gras  * are met:
10e83f7ba2SBen Gras  * 1. Redistributions of source code must retain the above copyright
11e83f7ba2SBen Gras  *    notice, this list of conditions and the following disclaimer.
12e83f7ba2SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
13e83f7ba2SBen Gras  *    notice, this list of conditions and the following disclaimer in the
14e83f7ba2SBen Gras  *    documentation and/or other materials provided with the distribution.
15e83f7ba2SBen Gras  * 3. The name of the author may not be used to endorse or promote products
16e83f7ba2SBen Gras  *    derived from this software without specific prior written permission.
17e83f7ba2SBen Gras  *
18e83f7ba2SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19e83f7ba2SBen Gras  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20e83f7ba2SBen Gras  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21e83f7ba2SBen Gras  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22e83f7ba2SBen Gras  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23e83f7ba2SBen Gras  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24e83f7ba2SBen Gras  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25e83f7ba2SBen Gras  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26e83f7ba2SBen Gras  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27e83f7ba2SBen Gras  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28e83f7ba2SBen Gras  */
29e83f7ba2SBen Gras 
30e83f7ba2SBen Gras #ifndef _RTLDENV_H
31e83f7ba2SBen Gras #define	_RTLDENV_H
32e83f7ba2SBen Gras 
33e83f7ba2SBen Gras #include <stddef.h>
34e83f7ba2SBen Gras #include <stdarg.h>
35e83f7ba2SBen Gras 
36e83f7ba2SBen Gras void    *xcalloc(size_t);
37e83f7ba2SBen Gras void    *xmalloc(size_t);
38e83f7ba2SBen Gras void    *xrealloc(void *, size_t);
39e83f7ba2SBen Gras char    *xstrdup(const char *);
40e83f7ba2SBen Gras void	xfree(void *);
41e83f7ba2SBen Gras 
42e83f7ba2SBen Gras #ifdef RTLD_LOADER
43e83f7ba2SBen Gras void xprintf(const char *, ...)
44e83f7ba2SBen Gras     __attribute__((__format__(__printf__, 1, 2)));
45e83f7ba2SBen Gras void xvprintf(const char *, va_list)
46e83f7ba2SBen Gras     __attribute__((__format__(__printf__, 1, 0)));
47e83f7ba2SBen Gras void xsnprintf(char *, size_t, const char *, ...)
48e83f7ba2SBen Gras     __attribute__((__format__(__printf__, 3, 4)));
49e83f7ba2SBen Gras size_t xvsnprintf(char *, size_t, const char *, va_list)
50e83f7ba2SBen Gras     __attribute__((__format__(__printf__, 3, 0)));
51e83f7ba2SBen Gras void xwarn(const char *, ...)
52e83f7ba2SBen Gras     __attribute__((__format__(__printf__, 1, 2)));
53e83f7ba2SBen Gras void xwarnx(const char *, ...)
54e83f7ba2SBen Gras     __attribute__((__format__(__printf__, 1, 2)));
55e83f7ba2SBen Gras void xerr(int, const char *, ...)
56e83f7ba2SBen Gras     __attribute__((__noreturn__, __format__(__printf__, 2, 3)));
57e83f7ba2SBen Gras void xerrx(int, const char *, ...)
58e83f7ba2SBen Gras     __attribute__((__noreturn__, __format__(__printf__, 2, 3)));
59e83f7ba2SBen Gras 
60f14fb602SLionel Sambuc void     xassert(const char *, int, const char *) __dead;
61e83f7ba2SBen Gras const char *xstrerror(int);
62e83f7ba2SBen Gras int	xunsetenv(const char *);
63e83f7ba2SBen Gras 
64e83f7ba2SBen Gras # ifdef DEBUG
65e83f7ba2SBen Gras #  define assert(cond)	((cond) ? (void) 0 : xassert(__FILE__, __LINE__, #cond))
66e83f7ba2SBen Gras # else
67e83f7ba2SBen Gras #  define assert(cond)	(void) 0
68e83f7ba2SBen Gras # endif
69e83f7ba2SBen Gras #else
70e83f7ba2SBen Gras # include <assert.h>
71e83f7ba2SBen Gras # include <stdio.h>
72e83f7ba2SBen Gras # include <err.h>
73e83f7ba2SBen Gras 
74e83f7ba2SBen Gras # define xprintf	printf
75e83f7ba2SBen Gras # define xvprintf	vprintf
76e83f7ba2SBen Gras # define xsnprintf	snprintf
77e83f7ba2SBen Gras # define xvsnprintf	vsnprintf
78e83f7ba2SBen Gras # define xwarn		warn
79e83f7ba2SBen Gras # define xwarnx		warnx
80e83f7ba2SBen Gras # define xerr		err
81e83f7ba2SBen Gras # define xerrx		errx
82e83f7ba2SBen Gras # define xassert	assert
83e83f7ba2SBen Gras # define xstrerror	strerror
84e83f7ba2SBen Gras #endif
85e83f7ba2SBen Gras 
86e83f7ba2SBen Gras #endif /* _RTLDENV_H */
87