b7853d619cd7f77d7be359223c8dfb8920ce67cc
[reactos.git] / reactos / sdk / include / reactos / libs / libmpg123 / mangle.h
1 /*
2 mangle: support defines for preprocessed assembler
3
4 copyright 1995-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6
7 This once started out as mangle.h from MPlayer, but you can't really call it derived work... the small part that in principle stems from MPlayer also being not very special (once you decided to use such a header at all, it's quite obvious material).
8 */
9
10 #ifndef __MANGLE_H
11 #define __MANGLE_H
12
13 #include "config.h"
14 #include "intsym.h"
15
16 #ifdef CCALIGN
17 #define MOVUAPS movaps
18 #else
19 #define MOVUAPS movups
20 #endif
21
22 /*
23 ALIGNX: align to X bytes
24 This differs per compiler/platform in taking the byte count or an exponent for base 2.
25 A way out is balign, if the assembler supports it (gas extension).
26 */
27
28 #ifdef ASMALIGN_BALIGN
29
30 #define ALIGN4 .balign 4
31 #define ALIGN8 .balign 8
32 #define ALIGN16 .balign 16
33 #define ALIGN32 .balign 32
34 #define ALIGN64 .balign 64
35
36 #else
37
38 #ifdef ASMALIGN_EXP
39 #define ALIGN4 .align 2
40 #define ALIGN8 .align 3
41 #define ALIGN16 .align 4
42 #define ALIGN32 .align 5
43 #define ALIGN64 .align 6
44 #else
45 #ifdef ASMALIGN_BYTE
46 #define ALIGN4 .align 4
47 #define ALIGN8 .align 8
48 #define ALIGN16 .align 16
49 #define ALIGN32 .align 32
50 #define ALIGN64 .align 64
51 #else
52 #error "Dunno how assembler alignment works. Please specify."
53 #endif
54 #endif
55
56 #endif
57
58 #define MANGLE_MACROCAT_REALLY(a, b) a ## b
59 #define MANGLE_MACROCAT(a, b) MANGLE_MACROCAT_REALLY(a, b)
60 /* Feel free to add more to the list, eg. a.out IMO */
61 #if defined(__USER_LABEL_PREFIX__)
62 #define ASM_NAME(a) MANGLE_MACROCAT(__USER_LABEL_PREFIX__,a)
63 #define ASM_VALUE(a) MANGLE_MACROCAT($,ASM_NAME(a))
64 #elif defined(__CYGWIN__) || defined(_WIN32) && !defined (_WIN64) || defined(__OS2__) || \
65 (defined(__OpenBSD__) && !defined(__ELF__)) || defined(__APPLE__)
66 #define ASM_NAME(a) MANGLE_MACROCAT(_,a)
67 #define ASM_VALUE(a) MANGLE_MACROCAT($_,a)
68 #else
69 #define ASM_NAME(a) a
70 #define ASM_VALUE(a) MANGLE_MACROCAT($,a)
71 #endif
72
73 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)
74 #define COMM(a,b,c) .comm a,b
75 #else
76 #define COMM(a,b,c) .comm a,b,c
77 #endif
78 /* more hacks for macosx; no .bss ... */
79 #ifdef __APPLE__
80 #define BSS .data
81 #else
82 #define BSS .bss
83 #endif
84
85 /* Mark non-executable stack.
86 It's mainly for GNU on Linux... who else does (not) like this? */
87 #if !defined(__SUNPRO_C) && defined(__linux__) && defined(__ELF__)
88 #if defined(__arm__)
89 #define NONEXEC_STACK .section .note.GNU-stack,"",%progbits
90 #else
91 #define NONEXEC_STACK .section .note.GNU-stack,"",@progbits
92 #endif
93 #else
94 #define NONEXEC_STACK
95 #endif
96
97 #if defined(__x86_64__) && (defined(_WIN64) || defined (__CYGWIN__))
98 #define IS_MSABI 1 /* Not using SYSV */
99 #endif
100
101 /* Macros for +-4GiB PC-relative addressing on AArch64 */
102 #ifdef __APPLE__
103 #define AARCH64_PCREL_HI(label) label@PAGE
104 #define AARCH64_PCREL_LO(label) label@PAGEOFF
105 #else
106 #define AARCH64_PCREL_HI(label) label
107 #define AARCH64_PCREL_LO(label) :lo12:label
108 #endif
109
110 #ifdef __APPLE__
111 #define AARCH64_DUP_4S(dst, src, elem) dup.4s dst, src[elem]
112 #define AARCH64_DUP_2D(dst, src, elem) dup.2d dst, src[elem]
113 #define AARCH64_SQXTN2_8H(dst, src) sqxtn2.8h dst, src
114 #else
115 #define AARCH64_DUP_4S(dst, src, elem) dup dst.4s, src.s[elem]
116 #define AARCH64_DUP_2D(dst, src, elem) dup dst.2d, src.d[elem]
117 #define AARCH64_SQXTN2_8H(dst, src) sqxtn2 dst.8h, src.4s
118 #endif
119
120 #endif /* !__MANGLE_H */
121