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 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * lltostr -- convert long long to decimal string
40 * Ptr is assumed to point to the byte following a storage area
41 * into which the decimal representation of "value" is to be
42 * placed as a string. Lltostr converts "value" to decimal and
43 * produces the string, and returns a pointer to the beginning
44 * of the string. No leading zeroes are produced, and no
45 * terminating null is produced. The low-order digit of the
46 * result always occupies memory position ptr-1.
47 * Lltostr's behavior is undefined if "value" is negative. A single
48 * zero digit is produced if "value" is zero.
51 #pragma weak _lltostr = lltostr
52 #pragma weak _ulltostr = ulltostr
55 #include <sys/types.h>
59 lltostr(longlong_t value
, char *ptr
)
64 if (!(0xffffffff00000000ULL
& value
)) {
65 ulong_t t
, val
= (ulong_t
)value
;
68 *--ptr
= (char)('0' + val
- 10 * (t
= val
/ 10));
69 } while ((val
= t
) != 0);
76 *--ptr
= (char)('0' + value
- 10 * (t
= value
/ 10));
77 } while ((value
= t
) != 0);
83 ulltostr(u_longlong_t value
, char *ptr
)
88 if (!(0xffffffff00000000ULL
& value
)) {
89 ulong_t t
, val
= (ulong_t
)value
;
92 *--ptr
= (char)('0' + val
- 10 * (t
= val
/ 10));
93 } while ((val
= t
) != 0);
100 *--ptr
= (char)('0' + value
- 10 * (t
= value
/ 10));
101 } while ((value
= t
) != 0);