1 /*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 06/05/93";
10 #endif /* not lint */
11
12 #include <sys/types.h>
13 #include <sys/types.h>
14 #include <sys/disklabel.h>
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include "extern.h"
18
19 u_int
log2(num)20 log2(num)
21 u_int num;
22 {
23 register u_int i, limit;
24
25 limit = 1;
26 for (i = 0; limit < num; limit = limit << 1, i++);
27 return (i);
28 }
29
30 #if __STDC__
31 #include <stdarg.h>
32 #else
33 #include <varargs.h>
34 #endif
35
36 void
37 #if __STDC__
fatal(const char * fmt,...)38 fatal(const char *fmt, ...)
39 #else
40 fatal(fmt, va_alist)
41 char *fmt;
42 va_dcl
43 #endif
44 {
45 va_list ap;
46 #if __STDC__
47 va_start(ap, fmt);
48 #else
49 va_start(ap);
50 #endif
51 (void)fprintf(stderr, "%s: ", progname);
52 (void)vfprintf(stderr, fmt, ap);
53 va_end(ap);
54 (void)fprintf(stderr, "\n");
55 exit(1);
56 /* NOTREACHED */
57 }
58