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