forked from uliwitness/stackimport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndianStuff.h
More file actions
28 lines (24 loc) · 737 Bytes
/
Copy pathEndianStuff.h
File metadata and controls
28 lines (24 loc) · 737 Bytes
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
/*
* EndianStuff.h
* stackimport
*
* Created by Mr. Z. on 10/06/06.
* Copyright 2006 Mr Z. All rights reserved.
*
*/
#pragma once
#include <Carbon/Carbon.h> // For Endian.h
#include <stdint.h>
#if TARGET_RT_BIG_ENDIAN
#define BIG_ENDIAN_16(value) (value)
#define BIG_ENDIAN_32(value) (value)
#else
#define BIG_ENDIAN_16(value) \
(((((u_int16_t)(value))<<8) & 0xFF00) | \
((((u_int16_t)(value))>>8) & 0x00FF))
#define BIG_ENDIAN_32(value) \
(((((u_int32_t)(value))<<24) & 0xFF000000) | \
((((u_int32_t)(value))<< 8) & 0x00FF0000) | \
((((u_int32_t)(value))>> 8) & 0x0000FF00) | \
((((u_int32_t)(value))>>24) & 0x000000FF))
#endif