]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/stdio/_store_inttype.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / stdio / _store_inttype.c
1 /* Copyright (C) 2004       Manuel Novoa III    <mjn3@codepoet.org>
2  *
3  * GNU Library General Public License (LGPL) version 2 or later.
4  *
5  * Dedicated to Toni.  See uClibc/DEDICATION.mjn3 for details.
6  */
7
8 #include "_stdio.h"
9 #include <printf.h>
10
11 /* Right now, we assume intmax_t is either long or long long */
12
13 #ifdef INTMAX_MAX
14
15 #ifdef LLONG_MAX
16
17 #if INTMAX_MAX > LLONG_MAX
18 #error INTMAX_MAX > LLONG_MAX!  The printf code needs to be updated!
19 #endif
20
21 #elif INTMAX_MAX > LONG_MAX
22
23 #error No LLONG_MAX and INTMAX_MAX > LONG_MAX!  The printf code needs to be updated!
24
25 #endif /* LLONG_MAX */
26
27 #endif /* INTMAX_MAX */
28
29 /* We assume int may be short or long, but short and long are different. */
30
31 void _store_inttype(register void *dest, int desttype, uintmax_t val)
32 {
33         if (desttype == __PA_FLAG_CHAR) { /* assume char not int */
34                 *((unsigned char *) dest) = val;
35                 return;
36         }
37 #if defined(LLONG_MAX) && (INT_MAX != LLONG_MAX)
38         if (desttype == PA_FLAG_LONG_LONG) {
39                 *((unsigned long long int *) dest) = val;
40                 return;
41         }
42 #endif /* LLONG_MAX */
43 #if SHRT_MAX != INT_MAX
44         if (desttype == PA_FLAG_SHORT) {
45                 *((unsigned short int *) dest) = val;
46                 return;
47         }
48 #endif /* SHRT_MAX */
49 #if LONG_MAX != INT_MAX
50         if (desttype == PA_FLAG_LONG) {
51                 *((unsigned long int *) dest) = val;
52                 return;
53         }
54 #endif /* LONG_MAX */
55
56         *((unsigned int *) dest) = val;
57 }