Rizin
unix-like reverse engineering framework and cli tools
macros.h
Go to the documentation of this file.
1
/* This file is part of libmspack.
2
* (C) 2003-2020 Stuart Caie.
3
*
4
* libmspack is free software; you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License (LGPL) version 2.1
6
*
7
* For further details, see the file COPYING.LIB distributed with libmspack
8
*/
9
10
#ifndef MSPACK_MACROS_H
11
#define MSPACK_MACROS_H 1
12
13
/* define LD and LU as printf-format for signed and unsigned long offsets */
14
#if HAVE_INTTYPES_H
15
# include <inttypes.h>
16
#else
17
# define PRId64 "lld"
18
# define PRIu64 "llu"
19
# define PRId32 "ld"
20
# define PRIu32 "lu"
21
#endif
22
23
#if SIZEOF_OFF_T >= 8
24
# define LD PRId64
25
# define LU PRIu64
26
#else
27
# define LD PRId32
28
# define LU PRIu32
29
#endif
30
31
/* endian-neutral reading of little-endian data */
32
#define __egi32(a,n) (((unsigned int) ((unsigned char *)(a))[n+3] << 24) | \
33
((unsigned int) ((unsigned char *)(a))[n+2] << 16) | \
34
((unsigned int) ((unsigned char *)(a))[n+1] << 8) | \
35
((unsigned int) ((unsigned char *)(a))[n]))
36
#define EndGetI64(a) (((unsigned long long int) __egi32(a,4) << 32) | __egi32(a,0))
37
#define EndGetI32(a) __egi32(a,0)
38
#define EndGetI16(a) ((((a)[1])<<8)|((a)[0]))
39
40
/* endian-neutral reading of big-endian data */
41
#define EndGetM32(a) (((unsigned int) ((unsigned char *)(a))[0] << 24) | \
42
((unsigned int) ((unsigned char *)(a))[1] << 16) | \
43
((unsigned int) ((unsigned char *)(a))[2] << 8) | \
44
((unsigned int) ((unsigned char *)(a))[3]))
45
#define EndGetM16(a) ((((a)[0])<<8)|((a)[1]))
46
47
/* D(("formatstring", args)) prints debug messages if DEBUG defined */
48
#if DEBUG
49
/* http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html */
50
# if __STDC_VERSION__ < 199901L
51
# if __GNUC__ >= 2
52
# define __func__ __FUNCTION__
53
# else
54
# define __func__ "<unknown>"
55
# endif
56
# endif
57
# include <stdio.h>
58
# define D(x) do { printf("%s:%d (%s) "
,__FILE__, __LINE__, __func__); \
59
printf x ; fputc('\n', stdout); fflush(stdout);} while (0);
60
#else
61
# define D(x)
62
#endif
63
64
#endif
subprojects
libmspack
cabextract
mspack
macros.h
Generated by
1.9.1