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