Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
672f0574
Commit
672f0574
authored
Apr 24, 2018
by
Mark Olesen
Browse files
COMP: resolve signed/unsigned long ambiguity on Darwin
parent
29c020f5
Changes
12
Hide whitespace changes
Inline
Side-by-side
applications/test/limits/Test-limits.C
0 → 100644
View file @
672f0574
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Print max limits.
\*---------------------------------------------------------------------------*/
#include <limits>
#include "int.H"
#include "uint.H"
#include "string.H"
#include "IOstreams.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
//NONE Info<<"int16:" << pTraits<int16_t>::max << nl;
Info
<<
"int16:"
<<
std
::
numeric_limits
<
int16_t
>::
max
()
<<
nl
;
Info
<<
"int32:"
<<
pTraits
<
int32_t
>::
max
<<
nl
;
Info
<<
"int64:"
<<
pTraits
<
int64_t
>::
max
<<
nl
;
Info
<<
"uint32:"
<<
pTraits
<
uint32_t
>::
max
<<
nl
;
Info
<<
"uint64:"
<<
pTraits
<
uint64_t
>::
max
<<
nl
;
Info
<<
nl
;
cout
<<
"int16:"
<<
std
::
numeric_limits
<
int16_t
>::
max
()
<<
nl
;
cout
<<
"int32:"
<<
pTraits
<
int32_t
>::
max
<<
nl
;
cout
<<
"int64:"
<<
pTraits
<
int64_t
>::
max
<<
nl
;
cout
<<
"uint32:"
<<
pTraits
<
uint32_t
>::
max
<<
nl
;
cout
<<
"uint64:"
<<
pTraits
<
uint64_t
>::
max
<<
nl
;
Info
<<
"---
\n
End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
applications/test/machine-sizes/Make/files
0 → 100644
View file @
672f0574
Test-machine-sizes.cpp
EXE = $(FOAM_USER_APPBIN)/Test-machine-sizes
applications/test/machine-sizes/Make/options
0 → 100644
View file @
672f0574
/* EXE_INC = */
/* EXE_LIBS = */
applications/test/machine-sizes/Test-machine-sizes.cpp
0 → 100644
View file @
672f0574
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Test the sizeof for basic types. Can be compiled and run without
any OpenFOAM libraries.
\*---------------------------------------------------------------------------*/
#include <cstdint>
#include <climits>
#include <cstdlib>
#include <limits>
#include <iostream>
// Can also compile without OpenFOAM
#ifdef WM_LABEL_SIZE
#include "IOstreams.H"
#endif
template
<
class
T
>
void
print
(
const
char
*
msg
)
{
std
::
cout
<<
msg
<<
' '
<<
sizeof
(
T
)
<<
'\n'
;
}
#ifdef WM_LABEL_SIZE
template
<
class
T
>
void
printMax
(
const
char
*
msg
)
{
std
::
cout
<<
msg
<<
' '
<<
sizeof
(
T
)
<<
" max "
<<
std
::
numeric_limits
<
T
>::
max
()
<<
'\n'
;
Foam
::
Info
<<
msg
<<
' '
<<
sizeof
(
T
)
<<
" max "
<<
long
(
std
::
numeric_limits
<
T
>::
max
())
<<
'\n'
;
}
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
cout
<<
"machine sizes
\n
---
\n\n
"
;
print
<
mode_t
>
(
"mode_t"
);
print
<
short
>
(
"short"
);
print
<
int
>
(
"int"
);
print
<
long
>
(
"long"
);
print
<
long
long
>
(
"long long"
);
print
<
unsigned
short
>
(
"ushort"
);
print
<
unsigned
int
>
(
"uint"
);
print
<
unsigned
long
>
(
"ulong"
);
print
<
unsigned
long
long
>
(
"ulong-long"
);
print
<
int16_t
>
(
"int16"
);
print
<
int32_t
>
(
"int32"
);
print
<
int64_t
>
(
"int64"
);
print
<
uint16_t
>
(
"uint16"
);
print
<
uint32_t
>
(
"uint32"
);
print
<
uint64_t
>
(
"uint64"
);
print
<
float
>
(
"float"
);
print
<
double
>
(
"double"
);
print
<
std
::
string
>
(
"std::string"
);
print
<
std
::
string
::
size_type
>
(
"std::string::size_type"
);
#ifdef WM_LABEL_SIZE
std
::
cout
<<
"
\n
max values
\n
---
\n\n
"
;
printMax
<
mode_t
>
(
"mode_t"
);
Foam
::
Info
<<
"mode_t 0777: "
<<
mode_t
(
0777
)
<<
'\n'
;
printMax
<
short
>
(
"short"
);
printMax
<
int
>
(
"int"
);
printMax
<
long
>
(
"long"
);
printMax
<
unsigned
short
>
(
"ushort"
);
printMax
<
unsigned
int
>
(
"uint"
);
printMax
<
unsigned
long
>
(
"ulong"
);
printMax
<
float
>
(
"float"
);
printMax
<
double
>
(
"double"
);
#endif
std
::
cout
<<
"
\n
---
\n
End
\n\n
"
;
return
0
;
}
// ************************************************************************* //
src/OpenFOAM/primitives/Scalar/Scalar.H
View file @
672f0574
...
...
@@ -89,13 +89,13 @@ public:
// Member Functions
//- Access to the
Scalar
value
//- Access to the value
operator
Scalar
()
const
{
return
p_
;
}
//- Access to the
Scalar
value
//- Access to the value
operator
Scalar
&
()
{
return
p_
;
...
...
src/OpenFOAM/primitives/bools/bool/bool.H
View file @
672f0574
...
...
@@ -103,13 +103,13 @@ public:
// Member Functions
//- Access to the
bool
value
//- Access to the value
operator
bool
()
const
{
return
p_
;
}
//- Access to the
bool
value
//- Access to the value
operator
bool
&
()
{
return
p_
;
...
...
src/OpenFOAM/primitives/ints/int32/int32.H
View file @
672f0574
...
...
@@ -107,9 +107,8 @@ inline bool read(const std::string& str, int32_t& val)
Istream
&
operator
>>
(
Istream
&
is
,
int32_t
&
val
);
Ostream
&
operator
<<
(
Ostream
&
os
,
const
int32_t
val
);
// On 32bit OSs long is not unambiguously int32_t (or int64_t) causing problems
// for IO operator resolution.
// This problem is avoided by explicitly defining the following operators:
// 32bit OS: long is not unambiguously (int32_t | int64_t)
// - resolve explicitly for input and output
#if WM_ARCH_OPTION == 32
Istream
&
operator
>>
(
Istream
&
is
,
long
&
val
);
Ostream
&
operator
<<
(
Ostream
&
os
,
const
long
val
);
...
...
@@ -163,13 +162,13 @@ public:
// Member Functions
//- Access to the
int32_t
value
//- Access to the value
operator
int32_t
()
const
{
return
p_
;
}
//- Access to the
int
value
//- Access to the value
operator
int32_t
&
()
{
return
p_
;
...
...
src/OpenFOAM/primitives/ints/int64/int64.H
View file @
672f0574
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -108,6 +108,13 @@ inline bool read(const std::string& str, int64_t& val)
Istream
&
operator
>>
(
Istream
&
is
,
int64_t
&
val
);
Ostream
&
operator
<<
(
Ostream
&
os
,
const
int64_t
val
);
// On Darwin: long is not unambiguously (int32_t | int64_t)
// - explicitly resolve for output
#if WM_ARCH_OPTION == 64 && defined(darwin)
Ostream
&
operator
<<
(
Ostream
&
os
,
const
long
val
);
#endif
//- Template specialization for pTraits<int64_t>
template
<
>
class
pTraits
<
int64_t
>
...
...
@@ -155,13 +162,13 @@ public:
// Member Functions
//- Access to the
int64_t
value
//- Access to the value
operator
int64_t
()
const
{
return
p_
;
}
//- Access to the
int
value
//- Access to the value
operator
int64_t
&
()
{
return
p_
;
...
...
src/OpenFOAM/primitives/ints/int64/int64IO.C
View file @
672f0574
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -120,4 +120,13 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const int64_t val)
}
#if WM_ARCH_OPTION == 64 && defined(darwin)
Foam
::
Ostream
&
Foam
::
operator
<<
(
Ostream
&
os
,
const
long
val
)
{
os
<<
int64_t
(
val
);
return
os
;
}
#endif
// ************************************************************************* //
src/OpenFOAM/primitives/ints/uint32/uint32.H
View file @
672f0574
...
...
@@ -154,13 +154,13 @@ public:
// Member Functions
//- Access to the
uint32_t
value
//- Access to the value
operator
uint32_t
()
const
{
return
p_
;
}
//- Access to the
uint32_t
value
//- Access to the value
operator
uint32_t
&
()
{
return
p_
;
...
...
src/OpenFOAM/primitives/ints/uint64/uint64.H
View file @
672f0574
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -107,6 +107,13 @@ inline bool read(const std::string& str, uint64_t& val)
Istream
&
operator
>>
(
Istream
&
is
,
uint64_t
&
val
);
Ostream
&
operator
<<
(
Ostream
&
os
,
const
uint64_t
val
);
// On Darwin: unsigned long is not unambiguously (uint32_t | uint64_t)
// - explicitly resolve for output
#if WM_ARCH_OPTION == 64 && defined(darwin)
Ostream
&
operator
<<
(
Ostream
&
os
,
const
unsigned
long
val
);
#endif
//- Template specialization for pTraits<uint64_t>
template
<
>
class
pTraits
<
uint64_t
>
...
...
@@ -154,13 +161,13 @@ public:
// Member Functions
//- Access to the
uint64_t
value
//- Access to the value
operator
uint64_t
()
const
{
return
p_
;
}
//- Access to the
uint64_t
value
//- Access to the value
operator
uint64_t
&
()
{
return
p_
;
...
...
src/OpenFOAM/primitives/ints/uint64/uint64IO.C
View file @
672f0574
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -119,4 +119,13 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const uint64_t val)
}
#if WM_ARCH_OPTION == 64 && defined(darwin)
Foam
::
Ostream
&
Foam
::
operator
<<
(
Ostream
&
os
,
const
unsigned
long
val
)
{
os
<<
uint64_t
(
val
);
return
os
;
}
#endif
// ************************************************************************* //
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment