xref: /openbsd-src/usr.sbin/ldomctl/ldom_util.h (revision d73a4c4fb3962df1e72dd6910861075eabc6a1c3)
1*d73a4c4fSkn /*	$OpenBSD: ldom_util.h,v 1.1 2019/11/28 18:40:42 kn Exp $	*/
2*d73a4c4fSkn 
3*d73a4c4fSkn /*
4*d73a4c4fSkn  * Copyright (c) 2012 Mark Kettenis
5*d73a4c4fSkn  *
6*d73a4c4fSkn  * Permission to use, copy, modify, and distribute this software for any
7*d73a4c4fSkn  * purpose with or without fee is hereby granted, provided that the above
8*d73a4c4fSkn  * copyright notice and this permission notice appear in all copies.
9*d73a4c4fSkn  *
10*d73a4c4fSkn  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11*d73a4c4fSkn  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*d73a4c4fSkn  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13*d73a4c4fSkn  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*d73a4c4fSkn  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*d73a4c4fSkn  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*d73a4c4fSkn  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*d73a4c4fSkn  */
18*d73a4c4fSkn 
19*d73a4c4fSkn #include <stddef.h>
20*d73a4c4fSkn 
21*d73a4c4fSkn extern int debug;
22*d73a4c4fSkn #define DPRINTF(x)	if (debug) printf x
23*d73a4c4fSkn 
24*d73a4c4fSkn void *xmalloc(size_t);
25*d73a4c4fSkn void *xzalloc(size_t);
26*d73a4c4fSkn void *xreallocarray(void *, size_t, size_t);
27*d73a4c4fSkn char *xstrdup(const char *);
28*d73a4c4fSkn int xasprintf(char**, const char *, ...);
29*d73a4c4fSkn 
30*d73a4c4fSkn #define min(a, b)	((a) < (b) ? (a) : (b))
31*d73a4c4fSkn #define max(a, b)	((a) > (b) ? (a) : (b))
32*d73a4c4fSkn 
33*d73a4c4fSkn #define roundup(n, m) (((n) + ((m) - 1)) & ~((m) - 1))
34