6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libc / port / gen / lltostr.c
blobea81d603f0e37765fcd0bc000ded1d0aa0e3408b
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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
35 * char *
36 * lltostr(value, ptr)
37 * long long value;
38 * char *ptr;
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
54 #include "lint.h"
55 #include <sys/types.h>
56 #include <stdlib.h>
58 char *
59 lltostr(longlong_t value, char *ptr)
61 longlong_t t;
63 #ifdef _ILP32
64 if (!(0xffffffff00000000ULL & value)) {
65 ulong_t t, val = (ulong_t)value;
67 do {
68 *--ptr = (char)('0' + val - 10 * (t = val / 10));
69 } while ((val = t) != 0);
71 return (ptr);
73 #endif
75 do {
76 *--ptr = (char)('0' + value - 10 * (t = value / 10));
77 } while ((value = t) != 0);
79 return (ptr);
82 char *
83 ulltostr(u_longlong_t value, char *ptr)
85 u_longlong_t t;
87 #ifdef _ILP32
88 if (!(0xffffffff00000000ULL & value)) {
89 ulong_t t, val = (ulong_t)value;
91 do {
92 *--ptr = (char)('0' + val - 10 * (t = val / 10));
93 } while ((val = t) != 0);
95 return (ptr);
97 #endif
99 do {
100 *--ptr = (char)('0' + value - 10 * (t = value / 10));
101 } while ((value = t) != 0);
103 return (ptr);