asm.m4 1.72 KB
Newer Older
1
divert(-1)
2
changequote(<,>)dnl
3
dnl (progn (modify-syntax-entry ?< "(>") (modify-syntax-entry ?> ")<") )
Niels Möller's avatar
Niels Möller committed
4
5

dnl FORTRAN style comment character
6
7
define(<C>, <
dnl>)dnl
8
9
10
dnl Disable m4 comment processing, since the default, #, is used for
dnl constants on some architectures, in particular ARM.
changecom()dnl
Niels Möller's avatar
Niels Möller committed
11

Niels Möller's avatar
Niels Möller committed
12
dnl Including files from the srcdir
13
define(<include_src>, <include(srcdir/$1)>)dnl
Niels Möller's avatar
Niels Möller committed
14

15
16
17
18
19
dnl Pseudo ops

define(<PROLOGUE>,
<ifelse(ELF_STYLE,yes,
<.globl C_NAME($1)
Niels Möller's avatar
Niels Möller committed
20
.type C_NAME($1),TYPE_FUNCTION
21
22
23
24
25
26
C_NAME($1):>,
<.globl C_NAME($1)
C_NAME($1):>)>)

define(<EPILOGUE>,
<ifelse(ELF_STYLE,yes,
27
<.size C_NAME($1), . - C_NAME($1)>,<>)>)
28

29
30
31
32
33
34
35
36
define(<m4_log2>, <m4_log2_internal($1,1,0)>)
define(<m4_log2_internal>,
<ifelse($3, 10, <not-a-power-of-two>,
$1, $2, $3,
<m4_log2_internal($1, eval(2*$2), eval(1 + $3))>)>)

dnl Argument to ALIGN is always in bytes, and converted to a
dnl logarithmic .align if necessary.
37

38
define(<ALIGN>,
39
<.align ifelse(ALIGN_LOG,yes,<m4_log2($1)>,$1)
40
>)
41

42
43
44
dnl Struct defining macros

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
53
54
dnl UCHAR(name)
define(<UCHAR>, <STRUCT(<$1>, 1)>)dnl

55
dnl UNSIGNED(name)
56
define(<UNSIGNED>, <STRUCT(<$1>, 4)>)dnl
57

58
59
60
61
62
63
dnl Offsets in arcfour_ctx
STRUCTURE(ARCFOUR)
  STRUCT(S, 256)
  UCHAR(I)
  UCHAR(J)

64
dnl Offsets in aes_ctx and aes_table
65
66
67
STRUCTURE(AES)
  STRUCT(KEYS, 4*60)
  UNSIGNED(NROUNDS)
68

69
70
71
define(AES_SBOX_SIZE,	256)dnl
define(AES_TABLE_SIZE,	1024)dnl

Niels Möller's avatar
Niels Möller committed
72
STRUCTURE(AES)
73
74
75
76
77
  STRUCT(SBOX, AES_SBOX_SIZE)
  STRUCT(TABLE0, AES_TABLE_SIZE)
  STRUCT(TABLE1, AES_TABLE_SIZE)
  STRUCT(TABLE2, AES_TABLE_SIZE)
  STRUCT(TABLE3, AES_TABLE_SIZE)
78
79

divert