-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-macros.m4.in
103 lines (92 loc) · 3.79 KB
/
common-macros.m4.in
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
divert(-1)
Copyright © 2021 Barry Schwartz
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License, as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License
along with this program. If not, see
<https://www.gnu.org/licenses/>.
changecom(`/*',`*/')
define(`m4_undefine',defn(`undefine')) m4_undefine(`undefine')
define(`m4_define',defn(`define')) m4_undefine(`define')
m4_define(`m4_include',defn(`include')) m4_undefine(`include')
m4_define(`m4_pushdef',defn(`pushdef')) m4_undefine(`pushdef')
m4_define(`m4_popdef',defn(`popdef')) m4_undefine(`popdef')
m4_define(`m4_shift',defn(`shift')) m4_undefine(`shift')
m4_define(`m4_if',defn(`ifelse')) m4_undefine(`ifelse')
m4_define(`m4_ifdef',defn(`ifdef')) m4_undefine(`ifdef')
m4_define(`m4_translit',defn(`translit')) m4_undefine(`translit')
m4_define(`m4_index',defn(`index')) m4_undefine(`index')
m4_define(`m4_incr',defn(`incr')) m4_undefine(`incr')
m4_define(`m4_decr',defn(`decr')) m4_undefine(`decr')
m4_define(`m4_len',defn(`len')) m4_undefine(`len')
m4_define(`m4_divnum',defn(`divnum')) m4_undefine(`divnum')
m4_define(`m4_eval',defn(`eval')) m4_undefine(`eval')
m4_define(`m4_substr',defn(`substr')) m4_undefine(`substr')
dnl
dnl m4_foreachq(x, `item_1, item_2, ..., item_n', statement)
dnl
m4_define(`m4_foreachq',
`m4_if(`$2',`',`',
`m4_pushdef(`$1')_$0(`$1',`$3',`',$2)m4_popdef(`$1')')')
m4_define(`_m4_foreachq',
`m4_if(`$#',`3',`',
`m4_define(`$1',`$4')$2`'$0(`$1',`$2',m4_shift(m4_shift(m4_shift($@))))')')
dnl
dnl m4_forloop(variable, from, to, statement)
dnl
m4_define(`m4_forloop',`m4_if(m4_eval(`($2) <= ($3)'),`1',
`m4_pushdef(`$1')_$0(`$1',m4_eval(`$2'),
m4_eval(`$3'),`$4')m4_popdef(`$1')')')
m4_define(`_m4_forloop',
`m4_define(`$1',`$2')$4`'m4_if(`$2',`$3',`',
`$0(`$1',m4_incr(`$2'),`$3',`$4')')')
m4_define(`m4_map_typename',
`m4_if(`$1',`uchar',`unsigned char',
`$1',`schar',`signed char',
`$1',`usint',`unsigned short int',
`$1',`uint',`unsigned int',
`$1',`ulint',`unsigned long int',
`$1',`ullint',`unsigned long long int',
`$1',`sint',`short int',
`$1',`int',`int',
`$1',`lint',`long int',
`$1',`llint',`long long int',
`$1',`uint8',`uint8_t',
`$1',`uint16',`uint16_t',
`$1',`uint32',`uint32_t',
`$1',`uint64',`uint64_t',
`$1',`uint128',`__uint128_t',
`$1',`int8',`int8_t',
`$1',`int16',`int16_t',
`$1',`int32',`int32_t',
`$1',`int64',`int64_t',
`$1',`int128',`__int128_t',
`$1',`uintmax',`uintmax_t',
`$1',`intmax',`intmax_t',
`$1',`uintptr',`uintptr_t',
`$1',`intptr',`intptr_t',
`$1',`size',`size_t',
`$1',`ssize',`ssize_t',
`$1')')
m4_define(`m4_signed_to_unsigned',
`m4_if(`$1',`schar',`uchar',
`$1',`sint',`usint',
`$1',`int',`uint',
`$1',`lint',`ulint',
`$1',`llint',`ullint',
`$1',`int8',`uint8',
`$1',`int16',`uint16',
`$1',`int32',`uint32',
`$1',`int64',`uint64',
`$1',`int128',`uint128',
`$1',`intmax',`uintmax',
`$1',`intptr',`uintptr',
`$1',`ssize',`size',
`FIXME')')
divert`'dnl