4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
34 * Translate a struct timeval into a string appropriate for ld(1) and ld.so.1(1)
38 conv_time(struct timeval
*oldtime
, struct timeval
*newtime
,
39 Conv_time_buf_t
*time_buf
)
45 sec
= newtime
->tv_sec
- oldtime
->tv_sec
;
46 if (newtime
->tv_usec
>= oldtime
->tv_usec
)
47 usec
= newtime
->tv_usec
- oldtime
->tv_usec
;
49 usec
= (newtime
->tv_usec
+ MICROSEC
) - oldtime
->tv_usec
;
54 * The default display is "sec.fraction", but ld(1) has been know to
55 * ascend into minutes, and in worst case scenarios, hours.
57 if ((min
= sec
/ 60) != 0)
59 if ((hour
= min
/ 60) != 0)
63 (void) snprintf(time_buf
->buf
, sizeof (time_buf
->buf
),
64 MSG_ORIG(MSG_TIME_HMSF
), hour
, min
, sec
, usec
);
66 (void) snprintf(time_buf
->buf
, sizeof (time_buf
->buf
),
67 MSG_ORIG(MSG_TIME_MSF
), min
, sec
, usec
);
69 (void) snprintf(time_buf
->buf
, sizeof (time_buf
->buf
),
70 MSG_ORIG(MSG_TIME_SF
), sec
, usec
);
72 return ((const char *)time_buf
);