forked from daryl317/fail0verflow-PS3-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.h
50 lines (41 loc) · 1.45 KB
/
common.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright (C) Youness Alaoui (KaKaRoTo)
*
* This software is distributed under the terms of the GNU General Public
* License ("GPL") version 3, as published by the Free Software Foundation.
*
*/
#ifndef __COMMON_H__
#define __COMMON_H__
#include <stdio.h>
#ifdef WIN32
#define MKDIR(x,y) mkdir(x)
#else
#define MKDIR(x,y) mkdir(x,y)
#endif
#ifdef __BIG_ENDIAN__
#define swap16(x) (x)
#define swap32(x) (x)
#define swap64(x) (x)
#else
#define swap16(x) ((((uint16_t)(x) & 0xff00) >> 8) | \
(((uint16_t)(x) & 0x00ff) << 8))
#define swap32(x) ((((uint32_t)(x) & 0xff000000) >> 24) | \
(((uint32_t)(x) & 0x00ff0000) >> 8) | \
(((uint32_t)(x) & 0x0000ff00) << 8) | \
(((uint32_t)(x) & 0x000000ff) << 24))
#define swap64(x) \
((((uint64_t)(x) & 0xff00000000000000ull) >> 56) | \
((uint64_t)((x) & 0x00ff000000000000ull) >> 40) | \
((uint64_t)((x) & 0x0000ff0000000000ull) >> 24) | \
((uint64_t)((x) & 0x000000ff00000000ull) >> 8) | \
((uint64_t)((x) & 0x00000000ff000000ull) << 8) | \
((uint64_t)((x) & 0x0000000000ff0000ull) << 24) | \
((uint64_t)((x) & 0x000000000000ff00ull) << 40) | \
((uint64_t)((x) & 0x00000000000000ffull) << 56))
#endif
#define ERROR(err, msg) do { \
perror (msg); \
exit (err); \
} while(0);
#endif /* __COMMON_H__ */