asm.m4 2.22 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
dnl default definition, changed in fat builds
16 17
define(<fat_transform>, <$1>)
define(<C_NAME>, <SYMBOL_PREFIX<>fat_transform($1)>)
18

19
dnl Pseudo ops
20
define(<DECLARE_FUNC>,
21
<ifelse(ELF_STYLE,yes,
22 23 24
<.type $1,TYPE_FUNCTION>,
COFF_STYLE, yes,
<.def $1
25 26
.scl 2
.type 32
27 28 29
.endef>,
<>)>)

30 31
define(<GMP_NUMB_BITS>,<>)dnl

32
define(<PROLOGUE>,
33 34 35
<.globl C_NAME($1)
DECLARE_FUNC(C_NAME($1))
C_NAME($1):>)
36 37 38

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

41 42 43 44 45 46 47 48
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.
49

50
define(<ALIGN>,
51
<.align ifelse(ALIGN_LOG,yes,<m4_log2($1)>,$1)
52
>)
53

54 55 56 57 58 59 60 61
define(<IF_BE>, <ifelse(
WORDS_BIGENDIAN,yes,<$1>,
WORDS_BIGENDIAN,no,<$2>,
<errprint(<Unsupported endianness value>,WORDS_BIGENDIAN,<
>)
  m4exit(1)>)>)
define(<IF_LE>, <IF_BE(<$2>, <$1>)>)

62 63 64
dnl Struct defining macros

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

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

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

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

78 79 80 81 82 83
dnl Offsets in arcfour_ctx
STRUCTURE(ARCFOUR)
  STRUCT(S, 256)
  UCHAR(I)
  UCHAR(J)

84
dnl Offsets in aes_table
85 86 87
define(AES_SBOX_SIZE,	256)dnl
define(AES_TABLE_SIZE,	1024)dnl

Niels Möller's avatar
Niels Möller committed
88
STRUCTURE(AES)
89 90 91 92 93
  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)
94

Niels Möller's avatar
Niels Möller committed
95 96 97 98 99 100 101 102 103 104
C For 64-bit implementation
STRUCTURE(P1305)
  STRUCT(R0, 8)
  STRUCT(R1, 8)
  STRUCT(S1, 8)
  STRUCT(PAD, 12)
  STRUCT(H2, 4)
  STRUCT(H0, 8)
  STRUCT(H1, 8)

105
divert