Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
d5fcd521
Commit
d5fcd521
authored
May 23, 2015
by
Eric Coissac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a function to test indianness of the platform
parent
5138fe1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
src/littlebigman.c
src/littlebigman.c
+20
-0
src/littlebigman.h
src/littlebigman.h
+54
-0
No files found.
src/littlebigman.c
0 → 100644
View file @
d5fcd521
/*
* littlebigman.c
*
* Created on: 23 mai 2015
* Author: coissac
*/
#include <littlebigman.h>
bool
islittlend
()
{
union
{
int
entier
;
char
caractere
[
4
]
;
}
test
;
test
.
entier
=
0x01020304
;
return
(
test
.
caractere
[
3
]
==
1
);
}
src/littlebigman.h
0 → 100644
View file @
d5fcd521
/*
* littlebigman.h
*
* Created on: 23 mai 2015
* Author: coissac
*/
#ifndef LITTLEBIGMAN_H_
#define LITTLEBIGMAN_H_
#include <stdbool.h>
/**
* Test is the architecture of the processor is little endian.
*
* ##Two classes of CPU architecture can be define:
* - little endian
* - big endian
*
* They describe the way the processor store multi-byte values
* in memory. Considering an 32 bits integer value encoded in
* hexadecimal `0x11223344`. This value needs four bytes to be
* stored. These for bytes will have consecutive addresses in memory.
* Let says that these addresses will be : 01, 02, 03, and 04
*
* ###A big endian architecture will store our integer with the following schema:
*
* Address | 01 | 02 | 03 | 04
* ---------|------|------|------|------
* value | Ox11 | Ox22 | 0x33 | 0x44
*
* In this architecture the last address (the end of the representation) is
* used to store the byte of higher weight (BIG ENDian)
*
* ###A little endian architecture will store our integer with the following schema:
*
* Address | 01 | 02 | 03 | 04
* ---------|------|------|------|------
* value | Ox44 | Ox33 | 0x22 | 0x11
*
* In this architecture the last address is
* used to store the byte of lighter weight (LITTLE ENDian)
*
* @return a `bool` value:
* - `true` if the architecture is little endian
* - `false` if the architecture is big endian
*
* @author Eric Coissac (coissac)
* @created on 23/05/2015
*/
bool
islittlend
();
#endif
/* LITTLEBIGMAN_H_ */
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