summaryrefslogtreecommitdiff
path: root/asm.m4
blob: f24442da27c66b73c3138d107477bad9ade8a298 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
divert(-1)
changequote(<,>)dnl
dnl (progn (modify-syntax-entry ?< "(>") (modify-syntax-entry ?> ")<") )

dnl FORTRAN style comment character
define(<C>, <
dnl>)dnl
dnl Disable m4 comment processing, since the default, #, is used for
dnl constants on some architectures, in particular ARM.
changecom()dnl

dnl Including files from the srcdir
define(<include_src>, <include(srcdir/$1)>)dnl

dnl Pseudo ops

define(<PROLOGUE>,
<ifelse(ELF_STYLE,yes,
<.globl C_NAME($1)
.type C_NAME($1),TYPE_FUNCTION
C_NAME($1):>,
<.globl C_NAME($1)
C_NAME($1):>)>)

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

dnl Argument to ALIGN is always logarithmic
dnl FIXME: the << operator is not supported by Solaris m4,
dnl and ** is not supported by OpenBSD m4.
dnl We should switch to non-logarithmic ALIGN instead.

dnl Need changequote to be able to use the << operator.
define(<ALIGN>,
<changequote([,])dnl
.align ifelse(ALIGN_LOG,yes,$1,eval(1 << $1))dnl >> balance
changequote(<,>)dnl
>)

dnl Struct defining macros

dnl STRUCTURE(prefix) 
define(<STRUCTURE>, <define(<SOFFSET>, 0)define(<SPREFIX>, <$1>)>)dnl

dnl STRUCT(name, size)
define(<STRUCT>,
<define(SPREFIX<_>$1, SOFFSET)dnl
 define(<SOFFSET>, eval(SOFFSET + ($2)))>)dnl

dnl UCHAR(name)
define(<UCHAR>, <STRUCT(<$1>, 1)>)dnl

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

dnl Offsets in arcfour_ctx
STRUCTURE(ARCFOUR)
  STRUCT(S, 256)
  UCHAR(I)
  UCHAR(J)

dnl Offsets in aes_ctx and aes_table
STRUCTURE(AES)
  STRUCT(KEYS, 4*60)
  UNSIGNED(NROUNDS)

define(AES_SBOX_SIZE,	256)dnl
define(AES_TABLE_SIZE,	1024)dnl

STRUCTURE(AES)
  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)

divert