#include <sys/ioctl.h>
#include <libutil.h>
#endif
-
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#include <xen-tools/libs.h>
/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
static unsigned int current_array_size;
static unsigned int nr_fds;
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
struct buffer {
char *data;
size_t consumed;
})
#endif
+#ifndef ROUNDUP
+#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
+#endif
+
#endif /* __XEN_TOOLS_LIBS__ */
#include <errno.h>
#include <string.h>
#include <pthread.h>
+#include <xen-tools/libs.h>
#include "private.h"
#define DBGPRINTF(_m...) \
xtl_log(xcall->logger, XTL_DEBUG, -1, "xencall:buffer", _m)
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER;
static void cache_lock(xencall_handle *xcall)
#include <sys/mman.h>
#include <sys/ioctl.h>
+#include <xen-tools/libs.h>
#include "private.h"
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#include <xentoolcore_internal.h>
#include <xengnttab.h>
-/* Set of macros/defines used by both Linux and FreeBSD */
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
#define GTERROR(_l, _f...) xtl_log(_l, XTL_ERROR, errno, "gnttab", _f)
#define GSERROR(_l, _f...) xtl_log(_l, XTL_ERROR, errno, "gntshr", _f)
#define PAGE_SIZE_X86 (1UL << PAGE_SHIFT_X86)
#define PAGE_MASK_X86 (~(PAGE_SIZE_X86-1))
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
#define NRPAGES(x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT)
#define MB(_mb) (_AC(_mb, ULL) << 20)
#define GB(_gb) (_AC(_gb, ULL) << 30)
-#define ROUNDUP(_val, _order) \
- (((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1))
-
#define DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d))
#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
static int sock = -1;
static int ro_sock = -1;
-#define ROUNDUP(_x, _w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
static bool verbose = false;
LIST_HEAD(connections);
int tracefd = -1;