obilittlebigman.h 1.58 KB
Newer Older
1 2 3 4 5 6 7
/*
 * littlebigman.h
 *
 *  Created on: 23 mai 2015
 *      Author: coissac
 */

8 9
#ifndef OBILITTLEBIGMAN_H_
#define OBILITTLEBIGMAN_H_
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

#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
 *
Eric Coissac's avatar
Eric Coissac committed
48 49
 * @since May 2015
 * @author Eric Coissac (eric.coissac@metabarcoding.org)
50
 */
51
bool obi_is_little_end();
52 53


54
#endif /* OBILITTLEBIGMAN_H_ */