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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
#include "ace/Basic_Types.h"
#if !defined (__ACE_INLINE__)
# include "ace/Basic_Types.inl"
#endif /* ! __ACE_INLINE__ */
ACE_RCSID (ace,
Basic_Types,
"$Id$")
#if defined (ACE_LACKS_LONGLONG_T) && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
# include "ace/Log_Msg.h"
# include "ace/OS_NS_stdio.h"
# include "ace/OS_NS_string.h"
# if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
// FUZZ: disable check_for_streams_include
# include "ace/streams.h"
# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
ACE_U_LongLong::output (FILE *file) const
{
if (h_ () > 0)
ACE_OS::fprintf (file, "0x%lx%0*lx", h_ (), 2 * sizeof l_ (), l_ ());
else
ACE_OS::fprintf (file, "0x%lx", l_ ());
}
ACE_TCHAR *
ACE_U_LongLong::as_string (ACE_TCHAR *output,
unsigned int base,
unsigned int uppercase) const
{
if (*this == 0)
{
ACE_OS::strcpy(output, "0");
}
else
{
switch(base)
{
case 8:
{
unsigned int index = 0;
int bshift = 31;
while(bshift >= 1)
{
unsigned int sval = (this->h_ () >> bshift) & 7;
if (sval > 0 || index != 0)
{
output[index] = sval + '0';
index++;
}
bshift -= 3;
}
bshift = 30;
while(bshift >= 0)
{
unsigned int sval = (this->l_ () >> bshift) & 7;
// Combine the last bit of hi with the first 3-bit digit
if (bshift == 30)
{
sval |= (this->h_ () & 1) << 2;
}
if (sval > 0 || index != 0)
{
output[index] = sval + '0';
index++;
}
bshift -= 3;
}
output[index] = '\0';
break;
}
case 10:
{
ACE_OS::sprintf(output, "%.0f", *this / 1.0);
break;
}
case 16:
{
if (this->h_ () != 0)
{
ACE_OS::sprintf(output,
(uppercase ? "%lX%0*lX" : "%lx%0*lx"),
this->h_ (), 2 * sizeof this->l_ (),
this->l_ ());
}
else
{
ACE_OS::sprintf(output,
(uppercase ? "%lX" : "%lx"), this->l_ ());
}
break;
}
default:
{
ACE_DEBUG ((LM_DEBUG,
ACE_LIB_TEXT ("Unsupported base = %u\n"), base));
output[0] = '\0';
}
}
}
return output;
}
# if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
ostream&
operator<< (ostream& os, const ACE_U_LongLong& ll)
{
#ifdef __TANDEM && (__CPLUSPLUS_VERSION >= 3)
unsigned long flags = os.flags();
#else
unsigned long flags = os.setf(0);
#endif
char buffer[32];
if ((flags & ios::oct) != 0)
os << ll.as_string (buffer, 8);
else if ((flags & ios::hex) != 0)
os << ll.as_string (buffer, 16, (flags & ios::uppercase));
else
os << ll.as_string (buffer);
return os;
}
# endif
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_LACKS_LONGLONG_T */
|