libk  Check-in [d77ef26adf]

Overview
Comment:modify build system to replace extremely fragile error code generation mechanism
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d77ef26adfc782b0b47f886453e79d8fe16298d13522587ee430795ce6a0dab9
User & Date: lexi on 2019-08-21 04:24:21
Other Links: manifest | tags
Context
2019-08-21
04:50
Add initial build setup for Nix check-in: a26e579866 user: glow tags: trunk
04:24
modify build system to replace extremely fragile error code generation mechanism check-in: d77ef26adf user: lexi tags: trunk
03:44
make crt behave as a C runtime launcher should; comment code thoroughly check-in: f0f16493ca user: lexi tags: trunk
Changes

Added arch/posix/errnos version [cc3bf9e501].























>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
EPERM
EINVAL
EBADF
EFAULT
ENOSPC
EDQUOT
EIO
EAGAIN
EFBIG
EINTR
EDESTADDRREQ

Modified build.sh from [e1362458a3] to [4eaecd6098].

182
183
184
185
186
187
188






189
190
191
192
193
194
195
196



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
	# we wish to import; we use sed to transform this into a form
	# that cpp will fill out for us, producing a table that the
	# awk scripts can handle and turn into a list of constants.
	echo '#include <sys/syscall.h>' > $gen/system_calls.t.1 # this is the magic part
	cat arch/posix/syscalls > $gen/system_calls.t.2
	sed -e 's;^\(.*\)$;\1 SYS_\1;' -i $gen/system_calls.t.2
	cat $gen/system_calls.t.1 $gen/system_calls.t.2 | cpp -P >$gen/system_calls.tbl






else
	case $os in
		# lin) grep -h "#define __NR_" $p_headers_syscall | sed 's;^#define __NR_;;' > $gen/system_calls.tbl;;
		# fbsd) grep -h "#define	SYS_" $p_headers_syscall | sed 's;^#define	SYS_;;' | sed 's;[\t ]\+; ;' > $gen/system_calls.tbl;;
		*) noimpl 'system call table generation';;
	esac
fi
# cat $p_headers_syscall $gen/system_calls.tbl | cpp -P |



awk -f arch/syscall.awk -v out=s <$gen/system_calls.tbl>$gen/system_calls.s
# cat $p_headers_syscall $gen/system_calls.tbl | cpp -P |
awk -f arch/syscall.awk -v out=h <$gen/system_calls.tbl>$gen/system_calls.h

# generate errno tables
grep -h "#[ 	]*define[ 	]\+E" $p_headers_errno |
	sed 's;^#[\t ]*define[\t ]\+\(E[A-Z0-9]\+\).*$;k_platform_error_\1 \1;' >\
	$gen/error_names.tbl
cat $p_headers_errno $gen/error_names.tbl | cpp -P >$gen/error_numbers.tbl
awk -f arch/errtbl.awk <$gen/error_numbers.tbl >$gen/error_table.h

# generate symbol tables for error handling functions
mkdir -p "$to/k"
awk -f global/gen-conds.awk <global/modules >$to/k/internal.egroup.h
awk -f global/gen-ident.awk <global/modules >$gen/internal.ident.c
comp_co $gen/internal.ident.c $to/internal.ident.o








>
>
>
>
>
>


<
<



<
>
>
>

<


<
|
<
<
<
|







182
183
184
185
186
187
188
189
190
191
192
193
194
195
196


197
198
199

200
201
202
203

204
205

206



207
208
209
210
211
212
213
214
	# we wish to import; we use sed to transform this into a form
	# that cpp will fill out for us, producing a table that the
	# awk scripts can handle and turn into a list of constants.
	echo '#include <sys/syscall.h>' > $gen/system_calls.t.1 # this is the magic part
	cat arch/posix/syscalls > $gen/system_calls.t.2
	sed -e 's;^\(.*\)$;\1 SYS_\1;' -i $gen/system_calls.t.2
	cat $gen/system_calls.t.1 $gen/system_calls.t.2 | cpp -P >$gen/system_calls.tbl

	# generate errno tables the same way
	echo '#include <errno.h>' > $gen/error_codes.t.1 # this is the magic part
	cat arch/posix/errnos > $gen/error_codes.t.2
	sed -e 's;^\(.*\)$;k_platform_error_\1 \1;' -i $gen/error_codes.t.2
	cat $gen/error_codes.t.1 $gen/error_codes.t.2 | cpp -P | grep "^k_platform_error" >$gen/error_codes.tbl # haaaack
else
	case $os in


		*) noimpl 'system call table generation';;
	esac
fi


# take the OS-specific system call tables that have been prepared
# for us above and feed them into awk scripts to generate C headers
awk -f arch/syscall.awk -v out=s <$gen/system_calls.tbl>$gen/system_calls.s

awk -f arch/syscall.awk -v out=h <$gen/system_calls.tbl>$gen/system_calls.h


# do the same with our error codes table



awk -f arch/errtbl.awk <$gen/error_codes.tbl >$gen/error_table.h

# generate symbol tables for error handling functions
mkdir -p "$to/k"
awk -f global/gen-conds.awk <global/modules >$to/k/internal.egroup.h
awk -f global/gen-ident.awk <global/modules >$gen/internal.ident.c
comp_co $gen/internal.ident.c $to/internal.ident.o