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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/* -*- asm -*-
* Creation Date: <2001/12/30 20:08:53 samuel>
* Time-stamp: <2002/01/14 00:48:09 samuel>
*
* <asm.m4>
*
* m4 initialization (m4 is used as an assembly preprocessor)
*
* Copyright (C) 2001, 2002 Samuel Rydh (samuel@ibrium.se)
*
* 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
*
*/
/* This end-of-quote matches the start-of-quote in mol_config.h */
]]]]]
changequote([,])
dnl m4 macros to avoid in header files (we can not rename these)
dnl ==========================================================
dnl shift, eval, expr, decr, incr, ifelse, popdef, pushdef
dnl **************************************************************
dnl * Rename to reduce namespace conflicts
dnl **************************************************************
dnl *** Changing the name of built-in macros using defn does not always work ***
undefine([changecom])
undefine([changequote])
dnl undefine([decr])
undefine([defn])
undefine([divert])
undefine([divnum])
undefine([errprint])
dnl undefine([eval])
dnl undefine([expr])
undefine([file])
undefine([format])
undefine([len])
undefine([line])
dnl undefine([ifelse])
dnl undefine([incr])
undefine([indir])
undefine([include])
undefine([index])
undefine([maketemp])
undefine([paste])
undefine([patsubst])
dnl undefine([popdef])
dnl undefine([pushdef])
undefine([regexp])
dnl undefine([shift])
undefine([sinclude])
undefine([spaste])
undefine([substr])
undefine([syscmd])
undefine([sysval])
undefine([translit])
undefine([traceoff])
undefine([traceon])
undefine([undivert])
undefine([unix])
dnl undefine([__gnu__])
dnl undefine([__unix__])
dnl Uncomment to list m4 definitions
dnl dumpdef m4exit
/************************************************************************/
/* M4 Macros */
/************************************************************************/
/* WARNING - M4 BUG IN MacOS X (10.1.2):
* eval() in MacOS X (10.1.2) handles '&' as '&&' and '|' as '||'.
*/
/* FORLOOP(var, from, to, [body var...]) */
define([mFORLOOP], [pushdef([$1], [$2])_mFORLOOP([$1], [$2], [$3], [$4])popdef([$1])])
define([_mFORLOOP], [$4[]ifelse($1, [$3], ,
[define([$1], incr($1))_mFORLOOP([$1], [$2], [$3], [$4])])])
define([mFIRST],[$1])
define([mCONCAT_C],[ [$@] ])
/* FOREACH(var, [item1, ...], [body var ...]) */
define([mFOREACH],[pushdef([$1],mFIRST($2))_mFOREACH([$1],[shift($2)],[$3])popdef([$1])])
define([_mFOREACH],[$3] [ifelse(mFIRST($2),,,[define([$1],mFIRST($2)) _mFOREACH([$1],[shift($2)],[$3])])])
/******************** Nice macro definitions **************************/
/* MACRO(name, [param1, ...], [body _param1 ...]) */
#ifdef __linux__
define([MACRO], [
.macro [$1] $2
mFOREACH([i],[$2],[ pushdef(_[]i,\i) ])
$3
.endm
mFOREACH([i],[$2],[ popdef(_[]i) ])
])
#else
define([MACRO], [
.macro [$1]
pushdef([_n],0)
mFOREACH([i],[$2],[ pushdef(_[]i,[$[]]_n) define([_n],incr(_n)) ])
$3
.endmacro
mFOREACH([i],[$2],[ popdef(_[]i) ])
popdef([_n])
])
#endif
define([MACRO_0], [MACRO([$1],[_dummy_param_],[$2])])
/* mDEFINE(name, [param1, ...], [body _param1 ...]) */
define([mDEFINE], [
pushdef([_n],1)
mFOREACH([i],[$2],[ pushdef(_[]i,[$[]]_n) define([_n],incr(_n)) ])
define([$1], mCONCAT_C($3) )
mFOREACH([i],[$2],[ popdef(_[]i) ])
popdef([_n])
])
/* rLABEL(label): b label_b ; b label_f */
define(rLABEL,[dnl
ifdef([$1]_curnum,,[$1[]f:])dnl
define([_tmp_curnum],ifdef($1[]_curnum, [eval($1_curnum+1)], 1)) dnl
define([$1]_curnum,_tmp_curnum)dnl
define([$1]f,$1_[]eval($1_curnum[]+1) )dnl
define([$1]b,$1_[]$1_curnum[] )
$1[]_[]$1_curnum[]dnl
])
|