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