summaryrefslogblamecommitdiffstats
path: root/linux/syscall-table.mk
blob: a90be35f9078d6ca5040c022cd668cdd2df9e0d3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12

                                                     









                                                                                                                              
                                                                                                             
                 
                                                                                                                  




                                                                                       


                                       

 
                                                                    





                                                          
                                                                                   


                                                      


                                                                                  
























                                                                                              



                                                                                 
# See LICENSE file for copyright and license details.

OBJ += linux/syscall-table.o


linux/syscall-table.o: generated/linux-syscall-table.h linux/syscalls.h $(LINUX_SYSCALLS_HDR) generated/linux-syscall-dedup.h
linux/syscall-table.lo: generated/linux-syscall-table.h linux/syscalls.h $(LINUX_SYSCALLS_HDR) generated/linux-syscall-dedup.h

libsyscalls_get_syscall_range.o: $(LINUX_SYSCALLS_HDR)
libsyscalls_get_syscall_range.lo: $(LINUX_SYSCALLS_HDR)


generated/linux-syscall-table.h: linux/syscall-table.c common.h linux/linux-support.mk linux/syscall-table.mk
	set -e; \
	macros="$$(sed -n 's/^$(s)*$(h)$(s)*define$(s)\{1,\}MAKE_\([^(]*\)(.*$$/\1/p' < linux/syscall-table.c)"; \
	for arch in $(SUPPORTED_LINUX_ARCHES); do \
		for macro in $$macros; do \
			printf '\43define MAKE_%s_%s(...) MAKE_%s(%s, __VA_ARGS__)\n' \
				"$$arch" "$$macro" "$$macro" "$$arch"; \
		done; \
	done \
	| sed 's/_[BL]E\([_,]\)/\1/g' \
	| sort -u > $@


generated/linux-syscalls.h: linux/syscalls.mk linux/syscall-table.mk
	mkdir -p -- generated
	printf '\43include "%s"\n' $(LINUX_SYSCALLS_HDR) \
	| grep -v '"$@"' \
	| sed 's:generated/::' > $@


generated/linux-syscall-ranges.h: $(LINUX_SYSCALLS_ARCH_HDR) linux/syscall-table.mk
	printf '%s\n' 'This may take some time ...'; \
	set -e; arch=; \
	cat -- $(LINUX_SYSCALLS_ARCH_HDR) \
	| sed 's/^$(s)*X[A-Z_]*(\([^,]*\).*$$/\1/' \
	| sed 's/$(h)$(s)*define$(s)\{1,\}LIST_LINUX_SYSCALLS_FOR_\(.*\)(.*/\1/' \
	| sed '/^$(s)*$$/d' \
	| (\
		while read line; do \
			if test -z "$$(printf '%s\n' "$$line" | sed 's/^[A-Z].*$$//')"; then \
				if test -n "$$arch"; then \
					printf '\43define %s_LINUX_SYSCALL_FOR_%s %i\n' \
						MIN "$$arch" "$$min" \
						MAX "$$arch" "$$max"; \
				fi; \
				arch="$$line"; \
				min=; \
				max=; \
			else \
				val=$$(( $$line )); \
				if test -z "$$min" || test "$$val" -lt "$$min"; then \
					min=$$val; \
				fi; \
				if test -z "$$max" || test "$$val" -gt "$$max"; then \
					max=$$val; \
				fi; \
			fi; \
		done; \
		printf '\43define %s_LINUX_SYSCALL_FOR_%s %i\n' \
			MIN "$$arch" "$$min" \
			MAX "$$arch" "$$max"; \
	) > $@
	printf '\43define MIN_LINUX_SYSCALL_FOR_%s\n' $(SUPPORTED_LINUX_ARCHES) \
	| sed -n 's/\(MIN_LINUX_SYSCALL_FOR_.*\)_[LB]E$$/& \1/p' >> $@
	printf '\43define MAX_LINUX_SYSCALL_FOR_%s\n' $(SUPPORTED_LINUX_ARCHES) \
	| sed -n 's/\(MAX_LINUX_SYSCALL_FOR_.*\)_[LB]E$$/& \1/p' >> $@