ia64/xen-unstable

view tools/xenstore/utils.c @ 19731:01748ccc4da3

Intel VT-d: fix Stoakley boot issue with iommu=1

Signed-off-by: Weidong Han <Weidong.han@intel.com>
Signed-off-by: Allen Kay <allen.m.kay@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 09:25:50 2009 +0100 (2009-06-05)
parents f343d3c16dcc
children
line source
1 #define _GNU_SOURCE
2 #include <stdio.h>
3 #include <stdarg.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <errno.h>
7 #include <unistd.h>
8 #include <fcntl.h>
9 #include <sys/types.h>
10 #include <signal.h>
11 #include "utils.h"
13 static void default_xprintf(const char *fmt, ...)
14 {
15 va_list args;
17 va_start(args, fmt);
18 vfprintf(stderr, fmt, args);
19 va_end(args);
20 fflush(stderr);
21 }
23 void (*xprintf)(const char *fmt, ...) = default_xprintf;
25 void barf(const char *fmt, ...)
26 {
27 char *str;
28 int bytes;
29 va_list arglist;
31 xprintf("FATAL: ");
33 va_start(arglist, fmt);
34 bytes = vasprintf(&str, fmt, arglist);
35 va_end(arglist);
37 if (bytes >= 0) {
38 xprintf("%s\n", str);
39 free(str);
40 }
41 exit(1);
42 }
44 void barf_perror(const char *fmt, ...)
45 {
46 char *str;
47 int bytes, err = errno;
48 va_list arglist;
50 xprintf("FATAL: ");
52 va_start(arglist, fmt);
53 bytes = vasprintf(&str, fmt, arglist);
54 va_end(arglist);
56 if (bytes >= 0) {
57 xprintf("%s: %s\n", str, strerror(err));
58 free(str);
59 }
60 exit(1);
61 }