4018c2356a1dcfe57c5978d8ef1bfe04b24f0d07
[platform/upstream/nettle.git] / asm.m4
1 divert(-1)
2 changequote(<,>)dnl
3 dnl (progn (modify-syntax-entry ?< "(>") (modify-syntax-entry ?> ")<") )
4
5 dnl FORTRAN style comment character
6 define(<C>, <
7 dnl>)dnl
8 dnl Disable m4 comment processing, since the default, #, is used for
9 dnl constants on some architectures, in particular ARM.
10 changecom()dnl
11
12 dnl Including files from the srcdir
13 define(<include_src>, <include(srcdir/$1)>)dnl
14
15 dnl default definition, changed in fat builds
16 define(<fat_transform>, <$1>)
17 define(<C_NAME>, <SYMBOL_PREFIX<>fat_transform($1)>)
18
19 dnl Pseudo ops
20 define(<DECLARE_FUNC>,
21 <ifelse(ELF_STYLE,yes,
22 <.type $1,TYPE_FUNCTION>,
23 COFF_STYLE, yes,
24 <.def $1
25 .scl 2
26 .type 32
27 .endef>,
28 <>)>)
29
30 define(<GMP_NUMB_BITS>,<>)dnl
31
32 define(<PROLOGUE>,
33 <.globl C_NAME($1)
34 DECLARE_FUNC(C_NAME($1))
35 C_NAME($1):>)
36
37 define(<EPILOGUE>,
38 <ifelse(ELF_STYLE,yes,
39 <.size C_NAME($1), . - C_NAME($1)>,<>)>)
40
41 define(<m4_log2>, <m4_log2_internal($1,1,0)>)
42 define(<m4_log2_internal>,
43 <ifelse($3, 10, <not-a-power-of-two>,
44 $1, $2, $3,
45 <m4_log2_internal($1, eval(2*$2), eval(1 + $3))>)>)
46
47 dnl Argument to ALIGN is always in bytes, and converted to a
48 dnl logarithmic .align if necessary.
49
50 define(<ALIGN>,
51 <.align ifelse(ALIGN_LOG,yes,<m4_log2($1)>,$1)
52 >)
53
54 dnl Struct defining macros
55
56 dnl STRUCTURE(prefix) 
57 define(<STRUCTURE>, <define(<SOFFSET>, 0)define(<SPREFIX>, <$1>)>)dnl
58
59 dnl STRUCT(name, size)
60 define(<STRUCT>,
61 <define(SPREFIX<_>$1, SOFFSET)dnl
62  define(<SOFFSET>, eval(SOFFSET + ($2)))>)dnl
63
64 dnl UCHAR(name)
65 define(<UCHAR>, <STRUCT(<$1>, 1)>)dnl
66
67 dnl UNSIGNED(name)
68 define(<UNSIGNED>, <STRUCT(<$1>, 4)>)dnl
69
70 dnl Offsets in arcfour_ctx
71 STRUCTURE(ARCFOUR)
72   STRUCT(S, 256)
73   UCHAR(I)
74   UCHAR(J)
75
76 dnl Offsets in aes_table
77 define(AES_SBOX_SIZE,   256)dnl
78 define(AES_TABLE_SIZE,  1024)dnl
79
80 STRUCTURE(AES)
81   STRUCT(SBOX, AES_SBOX_SIZE)
82   STRUCT(TABLE0, AES_TABLE_SIZE)
83   STRUCT(TABLE1, AES_TABLE_SIZE)
84   STRUCT(TABLE2, AES_TABLE_SIZE)
85   STRUCT(TABLE3, AES_TABLE_SIZE)
86
87 C For 64-bit implementation
88 STRUCTURE(P1305)
89   STRUCT(R0, 8)
90   STRUCT(R1, 8)
91   STRUCT(S1, 8)
92   STRUCT(PAD, 12)
93   STRUCT(H2, 4)
94   STRUCT(H0, 8)
95   STRUCT(H1, 8)
96
97 divert