minix/kernel/extract-mfield.sh
David van Moolenbroek 80bd109cd3 libsys: various updates
- move system calls for use by services from libminlib into libsys;
- move srv_fork(2) and srv_kill(2) from RS and into libsys;
- replace getprocnr(2) with sef_self(3);
- rename previous getnprocnr(2) to getprocnr(2);
- clean up getepinfo(2);
- change all libsys calls that used _syscall to use _taskcall, so as
  to avoid going through errno to pass errors; this is already how
  most calls work anyway, and many of the calls previously using
  _syscall were already assumed to return the actual error;
- initialize request messages to zero, for future compatibility
  (note that this does not include PCI calls, which are in need of a
  much bigger overhaul, nor kernel calls);
- clean up more of dead DS code as a side effect.

Change-Id: I8788f54c68598fcf58e23486e270c2d749780ebb
2014-03-01 09:05:00 +01:00

45 lines
1.4 KiB
Bash

#!/bin/sh
set -e
find_files_and_lines()
(
find ../lib/libc/sys-minix ../lib/libsys -name '*.c' | \
xargs egrep -n '((_syscall|_taskcall)\([^,][^,]*,[ ]*|_kernel_call\()[A-Z_][A-Z0-9_]*,[ ]*&m\)' | \
cut -d: -f1,2
)
# grep message fields
(
# find references to _syscall, _taskcall and _kernel_call in the libraries
pathprev=
linecallprev=0
for f in `find_files_and_lines`
do
path="`echo $f | cut -d: -f1`"
linecall="`echo $f | cut -d: -f2`"
# find the matching message declaration; we can identify fields between message decl and call
linemsg=`head -n "$linecall" "$path" | egrep -n 'message[ ][ ]*m;' | tail -n 1 | cut -d: -f1`
if [ "x$linemsg" != "x" ]
then
# watch out: message may be re-used; start from last call in this case
[ \( "x$path" != "x$pathprev" \) -o \( "$linemsg" -gt "$linecallprev" \) ] || linemsg="$linecallprev"
# extract call name
callname=`head -n "$linecall" "$path" | tail -n 1 | sed 's/.*[ (,]\([A-Z_][A-Z0-9_]*\),[ ]*&m).*/\1/'`
# extract message fields
linelast="`expr "$linecall" - 1`"
linecount="`expr "$linelast" - "$linemsg"`"
head -n "$linelast" "$path" | \
tail -n "$linecount" | \
tr ' \t' ' ' | \
egrep '^ *m\.[A-Za-z_][A-Za-z0-9_]* *=' | \
sed 's/^ *m\.\([A-Za-z_][A-Za-z0-9_]*\) *=.*/IDENT('$callname', \1)/'
fi
pathprev="$path"
linemsgprev="$linemsg"
done
) | sort | uniq