asm.m4 1.75 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
dnl Argument to ALIGN is always logarithmic
30
31
32
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.
33

34
dnl Need changequote to be able to use the << operator.
35
define(<ALIGN>,
36
37
38
39
<changequote([,])dnl
.align ifelse(ALIGN_LOG,yes,$1,eval(1 << $1))dnl >> balance
changequote(<,>)dnl
>)
40

41
42
43
dnl Struct defining macros

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

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

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

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

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

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

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

Niels Möller's avatar
Niels Möller committed
71
STRUCTURE(AES)
72
73
74
75
76
  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)
77
78

divert