add packaging
[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 Pseudo ops
16
17 define(<PROLOGUE>,
18 <ifelse(ELF_STYLE,yes,
19 <.globl C_NAME($1)
20 .type C_NAME($1),TYPE_FUNCTION
21 C_NAME($1):>,
22 <.globl C_NAME($1)
23 C_NAME($1):>)>)
24
25 define(<EPILOGUE>,
26 <ifelse(ELF_STYLE,yes,
27 <.size C_NAME($1), . - C_NAME($1)>,<>)>)
28
29 define(<m4_log2>, <m4_log2_internal($1,1,0)>)
30 define(<m4_log2_internal>,
31 <ifelse($3, 10, <not-a-power-of-two>,
32 $1, $2, $3,
33 <m4_log2_internal($1, eval(2*$2), eval(1 + $3))>)>)
34
35 dnl Argument to ALIGN is always in bytes, and converted to a
36 dnl logarithmic .align if necessary.
37
38 define(<ALIGN>,
39 <.align ifelse(ALIGN_LOG,yes,<m4_log2($1)>,$1)
40 >)
41
42 dnl Struct defining macros
43
44 dnl STRUCTURE(prefix) 
45 define(<STRUCTURE>, <define(<SOFFSET>, 0)define(<SPREFIX>, <$1>)>)dnl
46
47 dnl STRUCT(name, size)
48 define(<STRUCT>,
49 <define(SPREFIX<_>$1, SOFFSET)dnl
50  define(<SOFFSET>, eval(SOFFSET + ($2)))>)dnl
51
52 dnl UCHAR(name)
53 define(<UCHAR>, <STRUCT(<$1>, 1)>)dnl
54
55 dnl UNSIGNED(name)
56 define(<UNSIGNED>, <STRUCT(<$1>, 4)>)dnl
57
58 dnl Offsets in arcfour_ctx
59 STRUCTURE(ARCFOUR)
60   STRUCT(S, 256)
61   UCHAR(I)
62   UCHAR(J)
63
64 dnl Offsets in aes_ctx and aes_table
65 STRUCTURE(AES)
66   STRUCT(KEYS, 4*60)
67   UNSIGNED(NROUNDS)
68
69 define(AES_SBOX_SIZE,   256)dnl
70 define(AES_TABLE_SIZE,  1024)dnl
71
72 STRUCTURE(AES)
73   STRUCT(SBOX, AES_SBOX_SIZE)
74   STRUCT(TABLE0, AES_TABLE_SIZE)
75   STRUCT(TABLE1, AES_TABLE_SIZE)
76   STRUCT(TABLE2, AES_TABLE_SIZE)
77   STRUCT(TABLE3, AES_TABLE_SIZE)
78
79 divert