Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuhao Liu
ogs
Commits
b5dbd26d
Commit
b5dbd26d
authored
12 years ago
by
Norihiro Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
follow the advice of Lars for checking endian
parent
91ad292d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
BaseLib/SystemTools.h
+5
-5
5 additions, 5 deletions
BaseLib/SystemTools.h
Tests/BaseLib/TestSystemTools.cpp
+25
-0
25 additions, 0 deletions
Tests/BaseLib/TestSystemTools.cpp
scripts/cmake/CheckTypeSizes.cmake
+13
-1
13 additions, 1 deletion
scripts/cmake/CheckTypeSizes.cmake
with
43 additions
and
6 deletions
BaseLib/SystemTools.h
+
5
−
5
View file @
b5dbd26d
...
...
@@ -19,11 +19,11 @@ namespace BaseLib
/// return if this system supports little endian or not
inline
bool
IsLittleEndian
()
{
int
x
=
0x00000001
;
if
(
*
(
char
*
)
&
x
)
return
true
;
//am little
else
return
false
;
//am big
#ifdef ENDIAN_IS_BIG
return
false
;
#elif ENDIAN_IS_LITTLE
return
true
;
#endif
}
}
...
...
This diff is collapsed.
Click to expand it.
Tests/BaseLib/TestSystemTools.cpp
0 → 100644
+
25
−
0
View file @
b5dbd26d
/**
* Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* \file TestSystemTools.cpp
*
* Created on 2012-10-30 by Norihiro Watanabe
*/
// ** INCLUDES **
#include
"gtest.h"
#include
"SystemTools.h"
TEST
(
BaseLib
,
EndianLittle
)
{
bool
isLittle
=
false
;
int
x
=
0x00000001
;
if
(
*
(
char
*
)
&
x
)
isLittle
=
true
;
//am little
ASSERT_EQ
(
isLittle
,
BaseLib
::
IsLittleEndian
());
}
This diff is collapsed.
Click to expand it.
scripts/cmake/CheckTypeSizes.cmake
+
13
−
1
View file @
b5dbd26d
...
...
@@ -14,4 +14,16 @@ ELSE()
SET
(
HAVE_64_BIT 1
)
ADD_DEFINITIONS
(
-DHAVE_64_BIT
)
SET
(
BITS 64
)
ENDIF
()
\ No newline at end of file
ENDIF
()
# Check endian of the system
INCLUDE
(
TestBigEndian
)
TEST_BIG_ENDIAN
(
IS_BIG_ENDIAN
)
IF
(
IS_BIG_ENDIAN
)
ADD_DEFINITIONS
(
-DENDIAN_IS_BIG
)
# cannot use BIG_ENDIAN because it's reserved in Linux
ELSE
()
ADD_DEFINITIONS
(
-DENDIAN_IS_LITTLE
)
# cannot use LITTLE_ENDIAN because it's reserved in Linux
ENDIF
()
# IS_BIG_ENDIAN
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment