# XXX: nothing uses this ?
echo '#include <signal.h>' | \
bfin-uclinux-gcc -E -dD -P - | \
+grep -v SIGSTKSZ | \
sed -r -n \
-e '1istatic CB_TARGET_DEFS_MAP cb_linux_signal_map[] = {' \
-e '$i\ \ { 0, -1, -1 }\n};' \
#ifdef SIG_SETMASK
# define TARGET_LINUX_SIG_SETMASK 2
{ "SIG_SETMASK", SIG_SETMASK, TARGET_LINUX_SIG_SETMASK },
-#endif
-#ifdef SIGSTKSZ
-# define TARGET_LINUX_SIGSTKSZ 8192
- { "SIGSTKSZ", SIGSTKSZ, TARGET_LINUX_SIGSTKSZ },
#endif
{ 0, -1, -1 }
};
def gentvals(output: TextIO, cpp: str, srctype: str, srcdir: Path,
headers: Iterable[str],
pattern: str,
+ filter: str = r'^$',
target: str = None):
"""Extract constants from the specified files using a regular expression.
srcfile = ''.join(f'#include <{x}>\n' for x in headers)
syms = set()
define_pattern = re.compile(r'^#\s*define\s+(' + pattern + ')')
+ filter_pattern = re.compile(filter)
for header in headers:
with open(srcdir / header, 'r', encoding='utf-8') as fp:
data = fp.read()
for line in data.splitlines():
m = define_pattern.match(line)
- if m:
+ if m and not filter_pattern.search(line):
syms.add(m.group(1))
for sym in sorted(syms):
srcfile += f'#ifdef {sym}\nDEFVAL {{ "{sym}", {sym} }},\n#endif\n'
('errno.h', 'sys/errno.h'), 'E[A-Z0-9]*')
gentvals(output, cpp, 'signal', newlib / 'newlib/libc/include',
- ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*')
+ ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*', filter=r'SIGSTKSZ')
gentvals(output, cpp, 'open', newlib / 'newlib/libc/include',
('fcntl.h', 'sys/fcntl.h', 'sys/_default_fcntl.h'), r'O_[A-Z0-9]*')