1 /* $NetBSD: misc.c,v 1.20 2007/07/03 05:25:25 lukem Exp $ */
4 * Copyright (c) 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Keith Muller of the University of California, San Diego and Lance
9 * Visser of Convex Computer Corporation.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/cdefs.h>
39 static char sccsid
[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
41 __RCSID("$NetBSD: misc.c,v 1.20 2007/07/03 05:25:25 lukem Exp $");
45 #include <sys/param.h>
46 #include <sys/types.h>
60 #define tv2mS(tv) ((tv).tv_sec * 1000LL + ((tv).tv_usec + 500) / 1000)
70 (void)write(STDERR_FILENO
, "\n", 1);
72 (void)gettimeofday(&tv
, NULL
);
73 mS
= tv2mS(tv
) - tv2mS(st
.start
);
76 /* Use snprintf(3) so that we don't reenter stdio(3). */
77 (void)snprintf(buf
, sizeof(buf
),
78 "%llu+%llu records in\n%llu+%llu records out\n",
79 (unsigned long long)st
.in_full
, (unsigned long long)st
.in_part
,
80 (unsigned long long)st
.out_full
, (unsigned long long)st
.out_part
);
81 (void)write(STDERR_FILENO
, buf
, strlen(buf
));
83 (void)snprintf(buf
, sizeof(buf
), "%llu odd length swab %s\n",
84 (unsigned long long)st
.swab
,
85 (st
.swab
== 1) ? "block" : "blocks");
86 (void)write(STDERR_FILENO
, buf
, strlen(buf
));
89 (void)snprintf(buf
, sizeof(buf
), "%llu truncated %s\n",
90 (unsigned long long)st
.trunc
,
91 (st
.trunc
== 1) ? "block" : "blocks");
92 (void)write(STDERR_FILENO
, buf
, strlen(buf
));
95 (void)snprintf(buf
, sizeof(buf
), "%llu sparse output %s\n",
96 (unsigned long long)st
.sparse
,
97 (st
.sparse
== 1) ? "block" : "blocks");
98 (void)write(STDERR_FILENO
, buf
, strlen(buf
));
100 (void)snprintf(buf
, sizeof(buf
),
101 "%llu bytes transferred in %lu.%03d secs (%llu bytes/sec)\n",
102 (unsigned long long) st
.bytes
,
105 (unsigned long long) (st
.bytes
* 1000LL / mS
));
106 (void)write(STDERR_FILENO
, buf
, strlen(buf
));
111 summaryx(int notused
)
123 (void)raise_default_signal(signo
);