diff --git a/Config.in b/Config.in index 546e8249c..6d71d4c6e 100644 --- a/Config.in +++ b/Config.in @@ -5,7 +5,7 @@ mainmenu "OpenWrt Configuration" config MODULES - option modules + modules bool default y @@ -13,6 +13,14 @@ config HAVE_DOT_CONFIG bool default y +HOST_OS := $(shell, uname) + +config HOST_OS_LINUX + def_bool $(shell, ./config/check-uname.sh Linux) + +config HOST_OS_MACOS + def_bool $(shell, ./config/check-uname.sh Darwin) + source "target/Config.in" source "config/Config-images.in" diff --git a/Makefile b/Makefile index e18bc1860..cbf9fa2cd 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir world: -DISTRO_PKG_CONFIG:=$(shell which -a pkg-config | grep -E '\/usr' | head -n 1) +DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1) export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH) ifneq ($(OPENWRT_BUILD),1) @@ -38,7 +38,7 @@ else include tools/Makefile include toolchain/Makefile -$(toolchain/stamp-compile): $(tools/stamp-compile) +$(toolchain/stamp-compile): $(tools/stamp-compile) $(if $(CONFIG_BUILDBOT),toolchain_rebuild_check) $(target/stamp-compile): $(toolchain/stamp-compile) $(tools/stamp-compile) $(BUILD_DIR)/.prepared $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup) $(package/stamp-install): $(package/stamp-compile) @@ -50,14 +50,23 @@ printdb: prepare: $(target/stamp-compile) -clean: FORCE - rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(BUILD_LOG_DIR) $(TOPDIR)/staging_dir/packages +_clean: FORCE + rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(TOPDIR)/staging_dir/packages -dirclean: clean - rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/host $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN) +clean: _clean + rm -rf $(BUILD_LOG_DIR) + +targetclean: _clean + rm -rf $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN) + +dirclean: targetclean clean + rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(BUILD_DIR_BASE)/host rm -rf $(TMP_DIR) $(MAKE) -C $(TOPDIR)/scripts/config clean +toolchain_rebuild_check: + $(SCRIPT_DIR)/check-toolchain-clean.sh + cacheclean: ifneq ($(CONFIG_CCACHE),) $(STAGING_DIR_HOST)/bin/ccache -C diff --git a/config/Config-build.in b/config/Config-build.in index 6e2864401..c2303637c 100644 --- a/config/Config-build.in +++ b/config/Config-build.in @@ -14,14 +14,14 @@ config EXPERIMENTAL positive and negative). But do so only if you know how to recover your device in case of flashing potentially non-working firmware. - + If you plan to use this build in production, say NO! menu "Global build settings" config JSON_OVERVIEW_IMAGE_INFO bool "Create JSON info file overview per target" - default BUILDBOT + default y help Create a JSON info file called profiles.json in the target directory containing machine readable list of built profiles @@ -78,7 +78,7 @@ menu "Global build settings" default n config BUILD_PATENTED - default y + default n bool "Compile with support for patented functionality" help When this option is disabled, software which provides patented functionality @@ -111,7 +111,7 @@ menu "Global build settings" default n help This makes file checksums part of package metadata. It increases size - but provides you with pkg_check command to check for flash coruptions. + but provides you with pkg_check command to check for flash corruptions. config INCLUDE_CONFIG bool "Include build configuration in firmware" if DEVEL @@ -154,17 +154,12 @@ menu "Global build settings" Adds -g3 to the CFLAGS. config IPV6 - bool - prompt "Enable IPv6 support in packages" - default y - help - Enables IPv6 support in kernel (builtin) and packages. + def_bool y comment "Stripping options" choice prompt "Binary stripping method" - default USE_STRIP if EXTERNAL_TOOLCHAIN default USE_STRIP if USE_GLIBC default USE_SSTRIP help @@ -221,20 +216,6 @@ menu "Global build settings" make the system libraries incompatible with most of the packages that are not selected during the build process. - choice - prompt "Preferred standard C++ library" - default USE_LIBSTDCXX if USE_GLIBC - default USE_UCLIBCXX - help - Select the preferred standard C++ library for all packages that support this. - - config USE_UCLIBCXX - bool "uClibc++" - - config USE_LIBSTDCXX - bool "libstdc++" - endchoice - comment "Hardening build options" config PKG_CHECK_FORMAT_SECURITY @@ -390,4 +371,16 @@ menu "Global build settings" endchoice + config SECCOMP + bool "Enable SECCOMP" + select KERNEL_SECCOMP + select PACKAGE_procd-seccomp + depends on (aarch64 || arm || armeb || mips || mipsel || mips64 || mips64el || i386 || powerpc || x86_64) + depends on !TARGET_uml + default y + help + This option enables seccomp kernel features to safely + execute untrusted bytecode and selects the seccomp-variants + of procd + endmenu diff --git a/config/Config-devel.in b/config/Config-devel.in index 528f221d1..e16e6ecaa 100644 --- a/config/Config-devel.in +++ b/config/Config-devel.in @@ -59,6 +59,13 @@ menuconfig DEVEL This allows you to symlink build_dir into a scratch location, e.g. a ramdisk, which does not have enough space to keep a complete build_dir. + config BUILD_ALL_HOST_TOOLS + bool "Compile all host tools" if DEVEL + default n + help + Compile all host host tools even if not needed. This is needed to prepare a + universal precompiled host tools archive to use in another buildroot. + config BUILD_SUFFIX string "Build suffix to append to the target BUILD_DIR variable" if DEVEL default "" @@ -88,6 +95,11 @@ menuconfig DEVEL Store ccache in this directory. If not set, uses './.ccache' + config KERNEL_CFLAGS + string "Kernel extra CFLAGS" if DEVEL + default "-falign-functions=32" if TARGET_bcm53xx + default "" + config EXTERNAL_KERNEL_TREE string "Use external kernel tree" if DEVEL default "" diff --git a/config/Config-images.in b/config/Config-images.in index 004b33c92..6c1408614 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -48,7 +48,7 @@ menu "Target Images" bool "xz" config TARGET_INITRAMFS_COMPRESSION_ZSTD - depends on !LINUX_5_4 && !LINUX_4_19 + depends on !LINUX_5_4 bool "zstd" endchoice @@ -152,7 +152,7 @@ menu "Target Images" bool "squashfs" default y if USES_SQUASHFS help - Build a squashfs-lzma root filesystem. + Build a squashfs root filesystem. config TARGET_SQUASHFS_BLOCK_SIZE int "Block size (in KiB)" @@ -160,6 +160,9 @@ menu "Target Images" default 64 if LOW_MEMORY_FOOTPRINT default 1024 if (SMALL_FLASH && !LOW_MEMORY_FOOTPRINT) default 1024 + help + Select squashfs block size, must be one of: + 4, 8, 16, 32, 64, 128, 256, 512, 1024 menuconfig TARGET_ROOTFS_UBIFS bool "ubifs" @@ -287,23 +290,24 @@ menu "Target Images" config TARGET_IMAGES_GZIP bool "GZip images" depends on TARGET_ROOTFS_EXT4FS || TARGET_x86 || TARGET_armvirt || TARGET_malta - default n + default y comment "Image Options" source "target/linux/*/image/Config.in" config TARGET_KERNEL_PARTSIZE - int "Kernel partition size (in MB)" + int "Kernel partition size (in MiB)" depends on USES_BOOT_PART default 8 if TARGET_apm821xx_sata default 64 if TARGET_bcm27xx - default 64 + default 64 if TARGET_rockchip + default 16 config TARGET_ROOTFS_PARTSIZE - int "Root filesystem partition size (in MB)" - depends on USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS || TARGET_omap || TARGET_sunxi || TARGET_uml - default 160 + int "Root filesystem partition size (in MiB)" + depends on USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS + default 400 help Select the root filesystem partition size. diff --git a/config/Config-kernel.in b/config/Config-kernel.in index e681f3cda..b6177421c 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -24,11 +24,6 @@ config KERNEL_PRINTK bool "Enable support for printk" default y -config KERNEL_CRASHLOG - bool "Crash logging" - depends on !(arm || powerpc || sparc || TARGET_uml || i386 || x86_64) - default y - config KERNEL_SWAP bool "Support for paging of anonymous memory (swap)" default y if !SMALL_FLASH @@ -48,8 +43,7 @@ config KERNEL_DEBUG_FS config KERNEL_MIPS_FP_SUPPORT bool - default y - depends on (mips || mipsel || mips64 || mips64el) + default y if TARGET_pistachio config KERNEL_ARM_PMU bool @@ -87,6 +81,11 @@ config KERNEL_PROFILING Enable the extended profiling support mechanisms used by profilers such as OProfile. +config KERNEL_RPI_AXIPERF + bool "Compile the kernel with RaspberryPi AXI Performance monitors" + default y + depends on KERNEL_PERF_EVENTS && TARGET_bcm27xx + config KERNEL_UBSAN bool "Compile the kernel with undefined behaviour sanity checker" help @@ -115,6 +114,16 @@ config KERNEL_UBSAN_ALIGNMENT Enabling this option on architectures that support unaligned accesses may produce a lot of false positives. +config KERNEL_UBSAN_BOUNDS + bool "Perform array index bounds checking" + depends on KERNEL_UBSAN + help + This option enables detection of directly indexed out of bounds array + accesses, where the array size is known at compile time. Note that + this does not protect array overflows via bad calls to the + {str,mem}*cpy() family of functions (that is addressed by + FORTIFY_SOURCE). + config KERNEL_UBSAN_NULL bool "Enable checking of null pointers" depends on KERNEL_UBSAN @@ -122,6 +131,19 @@ config KERNEL_UBSAN_NULL This option enables detection of memory accesses via a null pointer. +config KERNEL_UBSAN_TRAP + bool "On Sanitizer warnings, abort the running kernel code" + depends on KERNEL_UBSAN + help + Building kernels with Sanitizer features enabled tends to grow the + kernel size by around 5%, due to adding all the debugging text on + failure paths. To avoid this, Sanitizer instrumentation can just + issue a trap. This reduces the kernel size overhead but turns all + warnings (including potentially harmless conditions) into full + exceptions that abort the running kernel code (regardless of context, + locks held, etc), which may destabilize the system. For some system + builders this is an acceptable trade-off. + config KERNEL_KASAN bool "Compile the kernel with KASan: runtime memory debugger" select KERNEL_SLUB_DEBUG @@ -148,6 +170,30 @@ config KERNEL_KASAN_EXTRA compile time. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 has more +config KERNEL_KASAN_VMALLOC + bool "Back mappings in vmalloc space with real shadow memory" + depends on KERNEL_KASAN + help + By default, the shadow region for vmalloc space is the read-only + zero page. This means that KASAN cannot detect errors involving + vmalloc space. + + Enabling this option will hook in to vmap/vmalloc and back those + mappings with real shadow memory allocated on demand. This allows + for KASAN to detect more sorts of errors (and to support vmapped + stacks), but at the cost of higher memory usage. + + This option depends on HAVE_ARCH_KASAN_VMALLOC, but we can't + depend on that in here, so it is possible that enabling this + will have no effect. + +if KERNEL_KASAN + config KERNEL_KASAN_GENERIC + def_bool y + + config KERNEL_KASAN_SW_TAGS + def_bool n +endif choice prompt "Instrumentation type" @@ -303,6 +349,19 @@ config KERNEL_PREEMPT_TRACER enabled. This option and the irqs-off timing option can be used together or separately.) +config KERNEL_HIST_TRIGGERS + bool "Histogram triggers" + depends on KERNEL_FTRACE + help + Hist triggers allow one or more arbitrary trace event fields to be + aggregated into hash tables and dumped to stdout by reading a + debugfs/tracefs file. They're useful for gathering quick and dirty + (though precise) summaries of event activity as an initial guide for + further investigation using more advanced tools. + + Inter-event tracing of quantities such as latencies is also + supported using hist triggers under this option. + config KERNEL_DEBUG_KERNEL bool default n @@ -314,6 +373,34 @@ config KERNEL_DEBUG_INFO help This will compile your kernel and modules with debug information. +config KERNEL_DEBUG_INFO_BTF + + bool "Enable additional BTF type information" + default n + depends on !HOST_OS_MACOS + depends on KERNEL_DEBUG_INFO && !KERNEL_DEBUG_INFO_REDUCED + select DWARVES + help + Generate BPF Type Format (BTF) information from DWARF debug info. + Turning this on expects presence of pahole tool, which will convert + DWARF type info into equivalent deduplicated BTF type info. + + Required to run BPF CO-RE applications. + +config KERNEL_DEBUG_INFO_REDUCED + bool "Reduce debugging information" + default y + depends on KERNEL_DEBUG_INFO + help + If you say Y here gcc is instructed to generate less debugging + information for structure types. This means that tools that + need full debugging information (like kgdb or systemtap) won't + be happy. But if you merely need debugging information to + resolve line numbers there is no loss. Advantage is that + build directory object sizes shrink dramatically over a full + DEBUG_INFO build and compile times are reduced too. + Only works with newer gcc versions. + config KERNEL_DEBUG_LL_UART_NONE bool default n @@ -327,6 +414,14 @@ config KERNEL_DEBUG_LL help ARM low level debugging. +config KERNEL_DEBUG_VIRTUAL + bool "Compile the kernel with VM translations debugging" + select KERNEL_DEBUG_KERNEL + default n + help + Enable checks sanity checks to catch invalid uses of + virt_to_phys()/phys_to_virt() against the non-linear address space. + config KERNEL_DYNAMIC_DEBUG bool "Compile the kernel with dynamic printk" select KERNEL_DEBUG_FS @@ -368,6 +463,21 @@ config KERNEL_KPROBE_EVENTS bool default y if KERNEL_KPROBES +config KERNEL_BPF_EVENTS + bool "Compile the kernel with BPF event support" + default n + select KERNEL_KPROBES + help + Allows to attach BPF programs to kprobe, uprobe and tracepoint events. + This is required to use BPF maps of type BPF_MAP_TYPE_PERF_EVENT_ARRAY + for sending data from BPF programs to user-space for post-processing + or logging. + +config KERNEL_BPF_KPROBE_OVERRIDE + bool + default n + depends on KERNEL_KPROBES + config KERNEL_AIO bool "Compile the kernel with asynchronous IO support" default y if !SMALL_FLASH @@ -437,34 +547,22 @@ config KERNEL_PROVE_LOCKING select KERNEL_DEBUG_KERNEL default n -config KERNEL_LOCKUP_DETECTOR - bool "Compile the kernel with detect Hard and Soft Lockups" +config KERNEL_SOFTLOCKUP_DETECTOR + bool "Compile the kernel with detect Soft Lockups" depends on KERNEL_DEBUG_KERNEL help Say Y here to enable the kernel to act as a watchdog to detect - hard and soft lockups. + soft lockups. Softlockups are bugs that cause the kernel to loop in kernel mode for more than 20 seconds, without giving other tasks a chance to run. The current stack trace is displayed upon detection and the system will stay locked up. - Hardlockups are bugs that cause the CPU to loop in kernel mode - for more than 10 seconds, without letting other interrupts have a - chance to run. The current stack trace is displayed upon detection - and the system will stay locked up. - - The overhead should be minimal. A periodic hrtimer runs to - generate interrupts and kick the watchdog task every 4 seconds. - An NMI is generated every 10 seconds or so to check for hardlockups. - - The frequency of hrtimer and NMI events and the soft and hard lockup - thresholds can be controlled through the sysctl watchdog_thresh. - config KERNEL_DETECT_HUNG_TASK bool "Compile the kernel with detect Hung Tasks" depends on KERNEL_DEBUG_KERNEL - default KERNEL_LOCKUP_DETECTOR + default KERNEL_SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to detect "hung tasks", which are bugs that cause the task to be stuck in @@ -681,7 +779,7 @@ if KERNEL_CGROUPS bool "Memory Resource Controller for Control Groups" default y select KERNEL_FREEZER - depends on KERNEL_RESOURCE_COUNTERS || !LINUX_3_18 + depends on KERNEL_RESOURCE_COUNTERS help Provides a memory resource controller that manages both anonymous memory and page cache. (See Documentation/cgroups/memory.txt) @@ -944,6 +1042,19 @@ config KERNEL_IP_MROUTE Multicast routing requires a multicast routing daemon in addition to kernel support. +if KERNEL_IP_MROUTE + + config KERNEL_IP_MROUTE_MULTIPLE_TABLES + def_bool y + + config KERNEL_IP_PIMSM_V1 + def_bool y + + config KERNEL_IP_PIMSM_V2 + def_bool y + +endif + # # IPv6 configuration # @@ -966,8 +1077,15 @@ if KERNEL_IPV6 Multicast routing requires a multicast routing daemon in addition to kernel support. - config KERNEL_IPV6_PIMSM_V2 - def_bool n + if KERNEL_IPV6_MROUTE + + config KERNEL_IPV6_MROUTE_MULTIPLE_TABLES + def_bool y + + config KERNEL_IPV6_PIMSM_V2 + def_bool y + + endif config KERNEL_IPV6_SEG6_LWTUNNEL bool "Enable support for lightweight tunnels" @@ -980,6 +1098,16 @@ if KERNEL_IPV6 endif +# +# Miscellaneous network configuration +# + +config KERNEL_NET_L3_MASTER_DEV + bool "L3 Master device support" + help + This module provides glue between core networking code and device + drivers to support L3 master devices like VRF. + # # NFS related symbols # @@ -1125,7 +1253,7 @@ config KERNEL_SQUASHFS_XATTR bool "Squashfs XATTR support" # -# compile optimiziation setting +# compile optimization setting # choice prompt "Compiler optimization level" diff --git a/config/check-uname.sh b/config/check-uname.sh new file mode 100755 index 000000000..1f1bf9ee0 --- /dev/null +++ b/config/check-uname.sh @@ -0,0 +1 @@ +[ "$(uname)" = "$1" ] && echo y || echo n diff --git a/include/autotools.mk b/include/autotools.mk index 1686f69f8..f659bac3c 100644 --- a/include/autotools.mk +++ b/include/autotools.mk @@ -35,7 +35,7 @@ define autoreconf $(patsubst %,rm -f %;,$(2)) \ $(foreach p,$(3), \ if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \ - [ -d $(p)/autom4te.cache ] && rm -rf autom4te.cache; \ + [ -d $(p)/autom4te.cache ] && rm -rf $(p)/autom4te.cache; \ [ -e $(p)/config.rpath ] || \ ln -s $(SCRIPT_DIR)/config.rpath $(p)/config.rpath; \ touch NEWS AUTHORS COPYING ABOUT-NLS ChangeLog; \ @@ -113,7 +113,7 @@ ifneq ($(filter patch-libtool,$(PKG_FIXUP)),) endif ifneq ($(filter libtool,$(PKG_FIXUP)),) - PKG_BUILD_DEPENDS += libtool gettext libiconv + PKG_BUILD_DEPENDS += libtool ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),) Hooks/Configure/Pre += autoreconf_target endif @@ -124,7 +124,7 @@ ifneq ($(filter libtool-abiver,$(PKG_FIXUP)),) endif ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),) - PKG_BUILD_DEPENDS += libtool gettext libiconv + PKG_BUILD_DEPENDS += libtool ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),) Hooks/Configure/Pre += autoreconf_target endif diff --git a/include/bpf.mk b/include/bpf.mk new file mode 100644 index 000000000..e43fcad50 --- /dev/null +++ b/include/bpf.mk @@ -0,0 +1,85 @@ +BPF_DEPENDS := @HAS_BPF_TOOLCHAIN +LLVM_VER:= + +CLANG_MIN_VER:=12 + +ifneq ($(CONFIG_USE_LLVM_HOST),) + BPF_TOOLCHAIN_HOST_PATH:=$(call qstrip,$(CONFIG_BPF_TOOLCHAIN_HOST_PATH)) + ifneq ($(BPF_TOOLCHAIN_HOST_PATH),) + BPF_PATH:=$(BPF_TOOLCHAIN_HOST_PATH)/bin:$(PATH) + else + BPF_PATH:=$(PATH) + endif + CLANG:=$(firstword $(shell PATH='$(BPF_PATH)' command -v clang clang-13 clang-12 clang-11)) + LLVM_VER:=$(subst clang,,$(notdir $(CLANG))) +endif +ifneq ($(CONFIG_USE_LLVM_PREBUILT),) + CLANG:=$(TOPDIR)/llvm-bpf/bin/clang +endif +ifneq ($(CONFIG_USE_LLVM_BUILD),) + CLANG:=$(STAGING_DIR_HOST)/llvm-bpf/bin/clang +endif + +LLVM_PATH:=$(dir $(CLANG)) +LLVM_LLC:=$(LLVM_PATH)/llc$(LLVM_VER) +LLVM_DIS:=$(LLVM_PATH)/llvm-dis$(LLVM_VER) +LLVM_OPT:=$(LLVM_PATH)/opt$(LLVM_VER) +LLVM_STRIP:=$(LLVM_PATH)/llvm-strip$(LLVM_VER) + +BPF_KARCH:=mips +BPF_ARCH:=mips$(if $(CONFIG_ARCH_64BIT),64)$(if $(CONFIG_BIG_ENDIAN),,el) +BPF_TARGET:=bpf$(if $(CONFIG_BIG_ENDIAN),eb,el) + +BPF_HEADERS_DIR:=$(STAGING_DIR)/bpf-headers + +BPF_KERNEL_INCLUDE := \ + -nostdinc -isystem $(TOOLCHAIN_DIR)/include \ + -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include \ + -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/asm/mach-generic \ + -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/generated \ + -I$(BPF_HEADERS_DIR)/include \ + -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/uapi \ + -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/generated/uapi \ + -I$(BPF_HEADERS_DIR)/include/uapi \ + -I$(BPF_HEADERS_DIR)/include/generated/uapi \ + -I$(BPF_HEADERS_DIR)/tools/lib \ + -I$(BPF_HEADERS_DIR)/tools/testing/selftests \ + -I$(BPF_HEADERS_DIR)/samples/bpf \ + -include linux/kconfig.h -include asm_goto_workaround.h + +BPF_CFLAGS := \ + $(BPF_KERNEL_INCLUDE) -I$(PKG_BUILD_DIR) \ + -D__KERNEL__ -D__BPF_TRACING__ -DCONFIG_GENERIC_CSUM \ + -D__TARGET_ARCH_${BPF_KARCH} \ + -m$(if $(CONFIG_BIG_ENDIAN),big,little)-endian \ + -fno-stack-protector -Wall \ + -Wno-unused-value -Wno-pointer-sign \ + -Wno-compare-distinct-pointer-types \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-address-of-packed-member -Wno-tautological-compare \ + -Wno-unknown-warning-option \ + -fno-asynchronous-unwind-tables \ + -Wno-uninitialized -Wno-unused-variable \ + -Wno-unused-label \ + -O2 -emit-llvm -Xclang -disable-llvm-passes + +ifneq ($(CONFIG_HAS_BPF_TOOLCHAIN),) +ifeq ($(DUMP),) + CLANG_VER:=$(shell $(CLANG) -dM -E - < /dev/null | grep __clang_major__ | cut -d' ' -f3) + CLANG_VER_VALID:=$(shell [ "$(CLANG_VER)" -ge "$(CLANG_MIN_VER)" ] && echo 1 ) + ifeq ($(CLANG_VER_VALID),) + $(error ERROR: LLVM/clang version too old. Minimum required: $(CLANG_MIN_VER), found: $(CLANG_VER)) + endif +endif +endif + +define CompileBPF + $(CLANG) -g -target $(BPF_ARCH)-linux-gnu $(BPF_CFLAGS) $(2) \ + -c $(1) -o $(patsubst %.c,%.bc,$(1)) + $(LLVM_OPT) -O2 -mtriple=$(BPF_TARGET) < $(patsubst %.c,%.bc,$(1)) > $(patsubst %.c,%.opt,$(1)) + $(LLVM_DIS) < $(patsubst %.c,%.opt,$(1)) > $(patsubst %.c,%.S,$(1)) + $(LLVM_LLC) -march=$(BPF_TARGET) -mcpu=v3 -filetype=obj -o $(patsubst %.c,%.o,$(1)) < $(patsubst %.c,%.S,$(1)) + $(CP) $(patsubst %.c,%.o,$(1)) $(patsubst %.c,%.debug.o,$(1)) + $(LLVM_STRIP) --strip-debug $(patsubst %.c,%.o,$(1)) +endef + diff --git a/include/cmake.mk b/include/cmake.mk index b1f05bd50..9b169b069 100644 --- a/include/cmake.mk +++ b/include/cmake.mk @@ -52,7 +52,7 @@ CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB)) CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT)) CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOSTPKG);$(STAGING_DIR_HOST) CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions -CMAKE_HOST_INSTALL_PREFIX ?= $(HOST_BUILD_PREFIX) +CMAKE_HOST_INSTALL_PREFIX = $(HOST_BUILD_PREFIX) ifeq ($(HOST_USE_NINJA),1) CMAKE_HOST_OPTIONS += -DCMAKE_GENERATOR="Ninja" diff --git a/include/depends.mk b/include/depends.mk index 465e4e952..a858d4b03 100644 --- a/include/depends.mk +++ b/include/depends.mk @@ -12,6 +12,7 @@ DEP_FINDPARAMS := -x "*/.svn*" -x ".*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check" -x "*/.*.swp" -x "*/.pkgdir*" find_md5=find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) -printf "%p%T@\n" | sort | $(MKHASH) md5 +find_md5_reproducible=find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) -print0 | xargs -0 $(MKHASH) md5 | sort | $(MKHASH) md5 define rdep .PRECIOUS: $(2) @@ -27,7 +28,7 @@ ifneq ($(wildcard $(2)),) { [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \ ) \ { \ - [ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \ + [ -f "$(2)_check.1" ] && mv "$(2)_check.1" "$(2)_check"; \ $(TOPDIR)/scripts/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \ $(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \ touch -r "$(2)" "$(2)_check"; \ diff --git a/include/download.mk b/include/download.mk index 670711b30..34d31653b 100644 --- a/include/download.mk +++ b/include/download.mk @@ -63,6 +63,21 @@ define dl_tar_pack $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | $(call dl_pack,$(1)) endef +gen_sha256sum = $(shell $(MKHASH) sha256 $(DL_DIR)/$(1)) + +# Used in Build/CoreTargets and HostBuild/Core as an integrity check for +# downloaded files. It will add a FORCE rule if the sha256 hash does not +# match, so that the download can be more thoroughly handled by download.pl. +define check_download_integrity + expected_hash:=$(strip $(if $(filter-out x,$(HASH)),$(HASH),$(MIRROR_HASH))) + $$(if $$(and $(FILE),$$(wildcard $(DL_DIR)/$(FILE)), \ + $$(filter undefined,$$(flavor DownloadChecked/$(FILE)))), \ + $$(eval DownloadChecked/$(FILE):=1) \ + $$(if $$(filter-out $$(call gen_sha256sum,$(FILE)),$$(expected_hash)), \ + $(DL_DIR)/$(FILE): FORCE) \ + ) +endef + ifdef CHECK check_escape=$(subst ','\'',$(1)) #') @@ -78,8 +93,6 @@ else check_warn = $(if $(filter-out undefined,$(origin F_$(1))),$(filter ,$(shell $(call F_$(1),$(2),$(3),$(4)) >&2)),$(check_warn_nofix)) endif -gen_sha256sum = $(shell $(MKHASH) sha256 $(DL_DIR)/$(1)) - ifdef FIXUP F_hash_deprecated = $(SCRIPT_DIR)/fixup-makefile.pl $(CURDIR)/Makefile fix-hash $(3) $(call gen_sha256sum,$(1)) $(2) F_hash_mismatch = $(F_hash_deprecated) diff --git a/include/host-build.mk b/include/host-build.mk index e4a5c48e7..22fcc31f1 100644 --- a/include/host-build.mk +++ b/include/host-build.mk @@ -21,7 +21,7 @@ include $(INCLUDE_DIR)/depends.mk include $(INCLUDE_DIR)/quilt.mk BUILD_TYPES += host -HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),))_$(call confvar,CONFIG_AUTOREMOVE $(HOST_PREPARED_DEPENDS))) +HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call $(if $(CONFIG_AUTOREMOVE),find_md5_reproducible,find_md5),${CURDIR} $(PKG_FILE_DEPENDS),))_$(call confvar,CONFIG_AUTOREMOVE $(HOST_PREPARED_DEPENDS))) HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built HOST_BUILD_PREFIX?=$(if $(IS_PACKAGE_BUILD),$(STAGING_DIR_HOSTPKG),$(STAGING_DIR_HOST)) @@ -51,6 +51,7 @@ HOST_CONFIGURE_VARS = \ CFLAGS="$(HOST_CFLAGS)" \ CXX="$(HOSTCXX)" \ CPPFLAGS="$(HOST_CPPFLAGS)" \ + CXXFLAGS="$(HOST_CXXFLAGS)" \ LDFLAGS="$(HOST_LDFLAGS)" \ CONFIG_SHELL="$(SHELL)" @@ -180,7 +181,7 @@ ifndef DUMP clean-build: host-clean-build endif - $(DL_DIR)/$(FILE): FORCE + $(call check_download_integrity) $(_host_target)host-prepare: $(HOST_STAMP_PREPARED) $(_host_target)host-configure: $(HOST_STAMP_CONFIGURED) @@ -197,13 +198,13 @@ ifndef DUMP ifneq ($(CONFIG_AUTOREMOVE),) host-compile: - $(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' | \ - $(XARGS) rm -rf + $(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -print0 | \ + $(XARGS) -0 rm -rf endif endef endif define HostBuild $(HostBuild/Core) - $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))) + $(if $(if $(PKG_HOST_ONLY),,$(if $(and $(filter host-%,$(MAKECMDGOALS)),$(PKG_SKIP_DOWNLOAD)),,$(STAMP_PREPARED))),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))) endef diff --git a/include/image-commands.mk b/include/image-commands.mk index e0738818f..407dffa0c 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -4,7 +4,7 @@ IMAGE_KERNEL = $(word 1,$^) IMAGE_ROOTFS = $(word 2,$^) define ModelNameLimit16 -$(shell expr substr "$(word 2, $(subst _, ,$(1)))" 1 16) +$(shell printf %.16s "$(word 2, $(subst _, ,$(1)))") endef define rootfs_align @@ -27,8 +27,21 @@ define Build/append-kernel dd if=$(IMAGE_KERNEL) >> $@ endef +define Build/package-kernel-ubifs + mkdir $@.kernelubifs + cp $@ $@.kernelubifs/kernel + $(STAGING_DIR_HOST)/bin/mkfs.ubifs \ + $(KERNEL_UBIFS_OPTS) \ + -r $@.kernelubifs $@ + rm -r $@.kernelubifs +endef + define Build/append-image - dd if=$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1) >> $@ + cp "$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1)" "$@.stripmeta" + fwtool -s /dev/null -t "$@.stripmeta" || : + fwtool -i /dev/null -t "$@.stripmeta" || : + dd if="$@.stripmeta" >> "$@" + rm "$@.stripmeta" endef ifdef IB @@ -37,8 +50,13 @@ define Build/append-image-stage endef else define Build/append-image-stage - dd if=$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1) of=$(STAGING_DIR_IMAGE)/$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))-$(DEVICE_NAME)-$(1) - dd if=$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1) >> $@ + cp "$(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1)" "$@.stripmeta" + fwtool -s /dev/null -t "$@.stripmeta" || : + fwtool -i /dev/null -t "$@.stripmeta" || : + mkdir -p "$(STAGING_DIR_IMAGE)" + dd if="$@.stripmeta" of="$(STAGING_DIR_IMAGE)/$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))-$(DEVICE_NAME)-$(1)" + dd if="$@.stripmeta" >> "$@" + rm "$@.stripmeta" endef endif @@ -72,6 +90,7 @@ metadata_json = \ define Build/append-metadata $(if $(SUPPORTED_DEVICES),-echo $(call metadata_json) | fwtool -I - $@) + sha256sum "$@" | cut -d" " -f1 > "$@.sha256sum" [ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \ cp "$(BUILD_KEY).ucert" "$@.ucert" ;\ usign -S -m "$@" -s "$(BUILD_KEY)" -x "$@.sig" ;\ @@ -94,6 +113,15 @@ define Build/append-squashfs-fakeroot-be cat $@.fakesquashfs >> $@ endef +define Build/append-squashfs4-fakeroot + rm -rf $@.fakefs $@.fakesquashfs + mkdir $@.fakefs + $(STAGING_DIR_HOST)/bin/mksquashfs4 \ + $@.fakefs $@.fakesquashfs \ + -nopad -noappend -root-owned + cat $@.fakesquashfs >> $@ +endef + define Build/append-string echo -n $(1) >> $@ endef @@ -103,7 +131,7 @@ define Build/append-ubi $(if $(UBOOTENV_IN_UBI),--uboot-env) \ $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \ $(foreach part,$(UBINIZE_PARTS),--part $(part)) \ - $(IMAGE_ROOTFS) \ + --rootfs $(IMAGE_ROOTFS) \ $@.tmp \ -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \ $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \ @@ -113,6 +141,18 @@ define Build/append-ubi rm $@.tmp endef +define Build/ubinize-kernel + cp $@ $@.tmp + sh $(TOPDIR)/scripts/ubinize-image.sh \ + --kernel $@.tmp \ + $@ \ + -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \ + $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \ + $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \ + $(UBINIZE_OPTS) + rm $@.tmp +endef + define Build/append-uboot dd if=$(UBOOT_PATH) >> $@ endef @@ -170,11 +210,20 @@ define Build/check-size @imagesize="$$(stat -c%s $@)"; \ limitsize="$$(($(subst k,* 1024,$(subst m, * 1024k,$(if $(1),$(1),$(IMAGE_SIZE))))))"; \ [ $$limitsize -ge $$imagesize ] || { \ - echo "WARNING: Image file $@ is too big: $$imagesize > $$limitsize" >&2; \ + $(call ERROR_MESSAGE, WARNING: Image file $@ is too big: $$imagesize > $$limitsize); \ rm -f $@; \ } endef +define Build/copy-file + cat "$(1)" > "$@" +endef + +define Build/edimax-header + $(STAGING_DIR_HOST)/bin/mkedimaximg -i $@ -o $@.new $(1) + @mv $@.new $@ +endef + define Build/elecom-product-header $(eval product=$(word 1,$(1))) $(eval fw=$(if $(word 2,$(1)),$(word 2,$(1)),$@)) @@ -187,6 +236,19 @@ define Build/elecom-product-header mv $(fw).new $(fw) endef +define Build/elecom-wrc-gs-factory + $(eval product=$(word 1,$(1))) + $(eval version=$(word 2,$(1))) + $(eval hash_opt=$(word 3,$(1))) + $(MKHASH) md5 $(hash_opt) $@ >> $@ + ( \ + echo -n "ELECOM $(product) v$(version)" | \ + dd bs=32 count=1 conv=sync; \ + dd if=$@; \ + ) > $@.new + mv $@.new $@ +endef + define Build/elx-header $(eval hw_id=$(word 1,$(1))) $(eval xor_pattern=$(word 2,$(1))) @@ -223,15 +285,19 @@ endef define Build/fit $(TOPDIR)/scripts/mkits.sh \ -D $(DEVICE_NAME) -o $@.its -k $@ \ - -C $(word 1,$(1)) $(if $(word 2,$(1)),\ - $(if $(DEVICE_DTS_OVERLAY),-d $(KERNEL_BUILD_DIR)/image-$$(basename $(word 2,$(1))),\ - -d $(word 2,$(1)))) \ + -C $(word 1,$(1)) \ + $(if $(word 2,$(1)),\ + $(if $(findstring 11,$(if $(DEVICE_DTS_OVERLAY),1)$(if $(findstring $(KERNEL_BUILD_DIR)/image-,$(word 2,$(1))),,1)), \ + -d $(KERNEL_BUILD_DIR)/image-$$(basename $(word 2,$(1))), \ + -d $(word 2,$(1)))) \ $(if $(findstring with-rootfs,$(word 3,$(1))),-r $(IMAGE_ROOTFS)) \ $(if $(findstring with-initrd,$(word 3,$(1))), \ $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPARATE), \ -i $(KERNEL_BUILD_DIR)/initrd.cpio$(strip $(call Build/initrd_compression)))) \ -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \ $(if $(DEVICE_FDT_NUM),-n $(DEVICE_FDT_NUM)) \ + $(if $(DEVICE_DTS_DELIMITER),-l $(DEVICE_DTS_DELIMITER)) \ + $(if $(DEVICE_DTS_LOADADDR),-s $(DEVICE_DTS_LOADADDR)) \ $(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtb)) \ -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \ -A $(LINUX_KARCH) -v $(LINUX_VERSION) @@ -240,8 +306,13 @@ define Build/fit @mv $@.new $@ endef +define Build/libdeflate-gzip + $(STAGING_DIR_HOST)/bin/libdeflate-gzip -f -12 -c $@ $(1) > $@.new + @mv $@.new $@ +endef + define Build/gzip - gzip -f -9n -c $@ $(1) > $@.new + $(STAGING_DIR_HOST)/bin/gzip -f -9n -c $@ $(1) > $@.new @mv $@.new $@ endef @@ -256,6 +327,16 @@ define Build/install-dtb ) endef +define Build/iptime-crc32 + $(STAGING_DIR_HOST)/bin/iptime-crc32 $(1) $@ $@.new + mv $@.new $@ +endef + +define Build/iptime-naspkg + $(STAGING_DIR_HOST)/bin/iptime-naspkg $(1) $@ $@.new + mv $@.new $@ +endef + define Build/jffs2 rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \ mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \ @@ -318,6 +399,19 @@ define Build/netgear-dni mv $@.new $@ endef +define Build/netgear-encrypted-factory + $(TOPDIR)/scripts/netgear-encrypted-factory.py \ + --input-file $@ \ + --output-file $@ \ + --model $(NETGEAR_ENC_MODEL) \ + --region $(NETGEAR_ENC_REGION) \ + --version V1.0.0.0.$(VERSION_DIST).$(firstword $(subst -, ,$(REVISION))) \ + --encryption-block-size 0x20000 \ + --openssl-bin "$(STAGING_DIR_HOST)/bin/openssl" \ + --key 6865392d342b4d212964363d6d7e7765312c7132613364316e26322a5a5e2538 \ + --iv 4a253169516c38243d6c6d2d3b384145 +endef + define Build/openmesh-image $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \ "$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \ @@ -370,16 +464,16 @@ define Build/qemu-image fi endef -define Build/qsdk-ipq-factory-mmc +define Build/qsdk-ipq-factory-nand $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \ - $@.its kernel $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS) + $@.its ubi $@ PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new @mv $@.new $@ endef -define Build/qsdk-ipq-factory-nand +define Build/qsdk-ipq-factory-mmc $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \ - $@.its ubi $@ + $@.its kernel $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS) PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new @mv $@.new $@ endef @@ -496,12 +590,12 @@ define Build/xor-image endef define Build/zip + rm -rf $@.tmp mkdir $@.tmp - mv $@ $@.tmp/$(1) - - zip -j -X \ - $(if $(SOURCE_DATE_EPOCH),--mtime="$(SOURCE_DATE_EPOCH)") \ - $@ $@.tmp/$(if $(1),$(1),$@) + mv $@ $@.tmp/$(word 1,$(1)) + TZ=UTC $(STAGING_DIR_HOST)/bin/zip -j -X \ + $(wordlist 2,$(words $(1)),$(1)) \ + $@ $@.tmp/$(if $(word 1,$(1)),$(word 1,$(1)),$$(basename $@)) rm -rf $@.tmp endef diff --git a/include/image.mk b/include/image.mk index 7acc5af61..5d9d4acb4 100644 --- a/include/image.mk +++ b/include/image.mk @@ -137,14 +137,6 @@ define Image/BuildKernel/MkuImage -n '$(call toupper,$(ARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)' -d $(4) $(5) endef -define Image/BuildKernel/MkFIT - $(TOPDIR)/scripts/mkits.sh \ - -D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \ - -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \ - -A $(LINUX_KARCH) -v $(LINUX_VERSION) - PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb -endef - ifdef CONFIG_TARGET_IMAGES_GZIP define Image/Gzip rm -f $(1).gz @@ -184,6 +176,7 @@ endef # $(4) extra DTC flags define Image/BuildDTB $(TARGET_CROSS)cpp -nostdinc -x assembler-with-cpp \ + $(DTS_CPPFLAGS) \ -I$(DTS_DIR) \ -I$(DTS_DIR)/include \ -I$(LINUX_DIR)/include/ \ @@ -229,8 +222,7 @@ $(eval $(foreach S,$(NAND_BLOCKSIZE),$(call Image/mkfs/jffs2-nand/template,$(S)) define Image/mkfs/squashfs-common $(STAGING_DIR_HOST)/bin/mksquashfs4 $(call mkfs_target_dir,$(1)) $@ \ -nopad -noappend -root-owned \ - -comp $(SQUASHFSCOMP) $(SQUASHFSOPT) \ - -processors $(shell nproc) + -comp $(SQUASHFSCOMP) $(SQUASHFSOPT) endef ifeq ($(CONFIG_TARGET_ROOTFS_SECURITY_LABELS),y) @@ -394,7 +386,9 @@ define Device/Init DEVICE_DTS := DEVICE_DTS_CONFIG := + DEVICE_DTS_DELIMITER := DEVICE_DTS_DIR := + DEVICE_DTS_LOADADDR := DEVICE_DTS_OVERLAY := DEVICE_FDT_NUM := SOC := @@ -419,8 +413,9 @@ DEFAULT_DEVICE_VARS := \ DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_INITRAMFS_IMAGE KERNEL_SIZE \ CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI BLOCKSIZE PAGESIZE SUBPAGESIZE \ VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \ - DEVICE_DTS_CONFIG DEVICE_DTS_DIR DEVICE_DTS_OVERLAY DEVICE_FDT_NUM \ - DEVICE_IMG_PREFIX SOC BOARD_NAME UIMAGE_MAGIC UIMAGE_NAME \ + DEVICE_DTS_CONFIG DEVICE_DTS_DELIMITER DEVICE_DTS_DIR DEVICE_DTS_OVERLAY \ + DEVICE_DTS_LOADADDR \ + DEVICE_FDT_NUM DEVICE_IMG_PREFIX SOC BOARD_NAME UIMAGE_MAGIC UIMAGE_NAME \ SUPPORTED_DEVICES IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR \ UBOOT_PATH IMAGE_SIZE \ DEVICE_PACKAGES DEVICE_COMPAT_VERSION DEVICE_COMPAT_MESSAGE \ @@ -492,11 +487,11 @@ define Device/Build/initramfs $(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json: $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE) @mkdir -p $$(shell dirname $$@) DEVICE_ID="$(1)" \ - BIN_DIR="$(BIN_DIR)" \ SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \ - DEVICE_IMG_NAME="$$(notdir $$^)" \ - IMAGE_TYPE="kernel" \ - IMAGE_FILESYSTEM="initramfs" \ + FILE_NAME="$$(notdir $$^)" \ + FILE_DIR="$(KDIR)/tmp" \ + FILE_TYPE="kernel" \ + FILE_FILESYSTEM="initramfs" \ DEVICE_IMG_PREFIX="$$(DEVICE_IMG_PREFIX)" \ DEVICE_VENDOR="$$(DEVICE_VENDOR)" \ DEVICE_MODEL="$$(DEVICE_MODEL)" \ @@ -524,7 +519,8 @@ endif define Device/Build/compile $$(_COMPILE_TARGET): $(KDIR)/$(1) $(eval $(call Device/Export,$(KDIR)/$(1))) - $(KDIR)/$(1): + $(KDIR)/$(1): FORCE + rm -f $(KDIR)/$(1) $$(call concat_cmd,$(COMPILE/$(1))) endef @@ -599,11 +595,11 @@ define Device/Build/image $(BUILD_DIR)/json_info_files/$(call DEVICE_IMG_NAME,$(1),$(2)).json: $(BIN_DIR)/$(call DEVICE_IMG_NAME,$(1),$(2))$$(GZ_SUFFIX) @mkdir -p $$(shell dirname $$@) DEVICE_ID="$(DEVICE_NAME)" \ - BIN_DIR="$(BIN_DIR)" \ SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \ - DEVICE_IMG_NAME="$(DEVICE_IMG_NAME)" \ - IMAGE_TYPE=$(word 1,$(subst ., ,$(2))) \ - IMAGE_FILESYSTEM="$(1)" \ + FILE_NAME="$(DEVICE_IMG_NAME)" \ + FILE_DIR="$(KDIR)/tmp" \ + FILE_TYPE=$(word 1,$(subst ., ,$(2))) \ + FILE_FILESYSTEM="$(1)" \ DEVICE_IMG_PREFIX="$(DEVICE_IMG_PREFIX)" \ DEVICE_VENDOR="$(DEVICE_VENDOR)" \ DEVICE_MODEL="$(DEVICE_MODEL)" \ @@ -629,7 +625,9 @@ define Device/Build/image endef define Device/Build/artifact - $$(_TARGET): $(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1) + $$(_TARGET): $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \ + $(BUILD_DIR)/json_info_files/$(DEVICE_IMG_PREFIX)-$(1).json, \ + $(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1)) $(eval $(call Device/Export,$(KDIR)/tmp/$(DEVICE_IMG_PREFIX)-$(1))) $(KDIR)/tmp/$(DEVICE_IMG_PREFIX)-$(1): $$(KDIR_KERNEL_IMAGE) $(2)-images @rm -f $$@ @@ -640,6 +638,35 @@ define Device/Build/artifact $(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1): $(KDIR)/tmp/$(DEVICE_IMG_PREFIX)-$(1) cp $$^ $$@ + $(BUILD_DIR)/json_info_files/$(DEVICE_IMG_PREFIX)-$(1).json: $(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1) + @mkdir -p $$(shell dirname $$@) + DEVICE_ID="$(DEVICE_NAME)" \ + SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \ + FILE_NAME="$(DEVICE_IMG_PREFIX)-$(1)" \ + FILE_DIR="$(KDIR)/tmp" \ + FILE_TYPE="$(1)" \ + DEVICE_IMG_PREFIX="$(DEVICE_IMG_PREFIX)" \ + DEVICE_VENDOR="$(DEVICE_VENDOR)" \ + DEVICE_MODEL="$(DEVICE_MODEL)" \ + DEVICE_VARIANT="$(DEVICE_VARIANT)" \ + DEVICE_ALT0_VENDOR="$(DEVICE_ALT0_VENDOR)" \ + DEVICE_ALT0_MODEL="$(DEVICE_ALT0_MODEL)" \ + DEVICE_ALT0_VARIANT="$(DEVICE_ALT0_VARIANT)" \ + DEVICE_ALT1_VENDOR="$(DEVICE_ALT1_VENDOR)" \ + DEVICE_ALT1_MODEL="$(DEVICE_ALT1_MODEL)" \ + DEVICE_ALT1_VARIANT="$(DEVICE_ALT1_VARIANT)" \ + DEVICE_ALT2_VENDOR="$(DEVICE_ALT2_VENDOR)" \ + DEVICE_ALT2_MODEL="$(DEVICE_ALT2_MODEL)" \ + DEVICE_ALT2_VARIANT="$(DEVICE_ALT2_VARIANT)" \ + DEVICE_TITLE="$(DEVICE_TITLE)" \ + DEVICE_PACKAGES="$(DEVICE_PACKAGES)" \ + TARGET="$(BOARD)" \ + SUBTARGET="$(if $(SUBTARGET),$(SUBTARGET),generic)" \ + VERSION_NUMBER="$(VERSION_NUMBER)" \ + VERSION_CODE="$(VERSION_CODE)" \ + SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \ + $(TOPDIR)/scripts/json_add_image_info.py $$@ + endef define Device/Build @@ -732,6 +759,7 @@ define BuildImage else image_prepare: + rm -rf $(KDIR)/tmp mkdir -p $(BIN_DIR) $(KDIR)/tmp endif diff --git a/include/kernel-5.10 b/include/kernel-5.10 index 954c35eda..da007fc72 100644 --- a/include/kernel-5.10 +++ b/include/kernel-5.10 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.10 = .108 -LINUX_KERNEL_HASH-5.10.108 = bf6cc2d6e0918b8f34d1cde2fa39a6ad69c45025425048be1a1dac4a5b3641d8 +LINUX_VERSION-5.10 = .161 +LINUX_KERNEL_HASH-5.10.161 = 7aaaf6d0bcd8a2cfa14ad75f02ca62bb2de08aad3bee3eff198de49ea5254079 diff --git a/include/kernel-5.15 b/include/kernel-5.15 index a7d4d0ca7..d24c2a001 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .79 -LINUX_KERNEL_HASH-5.15.79 = cba39031dbc0eed0785b8afdc8c58cf23df83e47001b2354fa44486ae699c154 +LINUX_VERSION-5.15 = .86 +LINUX_KERNEL_HASH-5.15.86 = 80fcd9efa443502de9e2750f6dfb59e8de43a5d87a6d2be09dca748d79b5f2ee diff --git a/include/kernel-build.mk b/include/kernel-build.mk index 66a9f64c8..5b332258f 100644 --- a/include/kernel-build.mk +++ b/include/kernel-build.mk @@ -10,7 +10,7 @@ ifneq ($(DUMP),1) endif KERNEL_FILE_DEPENDS=$(GENERIC_BACKPORT_DIR) $(GENERIC_PATCH_DIR) $(GENERIC_HACK_DIR) $(PATCH_DIR) $(GENERIC_FILES_DIR) $(FILES_DIR) -STAMP_PREPARED=$(LINUX_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,$(KERNEL_FILE_DEPENDS),))) +STAMP_PREPARED=$(LINUX_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call $(if $(CONFIG_AUTOREMOVE),find_md5_reproducible,find_md5),$(KERNEL_FILE_DEPENDS),))) STAMP_CONFIGURED:=$(LINUX_DIR)/.configured include $(INCLUDE_DIR)/download.mk include $(INCLUDE_DIR)/quilt.mk @@ -132,6 +132,7 @@ define BuildKernel $(LINUX_DIR)/.modules: export STAGING_PREFIX=$$(STAGING_DIR_HOST) $(LINUX_DIR)/.modules: export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig $(LINUX_DIR)/.modules: export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig + $(LINUX_DIR)/.modules: export FAIL_ON_UNCONFIGURED=1 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE $(Kernel/CompileModules) touch $$@ @@ -161,7 +162,6 @@ define BuildKernel $(LINUX_RECONF_CMD) > $(LINUX_DIR)/.config $(_SINGLE)$(KERNEL_MAKE) \ $(if $(findstring Darwin,$(HOST_OS)), \ - HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib -lncurses" \ HOSTLDLIBS_mconf="-L$(STAGING_DIR_HOST)/lib -lncurses" \ filechk_conf_cfg=" :" \ ) \ diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk index efbe5288e..5b334fcdf 100644 --- a/include/kernel-defaults.mk +++ b/include/kernel-defaults.mk @@ -117,7 +117,7 @@ define Kernel/Configure/Default cp $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config; \ cp $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config.prev; \ } - $(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(KERNEL_MAKE) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install + $(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(KERNEL_MAKE) $(if $(findstring uml,$(BOARD)),ARCH=$(ARCH)) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install grep '=[ym]' $(LINUX_DIR)/.config.set | LC_ALL=C sort | $(MKHASH) md5 > $(LINUX_DIR)/.vermagic endef @@ -129,6 +129,10 @@ define Kernel/CompileModules/Default rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map +$(KERNEL_MAKE) olddefconfig +$(KERNEL_MAKE) $(if $(KERNELNAME),$(KERNELNAME),all) modules + # If .config did not change, use the previous timestamp to avoid package rebuilds + cmp -s $(LINUX_DIR)/.config $(LINUX_DIR)/.config.modules.save && \ + mv $(LINUX_DIR)/.config.modules.save $(LINUX_DIR)/.config; \ + $(CP) $(LINUX_DIR)/.config $(LINUX_DIR)/.config.modules.save endef OBJCOPY_STRIP = -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id @@ -165,19 +169,20 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) define Kernel/CompileImage/Initramfs $(call Kernel/Configure/Initramfs) $(CP) $(GENERIC_PLATFORM_DIR)/other-files/init $(TARGET_DIR)/init - $(if $(SOURCE_DATE_EPOCH),touch -hcd "@$(SOURCE_DATE_EPOCH)" $(TARGET_DIR)/init) + $(if $(SOURCE_DATE_EPOCH),touch -hcd "@$(SOURCE_DATE_EPOCH)" $(TARGET_DIR) $(TARGET_DIR)/init) rm -rf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/usr/initramfs_data.cpio* ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPARATE),y) -ifeq ($(CONFIG_EXTERNAL_CPIO),y) +ifneq ($(qstrip $(CONFIG_EXTERNAL_CPIO)),) $(CP) $(CONFIG_EXTERNAL_CPIO) $(KERNEL_BUILD_DIR)/initrd.cpio else - ( cd $(TARGET_DIR); find . | $(STAGING_DIR_HOST)/bin/cpio -o -H newc -R 0:0 > $(KERNEL_BUILD_DIR)/initrd.cpio ) + ( cd $(TARGET_DIR); find . | LC_ALL=C sort | $(STAGING_DIR_HOST)/bin/cpio --reproducible -o -H newc -R 0:0 > $(KERNEL_BUILD_DIR)/initrd.cpio ) endif + $(if $(SOURCE_DATE_EPOCH),touch -hcd "@$(SOURCE_DATE_EPOCH)" $(KERNEL_BUILD_DIR)/initrd.cpio) $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),bzip2 -9 -c < $(KERNEL_BUILD_DIR)/initrd.cpio > $(KERNEL_BUILD_DIR)/initrd.cpio.bzip2) - $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),gzip -f -S .gzip -9n $(KERNEL_BUILD_DIR)/initrd.cpio) + $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),gzip -n -f -S .gzip -9n $(KERNEL_BUILD_DIR)/initrd.cpio) $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),$(STAGING_DIR_HOST)/bin/lzma e -lc1 -lp2 -pb2 $(KERNEL_BUILD_DIR)/initrd.cpio $(KERNEL_BUILD_DIR)/initrd.cpio.lzma) # ? $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO),) - $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),$(STAGING_DIR_HOST)/bin/xz -9 -fz --check=crc32 $(KERNEL_BUILD_DIR)/initrd.cpio) + $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),$(STAGING_DIR_HOST)/bin/xz -T$(if $(filter 1,$(NPROC)),2,0) -9 -fz --check=crc32 $(KERNEL_BUILD_DIR)/initrd.cpio) # ? $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4),) $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_ZSTD),$(STAGING_DIR_HOST)/bin/zstd -T0 -f -o $(KERNEL_BUILD_DIR)/initrd.cpio.zstd $(KERNEL_BUILD_DIR)/initrd.cpio) endif diff --git a/include/kernel.mk b/include/kernel.mk index e4074a48f..c657bf5d8 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -101,7 +101,7 @@ endif KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS) KERNEL_MAKE_FLAGS = \ - KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR)))" \ + KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) $(call qstrip,$(CONFIG_KERNEL_CFLAGS))" \ HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \ CROSS_COMPILE="$(KERNEL_CROSS)" \ ARCH="$(LINUX_KARCH)" \ @@ -110,8 +110,7 @@ KERNEL_MAKE_FLAGS = \ KBUILD_BUILD_HOST="$(call qstrip,$(CONFIG_KERNEL_BUILD_DOMAIN))" \ KBUILD_BUILD_TIMESTAMP="$(KBUILD_BUILD_TIMESTAMP)" \ KBUILD_BUILD_VERSION="0" \ - HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \ - KBUILD_HOSTLDLIBS="-L$(STAGING_DIR_HOST)/lib" \ + KBUILD_HOSTLDFLAGS="-L$(STAGING_DIR_HOST)/lib" \ CONFIG_SHELL="$(BASH)" \ $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \ $(if $(PKG_BUILD_ID),LDFLAGS_MODULE=--build-id=0x$(PKG_BUILD_ID)) \ @@ -126,17 +125,17 @@ ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL KERNELRELEASE=$(LINUX_VERSION) endif -KERNEL_MAKEOPTS := -C $(LINUX_DIR) $(KERNEL_MAKE_FLAGS) +ifneq ($(HOST_OS),Linux) + KERNEL_MAKE_FLAGS += CONFIG_STACK_VALIDATION= + export SKIP_STACK_VALIDATION:=1 +endif + +KERNEL_MAKEOPTS = -C $(LINUX_DIR) $(KERNEL_MAKE_FLAGS) ifdef CONFIG_USE_SPARSE KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse endif -ifneq ($(HOST_OS),Linux) - KERNEL_MAKEOPTS += CONFIG_STACK_VALIDATION= - export SKIP_STACK_VALIDATION:=1 -endif - PKG_EXTMOD_SUBDIRS ?= . PKG_SYMVERS_DIR = $(KERNEL_BUILD_DIR)/symvers diff --git a/include/netfilter.mk b/include/netfilter.mk index 06246ecd1..92dbf5e1c 100644 --- a/include/netfilter.mk +++ b/include/netfilter.mk @@ -48,9 +48,6 @@ $(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_COMMENT, $(P_XT)xt_comme $(eval $(call nf_add,IPT_CLUSTER,CONFIG_NETFILTER_XT_MATCH_CLUSTER, $(P_XT)xt_cluster)) $(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_XT)xt_LOG)) -$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_XT)nf_log_common, lt 5.13)) -$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_V4)nf_log_ipv4, lt 5.13)) -$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_XT)nf_log_syslog, ge 5.13)) $(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_TCPMSS, $(P_XT)xt_TCPMSS)) $(eval $(call nf_add,IPT_CORE,CONFIG_IP_NF_TARGET_REJECT, $(P_V4)ipt_REJECT)) $(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_TIME, $(P_XT)xt_time)) @@ -173,11 +170,21 @@ $(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_OPTS, $(P_V6)ip6t_hbh)) $(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_FRAG, $(P_V6)ip6t_frag)) $(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_RT, $(P_V6)ip6t_rt)) +# log + +$(eval $(call nf_add,NF_LOG,CONFIG_NF_LOG_COMMON, $(P_XT)nf_log_common, lt 5.13)) +$(eval $(call nf_add,NF_LOG,CONFIG_NF_LOG_IPV4, $(P_V4)nf_log_ipv4, lt 5.13)) +$(eval $(call nf_add,NF_LOG,CONFIG_NF_LOG_SYSLOG, $(P_XT)nf_log_syslog, ge 5.13)) +# $(eval $(if $(NF_KMOD),$(call nf_add,NF_LOG6,CONFIG_NF_LOG_IPV6, $(P_V6)nf_log_ipv6,lt 5.13),)) + # nat # kernel only $(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT, $(P_XT)nf_nat),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT_IPV4, $(P_V4)nf_nat_ipv4, lt 5.1))) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT6,CONFIG_NF_NAT_IPV6, $(P_V6)nf_nat_ipv6, lt 5.1))) + $(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT,CONFIG_NETFILTER_XT_NAT, $(P_XT)xt_nat),)) $(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT,CONFIG_IP_NF_NAT, $(P_V4)iptable_nat),)) $(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_NAT, $(P_V6)ip6table_nat),)) @@ -207,6 +214,8 @@ $(eval $(call nf_add,NF_NATHELPER,CONFIG_NF_NAT_FTP, $(P_XT)nf_nat_ftp)) $(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_BROADCAST, $(P_XT)nf_conntrack_broadcast)) $(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_AMANDA, $(P_XT)nf_conntrack_amanda)) $(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_AMANDA, $(P_XT)nf_nat_amanda)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CT_PROTO_GRE, $(P_XT)nf_conntrack_proto_gre, lt 5.1)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_PROTO_GRE, $(P_V4)nf_nat_proto_gre, lt 5.0)) $(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_H323, $(P_XT)nf_conntrack_h323)) $(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_H323, $(P_V4)nf_nat_h323)) $(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_PPTP, $(P_XT)nf_conntrack_pptp)) @@ -235,14 +244,15 @@ $(eval $(call nf_add,IPT_NFQUEUE,CONFIG_NETFILTER_XT_TARGET_NFQUEUE, $(P_XT)xt_N $(eval $(call nf_add,IPT_DEBUG,CONFIG_NETFILTER_XT_TARGET_TRACE, $(P_XT)xt_TRACE)) -# tproxy +# socket +$(eval $(call nf_add,NF_SOCKET,CONFIG_NF_SOCKET_IPV4, $(P_V4)nf_socket_ipv4)) +$(eval $(call nf_add,NF_SOCKET,CONFIG_NF_SOCKET_IPV6, $(P_V6)nf_socket_ipv6)) +$(eval $(call nf_add,IPT_SOCKET,CONFIG_NETFILTER_XT_MATCH_SOCKET, $(P_XT)xt_socket)) -$(eval $(call nf_add,IPT_TPROXY,CONFIG_NETFILTER_XT_MATCH_SOCKET, $(P_XT)xt_socket)) -$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_SOCKET_IPV4, $(P_V4)nf_socket_ipv4)) -$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_SOCKET_IPV6, $(P_V6)nf_socket_ipv6)) +# tproxy +$(eval $(call nf_add,NF_TPROXY,CONFIG_NF_TPROXY_IPV4, $(P_V4)nf_tproxy_ipv4)) +$(eval $(call nf_add,NF_TPROXY,CONFIG_NF_TPROXY_IPV6, $(P_V6)nf_tproxy_ipv6)) $(eval $(call nf_add,IPT_TPROXY,CONFIG_NETFILTER_XT_TARGET_TPROXY, $(P_XT)xt_TPROXY)) -$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_TPROXY_IPV4, $(P_V4)nf_tproxy_ipv4)) -$(eval $(call nf_add,IPT_TPROXY,CONFIG_NF_TPROXY_IPV6, $(P_V6)nf_tproxy_ipv6)) # led $(eval $(call nf_add,IPT_LED,CONFIG_NETFILTER_XT_TARGET_LED, $(P_XT)xt_LED)) @@ -327,6 +337,7 @@ $(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_REJECT_INET, $(P_XT)nft $(eval $(if $(NF_KMOD),$(call nf_add,NFT_BRIDGE,CONFIG_NFT_BRIDGE_META, $(P_EBT)nft_meta_bridge),)) $(eval $(if $(NF_KMOD),$(call nf_add,NFT_BRIDGE,CONFIG_NFT_BRIDGE_REJECT, $(P_EBT)nft_reject_bridge),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_BRIDGE,CONFIG_NF_CONNTRACK_BRIDGE, $(P_EBT)nf_conntrack_bridge),)) $(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_NAT, $(P_XT)nft_nat),)) $(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_NAT, $(P_XT)nft_chain_nat),)) @@ -344,6 +355,14 @@ $(eval $(if $(NF_KMOD),$(call nf_add,NFT_FIB,CONFIG_NFT_FIB_IPV6, $(P_V6)nft_fib $(eval $(if $(NF_KMOD),$(call nf_add,NFT_QUEUE,CONFIG_NFT_QUEUE, $(P_XT)nft_queue),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_SOCKET,CONFIG_NFT_SOCKET, $(P_XT)nft_socket),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_TPROXY,CONFIG_NFT_TPROXY, $(P_XT)nft_tproxy),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_COMPAT,CONFIG_NFT_COMPAT, $(P_XT)nft_compat),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_XFRM,CONFIG_NFT_XFRM, $(P_XT)nft_xfrm),)) + # userland only IPT_BUILTIN += $(NF_IPT-y) $(NF_IPT-m) IPT_BUILTIN += $(IPT_CORE-y) $(IPT_CORE-m) diff --git a/include/nls.mk b/include/nls.mk index 742f8c25a..f054d2bb6 100644 --- a/include/nls.mk +++ b/include/nls.mk @@ -10,27 +10,38 @@ ifeq ($(CONFIG_BUILD_NLS),y) INTL_PREFIX:=$(STAGING_DIR)/usr/lib/libintl-full INTL_FULL:=1 -# iconv stub + CMAKE_OPTIONS += -DCMAKE_PREFIX_PATH="$(ICONV_PREFIX);$(INTL_PREFIX)" else - ICONV_PREFIX:=$(STAGING_DIR)/usr/lib/libiconv-stub + ICONV_PREFIX:= ICONV_FULL:= - INTL_PREFIX:=$(STAGING_DIR)/usr/lib/libintl-stub + INTL_PREFIX:= INTL_FULL:= endif PKG_CONFIG_DEPENDS += CONFIG_BUILD_NLS -PKG_BUILD_DEPENDS += !BUILD_NLS:libiconv !BUILD_NLS:gettext ICONV_DEPENDS:=+BUILD_NLS:libiconv-full -ICONV_CFLAGS:=-I$(ICONV_PREFIX)/include -ICONV_CPPFLAGS:=-I$(ICONV_PREFIX)/include -ICONV_LDFLAGS:=-L$(ICONV_PREFIX)/lib -Wl,-rpath-link=$(ICONV_PREFIX)/lib +ifeq ($(CONFIG_BUILD_NLS),y) + ICONV_CFLAGS:=-I$(ICONV_PREFIX)/include + ICONV_CPPFLAGS:=-I$(ICONV_PREFIX)/include + ICONV_LDFLAGS:=-L$(ICONV_PREFIX)/lib -Wl,-rpath-link=$(ICONV_PREFIX)/lib +else + ICONV_CFLAGS:= + ICONV_CPPFLAGS:= + ICONV_LDFLAGS:= +endif INTL_DEPENDS:=+BUILD_NLS:libintl-full -INTL_CFLAGS:=-I$(INTL_PREFIX)/include -INTL_CPPFLAGS:=-I$(INTL_PREFIX)/include -INTL_LDFLAGS:=-L$(INTL_PREFIX)/lib -Wl,-rpath-link=$(INTL_PREFIX)/lib +ifeq ($(CONFIG_BUILD_NLS),y) + INTL_CFLAGS:=-I$(INTL_PREFIX)/include + INTL_CPPFLAGS:=-I$(INTL_PREFIX)/include + INTL_LDFLAGS:=-L$(INTL_PREFIX)/lib -Wl,-rpath-link=$(INTL_PREFIX)/lib +else + INTL_CFLAGS:= + INTL_CPPFLAGS:= + INTL_LDFLAGS:= +endif TARGET_CFLAGS += $(ICONV_CFLAGS) $(INTL_CFLAGS) TARGET_CPPFLAGS += $(ICONV_CPPFLAGS) $(INTL_CPPFLAGS) diff --git a/include/package-bin.mk b/include/package-bin.mk index 192f0726d..4ca49218e 100644 --- a/include/package-bin.mk +++ b/include/package-bin.mk @@ -4,7 +4,8 @@ ifeq ($(DUMP),) define BuildTarget/bin - ifeq ($(if $(VARIANT),$(BUILD_VARIANT)),$(VARIANT)) + TARGET_VARIANT=$(if $(ALL_VARIANTS),$(if $(VARIANT),$(filter-out *,$(VARIANT)),$(firstword $(ALL_VARIANTS)))) + ifeq ($(if $(TARGET_VARIANT),$(BUILD_VARIANT)),$(TARGET_VARIANT)) ifdef Package/$(1)/install ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),) $(_pkg_target)compile: $(PKG_BUILD_DIR)/.pkgdir/$(1).installed diff --git a/include/package-defaults.mk b/include/package-defaults.mk index 3ee3a965f..72f88b9bb 100644 --- a/include/package-defaults.mk +++ b/include/package-defaults.mk @@ -2,7 +2,7 @@ # # Copyright (C) 2006-2020 OpenWrt.org -PKG_DEFAULT_DEPENDS = +libc +USE_GLIBC:librt +USE_GLIBC:libpthread +PKG_DEFAULT_DEPENDS = +libc ifneq ($(PKG_NAME),toolchain) PKG_FIXUP_DEPENDS = $(if $(filter kmod-%,$(1)),$(2),$(PKG_DEFAULT_DEPENDS) $(filter-out $(PKG_DEFAULT_DEPENDS),$(2))) diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk index 19f09c231..3063a86a2 100644 --- a/include/package-ipkg.mk +++ b/include/package-ipkg.mk @@ -105,7 +105,8 @@ ifeq ($(DUMP),) IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1) KEEP_$(1):=$(strip $(call Package/$(1)/conffiles)) - ifeq ($(BUILD_VARIANT),$$(if $$(VARIANT),$$(VARIANT),$(BUILD_VARIANT))) + TARGET_VARIANT:=$$(if $(ALL_VARIANTS),$$(if $$(VARIANT),$$(filter-out *,$$(VARIANT)),$(firstword $(ALL_VARIANTS)))) + ifeq ($(BUILD_VARIANT),$$(if $$(TARGET_VARIANT),$$(TARGET_VARIANT),$(BUILD_VARIANT))) do_install= ifdef Package/$(1)/install do_install=yes @@ -263,7 +264,7 @@ $(_endef) endif $(INSTALL_DIR) $$(PDIR_$(1)) - $(FAKEROOT) $(SCRIPT_DIR)/ipkg-build -m "$(FILE_MODES)" $$(IDIR_$(1)) $$(PDIR_$(1)) + $(FAKEROOT) $(STAGING_DIR_HOST)/bin/bash $(SCRIPT_DIR)/ipkg-build -m "$(FILE_MODES)" $$(IDIR_$(1)) $$(PDIR_$(1)) @[ -f $$(IPKG_$(1)) ] $(1)-clean: diff --git a/include/package.mk b/include/package.mk index db0a869da..368bf0d7c 100644 --- a/include/package.mk +++ b/include/package.mk @@ -13,6 +13,7 @@ PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install PKG_BUILD_PARALLEL ?= PKG_USE_MIPS16 ?= 1 PKG_IREMAP ?= 1 +PKG_SKIP_DOWNLOAD=$(USE_SOURCE_DIR)$(USE_GIT_TREE)$(USE_GIT_SRC_CHECKOUT) MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j)) @@ -84,7 +85,7 @@ ifneq ($(PREV_STAMP_PREPARED),) STAMP_PREPARED:=$(PREV_STAMP_PREPARED) CONFIG_AUTOREBUILD:= else - STAMP_PREPARED=$(PKG_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),))_$(call confvar,CONFIG_AUTOREMOVE $(PKG_PREPARED_DEPENDS))) + STAMP_PREPARED=$(PKG_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call $(if $(CONFIG_AUTOREMOVE),find_md5_reproducible,find_md5),${CURDIR} $(PKG_FILE_DEPENDS),))_$(call confvar,CONFIG_AUTOREMOVE $(PKG_PREPARED_DEPENDS))) endif STAMP_CONFIGURED=$(PKG_BUILD_DIR)/.configured$(if $(DUMP),,_$(call confvar,$(PKG_CONFIG_DEPENDS))) STAMP_CONFIGURED_WILDCARD=$(PKG_BUILD_DIR)/.configured_* @@ -183,7 +184,7 @@ define Build/CoreTargets $(call Build/Autoclean) $(call DefaultTargets) - $(DL_DIR)/$(FILE): FORCE + $(call check_download_integrity) download: $(foreach hook,$(Hooks/Download), @@ -258,13 +259,13 @@ define Build/CoreTargets ifneq ($(CONFIG_AUTOREMOVE),) compile: -touch -r $(PKG_BUILD_DIR)/.built $(PKG_BUILD_DIR)/.autoremove 2>/dev/null >/dev/null - $(FIND) $(PKG_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' | \ - $(XARGS) rm -rf + $(FIND) $(PKG_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' -print0 | \ + $(XARGS) -0 rm -rf endif endef define Build/DefaultTargets - $(if $(USE_SOURCE_DIR)$(USE_GIT_TREE)$(USE_GIT_SRC_CHECKOUT),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))) + $(if $(PKG_SKIP_DOWNLOAD),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))) $(if $(DUMP),,$(Build/CoreTargets)) define Build/DefaultTargets diff --git a/include/prereq-build.mk b/include/prereq-build.mk index bc00cf2f1..9c4ef547a 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -53,6 +53,13 @@ $(eval $(call TestHostCommand,ncurses, \ Please install ncurses. (Missing libncurses.so or ncurses.h), \ echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \ gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses)) + +$(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \ + git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule, \ + git submodule --help | grep -- --recursive)) + +$(eval $(call SetupHostCommand,rsync,Please install 'rsync', \ + rsync --version &1 | grep zipfile, \ unzip)) @@ -157,44 +172,48 @@ $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \ $(eval $(call CleanupPython2)) $(eval $(call SetupHostCommand,python,Please install Python >= 3.6, \ + python3.11 -V 2>&1 | grep 'Python 3', \ python3.10 -V 2>&1 | grep 'Python 3', \ python3.9 -V 2>&1 | grep 'Python 3', \ python3.8 -V 2>&1 | grep 'Python 3', \ python3.7 -V 2>&1 | grep 'Python 3', \ python3.6 -V 2>&1 | grep 'Python 3', \ - python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|10)\.?')) + python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|[0-9][0-9])\.?')) $(eval $(call SetupHostCommand,python3,Please install Python >= 3.6, \ + python3.11 -V 2>&1 | grep 'Python 3', \ python3.10 -V 2>&1 | grep 'Python 3', \ python3.9 -V 2>&1 | grep 'Python 3', \ python3.8 -V 2>&1 | grep 'Python 3', \ python3.7 -V 2>&1 | grep 'Python 3', \ python3.6 -V 2>&1 | grep 'Python 3', \ - python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|10)\.?')) + python3 -V 2>&1 | grep -E 'Python 3\.([6-9]|[0-9][0-9])\.?')) $(eval $(call TestHostCommand,python3-distutils, \ Please install the Python3 distutils module, \ - $(STAGING_DIR_HOST)/bin/python3 -c 'import distutils')) + $(STAGING_DIR_HOST)/bin/python3 -c 'from distutils import util')) -$(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \ - git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule)) +$(eval $(call TestHostCommand,python3-stdlib, \ + Please install the Python3 stdlib module, \ + $(STAGING_DIR_HOST)/bin/python3 -c 'import ntpath')) $(eval $(call SetupHostCommand,file,Please install the 'file' package, \ file --version 2>&1 | grep file)) -$(eval $(call SetupHostCommand,rsync,Please install 'rsync', \ - rsync --version /dev/null 2>/dev/null; then \ mkdir -p "$(STAGING_DIR_HOST)/bin"; \ ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \ diff --git a/include/quilt.mk b/include/quilt.mk index 6d25469da..18cafe60a 100644 --- a/include/quilt.mk +++ b/include/quilt.mk @@ -116,7 +116,7 @@ define Quilt/RefreshDir endef define Quilt/Refresh/Host - $(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(PATCH_DIR)) + $(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(HOST_PATCH_DIR)) endef define Quilt/Refresh/Package diff --git a/include/scan.mk b/include/scan.mk index aee24cb3e..5032afa81 100644 --- a/include/scan.mk +++ b/include/scan.mk @@ -72,7 +72,7 @@ endif $(FILELIST): $(OVERRIDELIST) rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-* - find -L $(SCAN_DIR) $(SCAN_EXTRA) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -aHE 'call $(GREP_STRING)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@ + find -L $(SCAN_DIR) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) $(SCAN_EXTRA) -name Makefile | xargs grep -aHE 'call $(GREP_STRING)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@ $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST) ( \ diff --git a/include/subdir.mk b/include/subdir.mk index be080859b..95009f814 100644 --- a/include/subdir.mk +++ b/include/subdir.mk @@ -27,14 +27,16 @@ lastdir=$(word $(words $(subst /, ,$(1))),$(subst /, ,$(1))) diralias=$(if $(findstring $(1),$(call lastdir,$(1))),,$(call lastdir,$(1))) subdir_make_opts = \ - -r -C $(1) \ + $(if $(SUBDIR_MAKE_DEBUG),-d) -r -C $(1) \ BUILD_SUBDIR="$(1)" \ - BUILD_VARIANT="$(4)" + BUILD_VARIANT="$(4)" \ + ALL_VARIANTS="$(5)" # 1: subdir # 2: target # 3: build type # 4: build variant +# 5: all variants log_make = \ $(if $(call debug,$(1),v),,@)+ \ $(if $(BUILD_LOG), \ @@ -62,15 +64,15 @@ define subdir $(foreach target,$(SUBTARGETS) $($(1)/subtargets), $(foreach btype,$(buildtypes-$(bd)), $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(btype)/$(target): $(if $(NO_DEPS)$(QUILT),,$($(1)/$(bd)/$(btype)/$(target)) $(call $(1)//$(btype)/$(target),$(1)/$(bd)/$(btype)))) - $(call log_make,$(1)/$(bd),$(target),$(btype),$(filter-out __default,$(variant))) \ + $(call log_make,$(1)/$(bd),$(target),$(btype),$(filter-out __default,$(variant)),$($(1)/$(bd)/variants)) \ || $(call ERROR,$(2), ERROR: $(1)/$(bd) [$(btype)] failed to build.,$(findstring $(bd),$($(1)/builddirs-ignore-$(btype)-$(target)))) $(if $(call diralias,$(bd)),$(call warn_eval,$(1)/$(bd),l,T,$(1)/$(call diralias,$(bd))/$(btype)/$(target): $(1)/$(bd)/$(btype)/$(target))) ) $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(target): $(if $(NO_DEPS)$(QUILT),,$($(1)/$(bd)/$(target)) $(call $(1)//$(target),$(1)/$(bd)))) - $(foreach variant,$(if $(BUILD_VARIANT),$(BUILD_VARIANT),$(if $(strip $($(1)/$(bd)/variants)),$($(1)/$(bd)/variants),$(if $($(1)/$(bd)/default-variant),$($(1)/$(bd)/default-variant),__default))), + $(foreach variant,$(filter-out *,$(if $(BUILD_VARIANT),$(BUILD_VARIANT),$(if $(strip $($(1)/$(bd)/variants)),$($(1)/$(bd)/variants),$(if $($(1)/$(bd)/default-variant),$($(1)/$(bd)/default-variant),__default)))), $(if $(BUILD_LOG),@mkdir -p $(BUILD_LOG_DIR)/$(1)/$(bd)/$(filter-out __default,$(variant))) - $(if $($(1)/autoremove),$(call rebuild_check,$(1)/$(bd),$(target),,$(filter-out __default,$(variant)))) - $(call log_make,$(1)/$(bd),$(target),,$(filter-out __default,$(variant))) \ + $(if $($(1)/autoremove),$(call rebuild_check,$(1)/$(bd),$(target),,$(filter-out __default,$(variant)),$($(1)/$(bd)/variants))) + $(call log_make,$(1)/$(bd),$(target),,$(filter-out __default,$(variant)),$($(1)/$(bd)/variants)) \ || $(call ERROR,$(1), ERROR: $(1)/$(bd) failed to build$(if $(filter-out __default,$(variant)), (build variant: $(variant))).,$(findstring $(bd),$($(1)/builddirs-ignore-$(target)))) ) $(if $(PREREQ_ONLY)$(DUMP_TARGET_DB),, diff --git a/include/target.mk b/include/target.mk index 16381bc32..2a138784c 100644 --- a/include/target.mk +++ b/include/target.mk @@ -12,6 +12,7 @@ DEVICE_TYPE?=router # Default packages - the really basic set DEFAULT_PACKAGES:=\ base-files \ + ca-bundle \ dropbear \ fstools \ libc \ @@ -23,7 +24,8 @@ DEFAULT_PACKAGES:=\ opkg \ uci \ uclient-fetch \ - urandom-seed + urandom-seed \ + urngd ifneq ($(CONFIG_SELINUX),) DEFAULT_PACKAGES+=busybox-selinux procd-selinux @@ -31,6 +33,16 @@ else DEFAULT_PACKAGES+=busybox procd endif +# include ujail on systems with enough storage +ifeq ($(CONFIG_SMALL_FLASH),) +DEFAULT_PACKAGES+=procd-ujail +endif + +# include seccomp ld-preload hooks if kernel supports it +ifneq ($(CONFIG_SECCOMP),) +DEFAULT_PACKAGES+=procd-seccomp +endif + # For the basic set DEFAULT_PACKAGES.basic:= # For nas targets @@ -41,16 +53,12 @@ DEFAULT_PACKAGES.nas:=\ mdadm # For router targets DEFAULT_PACKAGES.router:=\ - dnsmasq-full \ - firewall \ - iptables \ - ppp \ - ppp-mod-pppoe \ - luci-newapi block-mount coremark kmod-nf-nathelper kmod-nf-nathelper-extra kmod-ipt-raw \ - default-settings luci luci-app-ddns luci-app-upnp luci-app-autoreboot \ - luci-app-filetransfer luci-app-vsftpd luci-app-ssr-plus luci-app-unblockmusic luci-app-arpbind \ - luci-app-vlmcsd luci-app-wol luci-app-ramfree \ - luci-app-turboacc luci-app-nlbwmon luci-app-accesscontrol ddns-scripts_aliyun ddns-scripts_dnspod + dnsmasq-full firewall iptables ppp ppp-mod-pppoe \ + block-mount coremark kmod-nf-nathelper kmod-nf-nathelper-extra kmod-ipt-raw kmod-tun \ + iptables-mod-tproxy iptables-mod-extra ipset ip-full default-settings luci luci-newapi \ + ddns-scripts_aliyun ddns-scripts_dnspod luci-app-ddns luci-app-upnp luci-app-autoreboot \ + luci-app-arpbind luci-app-filetransfer luci-app-vsftpd luci-app-ssr-plus luci-app-vlmcsd \ + luci-app-accesscontrol luci-app-nlbwmon luci-app-turboacc luci-app-wol curl ca-certificates ifneq ($(DUMP),) all: dumpinfo @@ -58,7 +66,7 @@ endif target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) ifeq ($(DUMP),) - PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD) + PLATFORM_DIR:=$(firstword $(wildcard $(TOPDIR)/target/linux/feeds/$(BOARD) $(TOPDIR)/target/linux/$(BOARD))) SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir)))) else PLATFORM_DIR:=${CURDIR} @@ -163,22 +171,30 @@ USE_SUBTARGET_CONFIG = $(if $(wildcard $(LINUX_TARGET_CONFIG)),,$(if $(LINUX_SUB LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG))) LINUX_RECONFIG_TARGET = $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG),$(LINUX_TARGET_CONFIG)) +CFG_TARGET = $(CONFIG_TARGET) +ifeq ($(CFG_TARGET),platform) + CFG_TARGET = target + $(warning Deprecation warning: use CONFIG_TARGET=target instead.) +else ifeq ($(CFG_TARGET),subtarget_platform) + CFG_TARGET = subtarget_target + $(warning Deprecation warning: use CONFIG_TARGET=subtarget_target instead.) +endif + # select the config file to be changed by kernel_menuconfig/kernel_oldconfig -ifeq ($(CONFIG_TARGET),platform) +ifeq ($(CFG_TARGET),target) LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG)) LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG) -endif -ifeq ($(CONFIG_TARGET),subtarget) +else ifeq ($(CFG_TARGET),subtarget) LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG)) LINUX_RECONFIG_TARGET = $(LINUX_SUBTARGET_CONFIG) -endif -ifeq ($(CONFIG_TARGET),subtarget_platform) +else ifeq ($(CFG_TARGET),subtarget_target) LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(LINUX_TARGET_CONFIG)) LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG) -endif -ifeq ($(CONFIG_TARGET),env) +else ifeq ($(CFG_TARGET),env) LINUX_RECONFIG_LIST = $(LINUX_KCONFIG_LIST) LINUX_RECONFIG_TARGET = $(TOPDIR)/env/kernel-config +else ifneq ($(strip $(CFG_TARGET)),) + $(error CONFIG_TARGET=$(CFG_TARGET) is invalid. Valid: target|subtarget|subtarget_target|env) endif __linux_confcmd = $(2) $(patsubst %,+,$(wordlist 2,9999,$(1))) $(1) @@ -217,12 +233,14 @@ ifeq ($(DUMP),1) ifeq ($(ARCH),powerpc) CPU_CFLAGS_603e:=-mcpu=603e CPU_CFLAGS_8540:=-mcpu=8540 + CPU_CFLAGS_8548:=-mcpu=8548 CPU_CFLAGS_405:=-mcpu=405 CPU_CFLAGS_440:=-mcpu=440 CPU_CFLAGS_464fp:=-mcpu=464fp endif ifeq ($(ARCH),powerpc64) CPU_TYPE ?= powerpc64 + CPU_CFLAGS_e5500:=-mcpu=e5500 CPU_CFLAGS_powerpc64:=-mcpu=powerpc64 endif ifeq ($(ARCH),sparc) diff --git a/include/toolchain-build.mk b/include/toolchain-build.mk index b7a253b71..87ba8313d 100644 --- a/include/toolchain-build.mk +++ b/include/toolchain-build.mk @@ -18,6 +18,6 @@ define FixupLibdir mkdir -p $(1)/lib; \ mv $(1)/lib64/* $(1)/lib/; \ rm -rf $(1)/lib64; \ + ln -sf lib $(1)/lib64; \ fi - ln -sf lib $(1)/lib64 endef diff --git a/include/toplevel.mk b/include/toplevel.mk index f5a2593a1..455fc9c4d 100644 --- a/include/toplevel.mk +++ b/include/toplevel.mk @@ -60,6 +60,7 @@ endif SCAN_COOKIE?=$(shell echo $$$$) export SCAN_COOKIE +export STAGING_DIR_HOST=$(TOPDIR)/staging_dir/host SUBMAKE:=umask 022; $(SUBMAKE) @@ -77,7 +78,7 @@ prepare-tmpinfo: FORCE @+$(MAKE) -r -s staging_dir/host/.prereq-build $(PREP_MK) mkdir -p tmp/info $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPTH=5 SCAN_EXTRA="" - $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1" + $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPTH=3 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1" for type in package target; do \ f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \ [ "$$t" -nt "$$f" ] || ./scripts/$${type}-metadata.pl $(_ignore) config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \ @@ -101,7 +102,7 @@ ifneq ($(DISTRO_PKG_CONFIG),) scripts/config/%onf: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH) endif scripts/config/%onf: CFLAGS+= -O2 -scripts/config/%onf: +scripts/config/%onf: FORCE @$(_SINGLE)$(SUBMAKE) $(if $(findstring s,$(OPENWRT_VERBOSE)),,-s) \ -C scripts/config $(notdir $@) diff --git a/include/trusted-firmware-a.mk b/include/trusted-firmware-a.mk index dd740c45f..082ada269 100644 --- a/include/trusted-firmware-a.mk +++ b/include/trusted-firmware-a.mk @@ -1,5 +1,5 @@ PKG_NAME ?= trusted-firmware-a -PKG_CPE_ID ?= cpe:/a:arm:arm_trusted_firmware +PKG_CPE_ID ?= cpe:/a:arm:trusted_firmware-a ifndef PKG_SOURCE_PROTO PKG_SOURCE = trusted-firmware-a-$(PKG_VERSION).tar.gz @@ -68,13 +68,20 @@ define Build/Trusted-Firmware-A/Target endef endef +define Build/Configure/Trusted-Firmware-A + $(INSTALL_DIR) $(STAGING_DIR)/usr/include +endef + +DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc) define Build/Compile/Trusted-Firmware-A +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ CROSS_COMPILE=$(TARGET_CROSS) \ OPENSSL_DIR=$(STAGING_DIR_HOST) \ + $(if $(DTC),DTC="$(DTC)") \ PLAT=$(PLAT) \ BUILD_STRING="OpenWrt v$(PKG_VERSION)-$(PKG_RELEASE) ($(VARIANT))" \ + $(if $(CONFIG_BINUTILS_VERSION_2_39),LDFLAGS="-no-warn-rwx-segments") \ $(TFA_MAKE_FLAGS) endef diff --git a/include/u-boot.mk b/include/u-boot.mk index c0a1e87bf..8945e8e2b 100644 --- a/include/u-boot.mk +++ b/include/u-boot.mk @@ -45,6 +45,11 @@ UBOOT_MAKE_FLAGS = \ HOSTCC="$(HOSTCC)" \ HOSTCFLAGS="$(HOST_CFLAGS) $(HOST_CPPFLAGS) -std=gnu11" \ HOSTLDFLAGS="$(HOST_LDFLAGS)" \ + LOCALVERSION="-OpenWrt-$(REVISION)" \ + STAGING_PREFIX="$(STAGING_DIR_HOST)" \ + PKG_CONFIG_PATH="$(STAGING_DIR_HOST)/lib/pkgconfig" \ + PKG_CONFIG_LIBDIR="$(STAGING_DIR_HOST)/lib/pkgconfig" \ + PKG_CONFIG_EXTRAARGS="--static" \ $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') define Build/U-Boot/Target diff --git a/include/uclibc++.mk b/include/uclibc++.mk index a1a61f26d..10f8d98e1 100644 --- a/include/uclibc++.mk +++ b/include/uclibc++.mk @@ -1,16 +1,2 @@ -ifndef DUMP - ifdef __package_mk - $(error uclibc++.mk must be included before package.mk) - endif -endif - -PKG_PREPARED_DEPENDS += CONFIG_USE_UCLIBCXX -CXX_DEPENDS = +USE_UCLIBCXX:uclibcxx +USE_LIBSTDCXX:libstdcpp - -ifneq ($(CONFIG_USE_UCLIBCXX),) - ifneq ($(CONFIG_CCACHE),) - TARGET_CXX_NOCACHE=g++-uc - else - TARGET_CXX=g++-uc - endif -endif +$(warn uclibc++.mk is deprecated. Please remove it and CXX_DEPENDS) +CXX_DEPENDS = +libstdcpp diff --git a/include/verbose.mk b/include/verbose.mk index 3ecf842d1..4487a207e 100644 --- a/include/verbose.mk +++ b/include/verbose.mk @@ -29,15 +29,15 @@ ifeq ($(IS_TTY),1) endif endif +define ERROR_MESSAGE + printf "$(_R)%s$(_N)\n" "$(1)" >&8 +endef + ifeq ($(findstring s,$(OPENWRT_VERBOSE)),) define MESSAGE printf "$(_Y)%s$(_N)\n" "$(1)" >&8 endef - define ERROR_MESSAGE - printf "$(_R)%s$(_N)\n" "$(1)" >&8 - endef - ifeq ($(QUIET),1) ifneq ($(CURDIR),$(TOPDIR)) _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR}) @@ -60,5 +60,4 @@ else define MESSAGE printf "%s\n" "$(1)" endef - ERROR_MESSAGE=$(MESSAGE) endif diff --git a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/common/rtmp_init.c b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/common/rtmp_init.c index a0d9eb2ad..3a9411a86 100644 --- a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/common/rtmp_init.c +++ b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/common/rtmp_init.c @@ -114,7 +114,7 @@ NDIS_STATUS RTMPAllocAdapterBlock(VOID *handle, VOID **ppAdapter) pAd->OS_Cookie = handle; ((POS_COOKIE)(handle))->pAd_va = (UINT32)pAd; } - DBGPRINT(RT_DEBUG_OFF, ("\n\n=== pAd = %p, size = %d ===\n\n", pAd, sizeof(RTMP_ADAPTER))); + DBGPRINT(RT_DEBUG_OFF, ("\n=== pAd = %p, size = %d ===\n", pAd, sizeof(RTMP_ADAPTER))); if (RtmpOsStatsAlloc(&pAd->stats, &pAd->iw_stats) == FALSE) { diff --git a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/mcu/andes_mt.c b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/mcu/andes_mt.c index cd3b3c371..376f49aa4 100644 --- a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/mcu/andes_mt.c +++ b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/mcu/andes_mt.c @@ -2253,15 +2253,15 @@ static NDIS_STATUS AndesMTLoadFwMethod1(RTMP_ADAPTER *ad) Ctl->Stage = FW_DOWNLOAD; - DBGPRINT(RT_DEBUG_OFF, ("FW Version:")); + printk(KERN_CONT "FW Version:"); for (loop = 0; loop < 10; loop++) - DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->FWImageName + cap->fw_len - 29 + loop))); - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "%c", *(cap->FWImageName + cap->fw_len - 29 + loop)); + printk(KERN_CONT "\n"); - DBGPRINT(RT_DEBUG_OFF, ("FW Build Date:")); + printk(KERN_CONT "FW Build Date:"); for (loop = 0; loop < 15; loop++) - DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->FWImageName + cap->fw_len - 19 + loop))); - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "%c", *(cap->FWImageName + cap->fw_len - 19 + loop)); + printk(KERN_CONT "\n"); dl_len = (*(cap->FWImageName + cap->fw_len - 1) << 24) | (*(cap->FWImageName + cap->fw_len - 2) << 16) | diff --git a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/os/linux/rt_linux.c b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/os/linux/rt_linux.c index 68abbd8b4..5eec53ceb 100644 --- a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/os/linux/rt_linux.c +++ b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi/os/linux/rt_linux.c @@ -914,6 +914,7 @@ static inline void __RtmpOSFSInfoChange(OS_FS_INFO * pOSFSInfo, BOOLEAN bSet) #endif #endif +#if 0 pOSFSInfo->fs = get_fs(); set_fs(KERNEL_DS); } else { @@ -921,6 +922,7 @@ static inline void __RtmpOSFSInfoChange(OS_FS_INFO * pOSFSInfo, BOOLEAN bSet) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) current->fsuid = pOSFSInfo->fsuid; current->fsgid = pOSFSInfo->fsgid; +#endif #endif } } @@ -1936,8 +1938,10 @@ VOID RtmpDrvAllMacPrint( if (!msg) return; +#if 0 orig_fs = get_fs(); set_fs(KERNEL_DS); +#endif /* open file */ file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0); @@ -1965,7 +1969,9 @@ VOID RtmpDrvAllMacPrint( } filp_close(file_w, NULL); } +#if 0 set_fs(orig_fs); +#endif os_free_mem(NULL, msg); } @@ -1987,8 +1993,10 @@ VOID RtmpDrvAllE2PPrint( if (!msg) return; +#if 0 orig_fs = get_fs(); set_fs(KERNEL_DS); +#endif /* open file */ file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0); @@ -2017,7 +2025,9 @@ VOID RtmpDrvAllE2PPrint( } filp_close(file_w, NULL); } +#if 0 set_fs(orig_fs); +#endif os_free_mem(NULL, msg); } @@ -2031,8 +2041,10 @@ VOID RtmpDrvAllRFPrint( RTMP_STRING *fileName = "RFDump.txt"; mm_segment_t orig_fs; +#if 0 orig_fs = get_fs(); set_fs(KERNEL_DS); +#endif /* open file */ file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0); @@ -2048,7 +2060,9 @@ VOID RtmpDrvAllRFPrint( } filp_close(file_w, NULL); } +#if 0 set_fs(orig_fs); +#endif } diff --git a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi_ap/Kconfig b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi_ap/Kconfig index bffacbbb2..ecfe63491 100644 --- a/package/lean/mt/drivers/mt7603e/src/mt7603_wifi_ap/Kconfig +++ b/package/lean/mt/drivers/mt7603e/src/mt7603_wifi_ap/Kconfig @@ -154,7 +154,7 @@ config MT7603E_SECURITY_IMPROVEMENT_SUPPORT bool "WPA2 security improvement support" depends on MT7603E_RLT_AP_SUPPORT default n - ---help--- + help WPA2 security improvement support @@ -164,7 +164,7 @@ config MT7603E_WPA3_SUPPORT select MT7603E_SECURITY_IMPROVEMENT_SUPPORT depends on MT7603E_RLT_AP_SUPPORT default n - ---help--- + help WPA3 support config MT7603E_OWE_SUPPORT @@ -172,12 +172,12 @@ config MT7603E_OWE_SUPPORT select MT7603E_DOT11W_PMF_SUPPORT depends on MT7603E_RLT_AP_SUPPORT default n - ---help--- + help Enhanced Open/OWE support config MT7603E_NEW_BW2040_COEXIST_SUPPORT bool "New BW20/40 Coexist support" depends on MT7603E_RLT_AP_SUPPORT default y - ---help--- + help Both Beacon and Radio fallback to BW20 for anti-interference diff --git a/package/lean/mt/drivers/mt7612e/src/mt76x2/common/rtmp_init.c b/package/lean/mt/drivers/mt7612e/src/mt76x2/common/rtmp_init.c index ca2d3f965..8ac539d71 100644 --- a/package/lean/mt/drivers/mt7612e/src/mt76x2/common/rtmp_init.c +++ b/package/lean/mt/drivers/mt7612e/src/mt76x2/common/rtmp_init.c @@ -124,7 +124,7 @@ NDIS_STATUS RTMPAllocAdapterBlock(VOID *handle, VOID **ppAdapter) #endif /* WORKQUEUE_BH */ } pAd->BeaconBuf = pBeaconBuf; - DBGPRINT(RT_DEBUG_OFF, ("\n\n=== pAd = %p, size = %d ===\n\n", pAd, sizeof(RTMP_ADAPTER))); + DBGPRINT(RT_DEBUG_OFF, ("\n=== pAd = %p, size = %d ===\n", pAd, sizeof(RTMP_ADAPTER))); if (RtmpOsStatsAlloc(&pAd->iw_stats) == FALSE) { diff --git a/package/lean/mt/drivers/mt7612e/src/mt76x2/mcu/mcu_and.c b/package/lean/mt/drivers/mt7612e/src/mt76x2/mcu/mcu_and.c index 79adb54ed..daa70a59a 100644 --- a/package/lean/mt/drivers/mt7612e/src/mt76x2/mcu/mcu_and.c +++ b/package/lean/mt/drivers/mt7612e/src/mt76x2/mcu/mcu_and.c @@ -100,10 +100,10 @@ loadfw_protect: #ifdef DBG /* get rom patch information */ - DBGPRINT(RT_DEBUG_OFF, ("build time = ")); + printk(KERN_CONT "build time = "); for (loop = 0; loop < 16; loop++) - DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->rom_patch + loop))); - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "%c", *(cap->rom_patch + loop)); + printk(KERN_CONT "\n"); #endif if (IS_MT76x2(ad)) { @@ -121,22 +121,22 @@ loadfw_protect: } #ifdef DBG - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "\n"); - DBGPRINT(RT_DEBUG_OFF, ("platform = ")); + printk(KERN_CONT "platform = "); for (loop = 0; loop < 4; loop++) - DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->rom_patch + 16 + loop))); - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "%c", *(cap->rom_patch + 16 + loop)); + printk(KERN_CONT "\n"); - DBGPRINT(RT_DEBUG_OFF, ("hw/sw version = ")); + printk(KERN_CONT "hw/sw version = "); for (loop = 0; loop < 4; loop++) - DBGPRINT(RT_DEBUG_OFF, ("%x", *(cap->rom_patch + 20 + loop))); - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "%x", *(cap->rom_patch + 20 + loop)); + printk(KERN_CONT "\n"); - DBGPRINT(RT_DEBUG_OFF, ("patch version = ")); + printk(KERN_CONT "patch version = "); for (loop = 0; loop < 4; loop++) - DBGPRINT(RT_DEBUG_OFF, ("%x", *(cap->rom_patch + 24 + loop))); - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "%x", *(cap->rom_patch + 24 + loop)); + printk(KERN_CONT "\n"); #endif RTMP_IO_WRITE32(ad, PCIE_REMAP_BASE4, cap->rom_patch_offset - 10000); @@ -239,10 +239,10 @@ int andes_pci_erasefw(RTMP_ADAPTER *ad) (fw_ver & 0x0f00) >> 8, fw_ver & 0x00ff)); DBGPRINT(RT_DEBUG_TRACE, ("Build:%x\n", build_ver)); - DBGPRINT(RT_DEBUG_TRACE, ("Build Time:")); + printk(KERN_CONT "Build Time:"); for (loop = 0; loop < 16; loop++) - DBGPRINT(RT_DEBUG_TRACE, ("%c", *(cap->FWImageName + 16 + loop))); - DBGPRINT(RT_DEBUG_TRACE, ("\n")); + printk(KERN_CONT "%c", *(cap->FWImageName + 16 + loop)); + printk(KERN_CONT "\n"); DBGPRINT(RT_DEBUG_TRACE, ("ILM Length = %d(bytes)\n", ilm_len)); DBGPRINT(RT_DEBUG_TRACE, ("DLM Length = %d(bytes)\n", dlm_len)); @@ -386,10 +386,10 @@ loadfw_protect: (fw_ver & 0x0f00) >> 8, fw_ver & 0x00ff)); DBGPRINT(RT_DEBUG_OFF, ("Build:%x\n", build_ver)); - DBGPRINT(RT_DEBUG_OFF, ("Build Time:")); + printk(KERN_CONT "Build Time:"); for (loop = 0; loop < 16; loop++) - DBGPRINT(RT_DEBUG_OFF, ("%c", *(cap->FWImageName + 16 + loop))); - DBGPRINT(RT_DEBUG_OFF, ("\n")); + printk(KERN_CONT "%c", *(cap->FWImageName + 16 + loop)); + printk(KERN_CONT "\n"); #endif if (IS_MT76x2(ad)) { diff --git a/package/lean/mt/drivers/mt7615d/files/lib/netifd/wireless/mt_dbdc.sh b/package/lean/mt/drivers/mt7615d/files/lib/netifd/wireless/mt_dbdc.sh index 394544f52..d6f5ed195 100644 --- a/package/lean/mt/drivers/mt7615d/files/lib/netifd/wireless/mt_dbdc.sh +++ b/package/lean/mt/drivers/mt7615d/files/lib/netifd/wireless/mt_dbdc.sh @@ -5,8 +5,9 @@ # Copyright (c) 2013, Hoowa # Copyright (c) 2015-2017, GuoGuo # Copyright (c) 2020, jjm2473 +# Copyright (c) 2022, nanchuci # -# netifd config script for MT7615 DBDC mode. +# netifd config script for MT7615/MT7915 DBDC mode. # # 嘿,对着屏幕的哥们,为了表示对原作者辛苦工作的尊重,任何引用跟借用都不允许你抹去所有作者的信息,请保留这段话。 # @@ -68,7 +69,10 @@ drv_mt_dbdc_init_device_config() { drv_mt_dbdc_init_iface_config() { config_add_boolean disabled config_add_string mode bssid ssid encryption + config_add_boolean hidden isolate doth ieee80211k + config_add_boolean hidden isolate doth ieee80211v config_add_boolean hidden isolate doth ieee80211r + config_add_boolean hidden isolate doth ieee80211w config_add_string key key1 key2 key3 key4 config_add_string wps config_add_string pin @@ -97,7 +101,7 @@ mt_dbdc_ap_vif_pre_config() { local name="$1" json_select config - json_get_vars disabled encryption key key1 key2 key3 key4 ssid mode wps pin isolate doth hidden disassoc_low_ack rssiassoc ieee80211r macfilter + json_get_vars disabled encryption key key1 key2 key3 key4 ssid mode wps pin isolate doth hidden disassoc_low_ack rssiassoc ieee80211k ieee80211v ieee80211r ieee80211w macfilter json_get_values maclist maclist json_select .. [ "$disabled" == "1" ] && return @@ -192,7 +196,7 @@ mt_dbdc_ap_vif_pre_config() { mt_cmd echo "Interface $ifname now up." mt_cmd iwpriv $ifname set NoForwarding=${isolate:-0} mt_cmd iwpriv $ifname set IEEE80211H=${doth:-0} - if [ "$wps" == "pbc" ] && [ "$encryption" != "none" ]; then + if [ "$wps" == "pbc" ] || [ "$wps" == "pin" ] && [ "$encryption" != "none" ]; then echo "Enable WPS for ${ifname}." mt_cmd iwpriv $ifname set WscConfMode=4 mt_cmd iwpriv $ifname set WscConfStatus=2 @@ -203,7 +207,10 @@ mt_dbdc_ap_vif_pre_config() { fi [ -n "$disassoc_low_ack" ] && [ "$disassoc_low_ack" != "0" ] && mt_cmd iwpriv $ifname set KickStaRssiLow=$disassoc_low_ack [ -n "$rssiassoc" ] && [ "$rssiassoc" != "0" ] && mt_cmd iwpriv $ifname set AssocReqRssiThres=$rssiassoc + [ -n "$ieee80211k" ] && [ "$ieee80211k" != "0" ] && mt_cmd iwpriv $ifname set rrmenable=1 + [ -n "$ieee80211v" ] && [ "$ieee80211v" != "0" ] && mt_cmd iwpriv $ifname set wnmenable=1 [ -n "$ieee80211r" ] && [ "$ieee80211r" != "0" ] && mt_cmd iwpriv $ifname set ftenable=1 + [ -n "$ieee80211w" ] && [ "$ieee80211w" != "0" ] && mt_cmd iwpriv $ifname set pmfenable=1 } mt_dbdc_wds_vif_pre_config() { @@ -272,7 +279,7 @@ mt_dbdc_ap_vif_post_config() { local name="$1" json_select config - json_get_vars disabled encryption key key1 key2 key3 key4 ssid mode wps pin isolate doth hidden disassoc_low_ack rssiassoc ieee80211r + json_get_vars disabled encryption key key1 key2 key3 key4 ssid mode wps pin isolate doth hidden disassoc_low_ack rssiassoc ieee80211k ieee80211v ieee80211r ieee80211w json_select .. [ "$disabled" == "1" ] && return @@ -532,6 +539,10 @@ MacAddress=${macaddr} CountryRegion=${countryregion:-5} CountryRegionABand=${countryregion_a:-7} CountryCode=${country:-CN} +RRMEnable=${RRMEnable:-0};${RRMEnable:-0};${RRMEnable:-0};${RRMEnable:-0} +WNMEnable=${WNMEnable:-0};${WNMEnable:-0};${WNMEnable:-0};${WNMEnable:-0} +FTEnable=${FTEnable:-0};${FTEnable:-0};${FTEnable:-0};${FTEnable:-0} +PMFenable=${PMFenable:-0};${PMFenable:-0};${PMFenable:-0};${PMFenable:-0} WirelessMode=${WirelessMode} G_BAND_256QAM=1 FixedTxMode= @@ -547,8 +558,8 @@ BFBACKOFFenable=0 CalCacheApply=0 DisableOLBC=0 BGProtection=0 -TxAntenna= -RxAntenna= +TxAntenna=${TxAntenna:-2};${TxAntenna:-2};${TxAntenna:-4};${TxAntenna:-4} +RxAntenna=${RxAntenna:-2};${RxAntenna:-2};${RxAntenna:-4};${RxAntenna:-4} TxPreamble=1 RTSThreshold=${rts:-2347} FragThreshold=${frag:-2346} @@ -677,8 +688,8 @@ VHT_STBC=${tx_stbc:-1} VHT_BW_SIGNAL=0 VHT_DisallowNonVHT=${VHT_DisallowNonVHT:-0} VHT_LDPC=${ldpc:-1} -#HT_TxStream=2 -#HT_RxStream=2 +HT_TxStream=2;2;2;2 +HT_RxStream=2;2;2;2 HT_PROTECT=0 HT_DisallowTKIP=${HT_DisallowTKIP:-0} HT_BSSCoexistence=${HT_CE:-1} diff --git a/package/lean/mt/drivers/mt7615d/src/mt_wifi/os/linux/rt_linux.c b/package/lean/mt/drivers/mt7615d/src/mt_wifi/os/linux/rt_linux.c index 871a45b2e..90a599639 100644 --- a/package/lean/mt/drivers/mt7615d/src/mt_wifi/os/linux/rt_linux.c +++ b/package/lean/mt/drivers/mt7615d/src/mt_wifi/os/linux/rt_linux.c @@ -865,6 +865,7 @@ static inline void __RtmpOSFSInfoChange(OS_FS_INFO *pOSFSInfo, BOOLEAN bSet) /* pOSFSInfo->fsgid = (int)(current_fsgid()); */ #endif #endif +#if 0 pOSFSInfo->fs = get_fs(); set_fs(KERNEL_DS); } else { @@ -872,6 +873,7 @@ static inline void __RtmpOSFSInfoChange(OS_FS_INFO *pOSFSInfo, BOOLEAN bSet) #if (KERNEL_VERSION(2, 6, 29) > LINUX_VERSION_CODE) current->fsuid = pOSFSInfo->fsuid; current->fsgid = pOSFSInfo->fsgid; +#endif #endif } } @@ -1925,8 +1927,10 @@ VOID RtmpDrvAllMacPrint( if (!msg) return; +#if 0 orig_fs = get_fs(); set_fs(KERNEL_DS); +#endif /* open file */ file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0); @@ -1968,7 +1972,9 @@ VOID RtmpDrvAllMacPrint( filp_close(file_w, NULL); } +#if 0 set_fs(orig_fs); +#endif os_free_mem(msg); } @@ -1991,8 +1997,10 @@ VOID RtmpDrvAllE2PPrint( if (!msg) return; +#if 0 orig_fs = get_fs(); set_fs(KERNEL_DS); +#endif /* open file */ file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0); @@ -2035,7 +2043,9 @@ VOID RtmpDrvAllE2PPrint( filp_close(file_w, NULL); } +#if 0 set_fs(orig_fs); +#endif os_free_mem(msg); } @@ -2049,8 +2059,10 @@ VOID RtmpDrvAllRFPrint( RTMP_STRING *fileName = "RFDump.txt"; mm_segment_t orig_fs; +#if 0 orig_fs = get_fs(); set_fs(KERNEL_DS); +#endif /* open file */ file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0); @@ -2081,7 +2093,9 @@ VOID RtmpDrvAllRFPrint( filp_close(file_w, NULL); } +#if 0 set_fs(orig_fs); +#endif } diff --git a/package/lean/mt/mtkiappd/Makefile b/package/lean/mt/mtkiappd/Makefile new file mode 100644 index 000000000..eb26558ec --- /dev/null +++ b/package/lean/mt/mtkiappd/Makefile @@ -0,0 +1,56 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mtkiappd +PKG_VERSION:=1 +PKG_RELEASE:=1 + +PKG_CONFIG_DEPENDS := \ + CONFIG_MTK_CHIP_MT7615E_DBDC \ + CONFIG_PACKAGE_mtkiappd_DUAL_BAND + +include $(INCLUDE_DIR)/package.mk + +define Package/mtkiappd + SECTION:=net + CATEGORY:=Network + TITLE:=MTK 802.11f supporting daemon + DEPENDS:=@TARGET_ramips + SUBMENU:=Wireless +endef + +define Package/mtkiappd/description + Mtkiappd is an optional user space component for MT76xx SoftAP driver. +endef + +define Package/mtkiappd/config +config PACKAGE_mtkiappd_DUAL_BAND + bool "dual band" + depends on MTK_CHIP_MT7615E + default y if TARGET_ramips_mt7621_DEVICE_phicomm_k2p + default y if TARGET_ramips_mt7621_DEVICE_raisecom_msg1500-x-00 + default n +endef + +ifeq ($(CONFIG_PACKAGE_mtkiappd_DUAL_BAND),y) + WIRELESS_IOCTL_PARAM:=-wi ra0 -wi rax0 +else + WIRELESS_IOCTL_PARAM:=-wi ra0 +endif + +define Package/mtkiappd/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/usr/share/mtkiappd + + $(INSTALL_BIN) $(PKG_BUILD_DIR)/mtkiappd $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/mtkiappd.sh $(1)/etc/init.d/mtkiappd + sed -i 's/WIRELESS_IOCTL_PARAM/$(WIRELESS_IOCTL_PARAM)/' $(1)/etc/init.d/mtkiappd + $(INSTALL_DATA) ./files/firewall.include $(1)/usr/share/mtkiappd/ +endef + +$(eval $(call BuildPackage,mtkiappd)) diff --git a/package/lean/mt/mtkiappd/files/README b/package/lean/mt/mtkiappd/files/README new file mode 100644 index 000000000..4f2cce308 --- /dev/null +++ b/package/lean/mt/mtkiappd/files/README @@ -0,0 +1,49 @@ +mtkiappd - user space daemon supported 802.11f protocol + for RTxxxx a/b/g/n SoftAP driver, Ralink Technology, Corp. +================================================================= + +This is the README file for the 802.11f/802.11r/802.11k daemon - mtkiappd, +which comes with RTxxxx SoftAP driver. + + +I. Introduction +================================================================= +mtkiappd is an optional user space component for RTxxxx SoftAP driver. + + +II. 802.11f features in mtkiappd +================================================================= +IEEE Std 802.11F-2003 is a standard for inter-access point protocol(IAPP). +It can handle issues on multi-verder access point interoperability. + +There are three major topics which 802.11f supported, +1. ADD-notify +2. MOVE-notify +3. CACHE-notify + +mtkiappd only supports ADD-notify in current phase due to lack of support from radius server + +There are three major topics which 802.11r supported, +1. Key Distribution Protocol + +There are three major topics which 802.11k supported, +1. Neighbor Report + +Some ethernet card needs special configuration to support multicasting. +Make sure your ethernet card support multicasting + + +III. How to start mtkiappd +================================================================= +Note: the broadcast/netmask address of all AP must be the same. +1. If you want to debug mtkiappd, add CFLAGS with DBG. +2. If you want to extend wifi control interface, + modify "MAX_WIFI_COUNT" in rtmpiapp.h. (default setting is 2) +3. First we need to compile the source code using 'make' command +4. Load RTxxxx SoftAP driver - ex: rt2860ap.ko +5. Manually start mtkiappd, type $mtkiappd +6. For wifi multi-interface, type $mtkiappd -wi ra0 -wi rai0 + + +IV. Reference +IEEE Std 802.11F-2003, IEEE802.11r, IEEE802.11k \ No newline at end of file diff --git a/package/lean/mt/mtkiappd/files/firewall.include b/package/lean/mt/mtkiappd/files/firewall.include new file mode 100644 index 000000000..dd5d387c6 --- /dev/null +++ b/package/lean/mt/mtkiappd/files/firewall.include @@ -0,0 +1,2 @@ +-A INPUT -i br-lan -p tcp --dport 3517 -j ACCEPT +-A INPUT -i br-lan -p udp --dport 3517 -j ACCEPT diff --git a/package/lean/mt/mtkiappd/files/mtkiappd.defaults b/package/lean/mt/mtkiappd/files/mtkiappd.defaults new file mode 100644 index 000000000..183a87133 --- /dev/null +++ b/package/lean/mt/mtkiappd/files/mtkiappd.defaults @@ -0,0 +1,12 @@ +#!/bin/sh + +uci -q batch <<-EOT + delete firewall.mtkiappd + set firewall.mtkiappd=include + set firewall.mtkiappd.type=restore + set firewall.mtkiappd.path=/usr/share/mtkiappd/firewall.include + set firewall.mtkiappd.reload=1 + commit firewall +EOT + +exit 0 diff --git a/package/lean/mt/mtkiappd/files/mtkiappd.sh b/package/lean/mt/mtkiappd/files/mtkiappd.sh new file mode 100644 index 000000000..8c553bdf2 --- /dev/null +++ b/package/lean/mt/mtkiappd/files/mtkiappd.sh @@ -0,0 +1,20 @@ +#!/bin/sh /etc/rc.common + +START=99 +STOP=01 + +USE_PROCD=1 + +start_service() { + procd_open_instance mtkiappd + procd_set_param command /usr/sbin/mtkiappd -e br-lan WIRELESS_IOCTL_PARAM + procd_set_param respawn + procd_set_param netdev br-lan + procd_set_param netdev ra0 + procd_close_instance +} + +reload_service() { + stop + start +} diff --git a/package/lean/mt/mtkiappd/src/Makefile b/package/lean/mt/mtkiappd/src/Makefile new file mode 100644 index 000000000..35cea3e25 --- /dev/null +++ b/package/lean/mt/mtkiappd/src/Makefile @@ -0,0 +1,10 @@ +OBJS = rtmpiapp.o mt_iapp_util.o + +# If you want to debug daemon, uncomment following line +# CFLAGS += -ggdb3 -DDBG + +mtkiappd: $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) + +clean: + rm -f core *.o mtkiappd diff --git a/package/lean/mt/mtkiappd/src/iappdefs.h b/package/lean/mt/mtkiappd/src/iappdefs.h new file mode 100644 index 000000000..03a519502 --- /dev/null +++ b/package/lean/mt/mtkiappd/src/iappdefs.h @@ -0,0 +1,128 @@ +/**************************************************************************** + * Ralink Tech Inc. + * Taiwan, R.O.C. + * + * (c) Copyright 2002, Ralink Technology, Inc. + * + * All rights reserved. Ralink's source code is an unpublished work and the + * use of a copyright notice does not imply otherwise. This source code + * contains confidential trade secret material of Ralink Tech. Any attemp + * or participation in deciphering, decoding, reverse engineering or in any + * way altering the source code is stricitly prohibited, unless the prior + * written consent of Ralink Technology, Inc. is obtained. + ***************************************************************************/ + +/**************************************************************************** + + Abstract: + + All related IEEE802.11f IAPP + IEEE802.11r IAPP extension. + +***************************************************************************/ + +#ifndef __IAPP_DEF_H__ +#define __IAPP_DEF_H__ + +/* Some Notes */ + +#define IAPP_DS_LINK_LOST +/* + When an AP continues to accept associations without a link to the DS, + it is a black hole in the WLAN, where STAs associate and cannot + communicate with anything beyond the AP’s BSS. When an AP loses its link + to the DS, it should cease transmitting Beacons, disassociate all + associated stations, and cease responding to Probe Request, + Authentication, and Association Request frames. +*/ + +/* Local use file */ +#define PROC_NET_ARP_PATH "/proc/net/arp" +#define IAPP_PID_BACKUP_FILE "/var/run/mtkiappd.pid" + +/* Definition of IAPP */ +#define IAPP_DAEMON_VERSION "v1.1.0" +#define IAPP_VERSION 0 +//#define IAPP_MULTICAST_ADDR "224.0.1.178" /* used in +// ADD-req frame*/ #define IAPP_MULTICAST_ADDR +//"192.168.15.255" /* used in ADD-req frame*/ + +/* + The UDP Port parameter is the UDP port number to be opened for the IAPP + for transmission and reception of IAPP packets. +*/ +#define IAPP_UDP_PORT 3517 /* used in UDP connection */ + +/* + The TCP Port parameter is the TCP port number that the IAPP entity opens + to listen for new IAPP TCP connections from the IAPP entities of other + APs. +*/ +#define IAPP_TCP_PORT 3517 /* used in TCP connection */ + +/* Message type */ +#define IAPP_ETH_PRO 0xEEEE +#define IAPPMSGQUEID 1 +#define RADIUSMSGQUEID 2 +#define RRB_ETH_PRO 0x890D + +/* Message subtype */ +#define IAPP_OPEN_SERVICE_REQ 0 +#define IAPP_OPEN_SERVICE_RSP 1 +#define IAPP_CLOSE_SERVICE_REQ 2 +#define IAPP_SIGNAL_REQ 3 +#define IAPP_SET_OID_REQ 4 +#define IAPP_QUERY_OID_REQ 5 +#define IAPP_QUERY_OID_RSP 6 + +/* Definition of signal */ +#define IAPP_SIG_NONE 0 +#define IAPP_SIG_ASSOCIATION 1 +#define IAPP_SIG_REASSOCIATION 2 +#define IAPP_SIG_TERMINATE 3 + +/* Definition of IAPP command */ /* reference to IEEE802.11f page 50 */ +#define IAPP_CMD_ADD_NOTIFY 0 /* ADD-notify */ +#define IAPP_CMD_MOVE_NOTIFY 1 /* MOVE-notify */ +#define IAPP_CMD_MOVE_RESPONSE 2 /* MOVE-response */ +#define IAPP_CMD_SEND_SECURITY_BLOCK 3 /* Send-Security-Block */ +#define IAPP_CMD_ACK_SECURITY_BLOCK 4 /* ACK-Security-Block */ +#define IAPP_CMD_CACHE_NOTIFY 5 /* CACHE-notify */ +#define IAPP_CMD_CACHE_RESPONSE 6 /* CACHE-response */ + +#define IAPP_CMD_FT_SEND_SECURITY_BLOCK \ + 50 /* proprietary FT Send-Security-Block */ +#define IAPP_CMD_FT_ACK_SECURITY_BLOCK \ + 51 /* proprietary FT ACK-Security-Block */ + +#define IAPP_CMD_INFO_BROADCAST 60 /* proprietary INFO broadcast */ +#define IAPP_CMD_INFO_REQUEST 61 /* proprietary INFO request */ +#define IAPP_CMD_INFO_RESPONSE 62 /* proprietary INFO response */ + +#define IAPP_CMD_SECURITY_MONITOR 128 /* proprietary, for SM broadcast */ + +/* Definition of event log */ +#define IAPP_MAX_SIZE_OF_EVENT_LOG 1024 + +/* Definition of general */ +#define IAPP_SELECT_TIMEOUT 5 /* unit: second */ + +#define IAPP_MAX_RCV_PKT_SIZE 1600 +#define IAPP_MAX_RCV_PKT_SIZE_SAFE 100 + +#define IAPP_IP_HEADER_OFFSET 14 /* skip MAC header */ +#define IAPP_IP_PROTO_OFFSET 9 +#define IAPP_IP_PROTO_UDP 17 +#define IAPP_UDP_DST_PORT_OFFSET (20 + 2) + +#define IAPP_MAC_IP_UDP_LEN (14 + 20 + 8) + +/* 16 for extra 8B encryption & 8B-align, other 16B for safe */ +#define IAPP_SECURITY_EXTEND_LEN 32 + +#define IAPP_IN +#define IAPP_OUT +#define IAPP_INOUT + +#endif /* __IAPP_DEF_H__ */ + +/* End of iapp_def.h */ diff --git a/package/lean/mt/mtkiappd/src/mt_iapp_util.c b/package/lean/mt/mtkiappd/src/mt_iapp_util.c new file mode 100644 index 000000000..dc5e4b5e2 --- /dev/null +++ b/package/lean/mt/mtkiappd/src/mt_iapp_util.c @@ -0,0 +1,234 @@ +/**************************************************************************** + * Ralink Tech Inc. + * Taiwan, R.O.C. + * + * (c) Copyright 2002, Ralink Technology, Inc. + * + * All rights reserved. Ralink's source code is an unpublished work and the + * use of a copyright notice does not imply otherwise. This source code + * contains confidential trade secret material of Ralink Tech. Any attemp + * or participation in deciphering, decoding, reverse engineering or in any + * way altering the source code is stricitly prohibited, unless the prior + * written consent of Ralink Technology, Inc. is obtained. + ***************************************************************************/ + +/**************************************************************************** + + Abstract: + + All related IEEE802.11f IAPP + IEEE802.11r/11k IAPP extension. + +***************************************************************************/ + +/* Include */ + +#include "iappdefs.h" +#include "rt_config.h" +#include "rt_typedef.h" +#include "rtmpiapp.h" + +VOID os_alloc_mem(UCHAR *pAd, UCHAR **ppMem, UINT32 Size) { + *ppMem = (UCHAR *)malloc(Size); +} + +VOID os_free_mem(UCHAR *pAd, VOID *pMem) { free(pMem); } + +BOOLEAN mt_iapp_get_wifi_iface_mac(RTMP_IAPP *pCtrlBK) { +#ifdef IAPP_OS_LINUX + INT idx; + for (idx = 0; idx < pCtrlBK->IfNameWlanCount; idx++) { + struct ifreq ReqIf; + + NdisZeroMemory(pCtrlBK->IfNameWlanMAC[idx], ETH_ALEN); + NdisCopyMemory(ReqIf.ifr_name, pCtrlBK->IfNameWlanIoctl[idx], IFNAMSIZ); + /* get mac address of the interface */ + if (ioctl(pCtrlBK->SocketIoctl, SIOCGIFHWADDR, &ReqIf) < 0) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> %s - Fail to get MAC of IfName[%d]: %s\n", __FUNCTION__, + idx, pCtrlBK->IfNameWlanIoctl[idx])); + return FALSE; + } else { + NdisCopyMemory(pCtrlBK->IfNameWlanMAC[idx], + &ReqIf.ifr_ifru.ifru_hwaddr.sa_data[0], ETH_ALEN); + DBGPRINT(RT_DEBUG_OFF, ("iapp> %s - IfName[%d]: %s\n", __FUNCTION__, idx, + pCtrlBK->IfNameWlanIoctl[idx])); + IAPP_HEX_DUMP("MAC", pCtrlBK->IfNameWlanMAC[idx], ETH_ALEN); + } + } + return TRUE; +#else + return FALSE; +#endif +} + +INT32 mt_iapp_find_ifidx_by_mac(RTMP_IAPP *pCtrlBK, UCHAR *WifiMAC) { + INT32 idx = 0; + + if (WifiMAC == NULL) { + DBGPRINT(RT_DEBUG_OFF, ("iapp> %s - WifiMAC is null.\n", __FUNCTION__)); + return -1; + } + + if (pCtrlBK->IfNameWlanCount < MAX_WIFI_COUNT) { + DBGPRINT(RT_DEBUG_OFF, + ("iapp> %s - pCtrlBK->IfNameWlanCount (%d) is less than %d.\n", + __FUNCTION__, pCtrlBK->IfNameWlanCount, MAX_WIFI_COUNT)); + } + + for (idx = 0; idx < MAX_WIFI_COUNT; idx++) { + if (NdisCompareMemory(WifiMAC, pCtrlBK->IfNameWlanMAC[idx], ETH_ALEN) == + 0) { + return idx; + } + } + + return -1; +} + +VOID mt_iapp_set_daemon_information(RTMP_IAPP *pCtrlBK, pid_t *pPidAuth) { + INT32 ComLen = 0; + INT32 idx = 0; + + for (idx = 0; idx < pCtrlBK->IfNameWlanCount; idx++) { + ComLen = sizeof(INT32); + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pPidAuth, &ComLen, idx, + RT_SET_IAPP_PID | OID_GET_SET_TOGGLE); +#ifdef FT_KDP_KEY_FROM_DAEMON + ComLen = strlen(pCtrlBK->CommonKey); + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pCtrlBK->CommonKey, &ComLen, idx, + RT_FT_KEY_SET | OID_GET_SET_TOGGLE); +#endif /* FT_KDP_KEY_FROM_DAEMON */ + } + return; +} + +VOID mt_iapp_ft_client_table_init(RTMP_IAPP *pCtrlBK) { + INT i; + NdisZeroMemory(&pCtrlBK->SelfFtStaTable, sizeof(pCtrlBK->SelfFtStaTable)); + for (i = 0; i < HASH_TABLE_SIZE; i++) + pCtrlBK->SelfFtStaTable.hash[i] = NULL; + return; +} + +FT_CLIENT_INFO *mt_iapp_ft_client_look_up(FT_CLIENT_TABLE *pFtTable, + UCHAR *pAddr) { + ULONG HashIdx; + FT_CLIENT_INFO *ft_entry = NULL; + + HashIdx = MAC_ADDR_HASH_INDEX(pAddr); + ft_entry = pFtTable->hash[HashIdx]; + + while (ft_entry) { + if (NdisCompareMemory(ft_entry->sta_mac, pAddr, ETH_ALEN) == 0) + break; + else + ft_entry = ft_entry->next; + } + + return ft_entry; +} + +FT_CLIENT_INFO *mt_iapp_ft_client_insert(FT_CLIENT_TABLE *pFtTable, + UCHAR *pStaAddr, UCHAR *pApAddr, + INT32 ApIfIdx) { + UCHAR HashIdx; + INT idx = 0; + FT_CLIENT_INFO *ft_entry = NULL; + FT_CLIENT_INFO *current_ft_entry = NULL; + + ft_entry = mt_iapp_ft_client_look_up(pFtTable, pStaAddr); + if (ft_entry) { + /* Update information */ + if (pApAddr) + NdisCopyMemory(ft_entry->ap_mac, pApAddr, ETH_ALEN); + ft_entry->if_idx = ApIfIdx; + ft_entry->used = 1; + return ft_entry; + } + + if (pFtTable->ft_sta_table_size >= MAX_NUM_OF_CLIENT) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> %s - FT client table is full. (FtStaTableSize=%d)\n", + __FUNCTION__, pFtTable->ft_sta_table_size)); + return NULL; + } + + for (idx = 0; idx < MAX_NUM_OF_CLIENT; idx++) { + ft_entry = &pFtTable->ft_sta_info[idx]; + if (ft_entry->used) + continue; + if (pStaAddr) + NdisCopyMemory(ft_entry->sta_mac, pStaAddr, ETH_ALEN); + if (pApAddr) + NdisCopyMemory(ft_entry->ap_mac, pApAddr, ETH_ALEN); + ft_entry->if_idx = ApIfIdx; + ft_entry->used = 1; + break; + } + pFtTable->ft_sta_table_size++; + + HashIdx = MAC_ADDR_HASH_INDEX(pStaAddr); + ft_entry->hash_idx = HashIdx; + if (pFtTable->hash[HashIdx] == NULL) + pFtTable->hash[HashIdx] = ft_entry; + else { + current_ft_entry = pFtTable->hash[HashIdx]; + while (current_ft_entry->next != NULL) + current_ft_entry = current_ft_entry->next; + current_ft_entry->next = ft_entry; + } + return ft_entry; +} + +VOID mt_iapp_ft_client_delete(FT_CLIENT_TABLE *pFtTable, UCHAR *pStaAddr) { + UCHAR HashIdx = 0xFF; + FT_CLIENT_INFO *ft_entry = NULL; + FT_CLIENT_INFO *hash_ft_entry = NULL; + FT_CLIENT_INFO *pre_hash_ft_entry = NULL; + + ft_entry = mt_iapp_ft_client_look_up(pFtTable, pStaAddr); + + if (ft_entry == NULL) { + DBGPRINT( + RT_DEBUG_TRACE, + ("iapp> %s - cannot find this entry (%02x:%02x:%02x:%02x:%02x:%02x)\n", + __FUNCTION__, pStaAddr[0], pStaAddr[1], pStaAddr[2], pStaAddr[3], + pStaAddr[4], pStaAddr[5])); + return; + } + + ft_entry->used = 0; + NdisZeroMemory(ft_entry->ap_mac, ETH_ALEN); + NdisZeroMemory(ft_entry->sta_mac, ETH_ALEN); + ft_entry->if_idx = -1; + + HashIdx = ft_entry->hash_idx; + hash_ft_entry = pFtTable->hash[HashIdx]; + pre_hash_ft_entry = NULL; + if (hash_ft_entry != NULL) { + /* update Hash list*/ + do { + if (hash_ft_entry == ft_entry) { + if (pre_hash_ft_entry == NULL) + pFtTable->hash[HashIdx] = ft_entry->next; + else + pre_hash_ft_entry->next = ft_entry->next; + break; + } + + pre_hash_ft_entry = hash_ft_entry; + hash_ft_entry = hash_ft_entry->next; + } while (hash_ft_entry); + } + pFtTable->ft_sta_table_size--; +} + +INT32 mt_iapp_find_ifidx_by_sta_mac(FT_CLIENT_TABLE *pFtTable, UCHAR *pStaMAC) { + FT_CLIENT_INFO *ft_entry = NULL; + ft_entry = mt_iapp_ft_client_look_up(pFtTable, pStaMAC); + if (ft_entry) + return ft_entry->if_idx; + else + return -1; +} +/* End of mt_iapp_util.c */ diff --git a/package/lean/mt/mtkiappd/src/rt_config.h b/package/lean/mt/mtkiappd/src/rt_config.h new file mode 100644 index 000000000..b6e3fdc19 --- /dev/null +++ b/package/lean/mt/mtkiappd/src/rt_config.h @@ -0,0 +1,187 @@ +/**************************************************************************** + * Ralink Tech Inc. + * Taiwan, R.O.C. + * + * (c) Copyright 2002, Ralink Technology, Inc. + * + * All rights reserved. Ralink's source code is an unpublished work and the + * use of a copyright notice does not imply otherwise. This source code + * contains confidential trade secret material of Ralink Tech. Any attemp + * or participation in deciphering, decoding, reverse engineering or in any + * way altering the source code is stricitly prohibited, unless the prior + * written consent of Ralink Technology, Inc. is obtained. + ***************************************************************************/ + +/**************************************************************************** + + Abstract: + + All related IEEE802.11f IAPP + IEEE802.11r IAPP extension. + +***************************************************************************/ + +#ifndef __RT_CONFIG_H__ +#define __RT_CONFIG_H__ + +/* Include Kernel file */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "rt_typedef.h" + +/* Definition of OID to RALINK AP driver */ +#define OID_GET_SET_TOGGLE 0x8000 +#define RT_QUERY_SIGNAL_CONTEXT 0x0402 +#define RT_SET_IAPP_PID 0x0404 +#define RT_SET_APD_PID 0x0405 +#define RT_SET_DEL_MAC_ENTRY 0x0406 +#define RT_QUERY_EVENT_TABLE 0x0407 + +#define RT_SET_FT_STATION_NOTIFY 0x0408 +#define RT_SET_FT_KEY_REQ 0x0409 +#define RT_SET_FT_KEY_RSP 0x040a + +#define RT_FT_KEY_SET 0x040b +#define RT_FT_DATA_ENCRYPT 0x040c +#define RT_FT_DATA_DECRYPT 0x040d +#define RT_FT_NEIGHBOR_REPORT 0x040e +#define RT_FT_NEIGHBOR_REQUEST 0x040f +#define RT_FT_NEIGHBOR_RESPONSE 0x0410 +#define RT_FT_ACTION_FORWARD 0x0411 + +/* File path */ +// #define MSG_FILE "/etc/wireless/mt7615/mtkiappd.dat" +#define EVENT_LOG_FILE "/var/log/mtkiappd.log" + +/* ReDefinition */ +#define NdisZeroMemory(__Dst, __Len) memset(__Dst, 0, __Len) +#define NdisFillMemory(__Dst, __Len, __Val) memset(__Dst, __Val, __Len) +#define NdisMoveMemory(__Dst, __Src, __Len) memmove(__Dst, __Src, __Len) +#define NdisCopyMemory(__Dst, __Src, __Len) memcpy(__Dst, __Src, __Len) +#define NdisCompareMemory(__Dst, __Src, __Len) memcmp(__Dst, __Src, __Len) + +VOID os_alloc_mem(UCHAR *pAd, UCHAR **ppMem, UINT32 Size); +VOID os_free_mem(UCHAR *pAd, VOID *pMem); + +/* Debug flag */ +#define RT_DEBUG_OFF 0 +#define RT_DEBUG_ERROR 1 +#define RT_DEBUG_WARN 2 +#define RT_DEBUG_TRACE 3 +#define RT_DEBUG_INFO 4 + +#define NIC_DBG_STRING (" ") + +#ifdef DBG +#define DBGPRINT(Level, Fmt) \ + { \ + if (Level <= RTDebugLevel) { \ + printf Fmt; \ + } \ + } +#else + +/* no debug information */ +#define DBGPRINT(Level, Fmt) +#endif + +#define MAX_NUM_OF_EVENT 30 /* entry # in EVENT table */ + +typedef struct _RT_802_11_EVENT_LOG { + + ULONG SystemTime; /* timestammp (jiffies) */ + UCHAR TriggerAddr[ETH_ALEN]; + UCHAR DetectorAddr[ETH_ALEN]; + UINT16 Event; /* EVENT_xxx */ +} RT_802_11_EVENT_LOG, *PRT_802_11_EVENT_LOG; + +typedef struct _RT_802_11_EVENT_TABLE { + + ULONG Num; + RT_802_11_EVENT_LOG Log[MAX_NUM_OF_EVENT]; +} RT_802_11_EVENT_TABLE, *PRT_802_11_EVENT_TABLE; + +#define PACKED __attribute__((packed)) + +typedef struct PACKED _FT_KDP_EVT_HEADER { + + UINT32 EventLen; + UINT32 PeerIpAddr; + +} FT_KDP_EVT_HEADER; + +typedef struct PACKED _RT_SIGNAL_STRUC { + + VOID *pNext; /* point to next signal */ + + UINT16 Sequence; + UCHAR MacAddr[ETH_ALEN]; + UCHAR CurrAPAddr[ETH_ALEN]; + +#define FT_KDP_SIG_NOTHING 0x00 /* no signal */ +#define FT_KDP_SIG_IAPP_ASSOCIATION 0x01 /* A station has associated */ +#define FT_KDP_SIG_IAPP_REASSOCIATION 0x02 /* A station has re-associated */ +#define FT_KDP_SIG_TERMINATE 0x03 /* terminate the daemon */ + +#define FT_KDP_SIG_FT_ASSOCIATION 0x50 /* A FT station has associated */ +#define FT_KDP_SIG_FT_REASSOCIATION 0x51 /* A FT station has re-associated */ +#define FT_KDP_SIG_KEY_TIMEOUT 0x52 /* PMK-R1 KEY Timeout */ +#define FT_KDP_SIG_KEY_REQ 0x53 /* Request PMK-R1 KEY from R0KH */ +#define FT_KDP_SIG_ACTION 0x54 /* Forward FT Action frame to DS */ + +#define FT_KDP_SIG_AP_INFO_REQ 0x70 /* request neighbor AP info. */ +#define FT_KDP_SIG_AP_INFO_RSP 0x71 /* response my AP info. */ + +/* FT KDP internal use */ +#define FT_KDP_SIG_KEY_REQ_AUTO 0xA0 /* Request PMK-R1 KEY from R0KH */ +#define FT_KDP_SIG_KEY_RSP_AUTO 0xA1 /* Response PMK-R1 KEY to R1KH */ +#define FT_KDP_SIG_INFO_BROADCAST 0xB0 /* broadcast our AP information */ + +#define FT_KSP_SIG_DEBUG_TRACE 0xC0 /* enable debug flag to TRACE */ + UCHAR Sig; + + UCHAR MacAddrSa[ETH_ALEN]; + + /* IEEE80211R_SUPPORT */ + /* the first 6B are FT_KDP_EVT_HEADER */ + /* + For FT_KDP_SIG_NOTHING: nothing + For FT_KDP_SIG_IAPP_ASSOCIATION:nothing + For FT_KDP_SIG_REASSOCIATION: nothing + For FT_KDP_SIG_TERMINATE: nothing + For FT_KDP_SIG_FT_ASSOCIATION: nothing + FT_KDP_SIG_FT_REASSOCIATION: nothing + For FT_KDP_SIG_KEY_TIMEOUT: it is + For FT_KDP_SIG_KEY_REQ_AUTO: it is FT_KDP_EVT_KEY_REQ + For FT_KDP_SIG_KEY_RSP_AUTO: it is FT_KDP_SIG_KEY_RSP + */ + UCHAR Reserved[3]; /* let Content address four-byte align */ + UCHAR Content[1024]; /* signal content */ + +#define RT_SIGNAL_STRUC_HDR_SIZE (sizeof(RT_SIGNAL_STRUC) - 1024) +} RT_SIGNAL_STRUC, *PRT_SIGNAL_STRUC; + +static INT32 RTDebugLevel = RT_DEBUG_ERROR; + +#endif /* __RT_CONFIG_H__ */ + +/* End of rt_config.h */ diff --git a/package/lean/mt/mtkiappd/src/rt_typedef.h b/package/lean/mt/mtkiappd/src/rt_typedef.h new file mode 100644 index 000000000..e23e035b6 --- /dev/null +++ b/package/lean/mt/mtkiappd/src/rt_typedef.h @@ -0,0 +1,22 @@ +#ifndef __RT_TYPEDEF_H__ +#define __RT_TYPEDEF_H__ + +#include + +typedef enum _BOOLEAN { FALSE = 0, TRUE = 1 } BOOLEAN; + +typedef char CHAR; +typedef int INT; + +typedef int INT32; +typedef int16_t INT16; +typedef uint8_t UCHAR; +typedef uint16_t UINT16; +typedef uint32_t UINT; +typedef uint32_t ULONG; +typedef uint32_t UINT32; + +typedef void VOID; +typedef void *PVOID; + +#endif diff --git a/package/lean/mt/mtkiappd/src/rtmpiapp.c b/package/lean/mt/mtkiappd/src/rtmpiapp.c new file mode 100644 index 000000000..b676c49e9 --- /dev/null +++ b/package/lean/mt/mtkiappd/src/rtmpiapp.c @@ -0,0 +1,3946 @@ +/**************************************************************************** + * Ralink Tech Inc. + * Taiwan, R.O.C. + * + * (c) Copyright 2002, Ralink Technology, Inc. + * + * All rights reserved. Ralink's source code is an unpublished work and the + * use of a copyright notice does not imply otherwise. This source code + * contains confidential trade secret material of Ralink Tech. Any attemp + * or participation in deciphering, decoding, reverse engineering or in any + * way altering the source code is stricitly prohibited, unless the prior + * written consent of Ralink Technology, Inc. is obtained. + ***************************************************************************/ + +/**************************************************************************** + + Abstract: + + All related IEEE802.11f IAPP + IEEE802.11r/11k IAPP extension. + +***************************************************************************/ + +//#define IAPP_EVENT_LOG +//#define IAPP_TEST + +/* Include */ +#include "rtmpiapp.h" +#include "iappdefs.h" +#include "rt_config.h" +#include "rt_typedef.h" + +/* Local Variable */ +#define IAPP_SHOW_IP_HTONL(__IP) \ + (htonl(__IP) >> 24) & 0xFF, (htonl(__IP) >> 16) & 0xFF, \ + (htonl(__IP) >> 8) & 0xFF, (htonl(__IP) & 0xFF) + +#define IAPP_SHOW_IP(__IP) \ + (__IP) & 0xFF, ((__IP) >> 8) & 0xFF, ((__IP) >> 16) & 0xFF, \ + ((__IP) >> 24) & 0xFF + +#define IAPP_IDENTIFIER_GET(__CB) (__CB)->PacketIdentifier++ + +#define IAPP_CMD_BUF_ALLOCATE(__pCmdBuf, __pBufMsg, __BufLen) \ + { \ + if ((__BufLen) > IAPP_MAX_RCV_PKT_SIZE) { \ + printf("iapp> Command Length is too large!\n"); \ + __pBufMsg = NULL; \ + } else \ + __pBufMsg = __pCmdBuf; \ + } + +#define IAPP_RSP_BUF_ALLOCATE(__pRspBuf, __pBufMsg, __BufLen) \ + { \ + if ((__BufLen) > IAPP_MAX_RCV_PKT_SIZE) { \ + printf("iapp> Response Length is too large!\n"); \ + __pBufMsg = NULL; \ + } else \ + __pBufMsg = __pRspBuf; \ + } + +static RTMP_IAPP IAPP_Ctrl_Block; +static UINT32 IAPP_MemAllocNum, IAPP_MemFreeNum; + +/* Local Function */ +#ifdef IAPP_EVENT_LOG +static BOOLEAN IAPP_EventLogClean(VOID); +static BOOLEAN IAPP_EventLogHandle(IAPP_IN PRT_802_11_EVENT_TABLE pEvtTab); +static VOID IAPP_EventLog_Query(VOID); +static VOID IAPP_SM_InfoHandle(IAPP_IN CHAR *pMsg); +#endif // IAPP_EVENT_LOG // + +#if 0 +static BOOLEAN IAPP_IP2MACTransfer( + IAPP_IN UCHAR *pMac, + IAPP_OUT struct in_addr *pApInfo); +#endif + +static BOOLEAN IAPP_ArgumentParse(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN INT32 Argc, IAPP_IN CHAR *pArgv[]); + +static BOOLEAN IAPP_DSIfInfoGet(IAPP_IN RTMP_IAPP *pCtrlBK); + +BOOLEAN IAPP_IoctlToWLAN(IAPP_IN RTMP_IAPP *pCtrlBK, IAPP_IN INT32 Param, + IAPP_IN CHAR *pData, IAPP_IN INT32 *pDataLen, + IAPP_IN UCHAR ApIdx, IAPP_IN INT32 Flags); +static INT32 IAPP_IPC_MSG_Init(IAPP_IN RTMP_IAPP *pCtrlBK); +static BOOLEAN IAPP_L2UpdateFrameSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pMac); + +static BOOLEAN IAPP_MsgProcess(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN INT32 MsgSubType, IAPP_IN UCHAR *pMsg, + IAPP_IN INT32 Len, IAPP_IN INT32 if_idx); + +static VOID IAPP_PID_Backup(IAPP_IN pid_t PID); +static VOID IAPP_PID_Kill(VOID); + +static BOOLEAN IAPP_SIG_Process(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *WiFiMAC, + IAPP_IN RT_SIGNAL_STRUC *pSig, + IAPP_IN INT32 Len, IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf); + +static BOOLEAN IAPP_SocketClose(IAPP_IN RTMP_IAPP *pCtrlBK); +static BOOLEAN IAPP_SocketOpen(IAPP_IN RTMP_IAPP *pCtrlBK); + +static VOID IAPP_Start(IAPP_IN RTMP_IAPP *pCtrlBK); + +#define IAPP_UDP_PACKET_SEND(__pCtrlBK, __pPkt, __Len, __pRspBuf, __IfIdx) \ + IAPP_UDP_PacketSend(__pCtrlBK, (UCHAR *)(__pPkt), (UINT32)(__Len), \ + __pRspBuf, __IfIdx) +static BOOLEAN IAPP_UDP_PacketSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPkt, IAPP_IN UINT32 PktLen, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx); + +#define IAPP_TCP_PACKET_SEND(__pCtrlBK, __pPkt, __Len, __PeerIP, __FlgUdp, \ + __pRspBuf, __IfIdx) \ + IAPP_TCP_PacketSend(__pCtrlBK, (UCHAR *)(__pPkt), (UINT32)(__Len), __PeerIP, \ + __FlgUdp, __pRspBuf, __IfIdx) +static BOOLEAN IAPP_TCP_PacketSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPkt, IAPP_IN UINT32 PktLen, + IAPP_IN UINT32 PeerIP, + IAPP_IN BOOLEAN FlgUsingUdpWhenNoIP, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx); + +static VOID IAPP_RcvHandler(IAPP_IN RTMP_IAPP *pCtrlBK, IAPP_IN INT32 Sig); + +#ifdef FT_KDP_FUNC_SOCK_COMM +static VOID IAPP_RcvHandlerRawDrv(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf); +static VOID IAPP_RcvHandlerRawRRB(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf); + +#ifdef IAPP_OS_VXWORKS +BOOLEAN IAPP_RcvHandlerRawDrvVxWorks(IAPP_IN VOID *pCookie, IAPP_IN long Type, + IAPP_IN M_BLK_ID pMblk, + IAPP_IN LL_HDR_INFO *pLinkHdrInfo, + IAPP_IN VOID *pSpare); +BOOLEAN IAPP_RcvHandlerRawRRBVxWorks(IAPP_IN VOID *pCookie, IAPP_IN long Type, + IAPP_IN M_BLK_ID pMblk, + IAPP_IN LL_HDR_INFO *pLinkHdrInfo, + IAPP_IN VOID *pSpare); +#endif // IAPP_OS_VXWORKS // +#endif // FT_KDP_FUNC_SOCK_COMM // + +static VOID IAPP_RcvHandlerUdp(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf); +static VOID IAPP_RcvHandlerTcp(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf); + +static VOID IAPP_RcvHandlerMoveReq(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, + IAPP_IN UINT32 PeerIP, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf); +static VOID IAPP_RcvHandlerSSB(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, IAPP_IN UINT32 PeerIP, + IAPP_IN UCHAR *pCmdBuf); +static VOID IAPP_RcvHandlerApInfor(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR Type, IAPP_IN UCHAR *pPktBuf, + IAPP_IN UINT32 PeerIP, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN INT32 if_idx); + +static VOID IAPP_Usage(VOID); +static VOID IAPP_USR2Handle(IAPP_IN INT32 Sig); +static VOID IAPP_TerminateHandle(IAPP_IN INT32 Sig); + +static VOID FT_KDP_SecurityBlockSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, IAPP_IN UCHAR *pRspBuf, + IAPP_IN UCHAR *WifiMAC, + IAPP_IN INT32 if_idx); +static VOID FT_KDP_SecurityBlockAck(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx); +static VOID FT_KDP_InformationRequestSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx); +static VOID FT_KDP_InformationResponseSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx); +static VOID FT_KDP_InformationReportSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx); +static VOID FT_RRB_ActionForward(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, IAPP_IN UINT16 PacketType, + IAPP_IN UCHAR *pMacDa, IAPP_IN UCHAR *pMacSa, + IAPP_IN UCHAR *pMacAp, IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx); + +/* ---------------------------- No Use Function (Backup Use) ---------------- */ + +#ifdef IAPP_EVENT_LOG +/* +======================================================================== +Routine Description: + Clean event log file content. + +Arguments: + None + +Return Value: + None + +Note: + EVENT_LOG_FILE = "/etc/Wireless/RT61AP/RT61APEvt.dat" +======================================================================== +*/ +static BOOLEAN IAPP_EventLogClean(VOID) { + FILE *pFile; + + /* re-open and truncate file to zero length by using "wb" */ + pFile = fopen(EVENT_LOG_FILE, "wb"); + + if (pFile == NULL) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> Open eventlog file %s failed!\n", EVENT_LOG_FILE)); + return FALSE; + } /* End of if */ + + fclose(pFile); + return TRUE; +} /* End of IAPP_EventLogClean */ + +/* +======================================================================== +Routine Description: + Write a list events to event log file. + +Arguments: + pEvtTab - event list + +Return Value: + TRUE - write successfully + FALSE - write fail + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_EventLogHandle(IAPP_IN PRT_802_11_EVENT_TABLE pEvtTab) { + FILE *pFile; + INT32 FileLen; + INT32 IdEvt; + + /* for append binary file format */ + pFile = fopen(EVENT_LOG_FILE, "ab"); + if (pFile == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open eventlog file failed!\n")); + return FALSE; + } /* End of if */ + + FileLen = ftell(pFile); + + if (FileLen > IAPP_MAX_SIZE_OF_EVENT_LOG) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> eventlog file size exceeds limitation(FileLen=%d)!\n", + FileLen)); + fclose(pFile); + return FALSE; + } /* End of if */ + + if (pEvtTab->Num > MAX_NUM_OF_EVENT) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> eventlog Num exceeds limitation(pEventTab->Num=%d)!\n", + pEvtTab->Num)); + fclose(pFile); + return FALSE; + } /* End of if */ + + for (IdEvt = 0; IdEvt < pEvtTab->Num; IdEvt++) { + if (fwrite(&pEvtTab->Log[IdEvt], sizeof(RT_802_11_EVENT_LOG), 1, pFile) != + 1) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> File write error!\n")); + } /* End of if */ + + DBGPRINT( + RT_DEBUG_TRACE, + ("iapp> (%d/%d): (Event=0x%x) (D:%02x:%02x:%02x:%02x:%02x:%02x) " + "(T:%02x:%02x:%02x:%02x:%02x:%02x)\n", + IdEvt, pEvtTab->Num, pEvtTab->Log[IdEvt].Event, + pEvtTab->Log[IdEvt].DetectorAddr[0], + pEvtTab->Log[IdEvt].DetectorAddr[1], + pEvtTab->Log[IdEvt].DetectorAddr[2], + pEvtTab->Log[IdEvt].DetectorAddr[3], + pEvtTab->Log[IdEvt].DetectorAddr[4], + pEvtTab->Log[IdEvt].DetectorAddr[5], + pEvtTab->Log[IdEvt].TriggerAddr[0], pEvtTab->Log[IdEvt].TriggerAddr[1], + pEvtTab->Log[IdEvt].TriggerAddr[2], pEvtTab->Log[IdEvt].TriggerAddr[3], + pEvtTab->Log[IdEvt].TriggerAddr[4], + pEvtTab->Log[IdEvt].TriggerAddr[5])); + } /* End of for */ + + fclose(pFile); + return TRUE; +} /* End of IAPP_EventLogHandle */ + +/* +======================================================================== +Routine Description: + Query event log content. + +Arguments: + *pCtrlBK - IAPP control block + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_EventLog_Query(IAPP_IN RTMP_IAPP *pCtrlBK) { + CHAR *pEvtBuf; + POID_REQ pOidReq; + + IAPP_MEM_ALLOC(pEvtBuf, sizeof(RT_802_11_EVENT_TABLE)); + if (pEvtBuf == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Out of memory!\n")); + return; + } /* End of if */ + + pOidReq = (POID_REQ)pEvtBuf; + pOidReq->OID = RT_QUERY_EVENT_TABLE; + pOidReq->Len = sizeof(RT_802_11_EVENT_TABLE); + + IAPP_MsgProcess(pCtrlBK, IAPP_QUERY_OID_REQ, pEvtBuf, + sizeof(RT_802_11_EVENT_TABLE)); + IAPP_MEM_FREE(pEvtBuf); +} /* End of IAPP_EventLog_Query */ + +/* +======================================================================== +Routine Description: + Send out private IAPP packet with security management information and + log current security management information to file. + +Arguments: + *pCtrlBK - IAPP control blcok + *pMsg - security management information + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_SM_InfoHandle(IAPP_IN RTMP_IAPP *pCtrlBK, IAPP_IN CHAR *pMsg) { + PRT_802_11_EVENT_TABLE pEvtTab; + POID_REQ OID_req_p; + INT32 PktLen; + + OID_req_p = (POID_REQ)pMsg; + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> (Receive IAPP_QUERY_OID_REQ)\n")); + + /* IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, + OID_req_p->Buf, &OID_req_p->Len, 0, OID_req_p->OID); */ + + pEvtTab = (PRT_802_11_EVENT_TABLE)OID_req_p->Buf; + + if (OID_req_p->OID == RT_QUERY_EVENT_TABLE) { + if ((OID_req_p->Len == sizeof(RT_802_11_EVENT_TABLE)) && + (pEvtTab->Num != 0)) { + RT_IAPP_SECURITY_MONITOR SM; + + /* just send valid Data, not whole structure */ + PktLen = sizeof(UINT32) + (pEvtTab->Num * sizeof(RT_802_11_EVENT_LOG)); + + SM.IappHeader.Version = 0; + SM.IappHeader.Command = IAPP_CMD_SECURITY_MONITOR; + + /* will be update before send out */ + SM.IappHeader.Identifier = 0; + SM.IappHeader.Length = SWAP_16(sizeof(RT_IAPP_HEADER) + PktLen); + IAPP_MEM_MOVE(&SM.EvtTab, OID_req_p->Buf, PktLen); + + /* send our events to all RALINK IAPP daemons in other AP */ + IAPP_UDP_PACKET_SEND(pCtrlBK, &SM, + (sizeof(RT_IAPP_HEADER) + PktLen, pRspBuf)); + + /* log our events */ + IAPP_EventLogHandle((PRT_802_11_EVENT_TABLE)OID_req_p->Buf); + } else { + DBGPRINT(RT_DEBUG_INFO, + ("iapp> RT_QUERY_EVENT_TABLE invalid or zero in length!\n")); + } /* End of if */ + } /* End of if */ +} /* End of IAPP_SM_InfoHandle */ +#endif // IAPP_EVENT_LOG // + +#if 0 /* no use */ +/* +======================================================================== +Routine Description: + Find the IP address by the AP MAC address. + +Arguments: + *pCtrlBK - IAPP control block + *pMac - the AP MAC address pointer + *pApInfo - the AP address information pointer + +Return Value: + TRUE - open IP/MAC mapping file successfully + FAIL - open fail + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_IP2MACTransfer( + IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pMac, + IAPP_OUT struct in_addr *pApInfo) +{ + FILE *Fd; + CHAR Buffer[200], Mask[32], DevName[32], Hwa[50], IP[50]; + INT32 Type, Flags, Num; + UCHAR AddrMac[ETH_ALEN]; + + + /* init */ + IAPP_MEM_MOVE(AddrMac, pMac, ETH_ALEN); + + /* + ping to broadcast address to get all neighboring AP MAC address/IP + address (bad method ??? use IARP or Radius Server or manual). + */ + sprintf(Buffer, "%s %d.%d.%d.%d %s %s %s %s", "ping", + IAPP_SHOW_IP_HTONL(pCtrlBK->AddrOwn.s_addr), + "-b", "-q", "-w", "2"); + system(Buffer); + sleep(3); + + /* open proc file: arp table */ + if ((Fd = fopen(PROC_NET_ARP_PATH, "r")) == NULL) + { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open proc file failed!\n")); + return FALSE; + } /* End of if */ + + /* bypass header -- read until newline */ + if (fgets(Buffer, sizeof(Buffer), Fd) != (CHAR *) NULL) + { + /* read the ARP cache entries */ + for(; fgets(Buffer, sizeof(Buffer), Fd);) + { + Num = sscanf(Buffer, "%s 0x%x 0x%x %s %s %s\n", + IP, &Type, &Flags, Hwa, Mask, DevName); + if (Num < 4) + break; + /* End of if */ + + /* if device differs, just skip it */ + if (strcmp(DevName, pCtrlBK->IfNameEth) != 0) + continue; /* not same network interface */ + /* End of if */ + + /* compare to find out the match one */ + { + UINT32 Mac0, Mac1, Mac2, Mac3, Mac4, Mac5; /* MAC[0] ~ MAC[5] */ + INT32 Ip0, Ip1, Ip2, Ip3; /* IP[0] ~ IP[3] */ + + sscanf(Hwa, "%x:%x:%x:%x:%x:%x\n", + &Mac0, &Mac1, &Mac2, &Mac3, &Mac4, &Mac5); + + if ((AddrMac[0] == (UCHAR)Mac0) && + (AddrMac[1] == (UCHAR)Mac1) && + (AddrMac[2] == (UCHAR)Mac2) && + (AddrMac[3] == (UCHAR)Mac3) && + (AddrMac[4] == (UCHAR)Mac4) && + (AddrMac[5] == (UCHAR)Mac5)) + { + sscanf(IP, "%d.%d.%d.%d\n", &Ip0, &Ip1, &Ip2, &Ip3); + + pApInfo->s_addr = Ip0 + + (Ip1 << 8) + + (Ip2 << 16) + + (Ip3 << 24); + + DBGPRINT(RT_DEBUG_INFO, ("iapp> Found the ARP entry.\n")); + break; + } /* End of if */ + } + + DBGPRINT(RT_DEBUG_INFO, + ("iapp> IP = %s Type = %d Flags = %d Hwa = %s " + "Mask = %s dev = %s\n", + IP, Type, Flags, Hwa, Mask, DevName)); + } /* End of for(; fgets(Buffer, sizeof(Buffer), Fd);) */ + } /* End of if (fgets(Buffer, sizeof(Buffer), Fd) != (CHAR *) NULL) */ + + /* close proc file */ + fclose(Fd); + return TRUE; +} /* End of IAPP_IP2MACTransfer */ +#endif // #if 0 */ + +/* ---------------------------- PRIVATE Function ---------------------------- */ +/* +======================================================================== +Routine Description: + Dump a buffer content. + +Arguments: + pPromptStr - prompt string + *pSrcBufVA - buffer content + SrcBufLen - display length + +Return Value: + None + +Note: + debug use +======================================================================== +*/ +VOID IAPP_HexDump(IAPP_IN CHAR *pPromptStr, IAPP_IN CHAR *pSrcBufVA, + IAPP_IN UINT32 SrcBufLen) { + CHAR *pChar; + UINT32 IdDump; + + pChar = pSrcBufVA; + printf("%s: %p, len = %d\n", pPromptStr, pSrcBufVA, SrcBufLen); + + for (IdDump = 0; IdDump < SrcBufLen; IdDump++) { + if ((IdDump & 0x0F) == 0) + printf("0x%04x : ", IdDump); + /* End of if */ + + printf("%02x ", ((UCHAR)pChar[IdDump])); + + if ((IdDump & 0x0F) == 15) + printf("\n"); + /* End of if */ + } /* End of for */ + + printf("\n"); +} /* End of IAPP_HexDump */ + +/* +======================================================================== +Routine Description: + Parse SysCmd arguments. + +Arguments: + *pCtrlBK - IAPP Control Block + Argc - argument number + *pArgv[] - arguments + +Return Value: + None + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_ArgumentParse(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN INT32 Argc, IAPP_IN CHAR *pArgv[]) { +#define IAPP_AGP_CMD_PARSE_NEXT_ONE \ + { \ + Argc--; \ + pArgv++; \ + } + + INT i = 0; + + /* init */ + strcpy(pCtrlBK->IfNameEth, FT_KDP_DEFAULT_IF_ETH); + strcpy(pCtrlBK->IfNameWlan, FT_KDP_DEFAULT_IF_WLAN); + strcpy(pCtrlBK->IfNameWlanIoctl[0], FT_KDP_DEFAULT_IF_WLAN_IOCTL); + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT +#ifdef FT_KDP_KEY_FROM_DAEMON + strcpy(pCtrlBK->CommonKey, FT_KDP_DEFAULT_PTK); +#endif // FT_KDP_KEY_FROM_DAEMON // +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + /* sanity check */ + if (Argc == 0) + goto label_exit; + /* End of if */ + + /* parse command */ + IAPP_AGP_CMD_PARSE_NEXT_ONE; + + while (Argc > 0) { + if (strncmp(pArgv[0], "-h", 2) == 0) { + IAPP_AGP_CMD_PARSE_NEXT_ONE; + IAPP_Usage(); + return FALSE; + } /* End of if */ + + if (strncmp(pArgv[0], "-e", 2) == 0) { + /* ethernet interface */ + IAPP_AGP_CMD_PARSE_NEXT_ONE; + + if (Argc > 0) { + strcpy(pCtrlBK->IfNameEth, pArgv[0]); + IAPP_AGP_CMD_PARSE_NEXT_ONE; + } /* End of if */ + } else if (strncmp(pArgv[0], "-wi", 3) == 0) { + /* wireless ioctl interface */ + IAPP_AGP_CMD_PARSE_NEXT_ONE; + + if (Argc > 0) { + strcpy(pCtrlBK->IfNameWlanIoctl[pCtrlBK->IfNameWlanCount++], pArgv[0]); + IAPP_AGP_CMD_PARSE_NEXT_ONE; + } /* End of if */ + } else if (strncmp(pArgv[0], "-w", 2) == 0) { + /* wireless interface */ + IAPP_AGP_CMD_PARSE_NEXT_ONE; + + if (Argc > 0) { + strcpy(pCtrlBK->IfNameWlan, pArgv[0]); + IAPP_AGP_CMD_PARSE_NEXT_ONE; + } /* End of if */ + } +#ifdef FT_KDP_FUNC_PKT_ENCRYPT +#ifdef FT_KDP_KEY_FROM_DAEMON + else if (strncmp(pArgv[0], "-k", 2) == 0) { + /* encrypt/decrypt key */ + IAPP_AGP_CMD_PARSE_NEXT_ONE; + + if (Argc > 0) { + if (strlen(pArgv[0]) > IAPP_ENCRYPT_KEY_MAX_SIZE) { + pArgv[0][IAPP_ENCRYPT_KEY_MAX_SIZE] = 0x00; + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> key length can not be larger than %d!", + IAPP_ENCRYPT_KEY_MAX_SIZE)); + } /* End of if */ + + strcpy(pCtrlBK->CommonKey, pArgv[0]); + IAPP_AGP_CMD_PARSE_NEXT_ONE; + } /* End of if */ + } +#endif // FT_KDP_KEY_FROM_DAEMON // +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + else if (strncmp(pArgv[0], "-d", 2) == 0) { + IAPP_AGP_CMD_PARSE_NEXT_ONE; + RTDebugLevel = atoi(pArgv[0]); + IAPP_AGP_CMD_PARSE_NEXT_ONE; + } else { + IAPP_AGP_CMD_PARSE_NEXT_ONE; + } /* End of if */ + } /* End of while */ + +label_exit: + if (pCtrlBK->IfNameWlanCount == 0) + pCtrlBK->IfNameWlanCount = 1; + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> -e=%s, -w=%s", pCtrlBK->IfNameEth, pCtrlBK->IfNameWlan)); + + for (i = 0; i < pCtrlBK->IfNameWlanCount; i++) { + DBGPRINT(RT_DEBUG_TRACE, (", -wi=%s", pCtrlBK->IfNameWlanIoctl[i])); + } + DBGPRINT(RT_DEBUG_TRACE, + (", IfNameWlanCount = %d\n", pCtrlBK->IfNameWlanCount)); + return TRUE; +} /* End of IAPP_ArgumentParse */ + +/* +======================================================================== +Routine Description: + Get interface information, such as IP, AddrNetmask, broadcast addr, etc. + +Arguments: + *pCtrlBK - IAPP control block + +Return Value: + TRUE - get successfully + FAIL - get fail + +Note: + Only for Ethernet interface of DS (distribution system). +======================================================================== +*/ +static BOOLEAN IAPP_DSIfInfoGet(IAPP_IN RTMP_IAPP *pCtrlBK) { + INT32 SockIf; + struct ifreq ReqIf; + + /* init */ + IAPP_MEM_MOVE(ReqIf.ifr_name, pCtrlBK->IfNameEth, IFNAMSIZ); + + /* open a UDP socket */ + if ((SockIf = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open socket failed!\n")); + return FALSE; + } /* End of if */ + + /* get own addr */ + if (ioctl(SockIf, SIOCGIFADDR, (int)&ReqIf) < 0) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> Get own address of %s failed!\n", ReqIf.ifr_name)); + goto label_fail; + } /* End of if */ + + IAPP_MEM_MOVE(&pCtrlBK->AddrOwn, + &((struct sockaddr_in *)&ReqIf.ifr_addr)->sin_addr, + sizeof(pCtrlBK->AddrOwn)); + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> own address (%d.%d.%d.%d)\n", + IAPP_SHOW_IP_HTONL(pCtrlBK->AddrOwn.s_addr))); + + /* get broadcast address */ + if (ioctl(SockIf, SIOCGIFBRDADDR, (int)&ReqIf) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Get broadcast address failed!\n")); + goto label_fail; + } /* End of if */ + + IAPP_MEM_MOVE(&pCtrlBK->AddrBroadcast, + &((struct sockaddr_in *)&ReqIf.ifr_addr)->sin_addr, + sizeof(pCtrlBK->AddrBroadcast)); + + /* can not use 255.255.255.255 or we can not send any packet */ + // NdisFillMemory(&pCtrlBK->AddrBroadcast, sizeof(pCtrlBK->AddrBroadcast), + // 0xFF); + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> broadcast address (%d.%d.%d.%d)\n", + IAPP_SHOW_IP_HTONL(pCtrlBK->AddrBroadcast.s_addr))); + + /* get network Mask */ + if (ioctl(SockIf, SIOCGIFNETMASK, (int)&ReqIf) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Get network Mask failed!\n")); + goto label_fail; + } /* End of if */ + + IAPP_MEM_MOVE(&pCtrlBK->AddrNetmask, + &((struct sockaddr_in *)&ReqIf.ifr_addr)->sin_addr, + sizeof(pCtrlBK->AddrNetmask)); + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> network Mask address (%d.%d.%d.%d)\n", + IAPP_SHOW_IP_HTONL(pCtrlBK->AddrNetmask.s_addr))); + + close(SockIf); + return TRUE; + +label_fail: + close(SockIf); + return FALSE; +} /* End of IAPP_DSIfInfoGet */ + +/* +======================================================================== +Routine Description: + Issue a SysCmd to RALINK AP driver. + +Arguments: + *pCtrlBK - the IAPP control block + Param - IOCTL command + *pData - command + *pDataLen - command length + ApIdx - BSS index + Flags - IOCTL sub-command + +Return Value: + Ret + +Note: +======================================================================== +*/ +BOOLEAN IAPP_IoctlToWLAN(IAPP_IN RTMP_IAPP *pCtrlBK, IAPP_IN INT32 Param, + IAPP_IN CHAR *pData, IAPP_IN INT32 *pDataLen, + IAPP_IN UCHAR ApIdx, IAPP_IN INT32 Flags) { + CHAR IfName[12]; /* in VxWorks, no iwreq.ifr_name */ + struct iwreq Wrq; + +#ifdef IAPP_OS_LINUX + if (strlen(pCtrlBK->IfNameWlanIoctl[ApIdx]) >= sizeof(IfName)) + strcpy(IfName, FT_KDP_DEFAULT_IF_WLAN_IOCTL); + else + strcpy(IfName, pCtrlBK->IfNameWlanIoctl[ApIdx]); + /* End of if */ + + /* sprintf(IfName, "ra%d", ApIdx); + IfName[3] = '\0'; */ + strcpy(Wrq.ifr_name, IfName); +#endif + + Wrq.u.data.flags = Flags; + Wrq.u.data.length = *pDataLen; + Wrq.u.data.pointer = (caddr_t)pData; + + DBGPRINT(RT_DEBUG_ERROR, ("iapp>[%s]IOCTL Flags = 0x%x!\n", IfName, Flags)); + +#ifdef IAPP_OS_LINUX + if (ioctl(pCtrlBK->SocketIoctl, Param, (int)&Wrq) < 0) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> IOCTL 0x%x to wlan %s failed!\n", Flags, IfName)); + return FALSE; + } /* End of if */ +#endif // IAPP_OS_LINUX // + +#ifdef IAPP_OS_VXWORKS + if (muxIoctl(pCtrlBK->pDrvCookieTo, Param, (caddr_t)&Wrq) == ERROR) { + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> IOCTL 0x%x to wlan %s failed!\n", Param, IfName)); + return FALSE; + } /* End of if */ +#endif // IAPP_OS_VXWORKS // + + *pDataLen = Wrq.u.data.length; + return TRUE; +} /* End of IAPP_IoctlToWLAN */ + +/* +======================================================================== +Routine Description: + Initialize IPC message control. + +Arguments: + *pCtrlBK - IAPP control blcok + +Return Value: + TRUE - always successfully + +Note: + IPC related SysCmd- + ipcs, ipcrm, msgget, msgsnd, msgrcv, msgctl +======================================================================== +*/ +static INT32 IAPP_IPC_MSG_Init(IAPP_IN RTMP_IAPP *pCtrlBK) { +#if 0 + INT32 Key = 0x55116604; + + + /* + Translate an unique Key from our dat file, the Key is fixed for + a fixed file content. + */ + if ((Key = ftok(MSG_FILE, 0xf)) == -1) + { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> ftok Error!\n")); + exit(-1); + } /* End of if */ + + if ((pCtrlBK->MsgId = msgget(Key, 0)) == -1) + { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> msgget Error:%s\n", strerror(errno))); + exit(-1); + } /* End of if */ + + pCtrlBK->FlgIsMsgReady = FALSE; +#endif + + pCtrlBK->PacketIdentifier = 0; + return TRUE; +} /* End of IAPP_IPC_MSG_Init */ + +/* +======================================================================== +Routine Description: + Send Layer 2 Update Frame to update forwarding table in Layer 2 devices. + +Arguments: + *pCtrlBK - IAPP control blcok + *pMac - the STATION MAC address pointer + +Return Value: + TRUE - send successfully + FAIL - send fail + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_L2UpdateFrameSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pMac) { + RT_IAPP_L2_UPDATE_FRAME FrameBody, *pFrameL2; + INT32 Status; + + /* init the update frame body */ + pFrameL2 = &FrameBody; + + IAPP_MEM_ZERO(pFrameL2, sizeof(FrameBody)); + IAPP_MEM_FILL(pFrameL2->ETH.DA, 0xFF, ETH_ALEN); + IAPP_MEM_MOVE(pFrameL2->ETH.SA, pMac, ETH_ALEN); + + pFrameL2->ETH.Len = htons(8); + pFrameL2->DSAP = 0; + pFrameL2->SSAP = 0x01; + pFrameL2->Control = 0xAF; + + pFrameL2->XIDInfo[0] = 0x81; + pFrameL2->XIDInfo[1] = 1; + pFrameL2->XIDInfo[2] = 1 << 1; + +#ifdef IAPP_OS_LINUX + /* send the update frame */ + Status = send(pCtrlBK->SocketRawBr, pFrameL2, sizeof(FrameBody), 0); + if (Status < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send L2 packet failed %d!\n", Status)); + return FALSE; + } /* End of if */ +#endif + +#ifdef IAPP_OS_VXWORKS + { + M_BLK_ID pUpdatePkt; + UINT32 IdIfNum; + + /* loop for eth0, eth1, eth2...... */ + for (IdIfNum = 0; IdIfNum < FT_KDP_BR_ETH_IF_NUM; IdIfNum++) { + if ((pUpdatePkt = netTupleGet(_pNetDpool, sizeof(FrameBody), M_DONTWAIT, + MT_DATA, TRUE)) == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Get packet buffer fail!\n")); + return FALSE; + } /* End of if */ + + pUpdatePkt->mBlkHdr.mFlags |= M_PKTHDR; + pUpdatePkt->m_len = sizeof(FrameBody); + + IAPP_MEM_MOVE(pUpdatePkt->m_data, pFrameL2, sizeof(FrameBody)); + + if (muxSend(pCtrlBK->pBcCookie[IdIfNum], pUpdatePkt) == ERROR) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send L2 packet failed!\n")); + netMblkClChainFree(pUpdatePkt); + return FALSE; + } /* End of if */ + } /* End of for */ + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Send L2 packet OK!\n")); + } +#endif + + return TRUE; +} /* End of IAPP_L2UpdateFrameSend */ + +/* +======================================================================== +Routine Description: + Process received message, such as rcv ADD-notify and inform AP to del +STA. + +Arguments: + *pCtrlBK - the IAPP control block pointer + MsgSubType - message Type + *pMsg - message + Len - message length + +Return Value: + TRUE - always successfully + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_MsgProcess(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN INT32 MsgSubType, IAPP_IN UCHAR *pMsg, + IAPP_IN INT32 Len, IAPP_IN INT32 if_idx) { + switch (MsgSubType) { + case IAPP_OPEN_SERVICE_REQ: + DBGPRINT(RT_DEBUG_TRACE, ("iapp> (FlgIsMsgReady is TRUE)\n")); + break; + + case IAPP_CLOSE_SERVICE_REQ: + DBGPRINT(RT_DEBUG_TRACE, ("iapp> (FlgIsMsgReady is FALSE)\n")); + break; + + case IAPP_SET_OID_REQ: { + POID_REQ OID_req_p; + + OID_req_p = (POID_REQ)pMsg; + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Command to WLAN (OID=%x, LEN=%d)\n", + OID_req_p->OID, OID_req_p->Len)); + + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, OID_req_p->Buf, &OID_req_p->Len, + if_idx, OID_req_p->OID); + } /* case IAPP_SET_OID_REQ */ + break; + + case IAPP_QUERY_OID_REQ: /* old SysCmd from 8021X deamon */ + // IAPP_SM_InfoHandle(pMsg); + break; + + default: + DBGPRINT(RT_DEBUG_ERROR, ("iapp> (unknown subtype)\n")); + break; + } /* End of switch */ + + return TRUE; +} /* End of IAPP_MsgProcess */ + +/* +======================================================================== +Routine Description: + Open a file with filename = our PID. + +Arguments: + PID - our background process ID + +Return Value: + None + +Note: + Why to backup PID? + + Because always we will restart new IAPP daemon but forget to destroy + the old IAPP daemon, many IAPP daemons will exist in kernel. + + So we will delete old IAPP daemon whenever you start a new IAPP daemon. +======================================================================== +*/ +static VOID IAPP_PID_Backup(IAPP_IN pid_t PID) { +#ifdef IAPP_OS_LINUX + FILE *pFile; + CHAR Buffer[30]; + + /* prepare PID file content */ + IAPP_MEM_ZERO(Buffer, sizeof(Buffer)); + sprintf(Buffer, "PID = %d\n", PID); + + /* re-open and truncate file to zero length by using "wb" */ + /* write new PID in the file */ + pFile = fopen(IAPP_PID_BACKUP_FILE, "wb"); + if (pFile) { + fwrite(Buffer, strlen(Buffer), 1, pFile); + fclose(pFile); + } else { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> File open error.\n")); + } +#endif // IAPP_OS_LINUX // +} /* End of IAPP_PID_Backup */ + +/* +======================================================================== +Routine Description: + Kill running IAPP daemon if exists. + +Arguments: + None + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_PID_Kill(VOID) { +#ifdef IAPP_OS_LINUX + FILE *pFile; + pid_t PID; + CHAR SysCmd[30]; + + /* get last PID */ + pFile = fopen(IAPP_PID_BACKUP_FILE, "rb"); + if (pFile == NULL) + return; + /* End of if */ + fscanf(pFile, "PID = %d\n", &PID); + DBGPRINT(RT_DEBUG_OFF, ("iapp> Found PID=%d\n", PID)); + fclose(pFile); + + /* kill old IAPP daemon */ + sprintf(SysCmd, "kill %d\n", PID); + system(SysCmd); + + /* sleep for a where to kill old daemon */ + sleep(2); +#endif // IAPP_OS_LINUX // +} /* End of IAPP_PID_Kill */ + +/* +======================================================================== +Routine Description: + Process received signal, such as STA ASSOCIATION and send a ADD-notify. + +Arguments: + *pCtrlBK - IAPP control blcok + *pSig - signal + Len - message length + *pCmdBuf - used to issue command to WLAN driver + *pRspBuf - used to issue response to the peer + +Return Value: + TRUE - always successfully + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_SIG_Process(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *WifiMAC, + IAPP_IN RT_SIGNAL_STRUC *pSig, + IAPP_IN INT32 Len, IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf) { + FT_KDP_EVT_HEADER *pEvtHeader; + INT32 if_idx = -1; + + if_idx = mt_iapp_find_ifidx_by_mac(pCtrlBK, WifiMAC); + if (if_idx == -1) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> %s - cannot find this wifi interface " + "(%02x:%02x:%02x:%02x:%02x:%02x)\n", + __FUNCTION__, WifiMAC[0], WifiMAC[1], WifiMAC[2], + WifiMAC[3], WifiMAC[4], WifiMAC[5])); + return FALSE; + } + + pEvtHeader = (FT_KDP_EVT_HEADER *)(pSig->Content); + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Sig = 0x%02x, pEvtHeader->EventLen = %d, " + "Peer IP = %d.%d.%d.%d\n", + pSig->Sig, pEvtHeader->EventLen, + IAPP_SHOW_IP_HTONL(pEvtHeader->PeerIpAddr))); + + switch (pSig->Sig) { + case FT_KDP_SIG_NOTHING: + DBGPRINT(RT_DEBUG_TRACE, ("iapp> NO event to handle.\n")); + break; + case FT_KDP_SIG_IAPP_ASSOCIATION: { +#if 1 + DBGPRINT(RT_DEBUG_TRACE, ("iapp> FT_KDP_SIG_IAPP_ASSOCIATION.\n")); +#else + + /* + This service primitive is used when a STA associates with the + AP using an 802.11 association request frame. + + One purpose of this primitive is to cause the forwarding + tables of layer 2 internetworking devices, e.g. bridges + and switches, to be updated. + + The second purpose of this primitive is to notify other APs + within the multicast domain, i.e., that portion of a network + in which a layer two frame addressed to a multicast address + can be received, of the STA’s new association, to allow those + APs to clean up context information left behind by STAs that + do not properly reassociate when moving from one AP to another, + but rather only use the 802.11 Association Request. + */ + RT_IAPP_ADD_NOTIFY IappAddNotify, *pFrameNotify; + UINT32 DataLen; + + /* pSig->MacAddr[] is the associated STATION MAC address */ + + /* init */ + IAPP_MEM_ZERO(&IappAddNotify, sizeof(IappAddNotify)); + + /* make up the frame content */ + pFrameNotify = &IappAddNotify; + pFrameNotify->IappHeader.Version = 0; + pFrameNotify->IappHeader.Command = IAPP_CMD_ADD_NOTIFY; + pFrameNotify->IappHeader.Identifier = 0; + + DataLen = sizeof(RT_IAPP_ADD_NOTIFY); + + pFrameNotify->IappHeader.Length = SWAP_16(DataLen); + pFrameNotify->Sequence = SWAP_16(pSig->Sequence); + + pFrameNotify->AddressLen = ETH_ALEN; + IAPP_MEM_MOVE(pFrameNotify->MacAddr, pSig->MacAddr, ETH_ALEN); + + mt_iapp_ft_client_insert(&pCtrlBK->SelfFtStaTable, pSig->MacAddr, WifiMAC, + if_idx); + /* +Send the ADD-notify with multicast address & +send the L2 update frame with broadcast address. +*/ + /* + An ESS is a set of Basic Service Sets (BSSs) that form a + single LAN, allowing an STA to move transparently from one + BSS to another throughout the ESS. + + Because this packet is addressed to the IAPP multicast + address, this packet may not reach all APs in an ESS. + In particular, if the ESS spans multiple subnets, neither + the ADD-notify packet nor the Layer 2 Update frame is likely + to reach the APs on subnets other than the one on which + the transmissions originate. + + Note that purpose of the IAPP ADD-notify packet is to remove + stale associations, not to modify the learning table. + The learning table update is done by the Layer 2 Update frame. + + This should allow for more efficient management of AP resources. + + There is no security provided for the Layer 2 Update frame. + + The Layer 2 Update frame does not open new potentials for + attacks against the WLAN or the STAs. However, the ADD-notify + is a UDP IP frame that COULD be sent from anywhere in the DS + and attack the AP’s state for the STA. + */ + IAPP_UDP_PACKET_SEND(pCtrlBK, pFrameNotify, DataLen, pRspBuf); + IAPP_L2UpdateFrameSend(pCtrlBK, pSig->MacAddr); + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> (IAPP_SIG_ASSOCIATION), Rcv assoc signal, and send out " + "IAPP add-notify\n")); +#endif + } /* case IAPP_SIG_ASSOCIATION */ + break; + + case IAPP_SIG_REASSOCIATION: + /* test only, not support currently */ +#if 0 + { + struct in_addr IP; + + /* UCHAR mac[ETH_ALEN] = {0x00,0x0c,0x43,0x26,0x65,0x09}; + + if (IAPP_IP2MACTransfer(&IP, mac) >= 0) + { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> (IAPP_SIG_REASSOCIATION), " + "IP: %d.%d.%d.%d\n", IP.s_addr & 0xFF, + (IP.s_addr >> 8) & 0xFF, + (IP.s_addr >> 16) & 0xFF, + (IP.s_addr >> 24) & 0xFF)); + }*/ + + IP.s_addr = 0; + + if (IAPP_IP2MACTransfer(pSig->CurrAPAddr, &IP) == TRUE) + { + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> (IAPP_SIG_REASSOCIATION), IP=%d.%d.%d.%d\n", + IAPP_SHOW_IP_HTONL(IP.s_addr))); + } /* End of if */ + } /* case IAPP_SIG_REASSOCIATION */ +#endif // #if 0 // + break; + + case FT_KDP_SIG_FT_ASSOCIATION: { + /* a station has already associated with us */ + /* so prepare and send out ADD_notify packet, L2 update frame */ + RT_IAPP_ADD_NOTIFY IappAddNotify, *pFrameNotify; + UINT32 DataLen; + + /* init */ + IAPP_MEM_ZERO(&IappAddNotify, sizeof(IappAddNotify)); + + /* make up the frame content */ + pFrameNotify = &IappAddNotify; + pFrameNotify->IappHeader.Version = 0; + pFrameNotify->IappHeader.Command = IAPP_CMD_ADD_NOTIFY; + pFrameNotify->IappHeader.Identifier = 0; + + DataLen = sizeof(RT_IAPP_ADD_NOTIFY); + + pFrameNotify->IappHeader.Length = SWAP_16(DataLen); + pFrameNotify->Sequence = SWAP_16(pSig->Sequence); + + pFrameNotify->AddressLen = ETH_ALEN; + IAPP_MEM_MOVE(pFrameNotify->MacAddr, pSig->MacAddr, ETH_ALEN); + + mt_iapp_ft_client_insert(&pCtrlBK->SelfFtStaTable, pSig->MacAddr, WifiMAC, + if_idx); + + /* mark the notify is for 11r station */ + pFrameNotify->Rsvd |= FT_KDP_ADD_NOTIFY_RSVD_11R_SUPPORT; + + /* + Send the ADD-notify with multicast address & + send the L2 update frame with broadcast address. + */ + DBGPRINT( + RT_DEBUG_TRACE, + ("iapp> (FT_KDP_SIG_FT_ASSOCIATION) Rcv a assoc signal and send out " + "IAPP add-notify!\n")); + + IAPP_UDP_PACKET_SEND(pCtrlBK, pFrameNotify, DataLen, pRspBuf, if_idx); + IAPP_L2UpdateFrameSend(pCtrlBK, pSig->MacAddr); + } break; + + case FT_KDP_SIG_FT_REASSOCIATION: { + /* + This primitive should be issued by the APME when it receives + an MLME-REASSOCIATE.indication from the MLME indicating that + an STA has reassociated with the AP. + + In IAPP, If the APME is utilizing caching, then the APME should + first lookup the STA’s context in the IAPP cache using the + STA’s MAC Address. If found (a cache hit), then an + IAPP-MOVE.request does not have to be issued until after an + 802.11 Reassociation Response frame. If the STA context is + not found in the cache (a cache miss), then the APME should + issue an IAPP-MOVE.request as usual. + + In IEEE802.11r, we just send MOVE-notify to inform the peer. + */ + RT_IAPP_MOVE_NOTIFY IappMoveNotify, *pFrameNotify; + UINT32 DataLen; + + /* init */ + IAPP_MEM_ZERO(&IappMoveNotify, sizeof(IappMoveNotify)); + + /* make up the frame content */ + pFrameNotify = &IappMoveNotify; + pFrameNotify->IappHeader.Version = 0; + pFrameNotify->IappHeader.Command = IAPP_CMD_MOVE_NOTIFY; + pFrameNotify->IappHeader.Identifier = 0; + + DataLen = sizeof(RT_IAPP_MOVE_NOTIFY); + + pFrameNotify->IappHeader.Length = SWAP_16(DataLen); + pFrameNotify->Sequence = SWAP_16(pSig->Sequence); + + pFrameNotify->AddressLen = ETH_ALEN; + IAPP_MEM_MOVE(pFrameNotify->MacAddr, pSig->MacAddr, ETH_ALEN); + + mt_iapp_ft_client_insert(&pCtrlBK->SelfFtStaTable, pSig->MacAddr, WifiMAC, + if_idx); + + /* + Send the MOVE-notify with multicast address & + send the L2 update frame with broadcast address. + */ + IAPP_TCP_PACKET_SEND(pCtrlBK, pFrameNotify, sizeof(RT_IAPP_MOVE_NOTIFY), + pEvtHeader->PeerIpAddr, TRUE, pRspBuf, if_idx); + IAPP_L2UpdateFrameSend(pCtrlBK, pSig->MacAddr); + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> (IAPP_SIG_REASSOCIATION) Rcv a reassoc signal and " + "send out IAPP move-notify!\n")); + } break; + + case IAPP_SIG_TERMINATE: { + /* terminate the daemon */ + IAPP_TerminateHandle(0); + } break; + + case FT_KDP_SIG_KEY_TIMEOUT: { + /* inform other APs the key timeouts */ + } break; + + case FT_KDP_SIG_KEY_REQ: + case FT_KDP_SIG_KEY_REQ_AUTO: + /* request PMK-R1 from the R0KH */ + FT_KDP_SecurityBlockSend(pCtrlBK, pEvtHeader, + pSig->Content + FT_KDP_EVT_HEADER_SIZE, pRspBuf, + WifiMAC, if_idx); + break; + + case FT_KDP_SIG_ACTION: + /* forward FT Action Req/Rsp for the peer */ + FT_RRB_ActionForward(pCtrlBK, pEvtHeader, + pSig->Content + FT_KDP_EVT_HEADER_SIZE, pSig->Sequence, + pSig->MacAddr, pSig->MacAddrSa, pSig->CurrAPAddr, + pRspBuf, if_idx); + break; + + case FT_KDP_SIG_KEY_RSP_AUTO: + /* response PMK-R1 to the R1KH */ + FT_KDP_SecurityBlockAck(pCtrlBK, pEvtHeader, + pSig->Content + FT_KDP_EVT_HEADER_SIZE, pRspBuf, + if_idx); + break; + + case FT_KDP_SIG_INFO_BROADCAST: + /* send my AP information to the ESS */ + FT_KDP_InformationReportSend(pCtrlBK, pEvtHeader, + pSig->Content + FT_KDP_EVT_HEADER_SIZE, + pRspBuf, if_idx); + break; + + case FT_KDP_SIG_AP_INFO_REQ: + /* request other AP information in the ESS */ + FT_KDP_InformationRequestSend(pCtrlBK, pEvtHeader, + pSig->Content + FT_KDP_EVT_HEADER_SIZE, + pRspBuf, if_idx); + break; + + case FT_KDP_SIG_AP_INFO_RSP: + /* response my AP information to a AP */ + FT_KDP_InformationResponseSend(pCtrlBK, pEvtHeader, + pSig->Content + FT_KDP_EVT_HEADER_SIZE, + pRspBuf, if_idx); + break; + + case FT_KSP_SIG_DEBUG_TRACE: + /* change debug level */ + RTDebugLevel = *(INT32 *)(pSig->Content + FT_KDP_EVT_HEADER_SIZE); + DBGPRINT(RT_DEBUG_OFF, ("iapp> Change debug level to %d!\n", RTDebugLevel)); + break; + + default: + DBGPRINT(RT_DEBUG_ERROR, + ("iapp> Signal %d is not supported!\n", pSig->Sig)); + return FALSE; + } /* End of switch(pSig->Sig) */ + + return TRUE; +} /* End of IAPP_SIG_Process */ + +/* +======================================================================== +Routine Description: + Close TCP/UDP socket. + +Arguments: + *pCtrlBK - IAPP control blcok + +Return Value: + TRUE - always successfully + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_SocketClose(IAPP_IN RTMP_IAPP *pCtrlBK) { + /* struct ip_mreq MReq;*/ + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Close TCP/UDP socket.\n")); + +#if 0 + MReq.imr_multiaddr.s_addr = inet_addr(IAPP_MULTICAST_ADDR); + MReq.imr_interface.s_addr = htonl(INADDR_ANY); + + if (setsockopt(pCtrlBK->SocketUdpSend, + IPPROTO_IP, + IP_DROP_MEMBERSHIP, + &MReq, + sizeof(MReq)) < 0) + { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> setsockopt-IP_DROP_MEMBERSHIP failed!\n")); + } /* End of if */ +#endif // #if 0 // + + if (pCtrlBK->SocketUdpSend >= 0) + close(pCtrlBK->SocketUdpSend); + /* End of if */ + + if (pCtrlBK->SocketTcpRcv >= 0) + close(pCtrlBK->SocketTcpRcv); + /* End of if */ + + if (pCtrlBK->SocketRawBr >= 0) + close(pCtrlBK->SocketRawBr); + /* End of if */ + + if (pCtrlBK->SocketIoctl >= 0) + close(pCtrlBK->SocketIoctl); + /* End of if */ + + if (pCtrlBK->SocketRawRRB >= 0) + close(pCtrlBK->SocketRawRRB); + /* End of if */ + +#ifdef FT_KDP_FUNC_SOCK_COMM + if (pCtrlBK->SocketRawDrv >= 0) + close(pCtrlBK->SocketRawDrv); + /* End of if */ +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifndef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX + if (pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ] >= 0) + close(pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ]); + /* End of if */ + + if (pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_WRITE] >= 0) + close(pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_WRITE]); + /* End of if */ +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + + pCtrlBK->FlgIsRcvRunning = FALSE; + return TRUE; +} /* End of IAPP_SocketClose */ + +/* +======================================================================== +Routine Description: + Open TCP/UDP socket. + +Arguments: + *pCtrlBK - IAPP control blcok + +Return Value: + TRUE - open successfully + FAIL - open fail + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_SocketOpen(IAPP_IN RTMP_IAPP *pCtrlBK) { + INT32 FlgIsLoop, FlgIsReUsed, FlgIsBroadcast; +#if 0 + struct hostent *SerHostName; +#endif + /* struct ip_mreq MReq;*/ + struct sockaddr_in AddrUdp, AddrTcp; +#ifdef IAPP_OS_LINUX + struct ifreq ReqIf; + struct sockaddr_ll AddrRaw; +#endif +#if 0 + struct sigaction HandlerUdp; +#endif +#ifdef IAPP_OS_VXWORKS + struct in_addr AddrIf; +#endif + + /* init */ + pCtrlBK->SocketUdpSend = -1; + pCtrlBK->SocketTcpRcv = -1; + pCtrlBK->SocketRawBr = -1; + pCtrlBK->SocketIoctl = -1; + pCtrlBK->SocketRawRRB = -1; + +#ifdef FT_KDP_FUNC_SOCK_COMM + pCtrlBK->SocketRawDrv = -1; +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifndef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX + pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ] = -1; + pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_WRITE] = -1; +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifdef IAPP_OS_VXWORKS + /* muxBind a cookie for receiving commands from wireless driver */ + pCtrlBK->pDrvCookieFrom = muxBind( + FT_KDP_BR_NAME, FT_KDP_BR_UNIT, (FUNCPTR)IAPP_RcvHandlerRawDrvVxWorks, + (FUNCPTR)NULL, (FUNCPTR)NULL, (VOIDFUNCPTR)NULL, IAPP_ETH_PRO, + "IAPP IO FROM", (VOID *)pCtrlBK); + + if (pCtrlBK->pDrvCookieFrom == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> muxBind device failed!\n")); + goto label_fail; + } /* End of if */ + + /* muxBind a cookie for issuing commands to wireless driver */ + pCtrlBK->pDrvCookieTo = + muxBind(FT_KDP_WLAN_NAME, FT_KDP_WLAN_UNIT, (FUNCPTR)NULL, (FUNCPTR)NULL, + (FUNCPTR)NULL, (VOIDFUNCPTR)NULL, 0, "IAPP IO TO", NULL); + + if (pCtrlBK->pDrvCookieTo == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> muxBind device failed!\n")); + goto label_fail; + } /* End of if */ +#endif // IAPP_OS_VXWORKS // + +#if 0 + /* get IP address */ + if ((SerHostName = gethostbyname(IAPP_MULTICAST_ADDR)) == 0) + { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> gethostbyname failed!\n")); + goto label_fail; + } /* End of if */ +#endif + + /* open a Send UDP socket */ + if ((pCtrlBK->SocketUdpSend = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open UDP socket failed!\n")); + goto label_fail; + } /* End of if */ + + /* set socket reusable */ + FlgIsReUsed = 1; + if (setsockopt(pCtrlBK->SocketUdpSend, SOL_SOCKET, SO_REUSEADDR, &FlgIsReUsed, + sizeof(FlgIsReUsed)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> setsockopt-SO_REUSEADDR failed!\n")); + goto label_fail; + } /* End of if */ + + /* bind the Send UDP socket */ + IAPP_MEM_ZERO(&AddrUdp, sizeof(AddrUdp)); + AddrUdp.sin_family = AF_INET; + /* + We can not use multicast address or in vxWorks, it will use the + multicast address as the source IP address. + + And you will suffer "Address load Exception" in IAPP_Task(). + + And you also can not use unicast address, or you can not receive + any broadcast packet. + + So must use INADDR_ANY. + */ + // AddrUdp.sin_addr.s_addr = inet_addr(IAPP_MULTICAST_ADDR); + AddrUdp.sin_addr.s_addr = INADDR_ANY; + AddrUdp.sin_port = htons(IAPP_UDP_PORT); + + if (bind(pCtrlBK->SocketUdpSend, (struct sockaddr *)&AddrUdp, + sizeof(AddrUdp)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Bind Send UDP failed!\n")); + goto label_fail; + } /* End of if */ + +#ifdef IAPP_OS_VXWORKS + /* support multicast packet sent */ + AddrIf.s_addr = pCtrlBK->AddrOwn.s_addr; + + if (setsockopt(pCtrlBK->SocketUdpSend, IPPROTO_IP, IP_MULTICAST_IF, + (char *)&AddrIf, sizeof(AddrIf)) == ERROR) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> iapp> setsockopt error!\n")); + goto label_fail; + } /* End of if */ +#endif // IAPP_OS_VXWORKS // + + /* no loopback support */ + FlgIsLoop = 0; + if (setsockopt(pCtrlBK->SocketUdpSend, IPPROTO_IP, IP_MULTICAST_LOOP, + &FlgIsLoop, sizeof(FlgIsLoop)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> setsockopt-multicast failed!\n")); + goto label_fail; + } /* End of if */ + +#if 0 + IAPP_MEM_ZERO(&MReq, sizeof(MReq)); + MReq.imr_multiaddr.s_addr = inet_addr(IAPP_MULTICAST_ADDR); + MReq.imr_interface.s_addr = pCtrlBK->AddrOwn.s_addr; + if (MReq.imr_multiaddr.s_addr == -1) + { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Illegal multicast address!\n")); + goto label_fail; + } /* End of if */ + +#ifndef RTL865X_SOC + /* register with kernel which addr support multicast */ + if (setsockopt(pCtrlBK->SocketUdpSend, + IPPROTO_IP, + IP_ADD_MEMBERSHIP, + &MReq, + sizeof(MReq)) < 0) + { + /* + 1. Your machine doesn't have multicast support enabled. For example, + on Linux and FreeBSD it is possible to compile a kernel which + doesn't support multicast. + 2. You don't have a route for multicast traffic. Some systems don't + add this by default, and you need to run. + route add -net 224.0.0.0 AddrNetmask 224.0.0.0 eth0 + + Because we bind the socket on multicast address, OS will not know + what interface it will send any multicast packet to. + */ + + DBGPRINT(RT_DEBUG_ERROR, ("iapp> setsockopt-IP_ADD_MEMBERSHIP failed!\n")); + goto label_fail; + } /* End of if */ +#endif // RTL865X_SOC // +#endif // #if 0 // + + /* use broadcast address */ + FlgIsBroadcast = 1; + if (setsockopt(pCtrlBK->SocketUdpSend, SOL_SOCKET, SO_BROADCAST, + &FlgIsBroadcast, sizeof(FlgIsBroadcast)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> setsockopt-SO_BROADCAST failed!\n")); + goto label_fail; + } /* End of if */ + +#ifdef IAPP_OS_LINUX + /* + Retrieve the interface index of the interface into ifr_ifindex by + ReqIf.ifr_name + */ + IAPP_MEM_MOVE(ReqIf.ifr_name, pCtrlBK->IfNameEth, IFNAMSIZ); + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> Register ethernet interface as (%s)\n", ReqIf.ifr_name)); + + if (ioctl(pCtrlBK->SocketUdpSend, SIOCGIFINDEX, &ReqIf) != 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> ioctl(SIOCGIFINDEX) failed!\n")); + goto label_fail; + } /* End of if */ +#endif // IAPP_OS_LINUX // + + /* setup non-blocking RCV UDP */ +#if 0 + HandlerUdp.sa_handler = IAPP_RcvHandler; + + /* init signal set */ + if (sigfillset(&HandlerUdp.sa_mask) < 0) + { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> sigfillset failed!\n")); + goto label_fail; + } /* End of if */ + + HandlerUdp.sa_flags = 0; + if (sigaction(SIGIO, &HandlerUdp, 0) < 0) + { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> sigaction failed!\n")); + goto label_fail; + } /* End of if */ +#endif + +#ifdef IAPP_OS_LINUX + /* open RAW socket */ + if ((pCtrlBK->SocketRawBr = socket( + PF_PACKET, SOCK_RAW, + // htons(ETH_P_ALL))) + //< 0) + htons(0x0008))) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open RAW socket failed!\n")); + goto label_fail; + } /* End of if */ + + /* bind RAW socket to pCtrlBK->IfNameEth (br-lan) */ + IAPP_MEM_ZERO(&AddrRaw, sizeof(AddrRaw)); + AddrRaw.sll_family = AF_PACKET; + AddrRaw.sll_ifindex = ReqIf.ifr_ifindex; + + if (bind(pCtrlBK->SocketRawBr, (struct sockaddr *)&AddrRaw, sizeof(AddrRaw)) < + 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Bind RAW socket failed!\n")); + goto label_fail; + } /* End of if */ + + /* open RAW socket */ + if ((pCtrlBK->SocketRawRRB = + socket(PF_PACKET, SOCK_RAW, htons(RRB_ETH_PRO))) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> open RRB RAW socket failed!\n")); + goto label_fail; + } /* End of if */ + + /* bind RAW socket to pCtrlBK->IfNameEth (br-lan) */ + IAPP_MEM_ZERO(&AddrRaw, sizeof(AddrRaw)); + AddrRaw.sll_family = AF_PACKET; + AddrRaw.sll_ifindex = ReqIf.ifr_ifindex; + + if (bind(pCtrlBK->SocketRawRRB, (struct sockaddr *)&AddrRaw, + sizeof(AddrRaw)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Bind RRB RAW socket failed!\n")); + goto label_fail; + } /* End of if */ +#endif // IAPP_OS_LINUX // + +#ifdef IAPP_OS_VXWORKS + { + UINT32 IdIfNum = 0; + CHAR BindNameBc[20]; + CHAR BindNameRrb[20]; + + /* open RAW socket */ + IAPP_MEM_ZERO(BindNameBc, sizeof(BindNameBc)); + + for (IdIfNum = 0; IdIfNum < FT_KDP_BR_ETH_IF_NUM; IdIfNum++) { + sprintf(BindNameBc, "IAPP KDP BC%d", IdIfNum); + sprintf(BindNameRrb, "IAPP KDP RRB%d", IdIfNum); + + pCtrlBK->pBcCookie[IdIfNum] = + muxBind(FT_KDP_ETH_NAME, IdIfNum, (FUNCPTR)NULL, (FUNCPTR)NULL, + (FUNCPTR)NULL, (VOIDFUNCPTR)NULL, 0, BindNameBc, NULL); + + if (pCtrlBK->pBcCookie[IdIfNum] == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> muxBind BC failed!\n")); + goto label_fail; + } /* End of if */ + + pCtrlBK->pRrbCookieTo[IdIfNum] = muxBind( + FT_KDP_ETH_NAME, IdIfNum, (FUNCPTR)NULL, (FUNCPTR)NULL, (FUNCPTR)NULL, + (VOIDFUNCPTR)NULL, RRB_ETH_PRO, BindNameRrb, NULL); + + if (pCtrlBK->pRrbCookieTo[IdIfNum] == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> iapp> muxBind RRB failed!\n")); + goto label_fail; + } /* End of if */ + } /* End of for */ + + pCtrlBK->pRrbCookieFrom = muxBind( + FT_KDP_BR_NAME, FT_KDP_BR_UNIT, (FUNCPTR)IAPP_RcvHandlerRawRRBVxWorks, + (FUNCPTR)NULL, (FUNCPTR)NULL, (VOIDFUNCPTR)NULL, RRB_ETH_PRO, + "IAPP RRB FROM", (VOID *)pCtrlBK); + + if (pCtrlBK->pRrbCookieFrom == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> muxBind RRB failed!\n")); + goto label_fail; + } /* End of if */ + + if ((pCtrlBK->SocketRawBr = socket(PF_PACKET, SOCK_RAW, 0)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open RAW socket failed!\n")); + goto label_fail; + } /* End of if */ + + pipeDevCreate(IAPP_KDP_PIPE_DRV, 5, sizeof(RT_SIGNAL_STRUC)); + pCtrlBK->SocketRawDrv = open(IAPP_KDP_PIPE_DRV, O_RDWR, 0); + if (pCtrlBK->SocketRawDrv < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open a PIPE DRV failed!\n")); + goto label_fail; + } /* End of if */ + + pipeDevCreate(IAPP_KDP_PIPE_ETH, 5, IAPP_MAX_RCV_PKT_SIZE); + pCtrlBK->SocketRawRRB = open(IAPP_KDP_PIPE_ETH, O_RDWR, 0); + if (pCtrlBK->SocketRawRRB < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open a PIPE RRB failed!\n")); + goto label_fail; + } /* End of if */ + } +#endif // IAPP_OS_VXWORKS // + + /* open IOCTL socket */ + if ((pCtrlBK->SocketIoctl = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { + goto label_fail; + } /* End of if */ + + /* Open TCP socket for accepting connection from other AP */ + if ((pCtrlBK->SocketTcpRcv = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open TcpSocketForOtherAP failed!\n")); + goto label_fail; + } /* End of if */ + + /* bind the Rcv TCP socket */ + IAPP_MEM_ZERO(&AddrTcp, sizeof(AddrTcp)); + AddrTcp.sin_family = AF_INET; + AddrTcp.sin_addr.s_addr = htonl(INADDR_ANY); + AddrTcp.sin_port = htons(IAPP_TCP_PORT); + + if (bind(pCtrlBK->SocketTcpRcv, (struct sockaddr *)&AddrTcp, + sizeof(AddrTcp)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Bind Rcv TCP failed!\n")); + goto label_fail; + } /* End of if */ + + listen(pCtrlBK->SocketTcpRcv, 10); /* max 10 TCP connections simultaneously */ + +#ifdef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX + /* open a socket receiving message from driver */ + if ((pCtrlBK->SocketRawDrv = + socket(PF_PACKET, SOCK_RAW, htons(IAPP_ETH_PRO))) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open RAW DRV socket failed!\n")); + goto label_fail; + } /* End of if */ + + /* bind RAW socket to pCtrlBK->IfNameEth (br-lan) */ + IAPP_MEM_MOVE(ReqIf.ifr_name, pCtrlBK->IfNameWlan, IFNAMSIZ); + + if (ioctl(pCtrlBK->SocketRawDrv, SIOCGIFINDEX, &ReqIf) != 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> ioctl(SIOCGIFINDEX) failed 2!\n")); + goto label_fail; + } /* End of if */ + + IAPP_MEM_ZERO(&AddrRaw, sizeof(AddrRaw)); + AddrRaw.sll_family = AF_PACKET; + AddrRaw.sll_ifindex = ReqIf.ifr_ifindex; + + if (bind(pCtrlBK->SocketRawDrv, (struct sockaddr *)&AddrRaw, + sizeof(AddrRaw)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Bind RAW DRV socket failed!\n")); + goto label_fail; + } /* End of if */ +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifndef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX + pipe(pCtrlBK->PipeRawDrv); + + if ((pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ] < 0) || + (pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_WRITE] < 0)) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open raw drv pipe failed!\n")); + goto label_fail; + } /* End of if */ +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + + return TRUE; + +label_fail: + IAPP_SocketClose(pCtrlBK); + return FALSE; +} /* End of IAPP_SocketOpen */ + +/* +======================================================================== +Routine Description: + Start IAPP daemon. + +Arguments: + *pCtrlBK - IAPP control blcok + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_Start(IAPP_IN RTMP_IAPP *pCtrlBK) { +#ifdef IAPP_EVENT_LOG + struct timeval now, backuptime, res; + MsgSubType msg; + INT32 flag = IPC_NOWAIT; + INT32 msglen; +#endif // IAPP_EVENT_LOG // + + /* init */ + pCtrlBK->FlgIsTerminated = 0; + +#ifdef IAPP_EVENT_LOG + gettimeofday(&backuptime, NULL); + IAPP_EventLogClean(); +#endif // IAPP_EVENT_LOG // + + mt_iapp_ft_client_table_init(pCtrlBK); + + /* waiting for local AP SysCmd or peer AP IAPP packets */ + while (!pCtrlBK->FlgIsTerminated) { +#ifdef IAPP_EVENT_LOG + /* check for message from 8021X daemon (no sleep) */ + if ((msglen = msgrcv(rtmpiapp.MsgId, &msg, sizeof(MsgSubType), + RADIUSMSGQUEID, flag)) > 0) { + IAPP_MsgProcess(&msg, msglen); + } /* End of if */ + + /* implement timer function */ + gettimeofday(&now, NULL); + timersub(&now, &backuptime, &res); + + /* 1s periodic timer to write events */ + if ((res.tv_sec >= 1000) /* || (res.tv_usec >= 100000)*/) { + backuptime = now; + IAPP_EventLog_Query(); + } /* End of if */ +#endif // IAPP_EVENT_LOG // + + /* CPU suspend will be done in IAPP_RcvHandler() */ + IAPP_RcvHandler(pCtrlBK, 0); + } /* End of while */ + +#ifdef IAPP_EVENT_LOG + /* clean all events */ + IAPP_EventLogClean(); +#endif // IAPP_EVENT_LOG // +} /* End of IAPP_Start */ + +/* +======================================================================== +Routine Description: + Send out a IAPP UDP packet. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPkt - the UDP packet + PktLen - the packet size + *pRspBuf - used to issue response to the peer + +Return Value: + TRUE - send successfully + FAIL - send fail + +Note: +======================================================================== +*/ +static BOOLEAN IAPP_UDP_PacketSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPkt, IAPP_IN UINT32 PktLen, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx) { + struct sockaddr_in AddrMulticast; + RT_IAPP_HEADER *pIappHdr; + UINT16 Identifier; + UCHAR *pBufEncrypt; + BOOLEAN Status; + UINT32 total_len; + + /* init */ + pIappHdr = (RT_IAPP_HEADER *)pPkt; + Status = TRUE; + + /* for identification of the request/response packet */ + Identifier = IAPP_IDENTIFIER_GET(pCtrlBK); + pIappHdr->Identifier = SWAP_16(Identifier); + + pCtrlBK->PacketIdentifier++; + + IAPP_MEM_ZERO(&AddrMulticast, sizeof(AddrMulticast)); + AddrMulticast.sin_family = AF_INET; + // AddrMulticast.sin_addr.s_addr = inet_addr(IAPP_MULTICAST_ADDR); + AddrMulticast.sin_addr.s_addr = pCtrlBK->AddrBroadcast.s_addr; + AddrMulticast.sin_port = htons(IAPP_UDP_PORT); + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufEncrypt, + PktLen + IAPP_SECURITY_EXTEND_LEN + ETH_ALEN); + if (pBufEncrypt == NULL) + return FALSE; + /* End of if */ + IAPP_MEM_MOVE(pBufEncrypt, pPkt, PktLen); + IAPP_MEM_MOVE(pBufEncrypt + PktLen, pCtrlBK->IfNameWlanMAC[if_idx], ETH_ALEN); + total_len = PktLen + ETH_ALEN; + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to encrypt */ + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pBufEncrypt, &total_len, if_idx, + RT_FT_DATA_ENCRYPT); +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + /* send out the packet */ + if (sendto(pCtrlBK->SocketUdpSend, pBufEncrypt, total_len, 0, + (struct sockaddr *)&AddrMulticast, + sizeof(AddrMulticast)) != (total_len)) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send UDP packet failed!\n")); + Status = FALSE; + } /* End of if */ + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> Send UDP packet ok (Len = %d)\n\n", total_len)); + return Status; +} /* End of IAPP_UDP_PacketSend */ + +/* +======================================================================== +Routine Description: + Handle received IAPP UDP packets. + +Arguments: + *pCtrlBK - IAPP control blcok + Sig - no use + +Return Value: + None + +Note: +======================================================================== +*/ +VOID IAPP_RcvHandler(IAPP_IN RTMP_IAPP *pCtrlBK, IAPP_IN INT32 Sig) { + UCHAR *pPktBuf, *pCmdBuf, *pRspBuf; +#if 0 + UCHAR *pIpHdr; +#endif + fd_set FdSet; + INT32 SockMax; +#ifdef FT_KDP_SELECT_TIMEOUT + struct timeval Timeout; +#endif // FT_KDP_SELECT_TIMEOUT // + + /* sanity check */ + if (pCtrlBK->FlgIsRcvRunning == TRUE) + return; /* the handler function is running */ + /* End of if */ + + /* init */ + pPktBuf = NULL; + pCmdBuf = NULL; + pRspBuf = NULL; + + /* allocate packet & cmd Buffer */ + IAPP_MEM_ALLOC(pPktBuf, IAPP_MAX_RCV_PKT_SIZE + IAPP_MAX_RCV_PKT_SIZE_SAFE); + if (pPktBuf == NULL) { + printf("Allocate packet buffer fail!\n"); + goto LabelExit; + } /* End of if */ + + IAPP_MEM_ALLOC(pCmdBuf, IAPP_MAX_RCV_PKT_SIZE + IAPP_MAX_RCV_PKT_SIZE_SAFE); + if (pCmdBuf == NULL) { + printf("Allocate command buffer fail!\n"); + goto LabelExit; + } /* End of if */ + + IAPP_MEM_ALLOC(pRspBuf, IAPP_MAX_RCV_PKT_SIZE + IAPP_MAX_RCV_PKT_SIZE_SAFE); + if (pRspBuf == NULL) { + printf("Allocate response buffer fail!\n"); + goto LabelExit; + } /* End of if */ + + /* init */ + pCtrlBK->FlgIsRcvRunning = TRUE; + SockMax = pCtrlBK->SocketUdpSend; + + if (pCtrlBK->SocketTcpRcv > pCtrlBK->SocketUdpSend) + SockMax = pCtrlBK->SocketTcpRcv; + /* End of if */ + +#ifdef FT_KDP_FUNC_SOCK_COMM + if (pCtrlBK->SocketRawDrv > SockMax) + SockMax = pCtrlBK->SocketRawDrv; + /* End of if */ +#endif // FT_KDP_FUNC_SOCK_COMM // + + if (pCtrlBK->SocketRawRRB > SockMax) + SockMax = pCtrlBK->SocketRawRRB; + /* End of if */ + +#ifndef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX + if (pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ] > SockMax) + SockMax = pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ]; + /* End of if */ +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + + /* waiting for any UDP packet */ + while (1) { + /* must re- FD_SET before each select() */ + FD_ZERO(&FdSet); + + FD_SET(pCtrlBK->SocketUdpSend, &FdSet); + FD_SET(pCtrlBK->SocketTcpRcv, &FdSet); + FD_SET(pCtrlBK->SocketRawRRB, &FdSet); + +#ifdef FT_KDP_FUNC_SOCK_COMM + FD_SET(pCtrlBK->SocketRawDrv, &FdSet); +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifndef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX + FD_SET(pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ], &FdSet); +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifdef FT_KDP_SELECT_TIMEOUT + IAPP_MEM_ZERO(&Timeout, sizeof(Timeout)); + Timeout.tv_sec = IAPP_SELECT_TIMEOUT; + Timeout.tv_usec = 0; + + if (select(SockMax + 1, &FdSet, NULL, NULL, &Timeout) < 0) + break; + /* End of if */ +#else + + /* must use SockMax+1, not SockMax */ + if (select(SockMax + 1, &FdSet, NULL, NULL, NULL) < 0) + break; + /* End of if */ +#endif // FT_KDP_SELECT_TIMEOUT // + + /* handle packets from UDP layer */ + if (FD_ISSET(pCtrlBK->SocketUdpSend, &FdSet)) + IAPP_RcvHandlerUdp(pCtrlBK, pPktBuf, pCmdBuf, pRspBuf); + /* End of if */ + + /* handle packets from TCP layer */ + if (FD_ISSET(pCtrlBK->SocketTcpRcv, &FdSet)) + IAPP_RcvHandlerTcp(pCtrlBK, pPktBuf, pCmdBuf, pRspBuf); + /* End of if */ + + if (FD_ISSET(pCtrlBK->SocketRawRRB, &FdSet)) + IAPP_RcvHandlerRawRRB(pCtrlBK, pPktBuf, pCmdBuf, pRspBuf); + /* End of if */ + +#ifdef FT_KDP_FUNC_SOCK_COMM + if (FD_ISSET(pCtrlBK->SocketRawDrv, &FdSet)) + IAPP_RcvHandlerRawDrv(pCtrlBK, pPktBuf, pCmdBuf, pRspBuf); + /* End of if */ +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifndef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX + if (FD_ISSET(pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ], &FdSet)) { + UINT32 CmdLen; + + CmdLen = read(pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_READ], pPktBuf, + IAPP_MAX_RCV_PKT_SIZE); + if (CmdLen > 0) { + /* handle the signal context, assoicate or reassociate or terminate */ + IAPP_SIG_Process((RT_SIGNAL_STRUC *)pPktBuf, CmdLen, pCmdBuf, pRspBuf); + } /* End of if */ + } /* End of if */ +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + }; + +LabelExit: + if (pPktBuf != NULL) + IAPP_MEM_FREE(pPktBuf); + /* End of if */ + if (pCmdBuf != NULL) + IAPP_MEM_FREE(pCmdBuf); + /* End of if */ + if (pRspBuf != NULL) + IAPP_MEM_FREE(pRspBuf); + /* End of if */ + pCtrlBK->FlgIsRcvRunning = FALSE; +} /* End of IAPP_RcvHandler */ + +/* +======================================================================== +Routine Description: + Handle received IAPP TCP packets. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPktBuf - packet buffer + *pCmdBuf - used to issue command to WLAN driver + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_RcvHandlerTcp(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf) { + struct sockaddr_in AddrPeer; + RT_IAPP_HEADER *pIappHdr; + INT32 SockNew; + socklen_t Length; + INT32 SizeRcvMsg; + INT32 if_idx = 0; + // UCHAR WifiMAC[ETH_ALEN] = {0}; + + /* init */ + IAPP_MEM_ZERO(&AddrPeer, sizeof(AddrPeer)); + Length = sizeof(struct sockaddr_in); + + SockNew = + accept(pCtrlBK->SocketTcpRcv, (struct sockaddr *)&AddrPeer, &Length); + if (SockNew < 0) + return; /* no any new connection */ + /* End of if */ + + /* handle the packet */ + SizeRcvMsg = read(SockNew, pPktBuf, IAPP_MAX_RCV_PKT_SIZE); + close(SockNew); + + if (SizeRcvMsg > 0) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Recv TCP successfully from %d.%d.%d.%d\n", + IAPP_SHOW_IP(AddrPeer.sin_addr.s_addr))); + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to decrypt */ + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pPktBuf, &SizeRcvMsg, 0, + RT_FT_DATA_DECRYPT); +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + /* get IAPP frame body */ + pIappHdr = (RT_IAPP_HEADER *)(pPktBuf); + + if (pIappHdr->Version != IAPP_VERSION) { + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> IAPP version not match %d!\n", pIappHdr->Version)); + IAPP_HEX_DUMP("Wrong TCP Frame Content: ", pPktBuf, SizeRcvMsg); + return; /* version not match */ + } /* End of if */ + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> IAPP SysCmd = %d\n", pIappHdr->Command)); + + switch (pIappHdr->Command) { + case IAPP_CMD_MOVE_NOTIFY: + IAPP_RcvHandlerMoveReq(pCtrlBK, (UCHAR *)pIappHdr, + AddrPeer.sin_addr.s_addr, pCmdBuf, pRspBuf); + break; + + case IAPP_CMD_MOVE_RESPONSE: { + /* + If the received sequence number does not represent a more + recent association than that at the AP where the + IAPPMOVE.indication is received, the APME should ignore the + indicated reassociation, the APME should issue an + IAPP-MOVE.response with a status of STALE_MOVE that will + cause an IAPP MOVE-response packet to be sent to the AP + that originated the IAPP MOVE-notify packet, and the APME + should issue an IAPPADD.request primitive of its own to + ensure that all Layer 2 devices are properly informed of + the correct location of the STA’s most recent association. + */ + + DBGPRINT( + RT_DEBUG_TRACE, + ("iapp> Receive IAPP_CMD_MOVE_RESPONSE! (size = %d)\n", SizeRcvMsg)); + + /* not yet implement */ + } break; + + case IAPP_CMD_FT_SEND_SECURITY_BLOCK: + IAPP_RcvHandlerSSB(pCtrlBK, (UCHAR *)pIappHdr, AddrPeer.sin_addr.s_addr, + pCmdBuf); + break; + + case IAPP_CMD_FT_ACK_SECURITY_BLOCK: { + RT_IAPP_SEND_SECURITY_BLOCK *pAckSB; + UCHAR *pBufMsg; + UINT32 BufLen; + POID_REQ OidReq; + INT32 idx; + + /* init */ + pAckSB = (RT_IAPP_SEND_SECURITY_BLOCK *)pIappHdr; + + BufLen = sizeof(OID_REQ); + BufLen += FT_IP_ADDRESS_SIZE + IAPP_SB_INIT_VEC_SIZE + pAckSB->Length; + + IAPP_CMD_BUF_ALLOCATE(pCmdBuf, pBufMsg, BufLen); + if (pBufMsg == NULL) + break; + /* End of if */ + + /* command to notify that a Key Req is received */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> IAPP_CMD_FT_ACK_SECURITY_BLOCK\n")); + + OidReq = (POID_REQ)pBufMsg; + OidReq->OID = (RT_SET_FT_KEY_RSP | OID_GET_SET_TOGGLE); + + /* peer IP address */ + IAPP_MEM_MOVE(OidReq->Buf, &(AddrPeer.sin_addr.s_addr), + FT_IP_ADDRESS_SIZE); + + /* IP & nonce & security block */ + IAPP_MEM_MOVE(OidReq->Buf + FT_IP_ADDRESS_SIZE, pAckSB->InitVec, + IAPP_SB_INIT_VEC_SIZE); + IAPP_MEM_MOVE(OidReq->Buf + FT_IP_ADDRESS_SIZE + IAPP_SB_INIT_VEC_SIZE, + pAckSB->SB, pAckSB->Length); + + OidReq->Len = BufLen - sizeof(OID_REQ); + + /* + send to all wifi 11r interface. + */ + for (idx = 0; idx < pCtrlBK->IfNameWlanCount; idx++) { + IAPP_MsgProcess(pCtrlBK, IAPP_SET_OID_REQ, pBufMsg, BufLen, idx); + } + } break; + + case IAPP_CMD_INFO_RESPONSE: + IAPP_RcvHandlerApInfor(pCtrlBK, IAPP_INFO_TYPE_RSP, (UCHAR *)pIappHdr, + AddrPeer.sin_addr.s_addr, pCmdBuf, if_idx); + break; + + default: + IAPP_HEX_DUMP("Wrong TCP Frame Content: ", pPktBuf, SizeRcvMsg); + break; + } + } /* End of if */ +} /* End of IAPP_RcvHandlerTcp */ + +/* +======================================================================== +Routine Description: + Handle received IAPP Move Request packet. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPktBuf - packet buffer + PeerIP - the peer IP address + *pCmdBuf - used to issue command to WLAN driver + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_RcvHandlerMoveReq(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, + IAPP_IN UINT32 PeerIP, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf) { + /* + In IAPP, when the Status is not SUCCESSFUL, the APME should + disassociate the STA indicated by the MAC Address + parameter, using the 802.11 MLME-DISASSOCIATE.request + primitive with a Reason Code of 1, meaning "Unspecified + Reason." Future revisions of the IEEE Std 802.11 may define + a new Reason Code that means "Old AP did not verify + previous association." + */ + RT_IAPP_MOVE_NOTIFY *pNotify; + RT_IAPP_MOVE_RSP *pRsp; + UCHAR *pBufMsg; + UINT32 BufLen; + POID_REQ OidReq; + INT32 if_idx; + + /* sanity check */ + pNotify = (RT_IAPP_MOVE_NOTIFY *)pPktBuf; + + if (SWAP_16(pNotify->IappHeader.Length) != sizeof(RT_IAPP_MOVE_NOTIFY)) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Len %d != Move Request Len %d!\n", + SWAP_16(pNotify->IappHeader.Length), + sizeof(RT_IAPP_MOVE_NOTIFY))); + return; + } /* End of if */ + + /* delete MAC Entry when receive a add-notify packet */ + BufLen = sizeof(OID_REQ); + BufLen += ETH_ALEN; + + IAPP_CMD_BUF_ALLOCATE(pCmdBuf, pBufMsg, BufLen); + if (pBufMsg == NULL) + return; + /* End of if */ + + OidReq = (POID_REQ)pBufMsg; + OidReq->OID = (RT_SET_DEL_MAC_ENTRY | OID_GET_SET_TOGGLE); + IAPP_MEM_MOVE(OidReq->Buf, pNotify->MacAddr, ETH_ALEN); + OidReq->Len = BufLen - sizeof(OID_REQ); + + if_idx = + mt_iapp_find_ifidx_by_sta_mac(&pCtrlBK->SelfFtStaTable, pNotify->MacAddr); + if (if_idx < 0) { + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> %s: cannot find wifi interface.\n", __FUNCTION__)); + return; + } + + /* + Note: RALINK AP driver delete the STATION MAC by MAC + address, do NOT care which BSS index. + */ + IAPP_MsgProcess(pCtrlBK, IAPP_SET_OID_REQ, pBufMsg, BufLen, if_idx); + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> (Receive IAPP_CMD_MOVE_NOTIFY for " + "%02x:%02x:%02x:%02x:%02x:%02x)\n", + pNotify->MacAddr[0], pNotify->MacAddr[1], pNotify->MacAddr[2], + pNotify->MacAddr[3], pNotify->MacAddr[4], pNotify->MacAddr[5])); + + /* reponse the MOVE request */ + pRsp = (RT_IAPP_MOVE_RSP *)pNotify; + pRsp->IappHeader.Command = IAPP_CMD_MOVE_RESPONSE; + pRsp->Status = IAPP_MOVE_RSP_STATUS_SUCCESS; + + IAPP_TCP_PACKET_SEND(pCtrlBK, pRsp, sizeof(RT_IAPP_MOVE_RSP), PeerIP, TRUE, + pRspBuf, if_idx); + + mt_iapp_ft_client_delete(&pCtrlBK->SelfFtStaTable, pNotify->MacAddr); + +} /* End of IAPP_RcvHandlerMoveReq */ + +/* +======================================================================== +Routine Description: + Handle received IAPP Security Send Block packet. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPktBuf - packet buffer + PeerIP - the peer IP address + *pCmdBuf - used to issue command to WLAN driver + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_RcvHandlerSSB(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, IAPP_IN UINT32 PeerIP, + IAPP_IN UCHAR *pCmdBuf) { + RT_IAPP_SEND_SECURITY_BLOCK *pSendSB; + UCHAR *pBufMsg; + UINT32 BufLen, if_idx; + POID_REQ OidReq; + FT_KDP_EVT_KEY_ELM kdp_info; + + /* init */ + pSendSB = (RT_IAPP_SEND_SECURITY_BLOCK *)pPktBuf; + + BufLen = sizeof(OID_REQ); + BufLen += FT_IP_ADDRESS_SIZE + IAPP_SB_INIT_VEC_SIZE + pSendSB->Length; + + IAPP_CMD_BUF_ALLOCATE(pCmdBuf, pBufMsg, BufLen); + if (pBufMsg == NULL) + return; + /* End of if */ + + /* command to notify that a Key Req is received */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> IAPP_RcvHandlerSSB\n")); + + OidReq = (POID_REQ)pBufMsg; + OidReq->OID = (RT_SET_FT_KEY_REQ | OID_GET_SET_TOGGLE); + + /* peer IP address */ + IAPP_MEM_MOVE(OidReq->Buf, &PeerIP, FT_IP_ADDRESS_SIZE); + + /* nonce & security block */ + IAPP_MEM_MOVE(OidReq->Buf + FT_IP_ADDRESS_SIZE, pSendSB->InitVec, + IAPP_SB_INIT_VEC_SIZE); + IAPP_MEM_MOVE(OidReq->Buf + FT_IP_ADDRESS_SIZE + IAPP_SB_INIT_VEC_SIZE, + pSendSB->SB, pSendSB->Length); + IAPP_MEM_MOVE(&kdp_info, pSendSB->SB, pSendSB->Length); + IAPP_HEX_DUMP("kdp_info.MacAddr", kdp_info.MacAddr, ETH_ALEN); + if_idx = + mt_iapp_find_ifidx_by_sta_mac(&pCtrlBK->SelfFtStaTable, kdp_info.MacAddr); + if (if_idx < 0) { + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> %s: cannot find wifi interface\n", __FUNCTION__)); + return; + } + + OidReq->Len = BufLen - sizeof(OID_REQ); + + IAPP_MsgProcess(pCtrlBK, IAPP_SET_OID_REQ, pBufMsg, BufLen, if_idx); + +#ifndef FT_KDP_FUNC_SOCK_COMM + /* + Note: in VxWorks, we can not send any signal to same task + which issues a ioctl path. + + So we poll the event automatically. + */ + /* receive event */ + IAPP_USR2Handle(0, if_idx); +#endif // FT_KDP_FUNC_SOCK_COMM // +} /* End of IAPP_RcvHandlerSSB */ + +/* +======================================================================== +Routine Description: + Handle received IAPP AP Information BC/REQ/RSP packet. + +Arguments: + *pCtrlBK - IAPP control blcok + Type - IAPP_INFO_TYPE_BC, IAPP_INFO_TYPE_REQ, +IAPP_INFO_TYPE_RSP *pPktBuf - packet buffer PeerIP - the peer IP +address *pCmdBuf - used to issue command to WLAN driver + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_RcvHandlerApInfor(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR Type, IAPP_IN UCHAR *pPktBuf, + IAPP_IN UINT32 PeerIP, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN INT32 if_idx) { + RT_IAPP_INFORMATION *pApIB; + UCHAR *pBufMsg; + UINT32 BufLen; + POID_REQ OidReq; + INT32 OID[IAPP_INFO_TYPE_MAX_NUM] = { + RT_FT_NEIGHBOR_REPORT, RT_FT_NEIGHBOR_REQUEST, RT_FT_NEIGHBOR_RESPONSE}; + + /* sanity check */ + if (Type >= IAPP_INFO_TYPE_MAX_NUM) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Wrong Info Type %d\n", Type)); + return; + } /* End of if */ + + /* init */ + pApIB = (RT_IAPP_INFORMATION *)pPktBuf; + + BufLen = sizeof(OID_REQ); + BufLen += FT_IP_ADDRESS_SIZE + pApIB->Length; + + IAPP_CMD_BUF_ALLOCATE(pCmdBuf, pBufMsg, BufLen); + if (pBufMsg == NULL) + return; + /* End of if */ + + /* command to notify that a Key Req is received */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> IAPP_RcvHandlerApInfor %d\n", Type)); + + OidReq = (POID_REQ)pBufMsg; + OidReq->OID = (OID[Type] | OID_GET_SET_TOGGLE); + + /* peer IP address & information block */ + IAPP_MEM_MOVE(OidReq->Buf, &PeerIP, FT_IP_ADDRESS_SIZE); + IAPP_MEM_MOVE(OidReq->Buf + FT_IP_ADDRESS_SIZE, pApIB->IB, pApIB->Length); + OidReq->Len = BufLen - sizeof(OID_REQ); + + IAPP_MsgProcess(pCtrlBK, IAPP_SET_OID_REQ, pBufMsg, BufLen, if_idx); + +#ifndef FT_KDP_FUNC_SOCK_COMM + /* + Note: in VxWorks, we can not send any signal to same task + which issues a ioctl path. + + So we poll the event automatically. + */ + /* receive event */ + IAPP_USR2Handle(0, if_idx); +#endif // FT_KDP_FUNC_SOCK_COMM // +} /* End of IAPP_RcvHandlerApInfor */ + +#ifdef FT_KDP_FUNC_SOCK_COMM +/* +======================================================================== +Routine Description: + Handle received IAPP RAW packets from WLAN driver. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPktBuf - packet buffer + *pCmdBuf - used to issue command to WLAN driver + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_RcvHandlerRawDrv(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf) { + RT_SIGNAL_STRUC *pSignal; + INT32 SizeRcvMsg; + +#ifdef IAPP_OS_LINUX + struct sockaddr_in AddrPeer; + socklen_t Length; + + /* init */ + IAPP_MEM_ZERO(&AddrPeer, sizeof(AddrPeer)); + Length = sizeof(struct sockaddr_in); + + SizeRcvMsg = recvfrom(pCtrlBK->SocketRawDrv, pPktBuf, IAPP_MAX_RCV_PKT_SIZE, + 0, (struct sockaddr *)&AddrPeer, &Length); +#endif // IAPP_OS_LINUX // + +#ifdef IAPP_OS_VXWORKS + SizeRcvMsg = + read(pCtrlBK->SocketRawDrv, (CHAR *)pPktBuf, IAPP_MAX_RCV_PKT_SIZE); +#endif // IAPP_OS_VXWORKS // + + /* handle the packet */ + if (SizeRcvMsg > 0) { + UCHAR WifiMAC[ETH_ALEN]; + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Recvfrom RAW CMD successfully (%d, %d)!\n", + IAPP_MemAllocNum, IAPP_MemFreeNum)); + + NdisZeroMemory(WifiMAC, ETH_ALEN); + NdisCopyMemory(WifiMAC, pPktBuf, ETH_ALEN); + + /* handle the signal context, assoicate or reassociate or terminate */ + pSignal = (RT_SIGNAL_STRUC *)(pPktBuf + sizeof(FT_ETH_HEADER)); + IAPP_SIG_Process(pCtrlBK, WifiMAC, pSignal, SizeRcvMsg, pCmdBuf, pRspBuf); + } /* End of if */ +} /* End of IAPP_RcvHandlerRawDrv */ + +/* +======================================================================== +Routine Description: + Handle received RRB RAW packets from LAN. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPktBuf - packet buffer + *pCmdBuf - used to issue command to WLAN driver + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_RcvHandlerRawRRB(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, + IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf) { + INT32 SizeRcvMsg; + UCHAR *pBufMsg; + POID_REQ OidReq; + FT_RRB_FRAME *pFrameRRB; + +#ifdef IAPP_OS_LINUX + struct sockaddr_in AddrPeer; + socklen_t Length; + + /* init */ + IAPP_MEM_ZERO(&AddrPeer, sizeof(AddrPeer)); + Length = sizeof(struct sockaddr_in); + + SizeRcvMsg = recvfrom(pCtrlBK->SocketRawRRB, pPktBuf, IAPP_MAX_RCV_PKT_SIZE, + 0, (struct sockaddr *)&AddrPeer, &Length); +#endif // IAPP_OS_LINUX // + +#ifdef IAPP_OS_VXWORKS + SizeRcvMsg = + read(pCtrlBK->SocketRawRRB, (CHAR *)pPktBuf, IAPP_MAX_RCV_PKT_SIZE); +#endif // IAPP_OS_VXWORKS // + + /* handle the packet */ + if (SizeRcvMsg > 0) { + INT32 wifi_if_idx = 0; + UCHAR WifiMAC[ETH_ALEN]; + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> Recvfrom RRB RAW successfully! (len = %d)\n", SizeRcvMsg)); + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to decrypt */ + pFrameRRB = (FT_RRB_FRAME *)pPktBuf; + + if ((wifi_if_idx = mt_iapp_find_ifidx_by_mac(pCtrlBK, pPktBuf)) == -1) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> %s - Daemon doesn't hook this wifi " + "interface. Ignore this packet.\n", + __FUNCTION__)); + IAPP_HEX_DUMP("802.3 Hdr: ", pPktBuf, 14); + return; + } + NdisZeroMemory(WifiMAC, ETH_ALEN); + NdisCopyMemory(WifiMAC, pPktBuf, ETH_ALEN); + + /* + Note: Can not use "SizeRcvMsg - FT_RRB_HEADER_SIZE" to get the + encrypted data length, because when the ethernet frame length + < 64B and ethernet driver will fill 0 to the end of the frame, + we will get the wrong the encrypted data length. + */ + SizeRcvMsg = pFrameRRB->FTActionLength; + IAPP_ENCRYPTED_DATA_SIZE_CAL(SizeRcvMsg); + + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pPktBuf + FT_RRB_HEADER_SIZE, + &SizeRcvMsg, wifi_if_idx, RT_FT_DATA_DECRYPT); + + SizeRcvMsg += FT_RRB_HEADER_SIZE; +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + IAPP_CMD_BUF_ALLOCATE(pCmdBuf, pBufMsg, (sizeof(OID_REQ) + SizeRcvMsg)); + if (pBufMsg == NULL) + return; + /* End of if */ + + OidReq = (POID_REQ)pBufMsg; + OidReq->OID = (RT_FT_ACTION_FORWARD | OID_GET_SET_TOGGLE); + + /* nonce & security block */ + IAPP_MEM_MOVE(OidReq->Buf, pPktBuf, SizeRcvMsg); + OidReq->Len = SizeRcvMsg; + + IAPP_MsgProcess(pCtrlBK, IAPP_SET_OID_REQ, pBufMsg, + (sizeof(OID_REQ) + SizeRcvMsg), wifi_if_idx); + } /* End of if */ +} /* End of IAPP_RcvHandlerRawRRB */ + +#ifdef IAPP_OS_VXWORKS +/* +======================================================================== +Routine Description: + Handle received IAPP RAW packets from WLAN driver. + +Arguments: + *pCookie - protocol/device binding from muxBind() + Type - Protocol type + *pMblk - The whole packet + *pSpareData - pointer to link level header info + *pSpare - spare pointer from muxBind() + +Return Value: + None + +Note: +======================================================================== +*/ +BOOLEAN IAPP_RcvHandlerRawDrvVxWorks(IAPP_IN void *pCookie, IAPP_IN long Type, + IAPP_IN M_BLK_ID pMblk, + IAPP_IN LL_HDR_INFO *pLinkHdrInfo, + IAPP_IN void *pSpare) { + RTMP_IAPP *pCtrlBK = (RTMP_IAPP *)pSpare; + + if ((pCtrlBK != NULL) && (pMblk != NULL)) { + /* handle the signal context, assoicate or reassociate or terminate */ + write(pCtrlBK->SocketRawDrv, (CHAR *)pMblk->mBlkHdr.mData, + pMblk->mBlkHdr.mLen); + + /* free the Mblk */ + netMblkClChainFree(pMblk); + } /* End of if */ + + return TRUE; +} /* End of IAPP_RcvHandlerRawDrvVxWorks */ + +/* +======================================================================== +Routine Description: + Handle received IAPP RAW RRB packets from ethernet driver. + +Arguments: + *pCookie - protocol/device binding from muxBind() + Type - Protocol type + *pMblk - The whole packet + *pSpareData - pointer to link level header info + *pSpare - spare pointer from muxBind() + +Return Value: + None + +Note: +======================================================================== +*/ +BOOLEAN IAPP_RcvHandlerRawRRBVxWorks(IAPP_IN void *pCookie, IAPP_IN long Type, + IAPP_IN M_BLK_ID pMblk, + IAPP_IN LL_HDR_INFO *pLinkHdrInfo, + IAPP_IN void *pSpare) { + RTMP_IAPP *pCtrlBK = (RTMP_IAPP *)pSpare; + + if ((pCtrlBK != NULL) && (pMblk != NULL)) { + /* handle the signal context, assoicate or reassociate or terminate */ + write(pCtrlBK->SocketRawRRB, (CHAR *)pMblk->mBlkHdr.mData, + pMblk->mBlkHdr.mLen); + + /* free the Mblk */ + netMblkClChainFree(pMblk); + } /* End of if */ + + return TRUE; +} /* End of IAPP_RcvHandlerRawRRBVxWorks */ +#endif // IAPP_OS_VXWORKS // +#endif // FT_KDP_FUNC_SOCK_COMM // + +/* +======================================================================== +Routine Description: + Handle received IAPP UDP packets. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPktBuf - packet buffer + *pCmdBuf - used to issue command to WLAN driver + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_RcvHandlerUdp(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN UCHAR *pPktBuf, IAPP_IN UCHAR *pCmdBuf, + IAPP_IN UCHAR *pRspBuf) { + struct sockaddr_in AddrPeer; + RT_IAPP_HEADER *pIappHdr; + INT32 SizeRcvMsg; +#if 0 + UCHAR *pIpHdr; +#endif + socklen_t Length; + INT32 if_idx = -1, idx; + + /* init */ + IAPP_MEM_ZERO(&AddrPeer, sizeof(AddrPeer)); + Length = sizeof(struct sockaddr_in); + + SizeRcvMsg = recvfrom(pCtrlBK->SocketUdpSend, pPktBuf, IAPP_MAX_RCV_PKT_SIZE, + 0, (struct sockaddr *)&AddrPeer, &Length); + + /* handle the packet */ + if (SizeRcvMsg > 0) { + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> Recvfrom UDP (len%d) successfully from %d.%d.%d.%d\n", + SizeRcvMsg, IAPP_SHOW_IP(AddrPeer.sin_addr.s_addr))); + +#ifndef IAPP_TEST + if (AddrPeer.sin_addr.s_addr == pCtrlBK->AddrOwn.s_addr) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Skip packet from us!\n\n")); + return; /* same IP source address */ + } /* End of if */ +#endif // IAPP_TEST // + +#if 0 + /* find the IP header */ + pIpHdr = pPktBuf + IAPP_IP_HEADER_OFFSET; + + /* skip non UDP packets */ + if (pIpHdr[IAPP_IP_PROTO_OFFSET] != IAPP_IP_PROTO_UDP) + continue; /* the IP packet is not UDP */ + /* End of if */ + + /* + Because we dont bind RCV port to 3517, so we need to + its check UDP dest port, must be 3517. + */ + if (*((UINT16 *)(pIpHdr+IAPP_UDP_DST_PORT_OFFSET)) != + ntohs(IAPP_UDP_PORT)) + { + continue; /* not for us */ + } /* End of if */ + + /* get IAPP frame body */ + pIappHdr = (RT_IAPP_HEADER *)(pPktBuf + IAPP_MAC_IP_UDP_LEN); +#endif + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to decrypt */ + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pPktBuf, &SizeRcvMsg, 0, + RT_FT_DATA_DECRYPT); +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + /* get IAPP frame body */ + pIappHdr = (RT_IAPP_HEADER *)(pPktBuf); + + if (pIappHdr->Version != IAPP_VERSION) { + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> IAPP version not match %d!\n", pIappHdr->Version)); + IAPP_HEX_DUMP("Wrong UDP Frame Content: ", pPktBuf, SizeRcvMsg); + return; /* version not match */ + } /* End of if */ + + // IAPP_HEX_DUMP("UDP Frame Content: ", pPktBuf, SizeRcvMsg); + + /* handle the IAPP */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> IAPP SysCmd = %d\n", pIappHdr->Command)); + + switch (pIappHdr->Command) { + case IAPP_CMD_ADD_NOTIFY: { + RT_IAPP_ADD_NOTIFY *pNotify; + UCHAR *pBufMsg; + UINT32 BufLen; + POID_REQ OidReq; + + /* sanity check for frame length */ + pNotify = (RT_IAPP_ADD_NOTIFY *)pIappHdr; + + if (SWAP_16(pIappHdr->Length) != sizeof(RT_IAPP_ADD_NOTIFY)) { + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> Len 0x%x != ADD Notify Len %d!\n", + SWAP_16(pIappHdr->Length), sizeof(RT_IAPP_ADD_NOTIFY))); + break; + } /* End of if */ + + /* + Upon receipt of this service primitive the APME should + determine if the STA indicated by the MAC Address is shown + to be associated with the AP receiving the + IAPP-ADD.indication, with a sequence number older than that + in the IAPP ADD-notify packet. + + If so, this service primitive should cause the generation + of an 802.11 MLME-DISASSOCIATE.request by the APME. + + If the sequence number received in the IAPP ADD-notify + packet is older than that received from the STA when it + associated with the AP receiving the IAPP ADD-notify packet, + the APME should ignore the indicated association and issue + an IAPPADD.request. + + Implementers of STA MAC entities are advised of the + importance of continuing the sequential assignment of + sequence numbers for outgoing MPDUs and MMPDUs throughout + STA operation, as required by 802.11. + */ + /* not yet implement */ + + BufLen = sizeof(OID_REQ) + FT_IP_ADDRESS_SIZE + ETH_ALEN; + IAPP_CMD_BUF_ALLOCATE(pCmdBuf, pBufMsg, BufLen); + if (pBufMsg == NULL) + break; + + if_idx = mt_iapp_find_ifidx_by_sta_mac(&pCtrlBK->SelfFtStaTable, + pNotify->MacAddr); + + if (if_idx >= 0) { + /* delete MAC Entry when receive a add-notify packet */ + OidReq = (POID_REQ)pBufMsg; + OidReq->OID = (RT_SET_DEL_MAC_ENTRY | OID_GET_SET_TOGGLE); + IAPP_MEM_MOVE(OidReq->Buf, pNotify->MacAddr, ETH_ALEN); + OidReq->Len = ETH_ALEN; + + /* + Note: RALINK AP driver delete the STATION MAC by MAC + address, do NOT care which BSS index. + */ + IAPP_MsgProcess(pCtrlBK, IAPP_SET_OID_REQ, pBufMsg, + (sizeof(INT32) + sizeof(INT32) + ETH_ALEN), if_idx); + } + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> Receive IAPP_CMD_ADD_NOTIFY for " + "%02x:%02x:%02x:%02x:%02x:%02x (size = %d)\n", + pNotify->MacAddr[0], pNotify->MacAddr[1], pNotify->MacAddr[2], + pNotify->MacAddr[3], pNotify->MacAddr[4], pNotify->MacAddr[5], + SizeRcvMsg)); + + /* command to notify that this is for 11r station */ + if (pNotify->Rsvd & FT_KDP_ADD_NOTIFY_RSVD_11R_SUPPORT) { + OidReq = (POID_REQ)pBufMsg; + OidReq->OID = (RT_SET_FT_STATION_NOTIFY | OID_GET_SET_TOGGLE); + + /* peer IP address */ + IAPP_MEM_MOVE(OidReq->Buf, &(AddrPeer.sin_addr.s_addr), + FT_IP_ADDRESS_SIZE); + + /* station MAC */ + IAPP_MEM_MOVE(OidReq->Buf + FT_IP_ADDRESS_SIZE, pNotify->MacAddr, + ETH_ALEN); + + OidReq->Len = FT_IP_ADDRESS_SIZE + ETH_ALEN; + + /* + Send notify to all 11r interface. + */ + for (idx = 0; idx < pCtrlBK->IfNameWlanCount; idx++) { + IAPP_MsgProcess( + pCtrlBK, IAPP_SET_OID_REQ, pBufMsg, + (sizeof(INT32) + sizeof(INT32) + FT_IP_ADDRESS_SIZE + ETH_ALEN), + idx); + } + +#ifndef FT_KDP_FUNC_SOCK_COMM + /* + Note: in VxWorks, we can not send any signal to same task + which issues a ioctl path. + + So we poll the event automatically. + */ + /* receive event */ + IAPP_USR2Handle(0, if_idx); +#endif // FT_KDP_FUNC_SOCK_COMM // + } /* End of if */ + } /* IAPP_CMD_ADD_NOTIFY */ + break; + +#ifdef IAPP_EVENT_LOG + case IAPP_CMD_SECURITY_MONITOR: { + PRT_IAPP_SECURITY_MONITOR SM_p; + + SM_p = (PRT_IAPP_SECURITY_MONITOR)pIappHdr; + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> pkt = IAPP_CMD_SECURITY_MONITOR\n")); + + IAPP_EventLogHandle(&SM_p->EvtTab); + } /* IAPP_CMD_SECURITY_MONITOR */ + break; +#endif // IAPP_EVENT_LOG // + + case IAPP_CMD_MOVE_NOTIFY: + IAPP_RcvHandlerMoveReq(pCtrlBK, (UCHAR *)pIappHdr, + AddrPeer.sin_addr.s_addr, pCmdBuf, pRspBuf); + break; + + case IAPP_CMD_FT_SEND_SECURITY_BLOCK: + IAPP_RcvHandlerSSB(pCtrlBK, (UCHAR *)pIappHdr, AddrPeer.sin_addr.s_addr, + pCmdBuf); + break; + + case IAPP_CMD_INFO_BROADCAST: + IAPP_RcvHandlerApInfor(pCtrlBK, IAPP_INFO_TYPE_BC, (UCHAR *)pIappHdr, + AddrPeer.sin_addr.s_addr, pCmdBuf, if_idx); + break; + + case IAPP_CMD_INFO_REQUEST: + IAPP_RcvHandlerApInfor(pCtrlBK, IAPP_INFO_TYPE_REQ, (UCHAR *)pIappHdr, + AddrPeer.sin_addr.s_addr, pCmdBuf, if_idx); + break; + + default: + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> Unknown IAPP command %d!\n", pIappHdr->Command)); + break; + } /* End of switch(pIappHdr->Command) */ + } /* End of if (SizeRcvMsg > 0) */ +} /* End of IAPP_RcvHandlerUdp */ + +/* +======================================================================== +Routine Description: + Print IAPP deamon usage. + +Arguments: + None + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID IAPP_Usage(VOID) { + printf("\tUSAGE:\t\tmtkiappd <-e eth_if_name> <-w wireless_if_name>\n"); + printf("\t\t\t\t<-k security_key> <-d debug level>\n"); + printf("\tDefault:\tmtkiappd -e br-lan -w ra0 -k zpxrjs9uo2kvbuqo -d 3\n"); +} /* End of IAPP_Usage */ + +/* +======================================================================== +Routine Description: + Handle driver commands from RALINK AP. + +Arguments: + Sig - no use + +Return Value: + None + +Note: + When a station associates or re-associates to RALINK AP, RALINK AP will + use kill_proc() to send SIGUSR2 signal to us. + + Then we should to get the Data content from RALINK AP. +======================================================================== +*/ +static VOID IAPP_USR2Handle(IAPP_IN INT32 Sig) { +#ifndef FT_KDP_FUNC_SOCK_COMM + RT_SIGNAL_STRUC *pSigBuf; + INT32 DataLen; + INT32 if_idx = 0; + + /* get signal context from AP driver */ + DataLen = sizeof(RT_SIGNAL_STRUC); + IAPP_MEM_ALLOC(pSigBuf, DataLen); + if (pSigBuf == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Allocate signal buffer fail!\n")); + return; + } /* End of if */ + + IAPP_IOCTL_TO_WLAN(&IAPP_Ctrl_Block, RT_IOCTL_IAPP, pSigBuf, &DataLen, if_idx, + RT_QUERY_SIGNAL_CONTEXT); + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Receive a signal (Len = %d)!\n", DataLen)); + + /* pass event to raw drv socket */ + if (DataLen > 0) + write(pCtrlBK->PipeRawDrv[FT_KDP_PIPE_ID_WRITE], pSigBuf, DataLen); + /* End of if */ + + IAPP_MEM_FREE(pSigBuf); +#endif // FT_KDP_FUNC_SOCK_COMM // +} /* End of IAPP_USR2Handle */ + +/* +======================================================================== +Routine Description: + Handle termination signal. And we will close IAPP deamon at main(). + +Arguments: + Sig - no use + +Return Value: + None + +Note: + The APME should terminate operation of the local BSS, including + disassociation of any associated STAs and ceasing of beacon +transmissions, prior to terminating IAPP operation. + + The UDP and TCP ports for the IAPP should be closed and the IAPP entity + should cease operations. +======================================================================== +*/ +static VOID IAPP_TerminateHandle(IAPP_IN INT32 Sig) { + /* close all used sockets */ + IAPP_SocketClose(&IAPP_Ctrl_Block); + IAPP_Ctrl_Block.FlgIsTerminated = 1; +} /* End of IAPP_TerminateHandle */ + +/* +======================================================================== +Routine Description: + Main task. + +Arguments: + *pContext - IAPP control block + +Return Value: + None + +Note: +======================================================================== +*/ +VOID IAPP_Task(IAPP_IN VOID *pContext) { + // INT idx = 0; + RTMP_IAPP *pCtrlBK = (RTMP_IAPP *)pContext; + pid_t PidAuth; +//#ifdef IAPP_OS_LINUX +#if 0 + CHAR RouteAddCmd[64]; + CHAR RouteDelCmd[64]; +#endif + + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> (ver.%s) task start...\n", IAPP_DAEMON_VERSION)); + + /* here is the child background process */ + if (IAPP_DSIfInfoGet(pCtrlBK) != TRUE) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Get interfce information failed\n")); + goto label_err; + } /* End of if */ + + /* init IPC message queue with 8021X deamon (obsolete) */ + if (IAPP_IPC_MSG_Init(pCtrlBK) != TRUE) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Setup message failed\n")); + goto label_err; + } /* End of if */ + +//#ifdef IAPP_OS_LINUX +#if 0 + /* add multicast route path, use SysCmd 'route' to show */ + /* + Destination Gateway Genmask Flags Metric Ref Use Iface + 224.0.1.178 * 255.255.255.255 UH 0 0 0 br-lan + */ + sprintf(RouteAddCmd, "route add %s %s\n", + IAPP_MULTICAST_ADDR, pCtrlBK->IfNameEth); + + sprintf(RouteDelCmd, "route del %s %s\n", + IAPP_MULTICAST_ADDR, pCtrlBK->IfNameEth); + + system(RouteAddCmd); +#endif + + /* init RV/TX Sockets */ + /* setup the message queue to be synchronous */ + IAPP_MsgProcess(pCtrlBK, IAPP_OPEN_SERVICE_REQ, NULL, 0, 0); + + pCtrlBK->FlgIsRcvRunning = FALSE; + if (IAPP_SocketOpen(pCtrlBK) == FALSE) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Open Socket failed\n")); +//#ifdef IAPP_OS_LINUX +#if 0 + system(RouteDelCmd); +#endif + goto label_err; + } /* End of if */ + + if (mt_iapp_get_wifi_iface_mac(pCtrlBK) == FALSE) { + goto label_err; + } + + /* init signal functions, driver will use SIGUSR1/2 to inform us */ + signal(SIGINT, IAPP_TerminateHandle); + signal(SIGTERM, IAPP_TerminateHandle); + + /* + Keep IAPP_USR2Handle() even you do not enable FT_KDP_FUNC_SOCK_COMM; + Or when driver send a signal SIGUSR2 and we have not registered it, + IAPP daemon will be closed by kernel automatically. + */ + signal(SIGUSR2, IAPP_USR2Handle); /* handle message from AP driver */ + + /* when RALINK AP (re)start up, move the line to 8021x deamon */ + /* signal(SIGUSR1, IAPP_USR1_Handle); */ + + /* set our PID to RALINK WLAN driver so WLAN driver can send Data to us */ +#ifdef IAPP_OS_LINUX + PidAuth = getpid(); +#endif // IAPP_OS_LINUX // +#ifdef IAPP_OS_VXWORKS + PidAuth = pCtrlBK->PID; +#endif // IAPP_OS_VXWORKS // + + pCtrlBK->PID = PidAuth; + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Process ID = 0x%x (%d %d)\n", PidAuth, + IAPP_MemAllocNum, IAPP_MemFreeNum)); + + mt_iapp_set_daemon_information(pCtrlBK, &PidAuth); + + IAPP_PID_Backup(PidAuth); + + /* start IAPP function (while FlgIsLoop in the function) */ + IAPP_Start(pCtrlBK); + + /* will not be here except terminate signal */ +//#ifdef IAPP_OS_LINUX +#if 0 + system(RouteDelCmd); +#endif + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> IAPP_Task ends (%d, %d)!\n", + IAPP_MemAllocNum, IAPP_MemFreeNum)); + +label_err: + return; +} /* End of IAPP_Task */ + +/* +======================================================================== +Routine Description: + User space main function. + +Arguments: + Argc - argument number + *pArgv[] - arguments + +Return Value: + 0 - exit daemon + -1 - fork fail + +Note: +======================================================================== +*/ +#ifdef IAPP_OS_LINUX +INT32 main(INT32 Argc, CHAR *pArgv[]) +#endif // IAPP_OS_LINUX // +#ifdef IAPP_OS_VXWORKS + STATUS IAPP_Init(INT32 Argc, CHAR *pArgv[]) +#endif // IAPP_OS_VXWORKS // +{ + RTMP_IAPP *pCtrlBK = &IAPP_Ctrl_Block; +#ifdef IAPP_OS_LINUX + pid_t PID; +#endif // IAPP_OS_LINUX // + + /* init */ + IAPP_MEM_ZERO(pCtrlBK, sizeof(RTMP_IAPP)); + + /* kill old IAPP daemon if exists */ + IAPP_PID_Kill(); + + /* parse arguments from SysCmd line */ + if (IAPP_ArgumentParse(pCtrlBK, Argc, pArgv) == FALSE) + return 0; + /* End of if */ + +#ifdef IAPP_OS_LINUX + IAPP_Task((VOID *)pCtrlBK); +#endif + +#ifdef IAPP_OS_VXWORKS + pCtrlBK->PID = taskSpawn("tIappFt", 100, 0, 5000, (FUNCPTR)IAPP_Task, + (INT32)pCtrlBK, 0, 0, 0, 0, 0, 0, 0, 0, 0); + if (pCtrlBK->PID == ERROR) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Task spawn failed\n")); + goto label_err; + } /* End of if */ +#endif + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Exit daemon!\n")); + return 0; + +label_err: +#ifdef IAPP_OS_LINUX + exit(-1); +#endif + return 0; +} /* End of main */ + +/* +======================================================================== +Routine Description: + Send the IAPP move notify frame. + +Arguments: + *pCtrlBK - IAPP control blcok + *pPkt - the UDP packet + PktLen - the packet size + PeerIP - the IP of peer device + FlgUsingUdpWhenNoIP - TRUE: use UDP broadcast to send when PeerIP == 0 + *pRspBuf - used to issue response to the peer + +Return Value: + TRUE - send successfully + FAIL - send fail + +Note: + If PeerIP is 0, the func will use UDP broadcast frame. +======================================================================== +*/ +static BOOLEAN IAPP_TCP_PacketSend(IAPP_IN RTMP_IAPP *pCtrlBK, + /* IAPP_IN UCHAR *WifiMAC,*/ + IAPP_IN UCHAR *pPkt, IAPP_IN UINT32 PktLen, + IAPP_IN UINT32 PeerIP, + IAPP_IN BOOLEAN FlgUsingUdpWhenNoIP, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx) { + INT32 SocketPeer; + struct sockaddr_in AddrSockConn; + UCHAR *pBufEncrypt; + BOOLEAN FuncStatus; + + /* sanity check */ + if ((FlgUsingUdpWhenNoIP == FALSE) && (PeerIP == 0)) + return FALSE; + /* End of if */ + + /* init */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> IAPP_TCP_PacketSend %x\n", PeerIP)); + FuncStatus = FALSE; + + if (PeerIP != 0) { + /* use TCP to send the packet */ + SocketPeer = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (SocketPeer < 0) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Open TCP socket fail!\n")); + return FALSE; + } /* End of if */ + + IAPP_MEM_ZERO(&AddrSockConn, sizeof(AddrSockConn)); + AddrSockConn.sin_family = AF_INET; + AddrSockConn.sin_addr.s_addr = PeerIP; + AddrSockConn.sin_port = htons(IAPP_TCP_PORT); + + if (connect(SocketPeer, (struct sockaddr *)&AddrSockConn, + sizeof(AddrSockConn)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Connect socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + } /* End of if */ + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufEncrypt, + PktLen + IAPP_SECURITY_EXTEND_LEN); + if (pBufEncrypt == NULL) { + if (PeerIP != 0) + close(SocketPeer); + /* End of if */ + return FuncStatus; + } /* End of if */ + IAPP_MEM_MOVE(pBufEncrypt, pPkt, PktLen); + + if (PeerIP != 0) { +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to encrypt */ + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pBufEncrypt, &PktLen, if_idx, + RT_FT_DATA_ENCRYPT); +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + IAPP_HEX_DUMP("Send Content: ", pPkt, PktLen); // snowpin test + + if (send(SocketPeer, pBufEncrypt, PktLen, 0) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + } else { + /* use broadcast UDP packet but UDP can not be guaranted, no retry */ + IAPP_UDP_PACKET_SEND(pCtrlBK, pBufEncrypt, PktLen, pRspBuf, if_idx); + } /* End of if */ + + FuncStatus = TRUE; + +label_fail: + if (PeerIP != 0) + close(SocketPeer); + /* End of if */ + return FuncStatus; +} /* End of IAPP_TCP_PacketSend */ + +/* +======================================================================== +Routine Description: + Send the IAPP send security block frame. + +Arguments: + *pCtrlBK - IAPP control blcok + *pEvtHdr - event header + *pEvt - event + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: + If PeerIP is 0, the func will use UDP broadcast frame. +======================================================================== +*/ +static VOID FT_KDP_SecurityBlockSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, IAPP_IN UCHAR *pRspBuf, + IAPP_IN UCHAR *WifiMAC, + IAPP_IN INT32 if_idx) { + INT32 SocketPeer; + struct sockaddr_in AddrSockConn; + UCHAR *pBufFrame; + RT_IAPP_SEND_SECURITY_BLOCK *pIappSendSB; + UINT32 PktLen, buf_len = 0; + + /* init */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> FT_KDP_SecurityBlockSend to %d.%d.%d.%d\n\n", + IAPP_SHOW_IP_HTONL(pEvtHdr->PeerIpAddr))); + + SocketPeer = 0; + pBufFrame = NULL; + + /* sanity check */ + if (pEvtHdr->PeerIpAddr != 0) { + /* use TCP to send the packet */ + SocketPeer = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (SocketPeer < 0) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Open TCP socket fail!\n")); + return; + } /* End of if */ + + IAPP_MEM_ZERO(&AddrSockConn, sizeof(AddrSockConn)); + AddrSockConn.sin_family = AF_INET; +#ifndef IAPP_TEST + AddrSockConn.sin_addr.s_addr = pEvtHdr->PeerIpAddr; +#else + AddrSockConn.sin_addr.s_addr = inet_addr("127.0.0.1"); /* test use */ +#endif + AddrSockConn.sin_port = htons(IAPP_TCP_PORT); + + if (connect(SocketPeer, (struct sockaddr *)&AddrSockConn, + sizeof(AddrSockConn)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Connect socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + } /* End of if */ + + /* init frame buffer */ + buf_len = sizeof(RT_IAPP_SEND_SECURITY_BLOCK) + pEvtHdr->EventLen + + ETH_ALEN; /* ETH_ALEN is the length of WIFI Interface MAC. */ + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufFrame, buf_len); + if (pBufFrame == NULL) + goto label_fail; + /* End of if */ + + IAPP_PKT_ZERO(pBufFrame, buf_len); + + /* init the Security-Block-Send frame */ + pIappSendSB = (RT_IAPP_SEND_SECURITY_BLOCK *)pBufFrame; + pIappSendSB->IappHeader.Version = 0; + pIappSendSB->IappHeader.Command = IAPP_CMD_FT_SEND_SECURITY_BLOCK; + pIappSendSB->IappHeader.Identifier = SWAP_16(IAPP_IDENTIFIER_GET(pCtrlBK)); + PktLen = sizeof(RT_IAPP_SEND_SECURITY_BLOCK) + pEvtHdr->EventLen; + pIappSendSB->IappHeader.Length = SWAP_16(PktLen); + + pIappSendSB->Length = pEvtHdr->EventLen; + IAPP_MEM_MOVE(pIappSendSB->SB, pEvt, pEvtHdr->EventLen); + IAPP_MEM_MOVE(pIappSendSB->SB + pEvtHdr->EventLen, WifiMAC, ETH_ALEN); + + /* send out the frame */ + if (pEvtHdr->PeerIpAddr != 0) { +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to encrypt */ + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pBufFrame, &buf_len, if_idx, + RT_FT_DATA_ENCRYPT); +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + if (send(SocketPeer, pBufFrame, buf_len, 0) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + } else { + /* use broadcast UDP packet but UDP can not be guaranted, no retry */ + IAPP_UDP_PACKET_SEND(pCtrlBK, pBufFrame, buf_len, pRspBuf, if_idx); + } /* End of if */ + +label_fail: + if (SocketPeer > 0) + close(SocketPeer); + /* End of if */ + return; +} /* End of FT_KDP_SecurityBlockSend */ + +/* +======================================================================== +Routine Description: + Send the IAPP ack security block frame. + +Arguments: + *pCtrlBK - IAPP control blcok + *pEvtHdr - event header + *pEvt - event + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID FT_KDP_SecurityBlockAck(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx) { + INT32 SocketPeer; + struct sockaddr_in AddrSockConn; + UCHAR *pBufFrame; + RT_IAPP_SEND_SECURITY_BLOCK *pIappSendSB; + UINT32 PktLen; + + /* init */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> FT_KDP_SecurityBlockAck\n")); + + SocketPeer = 0; + pBufFrame = NULL; + + /* open TCP socket to the peer */ + SocketPeer = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (SocketPeer < 0) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Open TCP socket fail!\n")); + return; + } /* End of if */ + + IAPP_MEM_ZERO(&AddrSockConn, sizeof(AddrSockConn)); + AddrSockConn.sin_family = AF_INET; +#ifndef IAPP_TEST + AddrSockConn.sin_addr.s_addr = pEvtHdr->PeerIpAddr; +#else + AddrSockConn.sin_addr.s_addr = inet_addr("127.0.0.1"); /* test use */ +#endif + AddrSockConn.sin_port = htons(IAPP_TCP_PORT); + + if (connect(SocketPeer, (struct sockaddr *)&AddrSockConn, + sizeof(AddrSockConn)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Connect socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + + /* init frame buffer */ + PktLen = sizeof(RT_IAPP_SEND_SECURITY_BLOCK) + pEvtHdr->EventLen; + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufFrame, PktLen); + if (pBufFrame == NULL) + goto label_fail; + /* End of if */ + IAPP_PKT_ZERO(pBufFrame, PktLen); + + /* init the Security-Block-Ack frame */ + pIappSendSB = (RT_IAPP_SEND_SECURITY_BLOCK *)pBufFrame; + pIappSendSB->IappHeader.Version = 0; + pIappSendSB->IappHeader.Command = IAPP_CMD_FT_ACK_SECURITY_BLOCK; + pIappSendSB->IappHeader.Identifier = SWAP_16(IAPP_IDENTIFIER_GET(pCtrlBK)); + + pIappSendSB->IappHeader.Length = SWAP_16(PktLen); + + pIappSendSB->Length = pEvtHdr->EventLen; + IAPP_MEM_MOVE(pIappSendSB->SB, pEvt, pEvtHdr->EventLen); + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to encrypt */ + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pBufFrame, &PktLen, if_idx, + RT_FT_DATA_ENCRYPT); +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + /* send out the frame */ + if (send(SocketPeer, pBufFrame, PktLen, 0) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + +label_fail: + if (SocketPeer > 0) + close(SocketPeer); + /* End of if */ + return; +} /* End of FT_KDP_SecurityBlockAck */ + +/* +======================================================================== +Routine Description: + Send the Information Request frame. + +Arguments: + *pCtrlBK - IAPP control blcok + *pEvtHdr - event header + *pEvt - event + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID FT_KDP_InformationRequestSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx) { + UCHAR *pBufFrame; + RT_IAPP_INFORMATION *pIappInfor; + UINT32 PktLen; + + /* init */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> FT_KDP_InformationRequestSend\n")); + + pBufFrame = NULL; + + /* init frame buffer */ + PktLen = sizeof(RT_IAPP_INFORMATION) + pEvtHdr->EventLen; + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufFrame, PktLen); + if (pBufFrame == NULL) + return; + /* End of if */ + + IAPP_PKT_ZERO(pBufFrame, PktLen); + pIappInfor = (RT_IAPP_INFORMATION *)pBufFrame; + + /* init the AP Information frame */ + pIappInfor->IappHeader.Version = 0; + pIappInfor->IappHeader.Command = IAPP_CMD_INFO_REQUEST; + pIappInfor->IappHeader.Identifier = SWAP_16(IAPP_IDENTIFIER_GET(pCtrlBK)); + + pIappInfor->IappHeader.Length = SWAP_16(PktLen); + + pIappInfor->Length = pEvtHdr->EventLen; + IAPP_MEM_MOVE(pIappInfor->IB, pEvt, pEvtHdr->EventLen); + + /* use broadcast UDP packet but UDP can not be guaranted, no retry */ + IAPP_UDP_PACKET_SEND(pCtrlBK, pBufFrame, PktLen, pRspBuf, if_idx); +} /* End of FT_KDP_InformationRequestSend */ + +/* +======================================================================== +Routine Description: + Send the Information Response frame. + +Arguments: + *pCtrlBK - IAPP control blcok + *pEvtHdr - event header + *pEvt - event + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID FT_KDP_InformationResponseSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx) { + INT32 SocketPeer; + struct sockaddr_in AddrSockConn; + UCHAR *pBufFrame; + RT_IAPP_INFORMATION *pIappInfor; + UINT32 PktLen; + + /* init */ + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> FT_KDP_InformationResponseSend to %d.%d.%d.%d\n", + IAPP_SHOW_IP_HTONL(pEvtHdr->PeerIpAddr))); + + if (pEvtHdr->PeerIpAddr == 0) + return; + /* End of if */ + + SocketPeer = 0; + pBufFrame = NULL; + + /* open TCP socket to the peer */ + SocketPeer = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (SocketPeer < 0) { + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Open TCP socket fail!\n")); + return; + } /* End of if */ + + IAPP_MEM_ZERO(&AddrSockConn, sizeof(AddrSockConn)); + AddrSockConn.sin_family = AF_INET; +#ifndef IAPP_TEST + AddrSockConn.sin_addr.s_addr = pEvtHdr->PeerIpAddr; +#else + AddrSockConn.sin_addr.s_addr = inet_addr("127.0.0.1"); /* test use */ +#endif + AddrSockConn.sin_port = htons(IAPP_TCP_PORT); + + if (connect(SocketPeer, (struct sockaddr *)&AddrSockConn, + sizeof(AddrSockConn)) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Connect socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + + /* init frame buffer */ + PktLen = sizeof(RT_IAPP_INFORMATION) + pEvtHdr->EventLen; + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufFrame, PktLen); + if (pBufFrame == NULL) + goto label_fail; + /* End of if */ + IAPP_PKT_ZERO(pBufFrame, PktLen); + + /* init the Security-Block-Ack frame */ + pIappInfor = (RT_IAPP_INFORMATION *)pBufFrame; + pIappInfor->IappHeader.Version = 0; + pIappInfor->IappHeader.Command = IAPP_CMD_INFO_RESPONSE; + pIappInfor->IappHeader.Identifier = SWAP_16(IAPP_IDENTIFIER_GET(pCtrlBK)); + + pIappInfor->IappHeader.Length = SWAP_16(PktLen); + + pIappInfor->Length = pEvtHdr->EventLen; + IAPP_MEM_MOVE(pIappInfor->IB, pEvt, pEvtHdr->EventLen); + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to encrypt */ + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pBufFrame, &PktLen, if_idx, + RT_FT_DATA_ENCRYPT); +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + /* send out the frame */ + if (send(SocketPeer, pBufFrame, PktLen, 0) < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send socket failed %d.%d.%d.%d!\n", + IAPP_SHOW_IP(AddrSockConn.sin_addr.s_addr))); + goto label_fail; + } /* End of if */ + +label_fail: + if (SocketPeer > 0) + close(SocketPeer); + /* End of if */ + return; +} /* End of FT_KDP_InformationResponseSend */ + +/* +======================================================================== +Routine Description: + Send the Information Report frame. + +Arguments: + *pCtrlBK - IAPP control blcok + *pEvtHdr - event header + *pEvt - event + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID FT_KDP_InformationReportSend(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, + IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx) { + UCHAR *pBufFrame; + RT_IAPP_INFORMATION *pIappInfor; + UINT32 PktLen; + + /* init */ + DBGPRINT(RT_DEBUG_TRACE, + ("iapp> FT_KDP_InformationReportSend to %d.%d.%d.%d\n", + IAPP_SHOW_IP_HTONL(pEvtHdr->PeerIpAddr))); + + pBufFrame = NULL; + + /* init frame buffer */ + PktLen = sizeof(RT_IAPP_INFORMATION) + pEvtHdr->EventLen; + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufFrame, PktLen); + if (pBufFrame == NULL) + return; + /* End of if */ + + IAPP_PKT_ZERO(pBufFrame, PktLen); + pIappInfor = (RT_IAPP_INFORMATION *)pBufFrame; + + /* init the AP Information frame */ + pIappInfor->IappHeader.Version = 0; + pIappInfor->IappHeader.Command = IAPP_CMD_INFO_BROADCAST; + pIappInfor->IappHeader.Identifier = SWAP_16(IAPP_IDENTIFIER_GET(pCtrlBK)); + + pIappInfor->IappHeader.Length = SWAP_16(PktLen); + + pIappInfor->Length = pEvtHdr->EventLen; + IAPP_MEM_MOVE(pIappInfor->IB, pEvt, pEvtHdr->EventLen); + + /* use broadcast UDP packet but UDP can not be guaranted, no retry */ + IAPP_UDP_PACKET_SEND(pCtrlBK, pBufFrame, PktLen, pRspBuf, if_idx); +} /* End of FT_KDP_InformationReportSend */ + +/* +======================================================================== +Routine Description: + Forward the FT Action frame to the peer. + +Arguments: + *pCtrlBK - IAPP control blcok + *pEvtHdr - event header + *pEvt - event + PacketType - 0 for Remote Request, and to 1 for Remote Response + *pMacDa - DA MAC + *pMacSa - SA MAC + *pRspBuf - used to issue response to the peer + +Return Value: + None + +Note: +======================================================================== +*/ +static VOID FT_RRB_ActionForward(IAPP_IN RTMP_IAPP *pCtrlBK, + IAPP_IN FT_KDP_EVT_HEADER *pEvtHdr, + IAPP_IN VOID *pEvt, IAPP_IN UINT16 PacketType, + IAPP_IN UCHAR *pMacDa, IAPP_IN UCHAR *pMacSa, + IAPP_IN UCHAR *pMacAp, IAPP_IN UCHAR *pRspBuf, + IAPP_IN INT32 if_idx) { + UCHAR *pBufFrame; + FT_RRB_FRAME *pFrameRRB; + INT32 Status; + UINT32 PktLen; + UINT32 EvtLen; + + /* init the update frame body */ + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Forward a RRB packet (len = %d) to " + "%02x:%02x:%02x:%02x:%02x:%02x!\n", + pEvtHdr->EventLen, pMacDa[0], pMacDa[1], pMacDa[2], + pMacDa[3], pMacDa[4], pMacDa[5])); + + PktLen = sizeof(FT_RRB_FRAME) + pEvtHdr->EventLen; + + IAPP_RSP_BUF_ALLOCATE(pRspBuf, pBufFrame, PktLen); + if (pBufFrame == NULL) + return; + /* End of if */ + IAPP_PKT_ZERO(pBufFrame, PktLen); + + pFrameRRB = (FT_RRB_FRAME *)pBufFrame; + IAPP_MEM_MOVE(pFrameRRB->ETH.DA, pMacDa, sizeof(pFrameRRB->ETH.DA)); + IAPP_MEM_MOVE(pFrameRRB->ETH.SA, pMacSa, sizeof(pFrameRRB->ETH.SA)); + pFrameRRB->ETH.Len = htons(RRB_ETH_PRO); + + pFrameRRB->RemoteFrameType = FT_RRB_FRAME_TYPE; + pFrameRRB->FTPacketType = PacketType; + pFrameRRB->FTActionLength = pEvtHdr->EventLen; + IAPP_MEM_MOVE(pFrameRRB->ApAddress, pMacAp, sizeof(pFrameRRB->ApAddress)); + + IAPP_MEM_MOVE(pFrameRRB->FTActionFrame, pEvt, pEvtHdr->EventLen); + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* ioctl to encrypt */ + + /* the address of pEvtHdr->EventLen is not 4B align */ + EvtLen = pEvtHdr->EventLen; + + IAPP_IOCTL_TO_WLAN(pCtrlBK, RT_IOCTL_IAPP, pFrameRRB->FTActionFrame, &EvtLen, + if_idx, RT_FT_DATA_ENCRYPT); + + /* reassign the packet length due to changed pEvtHdr->EventLen */ + PktLen = sizeof(FT_RRB_FRAME) + EvtLen; +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + +#ifdef IAPP_OS_LINUX + { + /* send the RRB frame */ + Status = send(pCtrlBK->SocketRawRRB, pBufFrame, PktLen, 0); + if (Status < 0) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send RRB packet failed %d!\n", Status)); + goto LabelFail; + } /* End of if */ + } +#endif // IAPP_OS_LINUX // + +#ifdef IAPP_OS_VXWORKS + { + M_BLK_ID pUpdatePkt; + UINT32 IdIfNum; + + /* loop for eth0, eth1, eth2...... */ + for (IdIfNum = 0; IdIfNum < FT_KDP_BR_ETH_IF_NUM; IdIfNum++) { + if ((pUpdatePkt = netTupleGet(_pNetDpool, PktLen, M_DONTWAIT, MT_DATA, + TRUE)) == NULL) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> iapp> Get packet buffer fail!\n")); + goto LabelFail; + } /* End of if */ + + pUpdatePkt->mBlkHdr.mFlags |= M_PKTHDR; + pUpdatePkt->m_len = PktLen; + + IAPP_MEM_MOVE(pUpdatePkt->m_data, pBufFrame, PktLen); + + if (muxSend(pCtrlBK->pRrbCookieTo[IdIfNum], pUpdatePkt) == ERROR) { + DBGPRINT(RT_DEBUG_ERROR, ("iapp> Send RRB packet failed!\n")); + netMblkClChainFree(pUpdatePkt); + goto LabelFail; + } /* End of if */ + } /* End of for */ + } +#endif // IAPP_OS_VXWORKS // + + DBGPRINT(RT_DEBUG_TRACE, ("iapp> Send RRB packet OK!\n")); + +LabelFail: + return; +} /* End of FT_RRB_ActionForward */ + +/* End of rtmpiapp.c */ diff --git a/package/lean/mt/mtkiappd/src/rtmpiapp.h b/package/lean/mt/mtkiappd/src/rtmpiapp.h new file mode 100644 index 000000000..7fa503a35 --- /dev/null +++ b/package/lean/mt/mtkiappd/src/rtmpiapp.h @@ -0,0 +1,580 @@ +/**************************************************************************** + * Ralink Tech Inc. + * Taiwan, R.O.C. + * + * (c) Copyright 2002, Ralink Technology, Inc. + * + * All rights reserved. Ralink's source code is an unpublished work and the + * use of a copyright notice does not imply otherwise. This source code + * contains confidential trade secret material of Ralink Tech. Any attemp + * or participation in deciphering, decoding, reverse engineering or in any + * way altering the source code is stricitly prohibited, unless the prior + * written consent of Ralink Technology, Inc. is obtained. + ***************************************************************************/ + +/**************************************************************************** + + Abstract: + + All related IEEE802.11f IAPP + IEEE802.11r IAPP extension. + +***************************************************************************/ + +#ifndef __RTMP_IAPP_H__ +#define __RTMP_IAPP_H__ + +#include "rt_config.h" +#include "rt_typedef.h" + +#define IAPP_OS_LINUX +//#define IAPP_OS_VXWORKS + +/* + IAPP issues: + + 1. Lack of fast roaming support, particularly required for voice; + 2. Only supports use of RADIUS (in a non-standard way); +*/ + +/* + Three levels of support for ESS formation are possible with the IAPP + capabilities described here: + + Level 1: no administrative or security support; + Level 2: support for dynamic mapping of BSSID to IP addresses; and + Level 3: support for encryption and authentication of IAPP messages. + + Level 1 support can be achieved by configuring each AP in the ESS with + the BSSID to IP address mapping for all other APs in the ESS. This may + be acceptable for a small ESS. + + Many ESS providers will need levels 2 or 3, which require RADIUS + support. +*/ + +/* + Note with RALINK driver: + + 1. OID to RALINK AP driver; + 2. RT_SIGNAL_STRUC + 3. IAPP daemon must be run after br-lan & ra0 built up. +*/ + +/* ---------------------------- User Definition ------------------------ */ + +#define FT_KDP_FUNC_SOCK_COMM /* use socket to communicate with driver */ +#define FT_KDP_FUNC_PKT_ENCRYPT /* do encryption for each IAPP packet */ +#define FT_KDP_SELECT_TIMEOUT /* use timeout to wait for any packet */ +#define FT_KDP_KEY_FROM_DAEMON /* key is set in daemon */ +#define FT_KDP_DEFAULT_IF_ETH "br-lan" +#define FT_KDP_DEFAULT_IF_WLAN \ + "br-lan" /* used to receive command from WLAN \ + */ +#define FT_KDP_DEFAULT_IF_WLAN_IOCTL "ra0" /* ioctl command to WLAN */ + +/* + Inter-AP communications present opportunities to an attacker. + The attacker can use IAPP or forged 802.11 MAC management frames as a + Denial-of-Service (DoS) attack against a STA state in its AP. + It can capture MOVE packets to gather information on the STA that is + roaming. It can act as a rogue AP in the ESS. + + If use RADIUS server, the IAPP entity sends the RADIUS Initiate-Request + and receives the RADIUS Initiate-Accept or Initiate-Reject. + If the Initiate-Accept is received, then the IAPP entity initializes + its data structures, functions, and protocols. If an Initiate-Reject + is received, the IAPP does not start. + + The RADIUS servers provide two functions, mapping the BSSID of an AP to + its IP address on the DSM and distribution of keys to the APs to allow + the encryption of the communications between the APs. + + The function of mapping the BSSID of an AP to its IP address on the DSM + can also be accomplished by local configuration information or the IETF + Inverse Address Resolution Protocol (RFC 2390:1998). + + We don't support RADIUS server so we use a fixed PSK key to encrypt. +*/ +#define FT_KDP_DEFAULT_PTK "zpxrjs9uo2kvbuqo" + +#ifdef IAPP_OS_LINUX +#define RT_IOCTL_IAPP (SIOCIWFIRSTPRIV + 0x01) +#endif // IAPP_OS_LINUX // + +#ifdef IAPP_OS_VXWORKS +#define PF_PACKET AF_INET +#define RT_IOCTL_IAPP VX_RT_PRIV_IOCTL +#define FT_KDP_WLAN_NAME "ra" +#define FT_KDP_WLAN_UNIT 0 +#define FT_KDP_ETH_NAME "eth" /* must not use mirror */ +#define FT_KDP_BR_ETH_IF_NUM 2 /* eth0 and eth1 */ +#define FT_KDP_BR_NAME "mirror" +#define FT_KDP_BR_UNIT 0 +#endif // IAPP_OS_VXWORKS // + +#define HASH_TABLE_SIZE 128 +#define MAX_NUM_OF_CLIENT 64 + +#define MAC_ADDR_HASH(Addr) \ + (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5]) +#define MAC_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) & (HASH_TABLE_SIZE - 1)) + +/* ---------------------------- MACRO Definition ---------------------------- */ +#define IAPP_LITTLE_ENDIAN /* __BIG_ENDIAN */ + +#ifdef IAPP_LITTLE_ENDIAN +#define SWAP_16(x) \ + ((UINT16)((((UINT16)(x) & (UINT16)0x00ffU) << 8) | \ + (((UINT16)(x) & (UINT16)0xff00U) >> 8))) +#else + +#define SWAP_16(x) x +#endif + +/* 16 for extra 8B encryption & 8B-align */ +#define IAPP_PKT_ALLOCATE(__pPkt, __Len) \ + IAPP_MEM_ALLOC(__pPkt, __Len + IAPP_SECURITY_EXTEND_LEN) +#define IAPP_PKT_ZERO(__pPkt, __Len) \ + IAPP_MEM_ZERO(__pPkt, __Len + IAPP_SECURITY_EXTEND_LEN) + +#define IAPP_MEM_ALLOC(__pMem, __Size) \ + { \ + os_alloc_mem(NULL, (UCHAR **)(&__pMem), __Size); \ + IAPP_MemAllocNum++; \ + } +#define IAPP_MEM_FREE(__Mem) \ + { \ + os_free_mem(NULL, __Mem); \ + IAPP_MemFreeNum++; \ + } + +/* calculate the size to the multiple of 8 */ +#define IAPP_ENCRYPTED_DATA_SIZE_CAL(__LenOfAction) \ + if ((__LenOfAction)&0x07) \ + (__LenOfAction) += 8 - ((__LenOfAction)&0x07); \ + __LenOfAction += 8; + +#define IAPP_MEM_ZERO(__Dst, __Len) NdisZeroMemory(__Dst, __Len) +#define IAPP_MEM_FILL(__Dst, __Val, __Len) NdisFillMemory(__Dst, __Len, __Val) +#define IAPP_MEM_MOVE(__Dst, __Src, __Len) NdisMoveMemory(__Dst, __Src, __Len) + +#define IAPP_HEX_DUMP(__pPrompt, __pBuf, __Len) \ + IAPP_HexDump((CHAR *)__pPrompt, (CHAR *)__pBuf, __Len) + +#define IAPP_IOCTL_TO_WLAN(__pCtrlBK, __Param, __pData, __pLen, __ApIdx, \ + __Flags) \ + { \ + IAPP_IoctlToWLAN(__pCtrlBK, __Param, (CHAR *)(__pData), (INT32 *)(__pLen), \ + __ApIdx, __Flags); \ + } + +/* ---------------------------- Structure Definition ------------------------ */ + +/* + IAPP supports three protocol sequences. + + One is initiated by invoking the IAPP-ADD.request after the APME + receives an MLME-ASSOCIATE.indication. + + The second is initiated by invoking the IAPPMOVE.request after the APME + receives an MLME-REASSOCIATE.indication. + + The third is initiated by invoking the IAPP-CACHE.request to cache + context in neighboring APs to facilitate fast roaming. +*/ + +/* event log */ +#define FT_IP_ADDRESS_SIZE 4 + +/* IAPP header in the frame body, 6B */ +typedef struct PACKED _RT_IAPP_HEADER { + + UCHAR Version; /* indicates the protocol version of the IAPP */ + UCHAR Command; /* ADD-notify, MOVE-notify, etc. */ + UINT16 Identifier; /* aids in matching requests and responses */ + UINT16 Length; /* indicates the length of the entire packet */ +} RT_IAPP_HEADER; + +/* IAPP Action Frame */ +/* ADD notify frame */ +typedef struct PACKED _RT_IAPP_ADD_NOTIFY { + + RT_IAPP_HEADER IappHeader; + + /* the number of octets in the MAC Address */ + UCHAR AddressLen; + + /* should be sent with a value of zero */ +#define FT_KDP_ADD_NOTIFY_RSVD_11R_SUPPORT 0x01 + UCHAR Rsvd; + + /* the MAC address of the STA that has associated */ + UCHAR MacAddr[ETH_ALEN]; + + /* the integer value of the sequence number of the association request frame + */ + /* + The 802.11 sequence number may be an ambiguous indication of the most + recent association. But, this information may be useful to an + algorithm making a determination of the location of the most recent + association of a STA. + */ + UINT16 Sequence; + +} RT_IAPP_ADD_NOTIFY; + +/* MOVE requset frame */ +typedef struct PACKED _RT_IAPP_MOVE_NOTIFY { + + RT_IAPP_HEADER IappHeader; + + /* the number of octets in the MAC Address */ + UCHAR AddressLen; + + /* should be sent with a value of zero */ + UCHAR Rsvd; + + /* the MAC address of the STA that has associated */ + UCHAR MacAddr[ETH_ALEN]; + + /* the integer value of the sequence number of the association request frame + */ + UINT16 Sequence; + + /* indicates the number of octets in the Context Block field, always 0 */ + UINT16 LenOfContextBlock; + +} RT_IAPP_MOVE_NOTIFY; + +/* MOVE response frame */ +typedef struct PACKED _RT_IAPP_MOVE_RSP { + + RT_IAPP_HEADER IappHeader; + + /* the number of octets in the MAC Address */ + UCHAR AddressLen; + +#define IAPP_MOVE_RSP_STATUS_SUCCESS 0 +#define IAPP_MOVE_RSP_STATUS_DENY 1 +#define IAPP_MOVE_RSP_STATUS_STALE 2 + /* 0 Successful, 1 Move denied, 2 Stale move */ + /* + FAIL indicates that a RADIUS Access-Reject was received in response + to the RADIUS Access-Request sent to the RADUS server to look up the + IP address of the Old AP. (not use the IP in the MOVE-notify frame) + */ + UCHAR Status; + + /* the MAC address of the STA that has associated */ + UCHAR MacAddr[ETH_ALEN]; + + /* the integer value of the sequence number of the association request frame + */ + UINT16 Sequence; + + /* indicates the number of octets in the Context Block field, always 0 */ + UINT16 LenOfContextBlock; + +} RT_IAPP_MOVE_RSP; + +/* SEND-SECURITY-BLOCK frame */ +typedef struct PACKED _RT_IAPP_SEND_SECURITY_BLOCK { + + RT_IAPP_HEADER IappHeader; + + /* first 8 bytes of the ACK nonce */ +#define IAPP_SB_INIT_VEC_SIZE 8 + UCHAR InitVec[8]; + + /* indicates the number of octets in the Security Block field */ + UINT16 Length; + + /* + Contains the security information being forwarded from the + RADIUS Server through the new AP to the old AP. + */ + UCHAR SB[0]; + +} RT_IAPP_SEND_SECURITY_BLOCK; + +/* no use */ +typedef struct PACKED _RT_IAPP_ACK_SECURITY_BLOCK { + + RT_IAPP_HEADER IappHeader; + + /* copied from the Date/Time stamp */ + UCHAR InitVec[8]; + + /* + Content of the New-AP-ACK-Authenticator information element that + the old AP received in the Security Block. + */ + UCHAR NewApAckAuth[48]; + +} RT_IAPP_ACK_SECURITY_BLOCK; + +/* private frame */ +typedef struct PACKED _RT_IAPP_INFORMATION { + +#define IAPP_INFO_TYPE_BC 0 +#define IAPP_INFO_TYPE_REQ 1 +#define IAPP_INFO_TYPE_RSP 2 +#define IAPP_INFO_TYPE_MAX_NUM 3 + + RT_IAPP_HEADER IappHeader; + + /* indicates the number of octets in the Information Block field */ + UINT16 Length; + + /* contains the AP information being forwarded */ + UCHAR IB[0]; + +} RT_IAPP_INFORMATION; + +typedef struct PACKED _RT_IAPP_SECURITY_MONITOR { + + RT_IAPP_HEADER IappHeader; + RT_802_11_EVENT_TABLE EvtTab; +} RT_IAPP_SECURITY_MONITOR, *PRT_IAPP_SECURITY_MONITOR; + +/* Event structure between daemon and driver */ +#define FT_KDP_EVT_HEADER_SIZE sizeof(FT_KDP_EVT_HEADER) + +typedef struct _OID_REQ { + + INT32 OID; + INT32 Len; + CHAR Buf[0]; +} OID_REQ, *POID_REQ; + +typedef struct _MSG_BUF { + + INT32 MsgType; + INT32 MsgSubType; + CHAR Buf[1024]; +} MSG_BUF, *PMSG_BUF; + +/* Layer 2 Update frame to switch/bridge */ +typedef struct PACKED _FT_ETH_HEADER { + + UCHAR DA[ETH_ALEN]; + UCHAR SA[ETH_ALEN]; + UINT16 Len; + +} FT_ETH_HEADER; + +/* For any Layer2 devices, e.g., bridges, switches and other APs, the frame + can update their forwarding tables with the correct port to reach the new + location of the STA */ +typedef struct PACKED _RT_IAPP_L2_UPDATE_FRAME { + + FT_ETH_HEADER ETH; + UCHAR DSAP; /* must be NULL */ + UCHAR SSAP; /* must be NULL */ + UCHAR Control; /* reference to IEEE Std 802.2 */ + UCHAR XIDInfo[3]; /* reference to IEEE Std 802.2 */ +} RT_IAPP_L2_UPDATE_FRAME, *PRT_IAPP_L2_UPDATE_FRAME; + +/* RRB protocol */ +typedef struct PACKED _FT_RRB_FRAME { + /* ethernet header */ + FT_ETH_HEADER ETH; + + /* shall be set to 1 */ +#define FT_RRB_FRAME_TYPE 1 + UCHAR RemoteFrameType; + + /* 0 for Remote Request, and to 1 for Remote Response */ + UCHAR FTPacketType; + + /* the length in octets of the FT Action Frame field */ + UINT16 FTActionLength; + + /* the BSSID of the current AP */ + UCHAR ApAddress[ETH_ALEN]; + + /* + The contents of the FT Action frame, from the Category field to the + end of the Action Frame body. + */ +#define FT_RRB_HEADER_SIZE (sizeof(FT_RRB_FRAME)) + UCHAR FTActionFrame[0]; +} FT_RRB_FRAME; + +typedef struct _FT_CLIENT_INFO { + struct _FT_CLIENT_INFO *next; + INT if_idx; + UCHAR sta_mac[ETH_ALEN]; + UCHAR ap_mac[ETH_ALEN]; + UCHAR used; + UCHAR hash_idx; +} FT_CLIENT_INFO; + +typedef struct _FT_CLIENT_TABLE { + FT_CLIENT_INFO *hash[HASH_TABLE_SIZE]; + FT_CLIENT_INFO ft_sta_info[MAX_NUM_OF_CLIENT]; + INT32 ft_sta_table_size; +} FT_CLIENT_TABLE; + +/* IAPP control block */ +#define IAPP_ENCRYPT_KEY_MAX_SIZE 64 +#define MAX_WIFI_COUNT 2 +typedef struct _RTMP_IAPP { + + CHAR IfNameEth[IFNAMSIZ]; /* ethernet interface name */ + CHAR IfNameWlan[IFNAMSIZ]; /* wireless interface name */ + CHAR IfNameWlanIoctl[MAX_WIFI_COUNT][IFNAMSIZ]; /* wireless interface name */ + UCHAR IfNameWlanMAC[MAX_WIFI_COUNT][ETH_ALEN]; /* wireless interface name */ + INT32 IfNameWlanCount; + + BOOLEAN FlgIsTerminated; /* if terminate IAPP daemon */ + + struct in_addr AddrOwn; /* IP address of ethernet interface */ + struct in_addr AddrNetmask; /* netmask of ethernet interface */ + struct in_addr AddrBroadcast; /* broadcast address of ethernet interface */ + + BOOLEAN FlgIsRcvRunning; /* if rcv handler is running */ + + INT32 SocketUdpSend; /* used to send/rcv IAPP multicast frame */ + INT32 SocketTcpRcv; /* used to rcv unicast frame from a peer */ + INT32 SocketRawBr; /* used to send bridge L2 frame */ + INT32 SocketIoctl; /* used to ioctl() to WLAN driver */ + INT32 SocketRawRRB; /* used in RRB RAW protocol */ + +#ifdef FT_KDP_FUNC_SOCK_COMM + INT32 SocketRawDrv; /* used to receive message from driver */ +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifndef FT_KDP_FUNC_SOCK_COMM +#ifdef IAPP_OS_LINUX +#define FT_KDP_PIPE_ID_READ 0 +#define FT_KDP_PIPE_ID_WRITE 1 + INT32 PipeRawDrv[2]; /* used to receive message from driver */ +#endif // IAPP_OS_LINUX // +#endif // FT_KDP_FUNC_SOCK_COMM // + +#ifdef IAPP_OS_VXWORKS + VOID *pBcCookie[FT_KDP_BR_ETH_IF_NUM]; /* for bridge L2 frame */ + VOID *pDrvCookieTo; /* for ioctl to WLAN driver */ + VOID *pDrvCookieFrom; /* for ioctl from WLAN driver */ + VOID *pRrbCookieTo[FT_KDP_BR_ETH_IF_NUM]; /* used in RRB protocol */ + VOID *pRrbCookieFrom; /* for ioctl from WLAN driver */ + +#define IAPP_KDP_PIPE_DRV "/pipe/IAPP_Drv" +#define IAPP_KDP_PIPE_ETH "/pipe/IAPP_Eth" +#endif // IAPP_OS_VXWORKS // + +#ifdef IAPP_EVENT_LOG + INT32 MsgId; + BOOLEAN FlgIsMsgReady; +#endif // IAPP_EVENT_LOG // + + pid_t PID; /* IAPP task PID */ + UINT16 PacketIdentifier; /* used in IAPP frame identifier */ + +#ifdef FT_KDP_FUNC_PKT_ENCRYPT + /* common key, ASCII, the last byte must be 0x00 */ + CHAR CommonKey[IAPP_ENCRYPT_KEY_MAX_SIZE + 1]; +#endif // FT_KDP_FUNC_PKT_ENCRYPT // + + FT_CLIENT_TABLE SelfFtStaTable; +} RTMP_IAPP, *PRTMP_IAPP; + +/* key information */ +#define FT_IP_ADDRESS_SIZE 4 +#define FT_NONCE_SIZE 8 + +#define FT_KDP_WPA_NAME_MAX_SIZE 16 +#define FT_KDP_R0KHID_MAX_SIZE 48 +#define FT_KDP_R1KHID_MAX_SIZE 6 +#define FT_KDP_S1KHID_MAX_SIZE 6 +#define FT_KDP_PMKR1_MAX_SIZE 32 /* 256-bit key */ + +#define FT_R1KH_ENTRY_TABLE_SIZE 64 +#define FT_R1KH_ENTRY_HASH_TABLE_SIZE FT_R1KH_ENTRY_TABLE_SIZE + +typedef struct PACKED _FT_KDP_PMK_KEY_INFO { + + UCHAR R0KHID[FT_KDP_R0KHID_MAX_SIZE]; + UCHAR R0KHIDLen; + UCHAR PMKR0Name[FT_KDP_WPA_NAME_MAX_SIZE]; /* an ID that names the PMK-R0 */ + + UCHAR R1KHID[FT_KDP_R1KHID_MAX_SIZE]; + UCHAR S1KHID[FT_KDP_S1KHID_MAX_SIZE]; + + /* reserved field */ + UCHAR RSV[4]; + +} FT_KDP_PMK_KEY_INFO; + +typedef struct PACKED _FT_KDP_EVT_KEY_ELM { + /* must be 65535, Proprietary Information */ +#define FT_KDP_ELM_ID_PRI 65535 + UINT16 ElmId; + +#define FT_KDP_ELM_PRI_LEN (sizeof(FT_KDP_EVT_KEY_ELM) - 4) + UINT16 ElmLen; + + /* must be 0x00 0x0E 0x2E, RALINK */ +#define FT_KDP_ELM_PRI_OUI_0 0x00 +#define FT_KDP_ELM_PRI_OUI_1 0x0E +#define FT_KDP_ELM_PRI_OUI_2 0x2E +#define FT_KDP_ELM_PRI_OUI_SIZE 3 + UCHAR OUI[3]; + + /* station MAC */ + UCHAR MacAddr[ETH_ALEN]; + UCHAR RSV[3]; + + /* used in request */ + FT_KDP_PMK_KEY_INFO KeyInfo; + + /* used in response */ + UCHAR PMKR1Name[FT_KDP_WPA_NAME_MAX_SIZE]; /* an ID that names the PMK-R1 */ + UCHAR PMKR1[FT_KDP_PMKR1_MAX_SIZE]; /* PMK R1 Key */ + UCHAR R0KH_MAC[ETH_ALEN]; /* MAC of R0KH */ + + /* + During a Fast BSS Transition a non-AP STA shall negotiate the same + pairwise cipher suite with Target APs as was negotiated in the FT + Initial Mobility Domain association. The target AP shall verify + that the same pairwise cipher suite selector is used, using the + pairwise cipher suite selector value in the PMK-R1 SA received from + the R0KH. + */ + UCHAR PairwisChipher[4]; + UCHAR AkmSuite[4]; + + UINT32 KeyLifeTime; + UINT32 ReassocDeadline; +} FT_KDP_EVT_KEY_ELM; + +/* ---------------------------- API Definition ------------------------ */ + +VOID IAPP_HexDump(CHAR *pPromptStr, CHAR *pSrcBufVA, UINT32 SrcBufLen); + +BOOLEAN IAPP_IoctlToWLAN(RTMP_IAPP *pCtrlBK, INT32 Param, CHAR *pData, + INT32 *pDataLen, UCHAR ApIdx, INT32 Flags); + +BOOLEAN mt_iapp_get_wifi_iface_mac(RTMP_IAPP *pCtrlBK); + +INT32 mt_iapp_find_ifidx_by_mac(RTMP_IAPP *pCtrlBK, UCHAR *WifiMAC); + +VOID mt_iapp_set_daemon_information(RTMP_IAPP *pCtrlBK, pid_t *pPidAuth); + +VOID mt_iapp_ft_client_table_init(RTMP_IAPP *pCtrlBK); + +FT_CLIENT_INFO *mt_iapp_ft_client_look_up(FT_CLIENT_TABLE *pFtTable, + UCHAR *pAddr); + +FT_CLIENT_INFO *mt_iapp_ft_client_insert(FT_CLIENT_TABLE *pFtTable, + UCHAR *pStaAddr, UCHAR *pApAddr, + INT32 ApIfIdx); + +VOID mt_iapp_ft_client_delete(FT_CLIENT_TABLE *pFtTable, UCHAR *pStaAddr); + +INT32 mt_iapp_find_ifidx_by_sta_mac(FT_CLIENT_TABLE *pFtTable, UCHAR *pStaMAC); + +#endif /* __RTMP_IAPP_H__ */ + +/* End of rtmp_iapp.h */ diff --git a/package/libs/argp-standalone/Makefile b/package/libs/argp-standalone/Makefile index 8fad739d8..1a48dcb2c 100644 --- a/package/libs/argp-standalone/Makefile +++ b/package/libs/argp-standalone/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=argp-standalone PKG_VERSION:=1.3 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.lysator.liu.se/~nisse/misc/ @@ -20,6 +20,7 @@ PKG_LICENSE:=LGPL-2.1 PKG_LICENSE:=Makefile.am include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk define Package/argp-standalone SECTION:=libs @@ -33,8 +34,10 @@ define Package/argp-standalone/description endef MAKE_FLAGS += \ - CFLAGS="$(TARGET_CFLAGS) $(FPIC)" + CFLAGS="$(TARGET_CFLAGS) $(FPIC) -std=gnu89" +HOST_MAKE_FLAGS += \ + CFLAGS="$(HOST_CFLAGS) $(FPIC) -std=gnu89" define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include @@ -45,4 +48,14 @@ define Build/InstallDev $(1)/usr/lib/ endef +define Host/Install + $(INSTALL_DIR) $(1)/include + $(CP) $(HOST_BUILD_DIR)/argp.h \ + $(1)/include/ + $(INSTALL_DIR) $(1)/lib + $(CP) $(HOST_BUILD_DIR)/libargp.a \ + $(1)/lib/ +endef + $(eval $(call BuildPackage,argp-standalone)) +$(eval $(call HostBuild)) diff --git a/package/libs/elfutils/Makefile b/package/libs/elfutils/Makefile index 9aa78d835..d4e5d994e 100644 --- a/package/libs/elfutils/Makefile +++ b/package/libs/elfutils/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=elfutils -PKG_VERSION:=0.186 +PKG_VERSION:=0.188 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) -PKG_HASH:=7f6fb9149b1673d38d9178a0d3e0fb8a1ec4f53a9f4c2ff89469609879641177 +PKG_HASH:=fb8b0e8d0802005b9a309c60c1d8de32dd2951b56f0c3a3cb56d21ce01595dff PKG_MAINTAINER:=Luiz Angelo Daros de Luca PKG_LICENSE:=GPL-3.0-or-later @@ -26,7 +26,6 @@ PKG_BUILD_DEPENDS:=!USE_GLIBC:argp-standalone include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/nls.mk -include $(INCLUDE_DIR)/host-build.mk define Package/elfutils/Default SECTION:=libs @@ -62,6 +61,8 @@ CONFIGURE_ARGS += --disable-nls endif HOST_CONFIGURE_ARGS += \ + --disable-shared \ + --disable-nls \ --disable-debuginfod \ --disable-libdebuginfod \ --without-lzma \ @@ -110,7 +111,6 @@ define Package/libelf/install endef # these lines need to be ordered by dependency because of ABI versioning -$(eval $(call HostBuild)) $(eval $(call BuildPackage,libelf)) $(eval $(call BuildPackage,libdw)) $(eval $(call BuildPackage,libasm)) diff --git a/package/libs/elfutils/patches/003-libintl-compatibility.patch b/package/libs/elfutils/patches/003-libintl-compatibility.patch index 3254dcffb..ce71602d7 100644 --- a/package/libs/elfutils/patches/003-libintl-compatibility.patch +++ b/package/libs/elfutils/patches/003-libintl-compatibility.patch @@ -11,7 +11,7 @@ Requires.private: zlib --- a/configure.ac +++ b/configure.ac -@@ -610,6 +610,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo +@@ -652,6 +652,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo AM_GNU_GETTEXT_VERSION([0.19.6]) AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6]) diff --git a/package/libs/elfutils/patches/100-musl-compat.patch b/package/libs/elfutils/patches/100-musl-compat.patch index 52b9f2c43..3fa095bd7 100644 --- a/package/libs/elfutils/patches/100-musl-compat.patch +++ b/package/libs/elfutils/patches/100-musl-compat.patch @@ -9,7 +9,7 @@ } --- a/libdwfl/dwfl_error.c +++ b/libdwfl/dwfl_error.c -@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) +@@ -139,6 +139,7 @@ __libdwfl_seterrno (Dwfl_Error error) static const char * errnomsg(int error) { @@ -17,7 +17,7 @@ /* Won't be changed by strerror_r, but not const so compiler doesn't throw warning */ static char unknown[] = "unknown error"; -@@ -150,6 +151,9 @@ errnomsg(int error) +@@ -149,6 +150,9 @@ errnomsg(int error) static __thread char msg[128]; return strerror_r (error, msg, sizeof (msg)) ? unknown : msg; #endif diff --git a/package/libs/elfutils/patches/101-no-fts.patch b/package/libs/elfutils/patches/101-no-fts.patch index c4f0b8823..29a6c4b36 100644 --- a/package/libs/elfutils/patches/101-no-fts.patch +++ b/package/libs/elfutils/patches/101-no-fts.patch @@ -1,6 +1,6 @@ --- a/libdwfl/argp-std.c +++ b/libdwfl/argp-std.c -@@ -53,9 +53,6 @@ static const struct argp_option options[ +@@ -51,9 +51,6 @@ static const struct argp_option options[ { "linux-process-map", 'M', "FILE", 0, N_("Find addresses in files mapped as read from FILE" " in Linux /proc/PID/maps format"), 0 }, @@ -10,7 +10,7 @@ { "debuginfo-path", OPT_DEBUGINFO, "PATH", 0, N_("Search path for separate debuginfo files"), 0 }, { NULL, 0, NULL, 0, NULL, 0 } -@@ -82,15 +79,6 @@ static const Dwfl_Callbacks proc_callbac +@@ -80,15 +77,6 @@ static const Dwfl_Callbacks proc_callbac .find_elf = INTUSE(dwfl_linux_proc_find_elf), }; @@ -26,7 +26,7 @@ /* Structure held at state->HOOK. */ struct parse_opt { -@@ -223,43 +211,6 @@ parse_opt (int key, char *arg, struct ar +@@ -221,43 +209,6 @@ parse_opt (int key, char *arg, struct ar } break; diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile index 8111a36f5..2319401ba 100644 --- a/package/libs/gettext-full/Makefile +++ b/package/libs/gettext-full/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gettext-full -PKG_VERSION:=0.21 -PKG_RELEASE:=2 +PKG_VERSION:=0.21.1 +PKG_RELEASE:=1 PKG_SOURCE:=gettext-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/gettext -PKG_HASH:=d20fcbb537e02dcf1383197ba05bd0734ef7bf5db06bdb241eb69b7d16b73192 +PKG_HASH:=50dbc8f39797950aa2c98e939947c527e5ac9ebd2c1b99dd7b06ba33a6767ae6 PKG_BUILD_DIR:=$(BUILD_DIR)/gettext-$(PKG_VERSION) HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/gettext-$(PKG_VERSION) @@ -24,8 +24,8 @@ PKG_CPE_ID:=cpe:/a:gnu:gettext PKG_FIXUP:=autoreconf PKG_INSTALL:=1 PKG_BUILD_DEPENDS:=gettext-full/host -PKG_BUILD_PARALLEL:=1 -HOST_BUILD_PARALLEL:=1 +PKG_BUILD_PARALLEL:=0 +HOST_BUILD_PARALLEL:=0 include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk @@ -88,6 +88,11 @@ define Build/InstallDev $(SED) '/read dummy/d' $(STAGING_DIR_HOSTPKG)/bin/gettextize endef +define Host/Install + $(call Host/Install/Default) + $(LN) msgfmt $(STAGING_DIR_HOSTPKG)/bin/gmsgfmt +endef + define Package/libintl-full/install $(INSTALL_DIR) $(1)/usr/lib $(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.so.* $(1)/usr/lib/ diff --git a/package/libs/gettext-full/patches/001-autotools.patch b/package/libs/gettext-full/patches/001-autotools.patch index 034fc938a..7e1f005dc 100644 --- a/package/libs/gettext-full/patches/001-autotools.patch +++ b/package/libs/gettext-full/patches/001-autotools.patch @@ -12,7 +12,7 @@ $(INSTALL_DATA) $$dir/$$file $(DESTDIR)$(htmldir)/$$file; \ --- a/gettext-tools/man/Makefile.am +++ b/gettext-tools/man/Makefile.am -@@ -157,8 +157,7 @@ recode-sr-latin.1.html: recode-sr-latin. +@@ -158,8 +158,7 @@ recode-sr-latin.1.html: recode-sr-latin. gettextize.1.html: gettextize.1 autopoint.1.html: autopoint.1 diff --git a/package/libs/gettext-full/patches/010-m4.patch b/package/libs/gettext-full/patches/010-m4.patch index 6d08835e3..fe896db31 100644 --- a/package/libs/gettext-full/patches/010-m4.patch +++ b/package/libs/gettext-full/patches/010-m4.patch @@ -1,14 +1,14 @@ --- a/gettext-runtime/gnulib-m4/stddef_h.m4 +++ b/gettext-runtime/gnulib-m4/stddef_h.m4 -@@ -8,7 +8,7 @@ dnl with or without modifications, as lo - AC_DEFUN([gl_STDDEF_H], +@@ -9,7 +9,7 @@ dnl A placeholder for , for pl + AC_DEFUN_ONCE([gl_STDDEF_H], [ AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) - AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) - STDDEF_H= - dnl Test whether the type max_align_t exists and whether its alignment + dnl Persuade OpenBSD to declare max_align_t. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) --- a/gettext-runtime/gnulib-m4/stdint.m4 +++ b/gettext-runtime/gnulib-m4/stdint.m4 @@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H], @@ -22,7 +22,7 @@ dnl macros. --- a/gettext-runtime/gnulib-m4/wchar_h.m4 +++ b/gettext-runtime/gnulib-m4/wchar_h.m4 -@@ -27,7 +27,7 @@ AC_DEFUN([gl_WCHAR_H], +@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H], AC_REQUIRE([gl_FEATURES_H]) @@ -44,7 +44,7 @@ [AC_COMPILE_IFELSE( --- a/gettext-runtime/gnulib-m4/wctype_h.m4 +++ b/gettext-runtime/gnulib-m4/wctype_h.m4 -@@ -22,7 +22,7 @@ AC_DEFUN([gl_WCTYPE_H], +@@ -22,7 +22,7 @@ AC_DEFUN_ONCE([gl_WCTYPE_H], fi AC_SUBST([HAVE_ISWCNTRL]) @@ -77,26 +77,6 @@ [ AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], [AC_COMPILE_IFELSE( ---- a/gettext-runtime/intl/Makefile.am -+++ b/gettext-runtime/intl/Makefile.am -@@ -274,7 +274,7 @@ libgnuintl.h: $(srcdir)/libgnuintl.in.h - -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ - -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ - -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ -- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \ -+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \ - -e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \ - < $(srcdir)/libgnuintl.in.h \ - | if test '@WOE32DLL@' = yes; then \ -@@ -294,7 +294,7 @@ libintl.h: $(srcdir)/libgnuintl.in.h - -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ - -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ - -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ -- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \ -+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \ - -e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \ - < $(srcdir)/libgnuintl.in.h > libintl.h - MOSTLYCLEANFILES += libintl.h --- a/gettext-runtime/libasprintf/configure.ac +++ b/gettext-runtime/libasprintf/configure.ac @@ -76,8 +76,8 @@ dnl Checks for typedefs, structures, and @@ -145,30 +125,6 @@ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) AC_REQUIRE([gt_TYPE_INTMAX_T]) AC_REQUIRE([gt_PRINTF_POSIX]) ---- a/gettext-tools/gnulib-m4/gnulib-comp.m4 -+++ b/gettext-tools/gnulib-m4/gnulib-comp.m4 -@@ -1843,8 +1843,8 @@ changequote([, ])dnl - AC_REQUIRE([gl_SOCKETS]) - gl_TYPE_SOCKLEN_T - gl_STDALIGN_H -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - gl_FUNC_STRERROR_R - if test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1; then - AC_LIBOBJ([strerror_r]) ---- a/gettext-tools/gnulib-m4/stddef_h.m4 -+++ b/gettext-tools/gnulib-m4/stddef_h.m4 -@@ -8,7 +8,7 @@ dnl with or without modifications, as lo - AC_DEFUN([gl_STDDEF_H], - [ - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) - STDDEF_H= - - dnl Test whether the type max_align_t exists and whether its alignment --- a/gettext-tools/gnulib-m4/stdint.m4 +++ b/gettext-tools/gnulib-m4/stdint.m4 @@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H], @@ -216,7 +172,7 @@ dnl is defined as a weak alias of snprintf; we prefer to use the latter). --- a/gettext-tools/gnulib-m4/wchar_h.m4 +++ b/gettext-tools/gnulib-m4/wchar_h.m4 -@@ -27,7 +27,7 @@ AC_DEFUN([gl_WCHAR_H], +@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H], AC_REQUIRE([gl_FEATURES_H]) @@ -238,7 +194,7 @@ [AC_COMPILE_IFELSE( --- a/gettext-tools/gnulib-m4/wctype_h.m4 +++ b/gettext-tools/gnulib-m4/wctype_h.m4 -@@ -22,7 +22,7 @@ AC_DEFUN([gl_WCTYPE_H], +@@ -22,7 +22,7 @@ AC_DEFUN_ONCE([gl_WCTYPE_H], fi AC_SUBST([HAVE_ISWCNTRL]) @@ -271,37 +227,6 @@ [ AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], [AC_COMPILE_IFELSE( ---- a/gettext-tools/intl/Makefile.am -+++ b/gettext-tools/intl/Makefile.am -@@ -274,7 +274,7 @@ libgnuintl.h: $(srcdir)/libgnuintl.in.h - -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ - -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ - -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ -- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \ -+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \ - -e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \ - < $(srcdir)/libgnuintl.in.h \ - | if test '@WOE32DLL@' = yes; then \ -@@ -294,7 +294,7 @@ libintl.h: $(srcdir)/libgnuintl.in.h - -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ - -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ - -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ -- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \ -+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \ - -e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \ - < $(srcdir)/libgnuintl.in.h > libintl.h - MOSTLYCLEANFILES += libintl.h ---- a/libtextstyle/gnulib-m4/stddef_h.m4 -+++ b/libtextstyle/gnulib-m4/stddef_h.m4 -@@ -8,7 +8,7 @@ dnl with or without modifications, as lo - AC_DEFUN([gl_STDDEF_H], - [ - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) - STDDEF_H= - - dnl Test whether the type max_align_t exists and whether its alignment --- a/libtextstyle/gnulib-m4/stdint.m4 +++ b/libtextstyle/gnulib-m4/stdint.m4 @@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H], @@ -349,7 +274,7 @@ dnl is defined as a weak alias of snprintf; we prefer to use the latter). --- a/libtextstyle/gnulib-m4/wchar_h.m4 +++ b/libtextstyle/gnulib-m4/wchar_h.m4 -@@ -27,7 +27,7 @@ AC_DEFUN([gl_WCHAR_H], +@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H], AC_REQUIRE([gl_FEATURES_H]) @@ -380,3 +305,38 @@ [ AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], [AC_COMPILE_IFELSE( +--- a/gettext-tools/gnulib-m4/gnulib-comp.m4 ++++ b/gettext-tools/gnulib-m4/gnulib-comp.m4 +@@ -2218,8 +2218,8 @@ changequote([, ])dnl + AC_REQUIRE([gl_SOCKETLIB]) + AC_REQUIRE([gl_SOCKETS]) + gl_TYPE_SOCKLEN_T +- AC_REQUIRE([gt_TYPE_WCHAR_T]) +- AC_REQUIRE([gt_TYPE_WINT_T]) ++ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) ++ AC_REQUIRE([gt_TYPE_WINT_T_GT]) + gl_FUNC_STRERROR_R + AS_IF([test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1], [ + AC_LIBOBJ([strerror_r]) +--- a/libtextstyle/gnulib-m4/stddef_h.m4 ++++ b/libtextstyle/gnulib-m4/stddef_h.m4 +@@ -9,7 +9,7 @@ dnl A placeholder for , for pl + AC_DEFUN_ONCE([gl_STDDEF_H], + [ + AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) +- AC_REQUIRE([gt_TYPE_WCHAR_T]) ++ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) + + dnl Persuade OpenBSD to declare max_align_t. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) +--- a/gettext-tools/gnulib-m4/stddef_h.m4 ++++ b/gettext-tools/gnulib-m4/stddef_h.m4 +@@ -9,7 +9,7 @@ dnl A placeholder for , for pl + AC_DEFUN_ONCE([gl_STDDEF_H], + [ + AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) +- AC_REQUIRE([gt_TYPE_WCHAR_T]) ++ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) + + dnl Persuade OpenBSD to declare max_align_t. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) diff --git a/package/libs/gettext/Makefile b/package/libs/gettext/Makefile deleted file mode 100644 index f37c4e4e7..000000000 --- a/package/libs/gettext/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (C) 2010 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=gettext -PKG_RELEASE:=2 - -PKG_LICENSE:=FSFULLR -PKG_LICENSE_FILES:=LICENSE - -PKG_MAINTAINER:=Jo-Philipp Wich - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/host-build.mk - -define Package/libintl - SECTION:=libs - CATEGORY:=Libraries - TITLE:=Stub header for the GNU Internationalization library -endef - -define Build/Configure -endef - -define Build/Compile -endef - -define Build/InstallDev - $(INSTALL_DIR) $(1)/usr/lib/libintl-stub/include - $(INSTALL_DATA) $(PKG_BUILD_DIR)/include/libintl.h $(1)/usr/lib/libintl-stub/include/ - - $(INSTALL_DIR) $(1)/usr/share/aclocal - $(INSTALL_DATA) $(PKG_BUILD_DIR)/m4/* $(1)/usr/share/aclocal/ -endef - -define Host/Prepare - mkdir -p $(HOST_BUILD_DIR) -endef - -define Host/Compile - -endef - -define Host/Install - $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/include - $(INSTALL_DATA) ./src/include/libintl.h $(STAGING_DIR_HOSTPKG)/include/ - - $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/share/aclocal - $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOSTPKG)/share/aclocal/ -endef - -define Package/libintl/install - $(INSTALL_DIR) $(1)/tmp - touch $(1)/tmp/.libintl-placeholder -endef - -$(eval $(call HostBuild)) -$(eval $(call BuildPackage,libintl)) diff --git a/package/libs/gettext/src/LICENSE b/package/libs/gettext/src/LICENSE deleted file mode 100644 index d1a59b05e..000000000 --- a/package/libs/gettext/src/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Each source file contains the following message: - -Copyright (C) 1995-2010 Free Software Foundation, Inc. -This file is free software; the Free Software Foundation -gives unlimited permission to copy and/or distribute it, -with or without modifications, as long as this notice is preserved. - diff --git a/package/libs/gettext/src/include/libintl.h b/package/libs/gettext/src/include/libintl.h deleted file mode 100644 index a1157a445..000000000 --- a/package/libs/gettext/src/include/libintl.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This code is lifted from http://permalink.gmane.org/gmane.linux.gentoo.embedded/3218 - */ - -#ifndef _LIBINTL_H -#define _LIBINTL_H 1 - -#include - -/* Undef gettext macros, if any... */ -#undef gettext -#undef dgettext -#undef dcgettext -#undef ngettext -#undef dngettext -#undef dcngettext -#undef textdomain -#undef bindtextdomain -#undef bind_textdomain_codeset - -/* part of locale.h */ -/* #undef setlocale */ - -#undef _ -#undef N_ - -/* Define gettext stubs that map back to the original strings */ -#define gettext(String) (String) -#define dgettext(Domain, String) (String) -#define dcgettext(Domain, String, Type) (String) - -#define ngettext(Singular, Plural, Count) \ - ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural)) - -#define dngettext(Domain, Singular, Plural, Count) \ - ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural)) - -#define dcngettext(Domain, Singular, Plural, Count, Category) \ - ((Count) == 1 ? (const char *) (Singular) : (const char *) (Plural)) - -#define _(String) (String) -#define N_(String) String - -#ifndef _LOCALE_H -/* #define setlocale(Category, Locale) ((char *)NULL) */ -#endif - -/* No-ops for textdomain operations */ -#define bindtextdomain(Domain, Directory) (Domain) -#define bind_textdomain_codeset(Domain, Codeset) (Codeset) -#define textdomain(String) (String) ?: "messages" - -#endif /* _LIBINTL_H */ diff --git a/package/libs/gettext/src/m4/codeset.m4 b/package/libs/gettext/src/m4/codeset.m4 deleted file mode 100644 index a53c04260..000000000 --- a/package/libs/gettext/src/m4/codeset.m4 +++ /dev/null @@ -1,21 +0,0 @@ -# codeset.m4 serial 4 (gettext-0.18) -dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([AM_LANGINFO_CODESET], -[ - AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], - [AC_TRY_LINK([#include ], - [char* cs = nl_langinfo(CODESET); return !cs;], - [am_cv_langinfo_codeset=yes], - [am_cv_langinfo_codeset=no]) - ]) - if test $am_cv_langinfo_codeset = yes; then - AC_DEFINE([HAVE_LANGINFO_CODESET], [1], - [Define if you have and nl_langinfo(CODESET).]) - fi -]) diff --git a/package/libs/gettext/src/m4/gettext.m4 b/package/libs/gettext/src/m4/gettext.m4 deleted file mode 100644 index f84e6a5d7..000000000 --- a/package/libs/gettext/src/m4/gettext.m4 +++ /dev/null @@ -1,383 +0,0 @@ -# gettext.m4 serial 63 (gettext-0.18) -dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2006, 2008-2010. - -dnl Macro to add for using GNU gettext. - -dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). -dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The -dnl default (if it is not specified or empty) is 'no-libtool'. -dnl INTLSYMBOL should be 'external' for packages with no intl directory, -dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. -dnl If INTLSYMBOL is 'use-libtool', then a libtool library -dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, -dnl depending on --{enable,disable}-{shared,static} and on the presence of -dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library -dnl $(top_builddir)/intl/libintl.a will be created. -dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext -dnl implementations (in libc or libintl) without the ngettext() function -dnl will be ignored. If NEEDSYMBOL is specified and is -dnl 'need-formatstring-macros', then GNU gettext implementations that don't -dnl support the ISO C 99 formatstring macros will be ignored. -dnl INTLDIR is used to find the intl libraries. If empty, -dnl the value `$(top_builddir)/intl/' is used. -dnl -dnl The result of the configuration is one of three cases: -dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled -dnl and used. -dnl Catalog format: GNU --> install in $(datadir) -dnl Catalog extension: .mo after installation, .gmo in source tree -dnl 2) GNU gettext has been found in the system's C library. -dnl Catalog format: GNU --> install in $(datadir) -dnl Catalog extension: .mo after installation, .gmo in source tree -dnl 3) No internationalization, always use English msgid. -dnl Catalog format: none -dnl Catalog extension: none -dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. -dnl The use of .gmo is historical (it was needed to avoid overwriting the -dnl GNU format catalogs when building on a platform with an X/Open gettext), -dnl but we keep it in order not to force irrelevant filename changes on the -dnl maintainers. -dnl -AC_DEFUN([AM_GNU_GETTEXT], -[ - dnl Argument checking. - ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , - [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT -])])])])]) - ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], - [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) - ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , - [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT -])])])]) - define([gt_included_intl], - ifelse([$1], [external], - ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), - [yes])) - define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) - gt_NEEDS_INIT - AM_GNU_GETTEXT_NEED([$2]) - - AC_REQUIRE([AM_PO_SUBDIRS])dnl - ifelse(gt_included_intl, yes, [ - AC_REQUIRE([AM_INTL_SUBDIR])dnl - ]) - - dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - - dnl Sometimes libintl requires libiconv, so first search for libiconv. - dnl Ideally we would do this search only after the - dnl if test "$USE_NLS" = "yes"; then - dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then - dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT - dnl the configure script would need to contain the same shell code - dnl again, outside any 'if'. There are two solutions: - dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. - dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. - dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not - dnl documented, we avoid it. - ifelse(gt_included_intl, yes, , [ - AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - ]) - - dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. - gt_INTL_MACOSX - - dnl Set USE_NLS. - AC_REQUIRE([AM_NLS]) - - ifelse(gt_included_intl, yes, [ - BUILD_INCLUDED_LIBINTL=no - USE_INCLUDED_LIBINTL=no - ]) - LIBINTL= - LTLIBINTL= - POSUB= - - dnl Add a version number to the cache macros. - case " $gt_needs " in - *" need-formatstring-macros "*) gt_api_version=3 ;; - *" need-ngettext "*) gt_api_version=2 ;; - *) gt_api_version=1 ;; - esac - gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" - gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" - - dnl If we use NLS figure out what method - if test "$USE_NLS" = "yes"; then - gt_use_preinstalled_gnugettext=no - ifelse(gt_included_intl, yes, [ - AC_MSG_CHECKING([whether included gettext is requested]) - AC_ARG_WITH([included-gettext], - [ --with-included-gettext use the GNU gettext library included here], - nls_cv_force_use_gnu_gettext=$withval, - nls_cv_force_use_gnu_gettext=no) - AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) - - nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" - if test "$nls_cv_force_use_gnu_gettext" != "yes"; then - ]) - dnl User does not insist on using GNU NLS library. Figure out what - dnl to use. If GNU gettext is available we use this. Else we have - dnl to fall back to GNU NLS library. - - if test $gt_api_version -ge 3; then - gt_revision_test_code=' -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -#endif -changequote(,)dnl -typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -changequote([,])dnl -' - else - gt_revision_test_code= - fi - if test $gt_api_version -ge 2; then - gt_expression_test_code=' + * ngettext ("", "", 0)' - else - gt_expression_test_code= - fi - - AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], - [AC_TRY_LINK([#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern int *_nl_domain_bindings;], - [bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], - [eval "$gt_func_gnugettext_libc=yes"], - [eval "$gt_func_gnugettext_libc=no"])]) - - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then - dnl Sometimes libintl requires libiconv, so first search for libiconv. - ifelse(gt_included_intl, yes, , [ - AM_ICONV_LINK - ]) - dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL - dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) - dnl because that would add "-liconv" to LIBINTL and LTLIBINTL - dnl even if libiconv doesn't exist. - AC_LIB_LINKFLAGS_BODY([intl]) - AC_CACHE_CHECK([for GNU gettext in libintl], - [$gt_func_gnugettext_libintl], - [gt_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $INCINTL" - gt_save_LIBS="$LIBS" - LIBS="$LIBS $LIBINTL" - dnl Now see whether libintl exists and does not depend on libiconv. - AC_TRY_LINK([#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *);], - [bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], - [eval "$gt_func_gnugettext_libintl=yes"], - [eval "$gt_func_gnugettext_libintl=no"]) - dnl Now see whether libintl exists and depends on libiconv. - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then - LIBS="$LIBS $LIBICONV" - AC_TRY_LINK([#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *);], - [bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], - [LIBINTL="$LIBINTL $LIBICONV" - LTLIBINTL="$LTLIBINTL $LTLIBICONV" - eval "$gt_func_gnugettext_libintl=yes" - ]) - fi - CPPFLAGS="$gt_save_CPPFLAGS" - LIBS="$gt_save_LIBS"]) - fi - - dnl If an already present or preinstalled GNU gettext() is found, - dnl use it. But if this macro is used in GNU gettext, and GNU - dnl gettext is already preinstalled in libintl, we update this - dnl libintl. (Cf. the install rule in intl/Makefile.in.) - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ - || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ - && test "$PACKAGE" != gettext-runtime \ - && test "$PACKAGE" != gettext-tools; }; then - gt_use_preinstalled_gnugettext=yes - else - dnl Reset the values set by searching for libintl. - LIBINTL= - LTLIBINTL= - INCINTL= - fi - - ifelse(gt_included_intl, yes, [ - if test "$gt_use_preinstalled_gnugettext" != "yes"; then - dnl GNU gettext is not found in the C library. - dnl Fall back on included GNU gettext library. - nls_cv_use_gnu_gettext=yes - fi - fi - - if test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Mark actions used to generate GNU NLS library. - BUILD_INCLUDED_LIBINTL=yes - USE_INCLUDED_LIBINTL=yes - LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" - LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" - LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` - fi - - CATOBJEXT= - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Mark actions to use GNU gettext tools. - CATOBJEXT=.gmo - fi - ]) - - if test -n "$INTL_MACOSX_LIBS"; then - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - dnl Some extra flags are needed during linking. - LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" - LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" - fi - fi - - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - AC_DEFINE([ENABLE_NLS], [1], - [Define to 1 if translation of program messages to the user's native language - is requested.]) - else - USE_NLS=no - fi - fi - - AC_MSG_CHECKING([whether to use NLS]) - AC_MSG_RESULT([$USE_NLS]) - if test "$USE_NLS" = "yes"; then - AC_MSG_CHECKING([where the gettext function comes from]) - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - gt_source="external libintl" - else - gt_source="libc" - fi - else - gt_source="included intl directory" - fi - AC_MSG_RESULT([$gt_source]) - fi - - if test "$USE_NLS" = "yes"; then - - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - AC_MSG_CHECKING([how to link with libintl]) - AC_MSG_RESULT([$LIBINTL]) - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) - fi - - dnl For backward compatibility. Some packages may be using this. - AC_DEFINE([HAVE_GETTEXT], [1], - [Define if the GNU gettext() function is already present or preinstalled.]) - AC_DEFINE([HAVE_DCGETTEXT], [1], - [Define if the GNU dcgettext() function is already present or preinstalled.]) - fi - - dnl We need to process the po/ directory. - POSUB=po - fi - - ifelse(gt_included_intl, yes, [ - dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL - dnl to 'yes' because some of the testsuite requires it. - if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then - BUILD_INCLUDED_LIBINTL=yes - fi - - dnl Make all variables we use known to autoconf. - AC_SUBST([BUILD_INCLUDED_LIBINTL]) - AC_SUBST([USE_INCLUDED_LIBINTL]) - AC_SUBST([CATOBJEXT]) - - dnl For backward compatibility. Some configure.ins may be using this. - nls_cv_header_intl= - nls_cv_header_libgt= - - dnl For backward compatibility. Some Makefiles may be using this. - DATADIRNAME=share - AC_SUBST([DATADIRNAME]) - - dnl For backward compatibility. Some Makefiles may be using this. - INSTOBJEXT=.mo - AC_SUBST([INSTOBJEXT]) - - dnl For backward compatibility. Some Makefiles may be using this. - GENCAT=gencat - AC_SUBST([GENCAT]) - - dnl For backward compatibility. Some Makefiles may be using this. - INTLOBJS= - if test "$USE_INCLUDED_LIBINTL" = yes; then - INTLOBJS="\$(GETTOBJS)" - fi - AC_SUBST([INTLOBJS]) - - dnl Enable libtool support if the surrounding package wishes it. - INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix - AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) - ]) - - dnl For backward compatibility. Some Makefiles may be using this. - INTLLIBS="$LIBINTL" - AC_SUBST([INTLLIBS]) - - dnl Make all documented variables known to autoconf. - AC_SUBST([LIBINTL]) - AC_SUBST([LTLIBINTL]) - AC_SUBST([POSUB]) -]) - - -dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. -m4_define([gt_NEEDS_INIT], -[ - m4_divert_text([DEFAULTS], [gt_needs=]) - m4_define([gt_NEEDS_INIT], []) -]) - - -dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) -AC_DEFUN([AM_GNU_GETTEXT_NEED], -[ - m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) -]) - - -dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) -AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) diff --git a/package/libs/gettext/src/m4/intl.m4 b/package/libs/gettext/src/m4/intl.m4 deleted file mode 100644 index 335b23c20..000000000 --- a/package/libs/gettext/src/m4/intl.m4 +++ /dev/null @@ -1,294 +0,0 @@ -# intl.m4 serial 17 (gettext-0.18) -dnl Copyright (C) 1995-2009 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2009. - -AC_PREREQ([2.52]) - -dnl Checks for all prerequisites of the intl subdirectory, -dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, -dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. -AC_DEFUN([AM_INTL_SUBDIR], -[ - AC_REQUIRE([AC_PROG_INSTALL])dnl - AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake - AC_REQUIRE([AC_PROG_CC])dnl - AC_REQUIRE([AC_CANONICAL_HOST])dnl - AC_REQUIRE([gt_GLIBC2])dnl - AC_REQUIRE([AC_PROG_RANLIB])dnl - AC_REQUIRE([gl_VISIBILITY])dnl - AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl - AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl - AC_REQUIRE([gt_TYPE_WCHAR_T])dnl - AC_REQUIRE([gt_TYPE_WINT_T])dnl - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([gt_TYPE_INTMAX_T]) - AC_REQUIRE([gt_PRINTF_POSIX]) - AC_REQUIRE([gl_GLIBC21])dnl - AC_REQUIRE([gl_XSIZE])dnl - AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl - AC_REQUIRE([gt_INTL_MACOSX])dnl - - dnl Support for automake's --enable-silent-rules. - case "$enable_silent_rules" in - yes) INTL_DEFAULT_VERBOSITY=0;; - no) INTL_DEFAULT_VERBOSITY=1;; - *) INTL_DEFAULT_VERBOSITY=1;; - esac - AC_SUBST([INTL_DEFAULT_VERBOSITY]) - - AC_CHECK_TYPE([ptrdiff_t], , - [AC_DEFINE([ptrdiff_t], [long], - [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) - ]) - AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) - AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \ - snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) - - dnl Use the _snprintf function only if it is declared (because on NetBSD it - dnl is defined as a weak alias of snprintf; we prefer to use the latter). - gt_CHECK_DECL(_snprintf, [#include ]) - gt_CHECK_DECL(_snwprintf, [#include ]) - - dnl Use the *_unlocked functions only if they are declared. - dnl (because some of them were defined without being declared in Solaris - dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built - dnl on Solaris 2.5.1 to run on Solaris 2.6). - dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. - gt_CHECK_DECL(getc_unlocked, [#include ]) - - case $gt_cv_func_printf_posix in - *yes) HAVE_POSIX_PRINTF=1 ;; - *) HAVE_POSIX_PRINTF=0 ;; - esac - AC_SUBST([HAVE_POSIX_PRINTF]) - if test "$ac_cv_func_asprintf" = yes; then - HAVE_ASPRINTF=1 - else - HAVE_ASPRINTF=0 - fi - AC_SUBST([HAVE_ASPRINTF]) - if test "$ac_cv_func_snprintf" = yes; then - HAVE_SNPRINTF=1 - else - HAVE_SNPRINTF=0 - fi - AC_SUBST([HAVE_SNPRINTF]) - if test "$ac_cv_func_newlocale" = yes; then - HAVE_NEWLOCALE=1 - else - HAVE_NEWLOCALE=0 - fi - AC_SUBST([HAVE_NEWLOCALE]) - if test "$ac_cv_func_wprintf" = yes; then - HAVE_WPRINTF=1 - else - HAVE_WPRINTF=0 - fi - AC_SUBST([HAVE_WPRINTF]) - - AM_LANGINFO_CODESET - gt_LC_MESSAGES - - dnl Compilation on mingw and Cygwin needs special Makefile rules, because - dnl 1. when we install a shared library, we must arrange to export - dnl auxiliary pointer variables for every exported variable, - dnl 2. when we install a shared library and a static library simultaneously, - dnl the include file specifies __declspec(dllimport) and therefore we - dnl must arrange to define the auxiliary pointer variables for the - dnl exported variables _also_ in the static library. - if test "$enable_shared" = yes; then - case "$host_os" in - mingw* | cygwin*) is_woe32dll=yes ;; - *) is_woe32dll=no ;; - esac - else - is_woe32dll=no - fi - WOE32DLL=$is_woe32dll - AC_SUBST([WOE32DLL]) - - dnl On mingw and Cygwin, we can activate special Makefile rules which add - dnl version information to the shared libraries and executables. - case "$host_os" in - mingw* | cygwin*) is_woe32=yes ;; - *) is_woe32=no ;; - esac - WOE32=$is_woe32 - AC_SUBST([WOE32]) - if test $WOE32 = yes; then - dnl Check for a program that compiles Windows resource files. - AC_CHECK_TOOL([WINDRES], [windres]) - fi - - dnl Determine whether when creating a library, "-lc" should be passed to - dnl libtool or not. On many platforms, it is required for the libtool option - dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool - dnl in the *.la files - makes it impossible to create multithreaded programs, - dnl because libtool also reorders the -lc to come before the -pthread, and - dnl this disables pthread_create() . - case "$host_os" in - hpux*) LTLIBC="" ;; - *) LTLIBC="-lc" ;; - esac - AC_SUBST([LTLIBC]) - - dnl Rename some macros and functions used for locking. - AH_BOTTOM([ -#define __libc_lock_t gl_lock_t -#define __libc_lock_define gl_lock_define -#define __libc_lock_define_initialized gl_lock_define_initialized -#define __libc_lock_init gl_lock_init -#define __libc_lock_lock gl_lock_lock -#define __libc_lock_unlock gl_lock_unlock -#define __libc_lock_recursive_t gl_recursive_lock_t -#define __libc_lock_define_recursive gl_recursive_lock_define -#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized -#define __libc_lock_init_recursive gl_recursive_lock_init -#define __libc_lock_lock_recursive gl_recursive_lock_lock -#define __libc_lock_unlock_recursive gl_recursive_lock_unlock -#define glthread_in_use libintl_thread_in_use -#define glthread_lock_init_func libintl_lock_init_func -#define glthread_lock_lock_func libintl_lock_lock_func -#define glthread_lock_unlock_func libintl_lock_unlock_func -#define glthread_lock_destroy_func libintl_lock_destroy_func -#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded -#define glthread_rwlock_init_func libintl_rwlock_init_func -#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded -#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func -#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded -#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func -#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded -#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func -#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded -#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func -#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded -#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func -#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded -#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func -#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded -#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func -#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded -#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func -#define glthread_once_func libintl_once_func -#define glthread_once_singlethreaded libintl_once_singlethreaded -#define glthread_once_multithreaded libintl_once_multithreaded -]) -]) - - -dnl Checks for the core files of the intl subdirectory: -dnl dcigettext.c -dnl eval-plural.h -dnl explodename.c -dnl finddomain.c -dnl gettextP.h -dnl gmo.h -dnl hash-string.h hash-string.c -dnl l10nflist.c -dnl libgnuintl.h.in (except the *printf stuff) -dnl loadinfo.h -dnl loadmsgcat.c -dnl localealias.c -dnl log.c -dnl plural-exp.h plural-exp.c -dnl plural.y -dnl Used by libglocale. -AC_DEFUN([gt_INTL_SUBDIR_CORE], -[ - AC_REQUIRE([AC_C_INLINE])dnl - AC_REQUIRE([AC_TYPE_SIZE_T])dnl - AC_REQUIRE([gl_AC_HEADER_STDINT_H]) - AC_REQUIRE([AC_FUNC_ALLOCA])dnl - AC_REQUIRE([AC_FUNC_MMAP])dnl - AC_REQUIRE([gt_INTDIV0])dnl - AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl - AC_REQUIRE([gt_INTTYPES_PRI])dnl - AC_REQUIRE([gl_LOCK])dnl - - AC_TRY_LINK( - [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], - [], - [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], - [Define to 1 if the compiler understands __builtin_expect.])]) - - AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) - AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ - stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \ - argz_stringify argz_next __fsetlocking]) - - dnl Use the *_unlocked functions only if they are declared. - dnl (because some of them were defined without being declared in Solaris - dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built - dnl on Solaris 2.5.1 to run on Solaris 2.6). - dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. - gt_CHECK_DECL([feof_unlocked], [#include ]) - gt_CHECK_DECL([fgets_unlocked], [#include ]) - - AM_ICONV - - dnl intl/plural.c is generated from intl/plural.y. It requires bison, - dnl because plural.y uses bison specific features. It requires at least - dnl bison-1.26 because earlier versions generate a plural.c that doesn't - dnl compile. - dnl bison is only needed for the maintainer (who touches plural.y). But in - dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put - dnl the rule in general Makefile. Now, some people carelessly touch the - dnl files or have a broken "make" program, hence the plural.c rule will - dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not - dnl present or too old. - AC_CHECK_PROGS([INTLBISON], [bison]) - if test -z "$INTLBISON"; then - ac_verc_fail=yes - else - dnl Found it, now check the version. - AC_MSG_CHECKING([version of bison]) -changequote(<<,>>)dnl - ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` - case $ac_prog_version in - '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; - 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) -changequote([,])dnl - ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; - *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; - esac - AC_MSG_RESULT([$ac_prog_version]) - fi - if test $ac_verc_fail = yes; then - INTLBISON=: - fi -]) - - -dnl gt_CHECK_DECL(FUNC, INCLUDES) -dnl Check whether a function is declared. -AC_DEFUN([gt_CHECK_DECL], -[ - AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1], - [AC_TRY_COMPILE([$2], [ -#ifndef $1 - char *p = (char *) $1; -#endif -], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) - if test $ac_cv_have_decl_$1 = yes; then - gt_value=1 - else - gt_value=0 - fi - AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value], - [Define to 1 if you have the declaration of `$1', and to 0 if you don't.]) -]) diff --git a/package/libs/gettext/src/m4/intldir.m4 b/package/libs/gettext/src/m4/intldir.m4 deleted file mode 100644 index ebae76d36..000000000 --- a/package/libs/gettext/src/m4/intldir.m4 +++ /dev/null @@ -1,19 +0,0 @@ -# intldir.m4 serial 2 (gettext-0.18) -dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -AC_PREREQ([2.52]) - -dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory. -AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], []) diff --git a/package/libs/gettext/src/m4/intlmacosx.m4 b/package/libs/gettext/src/m4/intlmacosx.m4 deleted file mode 100644 index dd9102596..000000000 --- a/package/libs/gettext/src/m4/intlmacosx.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# intlmacosx.m4 serial 3 (gettext-0.18) -dnl Copyright (C) 2004-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Checks for special options needed on MacOS X. -dnl Defines INTL_MACOSX_LIBS. -AC_DEFUN([gt_INTL_MACOSX], -[ - dnl Check for API introduced in MacOS X 10.2. - AC_CACHE_CHECK([for CFPreferencesCopyAppValue], - [gt_cv_func_CFPreferencesCopyAppValue], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_TRY_LINK([#include ], - [CFPreferencesCopyAppValue(NULL, NULL)], - [gt_cv_func_CFPreferencesCopyAppValue=yes], - [gt_cv_func_CFPreferencesCopyAppValue=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then - AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], - [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) - fi - dnl Check for API introduced in MacOS X 10.3. - AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], - [gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], - [gt_cv_func_CFLocaleCopyCurrent=yes], - [gt_cv_func_CFLocaleCopyCurrent=no]) - LIBS="$gt_save_LIBS"]) - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], - [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) - fi - INTL_MACOSX_LIBS= - if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then - INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" - fi - AC_SUBST([INTL_MACOSX_LIBS]) -]) diff --git a/package/libs/gettext/src/m4/lcmessage.m4 b/package/libs/gettext/src/m4/lcmessage.m4 deleted file mode 100644 index 1a705431a..000000000 --- a/package/libs/gettext/src/m4/lcmessage.m4 +++ /dev/null @@ -1,31 +0,0 @@ -# lcmessage.m4 serial 6 (gettext-0.18) -dnl Copyright (C) 1995-2002, 2004-2005, 2008-2010 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995. - -# Check whether LC_MESSAGES is available in . - -AC_DEFUN([gt_LC_MESSAGES], -[ - AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES], - [AC_TRY_LINK([#include ], [return LC_MESSAGES], - [gt_cv_val_LC_MESSAGES=yes], [gt_cv_val_LC_MESSAGES=no])]) - if test $gt_cv_val_LC_MESSAGES = yes; then - AC_DEFINE([HAVE_LC_MESSAGES], [1], - [Define if your file defines LC_MESSAGES.]) - fi -]) diff --git a/package/libs/gettext/src/m4/nls.m4 b/package/libs/gettext/src/m4/nls.m4 deleted file mode 100644 index 003704c4b..000000000 --- a/package/libs/gettext/src/m4/nls.m4 +++ /dev/null @@ -1,32 +0,0 @@ -# nls.m4 serial 5 (gettext-0.18) -dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation, -dnl Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2003. - -AC_PREREQ([2.50]) - -AC_DEFUN([AM_NLS], -[ - AC_MSG_CHECKING([whether NLS is requested]) - dnl Default is enabled NLS - AC_ARG_ENABLE([nls], - [ --disable-nls do not use Native Language Support], - USE_NLS=$enableval, USE_NLS=yes) - AC_MSG_RESULT([$USE_NLS]) - AC_SUBST([USE_NLS]) -]) diff --git a/package/libs/gettext/src/m4/po.m4 b/package/libs/gettext/src/m4/po.m4 deleted file mode 100644 index 47f36a41a..000000000 --- a/package/libs/gettext/src/m4/po.m4 +++ /dev/null @@ -1,449 +0,0 @@ -# po.m4 serial 17 (gettext-0.18) -dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2003. - -AC_PREREQ([2.50]) - -dnl Checks for all prerequisites of the po subdirectory. -AC_DEFUN([AM_PO_SUBDIRS], -[ - AC_REQUIRE([AC_PROG_MAKE_SET])dnl - AC_REQUIRE([AC_PROG_INSTALL])dnl - AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake - AC_REQUIRE([AM_NLS])dnl - - dnl Release version of the gettext macros. This is used to ensure that - dnl the gettext macros and po/Makefile.in.in are in sync. - AC_SUBST([GETTEXT_MACRO_VERSION], [0.18]) - - dnl Perform the following tests also if --disable-nls has been given, - dnl because they are needed for "make dist" to work. - - dnl Search for GNU msgfmt in the PATH. - dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. - dnl The second test excludes FreeBSD msgfmt. - AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, - [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && - (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], - :) - AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) - - dnl Test whether it is GNU msgfmt >= 0.15. -changequote(,)dnl - case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; - *) MSGFMT_015=$MSGFMT ;; - esac -changequote([,])dnl - AC_SUBST([MSGFMT_015]) -changequote(,)dnl - case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; - *) GMSGFMT_015=$GMSGFMT ;; - esac -changequote([,])dnl - AC_SUBST([GMSGFMT_015]) - - dnl Search for GNU xgettext 0.12 or newer in the PATH. - dnl The first test excludes Solaris xgettext and early GNU xgettext versions. - dnl The second test excludes FreeBSD xgettext. - AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, - [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && - (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], - :) - dnl Remove leftover from FreeBSD xgettext call. - rm -f messages.po - - dnl Test whether it is GNU xgettext >= 0.15. -changequote(,)dnl - case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; - *) XGETTEXT_015=$XGETTEXT ;; - esac -changequote([,])dnl - AC_SUBST([XGETTEXT_015]) - - dnl Search for GNU msgmerge 0.11 or newer in the PATH. - AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, - [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) - - dnl Installation directories. - dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we - dnl have to define it here, so that it can be used in po/Makefile. - test -n "$localedir" || localedir='${datadir}/locale' - AC_SUBST([localedir]) - - dnl Support for AM_XGETTEXT_OPTION. - test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= - AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) - - AC_CONFIG_COMMANDS([po-directories], [[ - for ac_file in $CONFIG_FILES; do - # Support "outfile[:infile[:infile...]]" - case "$ac_file" in - *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - esac - # PO directories have a Makefile.in generated from Makefile.in.in. - case "$ac_file" in */Makefile.in) - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - # Treat a directory as a PO directory if and only if it has a - # POTFILES.in file. This allows packages to have multiple PO - # directories under different names or in different locations. - if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then - rm -f "$ac_dir/POTFILES" - test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" - cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" - POMAKEFILEDEPS="POTFILES.in" - # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend - # on $ac_dir but don't depend on user-specified configuration - # parameters. - if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then - # The LINGUAS file contains the set of available languages. - if test -n "$OBSOLETE_ALL_LINGUAS"; then - test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" - fi - ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assigment from automake < 1.5. - eval 'ALL_LINGUAS''=$ALL_LINGUAS_' - POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" - else - # The set of available languages was given in configure.in. - # Hide the ALL_LINGUAS assigment from automake < 1.5. - eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' - fi - # Compute POFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) - # Compute UPDATEPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) - # Compute DUMMYPOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) - # Compute GMOFILES - # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) - case "$ac_given_srcdir" in - .) srcdirpre= ;; - *) srcdirpre='$(srcdir)/' ;; - esac - POFILES= - UPDATEPOFILES= - DUMMYPOFILES= - GMOFILES= - for lang in $ALL_LINGUAS; do - POFILES="$POFILES $srcdirpre$lang.po" - UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" - DUMMYPOFILES="$DUMMYPOFILES $lang.nop" - GMOFILES="$GMOFILES $srcdirpre$lang.gmo" - done - # CATALOGS depends on both $ac_dir and the user's LINGUAS - # environment variable. - INST_LINGUAS= - if test -n "$ALL_LINGUAS"; then - for presentlang in $ALL_LINGUAS; do - useit=no - if test "%UNSET%" != "$LINGUAS"; then - desiredlanguages="$LINGUAS" - else - desiredlanguages="$ALL_LINGUAS" - fi - for desiredlang in $desiredlanguages; do - # Use the presentlang catalog if desiredlang is - # a. equal to presentlang, or - # b. a variant of presentlang (because in this case, - # presentlang can be used as a fallback for messages - # which are not translated in the desiredlang catalog). - case "$desiredlang" in - "$presentlang"*) useit=yes;; - esac - done - if test $useit = yes; then - INST_LINGUAS="$INST_LINGUAS $presentlang" - fi - done - fi - CATALOGS= - if test -n "$INST_LINGUAS"; then - for lang in $INST_LINGUAS; do - CATALOGS="$CATALOGS $lang.gmo" - done - fi - test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" - sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" - for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do - if test -f "$f"; then - case "$f" in - *.orig | *.bak | *~) ;; - *) cat "$f" >> "$ac_dir/Makefile" ;; - esac - fi - done - fi - ;; - esac - done]], - [# Capture the value of obsolete ALL_LINGUAS because we need it to compute - # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it - # from automake < 1.5. - eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' - # Capture the value of LINGUAS because we need it to compute CATALOGS. - LINGUAS="${LINGUAS-%UNSET%}" - ]) -]) - -dnl Postprocesses a Makefile in a directory containing PO files. -AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], -[ - # When this code is run, in config.status, two variables have already been - # set: - # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, - # - LINGUAS is the value of the environment variable LINGUAS at configure - # time. - -changequote(,)dnl - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - # Find a way to echo strings without interpreting backslash. - if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then - gt_echo='echo' - else - if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then - gt_echo='printf %s\n' - else - echo_func () { - cat < "$ac_file.tmp" - if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then - # Add dependencies that cannot be formulated as a simple suffix rule. - for lang in $ALL_LINGUAS; do - frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` - cat >> "$ac_file.tmp" < /dev/null; then - # Add dependencies that cannot be formulated as a simple suffix rule. - for lang in $ALL_LINGUAS; do - frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` - cat >> "$ac_file.tmp" <> "$ac_file.tmp" <$(DESTDIR)$(libdir)/libbsd.so + else + if [ "$(libdir)" != "$(runtimelibdir)" ]; then \ diff --git a/package/libs/libcap/Makefile b/package/libs/libcap/Makefile index dcd535bec..afc66d7c0 100644 --- a/package/libs/libcap/Makefile +++ b/package/libs/libcap/Makefile @@ -6,16 +6,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libcap -PKG_VERSION:=2.63 +PKG_VERSION:=2.66 PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/libs/security/linux-privs/libcap2 -PKG_HASH:=0c637b8f44fc7d8627787e9cf57f15ac06c1ddccb53e41feec5496be3466f77f +PKG_HASH:=15c40ededb3003d70a283fe587a36b7d19c8b3b554e33f86129c059a4bb466b2 PKG_MAINTAINER:=Paul Wassi PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:=License +PKG_CPE_ID:=cpe:/a:libcap_project:libcap PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 diff --git a/package/libs/libcap/patches/900-use-more-compatible-shebang.patch b/package/libs/libcap/patches/900-use-more-compatible-shebang.patch new file mode 100644 index 000000000..454c703fb --- /dev/null +++ b/package/libs/libcap/patches/900-use-more-compatible-shebang.patch @@ -0,0 +1,8 @@ +--- a/progs/mkcapshdoc.sh ++++ b/progs/mkcapshdoc.sh +@@ -1,4 +1,4 @@ +-#!/bin/bash ++#!/usr/bin/env bash + # This script generates some C code for inclusion in the capsh binary. + # The Makefile generally only generates the .c code and compares it + # with the checked in code in the progs directory. diff --git a/package/libs/libdouble-conversion/Makefile b/package/libs/libdouble-conversion/Makefile deleted file mode 100644 index 5a061f91f..000000000 --- a/package/libs/libdouble-conversion/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (C) 2008-2016 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=libdouble-conversion -PKG_VERSION:=2.0 -PKG_RELEASE:=1 - -PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=0d25506a2e7fb52928963313343e0237e890059e -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_MIRROR_HASH:=7466f634421f3136174cbc2b00635788509a3312894de28367f31d891fd401ad -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_URL:=https://github.com/google/double-conversion.git -PKG_LICENSE_FILES:=COPYING LICENSE - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/cmake.mk - -define Package/libdouble-conversion - SECTION:=libs - CATEGORY:=Libraries - TITLE:=Efficient binary-decimal and decimal-binary conversion routines for IEEE doubles - URL:=https://github.com/google/double-conversion - DEPENDS:=+libstdcpp -endef - -define Package/libdouble-conversion/description - double-conversion provides binary-decimal and decimal-binary routines for IEEE doubles. - - The library consists of efficient conversion routines that have been extracted - from the V8 JavaScript engine. The code has been refactored and improved so that - it can be used more easily in other projects. -endef - -CMAKE_OPTIONS += \ - -DBUILD_SHARED_LIBS=ON \ - -DBUILD_TESTING=OFF - -define Build/InstallDev - $(INSTALL_DIR) \ - $(1)/usr/lib \ - $(1)/usr/include/double-conversion - - $(CP) \ - $(PKG_INSTALL_DIR)/usr/include/* \ - $(1)/usr/include/ - - $(INSTALL_DATA) \ - $(PKG_INSTALL_DIR)/usr/lib/lib*.so* \ - $(1)/usr/lib/ -endef - -define Package/libdouble-conversion/install - $(INSTALL_DIR) \ - $(1)/usr/lib - - $(INSTALL_DATA) \ - $(PKG_INSTALL_DIR)/usr/lib/lib*.so* \ - $(1)/usr/lib/ -endef - -$(eval $(call BuildPackage,libdouble-conversion)) diff --git a/package/libs/libiconv-full/Makefile b/package/libs/libiconv-full/Makefile index e4f925a1a..0c793973a 100644 --- a/package/libs/libiconv-full/Makefile +++ b/package/libs/libiconv-full/Makefile @@ -8,13 +8,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libiconv-full -PKG_VERSION:=1.16 +PKG_VERSION:=1.17 PKG_RELEASE:=1 PKG_SOURCE:=libiconv-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/libiconv -PKG_HASH:=e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04 +PKG_HASH:=8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313 PKG_BUILD_DIR:=$(BUILD_DIR)/libiconv-$(PKG_VERSION) +HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/libiconv-$(PKG_VERSION) PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=LGPL-2.1-or-later @@ -25,6 +26,7 @@ PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk define Package/libiconv-full/Default URL:=https://www.gnu.org/software/libiconv/ @@ -61,6 +63,10 @@ CONFIGURE_ARGS += \ --disable-rpath \ --enable-relocatable +HOST_CONFIGURE_ARGS += \ + --disable-shared \ + --with-pic + define Build/InstallDev $(INSTALL_DIR) $(1)/usr/lib/libiconv-full/include $(CP) $(PKG_INSTALL_DIR)/usr/include/iconv.h $(1)/usr/lib/libiconv-full/include/ @@ -88,3 +94,4 @@ endef $(eval $(call BuildPackage,libcharset)) $(eval $(call BuildPackage,libiconv-full)) $(eval $(call BuildPackage,iconv)) +$(eval $(call HostBuild)) diff --git a/package/libs/libiconv/COPYING b/package/libs/libiconv/COPYING deleted file mode 100644 index 223ede7de..000000000 --- a/package/libs/libiconv/COPYING +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/package/libs/libiconv/COPYRIGHT b/package/libs/libiconv/COPYRIGHT deleted file mode 100644 index d228af355..000000000 --- a/package/libs/libiconv/COPYRIGHT +++ /dev/null @@ -1,20 +0,0 @@ -Copyright status on all included code: - -All files which have no copyright comments are original works -Copyright (C) 2005-2006 Rich Felker. The decision to exclude such -comments is intentional, as it should be possible to carry around the -complete source code on tiny storage media. All public header files -(include/*) should be treated as Public Domain as they intentionally -contain no content which can be covered by copyright. Some source -modules may fall in this category as well. If you believe that a file -is so trivial that it should be in the Public Domain, please contact -me and, if I agree, I will explicitly release it from copyright. - -Some code has been modified by the OpenWrt project, this includes -the conversion from char map files to C arrays and the iconv.h header -file in particular. - -The library as a whole is licensed under the GNU LGPL version 2.1. -See the file COPYING for the text of this license. - -The original source can be accessed at svn://svn.mplayerhq.hu/libc/trunk diff --git a/package/libs/libiconv/Makefile b/package/libs/libiconv/Makefile deleted file mode 100644 index 4d7dcd349..000000000 --- a/package/libs/libiconv/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# -# Copyright (C) 2010-2012 OpenWrt.org -# -# This Makefile and the code shipped in src/ is free software, licensed -# under the GNU Lesser General Public License, version 2.1 and later. -# See src/COPYING for more information. -# -# Refer to src/COPYRIGHT for copyright statements on the source files. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=libiconv -PKG_RELEASE:=8 - -PKG_LICENSE:=LGPL-2.1 -PKG_LICENSE_FILES:=LICENSE - -PKG_MAINTAINER:=Jo-Philipp Wich - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/host-build.mk - -define Package/libiconv - SECTION:=libs - CATEGORY:=Libraries - TITLE:=Tiny drop-in replacement for the GNU Character set conversion library -endef - -define Build/Configure -endef - -define Build/Compile - $(TARGET_CC) $(TARGET_CFLAGS) -c $(PKG_BUILD_DIR)/iconv.c -o $(PKG_BUILD_DIR)/iconv.o -I$(PKG_BUILD_DIR)/include $(FPIC) - $(TARGET_CROSS)ar rcs $(PKG_BUILD_DIR)/libiconv.a $(PKG_BUILD_DIR)/iconv.o -endef - -define Build/InstallDev - $(INSTALL_DIR) $(1)/usr/lib/libiconv-stub/lib - $(INSTALL_DATA) $(PKG_BUILD_DIR)/libiconv.a $(1)/usr/lib/libiconv-stub/lib/ - - $(INSTALL_DIR) $(1)/usr/lib/libiconv-stub/include - $(INSTALL_DATA) $(PKG_BUILD_DIR)/include/iconv.h $(1)/usr/lib/libiconv-stub/include/ - - $(INSTALL_DIR) $(1)/usr/share/aclocal - $(INSTALL_DATA) $(PKG_BUILD_DIR)/m4/* $(1)/usr/share/aclocal/ -endef - -define Package/libiconv/install - $(INSTALL_DIR) $(1)/tmp - touch $(1)/tmp/.libiconv-placeholder -endef - -define Host/Prepare - mkdir -p $(HOST_BUILD_DIR) -endef - -define Host/Configure - -endef - -define Host/Compile - $(HOSTCC) -c src/iconv.c -o $(HOST_BUILD_DIR)/iconv.o -Isrc/include -fPIC - ar rcs $(HOST_BUILD_DIR)/libiconv.a $(HOST_BUILD_DIR)/iconv.o -endef - -define Host/Install - $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/lib - $(INSTALL_DATA) $(HOST_BUILD_DIR)/libiconv.a $(STAGING_DIR_HOSTPKG)/lib/ - - $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/include - $(INSTALL_DATA) ./src/include/iconv.h $(STAGING_DIR_HOSTPKG)/include/ - - $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/share/aclocal - $(INSTALL_DATA) ./src/m4/* $(STAGING_DIR_HOSTPKG)/share/aclocal/ -endef - -$(eval $(call HostBuild)) -$(eval $(call BuildPackage,libiconv)) diff --git a/package/libs/libiconv/src/LICENSE b/package/libs/libiconv/src/LICENSE deleted file mode 100644 index b59e7be47..000000000 --- a/package/libs/libiconv/src/LICENSE +++ /dev/null @@ -1,6 +0,0 @@ -The source file iconv.m4 contains the following message - -Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. -This file is free software; the Free Software Foundation -gives unlimited permission to copy and/or distribute it, -with or without modifications, as long as this notice is preserved. diff --git a/package/libs/libiconv/src/iconv.c b/package/libs/libiconv/src/iconv.c deleted file mode 100644 index c3cfefa3c..000000000 --- a/package/libs/libiconv/src/iconv.c +++ /dev/null @@ -1,449 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/* builtin charmaps */ -#include "charmaps.h" - -/* only 0-7 are valid as dest charset */ -#define UTF_16BE 000 -#define UTF_16LE 001 -#define UTF_32BE 002 -#define UTF_32LE 003 -#define WCHAR_T 004 -#define UTF_8 005 -#define US_ASCII 006 -#define LATIN_1 007 - -/* additional charsets with algorithmic conversion */ -#define LATIN_9 010 -#define TIS_620 011 -#define JIS_0201 012 - -/* some programs like php need this */ -int _libiconv_version = _LIBICONV_VERSION; - -/* these must match the constants above */ -static const unsigned char charsets[] = - "\005" "UTF-8" "\0" - "\004" "WCHAR_T" "\0" - "\000" "UTF-16BE" "\0" - "\001" "UTF-16LE" "\0" - "\002" "UTF-32BE" "\0" - "\003" "UTF-32LE" "\0" - "\006" "ASCII" "\0" - "\006" "US-ASCII" "\0" - "\006" "ISO646-US" "\0" - "\006" "ISO_646.IRV:1991" "\0" - "\006" "ISO-IR-6" "\0" - "\006" "ANSI_X3.4-1968" "\0" - "\006" "ANSI_X3.4-1986" "\0" - "\006" "CP367" "\0" - "\006" "IBM367" "\0" - "\006" "US" "\0" - "\006" "CSASCII" "\0" - "\007" "ISO-8859-1" "\0" - "\007" "LATIN1" "\0" - "\010" "ISO-8859-15""\0" - "\010" "LATIN9" "\0" - "\011" "ISO-8859-11""\0" - "\011" "TIS-620" "\0" - "\012" "JIS-0201" "\0" - "\377"; - -/* separate identifiers for sbcs/dbcs/etc map type */ -#define UCS2_8BIT 000 -#define UCS3_8BIT 001 -#define EUC 002 -#define EUC_TW 003 -#define SHIFT_JIS 004 -#define BIG5 005 -#define GBK 006 - -/* FIXME: these are not implemented yet -// EUC: A1-FE A1-FE -// GBK: 81-FE 40-7E,80-FE -// Big5: A1-FE 40-7E,A1-FE -*/ - -static const unsigned short maplen[] = { - [UCS2_8BIT] = 4+ 2* 128, - [UCS3_8BIT] = 4+ 3* 128, - [EUC] = 4+ 2* 94*94, - [SHIFT_JIS] = 4+ 2* 94*94, - [BIG5] = 4+ 2* 94*157, - [GBK] = 4+ 2* 126*190, - [EUC_TW] = 4+ 2* 2*94*94, -}; - -static int find_charmap(const char *name) -{ - int i; - for (i = 0; i < (sizeof(charmaps) / sizeof(charmaps[0])); i++) - if (!strcasecmp(charmaps[i].name, name)) - return i; - return -1; -} - -static int find_charset(const char *name) -{ - const unsigned char *s; - for (s=charsets; *s<0xff && strcasecmp(s+1, name); s+=strlen(s)+1); - return *s; -} - -iconv_t iconv_open(const char *to, const char *from) -{ - unsigned f, t; - int m; - - if ((t = find_charset(to)) > 8) - return -1; - - if ((f = find_charset(from)) < 255) - return 0 | (t<<1) | (f<<8); - - if ((m = find_charmap(from)) > -1) - return 1 | (t<<1) | (m<<8); - - return -1; -} - -int iconv_close(iconv_t cd) -{ - return 0; -} - -static inline wchar_t get_16(const unsigned char *s, int endian) -{ - endian &= 1; - return s[endian]<<8 | s[endian^1]; -} - -static inline void put_16(unsigned char *s, wchar_t c, int endian) -{ - endian &= 1; - s[endian] = c>>8; - s[endian^1] = c; -} - -static inline int utf8enc_wchar(char *outb, wchar_t c) -{ - if (c <= 0x7F) { - *outb = c; - return 1; - } - else if (c <= 0x7FF) { - *outb++ = ((c >> 6) & 0x1F) | 0xC0; - *outb++ = ( c & 0x3F) | 0x80; - return 2; - } - else if (c <= 0xFFFF) { - *outb++ = ((c >> 12) & 0x0F) | 0xE0; - *outb++ = ((c >> 6) & 0x3F) | 0x80; - *outb++ = ( c & 0x3F) | 0x80; - return 3; - } - else if (c <= 0x10FFFF) { - *outb++ = ((c >> 18) & 0x07) | 0xF0; - *outb++ = ((c >> 12) & 0x3F) | 0x80; - *outb++ = ((c >> 6) & 0x3F) | 0x80; - *outb++ = ( c & 0x3F) | 0x80; - return 4; - } - else { - *outb++ = '?'; - return 1; - } -} - -static inline int utf8seq_is_overlong(char *s, int n) -{ - switch (n) - { - case 2: - /* 1100000x (10xxxxxx) */ - return (((*s >> 1) == 0x60) && - ((*(s+1) >> 6) == 0x02)); - - case 3: - /* 11100000 100xxxxx (10xxxxxx) */ - return ((*s == 0xE0) && - ((*(s+1) >> 5) == 0x04) && - ((*(s+2) >> 6) == 0x02)); - - case 4: - /* 11110000 1000xxxx (10xxxxxx 10xxxxxx) */ - return ((*s == 0xF0) && - ((*(s+1) >> 4) == 0x08) && - ((*(s+2) >> 6) == 0x02) && - ((*(s+3) >> 6) == 0x02)); - } - - return 0; -} - -static inline int utf8seq_is_surrogate(char *s, int n) -{ - return ((n == 3) && (*s == 0xED) && (*(s+1) >= 0xA0) && (*(s+1) <= 0xBF)); -} - -static inline int utf8seq_is_illegal(char *s, int n) -{ - return ((n == 3) && (*s == 0xEF) && (*(s+1) == 0xBF) && - (*(s+2) >= 0xBE) && (*(s+2) <= 0xBF)); -} - -static inline int utf8dec_wchar(wchar_t *c, unsigned char *in, size_t inb) -{ - int i; - int n = -1; - - /* trivial char */ - if (*in <= 0x7F) { - *c = *in; - return 1; - } - - /* find utf8 sequence length */ - if ((*in & 0xE0) == 0xC0) n = 2; - else if ((*in & 0xF0) == 0xE0) n = 3; - else if ((*in & 0xF8) == 0xF0) n = 4; - else if ((*in & 0xFC) == 0xF8) n = 5; - else if ((*in & 0xFE) == 0xFC) n = 6; - - /* starved? */ - if (n > inb) - return -2; - - /* decode ... */ - if (n > 1 && n < 5) { - /* reject invalid sequences */ - if (utf8seq_is_overlong(in, n) || - utf8seq_is_surrogate(in, n) || - utf8seq_is_illegal(in, n)) - return -1; - - /* decode ... */ - *c = (char)(*in++ & (0x7F >> n)); - - for (i = 1; i < n; i++) { - /* illegal continuation byte */ - if (*in < 0x80 || *in > 0xBF) - return -1; - - *c = (*c << 6) | (*in++ & 0x3F); - } - - return n; - } - - /* unmapped sequence (> 4) */ - return -1; -} - -static inline wchar_t latin9_translit(wchar_t c) -{ - /* a number of trivial iso-8859-15 <> utf-8 transliterations */ - switch (c) { - case 0x20AC: return 0xA4; /* Euro */ - case 0x0160: return 0xA6; /* S caron */ - case 0x0161: return 0xA8; /* s caron */ - case 0x017D: return 0xB4; /* Z caron */ - case 0x017E: return 0xB8; /* z caron */ - case 0x0152: return 0xBC; /* OE */ - case 0x0153: return 0xBD; /* oe */ - case 0x0178: return 0xBE; /* Y diaeresis */ - default: return 0xFFFD; /* cannot translate */ - } -} - -size_t iconv(iconv_t cd, char **in, size_t *inb, char **out, size_t *outb) -{ - size_t x=0; - unsigned char to = (cd>>1)&127; - unsigned char from = 255; - const unsigned char *map = 0; - char tmp[MB_LEN_MAX]; - wchar_t c, d; - size_t k, l; - int err; - - if (!in || !*in || !*inb) return 0; - - if (cd & 1) - map = charmaps[cd>>8].map; - else - from = cd>>8; - - for (; *inb; *in+=l, *inb-=l) { - c = *(unsigned char *)*in; - l = 1; - if (from >= UTF_8 && c < 0x80) goto charok; - switch (from) { - case WCHAR_T: - l = sizeof(wchar_t); - if (*inb < l) goto starved; - c = *(wchar_t *)*in; - break; - case UTF_8: - l = utf8dec_wchar(&c, *in, *inb); - if (!l) l++; - else if (l == (size_t)-1) goto ilseq; - else if (l == (size_t)-2) goto starved; - break; - case US_ASCII: - goto ilseq; - case LATIN_9: - if ((unsigned)c - 0xa4 <= 0xbe - 0xa4) { - static const unsigned char map[] = { - 0, 0x60, 0, 0x61, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x7d, 0, 0, 0, 0x7e, 0, 0, 0, - 0x52, 0x53, 0x78 - }; - if (c == 0xa4) c = 0x20ac; - else if (map[c-0xa5]) c = 0x100 | map[c-0xa5]; - } - case LATIN_1: - goto charok; - case TIS_620: - if (c >= 0xa1) c += 0x0e01-0xa1; - goto charok; - case JIS_0201: - if (c >= 0xa1) { - if (c <= 0xdf) c += 0xff61-0xa1; - else goto ilseq; - } - goto charok; - case UTF_16BE: - case UTF_16LE: - l = 2; - if (*inb < 2) goto starved; - c = get_16(*in, from); - if ((unsigned)(c-0xdc00) < 0x400) goto ilseq; - if ((unsigned)(c-0xd800) < 0x400) { - l = 4; - if (*inb < 4) goto starved; - d = get_16(*in + 2, from); - if ((unsigned)(c-0xdc00) >= 0x400) goto ilseq; - c = ((c-0xd800)<<10) | (d-0xdc00); - } - break; - case UTF_32BE: - case UTF_32LE: - l = 4; - if (*inb < 4) goto starved; - // FIXME - // c = get_32(*in, from); - break; - default: - /* only support ascii supersets */ - if (c < 0x80) break; - switch (map[0]) { - case UCS2_8BIT: - c -= 0x80; - break; - case EUC: - if ((unsigned)c - 0xa1 >= 94) goto ilseq; - if ((unsigned)in[0][1] - 0xa1 >= 94) goto ilseq; - c = (c-0xa1)*94 + (in[0][1]-0xa1); - l = 2; - break; - case SHIFT_JIS: - if ((unsigned)c - 0xa1 <= 0xdf-0xa1) { - c += 0xff61-0xa1; - goto charok; - } - // FIXME... - l = 2; - break; - default: - goto badf; - } - c = get_16(map + 4 + 2*c, 0); - if (c == 0xffff) goto ilseq; - goto charok; - } - - if ((unsigned)c - 0xd800 < 0x800 || (unsigned)c >= 0x110000) - goto ilseq; -charok: - switch (to) { - case WCHAR_T: - if (*outb < sizeof(wchar_t)) goto toobig; - *(wchar_t *)*out = c; - *out += sizeof(wchar_t); - *outb -= sizeof(wchar_t); - break; - case UTF_8: - if (*outb < 4) { - k = utf8enc_wchar(tmp, c); - if (*outb < k) goto toobig; - memcpy(*out, tmp, k); - } else k = utf8enc_wchar(*out, c); - *out += k; - *outb -= k; - break; - case US_ASCII: - if (c > 0x7f) c = 0xfffd; - /* fall thru and count replacement in latin1 case */ - case LATIN_9: - if (c >= 0x100 && c != 0xfffd) - c = latin9_translit(c); - /* fall through */ - case LATIN_1: - if (c > 0xff) goto ilseq; - if (!*outb) goto toobig; - **out = c; - ++*out; - --*outb; - break; - case UTF_16BE: - case UTF_16LE: - if (c < 0x10000) { - if (*outb < 2) goto toobig; - put_16(*out, c, to); - *out += 2; - *outb -= 2; - break; - } - if (*outb < 4) goto toobig; - put_16(*out, (c>>10)|0xd800, to); - put_16(*out + 2, (c&0x3ff)|0xdc00, to); - *out += 4; - *outb -= 4; - break; - default: - goto badf; - } - } - return x; -ilseq: - err = EILSEQ; - x = -1; - goto end; -badf: - err = EBADF; - x = -1; - goto end; -toobig: - err = E2BIG; - x = -1; - goto end; -starved: - err = EINVAL; -end: - errno = err; - return x; -} diff --git a/package/libs/libiconv/src/include/charmaps.h b/package/libs/libiconv/src/include/charmaps.h deleted file mode 100644 index 083cd699f..000000000 --- a/package/libs/libiconv/src/include/charmaps.h +++ /dev/null @@ -1,80 +0,0 @@ -#include "charmaps/iso-8859-2.h" -#include "charmaps/iso-8859-10.h" -#include "charmaps/windows-874.h" -#include "charmaps/windows-1250.h" -#include "charmaps/koi8-r.h" - -#ifdef ALL_CHARSETS -#include "charmaps/iso-8859-3.h" -#include "charmaps/iso-8859-4.h" -#include "charmaps/iso-8859-5.h" -#include "charmaps/iso-8859-6.h" -#include "charmaps/iso-8859-7.h" -#include "charmaps/iso-8859-8.h" -#include "charmaps/iso-8859-9.h" -#include "charmaps/iso-8859-13.h" -#include "charmaps/iso-8859-14.h" -#include "charmaps/iso-8859-16.h" -#include "charmaps/windows-1251.h" -#include "charmaps/windows-1252.h" -#include "charmaps/windows-1253.h" -#include "charmaps/windows-1254.h" -#include "charmaps/windows-1255.h" -#include "charmaps/windows-1256.h" -#include "charmaps/windows-1257.h" -#include "charmaps/windows-1258.h" -#endif - - -struct charmap { - const char name[13]; - const unsigned char *map; -}; - -static struct charmap charmaps[] = { - { "ISO-8859-2", map_iso_8859_2 }, - { "ISO-8859-10", map_iso_8859_10 }, - -#ifdef ALL_CHARSETS - { "ISO-8859-3", map_iso_8859_3 }, - { "ISO-8859-4", map_iso_8859_4 }, - { "ISO-8859-5", map_iso_8859_5 }, - { "ISO-8859-6", map_iso_8859_6 }, - { "ISO-8859-7", map_iso_8859_7 }, - { "ISO-8859-8", map_iso_8859_8 }, - { "ISO-8859-9", map_iso_8859_9 }, - { "ISO-8859-13", map_iso_8859_13 }, - { "ISO-8859-14", map_iso_8859_14 }, - { "ISO-8859-16", map_iso_8859_16 }, -#endif - - { "WINDOWS-874", map_windows_874 }, - { "WINDOWS-1250", map_windows_1250 }, - -#ifdef ALL_CHARSETS - { "WINDOWS-1251", map_windows_1251 }, - { "WINDOWS-1252", map_windows_1252 }, - { "WINDOWS-1253", map_windows_1253 }, - { "WINDOWS-1254", map_windows_1254 }, - { "WINDOWS-1255", map_windows_1255 }, - { "WINDOWS-1256", map_windows_1256 }, - { "WINDOWS-1257", map_windows_1257 }, - { "WINDOWS-1258", map_windows_1258 }, -#endif - - { "KOI8-R", map_koi8_r }, - - /* Aliases */ - { "LATIN2", map_iso_8859_2 }, - { "LATIN6", map_iso_8859_10 }, - -#ifdef ALL_CHARSETS - { "ARABIC", map_iso_8859_6 }, - { "CYRILLIC", map_iso_8859_5 }, - { "GREEK", map_iso_8859_7 }, - { "HEBREW", map_iso_8859_8 }, - { "LATIN3", map_iso_8859_3 }, - { "LATIN4", map_iso_8859_4 }, - { "LATIN5", map_iso_8859_9 }, -#endif -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-10.h b/package/libs/libiconv/src/include/charmaps/iso-8859-10.h deleted file mode 100644 index cb93d027d..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-10.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_10[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04, - 0x01, 0x12, 0x01, 0x22, 0x01, 0x2a, 0x01, 0x28, 0x01, 0x36, 0x00, 0xa7, - 0x01, 0x3b, 0x01, 0x10, 0x01, 0x60, 0x01, 0x66, 0x01, 0x7d, 0x00, 0xad, - 0x01, 0x6a, 0x01, 0x4a, 0x00, 0xb0, 0x01, 0x05, 0x01, 0x13, 0x01, 0x23, - 0x01, 0x2b, 0x01, 0x29, 0x01, 0x37, 0x00, 0xb7, 0x01, 0x3c, 0x01, 0x11, - 0x01, 0x61, 0x01, 0x67, 0x01, 0x7e, 0x20, 0x15, 0x01, 0x6b, 0x01, 0x4b, - 0x01, 0x00, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, - 0x00, 0xc6, 0x01, 0x2e, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb, - 0x01, 0x16, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x00, 0xd0, 0x01, 0x45, - 0x01, 0x4c, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x01, 0x68, - 0x00, 0xd8, 0x01, 0x72, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd, - 0x00, 0xde, 0x00, 0xdf, 0x01, 0x01, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, - 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x01, 0x2f, 0x01, 0x0d, 0x00, 0xe9, - 0x01, 0x19, 0x00, 0xeb, 0x01, 0x17, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0x00, 0xf0, 0x01, 0x46, 0x01, 0x4d, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5, - 0x00, 0xf6, 0x01, 0x69, 0x00, 0xf8, 0x01, 0x73, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x00, 0xfd, 0x00, 0xfe, 0x01, 0x38 -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-13.h b/package/libs/libiconv/src/include/charmaps/iso-8859-13.h deleted file mode 100644 index b44d1b434..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-13.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_13[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x20, 0x1d, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x20, 0x1e, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xd8, 0x00, 0xa9, 0x01, 0x56, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xc6, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x20, 0x1c, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xf8, 0x00, 0xb9, - 0x01, 0x57, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xe6, - 0x01, 0x04, 0x01, 0x2e, 0x01, 0x00, 0x01, 0x06, 0x00, 0xc4, 0x00, 0xc5, - 0x01, 0x18, 0x01, 0x12, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x79, 0x01, 0x16, - 0x01, 0x22, 0x01, 0x36, 0x01, 0x2a, 0x01, 0x3b, 0x01, 0x60, 0x01, 0x43, - 0x01, 0x45, 0x00, 0xd3, 0x01, 0x4c, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7, - 0x01, 0x72, 0x01, 0x41, 0x01, 0x5a, 0x01, 0x6a, 0x00, 0xdc, 0x01, 0x7b, - 0x01, 0x7d, 0x00, 0xdf, 0x01, 0x05, 0x01, 0x2f, 0x01, 0x01, 0x01, 0x07, - 0x00, 0xe4, 0x00, 0xe5, 0x01, 0x19, 0x01, 0x13, 0x01, 0x0d, 0x00, 0xe9, - 0x01, 0x7a, 0x01, 0x17, 0x01, 0x23, 0x01, 0x37, 0x01, 0x2b, 0x01, 0x3c, - 0x01, 0x61, 0x01, 0x44, 0x01, 0x46, 0x00, 0xf3, 0x01, 0x4d, 0x00, 0xf5, - 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x73, 0x01, 0x42, 0x01, 0x5b, 0x01, 0x6b, - 0x00, 0xfc, 0x01, 0x7c, 0x01, 0x7e, 0x20, 0x19 -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-14.h b/package/libs/libiconv/src/include/charmaps/iso-8859-14.h deleted file mode 100644 index 76cead98c..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-14.h +++ /dev/null @@ -1,25 +0,0 @@ -static const unsigned char map_iso_8859_14[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x1e, 0x02, - 0x1e, 0x03, 0x00, 0xa3, 0x01, 0x0a, 0x01, 0x0b, 0x1e, 0x0a, 0x00, 0xa7, - 0x1e, 0x80, 0x00, 0xa9, 0x1e, 0x82, 0x1e, 0x0b, 0x1e, 0xf2, 0x00, 0xad, - 0x00, 0xae, 0x01, 0x78, 0x1e, 0x1e, 0x1e, 0x1f, 0x01, 0x20, 0x01, 0x21, - 0x1e, 0x40, 0x1e, 0x41, 0x00, 0xb6, 0x1e, 0x56, 0x1e, 0x81, 0x1e, 0x57, - 0x1e, 0x83, 0x1e, 0x60, 0x1e, 0xf3, 0x1e, 0x84, 0x1e, 0x85, 0x1e, 0x61, - 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, - 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb, - 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x74, 0x00, 0xd1, - 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x1e, 0x6a, - 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd, - 0x01, 0x76, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, - 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0x01, 0x75, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5, - 0x00, 0xf6, 0x1e, 0x6b, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x77, 0x00, 0xff -}; - diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-16.h b/package/libs/libiconv/src/include/charmaps/iso-8859-16.h deleted file mode 100644 index 4437a41f0..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-16.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_16[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04, - 0x01, 0x05, 0x01, 0x41, 0x20, 0xac, 0x20, 0x1e, 0x01, 0x60, 0x00, 0xa7, - 0x01, 0x61, 0x00, 0xa9, 0x02, 0x18, 0x00, 0xab, 0x01, 0x79, 0x00, 0xad, - 0x01, 0x7a, 0x01, 0x7b, 0x00, 0xb0, 0x00, 0xb1, 0x01, 0x0c, 0x01, 0x42, - 0x01, 0x7d, 0x20, 0x1d, 0x00, 0xb6, 0x00, 0xb7, 0x01, 0x7e, 0x01, 0x0d, - 0x02, 0x19, 0x00, 0xbb, 0x01, 0x52, 0x01, 0x53, 0x01, 0x78, 0x01, 0x7c, - 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x06, - 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb, - 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x10, 0x01, 0x43, - 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x01, 0x5a, - 0x01, 0x70, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x18, - 0x02, 0x1a, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03, - 0x00, 0xe4, 0x01, 0x07, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0x01, 0x11, 0x01, 0x44, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51, - 0x00, 0xf6, 0x01, 0x5b, 0x01, 0x71, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x01, 0x19, 0x02, 0x1b, 0x00, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-2.h b/package/libs/libiconv/src/include/charmaps/iso-8859-2.h deleted file mode 100644 index 631610e17..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-2.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_2[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04, - 0x02, 0xd8, 0x01, 0x41, 0x00, 0xa4, 0x01, 0x3d, 0x01, 0x5a, 0x00, 0xa7, - 0x00, 0xa8, 0x01, 0x60, 0x01, 0x5e, 0x01, 0x64, 0x01, 0x79, 0x00, 0xad, - 0x01, 0x7d, 0x01, 0x7b, 0x00, 0xb0, 0x01, 0x05, 0x02, 0xdb, 0x01, 0x42, - 0x00, 0xb4, 0x01, 0x3e, 0x01, 0x5b, 0x02, 0xc7, 0x00, 0xb8, 0x01, 0x61, - 0x01, 0x5f, 0x01, 0x65, 0x01, 0x7a, 0x02, 0xdd, 0x01, 0x7e, 0x01, 0x7c, - 0x01, 0x54, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x39, - 0x01, 0x06, 0x00, 0xc7, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb, - 0x01, 0x1a, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x0e, 0x01, 0x10, 0x01, 0x43, - 0x01, 0x47, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x00, 0xd7, - 0x01, 0x58, 0x01, 0x6e, 0x00, 0xda, 0x01, 0x70, 0x00, 0xdc, 0x00, 0xdd, - 0x01, 0x62, 0x00, 0xdf, 0x01, 0x55, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03, - 0x00, 0xe4, 0x01, 0x3a, 0x01, 0x07, 0x00, 0xe7, 0x01, 0x0d, 0x00, 0xe9, - 0x01, 0x19, 0x00, 0xeb, 0x01, 0x1b, 0x00, 0xed, 0x00, 0xee, 0x01, 0x0f, - 0x01, 0x11, 0x01, 0x44, 0x01, 0x48, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51, - 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x59, 0x01, 0x6f, 0x00, 0xfa, 0x01, 0x71, - 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x63, 0x02, 0xd9 -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-3.h b/package/libs/libiconv/src/include/charmaps/iso-8859-3.h deleted file mode 100644 index cd76d59c6..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-3.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_3[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x26, - 0x02, 0xd8, 0x00, 0xa3, 0x00, 0xa4, 0xff, 0xff, 0x01, 0x24, 0x00, 0xa7, - 0x00, 0xa8, 0x01, 0x30, 0x01, 0x5e, 0x01, 0x1e, 0x01, 0x34, 0x00, 0xad, - 0xff, 0xff, 0x01, 0x7b, 0x00, 0xb0, 0x01, 0x27, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x01, 0x25, 0x00, 0xb7, 0x00, 0xb8, 0x01, 0x31, - 0x01, 0x5f, 0x01, 0x1f, 0x01, 0x35, 0x00, 0xbd, 0xff, 0xff, 0x01, 0x7c, - 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0xff, 0xff, 0x00, 0xc4, 0x01, 0x0a, - 0x01, 0x08, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb, - 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0xff, 0xff, 0x00, 0xd1, - 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x20, 0x00, 0xd6, 0x00, 0xd7, - 0x01, 0x1c, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x6c, - 0x01, 0x5c, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0xff, 0xff, - 0x00, 0xe4, 0x01, 0x0b, 0x01, 0x09, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0xff, 0xff, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x21, - 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x1d, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x01, 0x6d, 0x01, 0x5d, 0x02, 0xd9 -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-4.h b/package/libs/libiconv/src/include/charmaps/iso-8859-4.h deleted file mode 100644 index 5db2f7780..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-4.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_4[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x01, 0x04, - 0x01, 0x38, 0x01, 0x56, 0x00, 0xa4, 0x01, 0x28, 0x01, 0x3b, 0x00, 0xa7, - 0x00, 0xa8, 0x01, 0x60, 0x01, 0x12, 0x01, 0x22, 0x01, 0x66, 0x00, 0xad, - 0x01, 0x7d, 0x00, 0xaf, 0x00, 0xb0, 0x01, 0x05, 0x02, 0xdb, 0x01, 0x57, - 0x00, 0xb4, 0x01, 0x29, 0x01, 0x3c, 0x02, 0xc7, 0x00, 0xb8, 0x01, 0x61, - 0x01, 0x13, 0x01, 0x23, 0x01, 0x67, 0x01, 0x4a, 0x01, 0x7e, 0x01, 0x4b, - 0x01, 0x00, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, - 0x00, 0xc6, 0x01, 0x2e, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb, - 0x01, 0x16, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x2a, 0x01, 0x10, 0x01, 0x45, - 0x01, 0x4c, 0x01, 0x36, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7, - 0x00, 0xd8, 0x01, 0x72, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x68, - 0x01, 0x6a, 0x00, 0xdf, 0x01, 0x01, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, - 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x01, 0x2f, 0x01, 0x0d, 0x00, 0xe9, - 0x01, 0x19, 0x00, 0xeb, 0x01, 0x17, 0x00, 0xed, 0x00, 0xee, 0x01, 0x2b, - 0x01, 0x11, 0x01, 0x46, 0x01, 0x4d, 0x01, 0x37, 0x00, 0xf4, 0x00, 0xf5, - 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x01, 0x73, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x01, 0x69, 0x01, 0x6b, 0x02, 0xd9 -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-5.h b/package/libs/libiconv/src/include/charmaps/iso-8859-5.h deleted file mode 100644 index d9fe684a3..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-5.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_5[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x04, 0x01, - 0x04, 0x02, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07, - 0x04, 0x08, 0x04, 0x09, 0x04, 0x0a, 0x04, 0x0b, 0x04, 0x0c, 0x00, 0xad, - 0x04, 0x0e, 0x04, 0x0f, 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, - 0x04, 0x14, 0x04, 0x15, 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19, - 0x04, 0x1a, 0x04, 0x1b, 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e, 0x04, 0x1f, - 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, - 0x04, 0x26, 0x04, 0x27, 0x04, 0x28, 0x04, 0x29, 0x04, 0x2a, 0x04, 0x2b, - 0x04, 0x2c, 0x04, 0x2d, 0x04, 0x2e, 0x04, 0x2f, 0x04, 0x30, 0x04, 0x31, - 0x04, 0x32, 0x04, 0x33, 0x04, 0x34, 0x04, 0x35, 0x04, 0x36, 0x04, 0x37, - 0x04, 0x38, 0x04, 0x39, 0x04, 0x3a, 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d, - 0x04, 0x3e, 0x04, 0x3f, 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43, - 0x04, 0x44, 0x04, 0x45, 0x04, 0x46, 0x04, 0x47, 0x04, 0x48, 0x04, 0x49, - 0x04, 0x4a, 0x04, 0x4b, 0x04, 0x4c, 0x04, 0x4d, 0x04, 0x4e, 0x04, 0x4f, - 0x21, 0x16, 0x04, 0x51, 0x04, 0x52, 0x04, 0x53, 0x04, 0x54, 0x04, 0x55, - 0x04, 0x56, 0x04, 0x57, 0x04, 0x58, 0x04, 0x59, 0x04, 0x5a, 0x04, 0x5b, - 0x04, 0x5c, 0x00, 0xa7, 0x04, 0x5e, 0x04, 0x5f -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-6.h b/package/libs/libiconv/src/include/charmaps/iso-8859-6.h deleted file mode 100644 index 820020fd9..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-6.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_6[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0xa4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x0c, 0x00, 0xad, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x06, 0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x1f, - 0xff, 0xff, 0x06, 0x21, 0x06, 0x22, 0x06, 0x23, 0x06, 0x24, 0x06, 0x25, - 0x06, 0x26, 0x06, 0x27, 0x06, 0x28, 0x06, 0x29, 0x06, 0x2a, 0x06, 0x2b, - 0x06, 0x2c, 0x06, 0x2d, 0x06, 0x2e, 0x06, 0x2f, 0x06, 0x30, 0x06, 0x31, - 0x06, 0x32, 0x06, 0x33, 0x06, 0x34, 0x06, 0x35, 0x06, 0x36, 0x06, 0x37, - 0x06, 0x38, 0x06, 0x39, 0x06, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x06, 0x40, 0x06, 0x41, 0x06, 0x42, 0x06, 0x43, - 0x06, 0x44, 0x06, 0x45, 0x06, 0x46, 0x06, 0x47, 0x06, 0x48, 0x06, 0x49, - 0x06, 0x4a, 0x06, 0x4b, 0x06, 0x4c, 0x06, 0x4d, 0x06, 0x4e, 0x06, 0x4f, - 0x06, 0x50, 0x06, 0x51, 0x06, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-7.h b/package/libs/libiconv/src/include/charmaps/iso-8859-7.h deleted file mode 100644 index 174f9d3cb..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-7.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_7[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x20, 0x18, - 0x20, 0x19, 0x00, 0xa3, 0x20, 0xac, 0x20, 0xaf, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x03, 0x7a, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0xff, 0xff, 0x20, 0x15, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x03, 0x84, 0x03, 0x85, 0x03, 0x86, 0x00, 0xb7, 0x03, 0x88, 0x03, 0x89, - 0x03, 0x8a, 0x00, 0xbb, 0x03, 0x8c, 0x00, 0xbd, 0x03, 0x8e, 0x03, 0x8f, - 0x03, 0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95, - 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9a, 0x03, 0x9b, - 0x03, 0x9c, 0x03, 0x9d, 0x03, 0x9e, 0x03, 0x9f, 0x03, 0xa0, 0x03, 0xa1, - 0xff, 0xff, 0x03, 0xa3, 0x03, 0xa4, 0x03, 0xa5, 0x03, 0xa6, 0x03, 0xa7, - 0x03, 0xa8, 0x03, 0xa9, 0x03, 0xaa, 0x03, 0xab, 0x03, 0xac, 0x03, 0xad, - 0x03, 0xae, 0x03, 0xaf, 0x03, 0xb0, 0x03, 0xb1, 0x03, 0xb2, 0x03, 0xb3, - 0x03, 0xb4, 0x03, 0xb5, 0x03, 0xb6, 0x03, 0xb7, 0x03, 0xb8, 0x03, 0xb9, - 0x03, 0xba, 0x03, 0xbb, 0x03, 0xbc, 0x03, 0xbd, 0x03, 0xbe, 0x03, 0xbf, - 0x03, 0xc0, 0x03, 0xc1, 0x03, 0xc2, 0x03, 0xc3, 0x03, 0xc4, 0x03, 0xc5, - 0x03, 0xc6, 0x03, 0xc7, 0x03, 0xc8, 0x03, 0xc9, 0x03, 0xca, 0x03, 0xcb, - 0x03, 0xcc, 0x03, 0xcd, 0x03, 0xce, 0xff, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-8.h b/package/libs/libiconv/src/include/charmaps/iso-8859-8.h deleted file mode 100644 index 66d4a5ec1..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-8.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_8[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0xff, 0xff, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xd7, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9, - 0x00, 0xf7, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x17, 0x05, 0xd0, 0x05, 0xd1, 0x05, 0xd2, 0x05, 0xd3, - 0x05, 0xd4, 0x05, 0xd5, 0x05, 0xd6, 0x05, 0xd7, 0x05, 0xd8, 0x05, 0xd9, - 0x05, 0xda, 0x05, 0xdb, 0x05, 0xdc, 0x05, 0xdd, 0x05, 0xde, 0x05, 0xdf, - 0x05, 0xe0, 0x05, 0xe1, 0x05, 0xe2, 0x05, 0xe3, 0x05, 0xe4, 0x05, 0xe5, - 0x05, 0xe6, 0x05, 0xe7, 0x05, 0xe8, 0x05, 0xe9, 0x05, 0xea, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x0e, 0x20, 0x0f, 0xff, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/iso-8859-9.h b/package/libs/libiconv/src/include/charmaps/iso-8859-9.h deleted file mode 100644 index f1a864606..000000000 --- a/package/libs/libiconv/src/include/charmaps/iso-8859-9.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_iso_8859_9[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, - 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, - 0x00, 0x8a, 0x00, 0x8b, 0x00, 0x8c, 0x00, 0x8d, 0x00, 0x8e, 0x00, 0x8f, - 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, - 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, - 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0x9f, 0x00, 0xa0, 0x00, 0xa1, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9, - 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf, - 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, - 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb, - 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x1e, 0x00, 0xd1, - 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7, - 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x30, - 0x01, 0x5e, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, - 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0x01, 0x1f, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5, - 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x01, 0x31, 0x01, 0x5f, 0x00, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/koi8-r.h b/package/libs/libiconv/src/include/charmaps/koi8-r.h deleted file mode 100644 index c2453a531..000000000 --- a/package/libs/libiconv/src/include/charmaps/koi8-r.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_koi8_r[] = { - 0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x25, 0x02, 0x25, 0x0c, 0x25, 0x10, - 0x25, 0x14, 0x25, 0x18, 0x25, 0x1c, 0x25, 0x24, 0x25, 0x2c, 0x25, 0x34, - 0x25, 0x3c, 0x25, 0x80, 0x25, 0x84, 0x25, 0x88, 0x25, 0x8c, 0x25, 0x90, - 0x25, 0x91, 0x25, 0x92, 0x25, 0x93, 0x23, 0x20, 0x25, 0xa0, 0x22, 0x19, - 0x22, 0x1a, 0x22, 0x48, 0x22, 0x64, 0x22, 0x65, 0x00, 0xa0, 0x23, 0x21, - 0x00, 0xb0, 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xf7, 0x25, 0x50, 0x25, 0x51, - 0x25, 0x52, 0x04, 0x51, 0x25, 0x53, 0x25, 0x54, 0x25, 0x55, 0x25, 0x56, - 0x25, 0x57, 0x25, 0x58, 0x25, 0x59, 0x25, 0x5a, 0x25, 0x5b, 0x25, 0x5c, - 0x25, 0x5d, 0x25, 0x5e, 0x25, 0x5f, 0x25, 0x60, 0x25, 0x61, 0x04, 0x01, - 0x25, 0x62, 0x25, 0x63, 0x25, 0x64, 0x25, 0x65, 0x25, 0x66, 0x25, 0x67, - 0x25, 0x68, 0x25, 0x69, 0x25, 0x6a, 0x25, 0x6b, 0x25, 0x6c, 0x00, 0xa9, - 0x04, 0x4e, 0x04, 0x30, 0x04, 0x31, 0x04, 0x46, 0x04, 0x34, 0x04, 0x35, - 0x04, 0x44, 0x04, 0x33, 0x04, 0x45, 0x04, 0x38, 0x04, 0x39, 0x04, 0x3a, - 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d, 0x04, 0x3e, 0x04, 0x3f, 0x04, 0x4f, - 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43, 0x04, 0x36, 0x04, 0x32, - 0x04, 0x4c, 0x04, 0x4b, 0x04, 0x37, 0x04, 0x48, 0x04, 0x4d, 0x04, 0x49, - 0x04, 0x47, 0x04, 0x4a, 0x04, 0x2e, 0x04, 0x10, 0x04, 0x11, 0x04, 0x26, - 0x04, 0x14, 0x04, 0x15, 0x04, 0x24, 0x04, 0x13, 0x04, 0x25, 0x04, 0x18, - 0x04, 0x19, 0x04, 0x1a, 0x04, 0x1b, 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e, - 0x04, 0x1f, 0x04, 0x2f, 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, - 0x04, 0x16, 0x04, 0x12, 0x04, 0x2c, 0x04, 0x2b, 0x04, 0x17, 0x04, 0x28, - 0x04, 0x2d, 0x04, 0x29, 0x04, 0x27, 0x04, 0x2a -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1250.h b/package/libs/libiconv/src/include/charmaps/windows-1250.h deleted file mode 100644 index 8e4723e48..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1250.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1250[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0xff, 0xff, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30, - 0x01, 0x60, 0x20, 0x39, 0x01, 0x5a, 0x01, 0x64, 0x01, 0x7d, 0x01, 0x79, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a, - 0x01, 0x5b, 0x01, 0x65, 0x01, 0x7e, 0x01, 0x7a, 0x00, 0xa0, 0x02, 0xc7, - 0x02, 0xd8, 0x01, 0x41, 0x00, 0xa4, 0x01, 0x04, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x01, 0x5e, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x01, 0x7b, 0x00, 0xb0, 0x00, 0xb1, 0x02, 0xdb, 0x01, 0x42, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x01, 0x05, - 0x01, 0x5f, 0x00, 0xbb, 0x01, 0x3d, 0x02, 0xdd, 0x01, 0x3e, 0x01, 0x7c, - 0x01, 0x54, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x01, 0x39, - 0x01, 0x06, 0x00, 0xc7, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x18, 0x00, 0xcb, - 0x01, 0x1a, 0x00, 0xcd, 0x00, 0xce, 0x01, 0x0e, 0x01, 0x10, 0x01, 0x43, - 0x01, 0x47, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0x50, 0x00, 0xd6, 0x00, 0xd7, - 0x01, 0x58, 0x01, 0x6e, 0x00, 0xda, 0x01, 0x70, 0x00, 0xdc, 0x00, 0xdd, - 0x01, 0x62, 0x00, 0xdf, 0x01, 0x55, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03, - 0x00, 0xe4, 0x01, 0x3a, 0x01, 0x07, 0x00, 0xe7, 0x01, 0x0d, 0x00, 0xe9, - 0x01, 0x19, 0x00, 0xeb, 0x01, 0x1b, 0x00, 0xed, 0x00, 0xee, 0x01, 0x0f, - 0x01, 0x11, 0x01, 0x44, 0x01, 0x48, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0x51, - 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x59, 0x01, 0x6f, 0x00, 0xfa, 0x01, 0x71, - 0x00, 0xfc, 0x00, 0xfd, 0x01, 0x63, 0x02, 0xd9 -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1251.h b/package/libs/libiconv/src/include/charmaps/windows-1251.h deleted file mode 100644 index e27885072..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1251.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1251[] = { - 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x04, 0x03, 0x20, 0x1a, 0x04, 0x53, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x20, 0xac, 0x20, 0x30, - 0x04, 0x09, 0x20, 0x39, 0x04, 0x0a, 0x04, 0x0c, 0x04, 0x0b, 0x04, 0x0f, - 0x04, 0x52, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0x04, 0x59, 0x20, 0x3a, - 0x04, 0x5a, 0x04, 0x5c, 0x04, 0x5b, 0x04, 0x5f, 0x00, 0xa0, 0x04, 0x0e, - 0x04, 0x5e, 0x04, 0x08, 0x00, 0xa4, 0x04, 0x90, 0x00, 0xa6, 0x00, 0xa7, - 0x04, 0x01, 0x00, 0xa9, 0x04, 0x04, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x04, 0x07, 0x00, 0xb0, 0x00, 0xb1, 0x04, 0x06, 0x04, 0x56, - 0x04, 0x91, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x04, 0x51, 0x21, 0x16, - 0x04, 0x54, 0x00, 0xbb, 0x04, 0x58, 0x04, 0x05, 0x04, 0x55, 0x04, 0x57, - 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x04, 0x14, 0x04, 0x15, - 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19, 0x04, 0x1a, 0x04, 0x1b, - 0x04, 0x1c, 0x04, 0x1d, 0x04, 0x1e, 0x04, 0x1f, 0x04, 0x20, 0x04, 0x21, - 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, 0x04, 0x26, 0x04, 0x27, - 0x04, 0x28, 0x04, 0x29, 0x04, 0x2a, 0x04, 0x2b, 0x04, 0x2c, 0x04, 0x2d, - 0x04, 0x2e, 0x04, 0x2f, 0x04, 0x30, 0x04, 0x31, 0x04, 0x32, 0x04, 0x33, - 0x04, 0x34, 0x04, 0x35, 0x04, 0x36, 0x04, 0x37, 0x04, 0x38, 0x04, 0x39, - 0x04, 0x3a, 0x04, 0x3b, 0x04, 0x3c, 0x04, 0x3d, 0x04, 0x3e, 0x04, 0x3f, - 0x04, 0x40, 0x04, 0x41, 0x04, 0x42, 0x04, 0x43, 0x04, 0x44, 0x04, 0x45, - 0x04, 0x46, 0x04, 0x47, 0x04, 0x48, 0x04, 0x49, 0x04, 0x4a, 0x04, 0x4b, - 0x04, 0x4c, 0x04, 0x4d, 0x04, 0x4e, 0x04, 0x4f -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1252.h b/package/libs/libiconv/src/include/charmaps/windows-1252.h deleted file mode 100644 index a6dad8a05..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1252.h +++ /dev/null @@ -1,25 +0,0 @@ -static const unsigned char map_windows_1252[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30, - 0x01, 0x60, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0x01, 0x7d, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a, - 0x01, 0x53, 0xff, 0xff, 0x01, 0x7e, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9, - 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf, - 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, - 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb, - 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x00, 0xd0, 0x00, 0xd1, - 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7, - 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x00, 0xdd, - 0x00, 0xde, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, - 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0x00, 0xf0, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5, - 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x00, 0xfd, 0x00, 0xfe, 0x00, 0xff -}; - diff --git a/package/libs/libiconv/src/include/charmaps/windows-1253.h b/package/libs/libiconv/src/include/charmaps/windows-1253.h deleted file mode 100644 index b0bdf1eb3..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1253.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1253[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30, - 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x03, 0x85, - 0x03, 0x86, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0xff, 0xff, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x20, 0x15, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x03, 0x84, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x03, 0x88, 0x03, 0x89, - 0x03, 0x8a, 0x00, 0xbb, 0x03, 0x8c, 0x00, 0xbd, 0x03, 0x8e, 0x03, 0x8f, - 0x03, 0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95, - 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9a, 0x03, 0x9b, - 0x03, 0x9c, 0x03, 0x9d, 0x03, 0x9e, 0x03, 0x9f, 0x03, 0xa0, 0x03, 0xa1, - 0xff, 0xff, 0x03, 0xa3, 0x03, 0xa4, 0x03, 0xa5, 0x03, 0xa6, 0x03, 0xa7, - 0x03, 0xa8, 0x03, 0xa9, 0x03, 0xaa, 0x03, 0xab, 0x03, 0xac, 0x03, 0xad, - 0x03, 0xae, 0x03, 0xaf, 0x03, 0xb0, 0x03, 0xb1, 0x03, 0xb2, 0x03, 0xb3, - 0x03, 0xb4, 0x03, 0xb5, 0x03, 0xb6, 0x03, 0xb7, 0x03, 0xb8, 0x03, 0xb9, - 0x03, 0xba, 0x03, 0xbb, 0x03, 0xbc, 0x03, 0xbd, 0x03, 0xbe, 0x03, 0xbf, - 0x03, 0xc0, 0x03, 0xc1, 0x03, 0xc2, 0x03, 0xc3, 0x03, 0xc4, 0x03, 0xc5, - 0x03, 0xc6, 0x03, 0xc7, 0x03, 0xc8, 0x03, 0xc9, 0x03, 0xca, 0x03, 0xcb, - 0x03, 0xcc, 0x03, 0xcd, 0x03, 0xce, 0xff, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1254.h b/package/libs/libiconv/src/include/charmaps/windows-1254.h deleted file mode 100644 index be2260079..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1254.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1254[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30, - 0x01, 0x60, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0x01, 0x61, 0x20, 0x3a, - 0x01, 0x53, 0xff, 0xff, 0xff, 0xff, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9, - 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf, - 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, - 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb, - 0x00, 0xcc, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x1e, 0x00, 0xd1, - 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7, - 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0x30, - 0x01, 0x5e, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x00, 0xe3, - 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x00, 0xec, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0x01, 0x1f, 0x00, 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00, 0xf5, - 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x01, 0x31, 0x01, 0x5f, 0x00, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1255.h b/package/libs/libiconv/src/include/charmaps/windows-1255.h deleted file mode 100644 index 28bf513d4..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1255.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1255[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30, - 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x00, 0xa1, - 0x00, 0xa2, 0x00, 0xa3, 0x20, 0xaa, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xd7, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9, - 0x00, 0xf7, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf, - 0x05, 0xb0, 0x05, 0xb1, 0x05, 0xb2, 0x05, 0xb3, 0x05, 0xb4, 0x05, 0xb5, - 0x05, 0xb6, 0x05, 0xb7, 0x05, 0xb8, 0x05, 0xb9, 0xff, 0xff, 0x05, 0xbb, - 0x05, 0xbc, 0x05, 0xbd, 0x05, 0xbe, 0x05, 0xbf, 0x05, 0xc0, 0x05, 0xc1, - 0x05, 0xc2, 0x05, 0xc3, 0x05, 0xf0, 0x05, 0xf1, 0x05, 0xf2, 0x05, 0xf3, - 0x05, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x05, 0xd0, 0x05, 0xd1, 0x05, 0xd2, 0x05, 0xd3, - 0x05, 0xd4, 0x05, 0xd5, 0x05, 0xd6, 0x05, 0xd7, 0x05, 0xd8, 0x05, 0xd9, - 0x05, 0xda, 0x05, 0xdb, 0x05, 0xdc, 0x05, 0xdd, 0x05, 0xde, 0x05, 0xdf, - 0x05, 0xe0, 0x05, 0xe1, 0x05, 0xe2, 0x05, 0xe3, 0x05, 0xe4, 0x05, 0xe5, - 0x05, 0xe6, 0x05, 0xe7, 0x05, 0xe8, 0x05, 0xe9, 0x05, 0xea, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x0e, 0x20, 0x0f, 0xff, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1256.h b/package/libs/libiconv/src/include/charmaps/windows-1256.h deleted file mode 100644 index fbca315ef..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1256.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1256[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0x06, 0x7e, 0x20, 0x1a, 0x01, 0x92, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30, - 0x06, 0x79, 0x20, 0x39, 0x01, 0x52, 0x06, 0x86, 0x06, 0x98, 0x06, 0x88, - 0x06, 0xaf, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0x06, 0xa9, 0x21, 0x22, 0x06, 0x91, 0x20, 0x3a, - 0x01, 0x53, 0x20, 0x0c, 0x20, 0x0d, 0x06, 0xba, 0x00, 0xa0, 0x06, 0x0c, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x06, 0xbe, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9, - 0x06, 0x1b, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x06, 0x1f, - 0x06, 0xc1, 0x06, 0x21, 0x06, 0x22, 0x06, 0x23, 0x06, 0x24, 0x06, 0x25, - 0x06, 0x26, 0x06, 0x27, 0x06, 0x28, 0x06, 0x29, 0x06, 0x2a, 0x06, 0x2b, - 0x06, 0x2c, 0x06, 0x2d, 0x06, 0x2e, 0x06, 0x2f, 0x06, 0x30, 0x06, 0x31, - 0x06, 0x32, 0x06, 0x33, 0x06, 0x34, 0x06, 0x35, 0x06, 0x36, 0x00, 0xd7, - 0x06, 0x37, 0x06, 0x38, 0x06, 0x39, 0x06, 0x3a, 0x06, 0x40, 0x06, 0x41, - 0x06, 0x42, 0x06, 0x43, 0x00, 0xe0, 0x06, 0x44, 0x00, 0xe2, 0x06, 0x45, - 0x06, 0x46, 0x06, 0x47, 0x06, 0x48, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x06, 0x49, 0x06, 0x4a, 0x00, 0xee, 0x00, 0xef, - 0x06, 0x4b, 0x06, 0x4c, 0x06, 0x4d, 0x06, 0x4e, 0x00, 0xf4, 0x06, 0x4f, - 0x06, 0x50, 0x00, 0xf7, 0x06, 0x51, 0x00, 0xf9, 0x06, 0x52, 0x00, 0xfb, - 0x00, 0xfc, 0x20, 0x0e, 0x20, 0x0f, 0x06, 0xd2 -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1257.h b/package/libs/libiconv/src/include/charmaps/windows-1257.h deleted file mode 100644 index 69d4474bc..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1257.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1257[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0xff, 0xff, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0xff, 0xff, 0x20, 0x30, - 0xff, 0xff, 0x20, 0x39, 0xff, 0xff, 0x00, 0xa8, 0x02, 0xc7, 0x00, 0xb8, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a, - 0xff, 0xff, 0x00, 0xaf, 0x02, 0xdb, 0xff, 0xff, 0x00, 0xa0, 0xff, 0xff, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0xff, 0xff, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xd8, 0x00, 0xa9, 0x01, 0x56, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xc6, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xf8, 0x00, 0xb9, - 0x01, 0x57, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xe6, - 0x01, 0x04, 0x01, 0x2e, 0x01, 0x00, 0x01, 0x06, 0x00, 0xc4, 0x00, 0xc5, - 0x01, 0x18, 0x01, 0x12, 0x01, 0x0c, 0x00, 0xc9, 0x01, 0x79, 0x01, 0x16, - 0x01, 0x22, 0x01, 0x36, 0x01, 0x2a, 0x01, 0x3b, 0x01, 0x60, 0x01, 0x43, - 0x01, 0x45, 0x00, 0xd3, 0x01, 0x4c, 0x00, 0xd5, 0x00, 0xd6, 0x00, 0xd7, - 0x01, 0x72, 0x01, 0x41, 0x01, 0x5a, 0x01, 0x6a, 0x00, 0xdc, 0x01, 0x7b, - 0x01, 0x7d, 0x00, 0xdf, 0x01, 0x05, 0x01, 0x2f, 0x01, 0x01, 0x01, 0x07, - 0x00, 0xe4, 0x00, 0xe5, 0x01, 0x19, 0x01, 0x13, 0x01, 0x0d, 0x00, 0xe9, - 0x01, 0x7a, 0x01, 0x17, 0x01, 0x23, 0x01, 0x37, 0x01, 0x2b, 0x01, 0x3c, - 0x01, 0x61, 0x01, 0x44, 0x01, 0x46, 0x00, 0xf3, 0x01, 0x4d, 0x00, 0xf5, - 0x00, 0xf6, 0x00, 0xf7, 0x01, 0x73, 0x01, 0x42, 0x01, 0x5b, 0x01, 0x6b, - 0x00, 0xfc, 0x01, 0x7c, 0x01, 0x7e, 0x02, 0xd9 -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-1258.h b/package/libs/libiconv/src/include/charmaps/windows-1258.h deleted file mode 100644 index 5bbd737ae..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-1258.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_1258[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0x20, 0x1a, 0x01, 0x92, - 0x20, 0x1e, 0x20, 0x26, 0x20, 0x20, 0x20, 0x21, 0x02, 0xc6, 0x20, 0x30, - 0xff, 0xff, 0x20, 0x39, 0x01, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0x02, 0xdc, 0x21, 0x22, 0xff, 0xff, 0x20, 0x3a, - 0x01, 0x53, 0xff, 0xff, 0xff, 0xff, 0x01, 0x78, 0x00, 0xa0, 0x00, 0xa1, - 0x00, 0xa2, 0x00, 0xa3, 0x00, 0xa4, 0x00, 0xa5, 0x00, 0xa6, 0x00, 0xa7, - 0x00, 0xa8, 0x00, 0xa9, 0x00, 0xaa, 0x00, 0xab, 0x00, 0xac, 0x00, 0xad, - 0x00, 0xae, 0x00, 0xaf, 0x00, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, - 0x00, 0xb4, 0x00, 0xb5, 0x00, 0xb6, 0x00, 0xb7, 0x00, 0xb8, 0x00, 0xb9, - 0x00, 0xba, 0x00, 0xbb, 0x00, 0xbc, 0x00, 0xbd, 0x00, 0xbe, 0x00, 0xbf, - 0x00, 0xc0, 0x00, 0xc1, 0x00, 0xc2, 0x01, 0x02, 0x00, 0xc4, 0x00, 0xc5, - 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc9, 0x00, 0xca, 0x00, 0xcb, - 0x03, 0x00, 0x00, 0xcd, 0x00, 0xce, 0x00, 0xcf, 0x01, 0x10, 0x00, 0xd1, - 0x03, 0x09, 0x00, 0xd3, 0x00, 0xd4, 0x01, 0xa0, 0x00, 0xd6, 0x00, 0xd7, - 0x00, 0xd8, 0x00, 0xd9, 0x00, 0xda, 0x00, 0xdb, 0x00, 0xdc, 0x01, 0xaf, - 0x03, 0x03, 0x00, 0xdf, 0x00, 0xe0, 0x00, 0xe1, 0x00, 0xe2, 0x01, 0x03, - 0x00, 0xe4, 0x00, 0xe5, 0x00, 0xe6, 0x00, 0xe7, 0x00, 0xe8, 0x00, 0xe9, - 0x00, 0xea, 0x00, 0xeb, 0x03, 0x01, 0x00, 0xed, 0x00, 0xee, 0x00, 0xef, - 0x01, 0x11, 0x00, 0xf1, 0x03, 0x23, 0x00, 0xf3, 0x00, 0xf4, 0x01, 0xa1, - 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf8, 0x00, 0xf9, 0x00, 0xfa, 0x00, 0xfb, - 0x00, 0xfc, 0x01, 0xb0, 0x20, 0xab, 0x00, 0xff -}; diff --git a/package/libs/libiconv/src/include/charmaps/windows-874.h b/package/libs/libiconv/src/include/charmaps/windows-874.h deleted file mode 100644 index 5749280a5..000000000 --- a/package/libs/libiconv/src/include/charmaps/windows-874.h +++ /dev/null @@ -1,24 +0,0 @@ -static const unsigned char map_windows_874[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x26, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1c, 0x20, 0x1d, 0x20, 0x22, - 0x20, 0x13, 0x20, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xa0, 0x0e, 0x01, - 0x0e, 0x02, 0x0e, 0x03, 0x0e, 0x04, 0x0e, 0x05, 0x0e, 0x06, 0x0e, 0x07, - 0x0e, 0x08, 0x0e, 0x09, 0x0e, 0x0a, 0x0e, 0x0b, 0x0e, 0x0c, 0x0e, 0x0d, - 0x0e, 0x0e, 0x0e, 0x0f, 0x0e, 0x10, 0x0e, 0x11, 0x0e, 0x12, 0x0e, 0x13, - 0x0e, 0x14, 0x0e, 0x15, 0x0e, 0x16, 0x0e, 0x17, 0x0e, 0x18, 0x0e, 0x19, - 0x0e, 0x1a, 0x0e, 0x1b, 0x0e, 0x1c, 0x0e, 0x1d, 0x0e, 0x1e, 0x0e, 0x1f, - 0x0e, 0x20, 0x0e, 0x21, 0x0e, 0x22, 0x0e, 0x23, 0x0e, 0x24, 0x0e, 0x25, - 0x0e, 0x26, 0x0e, 0x27, 0x0e, 0x28, 0x0e, 0x29, 0x0e, 0x2a, 0x0e, 0x2b, - 0x0e, 0x2c, 0x0e, 0x2d, 0x0e, 0x2e, 0x0e, 0x2f, 0x0e, 0x30, 0x0e, 0x31, - 0x0e, 0x32, 0x0e, 0x33, 0x0e, 0x34, 0x0e, 0x35, 0x0e, 0x36, 0x0e, 0x37, - 0x0e, 0x38, 0x0e, 0x39, 0x0e, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0e, 0x3f, 0x0e, 0x40, 0x0e, 0x41, 0x0e, 0x42, 0x0e, 0x43, - 0x0e, 0x44, 0x0e, 0x45, 0x0e, 0x46, 0x0e, 0x47, 0x0e, 0x48, 0x0e, 0x49, - 0x0e, 0x4a, 0x0e, 0x4b, 0x0e, 0x4c, 0x0e, 0x4d, 0x0e, 0x4e, 0x0e, 0x4f, - 0x0e, 0x50, 0x0e, 0x51, 0x0e, 0x52, 0x0e, 0x53, 0x0e, 0x54, 0x0e, 0x55, - 0x0e, 0x56, 0x0e, 0x57, 0x0e, 0x58, 0x0e, 0x59, 0x0e, 0x5a, 0x0e, 0x5b, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff -}; diff --git a/package/libs/libiconv/src/include/iconv.h b/package/libs/libiconv/src/include/iconv.h deleted file mode 100644 index 8767be42e..000000000 --- a/package/libs/libiconv/src/include/iconv.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _LIBICONV_H -#define _LIBICONV_H 1 - -#define _LIBICONV_VERSION 0x010B /* version number: (major<<8) + minor */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern int _libiconv_version; /* Likewise */ - -typedef long iconv_t; - -#define iconv_open libiconv_open -#define iconv libiconv -#define iconv_close libiconv_close - -extern iconv_t -iconv_open(const char *tocode, const char *fromcode); - -extern size_t -iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft); - -extern int -iconv_close(iconv_t cd); - -#define libiconv_set_relocation_prefix(...) do {} while(0) - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBICONV_H */ diff --git a/package/libs/libiconv/src/m4/iconv.m4 b/package/libs/libiconv/src/m4/iconv.m4 deleted file mode 100644 index e2041b9b4..000000000 --- a/package/libs/libiconv/src/m4/iconv.m4 +++ /dev/null @@ -1,214 +0,0 @@ -# iconv.m4 serial 11 (gettext-0.18.1) -dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], -[ - dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_LIB_LINKFLAGS_BODY([iconv]) -]) - -AC_DEFUN([AM_ICONV_LINK], -[ - dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and - dnl those with the standalone portable GNU libiconv installed). - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - - dnl Add $INCICONV to CPPFLAGS before performing the following checks, - dnl because if the user has installed libiconv and not disabled its use - dnl via --without-libiconv-prefix, he wants to use it. The first - dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. - am_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) - - AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - [am_cv_func_iconv=yes]) - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - [am_cv_lib_iconv=yes] - [am_cv_func_iconv=yes]) - LIBS="$am_save_LIBS" - fi - ]) - if test "$am_cv_func_iconv" = yes; then - AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ - dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10. - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - AC_TRY_RUN([ -#include -#include -int main () -{ - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - return 1; - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\263"; - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - return 1; - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - return 1; - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - return 1; - return 0; -}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], - [case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac]) - LIBS="$am_save_LIBS" - ]) - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then - AC_DEFINE([HAVE_ICONV], [1], - [Define if you have the iconv() function and it works.]) - fi - if test "$am_cv_lib_iconv" = yes; then - AC_MSG_CHECKING([how to link with libiconv]) - AC_MSG_RESULT([$LIBICONV]) - else - dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV - dnl either. - CPPFLAGS="$am_save_CPPFLAGS" - LIBICONV= - LTLIBICONV= - fi - AC_SUBST([LIBICONV]) - AC_SUBST([LTLIBICONV]) -]) - -dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to -dnl avoid warnings like -dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". -dnl This is tricky because of the way 'aclocal' is implemented: -dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. -dnl Otherwise aclocal's initial scan pass would miss the macro definition. -dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. -dnl Otherwise aclocal would emit many "Use of uninitialized value $1" -dnl warnings. -m4_define([gl_iconv_AC_DEFUN], - m4_version_prereq([2.64], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [[AC_DEFUN( - [$1], [$2])]])) -gl_iconv_AC_DEFUN([AM_ICONV], -[ - AM_ICONV_LINK - if test "$am_cv_func_iconv" = yes; then - AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL([am_cv_proto_iconv], [ - AC_TRY_COMPILE([ -#include -#include -extern -#ifdef __cplusplus -"C" -#endif -#if defined(__STDC__) || defined(__cplusplus) -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif -], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) - am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([ - $am_cv_proto_iconv]) - AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], - [Define as const if the declaration of iconv() needs const.]) - fi -]) diff --git a/package/libs/libjson-c/Makefile b/package/libs/libjson-c/Makefile index 0ea3fe80b..2c312f200 100644 --- a/package/libs/libjson-c/Makefile +++ b/package/libs/libjson-c/Makefile @@ -8,20 +8,18 @@ include $(TOPDIR)/rules.mk PKG_NAME:=json-c -PKG_VERSION:=0.15 +PKG_VERSION:=0.16 PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-nodoc.tar.gz PKG_SOURCE_URL:=https://s3.amazonaws.com/json-c_releases/releases/ -PKG_HASH:=99bca4f944b8ced8ae0bbc6310d6a3528ca715e69541793a1ef51f8c5b4b0878 +PKG_HASH:=ac8a3dd6820daaca579b23fbc74664310fbc3d67f52f6707cda67d21dde5570f PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=MIT PKG_LICENSE_FILES:=COPYING PKG_CPE_ID:=cpe:/a:json-c_project:json-c -PKG_FLAGS := nonshared -PKG_BUILD_PARALLEL:=1 HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST) include $(INCLUDE_DIR)/package.mk @@ -29,9 +27,11 @@ include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk CMAKE_HOST_OPTIONS += \ - -DCMAKE_SKIP_RPATH=FALSE \ - -DCMAKE_MACOSX_RPATH=1 \ - -DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOST}/lib" + -DDISABLE_EXTRA_LIBS=TRUE \ + -DBUILD_SHARED_LIBS=FALSE + +CMAKE_OPTIONS += \ + -DDISABLE_EXTRA_LIBS=TRUE define Package/libjson-c SECTION:=libs diff --git a/package/libs/libjson-c/patches/000-libm.patch b/package/libs/libjson-c/patches/000-libm.patch deleted file mode 100644 index c6ff5f476..000000000 --- a/package/libs/libjson-c/patches/000-libm.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/math_compat.h -+++ b/math_compat.h -@@ -6,38 +6,9 @@ - * @brief Do not use, json-c internal, may be changed or removed at any time. - */ - --/* Define isnan, isinf, infinity and nan on Windows/MSVC */ -- --#ifndef HAVE_DECL_ISNAN --#ifdef HAVE_DECL__ISNAN --#include --#define isnan(x) _isnan(x) --#else --/* On platforms like AIX and "IBM i" we need to provide our own isnan */ --#define isnan(x) ((x) != (x)) --#endif --#endif -- --#ifndef HAVE_DECL_ISINF --#ifdef HAVE_DECL__FINITE --#include --#define isinf(x) (!_finite(x)) --#else --#include --/* On platforms like AIX and "IBM i" we need to provide our own isinf */ --#define isinf(x) ((x) < -DBL_MAX || (x) > DBL_MAX) --#endif --#endif -- --#ifndef HAVE_DECL_INFINITY --#include --#define INFINITY (DBL_MAX + DBL_MAX) --#define HAVE_DECL_INFINITY --#endif -- --#ifndef HAVE_DECL_NAN --#define NAN (INFINITY - INFINITY) --#define HAVE_DECL_NAN --#endif -+#undef isnan -+#define isnan(x) __builtin_isnan(x) -+#undef isinf -+#define isinf(x) __builtin_isinf(x) - - #endif diff --git a/package/libs/libjson-c/patches/001-dont-build-docs.patch b/package/libs/libjson-c/patches/001-dont-build-docs.patch index 1aa0da4f5..f35da8072 100644 --- a/package/libs/libjson-c/patches/001-dont-build-docs.patch +++ b/package/libs/libjson-c/patches/001-dont-build-docs.patch @@ -1,11 +1,11 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -401,8 +401,6 @@ set(JSON_C_SOURCES +@@ -433,8 +433,6 @@ configure_file(json.h.cmakein ${PROJECT_ include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_BINARY_DIR}) -add_subdirectory(doc) - - # uninstall - add_custom_target(uninstall - COMMAND cat ${PROJECT_BINARY_DIR}/install_manifest.txt | xargs rm + # "uninstall" custom target for make generators in unix like operating systems + # and if that target is not present + if (CMAKE_GENERATOR STREQUAL "Unix Makefiles") diff --git a/package/libs/libmd/Makefile b/package/libs/libmd/Makefile new file mode 100644 index 000000000..faba27e5e --- /dev/null +++ b/package/libs/libmd/Makefile @@ -0,0 +1,47 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=libmd +PKG_VERSION:=1.0.4 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://archive.hadrons.org/software/libmd/ +PKG_HASH:=f51c921042e34beddeded4b75557656559cf5b1f2448033b4c1eec11c07e530f + +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=COPYING + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-static + +define Package/libmd + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Message Digest functions from BSD systems + ABI_VERSION:=0 +endef + +define Package/libmd/description + This library provides message digest functions found on BSD systems either + on their libc or libmd libraries and lacking on others like GNU systems, + thus making it easier to port projects with strong BSD origins, without + needing to embed the same code over and over again on each project. +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmd.a $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmd*.pc $(1)/usr/lib/pkgconfig/ + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ +endef + +$(eval $(call BuildPackage,libmd)) diff --git a/package/libs/libmnl/Makefile b/package/libs/libmnl/Makefile index 13628728e..06f79d538 100644 --- a/package/libs/libmnl/Makefile +++ b/package/libs/libmnl/Makefile @@ -8,20 +8,21 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libmnl -PKG_VERSION:=1.0.4 -PKG_RELEASE:=2 +PKG_VERSION:=1.0.5 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:= \ http://www.netfilter.org/projects/libmnl/files \ ftp://ftp.netfilter.org/pub/libmnl -PKG_HASH:=171f89699f286a5854b72b91d06e8f8e3683064c5901fb09d954a9ab6f551f81 +PKG_HASH:=274b9b919ef3152bfb3da3a13c950dd60d6e2bcd54230ffeca298d03b40d0525 PKG_MAINTAINER:=Jo-Philipp Wich PKG_FIXUP:=autoreconf PKG_INSTALL:=1 PKG_LICENSE:=LGPL-2.1+ +PKG_CPE_ID:=cpe:/a:netfilter:libmnl include $(INCLUDE_DIR)/package.mk diff --git a/package/libs/libmnl/patches/001-fix_build.patch b/package/libs/libmnl/patches/001-fix_build.patch new file mode 100644 index 000000000..d095ec89d --- /dev/null +++ b/package/libs/libmnl/patches/001-fix_build.patch @@ -0,0 +1,11 @@ +--- a/doxygen/Makefile.am ++++ b/doxygen/Makefile.am +@@ -21,7 +21,7 @@ doxyfile.stamp: $(doc_srcs) Makefile.am + # The command has to be a single line so the functions work + # and so `make` gives all lines to `bash -c` + # (hence ";\" at the end of every line but the last). +- /bin/bash -p -c 'declare -A renamed_page;\ ++ bash -p -c 'declare -A renamed_page;\ + main(){ set -e; cd man/man3; rm -f _*;\ + count_real_pages;\ + rename_real_pages;\ diff --git a/package/libs/libnetfilter-conntrack/Makefile b/package/libs/libnetfilter-conntrack/Makefile index 2020709d0..50432e9cd 100644 --- a/package/libs/libnetfilter-conntrack/Makefile +++ b/package/libs/libnetfilter-conntrack/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libnetfilter_conntrack -PKG_VERSION:=1.0.8 -PKG_RELEASE:=1 +PKG_VERSION:=1.0.9 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://www.netfilter.org/projects/libnetfilter_conntrack/files -PKG_HASH:=0cd13be008923528687af6c6b860f35392d49251c04ee0648282d36b1faec1cf +PKG_HASH:=67bd9df49fe34e8b82144f6dfb93b320f384a8ea59727e92ff8d18b5f4b579a8 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=GPL-2.0-or-later diff --git a/package/libs/libnetfilter-conntrack/patches/0001-conntrack-fix-build-with-kernel-5_15-and-musl.patch b/package/libs/libnetfilter-conntrack/patches/0001-conntrack-fix-build-with-kernel-5_15-and-musl.patch new file mode 100644 index 000000000..d04f4b5e4 --- /dev/null +++ b/package/libs/libnetfilter-conntrack/patches/0001-conntrack-fix-build-with-kernel-5_15-and-musl.patch @@ -0,0 +1,49 @@ +From 21ee35dde73aec5eba35290587d479218c6dd824 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Thu, 24 Feb 2022 15:01:11 +0100 +Subject: conntrack: fix build with kernel 5.15 and musl + +Currently, with kernel 5.15 headers and musl building is failing with +redefinition errors due to a conflict between the kernel and musl headers. + +Musl is able to suppres the conflicting kernel header definitions if they +are included after the standard libc ones, however since ICMP definitions +were moved into a separate internal header to avoid duplication this has +stopped working and is breaking the builds. + +It seems that the issue is that which contains the UAPI +suppression defines is included in the internal.h header and not in the +proto.h which actually includes the kernel ICMP headers and thus UAPI +supression defines are not present. + +Solve this by moving the include before the ICMP kernel +includes in the proto.h + +Fixes: bc1cb4b11403 ("conntrack: Move icmp request>reply type mapping to common file") +Signed-off-by: Robert Marko +Signed-off-by: Florian Westphal +--- + include/internal/internal.h | 1 - + include/internal/proto.h | 1 + + 2 files changed, 1 insertion(+), 1 deletion(-) + +--- a/include/internal/internal.h ++++ b/include/internal/internal.h +@@ -14,7 +14,6 @@ + #include + #include + #include +-#include + + #include + #include +--- a/include/internal/proto.h ++++ b/include/internal/proto.h +@@ -2,6 +2,7 @@ + #define _NFCT_PROTO_H_ + + #include ++#include + #include + #include + diff --git a/package/libs/libnfnetlink/Makefile b/package/libs/libnfnetlink/Makefile index bc64ff111..be1eba651 100644 --- a/package/libs/libnfnetlink/Makefile +++ b/package/libs/libnfnetlink/Makefile @@ -8,16 +8,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libnfnetlink -PKG_VERSION:=1.0.1 -PKG_RELEASE:=4 +PKG_VERSION:=1.0.2 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:= \ http://www.netfilter.org/projects/libnfnetlink/files/ \ ftp://ftp.netfilter.org/pub/libnfnetlink/ -PKG_HASH:=f270e19de9127642d2a11589ef2ec97ef90a649a74f56cf9a96306b04817b51a +PKG_HASH:=b064c7c3d426efb4786e60a8e6859b82ee2f2c5e49ffeea640cfe4fe33cbc376 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=GPL-2.0+ +PKG_CPE_ID:=cpe:/a:netfilter:libnfnetlink PKG_FIXUP:=autoreconf diff --git a/package/libs/libnfnetlink/patches/100-missing_include.patch b/package/libs/libnfnetlink/patches/100-missing_include.patch deleted file mode 100644 index 163307d89..000000000 --- a/package/libs/libnfnetlink/patches/100-missing_include.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/include/libnfnetlink/libnfnetlink.h -+++ b/include/libnfnetlink/libnfnetlink.h -@@ -15,6 +15,7 @@ - #define aligned_u64 unsigned long long __attribute__((aligned(8))) - #endif - -+#include - #include /* for sa_family_t */ - #include - #include ---- a/include/libnfnetlink/linux_nfnetlink.h -+++ b/include/libnfnetlink/linux_nfnetlink.h -@@ -1,6 +1,6 @@ - #ifndef _NFNETLINK_H - #define _NFNETLINK_H --#include -+#include - #include - - enum nfnetlink_groups { diff --git a/package/libs/libnftnl/Makefile b/package/libs/libnftnl/Makefile index 4c7f6ad46..50ad11a2c 100644 --- a/package/libs/libnftnl/Makefile +++ b/package/libs/libnftnl/Makefile @@ -8,12 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libnftnl -PKG_VERSION:=1.2.0 +PKG_CPE_ID:=cpe:/a:netfilter:libnftnl +PKG_VERSION:=1.2.4 PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://netfilter.org/projects/$(PKG_NAME)/files -PKG_HASH:=90b01fddfe9be8c3245c3ba5ff5a4424a8df708828f92b2b361976b658c074f5 +PKG_HASH:=c0fe233be4cdfd703e7d5977ef8eb63fcbf1d0052b6044e1b23d47ca3562477f PKG_MAINTAINER:=Steven Barth PKG_LICENSE:=GPL-2.0-or-later diff --git a/package/libs/libnl-tiny/Makefile b/package/libs/libnl-tiny/Makefile index ff3da5b51..4f09861ed 100644 --- a/package/libs/libnl-tiny/Makefile +++ b/package/libs/libnl-tiny/Makefile @@ -8,17 +8,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libnl-tiny -PKG_RELEASE:=2 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/libnl-tiny.git -PKG_SOURCE_DATE:=2020-08-05 -PKG_SOURCE_VERSION:=c291088f631d1694f7ba0444b59677b194348da8 -PKG_MIRROR_HASH:=99bcce12701bb34dadb39689d95c2c5cf1e27719d0ecfd645d3957a8947025ac +PKG_SOURCE_DATE:=2022-11-01 +PKG_SOURCE_VERSION:=db3b2cdbca5277723326a2720024a59fb821ae36 +PKG_MIRROR_HASH:=f6f9e2cb5366cda3be6d27a6320aa6cf3681c0b10df07b29ab4e4005e9f04f1c CMAKE_INSTALL:=1 -PKG_FLAGS := nonshared - PKG_LICENSE:=LGPL-2.1 PKG_MAINTAINER:=Felix Fietkau @@ -29,7 +27,7 @@ define Package/libnl-tiny SECTION:=libs CATEGORY:=Libraries TITLE:=netlink socket library - ABI_VERSION:=1 + ABI_VERSION:=$(PKG_SOURCE_DATE) endef define Package/libnl-tiny/description diff --git a/package/libs/libnl/Makefile b/package/libs/libnl/Makefile index db0c65c7a..71b043a9e 100644 --- a/package/libs/libnl/Makefile +++ b/package/libs/libnl/Makefile @@ -1,20 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-only # # Copyright (C) 2006-2013 OpenWrt.org # -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# include $(TOPDIR)/rules.mk PKG_NAME:=libnl -PKG_VERSION:=3.5.0 +PKG_VERSION:=3.7.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/thom311/libnl/releases/download/libnl$(subst .,_,$(PKG_VERSION)) -PKG_HASH:=352133ec9545da76f77e70ccb48c9d7e5324d67f6474744647a7ed382b5e05fa +PKG_HASH:=9fe43ccbeeea72c653bdcf8c93332583135cda46a79507bfd0a483bb57f65939 + PKG_LICENSE:=LGPL-2.1 +PKG_LICENSE_FILES:=COPYING +PKG_CPE_ID:=cpe:/a:libnl_project:libnl PKG_INSTALL:=1 PKG_FIXUP:=autoreconf diff --git a/package/libs/libnl/patches/100-build-add-Libs.private-field-in-libnl-pkg-config-file.patch b/package/libs/libnl/patches/100-build-add-Libs.private-field-in-libnl-pkg-config-file.patch deleted file mode 100644 index cec720b8e..000000000 --- a/package/libs/libnl/patches/100-build-add-Libs.private-field-in-libnl-pkg-config-file.patch +++ /dev/null @@ -1,25 +0,0 @@ -From db0d59cd06f3ffd350379847c0885e1bfb85af0f Mon Sep 17 00:00:00 2001 -From: Thomas Petazzoni -Date: Sat, 7 Mar 2015 11:34:42 +0100 -Subject: [PATCH 2/2] build: add Libs.private field in libnl pkg-config file - -In order to support static linking, the libnl pkg-config file should -indicate in its Libs.private field the libraries that libnl-3.0.a -requires. The LIBS variable contains the appropriate list of -libraries: -lm in all cases, and -lpthread when pthread support is -enabled. This allows to statically link applications against libnl -properly. - -Signed-off-by: Thomas Petazzoni ---- - libnl-3.0.pc.in | 1 + - 1 file changed, 1 insertion(+) - ---- a/libnl-3.0.pc.in -+++ b/libnl-3.0.pc.in -@@ -7,4 +7,5 @@ Name: libnl - Description: Convenience library for netlink sockets - Version: @PACKAGE_VERSION@ - Libs: -L${libdir} -lnl-@MAJ_VERSION@ -+Libs.private: @LIBS@ - Cflags: -I${includedir}/libnl@MAJ_VERSION@ diff --git a/package/libs/libpcap/Makefile b/package/libs/libpcap/Makefile index 1abf0ac8f..5ee5727a9 100644 --- a/package/libs/libpcap/Makefile +++ b/package/libs/libpcap/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2013 OpenWrt.org +# Copyright (C) 2006-2022 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -20,7 +20,8 @@ PKG_LICENSE:=BSD-3-Clause PKG_LICENSE_FILES:=LICENSE PKG_ASLR_PIE_REGULAR:=1 -PKG_BUILD_PARALLEL:=1 + +PKG_CONFIG_DEPENDS := CONFIG_PACKAGE_rpcapd include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/package/libs/libpcap/patches/210-add-rpcapd-in-linux-support.patch b/package/libs/libpcap/patches/210-add-rpcapd-in-linux-support.patch new file mode 100644 index 000000000..91b77aaf3 --- /dev/null +++ b/package/libs/libpcap/patches/210-add-rpcapd-in-linux-support.patch @@ -0,0 +1,19 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -200,15 +200,7 @@ option(NO_PROTOCHAIN "Disable protochain + # + set(PCAP_TYPE "" CACHE STRING "Packet capture type") + +-# +-# Default to having remote capture support on Windows and, for now, to +-# not having it on UN*X. +-# +-if(WIN32) +- option(ENABLE_REMOTE "Enable remote capture" ON) +-else() +- option(ENABLE_REMOTE "Enable remote capture" OFF) +-endif(WIN32) ++option(ENABLE_REMOTE "Enable remote capture" ON) + + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + option(BUILD_WITH_LIBNL "Build with libnl" ON) diff --git a/package/libs/libselinux/Makefile b/package/libs/libselinux/Makefile index 0c5f9bace..7246d8556 100644 --- a/package/libs/libselinux/Makefile +++ b/package/libs/libselinux/Makefile @@ -6,17 +6,20 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libselinux -PKG_VERSION:=3.2 -PKG_RELEASE:=1 +PKG_VERSION:=3.3 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=df758ef1d9d4811051dd901ea6b029ae334ffd7c671c128beb16bce1e25ac161 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=acfdee27633d2496508c28727c3d41d3748076f66d42fccde2e6b9f3463a7057 HOST_BUILD_DEPENDS:=libsepol/host pcre/host PKG_LICENSE:=libselinux-1.0 PKG_LICENSE_FILES:=LICENSE PKG_MAINTAINER:=Thomas Petazzoni +PKG_CPE_ID:=cpe:/a:selinuxproject:libselinux + +HOST_BUILD_DEPENDS:=libsepol/host musl-fts/host pcre/host include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk @@ -107,7 +110,8 @@ HOST_LDFLAGS += -Wl,-rpath="$(STAGING_DIR_HOSTPKG)/lib" HOST_MAKE_FLAGS += \ PREFIX=$(STAGING_DIR_HOSTPKG) \ - SHLIBDIR=$(STAGING_DIR_HOSTPKG)/lib + SHLIBDIR=$(STAGING_DIR_HOSTPKG)/lib \ + FTS_LDLIBS=-lfts ifeq ($(CONFIG_USE_MUSL),y) MAKE_FLAGS += FTS_LDLIBS=-lfts diff --git a/package/libs/libsemanage/Makefile b/package/libs/libsemanage/Makefile index 2fde14c06..8337b90bd 100644 --- a/package/libs/libsemanage/Makefile +++ b/package/libs/libsemanage/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libsemanage -PKG_VERSION:=3.2 -PKG_RELEASE:=2 +PKG_VERSION:=3.3 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=d722a55ca4fe2d4e2b30527720db657e6238b28079e69e2e4affeb8e733ee511 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=84d0ec5afa34bbbb471f602d8c1bf317d12443d07852a34b60741d428d597ce8 PKG_MAINTAINER:=Thomas Petazzoni PKG_LICENSE:=LGPL-2.1 PKG_LICENSE_FILES:=COPYING diff --git a/package/libs/libsepol/Makefile b/package/libs/libsepol/Makefile index c7950a9ba..816b13972 100644 --- a/package/libs/libsepol/Makefile +++ b/package/libs/libsepol/Makefile @@ -6,14 +6,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libsepol -PKG_VERSION:=3.2 +PKG_VERSION:=3.3 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=dfc7f662af8000116e56a01de6a0394ed79be1b34b999e551346233c5dd19508 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=2d97df3eb8466169b389c3660acbb90c54200ac96e452eca9f41a9639f4f238b PKG_MAINTAINER:=Thomas Petazzoni +PKG_CPE_ID:=cpe:/a:selinuxproject:libsepol include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk diff --git a/package/libs/libtool/Makefile b/package/libs/libtool/Makefile index 4b54ac495..f897f98c1 100644 --- a/package/libs/libtool/Makefile +++ b/package/libs/libtool/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libtool -PKG_VERSION:=2.4.6 -PKG_RELEASE:=2 +PKG_VERSION:=2.4.7 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/libtool -PKG_HASH:=7c87a8c2c8c0fc9cd5019e402bed4292462d00a718a7cd5f11218153bf28b26f +PKG_HASH:=4f7f217f057ce655ff22559ad221a0fd8ef84ad1fc5fcb6990cecc333aa1635d PKG_LICENSE:=GPL-2.0+ PKG_LICENSE_FILES:=COPYING diff --git a/package/libs/libtraceevent/Makefile b/package/libs/libtraceevent/Makefile new file mode 100644 index 000000000..63f954ba0 --- /dev/null +++ b/package/libs/libtraceevent/Makefile @@ -0,0 +1,74 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=libtraceevent +PKG_VERSION:=1.7.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/snapshot/ +PKG_HASH:=3e902184f743c955b183b45f25ea163a3d41c9f287fdcfc95cd9cca748c563c8 + +PKG_MAINTAINER:=Nick Hainke + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libtraceevent + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Linux kernel trace event library + URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git + ABI_VERSION:=0 +endef + +define Package/libtraceevent/description +The libtraceevent library provides APIs to access kernel tracepoint events, located in +the tracefs file system under the events directory. +endef + +define Package/libtraceevent-extra + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Extra plugins for libtraceevent + DEPENDS:= +endef + +CONFIGURE_ARGS+= \ + --enable-shared \ + --enable-static + +PLUGINS_DIR := $(PKG_BUILD_DIR)/plugins +PLUGINS_MAIN := function hrtimer mac80211 sched_switch + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/include/traceevent $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/libtraceevent.{a,so*} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_BUILD_DIR)/libtraceevent.pc $(1)/usr/lib/pkgconfig/ +endef + +define Package/libtraceevent/install + $(INSTALL_DIR) $(1)/usr/lib/traceevent/plugins + $(CP) $(PKG_BUILD_DIR)/lib/libtraceevent.so.* $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(patsubst %,$(PLUGINS_DIR)/plugin_%.so,$(PLUGINS_MAIN)) \ + $(1)/usr/lib/traceevent/plugins +endef + +define Package/libtraceevent-extra/install + $(INSTALL_DIR) $(1)/usr/lib/traceevent/plugins + $(CP) \ + $$(patsubst %,$(PLUGINS_DIR)/plugin_%.so, \ + $$(filter-out $(PLUGINS_MAIN), \ + $$(patsubst $(PLUGINS_DIR)/plugin_%.so,%, \ + $$(wildcard $(PLUGINS_DIR)/plugin_*.so)))) \ + $(1)/usr/lib/traceevent/plugins +endef + +$(eval $(call BuildPackage,libtraceevent)) +$(eval $(call BuildPackage,libtraceevent-extra)) diff --git a/package/libs/libtracefs/Makefile b/package/libs/libtracefs/Makefile new file mode 100644 index 000000000..a3d08d298 --- /dev/null +++ b/package/libs/libtracefs/Makefile @@ -0,0 +1,49 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=libtracefs +PKG_VERSION:=1.6.3 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/snapshot/ +PKG_HASH:=de307faaa54ac52cf0ce3ff19b32b51af24897e3440e643068ac82d31e197e92 + +PKG_MAINTAINER:=Nick Hainke + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libtracefs + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Linux kernel trace file system library + URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git + DEPENDS+=+libpthread +libtraceevent + ABI_VERSION:=0 +endef + +define Package/libtracefs/description +The libtracefs library provides APIs to access kernel trace file system. +endef + +CONFIGURE_ARGS+= \ + --enable-shared \ + --enable-static \ + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/include/* $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/libtracefs.{a,so*} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_BUILD_DIR)/libtracefs.pc $(1)/usr/lib/pkgconfig/ +endef + +define Package/libtracefs/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/libtracefs.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libtracefs)) diff --git a/package/libs/libubox/Makefile b/package/libs/libubox/Makefile index cc5d7f7ae..e19a97cbb 100644 --- a/package/libs/libubox/Makefile +++ b/package/libs/libubox/Makefile @@ -1,18 +1,16 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libubox -PKG_RELEASE=2 +PKG_RELEASE=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/libubox.git -PKG_MIRROR_HASH:=7dd1db1e0074a9c7c722db654cce3111b3bd3cff0bfd791c4497cb0f6c22d3ca -PKG_SOURCE_DATE:=2021-05-16 -PKG_SOURCE_VERSION:=b14c4688612c05c78ce984d7bde633bce8703b1e +PKG_MIRROR_HASH:=400bef38b8c0f382e4e595a50bb52dfbdb8da820eb80f3447b9bd7be3f5499a5 +PKG_SOURCE_DATE:=2022-09-27 +PKG_SOURCE_VERSION:=ea56013409d5823001b47a9bba6f74055a6d76a5 PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_SOURCE_DATE)) CMAKE_INSTALL:=1 -PKG_FLAGS := nonshared - PKG_LICENSE:=ISC PKG_LICENSE_FILES:= diff --git a/package/libs/libunwind/Makefile b/package/libs/libunwind/Makefile index 7f79996d2..c676d501b 100644 --- a/package/libs/libunwind/Makefile +++ b/package/libs/libunwind/Makefile @@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libunwind -PKG_VERSION:=1.5.0 +PKG_VERSION:=1.6.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SAVANNAH/$(PKG_NAME) -PKG_HASH:=90337653d92d4a13de590781371c604f9031cdb50520366aa1e3a91e1efb1017 +PKG_HASH:=4a6aec666991fb45d0889c44aede8ad6eb108071c3554fcdff671f9c94794976 PKG_MAINTAINER:=Yousong Zhou PKG_LICENSE:=X11 @@ -32,7 +32,7 @@ define Package/libunwind CATEGORY:=Libraries TITLE:=The libunwind project URL:=http://www.nongnu.org/libunwind/ - DEPENDS:=@((mips||mipsel||mips64||x86_64||arm||aarch64)||(USE_GLIBC&&(powerpc||i386))) +zlib + DEPENDS:=@((mips||mipsel||mips64||powerpc64||x86_64||arm||aarch64)||(USE_GLIBC&&(powerpc||i386))) +zlib ABI_VERSION:=8 endef diff --git a/package/libs/libusb/Makefile b/package/libs/libusb/Makefile index ce5440509..65c624409 100644 --- a/package/libs/libusb/Makefile +++ b/package/libs/libusb/Makefile @@ -8,18 +8,19 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libusb -PKG_VERSION:=1.0.24 +PKG_VERSION:=1.0.26 PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=\ https://github.com/libusb/libusb/releases/download/v$(PKG_VERSION) \ @SF/$(PKG_NAME) -PKG_HASH:=7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a +PKG_HASH:=12ce7a61fc9854d1d2a1ffe095f7b5fac19ddba095c259e6067a46500381b5a5 PKG_MAINTAINER:= Felix Fietkau PKG_LICENSE:=LGPL-2.1-or-later PKG_LICENSE_FILES:=COPYING +PKG_CPE_ID:=cpe:/a:libusb:libusb PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 @@ -30,7 +31,7 @@ define Package/libusb-1.0 SECTION:=libs CATEGORY:=Libraries TITLE:=A library for accessing Linux USB devices - DEPENDS:=+libpthread +librt + DEPENDS:=+libpthread +librt +libatomic URL:=http://libusb.info/ ABI_VERSION:=0 endef @@ -72,7 +73,7 @@ endef define Package/libusb-1.0/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-1.0.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-1.0.so* $(1)/usr/lib/ endef define Package/fxload/install diff --git a/package/libs/libusb/patches/001-Correct-a-typo-in-the-Changelog-and-clean-up-a-stray.patch b/package/libs/libusb/patches/001-Correct-a-typo-in-the-Changelog-and-clean-up-a-stray.patch deleted file mode 100644 index b17d6178d..000000000 --- a/package/libs/libusb/patches/001-Correct-a-typo-in-the-Changelog-and-clean-up-a-stray.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 369af149e3ad92514a2d24f112cedfeb7acaf558 Mon Sep 17 00:00:00 2001 -From: Chris Dickens -Date: Sun, 13 Dec 2020 15:46:27 -0800 -Subject: [PATCH] Correct a typo in the Changelog and clean up a stray file - -Signed-off-by: Chris Dickens ---- - ChangeLog | 2 +- - libusb/version_nano.h | 2 +- - test | 0 - 3 files changed, 2 insertions(+), 2 deletions(-) - delete mode 100644 test - ---- a/ChangeLog -+++ b/ChangeLog -@@ -12,7 +12,7 @@ visit: http://log.libusb.info - * Darwin (macOS): use IOUSBDevice as darwin_device_class explicitly (#693) - * Linux: Drop support for kernel older than 2.6.32 - * Linux: Provide an event thread name (#689) --* Linux: Wait until all USBs have been reaped before freeing them (#607) -+* Linux: Wait until all URBs have been reaped before freeing them (#607) - * NetBSD: Recognize device timeouts (#710) - * OpenBSD: Allow opening ugen devices multiple times (#763) - * OpenBSD: Support libusb_get_port_number() (#764) ---- a/libusb/version_nano.h -+++ b/libusb/version_nano.h -@@ -1 +1 @@ --#define LIBUSB_NANO 11584 -+#define LIBUSB_NANO 11585 diff --git a/package/libs/libusb/patches/002-linux_usbfs-Fix-parsing-of-descriptors-for-multi-con.patch b/package/libs/libusb/patches/002-linux_usbfs-Fix-parsing-of-descriptors-for-multi-con.patch deleted file mode 100644 index a53a8900d..000000000 --- a/package/libs/libusb/patches/002-linux_usbfs-Fix-parsing-of-descriptors-for-multi-con.patch +++ /dev/null @@ -1,61 +0,0 @@ -From f6d2cb561402c3b6d3627c0eb89e009b503d9067 Mon Sep 17 00:00:00 2001 -From: Chris Dickens -Date: Sun, 13 Dec 2020 15:49:19 -0800 -Subject: [PATCH] linux_usbfs: Fix parsing of descriptors for - multi-configuration devices - -Commit e2be556bd2 ("linux_usbfs: Parse config descriptors during device -initialization") introduced a regression for devices with multiple -configurations. The logic that verifies the reported length of the -configuration descriptors failed to count the length of the -configuration descriptor itself and would truncate the actual length by -9 bytes, leading to a parsing error for subsequent descriptors. - -Closes #825 - -Signed-off-by: Chris Dickens ---- - libusb/os/linux_usbfs.c | 12 ++++++++---- - libusb/version_nano.h | 2 +- - 2 files changed, 9 insertions(+), 5 deletions(-) - ---- a/libusb/os/linux_usbfs.c -+++ b/libusb/os/linux_usbfs.c -@@ -641,7 +641,12 @@ static int seek_to_next_config(struct li - uint8_t *buffer, size_t len) - { - struct usbi_descriptor_header *header; -- int offset = 0; -+ int offset; -+ -+ /* Start seeking past the config descriptor */ -+ offset = LIBUSB_DT_CONFIG_SIZE; -+ buffer += LIBUSB_DT_CONFIG_SIZE; -+ len -= LIBUSB_DT_CONFIG_SIZE; - - while (len > 0) { - if (len < 2) { -@@ -718,7 +723,7 @@ static int parse_config_descriptors(stru - } - - if (priv->sysfs_dir) { -- /* -+ /* - * In sysfs wTotalLength is ignored, instead the kernel returns a - * config descriptor with verified bLength fields, with descriptors - * with an invalid bLength removed. -@@ -727,8 +732,7 @@ static int parse_config_descriptors(stru - int offset; - - if (num_configs > 1 && idx < num_configs - 1) { -- offset = seek_to_next_config(ctx, buffer + LIBUSB_DT_CONFIG_SIZE, -- remaining - LIBUSB_DT_CONFIG_SIZE); -+ offset = seek_to_next_config(ctx, buffer, remaining); - if (offset < 0) - return offset; - sysfs_config_len = (uint16_t)offset; ---- a/libusb/version_nano.h -+++ b/libusb/version_nano.h -@@ -1 +1 @@ --#define LIBUSB_NANO 11585 -+#define LIBUSB_NANO 11586 diff --git a/package/libs/mbedtls/Config.in b/package/libs/mbedtls/Config.in new file mode 100644 index 000000000..ffabd799d --- /dev/null +++ b/package/libs/mbedtls/Config.in @@ -0,0 +1,193 @@ +if PACKAGE_libmbedtls + +comment "Option details in source code: include/mbedtls/mbedtls_config.h" + +comment "Ciphers - unselect old or less-used ciphers to reduce binary size" + +config MBEDTLS_AES_C + bool "MBEDTLS_AES_C" + default y + +config MBEDTLS_CAMELLIA_C + bool "MBEDTLS_CAMELLIA_C" + default n + +config MBEDTLS_CCM_C + bool "MBEDTLS_CCM_C" + default n + +config MBEDTLS_CMAC_C + bool "MBEDTLS_CMAC_C (old but used by hostapd)" + default y + +config MBEDTLS_DES_C + bool "MBEDTLS_DES_C (old but used by hostapd)" + default y + +config MBEDTLS_GCM_C + bool "MBEDTLS_GCM_C" + default y + +config MBEDTLS_NIST_KW_C + bool "MBEDTLS_NIST_KW_C (old but used by hostapd)" + default y + +config MBEDTLS_RIPEMD160_C + bool "MBEDTLS_RIPEMD160_C" + default n + +config MBEDTLS_XTEA_C + bool "MBEDTLS_XTEA_C" + default n + +config MBEDTLS_RSA_NO_CRT + bool "MBEDTLS_RSA_NO_CRT" + default y + +config MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_PSK_ENABLED" + default y + +config MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED" + default n + +config MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED" + default y + +config MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED" + default n + +config MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED" + default n + +config MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED" + default n + +config MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED" + default y + +config MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED" + default y + +config MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED" + default n + +config MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + bool "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED" + default n + +comment "Curves - unselect old or less-used curves to reduce binary size" + +config MBEDTLS_ECP_DP_SECP192R1_ENABLED + bool "MBEDTLS_ECP_DP_SECP192R1_ENABLED" + default n + +config MBEDTLS_ECP_DP_SECP224R1_ENABLED + bool "MBEDTLS_ECP_DP_SECP224R1_ENABLED" + default n + +config MBEDTLS_ECP_DP_SECP256R1_ENABLED + bool "MBEDTLS_ECP_DP_SECP256R1_ENABLED" + default y + +config MBEDTLS_ECP_DP_SECP384R1_ENABLED + bool "MBEDTLS_ECP_DP_SECP384R1_ENABLED" + default y + +config MBEDTLS_ECP_DP_SECP521R1_ENABLED + bool "MBEDTLS_ECP_DP_SECP521R1_ENABLED" + default n + +config MBEDTLS_ECP_DP_SECP192K1_ENABLED + bool "MBEDTLS_ECP_DP_SECP192K1_ENABLED" + default n + +config MBEDTLS_ECP_DP_SECP224K1_ENABLED + bool "MBEDTLS_ECP_DP_SECP224K1_ENABLED" + default n + +config MBEDTLS_ECP_DP_SECP256K1_ENABLED + bool "MBEDTLS_ECP_DP_SECP256K1_ENABLED" + default y + +config MBEDTLS_ECP_DP_BP256R1_ENABLED + bool "MBEDTLS_ECP_DP_BP256R1_ENABLED" + default n + +config MBEDTLS_ECP_DP_BP384R1_ENABLED + bool "MBEDTLS_ECP_DP_BP384R1_ENABLED" + default n + +config MBEDTLS_ECP_DP_BP512R1_ENABLED + bool "MBEDTLS_ECP_DP_BP512R1_ENABLED" + default n + +config MBEDTLS_ECP_DP_CURVE25519_ENABLED + bool "MBEDTLS_ECP_DP_CURVE25519_ENABLED" + default y + +config MBEDTLS_ECP_DP_CURVE448_ENABLED + bool "MBEDTLS_ECP_DP_CURVE448_ENABLED" + default n + +comment "Build Options - unselect features to reduce binary size" + +config MBEDTLS_CERTS_C + bool "MBEDTLS_CERTS_C" + default n + +config MBEDTLS_CIPHER_MODE_OFB + bool "MBEDTLS_CIPHER_MODE_OFB" + default n + +config MBEDTLS_CIPHER_MODE_XTS + bool "MBEDTLS_CIPHER_MODE_XTS" + default n + +config MBEDTLS_DEBUG_C + bool "MBEDTLS_DEBUG_C" + default n + +config MBEDTLS_HKDF_C + bool "MBEDTLS_HKDF_C" + default n + +config MBEDTLS_PLATFORM_C + bool "MBEDTLS_PLATFORM_C" + default n + +config MBEDTLS_SELF_TEST + bool "MBEDTLS_SELF_TEST" + default n + +config MBEDTLS_SSL_TRUNCATED_HMAC + bool "MBEDTLS_SSL_TRUNCATED_HMAC" + default n + +config MBEDTLS_VERSION_C + bool "MBEDTLS_VERSION_C" + default n + +config MBEDTLS_VERSION_FEATURES + bool "MBEDTLS_VERSION_FEATURES" + default n + +comment "Build Options" + +config MBEDTLS_ENTROPY_FORCE_SHA256 + bool "MBEDTLS_ENTROPY_FORCE_SHA256" + default y + +config MBEDTLS_SSL_RENEGOTIATION + bool "MBEDTLS_SSL_RENEGOTIATION" + default n + +endif diff --git a/package/libs/mbedtls/Makefile b/package/libs/mbedtls/Makefile index e1900fcb5..b07f0477e 100644 --- a/package/libs/mbedtls/Makefile +++ b/package/libs/mbedtls/Makefile @@ -8,23 +8,72 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mbedtls -PKG_VERSION:=2.28.1 -PKG_RELEASE:=$(AUTORELEASE) +PKG_VERSION:=2.28.2 +PKG_RELEASE:=1 PKG_USE_MIPS16:=0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/ARMmbed/mbedtls/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=6797a7b6483ef589deeab8d33d401ed235d7be25eeecda1be8ddfed406d40ff4 +PKG_HASH:=bc55232bf71fd66045122ba9050a29ea7cb2e8f99b064a9e6334a82f715881a0 PKG_LICENSE:=GPL-2.0-or-later PKG_LICENSE_FILES:=gpl-2.0.txt PKG_CPE_ID:=cpe:/a:arm:mbed_tls -PKG_CONFIG_DEPENDS := \ - CONFIG_LIBMBEDTLS_DEBUG_C \ - CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES \ - CONFIG_LIBMBEDTLS_HAVE_SSE2 \ - CONFIG_LIBMBEDTLS_HKDF_C +MBEDTLS_BUILD_OPTS_CURVES= \ + CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED \ + CONFIG_MBEDTLS_ECP_DP_CURVE448_ENABLED + +MBEDTLS_BUILD_OPTS_CIPHERS= \ + CONFIG_MBEDTLS_AES_C \ + CONFIG_MBEDTLS_CAMELLIA_C \ + CONFIG_MBEDTLS_CCM_C \ + CONFIG_MBEDTLS_CMAC_C \ + CONFIG_MBEDTLS_DES_C \ + CONFIG_MBEDTLS_GCM_C \ + CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED \ + CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED \ + CONFIG_MBEDTLS_NIST_KW_C \ + CONFIG_MBEDTLS_RIPEMD160_C \ + CONFIG_MBEDTLS_RSA_NO_CRT \ + CONFIG_MBEDTLS_XTEA_C + +MBEDTLS_BUILD_OPTS= \ + $(MBEDTLS_BUILD_OPTS_CURVES) \ + $(MBEDTLS_BUILD_OPTS_CIPHERS) \ + CONFIG_MBEDTLS_CERTS_C \ + CONFIG_MBEDTLS_CIPHER_MODE_OFB \ + CONFIG_MBEDTLS_CIPHER_MODE_XTS \ + CONFIG_MBEDTLS_DEBUG_C \ + CONFIG_MBEDTLS_ENTROPY_FORCE_SHA256 \ + CONFIG_MBEDTLS_HKDF_C \ + CONFIG_MBEDTLS_PLATFORM_C \ + CONFIG_MBEDTLS_SELF_TEST \ + CONFIG_MBEDTLS_SSL_RENEGOTIATION \ + CONFIG_MBEDTLS_SSL_TRUNCATED_HMAC \ + CONFIG_MBEDTLS_VERSION_C \ + CONFIG_MBEDTLS_VERSION_FEATURES + +PKG_CONFIG_DEPENDS := $(MBEDTLS_BUILD_OPTS) include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk @@ -45,56 +94,12 @@ $(call Package/mbedtls/Default) CATEGORY:=Libraries SUBMENU:=SSL TITLE+= (library) - PKGFLAGS:=nonshared ABI_VERSION:=12 + MENU:=1 endef define Package/libmbedtls/config -config LIBMBEDTLS_DEBUG_C - depends on PACKAGE_libmbedtls - bool "Enable debug functions" - default n - help - This option enables mbedtls library's debug functions. - - It increases the uncompressed libmbedtls binary size - by around 60 KiB (for an ARMv5 platform). - - Usually, you don't need this, so don't select this if you're unsure. - -config LIBMBEDTLS_HAVE_ARMV8CE_AES - depends on PACKAGE_libmbedtls - bool - default y - prompt "Enable use of the ARMv8 Crypto Extensions" - depends on aarch64 && !TARGET_bcm27xx - help - Use of the ARMv8 Crypto Extensions greatly increase performance - (up to 4x faster on AES-GCM while 10x faster on raw AES). - - If you don't sure, say Y here. - -config LIBMBEDTLS_HAVE_SSE2 - depends on PACKAGE_libmbedtls - bool - default y if !TARGET_x86_legacy && !TARGET_x86_geode - prompt "Enable use of x86 SSE2 instructions" - depends on x86_64 || i386 - help - Use of SSE2 instructions greatly increase performance (up to - 3x faster) with a minimum (~0.2%, or 23KB) increase in package - size, but it will bring no benefit if your hardware does not - support them, such as Geode GX and LX. In this case you may - save 23KB by saying yes here. AMD Geode NX, and Intel - Pentium 4 and above support SSE2. - -config LIBMBEDTLS_HKDF_C - depends on PACKAGE_libmbedtls - bool "Enable the HKDF algorithm (RFC 5869)" - default n - help - This option adds support for the Hashed Message Authentication Code - (HMAC)-based key derivation function (HKDF). + source "$(SOURCE)/Config.in" endef define Package/mbedtls-util @@ -118,9 +123,6 @@ endef TARGET_CFLAGS += -ffunction-sections -fdata-sections TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -ifneq ($(CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES),) - TARGET_CFLAGS := $(filter-out -march=%,$(TARGET_CFLAGS)) -march=armv8-a+crypto -endif CMAKE_OPTIONS += \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ @@ -129,28 +131,22 @@ CMAKE_OPTIONS += \ -DENABLE_PROGRAMS:Bool=ON define Build/Configure - $(Build/Configure/Default) - - awk 'BEGIN { rc = 1 } \ - /#define MBEDTLS_DEBUG_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_DEBUG_C),,// )#define MBEDTLS_DEBUG_C"; rc = 0 } \ - /#define MBEDTLS_ARMV8CE_AES_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES),,// )#define MBEDTLS_ARMV8CE_AES_C"; rc = 0 } \ - /#define MBEDTLS_HAVE_SSE2/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HAVE_SSE2),,// )#define MBEDTLS_HAVE_SSE2"; rc = 0 } \ - { print } \ - END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \ - >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \ - mv $(PKG_BUILD_DIR)/include/mbedtls/config.h.new $(PKG_BUILD_DIR)/include/mbedtls/config.h - - awk 'BEGIN { rc = 1 } \ - /#define MBEDTLS_HKDF_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HKDF_C),,// )#define MBEDTLS_HKDF_C"; rc = 0 } \ - { print } \ - END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \ - >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \ - mv $(PKG_BUILD_DIR)/include/mbedtls/config.h.new $(PKG_BUILD_DIR)/include/mbedtls/config.h + $(call Build/Configure/Default) sed -i '/fuzz/d' $(PKG_BUILD_DIR)/programs/CMakeLists.txt sed -i '/test/d' $(PKG_BUILD_DIR)/programs/CMakeLists.txt endef +define Build/Prepare + $(call Build/Prepare/Default) + + $(if $(strip $(foreach opt,$(MBEDTLS_BUILD_OPTS),$($(opt)))), + $(foreach opt,$(MBEDTLS_BUILD_OPTS), + $(PKG_BUILD_DIR)/scripts/config.py \ + -f $(PKG_BUILD_DIR)/include/mbedtls/config.h \ + $(if $($(opt)),set,unset) $(patsubst CONFIG_%,%,$(opt))),) +endef + define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include $(CP) $(PKG_INSTALL_DIR)/usr/include/mbedtls $(1)/usr/include/ diff --git a/package/libs/mbedtls/patches/100-Implements-AES-and-GCM-with-ARMv8-Crypto-Extensions.patch b/package/libs/mbedtls/patches/100-Implements-AES-and-GCM-with-ARMv8-Crypto-Extensions.patch deleted file mode 100644 index d4900724a..000000000 --- a/package/libs/mbedtls/patches/100-Implements-AES-and-GCM-with-ARMv8-Crypto-Extensions.patch +++ /dev/null @@ -1,390 +0,0 @@ -From dfb6015ca79a9fee28f7fcb0af7e350a83574b83 Mon Sep 17 00:00:00 2001 -From: "Markku-Juhani O. Saarinen" -Date: Mon, 20 Nov 2017 14:58:41 +0000 -Subject: Implements AES and GCM with ARMv8 Crypto Extensions - -A compact patch that provides AES and GCM implementations that utilize the -ARMv8 Crypto Extensions. The config flag is MBEDTLS_ARMV8CE_AES_C, which -is disabled by default as we don't do runtime checking for the feature. -The new implementation lives in armv8ce_aes.c. - -Provides similar functionality to https://github.com/ARMmbed/mbedtls/pull/432 -Thanks to Barry O'Rourke and others for that contribtion. - -Tested on a Cortex A53 device and QEMU. On a midrange phone the real AES-GCM -throughput increases about 4x, while raw AES speed is up to 10x faster. - -When cross-compiling, you want to set something like: - - export CC='aarch64-linux-gnu-gcc' - export CFLAGS='-Ofast -march=armv8-a+crypto' - scripts/config.pl set MBEDTLS_ARMV8CE_AES_C - -QEMU seems to also need - - export LDFLAGS='-static' - -Then run normal make or cmake etc. ---- - ---- /dev/null -+++ b/ChangeLog.d/armv8_crypto_extensions.txt -@@ -0,0 +1,2 @@ -+Features -+ * Support ARMv8 Cryptography Extensions for AES and GCM. ---- /dev/null -+++ b/include/mbedtls/armv8ce_aes.h -@@ -0,0 +1,63 @@ -+/** -+ * \file armv8ce_aes.h -+ * -+ * \brief ARMv8 Cryptography Extensions -- Optimized code for AES and GCM -+ */ -+ -+/* -+ * -+ * Copyright (C) 2006-2017, ARM Limited, All Rights Reserved -+ * SPDX-License-Identifier: Apache-2.0 -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); you may -+ * not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ * -+ * This file is part of mbed TLS (https://tls.mbed.org) -+ */ -+ -+#ifndef MBEDTLS_ARMV8CE_AES_H -+#define MBEDTLS_ARMV8CE_AES_H -+ -+#include "aes.h" -+ -+/** -+ * \brief [ARMv8 Crypto Extensions] AES-ECB block en(de)cryption -+ * -+ * \param ctx AES context -+ * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT -+ * \param input 16-byte input block -+ * \param output 16-byte output block -+ * -+ * \return 0 on success (cannot fail) -+ */ -+ -+int mbedtls_armv8ce_aes_crypt_ecb( mbedtls_aes_context *ctx, -+ int mode, -+ const unsigned char input[16], -+ unsigned char output[16] ); -+ -+/** -+ * \brief [ARMv8 Crypto Extensions] Multiply in GF(2^128) for GCM -+ * -+ * \param c Result -+ * \param a First operand -+ * \param b Second operand -+ * -+ * \note Both operands and result are bit strings interpreted as -+ * elements of GF(2^128) as per the GCM spec. -+ */ -+ -+void mbedtls_armv8ce_gcm_mult( unsigned char c[16], -+ const unsigned char a[16], -+ const unsigned char b[16] ); -+ -+#endif /* MBEDTLS_ARMV8CE_AES_H */ ---- a/include/mbedtls/check_config.h -+++ b/include/mbedtls/check_config.h -@@ -72,6 +72,10 @@ - #error "MBEDTLS_AESNI_C defined, but not all prerequisites" - #endif - -+#if defined(MBEDTLS_ARMV8CE_AES_C) && !defined(MBEDTLS_HAVE_ASM) -+#error "MBEDTLS_ARMV8CE_AES_C defined, but not all prerequisites" -+#endif -+ - #if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C) - #error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites" - #endif -@@ -897,3 +901,4 @@ - typedef int mbedtls_iso_c_forbids_empty_translation_units; - - #endif /* MBEDTLS_CHECK_CONFIG_H */ -+ ---- a/include/mbedtls/config.h -+++ b/include/mbedtls/config.h -@@ -46,6 +46,7 @@ - * Requires support for asm() in compiler. - * - * Used in: -+ * library/armv8ce_aes.c - * library/aria.c - * library/timing.c - * include/mbedtls/bn_mul.h -@@ -2313,6 +2314,21 @@ - #define MBEDTLS_AESNI_C - - /** -+ * \def MBEDTLS_ARMV8CE_AES_C -+ * -+ * Enable ARMv8 Crypto Extensions for AES and GCM -+ * -+ * Module: library/armv8ce_aes.c -+ * Caller: library/aes.c -+ * library/gcm.c -+ * -+ * Requires: MBEDTLS_HAVE_ASM -+ * -+ * This module adds support for Armv8 Cryptography Extensions for AES and GCM. -+ */ -+//#define MBEDTLS_ARMV8CE_AES_C -+ -+/** - * \def MBEDTLS_AES_C - * - * Enable the AES block cipher. ---- a/library/aes.c -+++ b/library/aes.c -@@ -39,7 +39,9 @@ - #if defined(MBEDTLS_AESNI_C) - #include "mbedtls/aesni.h" - #endif -- -+#if defined(MBEDTLS_ARMV8CE_AES_C) -+#include "mbedtls/armv8ce_aes.h" -+#endif - #if defined(MBEDTLS_SELF_TEST) - #if defined(MBEDTLS_PLATFORM_C) - #include "mbedtls/platform.h" -@@ -999,6 +1001,11 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_c - return( mbedtls_aesni_crypt_ecb( ctx, mode, input, output ) ); - #endif - -+#if defined(MBEDTLS_ARMV8CE_AES_C) -+ // We don't do runtime checking for ARMv8 Crypto Extensions -+ return mbedtls_armv8ce_aes_crypt_ecb( ctx, mode, input, output ); -+#endif -+ - #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) - if( aes_padlock_ace ) - { ---- /dev/null -+++ b/library/armv8ce_aes.c -@@ -0,0 +1,142 @@ -+/* -+ * ARMv8 Cryptography Extensions -- Optimized code for AES and GCM -+ * -+ * Copyright (C) 2006-2017, ARM Limited, All Rights Reserved -+ * SPDX-License-Identifier: Apache-2.0 -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); you may -+ * not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ * -+ * This file is part of mbed TLS (https://tls.mbed.org) -+ */ -+ -+#if !defined(MBEDTLS_CONFIG_FILE) -+#include "mbedtls/config.h" -+#else -+#include MBEDTLS_CONFIG_FILE -+#endif -+ -+#if defined(MBEDTLS_ARMV8CE_AES_C) -+ -+#include -+#include "mbedtls/armv8ce_aes.h" -+ -+#ifndef asm -+#define asm __asm -+#endif -+ -+/* -+ * [Armv8 Cryptography Extensions] AES-ECB block en(de)cryption -+ */ -+ -+#if defined(MBEDTLS_AES_C) -+ -+int mbedtls_armv8ce_aes_crypt_ecb( mbedtls_aes_context *ctx, -+ int mode, -+ const unsigned char input[16], -+ unsigned char output[16] ) -+{ -+ unsigned int i; -+ const uint8_t *rk; -+ uint8x16_t x, k; -+ -+ x = vld1q_u8( input ); /* input block */ -+ rk = (const uint8_t *) ctx->rk; /* round keys */ -+ -+ if( mode == MBEDTLS_AES_ENCRYPT ) -+ { -+ for( i = ctx->nr - 1; i != 0; i-- ) /* encryption loop */ -+ { -+ k = vld1q_u8( rk ); -+ rk += 16; -+ x = vaeseq_u8( x, k ); -+ x = vaesmcq_u8( x ); -+ } -+ k = vld1q_u8( rk ); -+ rk += 16; -+ x = vaeseq_u8( x, k ); -+ } -+ else -+ { -+ for( i = ctx->nr - 1; i != 0 ; i-- ) /* decryption loop */ -+ { -+ k = vld1q_u8( rk ); -+ rk += 16; -+ x = vaesdq_u8( x, k ); -+ x = vaesimcq_u8( x ); -+ } -+ k = vld1q_u8( rk ); -+ rk += 16; -+ x = vaesdq_u8( x, k ); -+ } -+ -+ k = vld1q_u8( rk ); /* final key just XORed */ -+ x = veorq_u8( x, k ); -+ vst1q_u8( output, x ); /* write out */ -+ -+ return ( 0 ); -+} -+ -+#endif /* MBEDTLS_AES_C */ -+ -+ -+/* -+ * [Armv8 Cryptography Extensions] Multiply in GF(2^128) for GCM -+ */ -+ -+#if defined(MBEDTLS_GCM_C) -+ -+void mbedtls_armv8ce_gcm_mult( unsigned char c[16], -+ const unsigned char a[16], -+ const unsigned char b[16] ) -+{ -+ /* GCM's GF(2^128) polynomial basis is x^128 + x^7 + x^2 + x + 1 */ -+ const uint64x2_t base = { 0, 0x86 }; /* note missing LS bit */ -+ -+ register uint8x16_t vc asm( "v0" ); /* named registers */ -+ register uint8x16_t va asm( "v1" ); /* (to avoid conflict) */ -+ register uint8x16_t vb asm( "v2" ); -+ register uint64x2_t vp asm( "v3" ); -+ -+ va = vld1q_u8( a ); /* load inputs */ -+ vb = vld1q_u8( b ); -+ vp = base; -+ -+ asm ( -+ "rbit %1.16b, %1.16b \n\t" /* reverse bit order */ -+ "rbit %2.16b, %2.16b \n\t" -+ "pmull2 %0.1q, %1.2d, %2.2d \n\t" /* v0 = a.hi * b.hi */ -+ "pmull2 v4.1q, %0.2d, %3.2d \n\t" /* mul v0 by x^64, reduce */ -+ "ext %0.16b, %0.16b, %0.16b, #8 \n\t" -+ "eor %0.16b, %0.16b, v4.16b \n\t" -+ "ext v5.16b, %2.16b, %2.16b, #8 \n\t" /* (swap hi and lo in b) */ -+ "pmull v4.1q, %1.1d, v5.1d \n\t" /* v0 ^= a.lo * b.hi */ -+ "eor %0.16b, %0.16b, v4.16b \n\t" -+ "pmull2 v4.1q, %1.2d, v5.2d \n\t" /* v0 ^= a.hi * b.lo */ -+ "eor %0.16b, %0.16b, v4.16b \n\t" -+ "pmull2 v4.1q, %0.2d, %3.2d \n\t" /* mul v0 by x^64, reduce */ -+ "ext %0.16b, %0.16b, %0.16b, #8 \n\t" -+ "eor %0.16b, %0.16b, v4.16b \n\t" -+ "pmull v4.1q, %1.1d, %2.1d \n\t" /* v0 ^= a.lo * b.lo */ -+ "eor %0.16b, %0.16b, v4.16b \n\t" -+ "rbit %0.16b, %0.16b \n\t" /* reverse bits for output */ -+ : "=w" (vc) /* q0: output */ -+ : "w" (va), "w" (vb), "w" (vp) /* q1, q2: input */ -+ : "v4", "v5" /* q4, q5: clobbered */ -+ ); -+ -+ vst1q_u8( c, vc ); /* write out */ -+} -+ -+#endif /* MBEDTLS_GCM_C */ -+ -+#endif /* MBEDTLS_ARMV8CE_AES_C */ ---- a/library/CMakeLists.txt -+++ b/library/CMakeLists.txt -@@ -15,6 +15,7 @@ set(src_crypto - aesni.c - arc4.c - aria.c -+ armv8ce_aes.c - asn1parse.c - asn1write.c - base64.c ---- a/library/gcm.c -+++ b/library/gcm.c -@@ -41,6 +41,10 @@ - #include "mbedtls/aesni.h" - #endif - -+#if defined(MBEDTLS_ARMV8CE_AES_C) -+#include "mbedtls/armv8ce_aes.h" -+#endif -+ - #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) - #include "mbedtls/aes.h" - #include "mbedtls/platform.h" -@@ -87,6 +91,12 @@ static int gcm_gen_table( mbedtls_gcm_co - if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, h, 16, h, &olen ) ) != 0 ) - return( ret ); - -+#if defined(MBEDTLS_ARMV8CE_AES_C) -+ // we don't do feature testing with ARMv8 cryptography extensions -+ memcpy( ctx ->HL, h, 16 ); // put H at the beginning of buffer -+ return( 0 ); // that's all we need -+#endif -+ - /* pack h as two 64-bits ints, big-endian */ - hi = MBEDTLS_GET_UINT32_BE( h, 0 ); - lo = MBEDTLS_GET_UINT32_BE( h, 4 ); -@@ -196,6 +206,11 @@ static void gcm_mult( mbedtls_gcm_contex - unsigned char lo, hi, rem; - uint64_t zh, zl; - -+#if defined(MBEDTLS_ARMV8CE_AES_C) -+ mbedtls_armv8ce_gcm_mult( output, x, (const unsigned char *) ctx->HL ); -+ return; -+#endif -+ - #if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) - if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) { - unsigned char h[16]; ---- a/library/Makefile -+++ b/library/Makefile -@@ -74,6 +74,7 @@ OBJS_CRYPTO= \ - aria.o \ - asn1parse.o \ - asn1write.o \ -+ armv8ce_aes.o \ - base64.o \ - bignum.o \ - blowfish.o \ ---- a/library/version_features.c -+++ b/library/version_features.c -@@ -624,6 +624,9 @@ static const char * const features[] = { - #if defined(MBEDTLS_AESNI_C) - "MBEDTLS_AESNI_C", - #endif /* MBEDTLS_AESNI_C */ -+#if defined(MBEDTLS_ARMV8CE_AES_C) -+ "MBEDTLS_ARMV8CE_AES_C", -+#endif /* MBEDTLS_ARMV8CE_AES_C */ - #if defined(MBEDTLS_AES_C) - "MBEDTLS_AES_C", - #endif /* MBEDTLS_AES_C */ diff --git a/package/libs/mbedtls/patches/100-fix-compile.patch b/package/libs/mbedtls/patches/100-fix-compile.patch index c3b26ac9c..411d37169 100644 --- a/package/libs/mbedtls/patches/100-fix-compile.patch +++ b/package/libs/mbedtls/patches/100-fix-compile.patch @@ -4,7 +4,7 @@ Bug report: https://github.com/Mbed-TLS/mbedtls/issues/6243 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c -@@ -2511,7 +2511,6 @@ int main( int argc, char *argv[] ) +@@ -2529,7 +2529,6 @@ int main( int argc, char *argv[] ) } key_cert_init2 = 2; #endif /* MBEDTLS_ECDSA_C */ @@ -12,11 +12,11 @@ Bug report: https://github.com/Mbed-TLS/mbedtls/issues/6243 #if defined(MBEDTLS_USE_PSA_CRYPTO) if( opt.key_opaque != 0 ) -@@ -2540,6 +2539,7 @@ int main( int argc, char *argv[] ) +@@ -2558,6 +2557,7 @@ int main( int argc, char *argv[] ) } #endif /* MBEDTLS_USE_PSA_CRYPTO */ #endif /* MBEDTLS_CERTS_C */ + } mbedtls_printf( " ok (key types: %s - %s)\n", mbedtls_pk_get_name( &pkey ), mbedtls_pk_get_name( &pkey2 ) ); - #endif /* MBEDTLS_X509_CRT_PARSE_C */ + #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ diff --git a/package/libs/mbedtls/patches/200-config.patch b/package/libs/mbedtls/patches/200-config.patch deleted file mode 100644 index 54d4cf431..000000000 --- a/package/libs/mbedtls/patches/200-config.patch +++ /dev/null @@ -1,228 +0,0 @@ ---- a/include/mbedtls/config.h -+++ b/include/mbedtls/config.h -@@ -670,14 +670,14 @@ - * - * Enable Output Feedback mode (OFB) for symmetric ciphers. - */ --#define MBEDTLS_CIPHER_MODE_OFB -+//#define MBEDTLS_CIPHER_MODE_OFB - - /** - * \def MBEDTLS_CIPHER_MODE_XTS - * - * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. - */ --#define MBEDTLS_CIPHER_MODE_XTS -+//#define MBEDTLS_CIPHER_MODE_XTS - - /** - * \def MBEDTLS_CIPHER_NULL_CIPHER -@@ -795,20 +795,20 @@ - * Comment macros to disable the curve and functions for it - */ - /* Short Weierstrass curves (supporting ECP, ECDH, ECDSA) */ --#define MBEDTLS_ECP_DP_SECP192R1_ENABLED --#define MBEDTLS_ECP_DP_SECP224R1_ENABLED -+//#define MBEDTLS_ECP_DP_SECP192R1_ENABLED -+//#define MBEDTLS_ECP_DP_SECP224R1_ENABLED - #define MBEDTLS_ECP_DP_SECP256R1_ENABLED - #define MBEDTLS_ECP_DP_SECP384R1_ENABLED --#define MBEDTLS_ECP_DP_SECP521R1_ENABLED --#define MBEDTLS_ECP_DP_SECP192K1_ENABLED --#define MBEDTLS_ECP_DP_SECP224K1_ENABLED -+//#define MBEDTLS_ECP_DP_SECP521R1_ENABLED -+//#define MBEDTLS_ECP_DP_SECP192K1_ENABLED -+//#define MBEDTLS_ECP_DP_SECP224K1_ENABLED - #define MBEDTLS_ECP_DP_SECP256K1_ENABLED --#define MBEDTLS_ECP_DP_BP256R1_ENABLED --#define MBEDTLS_ECP_DP_BP384R1_ENABLED --#define MBEDTLS_ECP_DP_BP512R1_ENABLED -+//#define MBEDTLS_ECP_DP_BP256R1_ENABLED -+//#define MBEDTLS_ECP_DP_BP384R1_ENABLED -+//#define MBEDTLS_ECP_DP_BP512R1_ENABLED - /* Montgomery curves (supporting ECP) */ - #define MBEDTLS_ECP_DP_CURVE25519_ENABLED --#define MBEDTLS_ECP_DP_CURVE448_ENABLED -+//#define MBEDTLS_ECP_DP_CURVE448_ENABLED - - /** - * \def MBEDTLS_ECP_NIST_OPTIM -@@ -961,7 +961,7 @@ - * See dhm.h for more details. - * - */ --#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED -+//#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED - - /** - * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -@@ -981,7 +981,7 @@ - * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA - */ --#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -+//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED - - /** - * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -@@ -1006,7 +1006,7 @@ - * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA - */ --#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -+//#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED - - /** - * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -@@ -1140,7 +1140,7 @@ - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 - */ --#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED -+//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED - - /** - * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -@@ -1164,7 +1164,7 @@ - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 - */ --#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -+//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED - - /** - * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED -@@ -1268,7 +1268,7 @@ - * This option is only useful if both MBEDTLS_SHA256_C and - * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. - */ --//#define MBEDTLS_ENTROPY_FORCE_SHA256 -+#define MBEDTLS_ENTROPY_FORCE_SHA256 - - /** - * \def MBEDTLS_ENTROPY_NV_SEED -@@ -1483,14 +1483,14 @@ - * Uncomment this macro to disable the use of CRT in RSA. - * - */ --//#define MBEDTLS_RSA_NO_CRT -+#define MBEDTLS_RSA_NO_CRT - - /** - * \def MBEDTLS_SELF_TEST - * - * Enable the checkup functions (*_self_test). - */ --#define MBEDTLS_SELF_TEST -+//#define MBEDTLS_SELF_TEST - - /** - * \def MBEDTLS_SHA256_SMALLER -@@ -1761,7 +1761,7 @@ - * configuration of this extension). - * - */ --#define MBEDTLS_SSL_RENEGOTIATION -+//#define MBEDTLS_SSL_RENEGOTIATION - - /** - * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO -@@ -2022,7 +2022,7 @@ - * - * Comment this macro to disable support for truncated HMAC in SSL - */ --#define MBEDTLS_SSL_TRUNCATED_HMAC -+//#define MBEDTLS_SSL_TRUNCATED_HMAC - - /** - * \def MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT -@@ -2201,7 +2201,7 @@ - * - * Comment this to disable run-time checking and save ROM space - */ --#define MBEDTLS_VERSION_FEATURES -+//#define MBEDTLS_VERSION_FEATURES - - /** - * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 -@@ -2550,7 +2550,7 @@ - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 - * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 - */ --#define MBEDTLS_CAMELLIA_C -+//#define MBEDTLS_CAMELLIA_C - - /** - * \def MBEDTLS_ARIA_C -@@ -2616,7 +2616,7 @@ - * This module enables the AES-CCM ciphersuites, if other requisites are - * enabled as well. - */ --#define MBEDTLS_CCM_C -+//#define MBEDTLS_CCM_C - - /** - * \def MBEDTLS_CERTS_C -@@ -2628,7 +2628,7 @@ - * - * This module is used for testing (ssl_client/server). - */ --#define MBEDTLS_CERTS_C -+//#define MBEDTLS_CERTS_C - - /** - * \def MBEDTLS_CHACHA20_C -@@ -2741,7 +2741,7 @@ - * \warning DES is considered a weak cipher and its use constitutes a - * security risk. We recommend considering stronger ciphers instead. - */ --#define MBEDTLS_DES_C -+//#define MBEDTLS_DES_C - - /** - * \def MBEDTLS_DHM_C -@@ -2906,7 +2906,7 @@ - * This module adds support for the Hashed Message Authentication Code - * (HMAC)-based key derivation function (HKDF). - */ --#define MBEDTLS_HKDF_C -+//#define MBEDTLS_HKDF_C - - /** - * \def MBEDTLS_HMAC_DRBG_C -@@ -3219,7 +3219,7 @@ - * - * This module enables abstraction of common (libc) functions. - */ --#define MBEDTLS_PLATFORM_C -+//#define MBEDTLS_PLATFORM_C - - /** - * \def MBEDTLS_POLY1305_C -@@ -3295,7 +3295,7 @@ - * Caller: library/md.c - * - */ --#define MBEDTLS_RIPEMD160_C -+//#define MBEDTLS_RIPEMD160_C - - /** - * \def MBEDTLS_RSA_C -@@ -3506,7 +3506,7 @@ - * - * This module provides run-time version information. - */ --#define MBEDTLS_VERSION_C -+//#define MBEDTLS_VERSION_C - - /** - * \def MBEDTLS_X509_USE_C -@@ -3616,7 +3616,7 @@ - * Module: library/xtea.c - * Caller: - */ --#define MBEDTLS_XTEA_C -+//#define MBEDTLS_XTEA_C - - /** \} name SECTION: mbed TLS modules */ - diff --git a/package/libs/musl-fts/Makefile b/package/libs/musl-fts/Makefile index 494f700f8..72341cd37 100644 --- a/package/libs/musl-fts/Makefile +++ b/package/libs/musl-fts/Makefile @@ -30,6 +30,7 @@ PKG_BUILD_PARALLEL:=1 PKG_INSTALL:=1 include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk define Package/musl-fts SECTION:=libs @@ -43,6 +44,7 @@ define Package/musl-fts/description The musl-fts package implements the fts(3) functions fts_open, fts_read, fts_children, fts_set and fts_close, which are missing in musl libc. endef +HOST_CONFIGURE_ARGS += --disable-shared --with-pic define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include @@ -58,3 +60,4 @@ define Package/musl-fts/install endef $(eval $(call BuildPackage,musl-fts)) +$(eval $(call HostBuild)) diff --git a/package/libs/ncurses/Makefile b/package/libs/ncurses/Makefile index b21dd2b0a..14f74082a 100644 --- a/package/libs/ncurses/Makefile +++ b/package/libs/ncurses/Makefile @@ -8,6 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ncurses +PKG_CPE_ID:=cpe:/a:gnu:ncurses PKG_VERSION:=6.3 PKG_RELEASE:=$(AUTORELEASE) diff --git a/package/libs/nettle/Makefile b/package/libs/nettle/Makefile index 3b4bd9d05..8825da4be 100644 --- a/package/libs/nettle/Makefile +++ b/package/libs/nettle/Makefile @@ -8,16 +8,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nettle -PKG_VERSION:=3.7.3 +PKG_VERSION:=3.8.1 PKG_RELEASE:=$(AUTORELEASE) PKG_USE_MIPS16:=0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/nettle -PKG_HASH:=661f5eb03f048a3b924c3a8ad2515d4068e40f67e774e8a26827658007e3bcf0 +PKG_HASH:=364f3e2b77cd7dcde83fd7c45219c834e54b0c75e428b6f894a23d12dd41cbfe PKG_LICENSE:=GPL-2.0-or-later PKG_LICENSE_FILES:=COPYING +PKG_CPE_ID:=cpe:/a:nettle_project:nettle PKG_BUILD_PARALLEL:=1 PKG_CONFIG_DEPENDS := CONFIG_LIBNETTLE_MINI @@ -44,7 +45,8 @@ CONFIGURE_ARGS += \ --enable-fat \ --disable-openssl \ --disable-documentation \ - --enable-static + --enable-static \ + $(if $(CONFIG_powerpc64), $(if $(CONFIG_USE_MUSL),--disable-assembler)) ifeq ($(CONFIG_LIBNETTLE_MINI),y) CONFIGURE_ARGS += --enable-mini-gmp diff --git a/package/libs/nettle/patches/100-portability.patch b/package/libs/nettle/patches/100-portability.patch index 5bbae2275..b4677ec02 100644 --- a/package/libs/nettle/patches/100-portability.patch +++ b/package/libs/nettle/patches/100-portability.patch @@ -1,6 +1,6 @@ --- a/configure +++ b/configure -@@ -4661,6 +4661,7 @@ $as_echo_n "checking build system compil +@@ -4704,6 +4704,7 @@ $as_echo_n "checking build system compil # remove anything that might look like compiler output to our "||" expression rm -f conftest* a.out b.out a.exe a_out.exe cat >conftest.c <conftest.c <conftest.c <conftest.c < -Date: Thu, 21 May 2020 11:58:38 +0200 -Subject: [PATCH 1/2] Enable legacy AES API to use AESNI or VPAES if available - -When no assembler support is available, we fall back -to either the constant time C implementation or the -non-constant time C code implementation. - -This is controlled by -DOPENSSL_AES_CONST_TIME. -So this makes the legacy API completely constant time, -if OPENSSL_AES_CONST_TIME is defined, otherwise it uses constant time -assembler implementations when available, and may fall back to the -non-constant time implementation. - -This works so far only for intel and aarch64 CPUs. - -[extended tests] ---- - crypto/aes/aes_core.c | 15 ++++++++ - crypto/evp/e_aes.c | 82 +++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 97 insertions(+) - -diff --git a/crypto/aes/aes_core.c b/crypto/aes/aes_core.c -index ad00c729e70..36e35dfdf49 100644 ---- a/crypto/aes/aes_core.c -+++ b/crypto/aes/aes_core.c -@@ -43,6 +43,21 @@ - #include - #include "aes_local.h" - -+#if defined(OPENSSL_CPUID_OBJ) && !defined(AES_ASM) -+int aes_set_encrypt_key(const unsigned char *userKey, const int bits, -+ AES_KEY *key); -+int aes_set_decrypt_key(const unsigned char *userKey, const int bits, -+ AES_KEY *key); -+void aes_encrypt(const unsigned char *in, unsigned char *out, -+ const AES_KEY *key); -+void aes_decrypt(const unsigned char *in, unsigned char *out, -+ const AES_KEY *key); -+# define AES_set_encrypt_key aes_set_encrypt_key -+# define AES_set_decrypt_key aes_set_decrypt_key -+# define AES_encrypt aes_encrypt -+# define AES_decrypt aes_decrypt -+#endif -+ - #if defined(OPENSSL_AES_CONST_TIME) && !defined(AES_ASM) - typedef union { - unsigned char b[8]; -diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c -index 405ddbf9bf0..8dbc947157d 100644 ---- a/crypto/evp/e_aes.c -+++ b/crypto/evp/e_aes.c -@@ -100,6 +100,21 @@ typedef struct { - - #define MAXBITCHUNK ((size_t)1<<(sizeof(size_t)*8-4)) - -+#if defined(OPENSSL_CPUID_OBJ) && !defined(AES_ASM) -+int aes_set_encrypt_key(const unsigned char *userKey, const int bits, -+ AES_KEY *key); -+int aes_set_decrypt_key(const unsigned char *userKey, const int bits, -+ AES_KEY *key); -+void aes_encrypt(const unsigned char *in, unsigned char *out, -+ const AES_KEY *key); -+void aes_decrypt(const unsigned char *in, unsigned char *out, -+ const AES_KEY *key); -+# define AES_set_encrypt_key aes_set_encrypt_key -+# define AES_set_dncrypt_key aes_set_decrypt_key -+# define AES_encrypt aes_encrypt -+# define AES_dncrypt aes_dncrypt -+#endif -+ - #ifdef VPAES_ASM - int vpaes_set_encrypt_key(const unsigned char *userKey, int bits, - AES_KEY *key); -@@ -4287,3 +4302,70 @@ BLOCK_CIPHER_custom(NID_aes, 192, 16, 12, ocb, OCB, - BLOCK_CIPHER_custom(NID_aes, 256, 16, 12, ocb, OCB, - EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS) - #endif /* OPENSSL_NO_OCB */ -+ -+#if defined(OPENSSL_CPUID_OBJ) && !defined(AES_ASM) -+# undef AES_set_encrypt_key -+# undef AES_set_decrypt_key -+# undef AES_encrypt -+# undef AES_decrypt -+ -+int AES_set_encrypt_key(const unsigned char *userKey, const int bits, -+ AES_KEY *key) -+{ -+# ifdef AESNI_CAPABLE -+ if (AESNI_CAPABLE) -+ return aesni_set_encrypt_key(userKey, bits, key); -+# endif -+# ifdef VPAES_CAPABLE -+ if (VPAES_CAPABLE) -+ return vpaes_set_encrypt_key(userKey, bits, key); -+# endif -+ return aes_set_encrypt_key(userKey, bits, key); -+} -+ -+int AES_set_decrypt_key(const unsigned char *userKey, const int bits, -+ AES_KEY *key) -+{ -+# ifdef AESNI_CAPABLE -+ if (AESNI_CAPABLE) -+ return aesni_set_decrypt_key(userKey, bits, key); -+# endif -+# ifdef VPAES_CAPABLE -+ if (VPAES_CAPABLE) -+ return vpaes_set_decrypt_key(userKey, bits, key); -+# endif -+ return aes_set_decrypt_key(userKey, bits, key); -+} -+ -+void AES_encrypt(const unsigned char *in, unsigned char *out, -+ const AES_KEY *key) -+{ -+# ifdef AESNI_CAPABLE -+ if (AESNI_CAPABLE) -+ aesni_encrypt(in, out, key); -+ else -+# endif -+# ifdef VPAES_CAPABLE -+ if (VPAES_CAPABLE) -+ vpaes_encrypt(in, out, key); -+ else -+# endif -+ aes_encrypt(in, out, key); -+} -+ -+void AES_decrypt(const unsigned char *in, unsigned char *out, -+ const AES_KEY *key) -+{ -+# ifdef AESNI_CAPABLE -+ if (AESNI_CAPABLE) -+ aesni_decrypt(in, out, key); -+ else -+# endif -+# ifdef VPAES_CAPABLE -+ if (VPAES_CAPABLE) -+ vpaes_decrypt(in, out, key); -+ else -+# endif -+ aes_decrypt(in, out, key); -+} -+#endif - -From 5de700ae03e0fdb8ca738f4c4912107437399d87 Mon Sep 17 00:00:00 2001 -From: Bernd Edlinger -Date: Sat, 23 May 2020 23:43:36 +0200 -Subject: [PATCH 2/2] Enable AES_cbc_encrypt to use AESNI or VPAES if available - -This makes the legacy API AES_cbc_encrypt outperform the EVP API. - -[extended tests] ---- - crypto/aes/aes_cbc.c | 7 +++++++ - crypto/evp/e_aes.c | 22 ++++++++++++++++++++++ - 2 files changed, 29 insertions(+) - -diff --git a/crypto/aes/aes_cbc.c b/crypto/aes/aes_cbc.c -index 342841fc4ff..c1195bd432b 100644 ---- a/crypto/aes/aes_cbc.c -+++ b/crypto/aes/aes_cbc.c -@@ -10,6 +10,13 @@ - #include - #include - -+#if defined(OPENSSL_CPUID_OBJ) && !defined(AES_ASM) -+void aes_cbc_encrypt(const unsigned char *in, unsigned char *out, -+ size_t len, const AES_KEY *key, -+ unsigned char *ivec, const int enc); -+# define AES_cbc_encrypt aes_cbc_encrypt -+#endif -+ - void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const AES_KEY *key, - unsigned char *ivec, const int enc) -diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c -index 8dbc947157d..954425e6552 100644 ---- a/crypto/evp/e_aes.c -+++ b/crypto/evp/e_aes.c -@@ -109,10 +109,14 @@ void aes_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); - void aes_decrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); -+void aes_cbc_encrypt(const unsigned char *in, unsigned char *out, -+ size_t len, const AES_KEY *key, -+ unsigned char *ivec, const int enc); - # define AES_set_encrypt_key aes_set_encrypt_key - # define AES_set_dncrypt_key aes_set_decrypt_key - # define AES_encrypt aes_encrypt - # define AES_dncrypt aes_dncrypt -+# define AES_cbc_encrypt aes_cbc_encrypt - #endif - - #ifdef VPAES_ASM -@@ -4308,6 +4312,7 @@ BLOCK_CIPHER_custom(NID_aes, 256, 16, 12, ocb, OCB, - # undef AES_set_decrypt_key - # undef AES_encrypt - # undef AES_decrypt -+# undef AES_cbc_encrypt - - int AES_set_encrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key) -@@ -4368,4 +4373,21 @@ void AES_decrypt(const unsigned char *in, unsigned char *out, - # endif - aes_decrypt(in, out, key); - } -+ -+void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, -+ size_t len, const AES_KEY *key, -+ unsigned char *ivec, const int enc) -+{ -+# ifdef AESNI_CAPABLE -+ if (AESNI_CAPABLE) -+ aesni_cbc_encrypt(in, out, len, key, ivec, enc); -+ else -+# endif -+# ifdef VPAES_CAPABLE -+ if (VPAES_CAPABLE) -+ vpaes_cbc_encrypt(in, out, len, key, ivec, enc); -+ else -+# endif -+ aes_cbc_encrypt(in, out, len, key, ivec, enc); -+} - #endif diff --git a/package/libs/openssl/patches/14578.patch b/package/libs/openssl/patches/14578.patch deleted file mode 100644 index 287da3701..000000000 --- a/package/libs/openssl/patches/14578.patch +++ /dev/null @@ -1,2382 +0,0 @@ -From 50118d3fff2e17187e698d4a083f14c43645b41c Mon Sep 17 00:00:00 2001 -From: Ben Avison -Date: Wed, 10 Mar 2021 15:54:44 +0000 -Subject: [PATCH] ARM assembly pack: translate bit-sliced AES implementation to - AArch64 - ---- - Configurations/00-base-templates.conf | 2 +- - crypto/aes/asm/bsaes-armv8.S | 2338 +++++++++++++++++++++++++ - crypto/aes/build.info | 1 + - 3 files changed, 2340 insertions(+), 1 deletion(-) - create mode 100644 crypto/aes/asm/bsaes-armv8.S - -diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf -index e01dc63a8bf..8e83e068125 100644 ---- a/Configurations/00-base-templates.conf -+++ b/Configurations/00-base-templates.conf -@@ -315,7 +315,7 @@ my %targets=( - cpuid_asm_src => "armcap.c arm64cpuid.S", - ec_asm_src => "ecp_nistz256.c ecp_nistz256-armv8.S", - bn_asm_src => "bn_asm.c armv8-mont.S", -- aes_asm_src => "aes_core.c aes_cbc.c aesv8-armx.S vpaes-armv8.S", -+ aes_asm_src => "aes_core.c aes_cbc.c bsaes-armv8.S aesv8-armx.S vpaes-armv8.S", - sha1_asm_src => "sha1-armv8.S sha256-armv8.S sha512-armv8.S", - modes_asm_src => "ghashv8-armx.S", - chacha_asm_src => "chacha-armv8.S", -diff --git a/crypto/aes/asm/bsaes-armv8.S b/crypto/aes/asm/bsaes-armv8.S -new file mode 100644 -index 00000000000..9bd02d0c8a9 ---- /dev/null -+++ b/crypto/aes/asm/bsaes-armv8.S -@@ -0,0 +1,2338 @@ -+// Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. -+// -+// Licensed under the OpenSSL license (the "License"). You may not use -+// this file except in compliance with the License. You can obtain a copy -+// in the file LICENSE in the source distribution or at -+// https://www.openssl.org/source/license.html -+// -+// ==================================================================== -+// Written by Ben Avison for the OpenSSL -+// project. Rights for redistribution and usage in source and binary -+// forms are granted according to the OpenSSL license. -+// ==================================================================== -+// -+// This implementation is a translation of bsaes-armv7 for AArch64. -+// No attempt has been made to carry across the build switches for -+// kernel targets, since the Linux kernel crypto support has moved on -+// from when it was based on OpenSSL. -+ -+// A lot of hand-scheduling has been performed. Consequently, this code -+// doesn't factor out neatly into macros in the same way that the -+// AArch32 version did, and there is little to be gained by wrapping it -+// up in Perl, and it is presented as pure assembly. -+ -+ -+#include "crypto/arm_arch.h" -+ -+.text -+ -+.type _bsaes_decrypt8,%function -+.align 4 -+// On entry: -+// x9 -> key (previously expanded using _bsaes_key_convert) -+// x10 = number of rounds -+// v0-v7 input data -+// On exit: -+// x9-x11 corrupted -+// other general-purpose registers preserved -+// v0-v7 output data -+// v11-v15 preserved -+// other SIMD registers corrupted -+_bsaes_decrypt8: -+ ldr q8, [x9], #16 -+ adr x11, .LM0ISR -+ movi v9.16b, #0x55 -+ ldr q10, [x11], #16 -+ movi v16.16b, #0x33 -+ movi v17.16b, #0x0f -+ sub x10, x10, #1 -+ eor v0.16b, v0.16b, v8.16b -+ eor v1.16b, v1.16b, v8.16b -+ eor v2.16b, v2.16b, v8.16b -+ eor v4.16b, v4.16b, v8.16b -+ eor v3.16b, v3.16b, v8.16b -+ eor v5.16b, v5.16b, v8.16b -+ tbl v0.16b, {v0.16b}, v10.16b -+ tbl v1.16b, {v1.16b}, v10.16b -+ tbl v2.16b, {v2.16b}, v10.16b -+ tbl v4.16b, {v4.16b}, v10.16b -+ eor v6.16b, v6.16b, v8.16b -+ eor v7.16b, v7.16b, v8.16b -+ tbl v3.16b, {v3.16b}, v10.16b -+ tbl v5.16b, {v5.16b}, v10.16b -+ tbl v6.16b, {v6.16b}, v10.16b -+ ushr v8.2d, v0.2d, #1 -+ tbl v7.16b, {v7.16b}, v10.16b -+ ushr v10.2d, v4.2d, #1 -+ ushr v18.2d, v2.2d, #1 -+ eor v8.16b, v8.16b, v1.16b -+ ushr v19.2d, v6.2d, #1 -+ eor v10.16b, v10.16b, v5.16b -+ eor v18.16b, v18.16b, v3.16b -+ and v8.16b, v8.16b, v9.16b -+ eor v19.16b, v19.16b, v7.16b -+ and v10.16b, v10.16b, v9.16b -+ and v18.16b, v18.16b, v9.16b -+ eor v1.16b, v1.16b, v8.16b -+ shl v8.2d, v8.2d, #1 -+ and v9.16b, v19.16b, v9.16b -+ eor v5.16b, v5.16b, v10.16b -+ shl v10.2d, v10.2d, #1 -+ eor v3.16b, v3.16b, v18.16b -+ shl v18.2d, v18.2d, #1 -+ eor v0.16b, v0.16b, v8.16b -+ shl v8.2d, v9.2d, #1 -+ eor v7.16b, v7.16b, v9.16b -+ eor v4.16b, v4.16b, v10.16b -+ eor v2.16b, v2.16b, v18.16b -+ ushr v9.2d, v1.2d, #2 -+ eor v6.16b, v6.16b, v8.16b -+ ushr v8.2d, v0.2d, #2 -+ ushr v10.2d, v5.2d, #2 -+ ushr v18.2d, v4.2d, #2 -+ eor v9.16b, v9.16b, v3.16b -+ eor v8.16b, v8.16b, v2.16b -+ eor v10.16b, v10.16b, v7.16b -+ eor v18.16b, v18.16b, v6.16b -+ and v9.16b, v9.16b, v16.16b -+ and v8.16b, v8.16b, v16.16b -+ and v10.16b, v10.16b, v16.16b -+ and v16.16b, v18.16b, v16.16b -+ eor v3.16b, v3.16b, v9.16b -+ shl v9.2d, v9.2d, #2 -+ eor v2.16b, v2.16b, v8.16b -+ shl v8.2d, v8.2d, #2 -+ eor v7.16b, v7.16b, v10.16b -+ shl v10.2d, v10.2d, #2 -+ eor v6.16b, v6.16b, v16.16b -+ shl v16.2d, v16.2d, #2 -+ eor v1.16b, v1.16b, v9.16b -+ eor v0.16b, v0.16b, v8.16b -+ eor v5.16b, v5.16b, v10.16b -+ eor v4.16b, v4.16b, v16.16b -+ ushr v8.2d, v3.2d, #4 -+ ushr v9.2d, v2.2d, #4 -+ ushr v10.2d, v1.2d, #4 -+ ushr v16.2d, v0.2d, #4 -+ eor v8.16b, v8.16b, v7.16b -+ eor v9.16b, v9.16b, v6.16b -+ eor v10.16b, v10.16b, v5.16b -+ eor v16.16b, v16.16b, v4.16b -+ and v8.16b, v8.16b, v17.16b -+ and v9.16b, v9.16b, v17.16b -+ and v10.16b, v10.16b, v17.16b -+ and v16.16b, v16.16b, v17.16b -+ eor v7.16b, v7.16b, v8.16b -+ shl v8.2d, v8.2d, #4 -+ eor v6.16b, v6.16b, v9.16b -+ shl v9.2d, v9.2d, #4 -+ eor v5.16b, v5.16b, v10.16b -+ shl v10.2d, v10.2d, #4 -+ eor v4.16b, v4.16b, v16.16b -+ shl v16.2d, v16.2d, #4 -+ eor v3.16b, v3.16b, v8.16b -+ eor v2.16b, v2.16b, v9.16b -+ eor v1.16b, v1.16b, v10.16b -+ eor v0.16b, v0.16b, v16.16b -+ b .Ldec_sbox -+.align 4 -+.Ldec_loop: -+ ld1 {v16.16b, v17.16b, v18.16b, v19.16b}, [x9], #64 -+ ldp q8, q9, [x9], #32 -+ eor v0.16b, v16.16b, v0.16b -+ ldr q10, [x9], #16 -+ eor v1.16b, v17.16b, v1.16b -+ ldr q16, [x9], #16 -+ eor v2.16b, v18.16b, v2.16b -+ eor v3.16b, v19.16b, v3.16b -+ eor v4.16b, v8.16b, v4.16b -+ eor v5.16b, v9.16b, v5.16b -+ eor v6.16b, v10.16b, v6.16b -+ eor v7.16b, v16.16b, v7.16b -+ tbl v0.16b, {v0.16b}, v28.16b -+ tbl v1.16b, {v1.16b}, v28.16b -+ tbl v2.16b, {v2.16b}, v28.16b -+ tbl v3.16b, {v3.16b}, v28.16b -+ tbl v4.16b, {v4.16b}, v28.16b -+ tbl v5.16b, {v5.16b}, v28.16b -+ tbl v6.16b, {v6.16b}, v28.16b -+ tbl v7.16b, {v7.16b}, v28.16b -+.Ldec_sbox: -+ eor v1.16b, v1.16b, v4.16b -+ eor v3.16b, v3.16b, v4.16b -+ subs x10, x10, #1 -+ eor v4.16b, v4.16b, v7.16b -+ eor v2.16b, v2.16b, v7.16b -+ eor v1.16b, v1.16b, v6.16b -+ eor v6.16b, v6.16b, v4.16b -+ eor v2.16b, v2.16b, v5.16b -+ eor v0.16b, v0.16b, v1.16b -+ eor v7.16b, v7.16b, v6.16b -+ eor v8.16b, v6.16b, v2.16b -+ and v9.16b, v4.16b, v6.16b -+ eor v10.16b, v2.16b, v6.16b -+ eor v3.16b, v3.16b, v0.16b -+ eor v5.16b, v5.16b, v0.16b -+ eor v16.16b, v7.16b, v4.16b -+ eor v17.16b, v4.16b, v0.16b -+ and v18.16b, v0.16b, v2.16b -+ eor v19.16b, v7.16b, v4.16b -+ eor v1.16b, v1.16b, v3.16b -+ eor v20.16b, v3.16b, v0.16b -+ eor v21.16b, v5.16b, v2.16b -+ eor v22.16b, v3.16b, v7.16b -+ and v8.16b, v17.16b, v8.16b -+ orr v17.16b, v3.16b, v5.16b -+ eor v23.16b, v1.16b, v6.16b -+ eor v24.16b, v20.16b, v16.16b -+ eor v25.16b, v1.16b, v5.16b -+ orr v26.16b, v20.16b, v21.16b -+ and v20.16b, v20.16b, v21.16b -+ and v27.16b, v7.16b, v1.16b -+ eor v21.16b, v21.16b, v23.16b -+ orr v28.16b, v16.16b, v23.16b -+ orr v29.16b, v22.16b, v25.16b -+ eor v26.16b, v26.16b, v8.16b -+ and v16.16b, v16.16b, v23.16b -+ and v22.16b, v22.16b, v25.16b -+ and v21.16b, v24.16b, v21.16b -+ eor v8.16b, v28.16b, v8.16b -+ eor v23.16b, v5.16b, v2.16b -+ eor v24.16b, v1.16b, v6.16b -+ eor v16.16b, v16.16b, v22.16b -+ eor v22.16b, v3.16b, v0.16b -+ eor v25.16b, v29.16b, v21.16b -+ eor v21.16b, v26.16b, v21.16b -+ eor v8.16b, v8.16b, v20.16b -+ eor v26.16b, v23.16b, v24.16b -+ eor v16.16b, v16.16b, v20.16b -+ eor v28.16b, v22.16b, v19.16b -+ eor v20.16b, v25.16b, v20.16b -+ eor v9.16b, v21.16b, v9.16b -+ eor v8.16b, v8.16b, v18.16b -+ eor v18.16b, v5.16b, v1.16b -+ eor v21.16b, v16.16b, v17.16b -+ eor v16.16b, v16.16b, v17.16b -+ eor v17.16b, v20.16b, v27.16b -+ eor v20.16b, v3.16b, v7.16b -+ eor v25.16b, v9.16b, v8.16b -+ eor v27.16b, v0.16b, v4.16b -+ and v29.16b, v9.16b, v17.16b -+ eor v30.16b, v8.16b, v29.16b -+ eor v31.16b, v21.16b, v29.16b -+ eor v29.16b, v21.16b, v29.16b -+ bsl v30.16b, v17.16b, v21.16b -+ bsl v31.16b, v9.16b, v8.16b -+ bsl v16.16b, v30.16b, v29.16b -+ bsl v21.16b, v29.16b, v30.16b -+ eor v8.16b, v31.16b, v30.16b -+ and v1.16b, v1.16b, v31.16b -+ and v9.16b, v16.16b, v31.16b -+ and v6.16b, v6.16b, v30.16b -+ eor v16.16b, v17.16b, v21.16b -+ and v4.16b, v4.16b, v30.16b -+ eor v17.16b, v8.16b, v30.16b -+ and v21.16b, v24.16b, v8.16b -+ eor v9.16b, v9.16b, v25.16b -+ and v19.16b, v19.16b, v8.16b -+ eor v24.16b, v30.16b, v16.16b -+ eor v25.16b, v30.16b, v16.16b -+ and v7.16b, v7.16b, v17.16b -+ and v10.16b, v10.16b, v16.16b -+ eor v29.16b, v9.16b, v16.16b -+ eor v30.16b, v31.16b, v9.16b -+ and v0.16b, v24.16b, v0.16b -+ and v9.16b, v18.16b, v9.16b -+ and v2.16b, v25.16b, v2.16b -+ eor v10.16b, v10.16b, v6.16b -+ eor v18.16b, v29.16b, v16.16b -+ and v5.16b, v30.16b, v5.16b -+ eor v24.16b, v8.16b, v29.16b -+ and v25.16b, v26.16b, v29.16b -+ and v26.16b, v28.16b, v29.16b -+ eor v8.16b, v8.16b, v29.16b -+ eor v17.16b, v17.16b, v18.16b -+ eor v5.16b, v1.16b, v5.16b -+ and v23.16b, v24.16b, v23.16b -+ eor v21.16b, v21.16b, v25.16b -+ eor v19.16b, v19.16b, v26.16b -+ eor v0.16b, v4.16b, v0.16b -+ and v3.16b, v17.16b, v3.16b -+ eor v1.16b, v9.16b, v1.16b -+ eor v9.16b, v25.16b, v23.16b -+ eor v5.16b, v5.16b, v21.16b -+ eor v2.16b, v6.16b, v2.16b -+ and v6.16b, v8.16b, v22.16b -+ eor v3.16b, v7.16b, v3.16b -+ and v8.16b, v20.16b, v18.16b -+ eor v10.16b, v10.16b, v9.16b -+ eor v0.16b, v0.16b, v19.16b -+ eor v9.16b, v1.16b, v9.16b -+ eor v1.16b, v2.16b, v21.16b -+ eor v3.16b, v3.16b, v19.16b -+ and v16.16b, v27.16b, v16.16b -+ eor v17.16b, v26.16b, v6.16b -+ eor v6.16b, v8.16b, v7.16b -+ eor v7.16b, v1.16b, v9.16b -+ eor v1.16b, v5.16b, v3.16b -+ eor v2.16b, v10.16b, v3.16b -+ eor v4.16b, v16.16b, v4.16b -+ eor v8.16b, v6.16b, v17.16b -+ eor v5.16b, v9.16b, v3.16b -+ eor v9.16b, v0.16b, v1.16b -+ eor v6.16b, v7.16b, v1.16b -+ eor v0.16b, v4.16b, v17.16b -+ eor v4.16b, v8.16b, v7.16b -+ eor v7.16b, v9.16b, v2.16b -+ eor v8.16b, v3.16b, v0.16b -+ eor v7.16b, v7.16b, v5.16b -+ eor v3.16b, v4.16b, v7.16b -+ eor v4.16b, v7.16b, v0.16b -+ eor v7.16b, v8.16b, v3.16b -+ bcc .Ldec_done -+ ext v8.16b, v0.16b, v0.16b, #8 -+ ext v9.16b, v1.16b, v1.16b, #8 -+ ldr q28, [x11] // load from .LISR in common case (x10 > 0) -+ ext v10.16b, v6.16b, v6.16b, #8 -+ ext v16.16b, v3.16b, v3.16b, #8 -+ ext v17.16b, v5.16b, v5.16b, #8 -+ ext v18.16b, v4.16b, v4.16b, #8 -+ eor v8.16b, v8.16b, v0.16b -+ eor v9.16b, v9.16b, v1.16b -+ eor v10.16b, v10.16b, v6.16b -+ eor v16.16b, v16.16b, v3.16b -+ eor v17.16b, v17.16b, v5.16b -+ ext v19.16b, v2.16b, v2.16b, #8 -+ ext v20.16b, v7.16b, v7.16b, #8 -+ eor v18.16b, v18.16b, v4.16b -+ eor v6.16b, v6.16b, v8.16b -+ eor v8.16b, v2.16b, v10.16b -+ eor v4.16b, v4.16b, v9.16b -+ eor v2.16b, v19.16b, v2.16b -+ eor v9.16b, v20.16b, v7.16b -+ eor v0.16b, v0.16b, v16.16b -+ eor v1.16b, v1.16b, v16.16b -+ eor v6.16b, v6.16b, v17.16b -+ eor v8.16b, v8.16b, v16.16b -+ eor v7.16b, v7.16b, v18.16b -+ eor v4.16b, v4.16b, v16.16b -+ eor v2.16b, v3.16b, v2.16b -+ eor v1.16b, v1.16b, v17.16b -+ eor v3.16b, v5.16b, v9.16b -+ eor v5.16b, v8.16b, v17.16b -+ eor v7.16b, v7.16b, v17.16b -+ ext v8.16b, v0.16b, v0.16b, #12 -+ ext v9.16b, v6.16b, v6.16b, #12 -+ ext v10.16b, v4.16b, v4.16b, #12 -+ ext v16.16b, v1.16b, v1.16b, #12 -+ ext v17.16b, v5.16b, v5.16b, #12 -+ ext v18.16b, v7.16b, v7.16b, #12 -+ eor v0.16b, v0.16b, v8.16b -+ eor v6.16b, v6.16b, v9.16b -+ eor v4.16b, v4.16b, v10.16b -+ ext v19.16b, v2.16b, v2.16b, #12 -+ ext v20.16b, v3.16b, v3.16b, #12 -+ eor v1.16b, v1.16b, v16.16b -+ eor v5.16b, v5.16b, v17.16b -+ eor v7.16b, v7.16b, v18.16b -+ eor v2.16b, v2.16b, v19.16b -+ eor v16.16b, v16.16b, v0.16b -+ eor v3.16b, v3.16b, v20.16b -+ eor v17.16b, v17.16b, v4.16b -+ eor v10.16b, v10.16b, v6.16b -+ ext v0.16b, v0.16b, v0.16b, #8 -+ eor v9.16b, v9.16b, v1.16b -+ ext v1.16b, v1.16b, v1.16b, #8 -+ eor v8.16b, v8.16b, v3.16b -+ eor v16.16b, v16.16b, v3.16b -+ eor v18.16b, v18.16b, v5.16b -+ eor v19.16b, v19.16b, v7.16b -+ ext v21.16b, v5.16b, v5.16b, #8 -+ ext v5.16b, v7.16b, v7.16b, #8 -+ eor v7.16b, v20.16b, v2.16b -+ ext v4.16b, v4.16b, v4.16b, #8 -+ ext v20.16b, v3.16b, v3.16b, #8 -+ eor v17.16b, v17.16b, v3.16b -+ ext v2.16b, v2.16b, v2.16b, #8 -+ eor v3.16b, v10.16b, v3.16b -+ ext v10.16b, v6.16b, v6.16b, #8 -+ eor v0.16b, v0.16b, v8.16b -+ eor v1.16b, v1.16b, v16.16b -+ eor v5.16b, v5.16b, v18.16b -+ eor v3.16b, v3.16b, v4.16b -+ eor v7.16b, v20.16b, v7.16b -+ eor v6.16b, v2.16b, v19.16b -+ eor v4.16b, v21.16b, v17.16b -+ eor v2.16b, v10.16b, v9.16b -+ bne .Ldec_loop -+ ldr q28, [x11, #16]! // load from .LISRM0 on last round (x10 == 0) -+ b .Ldec_loop -+.align 4 -+.Ldec_done: -+ ushr v8.2d, v0.2d, #1 -+ movi v9.16b, #0x55 -+ ldr q10, [x9] -+ ushr v16.2d, v2.2d, #1 -+ movi v17.16b, #0x33 -+ ushr v18.2d, v6.2d, #1 -+ movi v19.16b, #0x0f -+ eor v8.16b, v8.16b, v1.16b -+ ushr v20.2d, v3.2d, #1 -+ eor v16.16b, v16.16b, v7.16b -+ eor v18.16b, v18.16b, v4.16b -+ and v8.16b, v8.16b, v9.16b -+ eor v20.16b, v20.16b, v5.16b -+ and v16.16b, v16.16b, v9.16b -+ and v18.16b, v18.16b, v9.16b -+ shl v21.2d, v8.2d, #1 -+ eor v1.16b, v1.16b, v8.16b -+ and v8.16b, v20.16b, v9.16b -+ eor v7.16b, v7.16b, v16.16b -+ shl v9.2d, v16.2d, #1 -+ eor v4.16b, v4.16b, v18.16b -+ shl v16.2d, v18.2d, #1 -+ eor v0.16b, v0.16b, v21.16b -+ shl v18.2d, v8.2d, #1 -+ eor v5.16b, v5.16b, v8.16b -+ eor v2.16b, v2.16b, v9.16b -+ eor v6.16b, v6.16b, v16.16b -+ ushr v8.2d, v1.2d, #2 -+ eor v3.16b, v3.16b, v18.16b -+ ushr v9.2d, v0.2d, #2 -+ ushr v16.2d, v7.2d, #2 -+ ushr v18.2d, v2.2d, #2 -+ eor v8.16b, v8.16b, v4.16b -+ eor v9.16b, v9.16b, v6.16b -+ eor v16.16b, v16.16b, v5.16b -+ eor v18.16b, v18.16b, v3.16b -+ and v8.16b, v8.16b, v17.16b -+ and v9.16b, v9.16b, v17.16b -+ and v16.16b, v16.16b, v17.16b -+ and v17.16b, v18.16b, v17.16b -+ eor v4.16b, v4.16b, v8.16b -+ shl v8.2d, v8.2d, #2 -+ eor v6.16b, v6.16b, v9.16b -+ shl v9.2d, v9.2d, #2 -+ eor v5.16b, v5.16b, v16.16b -+ shl v16.2d, v16.2d, #2 -+ eor v3.16b, v3.16b, v17.16b -+ shl v17.2d, v17.2d, #2 -+ eor v1.16b, v1.16b, v8.16b -+ eor v0.16b, v0.16b, v9.16b -+ eor v7.16b, v7.16b, v16.16b -+ eor v2.16b, v2.16b, v17.16b -+ ushr v8.2d, v4.2d, #4 -+ ushr v9.2d, v6.2d, #4 -+ ushr v16.2d, v1.2d, #4 -+ ushr v17.2d, v0.2d, #4 -+ eor v8.16b, v8.16b, v5.16b -+ eor v9.16b, v9.16b, v3.16b -+ eor v16.16b, v16.16b, v7.16b -+ eor v17.16b, v17.16b, v2.16b -+ and v8.16b, v8.16b, v19.16b -+ and v9.16b, v9.16b, v19.16b -+ and v16.16b, v16.16b, v19.16b -+ and v17.16b, v17.16b, v19.16b -+ eor v5.16b, v5.16b, v8.16b -+ shl v8.2d, v8.2d, #4 -+ eor v3.16b, v3.16b, v9.16b -+ shl v9.2d, v9.2d, #4 -+ eor v7.16b, v7.16b, v16.16b -+ shl v16.2d, v16.2d, #4 -+ eor v2.16b, v2.16b, v17.16b -+ shl v17.2d, v17.2d, #4 -+ eor v4.16b, v4.16b, v8.16b -+ eor v6.16b, v6.16b, v9.16b -+ eor v7.16b, v7.16b, v10.16b -+ eor v1.16b, v1.16b, v16.16b -+ eor v2.16b, v2.16b, v10.16b -+ eor v0.16b, v0.16b, v17.16b -+ eor v4.16b, v4.16b, v10.16b -+ eor v6.16b, v6.16b, v10.16b -+ eor v3.16b, v3.16b, v10.16b -+ eor v5.16b, v5.16b, v10.16b -+ eor v1.16b, v1.16b, v10.16b -+ eor v0.16b, v0.16b, v10.16b -+ ret -+.size _bsaes_decrypt8,.-_bsaes_decrypt8 -+ -+.type _bsaes_const,%object -+.align 6 -+_bsaes_const: -+// InvShiftRows constants -+// Used in _bsaes_decrypt8, which assumes contiguity -+// .LM0ISR used with round 0 key -+// .LISR used with middle round keys -+// .LISRM0 used with final round key -+.LM0ISR: -+.quad 0x0a0e0206070b0f03, 0x0004080c0d010509 -+.LISR: -+.quad 0x0504070602010003, 0x0f0e0d0c080b0a09 -+.LISRM0: -+.quad 0x01040b0e0205080f, 0x0306090c00070a0d -+ -+// ShiftRows constants -+// Used in _bsaes_encrypt8, which assumes contiguity -+// .LM0SR used with round 0 key -+// .LSR used with middle round keys -+// .LSRM0 used with final round key -+.LM0SR: -+.quad 0x0a0e02060f03070b, 0x0004080c05090d01 -+.LSR: -+.quad 0x0504070600030201, 0x0f0e0d0c0a09080b -+.LSRM0: -+.quad 0x0304090e00050a0f, 0x01060b0c0207080d -+ -+.LM0_bigendian: -+.quad 0x02060a0e03070b0f, 0x0004080c0105090d -+.LM0_littleendian: -+.quad 0x0105090d0004080c, 0x03070b0f02060a0e -+ -+// Used in bsaes_ctr32_encrypt_blocks, prior to dropping into -+// _bsaes_encrypt8_alt, for round 0 key in place of .LM0SR -+.LREVM0SR: -+.quad 0x090d01050c000408, 0x03070b0f060a0e02 -+ -+.align 6 -+.size _bsaes_const,.-_bsaes_const -+ -+.type _bsaes_encrypt8,%function -+.align 4 -+// On entry: -+// x9 -> key (previously expanded using _bsaes_key_convert) -+// x10 = number of rounds -+// v0-v7 input data -+// On exit: -+// x9-x11 corrupted -+// other general-purpose registers preserved -+// v0-v7 output data -+// v11-v15 preserved -+// other SIMD registers corrupted -+_bsaes_encrypt8: -+ ldr q8, [x9], #16 -+ adr x11, .LM0SR -+ ldr q9, [x11], #16 -+_bsaes_encrypt8_alt: -+ eor v0.16b, v0.16b, v8.16b -+ eor v1.16b, v1.16b, v8.16b -+ sub x10, x10, #1 -+ eor v2.16b, v2.16b, v8.16b -+ eor v4.16b, v4.16b, v8.16b -+ eor v3.16b, v3.16b, v8.16b -+ eor v5.16b, v5.16b, v8.16b -+ tbl v0.16b, {v0.16b}, v9.16b -+ tbl v1.16b, {v1.16b}, v9.16b -+ tbl v2.16b, {v2.16b}, v9.16b -+ tbl v4.16b, {v4.16b}, v9.16b -+ eor v6.16b, v6.16b, v8.16b -+ eor v7.16b, v7.16b, v8.16b -+ tbl v3.16b, {v3.16b}, v9.16b -+ tbl v5.16b, {v5.16b}, v9.16b -+ tbl v6.16b, {v6.16b}, v9.16b -+ ushr v8.2d, v0.2d, #1 -+ movi v10.16b, #0x55 -+ tbl v7.16b, {v7.16b}, v9.16b -+ ushr v9.2d, v4.2d, #1 -+ movi v16.16b, #0x33 -+ ushr v17.2d, v2.2d, #1 -+ eor v8.16b, v8.16b, v1.16b -+ movi v18.16b, #0x0f -+ ushr v19.2d, v6.2d, #1 -+ eor v9.16b, v9.16b, v5.16b -+ eor v17.16b, v17.16b, v3.16b -+ and v8.16b, v8.16b, v10.16b -+ eor v19.16b, v19.16b, v7.16b -+ and v9.16b, v9.16b, v10.16b -+ and v17.16b, v17.16b, v10.16b -+ eor v1.16b, v1.16b, v8.16b -+ shl v8.2d, v8.2d, #1 -+ and v10.16b, v19.16b, v10.16b -+ eor v5.16b, v5.16b, v9.16b -+ shl v9.2d, v9.2d, #1 -+ eor v3.16b, v3.16b, v17.16b -+ shl v17.2d, v17.2d, #1 -+ eor v0.16b, v0.16b, v8.16b -+ shl v8.2d, v10.2d, #1 -+ eor v7.16b, v7.16b, v10.16b -+ eor v4.16b, v4.16b, v9.16b -+ eor v2.16b, v2.16b, v17.16b -+ ushr v9.2d, v1.2d, #2 -+ eor v6.16b, v6.16b, v8.16b -+ ushr v8.2d, v0.2d, #2 -+ ushr v10.2d, v5.2d, #2 -+ ushr v17.2d, v4.2d, #2 -+ eor v9.16b, v9.16b, v3.16b -+ eor v8.16b, v8.16b, v2.16b -+ eor v10.16b, v10.16b, v7.16b -+ eor v17.16b, v17.16b, v6.16b -+ and v9.16b, v9.16b, v16.16b -+ and v8.16b, v8.16b, v16.16b -+ and v10.16b, v10.16b, v16.16b -+ and v16.16b, v17.16b, v16.16b -+ eor v3.16b, v3.16b, v9.16b -+ shl v9.2d, v9.2d, #2 -+ eor v2.16b, v2.16b, v8.16b -+ shl v8.2d, v8.2d, #2 -+ eor v7.16b, v7.16b, v10.16b -+ shl v10.2d, v10.2d, #2 -+ eor v6.16b, v6.16b, v16.16b -+ shl v16.2d, v16.2d, #2 -+ eor v1.16b, v1.16b, v9.16b -+ eor v0.16b, v0.16b, v8.16b -+ eor v5.16b, v5.16b, v10.16b -+ eor v4.16b, v4.16b, v16.16b -+ ushr v8.2d, v3.2d, #4 -+ ushr v9.2d, v2.2d, #4 -+ ushr v10.2d, v1.2d, #4 -+ ushr v16.2d, v0.2d, #4 -+ eor v8.16b, v8.16b, v7.16b -+ eor v9.16b, v9.16b, v6.16b -+ eor v10.16b, v10.16b, v5.16b -+ eor v16.16b, v16.16b, v4.16b -+ and v8.16b, v8.16b, v18.16b -+ and v9.16b, v9.16b, v18.16b -+ and v10.16b, v10.16b, v18.16b -+ and v16.16b, v16.16b, v18.16b -+ eor v7.16b, v7.16b, v8.16b -+ shl v8.2d, v8.2d, #4 -+ eor v6.16b, v6.16b, v9.16b -+ shl v9.2d, v9.2d, #4 -+ eor v5.16b, v5.16b, v10.16b -+ shl v10.2d, v10.2d, #4 -+ eor v4.16b, v4.16b, v16.16b -+ shl v16.2d, v16.2d, #4 -+ eor v3.16b, v3.16b, v8.16b -+ eor v2.16b, v2.16b, v9.16b -+ eor v1.16b, v1.16b, v10.16b -+ eor v0.16b, v0.16b, v16.16b -+ b .Lenc_sbox -+.align 4 -+.Lenc_loop: -+ ld1 {v16.16b, v17.16b, v18.16b, v19.16b}, [x9], #64 -+ ldp q8, q9, [x9], #32 -+ eor v0.16b, v16.16b, v0.16b -+ ldr q10, [x9], #16 -+ eor v1.16b, v17.16b, v1.16b -+ ldr q16, [x9], #16 -+ eor v2.16b, v18.16b, v2.16b -+ eor v3.16b, v19.16b, v3.16b -+ eor v4.16b, v8.16b, v4.16b -+ eor v5.16b, v9.16b, v5.16b -+ eor v6.16b, v10.16b, v6.16b -+ eor v7.16b, v16.16b, v7.16b -+ tbl v0.16b, {v0.16b}, v28.16b -+ tbl v1.16b, {v1.16b}, v28.16b -+ tbl v2.16b, {v2.16b}, v28.16b -+ tbl v3.16b, {v3.16b}, v28.16b -+ tbl v4.16b, {v4.16b}, v28.16b -+ tbl v5.16b, {v5.16b}, v28.16b -+ tbl v6.16b, {v6.16b}, v28.16b -+ tbl v7.16b, {v7.16b}, v28.16b -+.Lenc_sbox: -+ eor v5.16b, v5.16b, v6.16b -+ eor v3.16b, v3.16b, v0.16b -+ subs x10, x10, #1 -+ eor v2.16b, v2.16b, v1.16b -+ eor v5.16b, v5.16b, v0.16b -+ eor v8.16b, v3.16b, v7.16b -+ eor v6.16b, v6.16b, v2.16b -+ eor v7.16b, v7.16b, v5.16b -+ eor v8.16b, v8.16b, v4.16b -+ eor v3.16b, v6.16b, v3.16b -+ eor v4.16b, v4.16b, v5.16b -+ eor v6.16b, v1.16b, v5.16b -+ eor v2.16b, v2.16b, v7.16b -+ eor v1.16b, v8.16b, v1.16b -+ eor v8.16b, v7.16b, v4.16b -+ eor v9.16b, v3.16b, v0.16b -+ eor v10.16b, v7.16b, v6.16b -+ eor v16.16b, v5.16b, v3.16b -+ eor v17.16b, v6.16b, v2.16b -+ eor v18.16b, v5.16b, v1.16b -+ eor v19.16b, v2.16b, v4.16b -+ eor v20.16b, v1.16b, v0.16b -+ orr v21.16b, v8.16b, v9.16b -+ orr v22.16b, v10.16b, v16.16b -+ eor v23.16b, v8.16b, v17.16b -+ eor v24.16b, v9.16b, v18.16b -+ and v19.16b, v19.16b, v20.16b -+ orr v20.16b, v17.16b, v18.16b -+ and v8.16b, v8.16b, v9.16b -+ and v9.16b, v17.16b, v18.16b -+ and v17.16b, v23.16b, v24.16b -+ and v10.16b, v10.16b, v16.16b -+ eor v16.16b, v21.16b, v19.16b -+ eor v18.16b, v20.16b, v19.16b -+ and v19.16b, v2.16b, v1.16b -+ and v20.16b, v6.16b, v5.16b -+ eor v21.16b, v22.16b, v17.16b -+ eor v9.16b, v9.16b, v10.16b -+ eor v10.16b, v16.16b, v17.16b -+ eor v16.16b, v18.16b, v8.16b -+ and v17.16b, v4.16b, v0.16b -+ orr v18.16b, v7.16b, v3.16b -+ eor v21.16b, v21.16b, v8.16b -+ eor v8.16b, v9.16b, v8.16b -+ eor v9.16b, v10.16b, v19.16b -+ eor v10.16b, v3.16b, v0.16b -+ eor v16.16b, v16.16b, v17.16b -+ eor v17.16b, v5.16b, v1.16b -+ eor v19.16b, v21.16b, v20.16b -+ eor v20.16b, v8.16b, v18.16b -+ eor v8.16b, v8.16b, v18.16b -+ eor v18.16b, v7.16b, v4.16b -+ eor v21.16b, v9.16b, v16.16b -+ eor v22.16b, v6.16b, v2.16b -+ and v23.16b, v9.16b, v19.16b -+ eor v24.16b, v10.16b, v17.16b -+ eor v25.16b, v0.16b, v1.16b -+ eor v26.16b, v7.16b, v6.16b -+ eor v27.16b, v18.16b, v22.16b -+ eor v28.16b, v3.16b, v5.16b -+ eor v29.16b, v16.16b, v23.16b -+ eor v30.16b, v20.16b, v23.16b -+ eor v23.16b, v20.16b, v23.16b -+ eor v31.16b, v4.16b, v2.16b -+ bsl v29.16b, v19.16b, v20.16b -+ bsl v30.16b, v9.16b, v16.16b -+ bsl v8.16b, v29.16b, v23.16b -+ bsl v20.16b, v23.16b, v29.16b -+ eor v9.16b, v30.16b, v29.16b -+ and v5.16b, v5.16b, v30.16b -+ and v8.16b, v8.16b, v30.16b -+ and v1.16b, v1.16b, v29.16b -+ eor v16.16b, v19.16b, v20.16b -+ and v2.16b, v2.16b, v29.16b -+ eor v19.16b, v9.16b, v29.16b -+ and v17.16b, v17.16b, v9.16b -+ eor v8.16b, v8.16b, v21.16b -+ and v20.16b, v22.16b, v9.16b -+ eor v21.16b, v29.16b, v16.16b -+ eor v22.16b, v29.16b, v16.16b -+ and v23.16b, v25.16b, v16.16b -+ and v6.16b, v6.16b, v19.16b -+ eor v25.16b, v8.16b, v16.16b -+ eor v29.16b, v30.16b, v8.16b -+ and v4.16b, v21.16b, v4.16b -+ and v8.16b, v28.16b, v8.16b -+ and v0.16b, v22.16b, v0.16b -+ eor v21.16b, v23.16b, v1.16b -+ eor v22.16b, v9.16b, v25.16b -+ eor v9.16b, v9.16b, v25.16b -+ eor v23.16b, v25.16b, v16.16b -+ and v3.16b, v29.16b, v3.16b -+ and v24.16b, v24.16b, v25.16b -+ and v25.16b, v27.16b, v25.16b -+ and v10.16b, v22.16b, v10.16b -+ and v9.16b, v9.16b, v18.16b -+ eor v18.16b, v19.16b, v23.16b -+ and v19.16b, v26.16b, v23.16b -+ eor v3.16b, v5.16b, v3.16b -+ eor v17.16b, v17.16b, v24.16b -+ eor v10.16b, v24.16b, v10.16b -+ and v16.16b, v31.16b, v16.16b -+ eor v20.16b, v20.16b, v25.16b -+ eor v9.16b, v25.16b, v9.16b -+ eor v4.16b, v2.16b, v4.16b -+ and v7.16b, v18.16b, v7.16b -+ eor v18.16b, v19.16b, v6.16b -+ eor v5.16b, v8.16b, v5.16b -+ eor v0.16b, v1.16b, v0.16b -+ eor v1.16b, v21.16b, v10.16b -+ eor v8.16b, v3.16b, v17.16b -+ eor v2.16b, v16.16b, v2.16b -+ eor v3.16b, v6.16b, v7.16b -+ eor v6.16b, v18.16b, v9.16b -+ eor v4.16b, v4.16b, v20.16b -+ eor v10.16b, v5.16b, v10.16b -+ eor v0.16b, v0.16b, v17.16b -+ eor v9.16b, v2.16b, v9.16b -+ eor v3.16b, v3.16b, v20.16b -+ eor v7.16b, v6.16b, v1.16b -+ eor v5.16b, v8.16b, v4.16b -+ eor v6.16b, v10.16b, v1.16b -+ eor v2.16b, v4.16b, v0.16b -+ eor v4.16b, v3.16b, v10.16b -+ eor v9.16b, v9.16b, v7.16b -+ eor v3.16b, v0.16b, v5.16b -+ eor v0.16b, v1.16b, v4.16b -+ eor v1.16b, v4.16b, v8.16b -+ eor v4.16b, v9.16b, v5.16b -+ eor v6.16b, v6.16b, v3.16b -+ bcc .Lenc_done -+ ext v8.16b, v0.16b, v0.16b, #12 -+ ext v9.16b, v4.16b, v4.16b, #12 -+ ldr q28, [x11] -+ ext v10.16b, v6.16b, v6.16b, #12 -+ ext v16.16b, v1.16b, v1.16b, #12 -+ ext v17.16b, v3.16b, v3.16b, #12 -+ ext v18.16b, v7.16b, v7.16b, #12 -+ eor v0.16b, v0.16b, v8.16b -+ eor v4.16b, v4.16b, v9.16b -+ eor v6.16b, v6.16b, v10.16b -+ ext v19.16b, v2.16b, v2.16b, #12 -+ ext v20.16b, v5.16b, v5.16b, #12 -+ eor v1.16b, v1.16b, v16.16b -+ eor v3.16b, v3.16b, v17.16b -+ eor v7.16b, v7.16b, v18.16b -+ eor v2.16b, v2.16b, v19.16b -+ eor v16.16b, v16.16b, v0.16b -+ eor v5.16b, v5.16b, v20.16b -+ eor v17.16b, v17.16b, v6.16b -+ eor v10.16b, v10.16b, v4.16b -+ ext v0.16b, v0.16b, v0.16b, #8 -+ eor v9.16b, v9.16b, v1.16b -+ ext v1.16b, v1.16b, v1.16b, #8 -+ eor v8.16b, v8.16b, v5.16b -+ eor v16.16b, v16.16b, v5.16b -+ eor v18.16b, v18.16b, v3.16b -+ eor v19.16b, v19.16b, v7.16b -+ ext v3.16b, v3.16b, v3.16b, #8 -+ ext v7.16b, v7.16b, v7.16b, #8 -+ eor v20.16b, v20.16b, v2.16b -+ ext v6.16b, v6.16b, v6.16b, #8 -+ ext v21.16b, v5.16b, v5.16b, #8 -+ eor v17.16b, v17.16b, v5.16b -+ ext v2.16b, v2.16b, v2.16b, #8 -+ eor v10.16b, v10.16b, v5.16b -+ ext v22.16b, v4.16b, v4.16b, #8 -+ eor v0.16b, v0.16b, v8.16b -+ eor v1.16b, v1.16b, v16.16b -+ eor v5.16b, v7.16b, v18.16b -+ eor v4.16b, v3.16b, v17.16b -+ eor v3.16b, v6.16b, v10.16b -+ eor v7.16b, v21.16b, v20.16b -+ eor v6.16b, v2.16b, v19.16b -+ eor v2.16b, v22.16b, v9.16b -+ bne .Lenc_loop -+ ldr q28, [x11, #16]! // load from .LSRM0 on last round (x10 == 0) -+ b .Lenc_loop -+.align 4 -+.Lenc_done: -+ ushr v8.2d, v0.2d, #1 -+ movi v9.16b, #0x55 -+ ldr q10, [x9] -+ ushr v16.2d, v3.2d, #1 -+ movi v17.16b, #0x33 -+ ushr v18.2d, v4.2d, #1 -+ movi v19.16b, #0x0f -+ eor v8.16b, v8.16b, v1.16b -+ ushr v20.2d, v2.2d, #1 -+ eor v16.16b, v16.16b, v7.16b -+ eor v18.16b, v18.16b, v6.16b -+ and v8.16b, v8.16b, v9.16b -+ eor v20.16b, v20.16b, v5.16b -+ and v16.16b, v16.16b, v9.16b -+ and v18.16b, v18.16b, v9.16b -+ shl v21.2d, v8.2d, #1 -+ eor v1.16b, v1.16b, v8.16b -+ and v8.16b, v20.16b, v9.16b -+ eor v7.16b, v7.16b, v16.16b -+ shl v9.2d, v16.2d, #1 -+ eor v6.16b, v6.16b, v18.16b -+ shl v16.2d, v18.2d, #1 -+ eor v0.16b, v0.16b, v21.16b -+ shl v18.2d, v8.2d, #1 -+ eor v5.16b, v5.16b, v8.16b -+ eor v3.16b, v3.16b, v9.16b -+ eor v4.16b, v4.16b, v16.16b -+ ushr v8.2d, v1.2d, #2 -+ eor v2.16b, v2.16b, v18.16b -+ ushr v9.2d, v0.2d, #2 -+ ushr v16.2d, v7.2d, #2 -+ ushr v18.2d, v3.2d, #2 -+ eor v8.16b, v8.16b, v6.16b -+ eor v9.16b, v9.16b, v4.16b -+ eor v16.16b, v16.16b, v5.16b -+ eor v18.16b, v18.16b, v2.16b -+ and v8.16b, v8.16b, v17.16b -+ and v9.16b, v9.16b, v17.16b -+ and v16.16b, v16.16b, v17.16b -+ and v17.16b, v18.16b, v17.16b -+ eor v6.16b, v6.16b, v8.16b -+ shl v8.2d, v8.2d, #2 -+ eor v4.16b, v4.16b, v9.16b -+ shl v9.2d, v9.2d, #2 -+ eor v5.16b, v5.16b, v16.16b -+ shl v16.2d, v16.2d, #2 -+ eor v2.16b, v2.16b, v17.16b -+ shl v17.2d, v17.2d, #2 -+ eor v1.16b, v1.16b, v8.16b -+ eor v0.16b, v0.16b, v9.16b -+ eor v7.16b, v7.16b, v16.16b -+ eor v3.16b, v3.16b, v17.16b -+ ushr v8.2d, v6.2d, #4 -+ ushr v9.2d, v4.2d, #4 -+ ushr v16.2d, v1.2d, #4 -+ ushr v17.2d, v0.2d, #4 -+ eor v8.16b, v8.16b, v5.16b -+ eor v9.16b, v9.16b, v2.16b -+ eor v16.16b, v16.16b, v7.16b -+ eor v17.16b, v17.16b, v3.16b -+ and v8.16b, v8.16b, v19.16b -+ and v9.16b, v9.16b, v19.16b -+ and v16.16b, v16.16b, v19.16b -+ and v17.16b, v17.16b, v19.16b -+ eor v5.16b, v5.16b, v8.16b -+ shl v8.2d, v8.2d, #4 -+ eor v2.16b, v2.16b, v9.16b -+ shl v9.2d, v9.2d, #4 -+ eor v7.16b, v7.16b, v16.16b -+ shl v16.2d, v16.2d, #4 -+ eor v3.16b, v3.16b, v17.16b -+ shl v17.2d, v17.2d, #4 -+ eor v6.16b, v6.16b, v8.16b -+ eor v4.16b, v4.16b, v9.16b -+ eor v7.16b, v7.16b, v10.16b -+ eor v1.16b, v1.16b, v16.16b -+ eor v3.16b, v3.16b, v10.16b -+ eor v0.16b, v0.16b, v17.16b -+ eor v6.16b, v6.16b, v10.16b -+ eor v4.16b, v4.16b, v10.16b -+ eor v2.16b, v2.16b, v10.16b -+ eor v5.16b, v5.16b, v10.16b -+ eor v1.16b, v1.16b, v10.16b -+ eor v0.16b, v0.16b, v10.16b -+ ret -+.size _bsaes_encrypt8,.-_bsaes_encrypt8 -+ -+.type _bsaes_key_convert,%function -+.align 4 -+// On entry: -+// x9 -> input key (big-endian) -+// x10 = number of rounds -+// x17 -> output key (native endianness) -+// On exit: -+// x9, x10 corrupted -+// x11 -> .LM0_bigendian -+// x17 -> last quadword of output key -+// other general-purpose registers preserved -+// v2-v6 preserved -+// v7.16b[] = 0x63 -+// v8-v14 preserved -+// v15 = last round key (converted to native endianness) -+// other SIMD registers corrupted -+_bsaes_key_convert: -+#ifdef __ARMEL__ -+ adr x11, .LM0_littleendian -+#else -+ adr x11, .LM0_bigendian -+#endif -+ ldr q0, [x9], #16 // load round 0 key -+ ldr q1, [x11] // .LM0 -+ ldr q15, [x9], #16 // load round 1 key -+ -+ movi v7.16b, #0x63 // compose .L63 -+ movi v16.16b, #0x01 // bit masks -+ movi v17.16b, #0x02 -+ movi v18.16b, #0x04 -+ movi v19.16b, #0x08 -+ movi v20.16b, #0x10 -+ movi v21.16b, #0x20 -+ movi v22.16b, #0x40 -+ movi v23.16b, #0x80 -+ -+#ifdef __ARMEL__ -+ rev32 v0.16b, v0.16b -+#endif -+ sub x10, x10, #1 -+ str q0, [x17], #16 // save round 0 key -+ -+.align 4 -+.Lkey_loop: -+ tbl v0.16b, {v15.16b}, v1.16b -+ ldr q15, [x9], #16 // load next round key -+ -+ eor v0.16b, v0.16b, v7.16b -+ cmtst v24.16b, v0.16b, v16.16b -+ cmtst v25.16b, v0.16b, v17.16b -+ cmtst v26.16b, v0.16b, v18.16b -+ cmtst v27.16b, v0.16b, v19.16b -+ cmtst v28.16b, v0.16b, v20.16b -+ cmtst v29.16b, v0.16b, v21.16b -+ cmtst v30.16b, v0.16b, v22.16b -+ cmtst v31.16b, v0.16b, v23.16b -+ sub x10, x10, #1 -+ st1 {v24.16b-v27.16b}, [x17], #64 // write bit-sliced round key -+ st1 {v28.16b-v31.16b}, [x17], #64 -+ cbnz x10, .Lkey_loop -+ -+ // don't save last round key -+#ifdef __ARMEL__ -+ rev32 v15.16b, v15.16b -+ adr x11, .LM0_bigendian -+#endif -+ ret -+.size _bsaes_key_convert,.-_bsaes_key_convert -+ -+.globl bsaes_cbc_encrypt -+.type bsaes_cbc_encrypt,%function -+.align 4 -+// On entry: -+// x0 -> input ciphertext -+// x1 -> output plaintext -+// x2 = size of ciphertext and plaintext in bytes (assumed a multiple of 16) -+// x3 -> key -+// x4 -> 128-bit initialisation vector (or preceding 128-bit block of ciphertext if continuing after an earlier call) -+// w5 must be == 0 -+// On exit: -+// Output plaintext filled in -+// Initialisation vector overwritten with last quadword of ciphertext -+// No output registers, usual AAPCS64 register preservation -+bsaes_cbc_encrypt: -+ cmp x2, #128 -+ blo AES_cbc_encrypt -+ -+ // it is up to the caller to make sure we are called with enc == 0 -+ -+ stp fp, lr, [sp, #-48]! -+ stp d8, d9, [sp, #16] -+ stp d10, d15, [sp, #32] -+ lsr x2, x2, #4 // len in 16 byte blocks -+ -+ ldr w15, [x3, #240] // get # of rounds -+ mov x14, sp -+ -+ // allocate the key schedule on the stack -+ add x17, sp, #96 -+ sub x17, x17, x15, lsl #7 // 128 bytes per inner round key, less 96 bytes -+ -+ // populate the key schedule -+ mov x9, x3 // pass key -+ mov x10, x15 // pass # of rounds -+ mov sp, x17 // sp is sp -+ bl _bsaes_key_convert -+ ldr q6, [sp] -+ str q15, [x17] // save last round key -+ eor v6.16b, v6.16b, v7.16b // fix up round 0 key (by XORing with 0x63) -+ str q6, [sp] -+ -+ ldr q15, [x4] // load IV -+ b .Lcbc_dec_loop -+ -+.align 4 -+.Lcbc_dec_loop: -+ subs x2, x2, #0x8 -+ bmi .Lcbc_dec_loop_finish -+ -+ ldr q0, [x0], #16 // load input -+ mov x9, sp // pass the key -+ ldr q1, [x0], #16 -+ mov x10, x15 -+ ldr q2, [x0], #16 -+ ldr q3, [x0], #16 -+ ldr q4, [x0], #16 -+ ldr q5, [x0], #16 -+ ldr q6, [x0], #16 -+ ldr q7, [x0], #-7*16 -+ -+ bl _bsaes_decrypt8 -+ -+ ldr q16, [x0], #16 // reload input -+ eor v0.16b, v0.16b, v15.16b // ^= IV -+ eor v1.16b, v1.16b, v16.16b -+ str q0, [x1], #16 // write output -+ ldr q0, [x0], #16 -+ str q1, [x1], #16 -+ ldr q1, [x0], #16 -+ eor v1.16b, v4.16b, v1.16b -+ ldr q4, [x0], #16 -+ eor v2.16b, v2.16b, v4.16b -+ eor v0.16b, v6.16b, v0.16b -+ ldr q4, [x0], #16 -+ str q0, [x1], #16 -+ str q1, [x1], #16 -+ eor v0.16b, v7.16b, v4.16b -+ ldr q1, [x0], #16 -+ str q2, [x1], #16 -+ ldr q2, [x0], #16 -+ ldr q15, [x0], #16 -+ str q0, [x1], #16 -+ eor v0.16b, v5.16b, v2.16b -+ eor v1.16b, v3.16b, v1.16b -+ str q1, [x1], #16 -+ str q0, [x1], #16 -+ -+ b .Lcbc_dec_loop -+ -+.Lcbc_dec_loop_finish: -+ adds x2, x2, #8 -+ beq .Lcbc_dec_done -+ -+ ldr q0, [x0], #16 // load input -+ cmp x2, #2 -+ blo .Lcbc_dec_one -+ ldr q1, [x0], #16 -+ mov x9, sp // pass the key -+ mov x10, x15 -+ beq .Lcbc_dec_two -+ ldr q2, [x0], #16 -+ cmp x2, #4 -+ blo .Lcbc_dec_three -+ ldr q3, [x0], #16 -+ beq .Lcbc_dec_four -+ ldr q4, [x0], #16 -+ cmp x2, #6 -+ blo .Lcbc_dec_five -+ ldr q5, [x0], #16 -+ beq .Lcbc_dec_six -+ ldr q6, [x0], #-6*16 -+ -+ bl _bsaes_decrypt8 -+ -+ ldr q5, [x0], #16 // reload input -+ eor v0.16b, v0.16b, v15.16b // ^= IV -+ ldr q8, [x0], #16 -+ ldr q9, [x0], #16 -+ ldr q10, [x0], #16 -+ str q0, [x1], #16 // write output -+ ldr q0, [x0], #16 -+ eor v1.16b, v1.16b, v5.16b -+ ldr q5, [x0], #16 -+ eor v6.16b, v6.16b, v8.16b -+ ldr q15, [x0] -+ eor v4.16b, v4.16b, v9.16b -+ eor v2.16b, v2.16b, v10.16b -+ str q1, [x1], #16 -+ eor v0.16b, v7.16b, v0.16b -+ str q6, [x1], #16 -+ eor v1.16b, v3.16b, v5.16b -+ str q4, [x1], #16 -+ str q2, [x1], #16 -+ str q0, [x1], #16 -+ str q1, [x1] -+ b .Lcbc_dec_done -+.align 4 -+.Lcbc_dec_six: -+ sub x0, x0, #0x60 -+ bl _bsaes_decrypt8 -+ ldr q3, [x0], #16 // reload input -+ eor v0.16b, v0.16b, v15.16b // ^= IV -+ ldr q5, [x0], #16 -+ ldr q8, [x0], #16 -+ ldr q9, [x0], #16 -+ str q0, [x1], #16 // write output -+ ldr q0, [x0], #16 -+ eor v1.16b, v1.16b, v3.16b -+ ldr q15, [x0] -+ eor v3.16b, v6.16b, v5.16b -+ eor v4.16b, v4.16b, v8.16b -+ eor v2.16b, v2.16b, v9.16b -+ str q1, [x1], #16 -+ eor v0.16b, v7.16b, v0.16b -+ str q3, [x1], #16 -+ str q4, [x1], #16 -+ str q2, [x1], #16 -+ str q0, [x1] -+ b .Lcbc_dec_done -+.align 4 -+.Lcbc_dec_five: -+ sub x0, x0, #0x50 -+ bl _bsaes_decrypt8 -+ ldr q3, [x0], #16 // reload input -+ eor v0.16b, v0.16b, v15.16b // ^= IV -+ ldr q5, [x0], #16 -+ ldr q7, [x0], #16 -+ ldr q8, [x0], #16 -+ str q0, [x1], #16 // write output -+ ldr q15, [x0] -+ eor v0.16b, v1.16b, v3.16b -+ eor v1.16b, v6.16b, v5.16b -+ eor v3.16b, v4.16b, v7.16b -+ str q0, [x1], #16 -+ eor v0.16b, v2.16b, v8.16b -+ str q1, [x1], #16 -+ str q3, [x1], #16 -+ str q0, [x1] -+ b .Lcbc_dec_done -+.align 4 -+.Lcbc_dec_four: -+ sub x0, x0, #0x40 -+ bl _bsaes_decrypt8 -+ ldr q2, [x0], #16 // reload input -+ eor v0.16b, v0.16b, v15.16b // ^= IV -+ ldr q3, [x0], #16 -+ ldr q5, [x0], #16 -+ str q0, [x1], #16 // write output -+ ldr q15, [x0] -+ eor v0.16b, v1.16b, v2.16b -+ eor v1.16b, v6.16b, v3.16b -+ eor v2.16b, v4.16b, v5.16b -+ str q0, [x1], #16 -+ str q1, [x1], #16 -+ str q2, [x1] -+ b .Lcbc_dec_done -+.align 4 -+.Lcbc_dec_three: -+ sub x0, x0, #0x30 -+ bl _bsaes_decrypt8 -+ ldr q2, [x0], #16 // reload input -+ eor v0.16b, v0.16b, v15.16b // ^= IV -+ ldr q3, [x0], #16 -+ ldr q15, [x0] -+ str q0, [x1], #16 // write output -+ eor v0.16b, v1.16b, v2.16b -+ eor v1.16b, v6.16b, v3.16b -+ str q0, [x1], #16 -+ str q1, [x1] -+ b .Lcbc_dec_done -+.align 4 -+.Lcbc_dec_two: -+ sub x0, x0, #0x20 -+ bl _bsaes_decrypt8 -+ ldr q2, [x0], #16 // reload input -+ eor v0.16b, v0.16b, v15.16b // ^= IV -+ ldr q15, [x0] -+ str q0, [x1], #16 // write output -+ eor v0.16b, v1.16b, v2.16b -+ str q0, [x1] -+ b .Lcbc_dec_done -+.align 4 -+.Lcbc_dec_one: -+ sub x0, x0, #0x10 -+ stp x1, x4, [sp, #-32]! -+ str x14, [sp, #16] -+ mov v8.16b, v15.16b -+ mov v15.16b, v0.16b -+ mov x2, x3 -+ bl AES_decrypt -+ ldr x14, [sp, #16] -+ ldp x1, x4, [sp], #32 -+ ldr q0, [x1] // load result -+ eor v0.16b, v0.16b, v8.16b // ^= IV -+ str q0, [x1] // write output -+ -+.align 4 -+.Lcbc_dec_done: -+ movi v0.16b, #0 -+ movi v1.16b, #0 -+.Lcbc_dec_bzero:// wipe key schedule [if any] -+ stp q0, q1, [sp], #32 -+ cmp sp, x14 -+ bne .Lcbc_dec_bzero -+ str q15, [x4] // return IV -+ ldp d8, d9, [sp, #16] -+ ldp d10, d15, [sp, #32] -+ ldp fp, lr, [sp], #48 -+ ret -+.size bsaes_cbc_encrypt,.-bsaes_cbc_encrypt -+ -+.globl bsaes_ctr32_encrypt_blocks -+.type bsaes_ctr32_encrypt_blocks,%function -+.align 4 -+// On entry: -+// x0 -> input text (whole 16-byte blocks) -+// x1 -> output text (whole 16-byte blocks) -+// x2 = number of 16-byte blocks to encrypt/decrypt (> 0) -+// x3 -> key -+// x4 -> initial value of 128-bit counter (stored big-endian) which increments, modulo 2^32, for each block -+// On exit: -+// Output text filled in -+// No output registers, usual AAPCS64 register preservation -+bsaes_ctr32_encrypt_blocks: -+ -+ cmp x2, #8 // use plain AES for -+ blo .Lctr_enc_short // small sizes -+ -+ stp fp, lr, [sp, #-80]! -+ stp d8, d9, [sp, #16] -+ stp d10, d11, [sp, #32] -+ stp d12, d13, [sp, #48] -+ stp d14, d15, [sp, #64] -+ -+ ldr w15, [x3, #240] // get # of rounds -+ mov x14, sp -+ -+ // allocate the key schedule on the stack -+ add x17, sp, #96 -+ sub x17, x17, x15, lsl #7 // 128 bytes per inner round key, less 96 bytes -+ -+ // populate the key schedule -+ mov x9, x3 // pass key -+ mov x10, x15 // pass # of rounds -+ mov sp, x17 // sp is sp -+ bl _bsaes_key_convert -+ eor v7.16b, v7.16b, v15.16b // fix up last round key -+ str q7, [x17] // save last round key -+ -+ ldr q0, [x4] // load counter -+ add x13, x11, #.LREVM0SR-.LM0_bigendian -+ ldr q4, [sp] // load round0 key -+ -+ movi v8.4s, #1 // compose 1<<96 -+ movi v9.16b, #0 -+ rev32 v15.16b, v0.16b -+ rev32 v0.16b, v0.16b -+ ext v11.16b, v9.16b, v8.16b, #4 -+ rev32 v4.16b, v4.16b -+ add v12.4s, v11.4s, v11.4s // compose 2<<96 -+ str q4, [sp] // save adjusted round0 key -+ add v13.4s, v11.4s, v12.4s // compose 3<<96 -+ add v14.4s, v12.4s, v12.4s // compose 4<<96 -+ b .Lctr_enc_loop -+ -+.align 4 -+.Lctr_enc_loop: -+ // Intermix prologue from _bsaes_encrypt8 to use the opportunity -+ // to flip byte order in 32-bit counter -+ -+ add v1.4s, v15.4s, v11.4s // +1 -+ add x9, sp, #0x10 // pass next round key -+ add v2.4s, v15.4s, v12.4s // +2 -+ ldr q9, [x13] // .LREVM0SR -+ ldr q8, [sp] // load round0 key -+ add v3.4s, v15.4s, v13.4s // +3 -+ mov x10, x15 // pass rounds -+ sub x11, x13, #.LREVM0SR-.LSR // pass constants -+ add v6.4s, v2.4s, v14.4s -+ add v4.4s, v15.4s, v14.4s // +4 -+ add v7.4s, v3.4s, v14.4s -+ add v15.4s, v4.4s, v14.4s // next counter -+ add v5.4s, v1.4s, v14.4s -+ -+ bl _bsaes_encrypt8_alt -+ -+ subs x2, x2, #8 -+ blo .Lctr_enc_loop_done -+ -+ ldr q16, [x0], #16 -+ ldr q17, [x0], #16 -+ eor v1.16b, v1.16b, v17.16b -+ ldr q17, [x0], #16 -+ eor v0.16b, v0.16b, v16.16b -+ eor v4.16b, v4.16b, v17.16b -+ str q0, [x1], #16 -+ ldr q16, [x0], #16 -+ str q1, [x1], #16 -+ mov v0.16b, v15.16b -+ str q4, [x1], #16 -+ ldr q1, [x0], #16 -+ eor v4.16b, v6.16b, v16.16b -+ eor v1.16b, v3.16b, v1.16b -+ ldr q3, [x0], #16 -+ eor v3.16b, v7.16b, v3.16b -+ ldr q6, [x0], #16 -+ eor v2.16b, v2.16b, v6.16b -+ ldr q6, [x0], #16 -+ eor v5.16b, v5.16b, v6.16b -+ str q4, [x1], #16 -+ str q1, [x1], #16 -+ str q3, [x1], #16 -+ str q2, [x1], #16 -+ str q5, [x1], #16 -+ -+ bne .Lctr_enc_loop -+ b .Lctr_enc_done -+ -+.align 4 -+.Lctr_enc_loop_done: -+ add x2, x2, #8 -+ ldr q16, [x0], #16 // load input -+ eor v0.16b, v0.16b, v16.16b -+ str q0, [x1], #16 // write output -+ cmp x2, #2 -+ blo .Lctr_enc_done -+ ldr q17, [x0], #16 -+ eor v1.16b, v1.16b, v17.16b -+ str q1, [x1], #16 -+ beq .Lctr_enc_done -+ ldr q18, [x0], #16 -+ eor v4.16b, v4.16b, v18.16b -+ str q4, [x1], #16 -+ cmp x2, #4 -+ blo .Lctr_enc_done -+ ldr q19, [x0], #16 -+ eor v6.16b, v6.16b, v19.16b -+ str q6, [x1], #16 -+ beq .Lctr_enc_done -+ ldr q20, [x0], #16 -+ eor v3.16b, v3.16b, v20.16b -+ str q3, [x1], #16 -+ cmp x2, #6 -+ blo .Lctr_enc_done -+ ldr q21, [x0], #16 -+ eor v7.16b, v7.16b, v21.16b -+ str q7, [x1], #16 -+ beq .Lctr_enc_done -+ ldr q22, [x0] -+ eor v2.16b, v2.16b, v22.16b -+ str q2, [x1], #16 -+ -+.Lctr_enc_done: -+ movi v0.16b, #0 -+ movi v1.16b, #0 -+.Lctr_enc_bzero: // wipe key schedule [if any] -+ stp q0, q1, [sp], #32 -+ cmp sp, x14 -+ bne .Lctr_enc_bzero -+ -+ ldp d8, d9, [sp, #16] -+ ldp d10, d11, [sp, #32] -+ ldp d12, d13, [sp, #48] -+ ldp d14, d15, [sp, #64] -+ ldp fp, lr, [sp], #80 -+ ret -+ -+.Lctr_enc_short: -+ stp fp, lr, [sp, #-96]! -+ stp x19, x20, [sp, #16] -+ stp x21, x22, [sp, #32] -+ str x23, [sp, #48] -+ -+ mov x19, x0 // copy arguments -+ mov x20, x1 -+ mov x21, x2 -+ mov x22, x3 -+ ldr w23, [x4, #12] // load counter .LSW -+ ldr q1, [x4] // load whole counter value -+#ifdef __ARMEL__ -+ rev w23, w23 -+#endif -+ str q1, [sp, #80] // copy counter value -+ -+.Lctr_enc_short_loop: -+ add x0, sp, #80 // input counter value -+ add x1, sp, #64 // output on the stack -+ mov x2, x22 // key -+ -+ bl AES_encrypt -+ -+ ldr q0, [x19], #16 // load input -+ ldr q1, [sp, #64] // load encrypted counter -+ add x23, x23, #1 -+#ifdef __ARMEL__ -+ rev w0, w23 -+ str w0, [sp, #80+12] // next counter value -+#else -+ str w23, [sp, #80+12] // next counter value -+#endif -+ eor v0.16b, v0.16b, v1.16b -+ str q0, [x20], #16 // store output -+ subs x21, x21, #1 -+ bne .Lctr_enc_short_loop -+ -+ movi v0.16b, #0 -+ movi v1.16b, #0 -+ stp q0, q1, [sp, #64] -+ -+ ldr x23, [sp, #48] -+ ldp x21, x22, [sp, #32] -+ ldp x19, x20, [sp, #16] -+ ldp fp, lr, [sp], #96 -+ ret -+.size bsaes_ctr32_encrypt_blocks,.-bsaes_ctr32_encrypt_blocks -+ -+.globl bsaes_xts_encrypt -+.type bsaes_xts_encrypt,%function -+.align 4 -+// On entry: -+// x0 -> input plaintext -+// x1 -> output ciphertext -+// x2 -> length of text in bytes (must be at least 16) -+// x3 -> key1 (used to encrypt the XORed plaintext blocks) -+// x4 -> key2 (used to encrypt the initial vector to yield the initial tweak) -+// x5 -> 16-byte initial vector (typically, sector number) -+// On exit: -+// Output ciphertext filled in -+// No output registers, usual AAPCS64 register preservation -+bsaes_xts_encrypt: -+ // Stack layout: -+ // sp -> -+ // nrounds*128-96 bytes: key schedule -+ // x19 -> -+ // 16 bytes: frame record -+ // 4*16 bytes: tweak storage across _bsaes_encrypt8 -+ // 6*8 bytes: storage for 5 callee-saved general-purpose registers -+ // 8*8 bytes: storage for 8 callee-saved SIMD registers -+ stp fp, lr, [sp, #-192]! -+ stp x19, x20, [sp, #80] -+ stp x21, x22, [sp, #96] -+ str x23, [sp, #112] -+ stp d8, d9, [sp, #128] -+ stp d10, d11, [sp, #144] -+ stp d12, d13, [sp, #160] -+ stp d14, d15, [sp, #176] -+ -+ mov x19, sp -+ mov x20, x0 -+ mov x21, x1 -+ mov x22, x2 -+ mov x23, x3 -+ -+ // generate initial tweak -+ sub sp, sp, #16 -+ mov x0, x5 // iv[] -+ mov x1, sp -+ mov x2, x4 // key2 -+ bl AES_encrypt -+ ldr q11, [sp], #16 -+ -+ ldr w1, [x23, #240] // get # of rounds -+ // allocate the key schedule on the stack -+ add x17, sp, #96 -+ sub x17, x17, x1, lsl #7 // 128 bytes per inner round key, less 96 bytes -+ -+ // populate the key schedule -+ mov x9, x23 // pass key -+ mov x10, x1 // pass # of rounds -+ mov sp, x17 -+ bl _bsaes_key_convert -+ eor v15.16b, v15.16b, v7.16b // fix up last round key -+ str q15, [x17] // save last round key -+ -+ subs x22, x22, #0x80 -+ blo .Lxts_enc_short -+ b .Lxts_enc_loop -+ -+.align 4 -+.Lxts_enc_loop: -+ ldr q8, .Lxts_magic -+ mov x10, x1 // pass rounds -+ add x2, x19, #16 -+ ldr q0, [x20], #16 -+ sshr v1.2d, v11.2d, #63 -+ mov x9, sp // pass key schedule -+ ldr q6, .Lxts_magic+16 -+ add v2.2d, v11.2d, v11.2d -+ cmtst v3.2d, v11.2d, v6.2d -+ and v1.16b, v1.16b, v8.16b -+ ext v1.16b, v1.16b, v1.16b, #8 -+ and v3.16b, v3.16b, v8.16b -+ ldr q4, [x20], #16 -+ eor v12.16b, v2.16b, v1.16b -+ eor v1.16b, v4.16b, v12.16b -+ eor v0.16b, v0.16b, v11.16b -+ cmtst v2.2d, v12.2d, v6.2d -+ add v4.2d, v12.2d, v12.2d -+ add x0, x19, #16 -+ ext v3.16b, v3.16b, v3.16b, #8 -+ and v2.16b, v2.16b, v8.16b -+ eor v13.16b, v4.16b, v3.16b -+ ldr q3, [x20], #16 -+ ext v4.16b, v2.16b, v2.16b, #8 -+ eor v2.16b, v3.16b, v13.16b -+ ldr q3, [x20], #16 -+ add v5.2d, v13.2d, v13.2d -+ cmtst v7.2d, v13.2d, v6.2d -+ and v7.16b, v7.16b, v8.16b -+ ldr q9, [x20], #16 -+ ext v7.16b, v7.16b, v7.16b, #8 -+ ldr q10, [x20], #16 -+ eor v14.16b, v5.16b, v4.16b -+ ldr q16, [x20], #16 -+ add v4.2d, v14.2d, v14.2d -+ eor v3.16b, v3.16b, v14.16b -+ eor v15.16b, v4.16b, v7.16b -+ add v5.2d, v15.2d, v15.2d -+ ldr q7, [x20], #16 -+ cmtst v4.2d, v14.2d, v6.2d -+ and v17.16b, v4.16b, v8.16b -+ cmtst v18.2d, v15.2d, v6.2d -+ eor v4.16b, v9.16b, v15.16b -+ ext v9.16b, v17.16b, v17.16b, #8 -+ eor v9.16b, v5.16b, v9.16b -+ add v17.2d, v9.2d, v9.2d -+ and v18.16b, v18.16b, v8.16b -+ eor v5.16b, v10.16b, v9.16b -+ str q9, [x2], #16 -+ ext v10.16b, v18.16b, v18.16b, #8 -+ cmtst v9.2d, v9.2d, v6.2d -+ and v9.16b, v9.16b, v8.16b -+ eor v10.16b, v17.16b, v10.16b -+ cmtst v17.2d, v10.2d, v6.2d -+ eor v6.16b, v16.16b, v10.16b -+ str q10, [x2], #16 -+ ext v9.16b, v9.16b, v9.16b, #8 -+ add v10.2d, v10.2d, v10.2d -+ eor v9.16b, v10.16b, v9.16b -+ str q9, [x2], #16 -+ eor v7.16b, v7.16b, v9.16b -+ add v9.2d, v9.2d, v9.2d -+ and v8.16b, v17.16b, v8.16b -+ ext v8.16b, v8.16b, v8.16b, #8 -+ eor v8.16b, v9.16b, v8.16b -+ str q8, [x2] // next round tweak -+ -+ bl _bsaes_encrypt8 -+ -+ ldr q8, [x0], #16 -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ ldr q9, [x0], #16 -+ eor v4.16b, v4.16b, v13.16b -+ eor v6.16b, v6.16b, v14.16b -+ ldr q10, [x0], #16 -+ eor v3.16b, v3.16b, v15.16b -+ subs x22, x22, #0x80 -+ str q0, [x21], #16 -+ ldr q11, [x0] // next round tweak -+ str q1, [x21], #16 -+ eor v0.16b, v7.16b, v8.16b -+ eor v1.16b, v2.16b, v9.16b -+ str q4, [x21], #16 -+ eor v2.16b, v5.16b, v10.16b -+ str q6, [x21], #16 -+ str q3, [x21], #16 -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ str q2, [x21], #16 -+ bpl .Lxts_enc_loop -+ -+.Lxts_enc_short: -+ adds x22, x22, #0x70 -+ bmi .Lxts_enc_done -+ -+ ldr q8, .Lxts_magic -+ sshr v1.2d, v11.2d, #63 -+ add v2.2d, v11.2d, v11.2d -+ ldr q9, .Lxts_magic+16 -+ subs x22, x22, #0x10 -+ ldr q0, [x20], #16 -+ and v1.16b, v1.16b, v8.16b -+ cmtst v3.2d, v11.2d, v9.2d -+ ext v1.16b, v1.16b, v1.16b, #8 -+ and v3.16b, v3.16b, v8.16b -+ eor v12.16b, v2.16b, v1.16b -+ ext v1.16b, v3.16b, v3.16b, #8 -+ add v2.2d, v12.2d, v12.2d -+ cmtst v3.2d, v12.2d, v9.2d -+ eor v13.16b, v2.16b, v1.16b -+ and v22.16b, v3.16b, v8.16b -+ bmi .Lxts_enc_1 -+ -+ ext v2.16b, v22.16b, v22.16b, #8 -+ add v3.2d, v13.2d, v13.2d -+ ldr q1, [x20], #16 -+ cmtst v4.2d, v13.2d, v9.2d -+ subs x22, x22, #0x10 -+ eor v14.16b, v3.16b, v2.16b -+ and v23.16b, v4.16b, v8.16b -+ bmi .Lxts_enc_2 -+ -+ ext v3.16b, v23.16b, v23.16b, #8 -+ add v4.2d, v14.2d, v14.2d -+ ldr q2, [x20], #16 -+ cmtst v5.2d, v14.2d, v9.2d -+ eor v0.16b, v0.16b, v11.16b -+ subs x22, x22, #0x10 -+ eor v15.16b, v4.16b, v3.16b -+ and v24.16b, v5.16b, v8.16b -+ bmi .Lxts_enc_3 -+ -+ ext v4.16b, v24.16b, v24.16b, #8 -+ add v5.2d, v15.2d, v15.2d -+ ldr q3, [x20], #16 -+ cmtst v6.2d, v15.2d, v9.2d -+ eor v1.16b, v1.16b, v12.16b -+ subs x22, x22, #0x10 -+ eor v16.16b, v5.16b, v4.16b -+ and v25.16b, v6.16b, v8.16b -+ bmi .Lxts_enc_4 -+ -+ ext v5.16b, v25.16b, v25.16b, #8 -+ add v6.2d, v16.2d, v16.2d -+ add x0, x19, #16 -+ cmtst v7.2d, v16.2d, v9.2d -+ ldr q4, [x20], #16 -+ eor v2.16b, v2.16b, v13.16b -+ str q16, [x0], #16 -+ subs x22, x22, #0x10 -+ eor v17.16b, v6.16b, v5.16b -+ and v26.16b, v7.16b, v8.16b -+ bmi .Lxts_enc_5 -+ -+ ext v7.16b, v26.16b, v26.16b, #8 -+ add v18.2d, v17.2d, v17.2d -+ ldr q5, [x20], #16 -+ eor v3.16b, v3.16b, v14.16b -+ str q17, [x0], #16 -+ subs x22, x22, #0x10 -+ eor v18.16b, v18.16b, v7.16b -+ bmi .Lxts_enc_6 -+ -+ ldr q6, [x20], #16 -+ eor v4.16b, v4.16b, v15.16b -+ eor v5.16b, v5.16b, v16.16b -+ str q18, [x0] // next round tweak -+ mov x9, sp // pass key schedule -+ mov x10, x1 -+ add x0, x19, #16 -+ sub x22, x22, #0x10 -+ eor v6.16b, v6.16b, v17.16b -+ -+ bl _bsaes_encrypt8 -+ -+ ldr q16, [x0], #16 -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ ldr q17, [x0], #16 -+ eor v4.16b, v4.16b, v13.16b -+ eor v6.16b, v6.16b, v14.16b -+ eor v3.16b, v3.16b, v15.16b -+ ldr q11, [x0] // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ eor v0.16b, v7.16b, v16.16b -+ eor v1.16b, v2.16b, v17.16b -+ str q4, [x21], #16 -+ str q6, [x21], #16 -+ str q3, [x21], #16 -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ b .Lxts_enc_done -+ -+.align 4 -+.Lxts_enc_6: -+ eor v4.16b, v4.16b, v15.16b -+ eor v5.16b, v5.16b, v16.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_encrypt8 -+ -+ ldr q16, [x0], #16 -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ eor v4.16b, v4.16b, v13.16b -+ eor v6.16b, v6.16b, v14.16b -+ ldr q11, [x0] // next round tweak -+ eor v3.16b, v3.16b, v15.16b -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ eor v0.16b, v7.16b, v16.16b -+ str q4, [x21], #16 -+ str q6, [x21], #16 -+ str q3, [x21], #16 -+ str q0, [x21], #16 -+ b .Lxts_enc_done -+ -+.align 4 -+.Lxts_enc_5: -+ eor v3.16b, v3.16b, v14.16b -+ eor v4.16b, v4.16b, v15.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_encrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ ldr q11, [x0] // next round tweak -+ eor v4.16b, v4.16b, v13.16b -+ eor v6.16b, v6.16b, v14.16b -+ eor v3.16b, v3.16b, v15.16b -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ str q4, [x21], #16 -+ str q6, [x21], #16 -+ str q3, [x21], #16 -+ b .Lxts_enc_done -+ -+.align 4 -+.Lxts_enc_4: -+ eor v2.16b, v2.16b, v13.16b -+ eor v3.16b, v3.16b, v14.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_encrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ eor v4.16b, v4.16b, v13.16b -+ eor v6.16b, v6.16b, v14.16b -+ mov v11.16b, v15.16b // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ str q4, [x21], #16 -+ str q6, [x21], #16 -+ b .Lxts_enc_done -+ -+.align 4 -+.Lxts_enc_3: -+ eor v1.16b, v1.16b, v12.16b -+ eor v2.16b, v2.16b, v13.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_encrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ eor v4.16b, v4.16b, v13.16b -+ mov v11.16b, v14.16b // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ str q4, [x21], #16 -+ b .Lxts_enc_done -+ -+.align 4 -+.Lxts_enc_2: -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_encrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ mov v11.16b, v13.16b // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ b .Lxts_enc_done -+ -+.align 4 -+.Lxts_enc_1: -+ eor v0.16b, v0.16b, v11.16b -+ sub x0, sp, #16 -+ sub x1, sp, #16 -+ mov x2, x23 -+ mov v13.d[0], v11.d[1] // just in case AES_encrypt corrupts top half of callee-saved SIMD registers -+ mov v14.d[0], v12.d[1] -+ str q0, [sp, #-16]! -+ -+ bl AES_encrypt -+ -+ ldr q0, [sp], #16 -+ trn1 v13.2d, v11.2d, v13.2d -+ trn1 v11.2d, v12.2d, v14.2d // next round tweak -+ eor v0.16b, v0.16b, v13.16b -+ str q0, [x21], #16 -+ -+.Lxts_enc_done: -+ adds x22, x22, #0x10 -+ beq .Lxts_enc_ret -+ -+ sub x6, x21, #0x10 -+ // Penultimate plaintext block produces final ciphertext part-block -+ // plus remaining part of final plaintext block. Move ciphertext part -+ // to final position and re-use penultimate ciphertext block buffer to -+ // construct final plaintext block -+.Lxts_enc_steal: -+ ldrb w0, [x20], #1 -+ ldrb w1, [x21, #-0x10] -+ strb w0, [x21, #-0x10] -+ strb w1, [x21], #1 -+ -+ subs x22, x22, #1 -+ bhi .Lxts_enc_steal -+ -+ // Finally encrypt the penultimate ciphertext block using the -+ // last tweak -+ ldr q0, [x6] -+ eor v0.16b, v0.16b, v11.16b -+ str q0, [sp, #-16]! -+ mov x0, sp -+ mov x1, sp -+ mov x2, x23 -+ mov x21, x6 -+ mov v13.d[0], v11.d[1] // just in case AES_encrypt corrupts top half of callee-saved SIMD registers -+ -+ bl AES_encrypt -+ -+ trn1 v11.2d, v11.2d, v13.2d -+ ldr q0, [sp], #16 -+ eor v0.16b, v0.16b, v11.16b -+ str q0, [x21] -+ -+.Lxts_enc_ret: -+ -+ movi v0.16b, #0 -+ movi v1.16b, #0 -+.Lxts_enc_bzero: // wipe key schedule -+ stp q0, q1, [sp], #32 -+ cmp sp, x19 -+ bne .Lxts_enc_bzero -+ -+ ldp x19, x20, [sp, #80] -+ ldp x21, x22, [sp, #96] -+ ldr x23, [sp, #112] -+ ldp d8, d9, [sp, #128] -+ ldp d10, d11, [sp, #144] -+ ldp d12, d13, [sp, #160] -+ ldp d14, d15, [sp, #176] -+ ldp fp, lr, [sp], #192 -+ ret -+.size bsaes_xts_encrypt,.-bsaes_xts_encrypt -+ -+// The assembler doesn't seem capable of de-duplicating these when expressed -+// using `ldr qd,=` syntax, so assign a symbolic address -+.align 5 -+.Lxts_magic: -+.quad 1, 0x87, 0x4000000000000000, 0x4000000000000000 -+ -+.globl bsaes_xts_decrypt -+.type bsaes_xts_decrypt,%function -+.align 4 -+// On entry: -+// x0 -> input ciphertext -+// x1 -> output plaintext -+// x2 -> length of text in bytes (must be at least 16) -+// x3 -> key1 (used to decrypt the XORed ciphertext blocks) -+// x4 -> key2 (used to encrypt the initial vector to yield the initial tweak) -+// x5 -> 16-byte initial vector (typically, sector number) -+// On exit: -+// Output plaintext filled in -+// No output registers, usual AAPCS64 register preservation -+bsaes_xts_decrypt: -+ // Stack layout: -+ // sp -> -+ // nrounds*128-96 bytes: key schedule -+ // x19 -> -+ // 16 bytes: frame record -+ // 4*16 bytes: tweak storage across _bsaes_decrypt8 -+ // 6*8 bytes: storage for 5 callee-saved general-purpose registers -+ // 8*8 bytes: storage for 8 callee-saved SIMD registers -+ stp fp, lr, [sp, #-192]! -+ stp x19, x20, [sp, #80] -+ stp x21, x22, [sp, #96] -+ str x23, [sp, #112] -+ stp d8, d9, [sp, #128] -+ stp d10, d11, [sp, #144] -+ stp d12, d13, [sp, #160] -+ stp d14, d15, [sp, #176] -+ -+ mov x19, sp -+ mov x20, x0 -+ mov x21, x1 -+ mov x22, x2 -+ mov x23, x3 -+ -+ // generate initial tweak -+ sub sp, sp, #16 -+ mov x0, x5 // iv[] -+ mov x1, sp -+ mov x2, x4 // key2 -+ bl AES_encrypt -+ ldr q11, [sp], #16 -+ -+ ldr w1, [x23, #240] // get # of rounds -+ // allocate the key schedule on the stack -+ add x17, sp, #96 -+ sub x17, x17, x1, lsl #7 // 128 bytes per inner round key, less 96 bytes -+ -+ // populate the key schedule -+ mov x9, x23 // pass key -+ mov x10, x1 // pass # of rounds -+ mov sp, x17 -+ bl _bsaes_key_convert -+ ldr q6, [sp] -+ str q15, [x17] // save last round key -+ eor v6.16b, v6.16b, v7.16b // fix up round 0 key (by XORing with 0x63) -+ str q6, [sp] -+ -+ sub x30, x22, #0x10 -+ tst x22, #0xf // if not multiple of 16 -+ csel x22, x30, x22, ne // subtract another 16 bytes -+ subs x22, x22, #0x80 -+ -+ blo .Lxts_dec_short -+ b .Lxts_dec_loop -+ -+.align 4 -+.Lxts_dec_loop: -+ ldr q8, .Lxts_magic -+ mov x10, x1 // pass rounds -+ add x2, x19, #16 -+ ldr q0, [x20], #16 -+ sshr v1.2d, v11.2d, #63 -+ mov x9, sp // pass key schedule -+ ldr q6, .Lxts_magic+16 -+ add v2.2d, v11.2d, v11.2d -+ cmtst v3.2d, v11.2d, v6.2d -+ and v1.16b, v1.16b, v8.16b -+ ext v1.16b, v1.16b, v1.16b, #8 -+ and v3.16b, v3.16b, v8.16b -+ ldr q4, [x20], #16 -+ eor v12.16b, v2.16b, v1.16b -+ eor v1.16b, v4.16b, v12.16b -+ eor v0.16b, v0.16b, v11.16b -+ cmtst v2.2d, v12.2d, v6.2d -+ add v4.2d, v12.2d, v12.2d -+ add x0, x19, #16 -+ ext v3.16b, v3.16b, v3.16b, #8 -+ and v2.16b, v2.16b, v8.16b -+ eor v13.16b, v4.16b, v3.16b -+ ldr q3, [x20], #16 -+ ext v4.16b, v2.16b, v2.16b, #8 -+ eor v2.16b, v3.16b, v13.16b -+ ldr q3, [x20], #16 -+ add v5.2d, v13.2d, v13.2d -+ cmtst v7.2d, v13.2d, v6.2d -+ and v7.16b, v7.16b, v8.16b -+ ldr q9, [x20], #16 -+ ext v7.16b, v7.16b, v7.16b, #8 -+ ldr q10, [x20], #16 -+ eor v14.16b, v5.16b, v4.16b -+ ldr q16, [x20], #16 -+ add v4.2d, v14.2d, v14.2d -+ eor v3.16b, v3.16b, v14.16b -+ eor v15.16b, v4.16b, v7.16b -+ add v5.2d, v15.2d, v15.2d -+ ldr q7, [x20], #16 -+ cmtst v4.2d, v14.2d, v6.2d -+ and v17.16b, v4.16b, v8.16b -+ cmtst v18.2d, v15.2d, v6.2d -+ eor v4.16b, v9.16b, v15.16b -+ ext v9.16b, v17.16b, v17.16b, #8 -+ eor v9.16b, v5.16b, v9.16b -+ add v17.2d, v9.2d, v9.2d -+ and v18.16b, v18.16b, v8.16b -+ eor v5.16b, v10.16b, v9.16b -+ str q9, [x2], #16 -+ ext v10.16b, v18.16b, v18.16b, #8 -+ cmtst v9.2d, v9.2d, v6.2d -+ and v9.16b, v9.16b, v8.16b -+ eor v10.16b, v17.16b, v10.16b -+ cmtst v17.2d, v10.2d, v6.2d -+ eor v6.16b, v16.16b, v10.16b -+ str q10, [x2], #16 -+ ext v9.16b, v9.16b, v9.16b, #8 -+ add v10.2d, v10.2d, v10.2d -+ eor v9.16b, v10.16b, v9.16b -+ str q9, [x2], #16 -+ eor v7.16b, v7.16b, v9.16b -+ add v9.2d, v9.2d, v9.2d -+ and v8.16b, v17.16b, v8.16b -+ ext v8.16b, v8.16b, v8.16b, #8 -+ eor v8.16b, v9.16b, v8.16b -+ str q8, [x2] // next round tweak -+ -+ bl _bsaes_decrypt8 -+ -+ eor v6.16b, v6.16b, v13.16b -+ eor v0.16b, v0.16b, v11.16b -+ ldr q8, [x0], #16 -+ eor v7.16b, v7.16b, v8.16b -+ str q0, [x21], #16 -+ eor v0.16b, v1.16b, v12.16b -+ ldr q1, [x0], #16 -+ eor v1.16b, v3.16b, v1.16b -+ subs x22, x22, #0x80 -+ eor v2.16b, v2.16b, v15.16b -+ eor v3.16b, v4.16b, v14.16b -+ ldr q4, [x0], #16 -+ str q0, [x21], #16 -+ ldr q11, [x0] // next round tweak -+ eor v0.16b, v5.16b, v4.16b -+ str q6, [x21], #16 -+ str q3, [x21], #16 -+ str q2, [x21], #16 -+ str q7, [x21], #16 -+ str q1, [x21], #16 -+ str q0, [x21], #16 -+ bpl .Lxts_dec_loop -+ -+.Lxts_dec_short: -+ adds x22, x22, #0x70 -+ bmi .Lxts_dec_done -+ -+ ldr q8, .Lxts_magic -+ sshr v1.2d, v11.2d, #63 -+ add v2.2d, v11.2d, v11.2d -+ ldr q9, .Lxts_magic+16 -+ subs x22, x22, #0x10 -+ ldr q0, [x20], #16 -+ and v1.16b, v1.16b, v8.16b -+ cmtst v3.2d, v11.2d, v9.2d -+ ext v1.16b, v1.16b, v1.16b, #8 -+ and v3.16b, v3.16b, v8.16b -+ eor v12.16b, v2.16b, v1.16b -+ ext v1.16b, v3.16b, v3.16b, #8 -+ add v2.2d, v12.2d, v12.2d -+ cmtst v3.2d, v12.2d, v9.2d -+ eor v13.16b, v2.16b, v1.16b -+ and v22.16b, v3.16b, v8.16b -+ bmi .Lxts_dec_1 -+ -+ ext v2.16b, v22.16b, v22.16b, #8 -+ add v3.2d, v13.2d, v13.2d -+ ldr q1, [x20], #16 -+ cmtst v4.2d, v13.2d, v9.2d -+ subs x22, x22, #0x10 -+ eor v14.16b, v3.16b, v2.16b -+ and v23.16b, v4.16b, v8.16b -+ bmi .Lxts_dec_2 -+ -+ ext v3.16b, v23.16b, v23.16b, #8 -+ add v4.2d, v14.2d, v14.2d -+ ldr q2, [x20], #16 -+ cmtst v5.2d, v14.2d, v9.2d -+ eor v0.16b, v0.16b, v11.16b -+ subs x22, x22, #0x10 -+ eor v15.16b, v4.16b, v3.16b -+ and v24.16b, v5.16b, v8.16b -+ bmi .Lxts_dec_3 -+ -+ ext v4.16b, v24.16b, v24.16b, #8 -+ add v5.2d, v15.2d, v15.2d -+ ldr q3, [x20], #16 -+ cmtst v6.2d, v15.2d, v9.2d -+ eor v1.16b, v1.16b, v12.16b -+ subs x22, x22, #0x10 -+ eor v16.16b, v5.16b, v4.16b -+ and v25.16b, v6.16b, v8.16b -+ bmi .Lxts_dec_4 -+ -+ ext v5.16b, v25.16b, v25.16b, #8 -+ add v6.2d, v16.2d, v16.2d -+ add x0, x19, #16 -+ cmtst v7.2d, v16.2d, v9.2d -+ ldr q4, [x20], #16 -+ eor v2.16b, v2.16b, v13.16b -+ str q16, [x0], #16 -+ subs x22, x22, #0x10 -+ eor v17.16b, v6.16b, v5.16b -+ and v26.16b, v7.16b, v8.16b -+ bmi .Lxts_dec_5 -+ -+ ext v7.16b, v26.16b, v26.16b, #8 -+ add v18.2d, v17.2d, v17.2d -+ ldr q5, [x20], #16 -+ eor v3.16b, v3.16b, v14.16b -+ str q17, [x0], #16 -+ subs x22, x22, #0x10 -+ eor v18.16b, v18.16b, v7.16b -+ bmi .Lxts_dec_6 -+ -+ ldr q6, [x20], #16 -+ eor v4.16b, v4.16b, v15.16b -+ eor v5.16b, v5.16b, v16.16b -+ str q18, [x0] // next round tweak -+ mov x9, sp // pass key schedule -+ mov x10, x1 -+ add x0, x19, #16 -+ sub x22, x22, #0x10 -+ eor v6.16b, v6.16b, v17.16b -+ -+ bl _bsaes_decrypt8 -+ -+ ldr q16, [x0], #16 -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ ldr q17, [x0], #16 -+ eor v6.16b, v6.16b, v13.16b -+ eor v4.16b, v4.16b, v14.16b -+ eor v2.16b, v2.16b, v15.16b -+ ldr q11, [x0] // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ eor v0.16b, v7.16b, v16.16b -+ eor v1.16b, v3.16b, v17.16b -+ str q6, [x21], #16 -+ str q4, [x21], #16 -+ str q2, [x21], #16 -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ b .Lxts_dec_done -+ -+.align 4 -+.Lxts_dec_6: -+ eor v4.16b, v4.16b, v15.16b -+ eor v5.16b, v5.16b, v16.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_decrypt8 -+ -+ ldr q16, [x0], #16 -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ eor v6.16b, v6.16b, v13.16b -+ eor v4.16b, v4.16b, v14.16b -+ ldr q11, [x0] // next round tweak -+ eor v2.16b, v2.16b, v15.16b -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ eor v0.16b, v7.16b, v16.16b -+ str q6, [x21], #16 -+ str q4, [x21], #16 -+ str q2, [x21], #16 -+ str q0, [x21], #16 -+ b .Lxts_dec_done -+ -+.align 4 -+.Lxts_dec_5: -+ eor v3.16b, v3.16b, v14.16b -+ eor v4.16b, v4.16b, v15.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_decrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ ldr q11, [x0] // next round tweak -+ eor v6.16b, v6.16b, v13.16b -+ eor v4.16b, v4.16b, v14.16b -+ eor v2.16b, v2.16b, v15.16b -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ str q6, [x21], #16 -+ str q4, [x21], #16 -+ str q2, [x21], #16 -+ b .Lxts_dec_done -+ -+.align 4 -+.Lxts_dec_4: -+ eor v2.16b, v2.16b, v13.16b -+ eor v3.16b, v3.16b, v14.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_decrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ eor v6.16b, v6.16b, v13.16b -+ eor v4.16b, v4.16b, v14.16b -+ mov v11.16b, v15.16b // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ str q6, [x21], #16 -+ str q4, [x21], #16 -+ b .Lxts_dec_done -+ -+.align 4 -+.Lxts_dec_3: -+ eor v1.16b, v1.16b, v12.16b -+ eor v2.16b, v2.16b, v13.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_decrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ eor v6.16b, v6.16b, v13.16b -+ mov v11.16b, v14.16b // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ str q6, [x21], #16 -+ b .Lxts_dec_done -+ -+.align 4 -+.Lxts_dec_2: -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ mov x9, sp // pass key schedule -+ mov x10, x1 // pass rounds -+ add x0, x19, #16 -+ -+ bl _bsaes_decrypt8 -+ -+ eor v0.16b, v0.16b, v11.16b -+ eor v1.16b, v1.16b, v12.16b -+ mov v11.16b, v13.16b // next round tweak -+ str q0, [x21], #16 -+ str q1, [x21], #16 -+ b .Lxts_dec_done -+ -+.align 4 -+.Lxts_dec_1: -+ eor v0.16b, v0.16b, v11.16b -+ sub x0, sp, #16 -+ sub x1, sp, #16 -+ mov x2, x23 -+ mov v13.d[0], v11.d[1] // just in case AES_decrypt corrupts top half of callee-saved SIMD registers -+ mov v14.d[0], v12.d[1] -+ str q0, [sp, #-16]! -+ -+ bl AES_decrypt -+ -+ ldr q0, [sp], #16 -+ trn1 v13.2d, v11.2d, v13.2d -+ trn1 v11.2d, v12.2d, v14.2d // next round tweak -+ eor v0.16b, v0.16b, v13.16b -+ str q0, [x21], #16 -+ -+.Lxts_dec_done: -+ adds x22, x22, #0x10 -+ beq .Lxts_dec_ret -+ -+ // calculate one round of extra tweak for the stolen ciphertext -+ ldr q8, .Lxts_magic -+ sshr v6.2d, v11.2d, #63 -+ and v6.16b, v6.16b, v8.16b -+ add v12.2d, v11.2d, v11.2d -+ ext v6.16b, v6.16b, v6.16b, #8 -+ eor v12.16b, v12.16b, v6.16b -+ -+ // perform the final decryption with the last tweak value -+ ldr q0, [x20], #16 -+ eor v0.16b, v0.16b, v12.16b -+ str q0, [sp, #-16]! -+ mov x0, sp -+ mov x1, sp -+ mov x2, x23 -+ mov v13.d[0], v11.d[1] // just in case AES_decrypt corrupts top half of callee-saved SIMD registers -+ mov v14.d[0], v12.d[1] -+ -+ bl AES_decrypt -+ -+ trn1 v12.2d, v12.2d, v14.2d -+ trn1 v11.2d, v11.2d, v13.2d -+ ldr q0, [sp], #16 -+ eor v0.16b, v0.16b, v12.16b -+ str q0, [x21] -+ -+ mov x6, x21 -+ // Penultimate ciphertext block produces final plaintext part-block -+ // plus remaining part of final ciphertext block. Move plaintext part -+ // to final position and re-use penultimate plaintext block buffer to -+ // construct final ciphertext block -+.Lxts_dec_steal: -+ ldrb w1, [x21] -+ ldrb w0, [x20], #1 -+ strb w1, [x21, #0x10] -+ strb w0, [x21], #1 -+ -+ subs x22, x22, #1 -+ bhi .Lxts_dec_steal -+ -+ // Finally decrypt the penultimate plaintext block using the -+ // penultimate tweak -+ ldr q0, [x6] -+ eor v0.16b, v0.16b, v11.16b -+ str q0, [sp, #-16]! -+ mov x0, sp -+ mov x1, sp -+ mov x2, x23 -+ mov x21, x6 -+ -+ bl AES_decrypt -+ -+ trn1 v11.2d, v11.2d, v13.2d -+ ldr q0, [sp], #16 -+ eor v0.16b, v0.16b, v11.16b -+ str q0, [x21] -+ -+.Lxts_dec_ret: -+ -+ movi v0.16b, #0 -+ movi v1.16b, #0 -+.Lxts_dec_bzero: // wipe key schedule -+ stp q0, q1, [sp], #32 -+ cmp sp, x19 -+ bne .Lxts_dec_bzero -+ -+ ldp x19, x20, [sp, #80] -+ ldp x21, x22, [sp, #96] -+ ldr x23, [sp, #112] -+ ldp d8, d9, [sp, #128] -+ ldp d10, d11, [sp, #144] -+ ldp d12, d13, [sp, #160] -+ ldp d14, d15, [sp, #176] -+ ldp fp, lr, [sp], #192 -+ ret -+.size bsaes_xts_decrypt,.-bsaes_xts_decrypt -diff --git a/crypto/aes/build.info b/crypto/aes/build.info -index 0f04863640d..cf688134f13 100644 ---- a/crypto/aes/build.info -+++ b/crypto/aes/build.info -@@ -4,6 +4,7 @@ SOURCE[../../libcrypto]=\ - aes_ige.c aes_wrap.c {- $target{aes_asm_src} -} - - GENERATE[aes-ia64.s]=asm/aes-ia64.S -+GENERATE[bsaes-armv8.S]=asm/bsaes-armv8.S - - GENERATE[aes-586.s]=asm/aes-586.pl \ - $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/package/libs/openssl/patches/16575.patch b/package/libs/openssl/patches/16575.patch deleted file mode 100644 index 566397658..000000000 --- a/package/libs/openssl/patches/16575.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 5e776d1ea16910373516853f4a2d586c12536aac Mon Sep 17 00:00:00 2001 -From: Bernd Edlinger -Date: Thu, 9 Sep 2021 19:34:49 +0200 -Subject: [PATCH] Make openssl speed aes use the -decrypt option - -with this patch, openssl speed -decrypt aes / aes-128-cbc / aes-128-ige -uses AES_DECRYPT mode instead of AES_ENCRYPT mode. -Previously this flag was only usable for the -evp cipher command. ---- - apps/speed.c | 20 +++++++++++++------- - 1 file changed, 13 insertions(+), 7 deletions(-) - -diff --git a/apps/speed.c b/apps/speed.c -index d4ae7ab7bfd..723d99f591a 100644 ---- a/apps/speed.c -+++ b/apps/speed.c -@@ -821,6 +821,7 @@ static int DES_ede3_cbc_encrypt_loop(void *args) - - #define MAX_BLOCK_SIZE 128 - -+static int decrypt = 0; - static unsigned char iv[2 * MAX_BLOCK_SIZE / 8]; - static AES_KEY aes_ks1, aes_ks2, aes_ks3; - static int AES_cbc_128_encrypt_loop(void *args) -@@ -830,7 +831,8 @@ static int AES_cbc_128_encrypt_loop(void *args) - int count; - for (count = 0; COND(c[D_CBC_128_AES][testnum]); count++) - AES_cbc_encrypt(buf, buf, -- (size_t)lengths[testnum], &aes_ks1, iv, AES_ENCRYPT); -+ (size_t)lengths[testnum], &aes_ks1, iv, -+ decrypt ? AES_DECRYPT : AES_ENCRYPT); - return count; - } - -@@ -841,7 +843,8 @@ static int AES_cbc_192_encrypt_loop(void *args) - int count; - for (count = 0; COND(c[D_CBC_192_AES][testnum]); count++) - AES_cbc_encrypt(buf, buf, -- (size_t)lengths[testnum], &aes_ks2, iv, AES_ENCRYPT); -+ (size_t)lengths[testnum], &aes_ks2, iv, -+ decrypt ? AES_DECRYPT : AES_ENCRYPT); - return count; - } - -@@ -852,7 +855,8 @@ static int AES_cbc_256_encrypt_loop(void *args) - int count; - for (count = 0; COND(c[D_CBC_256_AES][testnum]); count++) - AES_cbc_encrypt(buf, buf, -- (size_t)lengths[testnum], &aes_ks3, iv, AES_ENCRYPT); -+ (size_t)lengths[testnum], &aes_ks3, iv, -+ decrypt ? AES_DECRYPT : AES_ENCRYPT); - return count; - } - -@@ -864,7 +868,8 @@ static int AES_ige_128_encrypt_loop(void *args) - int count; - for (count = 0; COND(c[D_IGE_128_AES][testnum]); count++) - AES_ige_encrypt(buf, buf2, -- (size_t)lengths[testnum], &aes_ks1, iv, AES_ENCRYPT); -+ (size_t)lengths[testnum], &aes_ks1, iv, -+ decrypt ? AES_DECRYPT : AES_ENCRYPT); - return count; - } - -@@ -876,7 +881,8 @@ static int AES_ige_192_encrypt_loop(void *args) - int count; - for (count = 0; COND(c[D_IGE_192_AES][testnum]); count++) - AES_ige_encrypt(buf, buf2, -- (size_t)lengths[testnum], &aes_ks2, iv, AES_ENCRYPT); -+ (size_t)lengths[testnum], &aes_ks2, iv, -+ decrypt ? AES_DECRYPT : AES_ENCRYPT); - return count; - } - -@@ -888,7 +894,8 @@ static int AES_ige_256_encrypt_loop(void *args) - int count; - for (count = 0; COND(c[D_IGE_256_AES][testnum]); count++) - AES_ige_encrypt(buf, buf2, -- (size_t)lengths[testnum], &aes_ks3, iv, AES_ENCRYPT); -+ (size_t)lengths[testnum], &aes_ks3, iv, -+ decrypt ? AES_DECRYPT : AES_ENCRYPT); - return count; - } - -@@ -915,7 +922,6 @@ static int RAND_bytes_loop(void *args) - } - - static long save_count = 0; --static int decrypt = 0; - static int EVP_Update_loop(void *args) - { - loopargs_t *tempargs = *(loopargs_t **) args; diff --git a/package/libs/pcre/Makefile b/package/libs/pcre/Makefile index 8644746b4..894f39b7d 100644 --- a/package/libs/pcre/Makefile +++ b/package/libs/pcre/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=pcre -PKG_VERSION:=8.44 -PKG_RELEASE:=4 +PKG_VERSION:=8.45 +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@SF/$(PKG_NAME) -PKG_HASH:=19108658b23b3ec5058edc9f66ac545ea19f9537234be1ec62b714c84399366d +PKG_HASH:=4dae6fdcd2bb0bb6c37b5f97c33c2be954da743985369cddac3546e3218bffb8 PKG_MAINTAINER:=Thomas Heil PKG_LICENSE:=BSD-3-Clause @@ -24,6 +24,7 @@ PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 PKG_CONFIG_DEPENDS:=\ + CONFIG_PACKAGE_libpcrecpp \ CONFIG_PCRE_JIT_ENABLED include $(INCLUDE_DIR)/package.mk @@ -54,14 +55,20 @@ define Package/libpcre32 TITLE:=A Perl Compatible Regular Expression library (32bit support) endef +define Package/libpcrecpp + $(call Package/libpcre/default) + TITLE:=C++ wrapper for Perl Compatible Regular Expression library + DEPENDS:=+libpcre +libstdcpp +endef + HOST_CONFIGURE_ARGS += \ + --disable-shared \ --enable-utf8 \ --enable-unicode-properties \ --enable-pcre16 \ --with-match-limit-recursion=16000 \ - --disable-cpp - -TARGET_CFLAGS += $(FPIC) + --enable-cpp \ + --with-pic CONFIGURE_ARGS += \ --enable-utf8 \ @@ -70,7 +77,8 @@ CONFIGURE_ARGS += \ --enable-pcre32 \ $(if $(CONFIG_PCRE_JIT_ENABLED),--enable-jit,--disable-jit) \ --with-match-limit-recursion=16000 \ - -disable-cpp + --$(if $(CONFIG_PACKAGE_libpcrecpp),en,dis)able-cpp \ + --with-pic MAKE_FLAGS += \ CFLAGS="$(TARGET_CFLAGS)" @@ -109,7 +117,13 @@ define Package/libpcre32/install $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre32.so* $(1)/usr/lib/ endef +define Package/libpcrecpp/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcrecpp.so.* $(1)/usr/lib/ +endef + $(eval $(call BuildPackage,libpcre)) $(eval $(call BuildPackage,libpcre16)) $(eval $(call BuildPackage,libpcre32)) +$(eval $(call BuildPackage,libpcrecpp)) $(eval $(call HostBuild)) diff --git a/package/libs/popt/Makefile b/package/libs/popt/Makefile index 34ae4d7c6..ad767b8ee 100644 --- a/package/libs/popt/Makefile +++ b/package/libs/popt/Makefile @@ -8,15 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=popt -PKG_VERSION:=1.16 -PKG_RELEASE:=2 +PKG_VERSION:=1.19 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:= \ - http://distfiles.gentoo.org/distfiles/ \ - http://distcache.freebsd.org/ports-distfiles/ \ - http://rpm5.org/files/popt/ -PKG_HASH:=e728ed296fe9f069a0e005003c3d6b2dde3d9cad453422a10d6558616d304cc8 +PKG_SOURCE_URL:=http://ftp.rpm.org/popt/releases/popt-1.x/ +PKG_HASH:=c25a4838fc8e4c1c8aacb8bd620edb3084a3d63bf8987fdad3ca2758c63240f9 PKG_LICENSE:=MIT PKG_FIXUP:=autoreconf @@ -33,7 +30,7 @@ define Package/libpopt SECTION:=libs CATEGORY:=Libraries TITLE:=A command line option parsing library - URL:=http://rpm5.org/files/popt/ + URL:=https://github.com/rpm-software-management/popt ABI_VERSION:=0 endef diff --git a/package/libs/popt/patches/100-configure.ac-remove-require-gettext-version.patch b/package/libs/popt/patches/100-configure.ac-remove-require-gettext-version.patch new file mode 100644 index 000000000..24ad07643 --- /dev/null +++ b/package/libs/popt/patches/100-configure.ac-remove-require-gettext-version.patch @@ -0,0 +1,26 @@ +From 19d21b2d9e5aea5f73b1709b3c7803f920471146 Mon Sep 17 00:00:00 2001 +From: Nick Hainke +Date: Sun, 25 Sep 2022 11:52:29 +0200 +Subject: [PATCH] configure.ac: remove require gettext version + +This breaks compilation with OpenWrt: +./configure: line 13059: syntax error near unexpected token `0.19.8' +./configure: line 13059: `AM_GNU_GETTEXT_REQUIRE_VERSION(0.19.8)' + +Fixes: bf8dd64e8aa0 ("Update gettext autoconf usage") + +Signed-off-by: Nick Hainke +--- + configure.ac | 1 - + 1 file changed, 1 deletion(-) + +--- a/configure.ac ++++ b/configure.ac +@@ -53,7 +53,6 @@ AC_SEARCH_LIBS([setreuid], [ucb]) + AC_CHECK_FUNCS([getuid geteuid iconv mtrace secure_getenv __secure_getenv setreuid setuid stpcpy strerror vasprintf srandom glob_pattern_p mbsrtowcs]) + + AM_GNU_GETTEXT_VERSION([0.19.8]) +-AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8]) + AM_GNU_GETTEXT([external]) + AM_ICONV_LINK + diff --git a/package/libs/readline/Makefile b/package/libs/readline/Makefile index d41a6d74f..015a1ae2d 100644 --- a/package/libs/readline/Makefile +++ b/package/libs/readline/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=readline -PKG_VERSION:=8.1 +PKG_VERSION:=8.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/readline -PKG_HASH:=f8ceb4ee131e3232226a17f51b164afc46cd0b9e6cef344be87c65962cb82b02 +PKG_HASH:=3feb7171f16a84ee82ca18a36d7b9be109a52c04f492a053331d7d1095007c35 PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE_FILES:=COPYING @@ -45,6 +45,7 @@ define Package/libreadline/description history expansion on previous commands. endef +HOST_CONFIGURE_ARGS += --disable-shared --with-pic CONFIGURE_ARGS += --with-curses --disable-install-examples CONFIGURE_VARS += \ @@ -52,6 +53,7 @@ CONFIGURE_VARS += \ bash_cv_func_sigsetjmp=yes \ TARGET_CFLAGS += $(FPIC) +HOST_CFLAGS += $(FPIC) define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include diff --git a/package/libs/sysfsutils/Makefile b/package/libs/sysfsutils/Makefile index 8ce9a40f9..ff676308d 100644 --- a/package/libs/sysfsutils/Makefile +++ b/package/libs/sysfsutils/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sysfsutils PKG_VERSION:=2.1.0 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/linux-diag diff --git a/package/libs/sysfsutils/files/sysfsutils b/package/libs/sysfsutils/files/sysfsutils index 0305ca82a..3c5b35e78 100644 --- a/package/libs/sysfsutils/files/sysfsutils +++ b/package/libs/sysfsutils/files/sysfsutils @@ -4,6 +4,8 @@ # Based on Debian's script /etc/init.d/sysfsutils by # Martin Pitt +START=11 + load_conffile() { FILE="$1" sed 's/#.*$//; /^[[:space:]]*$/d; @@ -39,7 +41,6 @@ load_conffile() { } } -START=11 start() { for file in /etc/sysfs.conf /etc/sysfs.d/*.conf; do [ -r "$file" ] || continue diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile index cf2aff865..f9f8ac956 100644 --- a/package/libs/toolchain/Makefile +++ b/package/libs/toolchain/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=toolchain -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-3.0-with-GCC-exception @@ -115,7 +115,7 @@ define Package/libasan $(call Package/gcc/Default) NAME:=libasan TITLE:=Runtime library for AddressSanitizer in GCC - DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips @!mipsel @!mips64 @!mips64el @!arc + DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips64 @!mips64el @!arc ABI_VERSION:=5 endef @@ -202,7 +202,7 @@ define Package/libubsan $(call Package/gcc/Default) NAME:=libubsan TITLE:=Runtime library for UndefinedBehaviorSanitizer in GCC - DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips @!mipsel @!mips64 @!mips64el @!arc + DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips64 @!mips64el @!arc ABI_VERSION:=1 endef @@ -490,6 +490,7 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) define Package/libstdcpp/install $(INSTALL_DIR) $(1)/usr/lib $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/ + rm -rf $(1)/usr/lib/*-gdb.py endef define Package/libasan/install diff --git a/package/libs/uclibc++/Makefile b/package/libs/uclibc++/Makefile deleted file mode 100644 index 0e3210a5b..000000000 --- a/package/libs/uclibc++/Makefile +++ /dev/null @@ -1,105 +0,0 @@ -# -# Copyright (C) 2006-2012 OpenWrt.org -# Copyright (c) 2016 LEDE project -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=uclibc++ -PKG_VERSION:=0.2.5 -PKG_RELEASE:=3 - -PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.xz -PKG_SOURCE_URL:=https://cxx.uclibc.org/src/ -PKG_HASH:=596fb9ed7295564ce4c70ae6076a18f92e72f70310d70c98520bbca85c77895a -PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION) - -PKG_LICENSE:=LGPL-2.1-or-later -PKG_INSTALL:=1 -PKG_BUILD_PARALLEL:=1 -PKG_USE_MIPS16:=0 - -include $(INCLUDE_DIR)/package.mk - -define Package/uclibcxx - NAME:=uclibc++ - SECTION:=libs - CATEGORY:=Libraries - TITLE:=C++ library for embedded systems - URL:=https://cxx.uclibc.org/ -endef - -UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \ - -e 's/i.86/i386/' \ - -e 's/sparc.*/sparc/' \ - -e 's/m68k.*/m68k/' \ - -e 's/ppc/powerpc/g' \ - -e 's/v850.*/v850/g' \ - -e 's/sh64/sh/' \ - -e 's/sh[234].*/sh/' \ - -e 's/mips.*/mips/' \ - -e 's/mipsel.*/mips/' \ -) - -TARGET_CFLAGS += $(FPIC) -nostdinc++ -std=c++11 -TARGET_LDFLAGS += -Wl,--gc-sections - -ifneq ($(CONFIG_CCACHE),) -TARGET_CXX=$(TARGET_CXX_NOCACHE) -endif - -ifeq ($(CONFIG_USE_MUSL),y) -SSP_LIB=-lssp_nonshared -endif - -ifeq (${V}, s) -MAKE_VARS+= \ - V=1 -else ifeq (${V}, sc) -MAKE_VARS+= \ - V=2 -endif - -MAKE_FLAGS:= \ - $(TARGET_CONFIGURE_OPTS) \ - CPU_CFLAGS="$(TARGET_CFLAGS)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - LDFLAGS="$(TARGET_LDFLAGS)" \ - GEN_LIBS="-lc $(LIBGCC_S) $(SSP_LIB)" \ - check_as_needed= - -# check_as_needed overrides dependency on libgcc_s - -define Build/Configure - if [ -f ./files/config.$(UCLIBC_TARGET_ARCH) ]; then \ - cp ./files/config.$(UCLIBC_TARGET_ARCH) $(PKG_BUILD_DIR)/.config; \ - else \ - cp ./files/config.default $(PKG_BUILD_DIR)/.config; \ - fi -endef - -define Build/InstallDev - $(INSTALL_DIR) $(2)/bin $(1)/usr/include/uClibc++ $(1)/usr/lib - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/ - $(CP) $(PKG_INSTALL_DIR)/include/* $(1)/usr/include/uClibc++/ - $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++*.{a,so}* $(1)/usr/lib/ - $(SED) 's!\(^\|[[:space:]]\)-[IL]$(TOOLCHAIN_DIR)/[^[:space:]]*!!g' $(TOOLCHAIN_DIR)/bin/g++-uc - $(SED) 's|-I/include/|-I$$$${STAGING_DIR:-$(STAGING_DIR)}/usr/include/uClibc++/|g' $(TOOLCHAIN_DIR)/bin/g++-uc - $(SED) 's|-L/lib/|-L$$$${STAGING_DIR:-$(STAGING_DIR)}/lib/|g' $(TOOLCHAIN_DIR)/bin/g++-uc -# add another wrapper which links against both uClibc++ and libstdc++ - $(INSTALL_BIN) $(TOOLCHAIN_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/g++-uc+std - $(SED) 's|^WRAPPER_INCLUDEDIR=.*||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std - $(SED) 's|-luClibc++|-Wl,-Bdynamic,-luClibc++,-Bstatic,-lstdc++,-Bdynamic|g' $(TOOLCHAIN_DIR)/bin/g++-uc+std - $(SED) 's|-nostdinc++||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std -endef - -define Package/uclibcxx/install - $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++.so.* $(1)/usr/lib/ - $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++-*.so $(1)/usr/lib/ -endef - -$(eval $(call BuildPackage,uclibcxx)) diff --git a/package/libs/uclibc++/files/config.default b/package/libs/uclibc++/files/config.default deleted file mode 100644 index d76670e96..000000000 --- a/package/libs/uclibc++/files/config.default +++ /dev/null @@ -1,58 +0,0 @@ -# -# Automatically generated make config: don't edit -# - -# -# Target Features and Options -# -UCLIBCXX_HAS_FLOATS=y -# UCLIBCXX_HAS_LONG_DOUBLE is not set -# UCLIBCXX_HAS_TLS is not set -UCLIBCXX_WARNINGS="" -BUILD_EXTRA_LIBRARIES="" -HAVE_DOT_CONFIG=y - -# -# String and I/O Stream Support -# -UCLIBCXX_HAS_WCHAR=y -UCLIBCXX_IOSTREAM_BUFSIZE=32 -UCLIBCXX_HAS_LFS=y -UCLIBCXX_SUPPORT_CDIR=y -UCLIBCXX_SUPPORT_CIN=y -UCLIBCXX_SUPPORT_COUT=y -UCLIBCXX_SUPPORT_CERR=y -UCLIBCXX_SUPPORT_CLOG=y -# UCLIBCXX_SUPPORT_WCIN is not set -# UCLIBCXX_SUPPORT_WCOUT is not set -# UCLIBCXX_SUPPORT_WCERR is not set -# UCLIBCXX_SUPPORT_WCLOG is not set - -# -# STL and Code Expansion -# -UCLIBCXX_STL_BUFFER_SIZE=32 -UCLIBCXX_CODE_EXPANSION=y -UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS=y -UCLIBCXX_EXPAND_STRING_CHAR=y -UCLIBCXX_EXPAND_VECTOR_BASIC=y -UCLIBCXX_EXPAND_IOS_CHAR=y -UCLIBCXX_EXPAND_STREAMBUF_CHAR=y -UCLIBCXX_EXPAND_ISTREAM_CHAR=y -UCLIBCXX_EXPAND_OSTREAM_CHAR=y -UCLIBCXX_EXPAND_FSTREAM_CHAR=y -UCLIBCXX_EXPAND_SSTREAM_CHAR=y - -# -# Library Installation Options -# -UCLIBCXX_RUNTIME_PREFIX="" -UCLIBCXX_RUNTIME_INCLUDE_SUBDIR="/include" -UCLIBCXX_RUNTIME_LIB_SUBDIR="/lib" -UCLIBCXX_RUNTIME_BIN_SUBDIR="/bin" -UCLIBCXX_EXCEPTION_SUPPORT=y -IMPORT_LIBSUP=y -# IMPORT_LIBGCC_EH is not set -BUILD_STATIC_LIB=y -# BUILD_ONLY_STATIC_LIB is not set -# DODEBUG is not set diff --git a/package/libs/uclibc++/patches/001-no-ansi.patch b/package/libs/uclibc++/patches/001-no-ansi.patch deleted file mode 100644 index 7ddbf52f0..000000000 --- a/package/libs/uclibc++/patches/001-no-ansi.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/Rules.mak -+++ b/Rules.mak -@@ -232,7 +232,6 @@ endif - GEN_CXXFLAGS:=-nostdinc++ - GEN_CXXFLAGS+=$(if $(CXXFLAG_-fvisibility-inlines-hidden),-DGCC_HASCLASSVISIBILITY) - CXXFLAGS:=$(CFLAGS) --CFLAGS += -ansi - - LIBGCC:=$(shell $(CC) -print-libgcc-file-name) - LIBGCC_DIR:=$(dir $(LIBGCC)) diff --git a/package/libs/uclibc++/patches/002-undef-functions.patch b/package/libs/uclibc++/patches/002-undef-functions.patch deleted file mode 100644 index 47fa1580f..000000000 --- a/package/libs/uclibc++/patches/002-undef-functions.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 8245f62c1e7aba150f666b3c3a1dda646dee6d4b Mon Sep 17 00:00:00 2001 -From: Rosen Penev -Date: Fri, 27 Sep 2019 13:12:44 -0700 -Subject: [PATCH] cstdio: Add undef for four functions - -When compiling with uClibc-ng, these functions get defined as macros and -become unavailable for std. - -Fixes programs that use the std versions of these functions. - -This matches libstdcpp behavior. - -Signed-off-by: Rosen Penev ---- - include/cstdio | 9 +++++++++ - 1 file changed, 9 insertions(+) - ---- a/include/cstdio -+++ b/include/cstdio -@@ -21,6 +21,15 @@ - #ifndef __HEADER_CSTDIO - #define __HEADER_CSTDIO 1 - -+#undef clearerr -+#undef feof -+#undef ferror -+#undef fgetc -+#undef fputc -+#undef getc -+#undef getchar -+#undef putc -+#undef putchar - - namespace std{ - using ::FILE; diff --git a/package/libs/uclibc++/patches/003-no-fPIC.patch b/package/libs/uclibc++/patches/003-no-fPIC.patch deleted file mode 100644 index dfd8833ae..000000000 --- a/package/libs/uclibc++/patches/003-no-fPIC.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/Rules.mak -+++ b/Rules.mak -@@ -185,7 +185,6 @@ export UCLIBCXX_RUNTIME_PREFIX UCLIBCXX_ - - WRAPPER = $(top_builddir)bin/g++-uc - OPTIMIZATION:= --PICFLAG:=-fPIC - - # use '-Os' optimization if available, else use -O2, allow Config to override - $(eval $(call check-gcc-var,-Os)) diff --git a/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch b/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch deleted file mode 100644 index 6e13f22c8..000000000 --- a/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 8151579eb36d9366632242415ff3f5177fa5e1e2 Mon Sep 17 00:00:00 2001 -From: Rosen Penev -Date: Thu, 3 Oct 2019 18:58:43 -0700 -Subject: [PATCH] uClibc++: Make long long available to C++11 - -C++11 makes long long available. It is no longer a GNU extension. - -Signed-off-by: Rosen Penev ---- - include/istream | 4 ++-- - include/istream_helpers | 2 +- - include/ostream | 8 ++++---- - include/ostream_helpers | 8 ++++---- - tests/sstreamtest.cpp | 4 ++-- - 5 files changed, 13 insertions(+), 13 deletions(-) - ---- a/include/istream -+++ b/include/istream -@@ -72,7 +72,7 @@ namespace std{ - basic_istream& operator>>(void*& p); - basic_istream& operator>>(basic_streambuf* sb); - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - basic_istream& operator>>(long long& n); - basic_istream& operator>>(unsigned long long& n); - #endif -@@ -455,7 +455,7 @@ namespace std{ - return *this; - } - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(long long& n) - { ---- a/include/istream_helpers -+++ b/include/istream_helpers -@@ -301,7 +301,7 @@ namespace std{ - }; - - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, long long & var) ---- a/include/ostream -+++ b/include/ostream -@@ -85,7 +85,7 @@ namespace std { - basic_ostream& operator<<(long double f); - basic_ostream& operator<<(void* p); - basic_ostream& operator<<(basic_streambuf* sb); --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - basic_ostream& operator<<(long long n); - basic_ostream& operator<<(unsigned long long n); - #endif -@@ -221,7 +221,7 @@ namespace std { - return *this; - } - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long long n) - { - sentry s(*this); -@@ -487,7 +487,7 @@ namespace std { - #endif - - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - - //Support for output of long long data types - -@@ -509,7 +509,7 @@ template _UCXXEXPORT - } - - --#endif //__STRICT_ANSI__ -+#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - - - ---- a/include/ostream_helpers -+++ b/include/ostream_helpers -@@ -142,7 +142,7 @@ namespace std{ - } - }; - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - - template class _UCXXEXPORT __ostream_printout{ - public: -@@ -237,7 +237,7 @@ namespace std{ - }; - - --#endif //__STRICT_ANSI__ -+#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - - template class _UCXXEXPORT __ostream_printout{ - public: -@@ -357,7 +357,7 @@ namespace std{ - } - }; - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - - template class _UCXXEXPORT __ostream_printout{ - public: -@@ -428,7 +428,7 @@ namespace std{ - }; - - --#endif //__STRICT_ANSI__ -+#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - - template class _UCXXEXPORT __ostream_printout{ - public: ---- a/tests/sstreamtest.cpp -+++ b/tests/sstreamtest.cpp -@@ -9,7 +9,7 @@ int main(){ - int i; - std::string s; - char c; --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - long long ll; - unsigned long long ull; - #endif -@@ -32,7 +32,7 @@ int main(){ - - - --#ifndef __STRICT_ANSI__ -+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L) - a.str("678 76 54"); - a >> ll >> ull >> s; - std::cout << "ll (should be 678): " << ll << std::endl; diff --git a/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch b/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch deleted file mode 100644 index 66b62c197..000000000 --- a/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 7f6dd860818512c0eb313320308b22ba7e2c7205 Mon Sep 17 00:00:00 2001 -From: Rosen Penev -Date: Fri, 4 Oct 2019 20:06:53 -0700 -Subject: [PATCH] istream_helpers: Fix sscanf typo - -This caused readin not to work properly with long long types. - -Found accidentally through a glibc warning -(declared with warn_unused_result). - -Tested with gptfdisk on OpenWrt. - -Signed-off-by: Rosen Penev ---- - include/istream_helpers | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/include/istream_helpers -+++ b/include/istream_helpers -@@ -317,7 +317,7 @@ namespace std{ - sscanf(temp.c_str(), "%llo", (unsigned long long *)&var ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ -- scanf(temp.c_str(), "%llX", (unsigned long long *)&var ); -+ sscanf(temp.c_str(), "%llX", (unsigned long long *)&var ); - }else{ - sscanf(temp.c_str(), "%llx", (unsigned long long *)&var); - } -@@ -344,7 +344,7 @@ namespace std{ - sscanf(temp.c_str(), "%llo", &var ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ -- scanf(temp.c_str(), "%llX", &var ); -+ sscanf(temp.c_str(), "%llX", &var ); - }else{ - sscanf(temp.c_str(), "%llx", &var); - } diff --git a/package/libs/ustream-ssl/Makefile b/package/libs/ustream-ssl/Makefile index 7d9e83038..f90a2edb7 100644 --- a/package/libs/ustream-ssl/Makefile +++ b/package/libs/ustream-ssl/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/ustream-ssl.git -PKG_SOURCE_DATE:=2022-01-16 -PKG_SOURCE_VERSION:=868fd8812f477c110f9c6c5252c0bd172167b94c -PKG_MIRROR_HASH:=dd28d5e846b391917cf83d66176653bdfa4e8a0d5b11144b65a012fe7693ddeb +PKG_SOURCE_DATE:=2022-12-08 +PKG_SOURCE_VERSION:=9217ab46536353c7c792951b57163063f5ec7a3b +PKG_MIRROR_HASH:=cd4dc6a6c18290348b1f8b1c01df3320e4954dc46d714c797bef066f7a91248d CMAKE_INSTALL:=1 PKG_LICENSE:=ISC @@ -44,7 +44,7 @@ endef define Package/libustream-mbedtls $(Package/libustream/default) TITLE += (mbedtls) - DEPENDS += +libmbedtls + DEPENDS += +PACKAGE_libustream-mbedtls:libmbedtls CONFLICTS := libustream-openssl libustream-wolfssl VARIANT:=mbedtls DEFAULT_VARIANT:=1 diff --git a/package/libs/wolfssl/Config.in b/package/libs/wolfssl/Config.in index a212d1fb8..7c154ccb3 100644 --- a/package/libs/wolfssl/Config.in +++ b/package/libs/wolfssl/Config.in @@ -81,7 +81,7 @@ if PACKAGE_libwolfssl bool "AF_ALG" config WOLFSSL_HAS_DEVCRYPTO_CBC - bool "/dev/crytpo - AES-CBC-only" + bool "/dev/crypto - AES-CBC-only" select WOLFSSL_HAS_DEVCRYPTO config WOLFSSL_HAS_DEVCRYPTO_AES diff --git a/package/libs/wolfssl/Makefile b/package/libs/wolfssl/Makefile index 08a1ca740..1500a2cda 100644 --- a/package/libs/wolfssl/Makefile +++ b/package/libs/wolfssl/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wolfssl -PKG_VERSION:=5.5.1-stable +PKG_VERSION:=5.5.4-stable PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/wolfSSL/wolfssl/archive/v$(PKG_VERSION) -PKG_HASH:=97339e6956c90e7c881ba5c748dd04f7c30e5dbe0c06da765418c51375a6dee3 +PKG_HASH:=b7ee150e49def77c765bc02aac92ddeb0bebefd4cb12aa263d8f95e405221fb8 PKG_FIXUP:=libtool libtool-abiver PKG_INSTALL:=1 diff --git a/package/libs/wolfssl/patches/100-disable-hardening-check.patch b/package/libs/wolfssl/patches/100-disable-hardening-check.patch index bc5b27626..af774181e 100644 --- a/package/libs/wolfssl/patches/100-disable-hardening-check.patch +++ b/package/libs/wolfssl/patches/100-disable-hardening-check.patch @@ -1,6 +1,6 @@ --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h -@@ -2454,7 +2454,7 @@ extern void uITRON4_free(void *p) ; +@@ -2496,7 +2496,7 @@ extern void uITRON4_free(void *p) ; #endif /* warning for not using harden build options (default with ./configure) */ diff --git a/package/libs/wolfssl/patches/200-ecc-rng.patch b/package/libs/wolfssl/patches/200-ecc-rng.patch deleted file mode 100644 index bef2e6087..000000000 --- a/package/libs/wolfssl/patches/200-ecc-rng.patch +++ /dev/null @@ -1,50 +0,0 @@ -Since commit 6467de5a8840 ("Randomize z ordinates in scalar -mult when timing resistant") wolfssl requires a RNG for an EC -key when the hardened built option is selected. - -wc_ecc_set_rng is only available when built hardened, so there -is no safe way to install the RNG to the key regardless whether -or not wolfssl is compiled hardened. - -Always export wc_ecc_set_rng so tools such as hostapd can install -RNG regardless of the built settings for wolfssl. - ---- a/wolfcrypt/src/ecc.c -+++ b/wolfcrypt/src/ecc.c -@@ -12505,21 +12505,21 @@ void wc_ecc_fp_free(void) - - #endif /* FP_ECC */ - --#ifdef ECC_TIMING_RESISTANT - int wc_ecc_set_rng(ecc_key* key, WC_RNG* rng) - { - int err = 0; - -+#ifdef ECC_TIMING_RESISTANT - if (key == NULL) { - err = BAD_FUNC_ARG; - } - else { - key->rng = rng; - } -+#endif - - return err; - } --#endif - - #ifdef HAVE_ECC_ENCRYPT - ---- a/wolfssl/wolfcrypt/ecc.h -+++ b/wolfssl/wolfcrypt/ecc.h -@@ -656,10 +656,8 @@ WOLFSSL_ABI WOLFSSL_API - void wc_ecc_fp_free(void); - WOLFSSL_LOCAL - void wc_ecc_fp_init(void); --#ifdef ECC_TIMING_RESISTANT - WOLFSSL_API - int wc_ecc_set_rng(ecc_key* key, WC_RNG* rng); --#endif - - WOLFSSL_API - int wc_ecc_set_curve(ecc_key* key, int keysize, int curve_id); diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile index c7a8415c7..092443ab0 100644 --- a/package/libs/zlib/Makefile +++ b/package/libs/zlib/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zlib -PKG_VERSION:=1.2.11 -PKG_RELEASE:=3 +PKG_VERSION:=1.2.13 +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_SOURCE_URL:=@SF/libpng http://www.zlib.net -PKG_HASH:=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066 +PKG_SOURCE_URL:=https://github.com/madler/zlib/releases/download/v$(PKG_VERSION) +PKG_HASH:=d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98 PKG_LICENSE:=Zlib PKG_LICENSE_FILES:=README diff --git a/package/libs/zlib/patches/001-neon-implementation-of-adler32.patch b/package/libs/zlib/patches/001-neon-implementation-of-adler32.patch deleted file mode 100644 index 843ef45c7..000000000 --- a/package/libs/zlib/patches/001-neon-implementation-of-adler32.patch +++ /dev/null @@ -1,253 +0,0 @@ -From d2f06cd65d7ac39c6dd6761eef162abc946b155b Mon Sep 17 00:00:00 2001 -From: Adenilson Cavalcanti -Date: Tue, 11 Apr 2017 17:13:02 -0700 -Subject: [PATCH] NEON implementation for Adler32 - -The checksum is calculated in the uncompressed PNG data -and can be made much faster by using SIMD. - -Tests in ARMv8 yielded an improvement of about 3x -(e.g. walltime was 350ms x 125ms for a 4096x4096 bytes -executed 30 times). That results in at least 18% improvement -in image decoding in Chromium. - -Further details at: -https://bugs.chromium.org/p/chromium/issues/detail?id=688601 ---- - CMakeLists.txt | 29 +++++++--- - adler32.c | 5 ++ - contrib/README.contrib | 3 + - contrib/arm/neon_adler32.c | 137 +++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 166 insertions(+), 8 deletions(-) - create mode 100644 contrib/arm/neon_adler32.c - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0fe939df..8e75f664 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -7,6 +7,7 @@ set(VERSION "1.2.11") - - option(ASM686 "Enable building i686 assembly implementation") - option(AMD64 "Enable building amd64 assembly implementation") -+option(ARMv8 "Enable building ARM NEON intrinsics implementation") - - set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") - set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") -@@ -132,14 +133,26 @@ endif() - if(CMAKE_COMPILER_IS_GNUCC) - if(ASM686) - set(ZLIB_ASMS contrib/asm686/match.S) -- elseif (AMD64) -+ elseif(AMD64) - set(ZLIB_ASMS contrib/amd64/amd64-match.S) -- endif () -+ elseif(ARMv8) -+ set(ZLIB_ARMv8 contrib/arm/neon_adler32.c) -+ endif() - -- if(ZLIB_ASMS) -- add_definitions(-DASMV) -- set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) -- endif() -+ if(ZLIB_ASMS) -+ add_definitions(-DASMV) -+ set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) -+ elseif(ZLIB_ARMv8) -+ add_definitions(-DARMv8) -+ set(COMPILER ${CMAKE_C_COMPILER}) -+ # NEON is mandatory in ARMv8. -+ if(${COMPILER} MATCHES "aarch64") -+ set_source_files_properties(${ZLIB_ARMv8} PROPERTIES LANGUAGE C COMPILE_FLAGS -march=armv8-a) -+ # But it was optional for ARMv7. -+ elseif(${COMPILER} MATCHES "arm") -+ set_source_files_properties(${ZLIB_ARMv8} PROPERTIES LANGUAGE C COMPILE_FLAGS -mfpu=neon) -+ endif() -+ endif() - endif() - - if(MSVC) -@@ -183,8 +196,8 @@ if(MINGW) - set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) - endif(MINGW) - --add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) --add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -+add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_ARMv8} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -+add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_ARMv8} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) - set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) - set_target_properties(zlib PROPERTIES SOVERSION 1) - -diff --git a/adler32.c b/adler32.c -index d0be4380..45ebaa4b 100644 ---- a/adler32.c -+++ b/adler32.c -@@ -136,7 +136,12 @@ uLong ZEXPORT adler32(adler, buf, len) - const Bytef *buf; - uInt len; - { -+#ifdef ARMv8 -+# pragma message("Using NEON-ized Adler32.") -+ return NEON_adler32(adler, buf, len); -+#else - return adler32_z(adler, buf, len); -+#endif - } - - /* ========================================================================= */ -diff --git a/contrib/README.contrib b/contrib/README.contrib -index a411d5c3..3fd1d202 100644 ---- a/contrib/README.contrib -+++ b/contrib/README.contrib -@@ -12,6 +12,9 @@ amd64/ by Mikhail Teterin - asm code for AMD64 - See patch at http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/96393 - -+arm/ by Adenilson Cavalcanti -+ ARM optimizations (NEON and ARMv8 code). -+ - asm686/ by Brian Raiter - asm code for Pentium and PPro/PII, using the AT&T (GNU as) syntax - See http://www.muppetlabs.com/~breadbox/software/assembly.html -diff --git a/contrib/arm/neon_adler32.c b/contrib/arm/neon_adler32.c -new file mode 100644 -index 00000000..f173a74f ---- /dev/null -+++ b/contrib/arm/neon_adler32.c -@@ -0,0 +1,137 @@ -+/* Copyright (C) 1995-2011, 2016 Mark Adler -+ * Copyright (C) 2017 ARM Holdings Inc. -+ * Authors: Adenilson Cavalcanti -+ * Simon Hosie -+ * This software is provided 'as-is', without any express or implied -+ * warranty. In no event will the authors be held liable for any damages -+ * arising from the use of this software. -+ * Permission is granted to anyone to use this software for any purpose, -+ * including commercial applications, and to alter it and redistribute it -+ * freely, subject to the following restrictions: -+ * 1. The origin of this software must not be misrepresented; you must not -+ * claim that you wrote the original software. If you use this software -+ * in a product, an acknowledgment in the product documentation would be -+ * appreciated but is not required. -+ * 2. Altered source versions must be plainly marked as such, and must not be -+ * misrepresented as being the original software. -+ * 3. This notice may not be removed or altered from any source distribution. -+ */ -+ -+#if (defined(__ARM_NEON__) || defined(__ARM_NEON)) -+#include -+ -+static void NEON_accum32(uint32_t *s, const unsigned char *buf, -+ unsigned int len) -+{ -+ static const uint8_t taps[32] = { -+ 32, 31, 30, 29, 28, 27, 26, 25, -+ 24, 23, 22, 21, 20, 19, 18, 17, -+ 16, 15, 14, 13, 12, 11, 10, 9, -+ 8, 7, 6, 5, 4, 3, 2, 1 }; -+ -+ uint32x2_t adacc2, s2acc2, as; -+ uint8x16_t t0 = vld1q_u8(taps), t1 = vld1q_u8(taps + 16); -+ -+ uint32x4_t adacc = vdupq_n_u32(0), s2acc = vdupq_n_u32(0); -+ adacc = vsetq_lane_u32(s[0], adacc, 0); -+ s2acc = vsetq_lane_u32(s[1], s2acc, 0); -+ -+ while (len >= 2) { -+ uint8x16_t d0 = vld1q_u8(buf), d1 = vld1q_u8(buf + 16); -+ uint16x8_t adler, sum2; -+ s2acc = vaddq_u32(s2acc, vshlq_n_u32(adacc, 5)); -+ adler = vpaddlq_u8( d0); -+ adler = vpadalq_u8(adler, d1); -+ sum2 = vmull_u8( vget_low_u8(t0), vget_low_u8(d0)); -+ sum2 = vmlal_u8(sum2, vget_high_u8(t0), vget_high_u8(d0)); -+ sum2 = vmlal_u8(sum2, vget_low_u8(t1), vget_low_u8(d1)); -+ sum2 = vmlal_u8(sum2, vget_high_u8(t1), vget_high_u8(d1)); -+ adacc = vpadalq_u16(adacc, adler); -+ s2acc = vpadalq_u16(s2acc, sum2); -+ len -= 2; -+ buf += 32; -+ } -+ -+ while (len > 0) { -+ uint8x16_t d0 = vld1q_u8(buf); -+ uint16x8_t adler, sum2; -+ s2acc = vaddq_u32(s2acc, vshlq_n_u32(adacc, 4)); -+ adler = vpaddlq_u8(d0); -+ sum2 = vmull_u8( vget_low_u8(t1), vget_low_u8(d0)); -+ sum2 = vmlal_u8(sum2, vget_high_u8(t1), vget_high_u8(d0)); -+ adacc = vpadalq_u16(adacc, adler); -+ s2acc = vpadalq_u16(s2acc, sum2); -+ buf += 16; -+ len--; -+ } -+ -+ adacc2 = vpadd_u32(vget_low_u32(adacc), vget_high_u32(adacc)); -+ s2acc2 = vpadd_u32(vget_low_u32(s2acc), vget_high_u32(s2acc)); -+ as = vpadd_u32(adacc2, s2acc2); -+ s[0] = vget_lane_u32(as, 0); -+ s[1] = vget_lane_u32(as, 1); -+} -+ -+static void NEON_handle_tail(uint32_t *pair, const unsigned char *buf, -+ unsigned int len) -+{ -+ /* Oldie K&R code integration. */ -+ unsigned int i; -+ for (i = 0; i < len; ++i) { -+ pair[0] += buf[i]; -+ pair[1] += pair[0]; -+ } -+} -+ -+extern unsigned long NEON_adler32(unsigned long adler, const unsigned char *buf, -+ const unsigned int len) -+{ -+ /* initial Adler-32 value (deferred check for len == 1 speed) */ -+ if (!buf) -+ return 1L; -+ -+ /* The largest prime smaller than 65536. */ -+ const uint32_t M_BASE = 65521; -+ /* This is the threshold where doing accumulation may overflow. */ -+ const int M_NMAX = 5552; -+ -+ unsigned long sum2; -+ uint32_t pair[2]; -+ int n = M_NMAX; -+ unsigned int done = 0; -+ /* Oldie K&R code integration. */ -+ unsigned int i; -+ -+ /* Split Adler-32 into component sums, it can be supplied by -+ * the caller sites (e.g. in a PNG file). -+ */ -+ sum2 = (adler >> 16) & 0xffff; -+ adler &= 0xffff; -+ pair[0] = adler; -+ pair[1] = sum2; -+ -+ for (i = 0; i < len; i += n) { -+ if ((i + n) > len) -+ n = len - i; -+ -+ if (n < 16) -+ break; -+ -+ NEON_accum32(pair, buf + i, n / 16); -+ pair[0] %= M_BASE; -+ pair[1] %= M_BASE; -+ -+ done += (n / 16) * 16; -+ } -+ -+ /* Handle the tail elements. */ -+ if (done < len) { -+ NEON_handle_tail(pair, (buf + done), len - done); -+ pair[0] %= M_BASE; -+ pair[1] %= M_BASE; -+ } -+ -+ /* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */ -+ return (pair[1] << 16) | pair[0]; -+} -+#endif diff --git a/package/libs/zlib/patches/002-arm-specific-optimisations-for-inflate.patch b/package/libs/zlib/patches/002-arm-specific-optimisations-for-inflate.patch index d181b034e..04e66621e 100644 --- a/package/libs/zlib/patches/002-arm-specific-optimisations-for-inflate.patch +++ b/package/libs/zlib/patches/002-arm-specific-optimisations-for-inflate.patch @@ -11,9 +11,6 @@ Change-Id: Id4cda552b39bfb39ab35ec499dbe122b43b6d1a1 create mode 100644 contrib/arm/inffast.c create mode 100644 contrib/arm/inflate.c -diff --git a/contrib/arm/inffast.c b/contrib/arm/inffast.c -new file mode 100644 -index 00000000..0dbd1dbc --- /dev/null +++ b/contrib/arm/inffast.c @@ -0,0 +1,323 @@ @@ -340,9 +337,6 @@ index 00000000..0dbd1dbc + */ + +#endif /* !ASMINF */ -diff --git a/contrib/arm/inflate.c b/contrib/arm/inflate.c -new file mode 100644 -index 00000000..ac333e8c --- /dev/null +++ b/contrib/arm/inflate.c @@ -0,0 +1,1561 @@ diff --git a/package/libs/zlib/patches/003-arm-specific-optimisations-for-inflate.patch b/package/libs/zlib/patches/003-arm-specific-optimisations-for-inflate.patch index 9370264c4..1f83b500b 100644 --- a/package/libs/zlib/patches/003-arm-specific-optimisations-for-inflate.patch +++ b/package/libs/zlib/patches/003-arm-specific-optimisations-for-inflate.patch @@ -16,9 +16,6 @@ Change-Id: I59854eb25d2b1e43561c8a2afaf9175bf10cf674 3 files changed, 335 insertions(+), 62 deletions(-) create mode 100644 contrib/arm/chunkcopy.h -diff --git a/contrib/arm/chunkcopy.h b/contrib/arm/chunkcopy.h -new file mode 100644 -index 00000000..2d6fd6f9 --- /dev/null +++ b/contrib/arm/chunkcopy.h @@ -0,0 +1,279 @@ @@ -301,8 +298,6 @@ index 00000000..2d6fd6f9 +#undef Z_RESTRICT + +#endif /* CHUNKCOPY_H */ -diff --git a/contrib/arm/inffast.c b/contrib/arm/inffast.c -index 0dbd1dbc..f7f50071 100644 --- a/contrib/arm/inffast.c +++ b/contrib/arm/inffast.c @@ -7,6 +7,7 @@ @@ -313,7 +308,7 @@ index 0dbd1dbc..f7f50071 100644 #ifdef ASMINF # pragma message("Assembler code may have bugs -- use at your own risk") -@@ -57,6 +58,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ +@@ -57,6 +58,7 @@ unsigned start; /* inflate()'s s unsigned char FAR *out; /* local strm->next_out */ unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ unsigned char FAR *end; /* while out < end, enough space available */ @@ -321,7 +316,7 @@ index 0dbd1dbc..f7f50071 100644 #ifdef INFLATE_STRICT unsigned dmax; /* maximum distance from zlib header */ #endif -@@ -84,12 +86,13 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ +@@ -84,12 +86,13 @@ unsigned start; /* inflate()'s s out = strm->next_out; beg = out - (start - strm->avail_out); end = out + (strm->avail_out - 257); @@ -336,7 +331,7 @@ index 0dbd1dbc..f7f50071 100644 window = state->window; hold = state->hold; bits = state->bits; -@@ -197,70 +200,51 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ +@@ -197,70 +200,51 @@ unsigned start; /* inflate()'s s #endif } from = window; @@ -371,14 +366,8 @@ index 0dbd1dbc..f7f50071 100644 - } while (--op); - from = out - dist; /* rest from output */ - } -+ out = chunkcopy_safe(out, from, op, limit); -+ from = window; /* more from start of window */ -+ op = wnext; -+ /* This (rare) case can create a situation where -+ the first chunkcopy below must be checked. -+ */ - } - } +- } +- } - else { /* contiguous in window */ - from += wnext - op; - if (op < len) { /* some from window */ @@ -399,6 +388,14 @@ index 0dbd1dbc..f7f50071 100644 - *out++ = *from++; - if (len > 1) - *out++ = *from++; ++ out = chunkcopy_safe(out, from, op, limit); ++ from = window; /* more from start of window */ ++ op = wnext; ++ /* This (rare) case can create a situation where ++ the first chunkcopy below must be checked. ++ */ ++ } ++ } + if (op < len) { /* still need some from output */ + out = chunkcopy_safe(out, from, op, limit); + len -= op; @@ -443,8 +440,6 @@ index 0dbd1dbc..f7f50071 100644 } } else if ((op & 64) == 0) { /* 2nd level distance code */ -diff --git a/contrib/arm/inflate.c b/contrib/arm/inflate.c -index ac333e8c..e40322c3 100644 --- a/contrib/arm/inflate.c +++ b/contrib/arm/inflate.c @@ -84,6 +84,7 @@ diff --git a/package/libs/zlib/patches/004-attach-sourcefiles-in-patch-002-to-buildsystem.patch b/package/libs/zlib/patches/004-attach-sourcefiles-in-patch-002-to-buildsystem.patch index 68f317b24..81816aed6 100644 --- a/package/libs/zlib/patches/004-attach-sourcefiles-in-patch-002-to-buildsystem.patch +++ b/package/libs/zlib/patches/004-attach-sourcefiles-in-patch-002-to-buildsystem.patch @@ -1,8 +1,6 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8e75f66..24d7329 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -95,34 +95,67 @@ set(ZLIB_PUBLIC_HDRS +@@ -91,34 +91,67 @@ set(ZLIB_PUBLIC_HDRS ${CMAKE_CURRENT_BINARY_DIR}/zconf.h zlib.h ) diff --git a/package/system/ca-certificates/Makefile b/package/system/ca-certificates/Makefile index 46bd871cc..9fac32e7e 100644 --- a/package/system/ca-certificates/Makefile +++ b/package/system/ca-certificates/Makefile @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ca-certificates -PKG_VERSION:=20210119 +PKG_VERSION:=20211016 PKG_RELEASE:=1 PKG_MAINTAINER:= PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@DEBIAN/pool/main/c/ca-certificates -PKG_HASH:=daa3afae563711c30a0586ddae4336e8e3974c2b627faaca404c4e0141b64665 +PKG_HASH:=2ae9b6dc5f40c25d6d7fe55e07b54f12a8967d1955d3b7b2f42ee46266eeef88 PKG_INSTALL:=1 include $(INCLUDE_DIR)/package.mk diff --git a/package/system/ca-certificates/patches/0001-ca-certificates-fix-python3-cryptography-woes-in-cer.patch b/package/system/ca-certificates/patches/0001-ca-certificates-fix-python3-cryptography-woes-in-cer.patch new file mode 100644 index 000000000..add01f42c --- /dev/null +++ b/package/system/ca-certificates/patches/0001-ca-certificates-fix-python3-cryptography-woes-in-cer.patch @@ -0,0 +1,53 @@ +From 3c51cb5ff1d0db41fb3288fb555c7e7055cf3e86 Mon Sep 17 00:00:00 2001 +From: Christian Lamparter +Date: Wed, 1 Dec 2021 14:41:31 +0100 +Subject: [PATCH] ca-certificates: fix python3-cryptography woes in + certdata2pem.py + +reverts the code portion of the Debian's ca-certificate +commit 033d52259172 ("mozilla/certdata2pem.py: print a warning for expired certificates.") + +It broke builds with the popular Ubuntu 20.04 (focal) releases. +This was due to them shipping with an older python3-cryptography +version which is not compatible. + +More concerns were raised by jow- as well: +"We don't want the build to depend on the local system time anyway." + +Reported-by: Chen Minqiang +Reported-by: Shane Synan +Signed-off-by: Christian Lamparter +--- +--- a/work/mozilla/certdata2pem.py ++++ b/work/mozilla/certdata2pem.py +@@ -21,16 +21,12 @@ + # USA. + + import base64 +-import datetime + import os.path + import re + import sys + import textwrap + import io + +-from cryptography import x509 +- +- + objects = [] + + # Dirty file parser. +@@ -121,13 +117,6 @@ for obj in objects: + if obj['CKA_CLASS'] == 'CKO_CERTIFICATE': + if not obj['CKA_LABEL'] in trust or not trust[obj['CKA_LABEL']]: + continue +- +- cert = x509.load_der_x509_certificate(obj['CKA_VALUE']) +- if cert.not_valid_after < datetime.datetime.now(): +- print('!'*74) +- print('Trusted but expired certificate found: %s' % obj['CKA_LABEL']) +- print('!'*74) +- + bname = obj['CKA_LABEL'][1:-1].replace('/', '_')\ + .replace(' ', '_')\ + .replace('(', '=')\ diff --git a/package/system/fstools/Makefile b/package/system/fstools/Makefile index 9741b7ac0..3a82ecd11 100644 --- a/package/system/fstools/Makefile +++ b/package/system/fstools/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2014-2015 OpenWrt.org +# Copyright (C) 2014-2022 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -12,9 +12,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git -PKG_MIRROR_HASH:=faa4679562ae31cb6dbbc90b7f3f297294a51f7be1b12d10a5f0b7acfaae7252 -PKG_SOURCE_DATE:=2021-08-14 -PKG_SOURCE_VERSION:=2e3aca299ea7bbe74f219860510c4b34e77c7aa4 +PKG_MIRROR_HASH:=28be14a1e28fc62e80681e1b5e7f2435692ee326b66afcc1f3d158764df686d5 +PKG_SOURCE_DATE:=2022-11-10 +PKG_SOURCE_VERSION:=3affe9ea5098c8bb90111ce97d50ad976ef0c034 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 @@ -31,7 +31,6 @@ PKG_MAINTAINER:=John Crispin include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk -TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_UBIFS_EXTROOT),-DCMAKE_UBIFS_EXTROOT=y) CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_OVL_MOUNT_FULL_ACCESS_TIME),-DCMAKE_OVL_MOUNT_FULL_ACCESS_TIME=y) CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_OVL_MOUNT_COMPRESS_ZLIB),-DCMAKE_OVL_MOUNT_COMPRESS_ZLIB=y) @@ -39,7 +38,7 @@ CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_OVL_MOUNT_COMPRESS_ZLIB),-DCMAKE_OVL_MOUN define Package/fstools SECTION:=base CATEGORY:=Base system - DEPENDS:=+ubox +USE_GLIBC:librt +NAND_SUPPORT:ubi-utils + DEPENDS:=+ubox +NAND_SUPPORT:ubi-utils TITLE:=OpenWrt filesystem tools MENU:=1 endef @@ -75,6 +74,10 @@ define Package/snapshot-tool DEPENDS:=+libubox +fstools endef +define Package/block-mount/conffiles +/etc/config/fstab +endef + define Package/block-mount SECTION:=base CATEGORY:=Base system diff --git a/package/system/fstools/files/fstab.init b/package/system/fstools/files/fstab.init index 08d5601be..03a399349 100644 --- a/package/system/fstools/files/fstab.init +++ b/package/system/fstools/files/fstab.init @@ -1,7 +1,9 @@ #!/bin/sh /etc/rc.common -# (C) 2013 openwrt.org +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2013-2020 OpenWrt.org -START=40 +START=11 boot() { /sbin/block mount diff --git a/package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch b/package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch index 65d1a087c..20a68484d 100644 --- a/package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch +++ b/package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch @@ -16,12 +16,9 @@ Signed-off-by: Qi Liu 4 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 libfstools/fstype.h -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a586577..4b6e3e7 100644 - --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -75,9 +75,9 @@ INSTALL(TARGETS blockd RUNTIME DESTINATION sbin) +@@ -78,9 +78,9 @@ INSTALL(TARGETS blockd RUNTIME DESTINATI ADD_EXECUTABLE(block block.c probe.c probe-libblkid.c) IF(DEFINED CMAKE_UBIFS_EXTROOT) ADD_DEFINITIONS(-DUBIFS_EXTROOT) @@ -33,12 +30,10 @@ index a586577..4b6e3e7 100644 ENDIF(DEFINED CMAKE_UBIFS_EXTROOT) INSTALL(TARGETS block RUNTIME DESTINATION sbin) -diff --git a/block.c b/block.c -index 569bf56..66cce46 100644 --- a/block.c +++ b/block.c -@@ -45,6 +45,8 @@ - #include +@@ -44,6 +44,8 @@ + #include #include +#include "libfstools/fstype.h" @@ -46,7 +41,7 @@ index 569bf56..66cce46 100644 #include "probe.h" #define AUTOFS_MOUNT_PATH "/tmp/run/blockd/" -@@ -1590,6 +1592,44 @@ static int main_extroot(int argc, char **argv) +@@ -1696,6 +1698,44 @@ static int main_extroot(int argc, char * } #endif @@ -91,9 +86,6 @@ index 569bf56..66cce46 100644 /* As a last resort look for /etc/config/fstab on "rootfs" partition */ return mount_extroot(NULL); } -diff --git a/libfstools/fstype.h b/libfstools/fstype.h -new file mode 100644 -index 0000000..8882343 --- /dev/null +++ b/libfstools/fstype.h @@ -0,0 +1,13 @@ @@ -111,8 +103,6 @@ index 0000000..8882343 +}; +#endif \ No newline at end of file -diff --git a/libfstools/libfstools.h b/libfstools/libfstools.h -index f27307a..8d3362f 100644 --- a/libfstools/libfstools.h +++ b/libfstools/libfstools.h @@ -18,20 +18,10 @@ diff --git a/package/system/fstools/patches/0100-automount.patch b/package/system/fstools/patches/0100-automount.patch new file mode 100644 index 000000000..6a68444e0 --- /dev/null +++ b/package/system/fstools/patches/0100-automount.patch @@ -0,0 +1,20 @@ +--- a/block.c ++++ b/block.c +@@ -729,7 +729,7 @@ static int print_block_uci(struct probe_ + printf("\toption\tuuid\t'%s'\n", pr->uuid); + else + printf("\toption\tdevice\t'%s'\n", pr->dev); +- printf("\toption\tenabled\t'0'\n\n"); ++ printf("\toption\tenabled\t'1'\n\n"); + + return 0; + } +@@ -1794,7 +1794,7 @@ static int main_detect(int argc, char ** + cache_load(0); + printf("config 'global'\n"); + printf("\toption\tanon_swap\t'0'\n"); +- printf("\toption\tanon_mount\t'0'\n"); ++ printf("\toption\tanon_mount\t'1'\n"); + printf("\toption\tauto_swap\t'1'\n"); + printf("\toption\tauto_mount\t'1'\n"); + printf("\toption\tdelay_root\t'5'\n"); diff --git a/package/system/fstools/patches/0200-ntfs3-with-utf8.patch b/package/system/fstools/patches/0200-ntfs3-with-utf8.patch new file mode 100644 index 000000000..aa6df4d9d --- /dev/null +++ b/package/system/fstools/patches/0200-ntfs3-with-utf8.patch @@ -0,0 +1,23 @@ +--- a/block.c ++++ b/block.c +@@ -943,6 +943,11 @@ + { + size_t mount_opts_len; + char *mount_opts = NULL, *ptr; ++ char _data[128] = {0}; ++ if (strstr(fstype, "fat") || strstr(fstype, "ntfs")) { ++ snprintf(_data, sizeof(_data), "%s", "iocharset=utf8,uid=65534,gid=65534"); ++ } ++ + const char * const *filesystems; + int err = -EINVAL; + size_t count; +@@ -960,7 +965,7 @@ + const char *fs = filesystems[i]; + + err = mount(source, target, fs, m ? m->flags : 0, +- (m && m->options) ? m->options : ""); ++ (m && m->options) ? m->options : _data); + if (!err || errno != ENODEV) + break; + } diff --git a/package/system/iucode-tool/Makefile b/package/system/iucode-tool/Makefile index b8227ed4a..d7c85b2d4 100644 --- a/package/system/iucode-tool/Makefile +++ b/package/system/iucode-tool/Makefile @@ -9,13 +9,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=iucode-tool PKG_VERSION:=2.3.1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=iucode-tool_$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://gitlab.com/iucode-tool/releases/raw/latest PKG_HASH:=12b88efa4d0d95af08db05a50b3dcb217c0eb2bfc67b483779e33d498ddb2f95 PKG_BUILD_DEPENDS:=USE_UCLIBC:argp-standalone USE_MUSL:argp-standalone +HOST_BUILD_DEPENDS:=HOST_OS_MACOS:argp-standalone/host PKG_MAINTAINER:=Zoltan HERPAI PKG_LICENSE:=GPL-2.0 @@ -41,6 +42,18 @@ define Package/iucode-tool/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/iucode_tool $(1)/usr/bin/ endef +# List of build hosts with working cpuid.h +IUT_NATIVE_HOST_OS_ARCH := \ + linux/x86_64 linux/amd64 linux/i386 linux/i686 + +IUT_HOST_OS_ARCH := $(call tolower,$(HOST_OS))/$(HOST_ARCH) + +# Use cpuid.h compat header if build host does not have working cpuid.h +ifeq ($(filter $(IUT_HOST_OS_ARCH),$(IUT_NATIVE_HOST_OS_ARCH)),) +HOST_CFLAGS += \ + -I$(HOST_BUILD_DIR)/cpuid-compat +endif + define Host/Install $(INSTALL_BIN) $(HOST_BUILD_DIR)/iucode_tool $(STAGING_DIR_HOST)/bin/iucode_tool endef diff --git a/package/system/iucode-tool/patches/001-iucode_tool-add-missing-limits.h-for-USE_CPUID_DEVIC.patch b/package/system/iucode-tool/patches/001-iucode_tool-add-missing-limits.h-for-USE_CPUID_DEVIC.patch new file mode 100644 index 000000000..ef9e5ab2f --- /dev/null +++ b/package/system/iucode-tool/patches/001-iucode_tool-add-missing-limits.h-for-USE_CPUID_DEVIC.patch @@ -0,0 +1,29 @@ +From e1137cdafc97c0a8b2a0717a771823f3c4320087 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Tue, 29 Nov 2022 19:37:03 +0100 +Subject: [PATCH] iucode_tool: add missing limits.h for USE_CPUID_DEVICE + +If USE_CPUID_DEVICE is enabled, compilation fails for missing define. +Add the missing include to fix compilation error with USE_CPUID_DEVICE +define. + +Signed-off-by: Christian Marangi +--- + iucode_tool.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/iucode_tool.c b/iucode_tool.c +index 4bba5db..0246035 100644 +--- a/iucode_tool.c ++++ b/iucode_tool.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.37.2 + diff --git a/package/system/iucode-tool/patches/200_add-cpuid-compatibility-header-to-build-on-non-x86.patch b/package/system/iucode-tool/patches/200_add-cpuid-compatibility-header-to-build-on-non-x86.patch new file mode 100644 index 000000000..900f3596f --- /dev/null +++ b/package/system/iucode-tool/patches/200_add-cpuid-compatibility-header-to-build-on-non-x86.patch @@ -0,0 +1,31 @@ +From a21e75da32c0016f1575ea29775565934a67660d Mon Sep 17 00:00:00 2001 +From: "Sergey V. Lobanov" +Date: Sat, 5 Feb 2022 13:10:23 +0300 +Subject: [PATCH] Add cpuid compatibility header to build on non-x86 hosts + +Signed-off-by: Sergey V. Lobanov +--- + cpuid-compat/cpuid.h | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + create mode 100644 cpuid-compat/cpuid.h + +--- /dev/null ++++ b/cpuid-compat/cpuid.h +@@ -0,0 +1,17 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++/* ++ * cpuid compatibility header to build iucode-tool on non-x86 hosts ++ * ++ * Copyright (C) 2022 Sergey V. Lobanov ++ */ ++ ++#ifdef __APPLE__ ++# include ++#endif ++ ++static __inline int __get_cpuid (unsigned int leaf, ++ unsigned int *eax, unsigned int *ebx, ++ unsigned int *ecx, unsigned int *edx) ++{ ++ return 0; ++} diff --git a/package/system/mtd/src/Makefile b/package/system/mtd/src/Makefile index e204ecb22..cce39ef4e 100644 --- a/package/system/mtd/src/Makefile +++ b/package/system/mtd/src/Makefile @@ -19,6 +19,7 @@ obj.ramips = $(obj.seama) $(obj.tpl) $(obj.wrg) linksys_bootcount.o obj.mvebu = linksys_bootcount.o obj.kirkwood = linksys_bootcount.o obj.ipq806x = linksys_bootcount.o +obj.ipq60xx = linksys_bootcount.o obj.ipq40xx = linksys_bootcount.o ifdef FIS_SUPPORT diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile index 65bdf6dba..83c9dab1b 100644 --- a/package/system/opkg/Makefile +++ b/package/system/opkg/Makefile @@ -12,9 +12,9 @@ PKG_FLAGS:=essential PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/opkg-lede.git -PKG_SOURCE_DATE:=2021-06-13 -PKG_SOURCE_VERSION:=1bf042dd06751b693a8544d2317e5b969d666b69 -PKG_MIRROR_HASH:=aeda4e0f11805bf95fc7be6d38391ce579acd965c8ba6a490b3e8669815b7264 +PKG_SOURCE_DATE:=2022-02-24 +PKG_SOURCE_VERSION:=d038e5b6d155784575f62a66a8bb7e874173e92e +PKG_MIRROR_HASH:=e5ec4ae93f6529f7f0b9acc22a9a63c1b2f27d3b30b4a82041fcd58b9bc7cdf3 PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=COPYING @@ -26,10 +26,6 @@ PKG_CONFIG_DEPENDS += \ CONFIG_SIGNATURE_CHECK \ CONFIG_TARGET_INIT_PATH -PKG_BUILD_PARALLEL:=1 -HOST_BUILD_PARALLEL:=1 -PKG_INSTALL:=1 - HOST_BUILD_DEPENDS:=libubox/host include $(INCLUDE_DIR)/package.mk diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index ccd0a9c75..2eebe50a4 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git -PKG_SOURCE_DATE:=2021-08-13 -PKG_SOURCE_VERSION:=9f233f555f80d1c416656c04ab81d19edc738f07 -PKG_MIRROR_HASH:=01cdadba9e3a8848342f40383ff61cdc91516c9198790ca49dcc6837cdd83351 +PKG_MIRROR_HASH:=d60b4aa9d47d75e906dfd812528a1bc28e91f5af72a9d9275056b71b19d99f04 +PKG_SOURCE_DATE:=2022-11-10 +PKG_SOURCE_VERSION:=039b88f75367203e540009cc97603b1bce3fafa6 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 @@ -24,8 +24,7 @@ PKG_MAINTAINER:=John Crispin PKG_ASLR_PIE_REGULAR:=1 PKG_CONFIG_DEPENDS:= \ - CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP \ - CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \ + CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP CONFIG_PROCD_SHOW_BOOT \ CONFIG_KERNEL_NAMESPACES CONFIG_PACKAGE_procd-ujail CONFIG_PACKAGE_procd-seccomp include $(INCLUDE_DIR)/package.mk @@ -36,7 +35,6 @@ ifeq ($(DUMP),) endif CMAKE_OPTIONS += -DEARLY_PATH="$(TARGET_INIT_PATH)" -TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) TARGET_CFLAGS += -flto TARGET_LDFLAGS += -flto @@ -44,7 +42,7 @@ TARGET_LDFLAGS += -flto define Package/procd/Default SECTION:=base CATEGORY:=Base system - DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox \ + DEPENDS:=+ubusd +ubus +libjson-script +ubox +libubox \ +libubus +libblobmsg-json +libjson-c +jshn TITLE:=OpenWrt system process manager USERID:=:dialout=20 :audio=29 @@ -68,29 +66,21 @@ define Package/procd-ujail SECTION:=base CATEGORY:=Base system DEPENDS:=@KERNEL_NAMESPACES +@KERNEL_UTS_NS +@KERNEL_IPC_NS +@KERNEL_PID_NS \ - +libubox +libubus +libblobmsg-json + +libubox +libubus +libuci +libblobmsg-json TITLE:=OpenWrt process jail helper endef -define Package/procd-ujail-console - SECTION:=base - CATEGORY:=Base system - DEPENDS:=+procd-ujail +libubus +libubox - TITLE:=OpenWrt process jail console -endef - define Package/procd-seccomp SECTION:=base CATEGORY:=Base system - DEPENDS:=@(aarch64||arm||armeb||mips||mipsel||i386||powerpc||x86_64) @!TARGET_uml \ - @KERNEL_SECCOMP +libubox +libblobmsg-json + DEPENDS:=@SECCOMP +libubox +libblobmsg-json TITLE:=OpenWrt process seccomp helper + utrace endef define Package/uxc SECTION:=base CATEGORY:=Base system - DEPENDS:=+procd-ujail +libubus +libubox +libblobmsg-json +blockd + DEPENDS:=+procd-ujail +libubus +libubox +libblobmsg-json +blockd +PACKAGE_uxc:rpcd TITLE:=OpenWrt container management MAINTAINER:=Daniel Golle endef @@ -104,10 +94,6 @@ config PROCD_SHOW_BOOT default n prompt "Print the shutdown to the console as well as logging it to syslog" -config PROCD_ZRAM_TMPFS - bool - default n - prompt "Mount /tmp using zram." endmenu endef @@ -119,10 +105,6 @@ ifeq ($(CONFIG_PROCD_SHOW_BOOT),y) CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1 endif -ifeq ($(CONFIG_PROCD_ZRAM_TMPFS),y) - CMAKE_OPTIONS += -DZRAM_TMPFS=1 -endif - ifdef CONFIG_PACKAGE_procd-ujail CMAKE_OPTIONS += -DJAIL_SUPPORT=1 endif @@ -138,6 +120,7 @@ define Package/procd/install $(INSTALL_BIN) ./files/reload_config $(1)/sbin/ $(INSTALL_CONF) ./files/hotplug*.json $(1)/etc/ $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/ + $(INSTALL_BIN) ./files/service $(1)/sbin/service endef Package/procd-selinux/install = $(Package/procd/install) @@ -147,11 +130,6 @@ define Package/procd-ujail/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ujail $(1)/sbin/ endef -define Package/procd-ujail-console/install - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ujail-console $(1)/sbin/ -endef - define Package/procd-seccomp/install $(INSTALL_DIR) $(1)/sbin $(1)/lib $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-seccomp.so $(1)/lib @@ -174,6 +152,5 @@ endef $(eval $(call BuildPackage,procd)) $(eval $(call BuildPackage,procd-selinux)) $(eval $(call BuildPackage,procd-ujail)) -$(eval $(call BuildPackage,procd-ujail-console)) $(eval $(call BuildPackage,procd-seccomp)) $(eval $(call BuildPackage,uxc)) diff --git a/package/system/procd/files/hotplug.json b/package/system/procd/files/hotplug.json index 7e0f129d3..b930b307a 100644 --- a/package/system/procd/files/hotplug.json +++ b/package/system/procd/files/hotplug.json @@ -7,9 +7,19 @@ [ "has", "MINOR" ] ], [ + [ "if", + [ "eq", "DEVNAME", "null" ], + [ + [ "makedev", "/dev/%DEVNAME%", "0666" ], + [ "exec", "/bin/ln", "-s", "/proc/self/fd/0", "/dev/stdin" ], + [ "exec", "/bin/ln", "-s", "/proc/self/fd/1", "/dev/stdout" ], + [ "exec", "/bin/ln", "-s", "/proc/self/fd/2", "/dev/stderr" ], + [ "return" ] + ] + ], [ "if", [ "eq", "DEVNAME", - [ "null", "full", "ptmx", "zero", "tty", "net", "random", "urandom" ] + [ "full", "ptmx", "zero", "tty", "net", "random", "urandom" ] ], [ [ "makedev", "/dev/%DEVNAME%", "0666" ], diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index 3be496fbb..5148b2f03 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -48,6 +48,15 @@ _PROCD_SERVICE= procd_lock() { local basescript=$(readlink "$initscript") local service_name="$(basename ${basescript:-$initscript})" + + flock -n 1000 &> /dev/null + if [ "$?" != "0" ]; then + exec 1000>"$IPKG_INSTROOT/var/lock/procd_${service_name}.lock" + flock 1000 + if [ "$?" != "0" ]; then + logger "warning: procd flock for $service_name failed" + fi + fi } _procd_call() { @@ -189,7 +198,6 @@ _procd_add_jail() { netns) json_add_boolean "netns" "1";; userns) json_add_boolean "userns" "1";; cgroupsns) json_add_boolean "cgroupsns" "1";; - console) json_add_boolean "console" "1";; esac done json_add_object "mount" @@ -355,14 +363,15 @@ _procd_add_mount_trigger() { } _procd_add_action_mount_trigger() { + local action="$1" + shift + local mountpoints="$(procd_get_mountpoints "$@")" + [ "${mountpoints//[[:space:]]}" ] || return 0 local script=$(readlink "$initscript") local name=$(basename ${script:-$initscript}) - local action="$1" - local mpath - shift _procd_open_trigger - _procd_add_mount_trigger mount.add $action "$@" + _procd_add_mount_trigger mount.add $action "$mountpoints" _procd_close_trigger } @@ -376,7 +385,7 @@ procd_get_mountpoints() { target="${target%%/}/" [ "$path" != "${path##$target}" ] && echo "${target%%/}" } - + local mpath config_load fstab for mpath in "$@"; do config_foreach __procd_check_mount mount "$mpath" @@ -385,11 +394,11 @@ procd_get_mountpoints() { } _procd_add_restart_mount_trigger() { - _procd_add_action_mount_trigger restart $(procd_get_mountpoints "$@") + _procd_add_action_mount_trigger restart "$@" } _procd_add_reload_mount_trigger() { - _procd_add_action_mount_trigger reload $(procd_get_mountpoints "$@") + _procd_add_action_mount_trigger reload "$@" } _procd_add_raw_trigger() { @@ -626,6 +635,7 @@ _procd_wrapper \ procd_add_mount_trigger \ procd_add_reload_trigger \ procd_add_reload_interface_trigger \ + procd_add_action_mount_trigger \ procd_add_reload_mount_trigger \ procd_add_restart_mount_trigger \ procd_open_trigger \ diff --git a/package/system/procd/files/service b/package/system/procd/files/service new file mode 100644 index 000000000..0ca705804 --- /dev/null +++ b/package/system/procd/files/service @@ -0,0 +1,30 @@ +#!/bin/sh + +main() { + local service="$1" + shift + + local boot status + + if [ -f "/etc/init.d/${service}" ]; then + /etc/init.d/"${service}" "$@" + exit "$?" + fi + + if [ -n "$service" ]; then + echo "Service \"$service\" not found:" + exit 1 + fi + + echo "Usage: $(basename "$0") [command]" + for service in /etc/init.d/* ; do + boot="$($service enabled && echo "enabled" || echo "disabled" )" + status="$( [ "$(ubus call service list "{ 'verbose': true, 'name': '$(basename "$service")' }" \ + | jsonfilter -q -e "@['$(basename "$service")'].instances[*].running" | uniq)" = "true" ] \ + && echo "running" || echo "stopped" )" + + printf "%-30s\\t%10s\\t%10s\\n" "$service" "$boot" "$status" + done +} + +main "$@" diff --git a/package/system/procd/files/uxc.init b/package/system/procd/files/uxc.init index 1e75b796f..0b51925a7 100644 --- a/package/system/procd/files/uxc.init +++ b/package/system/procd/files/uxc.init @@ -6,17 +6,11 @@ NAME=uxc PROG=/sbin/uxc start_service() { - [ "${__BOOT_UXC}" = "1" ] || return 0 procd_open_instance "uxc" procd_set_param command "$PROG" boot procd_close_instance } -boot() { - __BOOT_UXC=1 - start -} - service_triggers() { - procd_add_raw_trigger "mount.add" 3000 /etc/init.d/uxc boot + procd_add_raw_trigger "mount.add" 3000 /etc/init.d/uxc start } diff --git a/package/system/procd/patches/001-procd_ujail_static_binary_fix.patch b/package/system/procd/patches/001-procd_ujail_static_binary_fix.patch deleted file mode 100644 index d0484b15f..000000000 --- a/package/system/procd/patches/001-procd_ujail_static_binary_fix.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/jail/elf.c -+++ b/jail/elf.c -@@ -240,18 +240,18 @@ int elf_load_deps(const char *path, cons - - gcc_mips64_bug_work_around = 1; - #endif -- if (elf_find_section(map, PT_LOAD, &load_offset, NULL, &load_vaddr)) { -- ERROR("failed to load the .load section from %s\n", path); -- return -1; -+ if (elf_find_section(map, PT_INTERP, &interp_offset, NULL, NULL) == 0) { -+ add_path_and_deps(map+interp_offset, 1, -1, 0); - } - -- if (elf_find_section(map, PT_DYNAMIC, &dyn_offset, &dyn_size, NULL)) { -- ERROR("failed to load the .dynamic section from %s\n", path); -- return -1; -+ if (elf_find_section(map, PT_LOAD, &load_offset, NULL, &load_vaddr)) { -+ DEBUG("failed to load the .load section from %s\n", path); -+ return 0; - } - -- if (elf_find_section(map, PT_INTERP, &interp_offset, NULL, NULL) == 0) { -- add_path_and_deps(map+interp_offset, 1, -1, 0); -+ if (elf_find_section(map, PT_DYNAMIC, &dyn_offset, &dyn_size, NULL)) { -+ DEBUG("failed to load the .dynamic section from %s\n", path); -+ return 0; - } - - int clazz = map[EI_CLASS]; diff --git a/package/system/rdloader/Makefile b/package/system/rdloader/Makefile new file mode 100644 index 000000000..f042dc3c2 --- /dev/null +++ b/package/system/rdloader/Makefile @@ -0,0 +1,54 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=rdloader +PKG_VERSION:=1.0.1 +PKG_RELEASE:=1 + +PKG_LICENSE:=GPLv3 +PKG_BUILD_DEPENDS:=util-linux e2fsprogs + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/rdloader + SECTION:=base + CATEGORY:=Base system + TITLE:=kmod loader for ramdisk enviroment + DEPENDS:=@TARGET_ramips +e2fsprogs +libblkid +endef + +define Package/rdloader/description + Lightweight kmod loader for ramdisk enviroment, + support uuid-based rootfs mount +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE=Release + +define Build/InstallDev + rm -fR $(STAGING_DIR)/rdloader + mkdir -p $(STAGING_DIR)/rdloader/{bin,lib,etc} + + $(CP) $(PKG_BUILD_DIR)/rdloader $(STAGING_DIR)/rdloader/bin/ + $(CP) $(STAGING_DIR_ROOT)/usr/sbin/e2fsck $(STAGING_DIR)/rdloader/bin/ + $(CP) $(STAGING_DIR_ROOT)/etc/e2fsck.conf $(STAGING_DIR)/rdloader/etc/ + + ( \ + export \ + READELF=$(TARGET_CROSS)readelf \ + OBJCOPY=$(TARGET_CROSS)objcopy \ + XARGS="$(XARGS)"; \ + find $(STAGING_DIR)/rdloader/bin/ -type f -a -exec \ + $(SCRIPT_DIR)/gen-rddependencies.sh {} \; ; \ + ) | while read FILE; do \ + cp $(STAGING_DIR_ROOT)/lib/$$$$FILE $(STAGING_DIR)/rdloader/lib/ || \ + cp $(STAGING_DIR_ROOT)/usr/lib/$$$$FILE $(STAGING_DIR)/rdloader/lib/ \ + ; \ + done; +endef + +$(eval $(call BuildPackage,rdloader)) diff --git a/package/system/rdloader/src/CMakeLists.txt b/package/system/rdloader/src/CMakeLists.txt new file mode 100644 index 000000000..90767725e --- /dev/null +++ b/package/system/rdloader/src/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +set(CMAKE_C_STANDARD 99) +project(rdloader C) + +add_executable(rdloader main.c insmod.c insmod.h mknod.c mknod.h mkdev_node.c mkdev_node.h blkid2.c blkid2.h cmdline.c cmdline.h switch_root.c switch_root.h) + +target_link_libraries(${PROJECT_NAME} blkid) + +install(TARGETS rdloader RUNTIME DESTINATION /usr/sbin) diff --git a/package/system/rdloader/src/blkid2.c b/package/system/rdloader/src/blkid2.c new file mode 100644 index 000000000..91b79d6ab --- /dev/null +++ b/package/system/rdloader/src/blkid2.c @@ -0,0 +1,40 @@ +// +// Created by juno on 2022/1/11. +// + +#include +#include +#include +#include +#include +#include "blkid2.h" + +int get_blkid(const char *blkdev, char **uuid) +{ + blkid_probe pr; + int ret; + size_t len; + const char *data; + void *out; + + pr = blkid_new_probe_from_filename(blkdev); + if (!pr) + { + fprintf(stderr, "Failed open %s:%s\n", blkdev, strerror(errno)); + return -1; + } + + blkid_do_probe(pr); + ret = blkid_probe_lookup_value(pr, "UUID", &data, &len); + + if (ret == 0) + { + out = calloc(1, len + 1); + memcpy(out, data, len); + *uuid = out; + } + + blkid_free_probe(pr); + + return ret; +} diff --git a/package/system/rdloader/src/blkid2.h b/package/system/rdloader/src/blkid2.h new file mode 100644 index 000000000..79e16366e --- /dev/null +++ b/package/system/rdloader/src/blkid2.h @@ -0,0 +1,10 @@ +// +// Created by juno on 2022/1/11. +// + +#ifndef INIT_BLKID2_H +#define INIT_BLKID2_H + +int get_blkid(const char *blkdev, char **uuid); + +#endif //INIT_BLKID2_H diff --git a/package/system/rdloader/src/cmdline.c b/package/system/rdloader/src/cmdline.c new file mode 100644 index 000000000..7d1a1d57d --- /dev/null +++ b/package/system/rdloader/src/cmdline.c @@ -0,0 +1,209 @@ +// +// Created by juno on 2022/1/11. +// + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include "cmdline.h" + +static void insert_fstype_tail(struct fstype **head, struct fstype *fs) +{ + struct fstype *curr = *head; + struct fstype *next = NULL; + + if (!curr) + { + *head = fs; + return; + } + + do + { + next = curr->next; + if (!next) + { + curr->next = fs; + break; + } + curr = next; + } while (curr); +} + +static int parse_root(char *args, char **ret) +{ + char *root = NULL; + + if (!args) + return -1; + + if (strstr(args, "PARTUUID=") != NULL) + { + root = strtok(args, "="); + root = strtok(NULL, "="); + root = strtok(NULL, "="); + if (!root) + return -1; + + asprintf(ret, "/dev/disk/by-partuuid/%s", root); + } + else if (strstr(args, "UUID=") != NULL) + { + + root = strtok(args, "="); + root = strtok(NULL, "="); + root = strtok(NULL, "="); + + if (!root) + return -1; + + asprintf(ret, "/dev/disk/by-uuid/%s", root); + } + else if (strstr(args, "/dev/")) + { + *ret = strdup(args); + } + else + { + asprintf(ret, "/dev/%s", args); + } + + return 0; +} + +struct fstype *parse_rootfs(char **fstype_list) +{ + struct fstype *ret = NULL; + char *list = *fstype_list; + struct fstype *default_fs = NULL; + struct fstype *fs = NULL; + + if (list) + { + list = strtok(list, "="); + + while ((list = strtok(NULL, ","))) + { + fs = calloc(1, sizeof(struct fstype)); + + if (!fs) + return NULL; + + fs->name = strdup(list); + insert_fstype_tail(&ret, fs); + } + } + + default_fs = calloc(1, sizeof(struct fstype)); + default_fs->name = strdup("ext4"); + insert_fstype_tail(&ret, default_fs); + + return ret; +} + +int parse_cmdline(struct bootargs_t **ret) +{ + FILE *fp; + char *cmdline = NULL; + struct fstype *fs = NULL; + char str[1024] = {0}; + char *root = NULL; + char *rootfs = NULL; + struct bootargs_t *bootargs = NULL; + + fp = fopen("/proc/cmdline", "r"); + + if (!fp) + { + fprintf(stderr, "get cmdline failed:%s\n", strerror(errno)); + return -1; + } + + if (fgets(str, sizeof(str) - 1, fp) == NULL) + { + fprintf(stderr, "cmdline empty\n"); + fclose(fp); + return -1; + } + + fclose(fp); + + cmdline = strtok(str, " "); + + do + { + if (!cmdline) + continue; + + if (strstr(cmdline, "root=")) + root = cmdline; + if (strstr(cmdline, "rootfstype=")) + rootfs = cmdline; + + } while ((cmdline = strtok(NULL, " ")) != NULL); + + if (parse_root(root, &root) < 0) + { + fprintf(stderr, "root args error\n"); + return -1; + } + + if ((fs = parse_rootfs(&rootfs)) == NULL) + { + fprintf(stderr, "fstype error\n"); + return -1; + } + + bootargs = calloc(1, sizeof(struct bootargs_t)); + + if (!bootargs) + { + fprintf(stderr, "alloc bootargs failed\n"); + free(fs); + free(root); + return -1; + } + + bootargs->root = root; + bootargs->fstype = fs; + + *ret = bootargs; + + return 0; +} + +void free_bootargs(struct bootargs_t **args) +{ + struct bootargs_t *bootargs = *args; + struct fstype *curr = NULL; + struct fstype *next = NULL; + + if (!bootargs) + return; + + if (bootargs->root) + free(bootargs->root); + + curr = bootargs->fstype; + + do + { + if (curr) + { + if (curr->name) + free(curr->name); + + next = curr->next; + free(curr); + } + + curr = next; + + } while (curr); + + free(bootargs); +} diff --git a/package/system/rdloader/src/cmdline.h b/package/system/rdloader/src/cmdline.h new file mode 100644 index 000000000..9c8e9abaf --- /dev/null +++ b/package/system/rdloader/src/cmdline.h @@ -0,0 +1,24 @@ +// +// Created by juno on 2022/1/11. +// + +#ifndef INIT_CMDLINE_H +#define INIT_CMDLINE_H + +struct fstype +{ + char *name; + struct fstype *next; +}; + +struct bootargs_t +{ + char *root; + struct fstype *fstype; +}; + +int parse_cmdline(struct bootargs_t **ret); + +void free_bootargs(struct bootargs_t **args); + +#endif //INIT_CMDLINE_H diff --git a/package/system/rdloader/src/insmod.c b/package/system/rdloader/src/insmod.c new file mode 100644 index 000000000..4cffbd054 --- /dev/null +++ b/package/system/rdloader/src/insmod.c @@ -0,0 +1,161 @@ +// +// Created by juno on 2022/1/7. +// +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "insmod.h" + +#define init_module(module, len, opts) syscall(__NR_init_module, module, len, opts) + +#if __BYTE_ORDER == __BIG_ENDIAN +#define SWAP_BE32(x) (x) +#define SWAP_BE64(x) (x) +#else +#define SWAP_BE32(x) bswap_32(x) +#define SWAP_BE64(x) bswap_64(x) +#endif + +static char *parse_cmdline_module_options(const char **argv, int quote_space) +{ + char *options; + int optlen; + + options = calloc(1, sizeof(char)); + optlen = 0; + + while (*++argv) + { + const char *fmt; + const char *var; + const char *val; + + var = *argv; + + options = realloc(options, optlen + 2 + strlen(var) + 2); + + fmt = "%.*s%s "; + + var = strchrnul(var, '='); + + if (quote_space) + { + if (*val) + { + val++; + if (strchr(val, ' ')) + fmt = "%.*s\"%s\" "; + } + } + + optlen += sprintf(options + optlen, fmt, (int)(val - var), var, val); + } + + return options; +} + +static void *mmap_read(int fd, size_t size) +{ + return mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); +} + +static void *try_to_map_module(const char *filename, size_t *image_size_p) +{ + void *image = NULL; + struct stat st; + int fd; + + fd = open(filename, O_RDONLY); + + if (fd < 0) + { + fprintf(stderr, "open %s failed:%s\n", filename, strerror(errno)); + return NULL; + } + + fstat(fd, &st); + + if (st.st_size <= *image_size_p) + { + size_t image_size = st.st_size; + image = mmap_read(fd, image_size); + + if (image == MAP_FAILED) + { + image = NULL; + } + else if (*(u_int32_t *)image != SWAP_BE32(0x7f454C46)) + { + munmap(image, image_size); + } + else + { + *image_size_p = image_size; + } + } + + close(fd); + return image; +} + +static void *malloc_open_zipped_read_close(const char *filename, size_t *image_size_p) +{ + return NULL; +} + +int do_insmod(const char *modname, const char **argv) +{ + int mmaped = 0; + size_t image_size = INT_MAX - 4095; + void *image = NULL; + int ret; + + if (!modname) + { + return -1; + } + + char *options = *argv == NULL ? "" : parse_cmdline_module_options(argv, 0); + + image = try_to_map_module(modname, &image_size); + + if (image) + { + mmaped = 1; + } + else + { + errno = ENOMEM; + image = malloc_open_zipped_read_close(modname, &image_size); + if (!image) + return -ENOMEM; + } + + errno = 0; + + init_module(image, image_size, options); + + ret = errno; + + if (mmaped) + munmap(image, image_size); + else + free(image); + + if (ret) + { + fprintf(stderr, "insmod failed:%s\n", strerror(ret)); + } + + return ret; +} diff --git a/package/system/rdloader/src/insmod.h b/package/system/rdloader/src/insmod.h new file mode 100644 index 000000000..f938ef16f --- /dev/null +++ b/package/system/rdloader/src/insmod.h @@ -0,0 +1,10 @@ +// +// Created by juno on 2022/1/7. +// + +#ifndef INIT_INSMOD_H +#define INIT_INSMOD_H + +int do_insmod(const char *modname, const char **argv); + +#endif //INIT_INSMOD_H diff --git a/package/system/rdloader/src/main.c b/package/system/rdloader/src/main.c new file mode 100644 index 000000000..b975d67bd --- /dev/null +++ b/package/system/rdloader/src/main.c @@ -0,0 +1,257 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "insmod.h" +#include "mknod.h" +#include "mkdev_node.h" +#include "cmdline.h" +#include "switch_root.h" + +static void hang(void); + +static int mount_fs(void) +{ + int ret; + + unsigned long flags = MS_NOEXEC | MS_NOSUID | MS_RELATIME | MS_NODEV; + + ret = mount(NULL, "/proc", "proc", flags, NULL); + + if (ret < 0) + goto err; + + ret = mount(NULL, "/sys", "sysfs", flags, NULL); + + if (ret < 0) + goto err; + + ret = mount(NULL, "/dev", "tmpfs", MS_RELATIME, NULL); + + if (ret < 0) + goto err; + + return 0; +err: + ret = errno; + return ret; +} + +struct dev_node_t +{ + const char *mode; + const char *name; + char type; + uint8_t major; + uint8_t minor; +} dev_nodes[] = { + { + .mode = "0666", + .name = "/dev/tty", + .type = 'c', + .major = 5, + .minor = 0, + }, + { + .mode = "0622", + .name = "/dev/console", + .type = 'c', + .major = 5, + .minor = 1, + }, + { + .mode = "0666", + .name = "/dev/null", + .type = 'c', + .major = 1, + .minor = 3, + }, + { + .mode = "0666", + .name = "/dev/zero", + .type = 'c', + .major = 1, + .minor = 5, + }, +}; + +static int make_node(void) +{ + for (int i = 0; i < sizeof(dev_nodes) / sizeof((dev_nodes)[0]); i++) + { + if (do_mknod(dev_nodes[i].mode, dev_nodes[i].name, dev_nodes[i].type, dev_nodes[i].major, dev_nodes[i].minor) < 0) + { + if (errno == EEXIST) + continue; + + fprintf(stderr, "make %s failed:%s\n", dev_nodes[i].name, strerror(errno)); + return -1; + } + } + return 0; +} + +static int insert_kernel_module(const char *path, const char **argv) +{ + int ret; + FILE *fp = NULL; + char module_name[1024] = {0}; + + if (access(path, F_OK) != 0) + { + fprintf(stderr, "%s not found\n", path); + return -1; + } + + fp = fopen(path, "r"); + if (!fp) + { + fprintf(stderr, "open %s failed:%s\n", path, strerror(errno)); + return -1; + } + + while ((fgets(module_name, sizeof(module_name) - 1, fp)) != NULL) + { + for (int i = 0; i < sizeof(module_name); i++) + { + if (module_name[i] == '\n') + { + module_name[i] = '\0'; + break; + } + } + + ret = do_insmod(module_name, argv); + + if (ret) + { + break; + } + } + + fclose(fp); + + return ret; +} + +static void e2fsck(const char *dev_path) +{ + int pid; + pid = fork(); + if (pid < 0) + { + printf("fork failed"); + hang(); + } + if (pid == 0) + { + execl("/bin/e2fsck", "-f", "-y", dev_path); + printf("execl failed"); + hang(); + } + else + { + waitpid(pid); + } +} + +static int mount_rootfs(struct bootargs_t *bootargs) +{ + int ret = 0; + char realroot[PATH_MAX]; + struct fstype *fstype = NULL; + + // OpenWrt dont have /dev/disk/by-* yet, use realpath as workaround. + if (realpath(bootargs->root, realroot) == NULL) + return -1; + + fstype = bootargs->fstype; + + for (struct fstype *next = fstype->next; fstype; next = fstype->next, fstype = next) + { + if (strcmp(fstype->name, "ext4") == 0) + { + e2fsck(realroot); + } + ret = mount(realroot, "/root", fstype->name, MS_RELATIME, NULL); + if (ret == 0) + break; + } + + return ret; +} + +static void hang() +{ + exit(-1); + while (1) + { + } +} + +int main(int argc, const char *argv[]) +{ + int ret; + struct bootargs_t *bootargs = NULL; + + if (getpid() != 1) + { + fprintf(stderr, "must run PID 1\n"); + hang(); + } + + if ((ret = mount_fs()) < 0) + { + fprintf(stderr, "mount ramdisk fs failed:%s\n", strerror(ret)); + hang(); + } + + if (make_node() < 0) + { + fprintf(stderr, "make ramdisk dev node failed\n"); + hang(); + } + + if ((ret = parse_cmdline(&bootargs)) < 0) + { + fprintf(stderr, "cmdline format error\n"); + hang(); + } + + if (insert_kernel_module("/etc/rdloader_list", argv + 1) != 0) + { + fprintf(stderr, "failed to load kmods\n"); + hang(); + } + + printf("Waiting for root: %s\n", bootargs->root); + + do + { + ret = mkdev_node(); + + if (ret) + continue; + + ret = mount_rootfs(bootargs); + } while (ret != 0); + + free_bootargs(&bootargs); + + umount("/dev"); + umount("/proc"); + umount("/sys"); + + switch_root("/root", "/etc/preinit", argv++); + + return 0; +} diff --git a/package/system/rdloader/src/mkdev_node.c b/package/system/rdloader/src/mkdev_node.c new file mode 100644 index 000000000..9207116db --- /dev/null +++ b/package/system/rdloader/src/mkdev_node.c @@ -0,0 +1,272 @@ +// +// Created by juno on 2022/1/10. +// +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mkdev_node.h" +#include "mknod.h" +#include "blkid2.h" + +static int parse_devno(const char *devname, int *maj, int *min) +{ + FILE *fp; + char *major_s, *minor_s; + int major, minor; + char dev_path[1024] = {0}; + char dev_no[32] = {0}; + + snprintf(dev_path, sizeof(dev_path) - 1, "/sys/class/block/%s/dev", devname); + + fp = fopen(dev_path, "r"); + + if (fp == NULL) + return -1; + + if (!fgets(dev_no, 31, fp)) + return -1; + + fclose(fp); + major_s = strtok(dev_no, ":"); + minor_s = strtok(NULL, ":"); + + major = (int)strtoul(major_s, NULL, 0); + + minor = (int)strtoul(minor_s, NULL, 0); + + *maj = major; + *min = minor; + + return 0; +} + +static int mkpartion_node(const char *devname) +{ + int ret = 0; + dev_t part_devno; + dev_t disk_devno; + char *disk_name; + blkid_probe disk_pr; + blkid_partlist ls; + blkid_partition par; + const char *uuid; + char *dev_path = NULL; + + asprintf(&dev_path, "/dev/%s", devname); + + if (dev_path == NULL) + return -1; + + blkid_probe part_pr = blkid_new_probe_from_filename(dev_path); + + if (!part_pr) + { + ret = -1; + goto out1; + } + + part_devno = blkid_probe_get_devno(part_pr); + + if (!part_devno) + { + ret = -1; + goto out2; + } + + disk_devno = blkid_probe_get_wholedisk_devno(part_pr); + + if (!disk_devno) + { + ret = -1; + goto out2; + } + + disk_name = blkid_devno_to_devname(disk_devno); + + if (!disk_name) + { + ret = -1; + goto out2; + } + + disk_pr = blkid_new_probe_from_filename(disk_name); + + if (!disk_pr) + { + ret = -1; + goto out3; + } + + ls = blkid_probe_get_partitions(disk_pr); + + if (!ls) + { + ret = -1; + goto out4; + } + + par = blkid_partlist_devno_to_partition(ls, part_devno); + + uuid = blkid_partition_get_uuid(par); + + if (uuid) + { + char long_path[1024] = {0}; + snprintf(long_path, sizeof(long_path) - 1, "/dev/disk/by-partuuid/%s", uuid); + + if (access(long_path, F_OK) == 0) + goto out4; + + if (access(dev_path, F_OK) != 0) + goto out4; + + symlink(dev_path, long_path); + } + else + { + ret = -1; + } + +out4: + blkid_free_probe(disk_pr); +out3: + free(disk_name); +out2: + blkid_free_probe(part_pr); +out1: + free(dev_path); + return ret; +} + +static int dev_by_partuuit(void) +{ + DIR *dir; + DIR *disk_dir; + struct dirent *filename; + struct dirent *partname; + char *disk = NULL; + + mkdir("/dev/disk/by-partuuid", 0755); + + dir = opendir("/sys/block"); + + if (!dir) + { + return -1; + } + + while ((filename = readdir(dir))) + { + if (filename->d_type != DT_LNK) + continue; + + asprintf(&disk, "/sys/block/%s", filename->d_name); + + disk_dir = opendir(disk); + + if (disk) + free(disk); + + if (disk_dir) + { + while ((partname = readdir(disk_dir))) + { + char *dev = NULL; + asprintf(&dev, "/sys/block/%s/%s/dev", filename->d_name, partname->d_name); + + if (access(dev, F_OK) == 0) + { + mkpartion_node(partname->d_name); + } + + if (dev) + free(dev); + } + } + + closedir(disk_dir); + } + + closedir(dir); + + return 0; +} + +int mkdev_node(void) +{ + int ret; + struct dirent *filename; + DIR *dir = NULL; + char dev_path[1024]; + char uuid_node[1024]; + + dir = opendir("/sys/class/block"); + + ret = mkdir("/dev/disk", 0755); + + if (ret < 0 && errno != EEXIST) + { + fprintf(stderr, "create /dev/disk directory failed:%s\n", strerror(errno)); + return -1; + } + + ret = mkdir("/dev/disk/by-uuid", 0755); + + if (ret < 0 && errno != EEXIST) + { + fprintf(stderr, "create /dev/disk/by-uuid directory failed:%s\n", strerror(errno)); + return -1; + } + + while ((filename = readdir(dir))) + { + if (filename->d_type == DT_LNK) + { + int major, minor; + char *uuid = NULL; + + memset(dev_path, 0, sizeof(dev_path)); + + snprintf(dev_path, sizeof(dev_path) - 1, "/dev/%s", filename->d_name); + + if (access(dev_path, F_OK) == 0) + continue; + + if (parse_devno(filename->d_name, &major, &minor) < 0) + continue; + + ret = do_mknod("0755", dev_path, 'b', major, minor); + + if (ret < 0) + return ret; + + ret = get_blkid(dev_path, &uuid); + + if (ret < 0) + continue; + + memset(uuid_node, 0, sizeof(uuid_node)); + snprintf(uuid_node, sizeof(uuid_node) - 1, "/dev/disk/by-uuid/%s", uuid); + + symlink(dev_path, uuid_node); + if (uuid) + { + free(uuid); + uuid = NULL; + } + } + } + + closedir(dir); + + dev_by_partuuit(); + + return 0; +} \ No newline at end of file diff --git a/package/system/rdloader/src/mkdev_node.h b/package/system/rdloader/src/mkdev_node.h new file mode 100644 index 000000000..998b77be5 --- /dev/null +++ b/package/system/rdloader/src/mkdev_node.h @@ -0,0 +1,10 @@ +// +// Created by juno on 2022/1/10. +// + +#ifndef INIT_MKDEV_NODE_H +#define INIT_MKDEV_NODE_H + +int mkdev_node(void); + +#endif //INIT_MKDEV_NODE_H diff --git a/package/system/rdloader/src/mknod.c b/package/system/rdloader/src/mknod.c new file mode 100644 index 000000000..a1a257368 --- /dev/null +++ b/package/system/rdloader/src/mknod.c @@ -0,0 +1,217 @@ +// +// Created by juno on 2022/1/7. +// + +#include +#include +#include +#include +#include +#include +#include +#include "mknod.h" + +static const mode_t modes_cubp[] = { + S_IFIFO, + S_IFCHR, + S_IFBLK, + S_IFLNK, +}; + +#define FILEMODEBITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) + +static mode_t parse_mode(const char *s) +{ + static const mode_t who_mask[] = { + S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO, /* a */ + S_ISUID | S_IRWXU, /* u */ + S_ISGID | S_IRWXG, /* g */ + S_IRWXO /* o */ + }; + static const mode_t perm_mask[] = { + S_IRUSR | S_IRGRP | S_IROTH, /* r */ + S_IWUSR | S_IWGRP | S_IWOTH, /* w */ + S_IXUSR | S_IXGRP | S_IXOTH, /* x */ + S_IXUSR | S_IXGRP | S_IXOTH, /* X -- special -- see below */ + S_ISUID | S_ISGID, /* s */ + S_ISVTX /* t */ + }; + static const char who_chars[] ALIGN1 = "augo"; + static const char perm_chars[] ALIGN1 = "rwxXst"; + + const char *p; + mode_t wholist; + mode_t permlist; + mode_t new_mode; + char op; + + if ((unsigned char)(*s - '0') < 8) + { + unsigned long tmp; + char *e; + + tmp = strtoul(s, &e, 8); + if (*e || (tmp > 07777U)) + { /* Check range and trailing chars. */ + return -1; + } + return tmp; + } + + new_mode = 0666; + + /* Note: we allow empty clauses, and hence empty modes. + * We treat an empty mode as no change to perms. */ + + while (*s) + { /* Process clauses. */ + if (*s == ',') + { /* We allow empty clauses. */ + ++s; + continue; + } + + /* Get a wholist. */ + wholist = 0; + WHO_LIST: + p = who_chars; + do + { + if (*p == *s) + { + wholist |= who_mask[(int)(p - who_chars)]; + if (!*++s) + { + return -1; + } + goto WHO_LIST; + } + } while (*++p); + + do + { /* Process action list. */ + if ((*s != '+') && (*s != '-')) + { + if (*s != '=') + { + return -1; + } + /* Since op is '=', clear all bits corresponding to the + * wholist, or all file bits if wholist is empty. */ + permlist = ~FILEMODEBITS; + if (wholist) + { + permlist = ~wholist; + } + new_mode &= permlist; + } + op = *s++; + + /* Check for permcopy. */ + p = who_chars + 1; /* Skip 'a' entry. */ + do + { + if (*p == *s) + { + int i = 0; + permlist = who_mask[(int)(p - who_chars)] & (S_IRWXU | S_IRWXG | S_IRWXO) & new_mode; + do + { + if (permlist & perm_mask[i]) + { + permlist |= perm_mask[i]; + } + } while (++i < 3); + ++s; + goto GOT_ACTION; + } + } while (*++p); + + /* It was not a permcopy, so get a permlist. */ + permlist = 0; + PERM_LIST: + p = perm_chars; + do + { + if (*p == *s) + { + if ((*p != 'X') || (new_mode & (S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH))) + { + permlist |= perm_mask[(int)(p - perm_chars)]; + } + if (!*++s) + { + break; + } + goto PERM_LIST; + } + } while (*++p); + GOT_ACTION: + if (permlist) + { /* The permlist was nonempty. */ + mode_t tmp = wholist; + if (!wholist) + { + mode_t u_mask = umask(0); + umask(u_mask); + tmp = ~u_mask; + } + permlist &= tmp; + if (op == '-') + { + new_mode &= ~permlist; + } + else + { + new_mode |= permlist; + } + } + } while (*s && (*s != ',')); + } + + return new_mode; +} + +static mode_t char_to_mode(char type) +{ + switch (type) + { + case 'f': + return modes_cubp[0]; + case 'c': + return modes_cubp[1]; + case 'b': + return modes_cubp[2]; + case 'l': + return modes_cubp[3]; + } + + return -1; +} + +int do_mknod(const char *mod, const char *name, char type, int maj, int min) +{ + int ret; + mode_t mode; + dev_t dev; + + mode = parse_mode(mod); + if (mode != (mode_t)-1) + umask(0); + else + { + fprintf(stderr, "mode failed\n"); + return -1; + } + + dev = makedev(maj, min); + + mode |= char_to_mode(type); + + ret = mknod(name, mode, dev); + + if (ret < 0) + ret = errno; + + return ret; +} diff --git a/package/system/rdloader/src/mknod.h b/package/system/rdloader/src/mknod.h new file mode 100644 index 000000000..058095942 --- /dev/null +++ b/package/system/rdloader/src/mknod.h @@ -0,0 +1,11 @@ +// +// Created by juno on 2022/1/7. +// + +#ifndef INIT_MKNOD_H +#define INIT_MKNOD_H + +#define ALIGN1 __attribute__((aligned(1))) +int do_mknod(const char *mod, const char *name, char type, int maj, int min); + +#endif //INIT_MKNOD_H diff --git a/package/system/rdloader/src/switch_root.c b/package/system/rdloader/src/switch_root.c new file mode 100644 index 000000000..45e781cb9 --- /dev/null +++ b/package/system/rdloader/src/switch_root.c @@ -0,0 +1,108 @@ +// +// Created by juno on 2022/1/12. +// + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +#include "switch_root.h" + +static char *last_char_is(const char *s, int c) +{ + if (!s[0]) + return NULL; + while (s[1]) + s++; + + return (*s == (char)c) ? (char *)s : NULL; +} + +static char *concat_path_file(const char *path, const char *filename) +{ + char *lc; + char *ret; + + if (!path) + path = ""; + + lc = last_char_is(path, '/'); + + while (*filename == '/') + filename++; + + asprintf(&ret, "%s/%s/%s", path, (lc == NULL ? "/" : ""), filename); + + return ret; +} + +static void delete_contents(const char *directory, dev_t rootdev) +{ + DIR *dir; + struct dirent *d; + struct stat st; + + if (lstat(directory, &st) || st.st_dev != rootdev) + return; + + if (S_ISDIR(st.st_mode)) + { + dir = opendir(directory); + if (dir) + { + while ((d = readdir(dir))) + { + char *newdir = d->d_name; + + if (DOT_OR_DOTDOT(newdir)) + continue; + + newdir = concat_path_file(directory, newdir); + delete_contents(newdir, rootdev); + free(newdir); + } + closedir(dir); + rmdir(directory); + } + else + { + unlink(directory); + } + } +} + +void switch_root(const char *new_root, const char *prog, char *const argv[]) +{ + struct stat st; + dev_t root_dev; + + chdir(new_root); + stat("/", &st); + + root_dev = st.st_dev; + + stat(".", &st); + + if (st.st_dev == root_dev) + { + fprintf(stderr, "%s must be a mountpoint\n", new_root); + return; + } + + delete_contents("/", root_dev); + if (mount(".", "/", NULL, MS_MOVE, NULL)) + { + fprintf(stderr, "failed to moving root\n"); + return; + } + + chroot("."); + + execv(prog, argv); +} diff --git a/package/system/rdloader/src/switch_root.h b/package/system/rdloader/src/switch_root.h new file mode 100644 index 000000000..d88757a2d --- /dev/null +++ b/package/system/rdloader/src/switch_root.h @@ -0,0 +1,12 @@ +// +// Created by juno on 2022/1/12. +// + +#ifndef INIT_SWITCH_ROOT_H +#define INIT_SWITCH_ROOT_H + +#define DOT_OR_DOTDOT(s) ((s)[0] == '.' && (!(s)[1] || ((s)[1] == '.' && !(s)[2]))) +void switch_root(const char *newroot, const char *prog, char *const argv[]); + + +#endif //INIT_SWITCH_ROOT_H diff --git a/package/system/rpcd/Makefile b/package/system/rpcd/Makefile index 9880ea4d6..c63b8acda 100644 --- a/package/system/rpcd/Makefile +++ b/package/system/rpcd/Makefile @@ -12,10 +12,10 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/rpcd.git -PKG_SOURCE_DATE:=2021-07-13 -PKG_SOURCE_VERSION:=1fa35765ddf64976aa48950cac53d501fb71dda0 +PKG_MIRROR_HASH:=18137fa6904b1a7aec03a16a4c25fd9b9689b24ee14d431bacdda9f093339071 +PKG_SOURCE_DATE:=2022-09-21 +PKG_SOURCE_VERSION:=8c852b656bf1622dee1ae2cfa4c083f730c1c539 PKG_MAINTAINER:=Jo-Philipp Wich -PKG_MIRROR_HASH:=be116e2616b3ae1b5fb9c4c338d6908f8cc9e5de239a2c83aa21b7a69b5c1c93 PKG_LICENSE:=ISC PKG_LICENSE_FILES:= @@ -72,7 +72,7 @@ endef # 3: plugin title/description define BuildPlugin - PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_luci-rpc-mod-$(1) + PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_rpcd-mod-$(1) define Package/rpcd-mod-$(1) $(Package/rpcd/default) @@ -84,6 +84,11 @@ define BuildPlugin $(3) endef + define Package/rpcd-mod-$(1)/postinst +#!/bin/sh +[ -n "$$$${IPKG_INSTROOT}" ] || /etc/init.d/rpcd reload + endef + define Package/rpcd-mod-$(1)/install $(INSTALL_DIR) $$(1)/usr/lib/rpcd $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(1).so $$(1)/usr/lib/rpcd/ @@ -97,3 +102,4 @@ $(eval $(call BuildPackage,rpcd)) $(eval $(call BuildPlugin,file,,Provides ubus calls for file and directory operations.)) $(eval $(call BuildPlugin,rpcsys,,Provides ubus calls for sysupgrade and password changing.)) $(eval $(call BuildPlugin,iwinfo,+libiwinfo,Provides ubus calls for accessing iwinfo data.)) +$(eval $(call BuildPlugin,ucode,+libucode,Allows implementing plugins using ucode scripts.)) diff --git a/package/system/selinux-policy/Makefile b/package/system/selinux-policy/Makefile index 219ebc799..bcf6b4a3c 100644 --- a/package/system/selinux-policy/Makefile +++ b/package/system/selinux-policy/Makefile @@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=selinux-policy PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://git.defensec.nl/selinux-policy.git -PKG_VERSION:=0.9 -PKG_MIRROR_HASH:=f1a37a4fc104fbacde3012178fc117b473899360f26a8735156394288441d99c +PKG_VERSION:=1.2.3 +PKG_MIRROR_HASH:=ff1ddca168a6631aeac34352657f424bc4acf5d50b8aa7ff8dfa8c9663ba8538 PKG_SOURCE_VERSION:=v$(PKG_VERSION) PKG_BUILD_DEPENDS:=secilc/host policycoreutils/host diff --git a/package/system/ubox/Makefile b/package/system/ubox/Makefile index 9ba4abdd5..1030c14bb 100644 --- a/package/system/ubox/Makefile +++ b/package/system/ubox/Makefile @@ -1,13 +1,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ubox -PKG_RELEASE:=2 +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/ubox.git -PKG_SOURCE_DATE:=2020-10-25 -PKG_SOURCE_VERSION:=9ef886819dd48303d8ced4cdbc9afbf32682535c -PKG_MIRROR_HASH:=e2d93b798b91de98cb003f7b3be97d3d8a2413c8612b527d096c86ac5365cbdd +PKG_SOURCE_DATE:=2022-08-13 +PKG_SOURCE_VERSION:=4c7b720b9c63b826fb9404e454ae54f2ef5649d5 +PKG_MIRROR_HASH:=35178148034dfef36c5fda2bc8217617920bc1a3b86f72efbe87e85048a6a2a8 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 @@ -18,12 +18,10 @@ PKG_MAINTAINER:=John Crispin include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk -TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) - define Package/ubox SECTION:=base CATEGORY:=Base system - DEPENDS:=+libubox +ubusd +ubus +libubus +libuci +USE_GLIBC:librt + DEPENDS:=+libubox +ubusd +ubus +libubus +libuci TITLE:=OpenWrt system helper toolbox ALTERNATIVES:=\ 100:/sbin/rmmod:/sbin/kmodloader \ @@ -33,6 +31,10 @@ define Package/ubox 100:/sbin/modprobe:/sbin/kmodloader endef +define Package/ubox/conffiles +/etc/modules.conf +endef + define Package/getrandom SECTION:=base CATEGORY:=Base system @@ -42,7 +44,7 @@ endef define Package/logd SECTION:=base CATEGORY:=Base system - DEPENDS:=+libubox +libubus +libblobmsg-json +USE_GLIBC:librt + DEPENDS:=+libubox +libubus +libblobmsg-json TITLE:=OpenWrt system log implementation USERID:=logd=514:logd=514 endef @@ -53,10 +55,11 @@ define Package/getrandom/install endef define Package/ubox/install - $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin + $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin $(1)/etc $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{kmodloader,validate_data} $(1)/sbin/ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libvalidate.so $(1)/lib + $(INSTALL_DATA) ./files/modules.conf $(1)/etc/modules.conf endef define Package/logd/install diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init index c4802d419..c6fdf4429 100644 --- a/package/system/ubox/files/log.init +++ b/package/system/ubox/files/log.init @@ -34,7 +34,7 @@ start_service_daemon() { [ $log_buffer_size -eq 0 -a $log_size -gt 0 ] && log_buffer_size=$log_size [ $log_buffer_size -eq 0 ] && log_buffer_size=64 - procd_open_instance + procd_open_instance logd procd_set_param command "/sbin/logd" procd_append_param command -S "${log_buffer_size}" procd_set_param respawn 5 1 -1 @@ -52,9 +52,12 @@ start_service_file() } [ -z "${log_file}" ] && return + [ "$_BOOT" = "1" ] && + [ "$(procd_get_mountpoints "${log_file}")" ] && return 0 + mkdir -p "$(dirname "${log_file}")" - procd_open_instance + procd_open_instance logfile procd_set_param command "$PROG" -f -F "$log_file" -p "$pid_file" [ -n "${log_size}" ] && procd_append_param command -S "$log_size" procd_close_instance @@ -73,7 +76,7 @@ start_service_remote() [ -z "${log_ip}" ] && return [ -z "${log_hostname}" ] && log_hostname=$(cat /proc/sys/kernel/hostname) - procd_open_instance + procd_open_instance logremote procd_set_param command "$PROG" -f -h "$log_hostname" -r "$log_ip" "${log_port}" -p "$pid_file" case "${log_proto}" in "udp") procd_append_param command -u;; @@ -83,10 +86,17 @@ start_service_remote() procd_close_instance } +register_mount_trigger() +{ + [ -n "${log_file}" ] && procd_add_action_mount_trigger start "${log_file}" +} + service_triggers() { + config_load system procd_add_reload_trigger "system" procd_add_validation validate_log_section + config_foreach validate_log_section system register_mount_trigger } start_service() @@ -96,3 +106,7 @@ start_service() config_foreach validate_log_section system start_service_file config_foreach validate_log_section system start_service_remote } + +boot() { + _BOOT=1 start +} diff --git a/package/system/ubox/files/modules.conf b/package/system/ubox/files/modules.conf new file mode 100644 index 000000000..f54345fe4 --- /dev/null +++ b/package/system/ubox/files/modules.conf @@ -0,0 +1,3 @@ +# examples: +# options mod1 option=val +# blacklist mod2 diff --git a/package/system/ubus/Makefile b/package/system/ubus/Makefile index 9b29bf0e0..c70defcaf 100644 --- a/package/system/ubus/Makefile +++ b/package/system/ubus/Makefile @@ -1,13 +1,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ubus -PKG_RELEASE:=2 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/ubus.git -PKG_SOURCE_DATE:=2021-06-03 -PKG_SOURCE_VERSION:=a8cf678230ed163ff7a07eb1e2c872f9d655460a -PKG_MIRROR_HASH:=aee34cd1c1aa0f1a459dda0b2c6cbdb6b66e67147ebd1bcbb2a16a2ef923d008 +PKG_SOURCE_DATE:=2022-06-01 +PKG_SOURCE_VERSION:=2bebf93cd3343fe49f22a05ef935e460d2d44f67 +PKG_MIRROR_HASH:=4efd873928089c086bbac02f3ca5bae55904500b6e6f1c4c377181a00b67147f PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_SOURCE_DATE)) CMAKE_INSTALL:=1 @@ -15,7 +15,6 @@ PKG_LICENSE:=LGPL-2.1 PKG_LICENSE_FILES:= PKG_MAINTAINER:=Felix Fietkau -PKG_FLAGS := nonshared PKG_ASLR_PIE_REGULAR:=1 include $(INCLUDE_DIR)/package.mk diff --git a/package/system/uci/Makefile b/package/system/uci/Makefile index 3d9fdf739..48e5bcc4d 100644 --- a/package/system/uci/Makefile +++ b/package/system/uci/Makefile @@ -9,22 +9,19 @@ include $(TOPDIR)/rules.mk PKG_NAME:=uci -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uci.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE=2021-04-14 -PKG_SOURCE_VERSION:=4b3db1179747b6a6779029407984bacef851325c -PKG_MIRROR_HASH:=9d00b5056a0dd4094c7e19f1a0ecaffa90409f22ea28f164d0e36febd06e37d1 +PKG_SOURCE_DATE=2021-10-22 +PKG_SOURCE_VERSION:=f84f49f00fb70364f58b4cce72f1796a7190d370 +PKG_MIRROR_HASH:=9f4747a029976b43fcea9919643ce71e587e515edc21b280163f7262360d847f PKG_LICENSE:=LGPL-2.1 PKG_LICENSE_FILES:= PKG_MAINTAINER:=Felix Fietkau -PKG_BUILD_PARALLEL:=0 -PKG_FLAGS := nonshared - include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/package/system/uci/files/lib/config/uci.sh b/package/system/uci/files/lib/config/uci.sh index 8d32cd174..6ebfb73ae 100644 --- a/package/system/uci/files/lib/config/uci.sh +++ b/package/system/uci/files/lib/config/uci.sh @@ -149,6 +149,14 @@ uci_remove_list() { /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del_list "$PACKAGE.$CONFIG.$OPTION=$VALUE" } +uci_revert() { + local PACKAGE="$1" + local CONFIG="$2" + local OPTION="$3" + + /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}" +} + uci_commit() { local PACKAGE="$1" /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE diff --git a/package/system/urngd/Makefile b/package/system/urngd/Makefile index f36b492a4..bfee18470 100644 --- a/package/system/urngd/Makefile +++ b/package/system/urngd/Makefile @@ -12,8 +12,6 @@ PKG_MIRROR_HASH:=2d31025b79fe130c579d6c3f4bf4dc12abc43a7319b20a5cdca24ae363ec70f PKG_LICENSE:=GPL-2.0 BSD-3-Clause PKG_LICENSE_FILES:= -PKG_BUILD_PARALLEL:=1 - include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/package/system/urngd/patches/0001-fix-high-cpu-usage-with-docker.patch b/package/system/urngd/patches/0001-fix-high-cpu-usage-with-docker.patch index a76f7dc15..0be9c5fa2 100644 --- a/package/system/urngd/patches/0001-fix-high-cpu-usage-with-docker.patch +++ b/package/system/urngd/patches/0001-fix-high-cpu-usage-with-docker.patch @@ -1,8 +1,6 @@ -diff --git a/urngd.c b/urngd.c -index 35ccdec..410d300 100644 --- a/urngd.c +++ b/urngd.c -@@ -129,9 +129,14 @@ static size_t gather_entropy(struct urngd *u) +@@ -129,9 +129,14 @@ static size_t gather_entropy(struct urng static void low_entropy_cb(struct uloop_fd *ufd, unsigned int events) { struct urngd *u = container_of(ufd, struct urngd, rnd_fd); @@ -16,4 +14,5 @@ index 35ccdec..410d300 100644 + sleep(60); + } } - \ No newline at end of file + + static void urngd_done(struct urngd *u) diff --git a/package/system/zram-swap/Makefile b/package/system/zram-swap/Makefile index 80f87fcdf..d0d1baddd 100644 --- a/package/system/zram-swap/Makefile +++ b/package/system/zram-swap/Makefile @@ -1,14 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-only # -# Copyright (C) 2013 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# +# Copyright (C) 2013-2021 OpenWrt.org include $(TOPDIR)/rules.mk PKG_NAME:=zram-swap -PKG_RELEASE:=8 +PKG_RELEASE:=$(AUTORELEASE) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init index 3c5466737..1a9cefeff 100755 --- a/package/system/zram-swap/files/zram.init +++ b/package/system/zram-swap/files/zram.init @@ -2,9 +2,8 @@ START=15 -EXTRA_COMMANDS="compact status" -EXTRA_HELP=" compact Trigger compaction for all Z-RAM swap dev's -status Print out information & statistics about Z-RAM swap devices" +extra_command "compact" "Trigger compaction for all zram swap devices" +extra_command "status" "Print out information & statistics about zram swap devices" ram_getsize() { @@ -26,31 +25,6 @@ zram_getsize() # in megabytes fi } -zram_applicable() -{ - local zram_dev="$1" - - [ -e "$zram_dev" ] || { - logger -s -t zram_applicable -p daemon.crit "[ERROR] device '$zram_dev' not found" - return 1 - } - - [ -x /sbin/mkswap ] || { - logger -s -t zram_applicable -p daemon.err "[ERROR] 'BusyBox mkswap' not installed" - return 1 - } - - [ -x /sbin/swapon ] || { - logger -s -t zram_applicable -p daemon.err "[ERROR] 'BusyBox swapon' not installed" - return 1 - } - - [ -x /sbin/swapoff ] || { - logger -s -t zram_applicable -p daemon.err "[ERROR] 'BusyBox swapoff' not installed" - return 1 - } -} - zram_dev() { local idx="$1" @@ -86,15 +60,15 @@ zram_comp_algo() local zram_comp_algo="$( uci -q get system.@system[0].zram_comp_algo )" if [ -z "$zram_comp_algo" ]; then - # lzo-rle fails on small RAM devices, default to lzo, which is always available + # default to lzo, which is always available zram_comp_algo="lzo" fi if [ $(grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm) -ne 0 ]; then - logger -s -t zram_comp_algo -p daemon.debug "Set compression algorithm '$zram_comp_algo' for zram '$dev'" + logger -s -t zram_comp_algo -p daemon.debug "set compression algorithm '$zram_comp_algo' for zram '$dev'" echo $zram_comp_algo > "/sys/block/$( basename $dev )/comp_algorithm" else - logger -s -t zram_comp_algo -p daemon.debug "Compression algorithm '$zram_comp_algo' is not supported for '$dev'" + logger -s -t zram_comp_algo -p daemon.debug "compression algorithm '$zram_comp_algo' is not supported for '$dev'" fi } @@ -105,7 +79,7 @@ zram_stats() printf "\nGathering stats info for zram device \"$( basename "$1" )\"\n\n" - printf "Z-RAM\n-----\n" + printf "ZRAM\n----\n" printf "%-25s - %s\n" "Block device" $zdev awk '{ printf "%-25s - %d MiB\n", "Device size", $1/1024/1024 }' <$zdev/disksize printf "%-25s - %s\n" "Compression algo" "$(cat $zdev/comp_algorithm)" @@ -157,23 +131,31 @@ start() } if [ $( grep -cs zram /proc/swaps ) -ne 0 ]; then - logger -s -t zram_start -p daemon.notice "[OK] zram swap is already mounted" + logger -s -t zram_start -p daemon.notice "zram swap is already mounted" return 1 fi - local zram_size="$( zram_getsize )" local zram_dev="$( zram_getdev )" - zram_applicable "$zram_dev" || return 1 - local zram_priority="$( uci -q get system.@system[0].zram_priority )" - zram_priority=${zram_priority:+-p $zram_priority} - logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)" + [ -e "$zram_dev" ] || { + logger -s -t zram_start -p daemon.crit "[ERROR] device '$zram_dev' not found" + return 1 + } + + local zram_size="$( zram_getsize )" + local zram_priority="$( uci -q get system.@system[0].zram_priority )" + + if [ -z "$zram_priority" ]; then + zram_priority="100" + fi + + logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MiB)" zram_reset "$zram_dev" "enforcing defaults" zram_comp_algo "$zram_dev" echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize" - /sbin/mkswap "$zram_dev" - /sbin/swapon -d $zram_priority "$zram_dev" + busybox mkswap "$zram_dev" + busybox swapon -d -p $zram_priority "$zram_dev" } stop() @@ -182,7 +164,7 @@ stop() for zram_dev in $( grep zram /proc/swaps |awk '{print $1}' ); do { logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev" - /sbin/swapoff "$zram_dev" && zram_reset "$zram_dev" "claiming memory back" + busybox swapoff "$zram_dev" && zram_reset "$zram_dev" "claiming memory back" local dev_index="$( echo $zram_dev | grep -o "[0-9]*$" )" if [ $dev_index -ne 0 ]; then logger -s -t zram_stop -p daemon.debug "removing zram $zram_dev" diff --git a/package/utils/bcm27xx-userland/Makefile b/package/utils/bcm27xx-userland/Makefile index 098c039f1..857db7969 100644 --- a/package/utils/bcm27xx-userland/Makefile +++ b/package/utils/bcm27xx-userland/Makefile @@ -8,16 +8,18 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bcm27xx-userland -PKG_VERSION:=4a0a19b88b43e48c6b51b526b9378289fb712a4c -PKG_RELEASE:=1 +PKG_VERSION:=c4fd1b8986c6d6d4ae5cd51e65a8bbeb495dfa4e +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/raspberrypi/userland/tar.gz/$(PKG_VERSION)? -PKG_HASH:=0f42d48095d1f680cbe8781c2e974b76bdd0507aaef64cce8b8b472ca3a09588 +PKG_HASH:=ab8a5b27c34cf1b97de87b895448a6355229f73b679866b47c51a723273cc8ae PKG_FLAGS:=nonshared PKG_MAINTAINER:=Álvaro Fernández Rojas +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=LICENCE CMAKE_INSTALL:=1 CMAKE_OPTIONS+=-DVMCS_INSTALL_PREFIX=/usr @@ -46,6 +48,19 @@ define Package/bcm27xx-userland/description BCM27xx userland tools including vcgencmd and tvservice. endef +define Package/bcm27xx-userland-dev + SECTION:=devel + CATEGORY:=Development + SUBMENU:=Libraries + DEPENDS:=@TARGET_bcm27xx +bcm27xx-userland + TITLE:=Development files of BCM27xx userland tools +endef + +define Package/bcm27xx-userland-dev/description + This package contains the header and static libraries of + the BCM27xx userland tools. +endef + define Package/bcm27xx-userland/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtmerge $(1)/usr/bin @@ -61,11 +76,22 @@ endif $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vcgencmd $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vcmailbox $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(1)/usr/lib/ +ifneq ($(ARCH),aarch64) + $(INSTALL_DIR) $(1)/usr/lib/plugins + $(CP) $(PKG_INSTALL_DIR)/usr/lib/plugins/ $(1)/usr/lib/ +endif +endef + +define Package/bcm27xx-userland-dev/install $(INSTALL_DIR) $(1)/usr/include $(CP) $(PKG_INSTALL_DIR)/usr/include/ $(1)/usr/ - $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/ $(1)/usr/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.a $(1)/usr/lib/ endef $(eval $(call BuildPackage,bcm27xx-userland)) +$(eval $(call BuildPackage,bcm27xx-userland-dev)) diff --git a/package/utils/bcm4908img/Makefile b/package/utils/bcm4908img/Makefile index c18ac958f..fbb91fba7 100644 --- a/package/utils/bcm4908img/Makefile +++ b/package/utils/bcm4908img/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bcm4908img -PKG_RELEASE:=1 +PKG_RELEASE:=3 PKG_FLAGS:=nonshared diff --git a/package/utils/bcm4908img/src/bcm4908img.c b/package/utils/bcm4908img/src/bcm4908img.c index 402d31719..240fe895d 100644 --- a/package/utils/bcm4908img/src/bcm4908img.c +++ b/package/utils/bcm4908img/src/bcm4908img.c @@ -77,13 +77,14 @@ struct bcm4908img_tail { * 4. padding ├─ firmware * 5. rootfs ─┘ * 6. BCM4908 tail + * 7. (Optional) vendor tail */ struct bcm4908img_info { - size_t file_size; size_t cferom_offset; size_t bootfs_offset; size_t padding_offset; size_t rootfs_offset; + size_t tail_offset; uint32_t crc32; /* Calculated checksum */ struct bcm4908img_tail tail; }; @@ -219,7 +220,7 @@ static int bcm4908img_calc_crc32(FILE *fp, struct bcm4908img_info *info) { fseek(fp, info->cferom_offset, SEEK_SET); info->crc32 = 0xffffffff; - length = info->file_size - info->cferom_offset - sizeof(struct bcm4908img_tail); + length = info->tail_offset - info->cferom_offset; while (length && (bytes = fread(buf, 1, bcm4908img_min(sizeof(buf), length), fp)) > 0) { info->crc32 = bcm4908img_crc32(info->crc32, buf, bytes); length -= bytes; @@ -249,6 +250,16 @@ struct chk_header { char board_id[0]; }; +struct linksys_tail { + char magic[9]; + uint8_t version[8]; + char model[15]; + uint32_t crc32; + uint8_t padding[9]; + uint8_t signature[16]; + uint8_t reserved[192]; +}; + static bool bcm4908img_is_all_ff(const void *buf, size_t length) { const uint8_t *in = buf; @@ -264,9 +275,11 @@ static bool bcm4908img_is_all_ff(const void *buf, size_t length) static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { struct bcm4908img_tail *tail = &info->tail; + struct linksys_tail *linksys; struct chk_header *chk; struct stat st; uint8_t buf[1024]; + size_t file_size; uint16_t tmp16; size_t length; size_t bytes; @@ -281,7 +294,9 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { fprintf(stderr, "Failed to fstat: %d\n", err); return err; } - info->file_size = st.st_size; + file_size = st.st_size; + + info->tail_offset = file_size - sizeof(*tail); /* Vendor formats */ @@ -294,10 +309,20 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { if (be32_to_cpu(chk->magic) == 0x2a23245e) info->cferom_offset = be32_to_cpu(chk->header_len); + fseek(fp, -sizeof(buf), SEEK_END); + if (fread(buf, 1, sizeof(buf), fp) != sizeof(buf)) { + fprintf(stderr, "Failed to read file header\n"); + return -EIO; + } + linksys = (void *)(buf + sizeof(buf) - sizeof(*linksys)); + if (!memcmp(linksys->magic, ".LINKSYS.", sizeof(linksys->magic))) { + info->tail_offset -= sizeof(*linksys); + } + /* Offsets */ for (info->bootfs_offset = info->cferom_offset; - info->bootfs_offset < info->file_size; + info->bootfs_offset < info->tail_offset; info->bootfs_offset += 0x20000) { if (fseek(fp, info->bootfs_offset, SEEK_SET)) { err = -errno; @@ -311,13 +336,13 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { if (be16_to_cpu(tmp16) == 0x8519) break; } - if (info->bootfs_offset >= info->file_size) { + if (info->bootfs_offset >= info->tail_offset) { fprintf(stderr, "Failed to find bootfs offset\n"); return -EPROTO; } for (info->rootfs_offset = info->bootfs_offset; - info->rootfs_offset < info->file_size; + info->rootfs_offset < info->tail_offset; info->rootfs_offset += 0x20000) { uint32_t *magic = (uint32_t *)&buf[0]; @@ -340,7 +365,7 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { if (be32_to_cpu(*magic) == UBI_EC_HDR_MAGIC) break; } - if (info->rootfs_offset >= info->file_size) { + if (info->rootfs_offset >= info->tail_offset) { fprintf(stderr, "Failed to find rootfs offset\n"); return -EPROTO; } @@ -351,7 +376,7 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { fseek(fp, info->cferom_offset, SEEK_SET); info->crc32 = 0xffffffff; - length = info->file_size - info->cferom_offset - sizeof(*tail); + length = info->tail_offset - info->cferom_offset; while (length && (bytes = fread(buf, 1, bcm4908img_min(sizeof(buf), length), fp)) > 0) { info->crc32 = bcm4908img_crc32(info->crc32, buf, bytes); length -= bytes; @@ -617,10 +642,10 @@ static int bcm4908img_extract(int argc, char **argv) { length = (info.padding_offset ? info.padding_offset : info.rootfs_offset) - offset; } else if (!strcmp(type, "rootfs")) { offset = info.rootfs_offset; - length = info.file_size - offset - sizeof(struct bcm4908img_tail); + length = info.tail_offset - offset; } else if (!strcmp(type, "firmware")) { offset = info.bootfs_offset; - length = info.file_size - offset - sizeof(struct bcm4908img_tail); + length = info.tail_offset - offset; } else { err = -EINVAL; fprintf(stderr, "Unsupported extract type: %s\n", type); diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in index 940b32d68..abe6d5431 100644 --- a/package/utils/busybox/Config-defaults.in +++ b/package/utils/busybox/Config-defaults.in @@ -336,10 +336,10 @@ config BUSYBOX_DEFAULT_FEATURE_GUNZIP_LONG_OPTIONS default n config BUSYBOX_DEFAULT_BUNZIP2 bool - default y + default n config BUSYBOX_DEFAULT_BZCAT bool - default y + default n config BUSYBOX_DEFAULT_UNLZMA bool default n diff --git a/package/utils/busybox/files/cron b/package/utils/busybox/files/cron index 28985ff18..4efdfa52c 100755 --- a/package/utils/busybox/files/cron +++ b/package/utils/busybox/files/cron @@ -4,7 +4,7 @@ START=50 USE_PROCD=1 -PROG=crond +PROG=/usr/sbin/crond validate_cron_section() { uci_validate_section system system "${1}" \ diff --git a/package/utils/busybox/patches/220-add_lock_util.patch b/package/utils/busybox/patches/220-add_lock_util.patch index 4e46b74f0..579b705f3 100644 --- a/package/utils/busybox/patches/220-add_lock_util.patch +++ b/package/utils/busybox/patches/220-add_lock_util.patch @@ -72,9 +72,9 @@ + +static int do_lock(void) +{ -+ int pid; ++ pid_t pid; + int flags; -+ char pidstr[8]; ++ char pidstr[12]; + + if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) { + if ((fd = open(file, O_RDWR)) < 0) { @@ -109,7 +109,7 @@ + if (!waitonly) { + lseek(fd, 0, SEEK_SET); + ftruncate(fd, 0); -+ sprintf(pidstr, "%d\n", pid); ++ snprintf(pidstr, sizeof(pidstr), "%d\n", pid); + write(fd, pidstr, strlen(pidstr)); + close(fd); + } diff --git a/package/utils/busybox/patches/530-nslookup-ensure-unique-transaction-IDs-for-the-DNS-queries.patch b/package/utils/busybox/patches/530-nslookup-ensure-unique-transaction-IDs-for-the-DNS-queries.patch new file mode 100644 index 000000000..caa5ee78f --- /dev/null +++ b/package/utils/busybox/patches/530-nslookup-ensure-unique-transaction-IDs-for-the-DNS-queries.patch @@ -0,0 +1,42 @@ +From: Uwe Kleine-König +Date: Sat, 8 Oct 2022 19:22:52 +0200 +Subject: [PATCH] nslookup: ensure unique transaction IDs for the DNS queries + +The transaction IDs generated by res_mkquery() for both glibc and musl only +depends on the state of the monotonic clock. +For some machines (here: a TP-Link RE200 powered by a MediaTek MT7620A) +the monotonic clock has a coarse resolution (here: 20 µs) and it can happen +that the requests for A and AAAA share the same transaction ID. + +In that case the mapping from received responses to the sent queries +doesn't work and name resolution fails as follows: + + # /bin/busybox nslookup heise.de + Server: 127.0.0.1 + Address: 127.0.0.1:53 + + Non-authoritative answer: + Name: heise.de + Address: 193.99.144.80 + + *** Can't find heise.de: No answer + +because the AAAA reply is dropped as a duplicate reply to the A query. + +To prevent this make sure the transaction IDs are unique. + +Forwarded: http://lists.busybox.net/pipermail/busybox/2022-October/089911.html +--- +--- a/networking/nslookup.c ++++ b/networking/nslookup.c +@@ -978,6 +978,10 @@ int nslookup_main(int argc UNUSED_PARAM, + } + } + ++ /* Ensure the Transaction IDs are unique */ ++ for (rc = 1; rc < G.query_count; rc++) ++ G.query[rc].query[1] = G.query[rc - 1].query[1] + 1; ++ + for (rc = 0; rc < G.serv_count;) { + int c; + diff --git a/package/utils/busybox/patches/900-add-e-f-option-for-docker.patch b/package/utils/busybox/patches/900-add-e-f-option-for-docker.patch index cf2b68305..41f1b0098 100644 --- a/package/utils/busybox/patches/900-add-e-f-option-for-docker.patch +++ b/package/utils/busybox/patches/900-add-e-f-option-for-docker.patch @@ -1,6 +1,6 @@ --- a/procps/ps.c -+++ a/procps/ps.c -@@ -665,7 +665,7 @@ ++++ b/procps/ps.c +@@ -668,7 +668,7 @@ int ps_main(int argc UNUSED_PARAM, char int w_count = 0; make_all_argv_opts(argv); opts = getopt32(argv, "^" diff --git a/package/utils/checkpolicy/Makefile b/package/utils/checkpolicy/Makefile index 206bf201c..e9c10e293 100644 --- a/package/utils/checkpolicy/Makefile +++ b/package/utils/checkpolicy/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=checkpolicy -PKG_VERSION:=3.2 +PKG_VERSION:=3.3 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=9b1c81fa86fe3867842164448d90c8e7ea94b2987497809c65d4caa87a5c5bc8 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=25c84edfa3a10ab8cb073b97bc55cb66377532d54a2723da9accdabd05431485 PKG_INSTALL:=1 PKG_BUILD_DEPENDS:=libselinux HOST_BUILD_DEPENDS:=libselinux/host diff --git a/package/utils/e2fsprogs/Makefile b/package/utils/e2fsprogs/Makefile index b131cdcca..94f22a53c 100644 --- a/package/utils/e2fsprogs/Makefile +++ b/package/utils/e2fsprogs/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=e2fsprogs PKG_VERSION:=1.46.5 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/kernel/people/tytso/e2fsprogs/v$(PKG_VERSION)/ @@ -144,7 +144,6 @@ endef TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections -flto -TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) TARGET_LDFLAGS += -flto CONFIGURE_ARGS += \ diff --git a/package/utils/e2fsprogs/patches/004-CVE-2022-1304-libext2fs-add-sanity-check-to-extent-manipulation.patch b/package/utils/e2fsprogs/patches/004-CVE-2022-1304-libext2fs-add-sanity-check-to-extent-manipulation.patch new file mode 100644 index 000000000..e5a76161f --- /dev/null +++ b/package/utils/e2fsprogs/patches/004-CVE-2022-1304-libext2fs-add-sanity-check-to-extent-manipulation.patch @@ -0,0 +1,50 @@ +From ab51d587bb9b229b1fade1afd02e1574c1ba5c76 Mon Sep 17 00:00:00 2001 +From: Lukas Czerner +Date: Thu, 21 Apr 2022 19:31:48 +0200 +Subject: libext2fs: add sanity check to extent manipulation + +It is possible to have a corrupted extent tree in such a way that a leaf +node contains zero extents in it. Currently if that happens and we try +to traverse the tree we can end up accessing wrong data, or possibly +even uninitialized memory. Make sure we don't do that. + +Additionally make sure that we have a sane number of bytes passed to +memmove() in ext2fs_extent_delete(). + +Note that e2fsck is currently unable to spot and fix such corruption in +pass1. + +Signed-off-by: Lukas Czerner +Reported-by: Nils Bars +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2068113 +Addresses: CVE-2022-1304 +Addresses-Debian-Bug: #1010263 +Signed-off-by: Theodore Ts'o +--- + lib/ext2fs/extent.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/lib/ext2fs/extent.c ++++ b/lib/ext2fs/extent.c +@@ -495,6 +495,10 @@ retry: + ext2fs_le16_to_cpu(eh->eh_entries); + newpath->max_entries = ext2fs_le16_to_cpu(eh->eh_max); + ++ /* Make sure there is at least one extent present */ ++ if (newpath->left <= 0) ++ return EXT2_ET_EXTENT_NO_DOWN; ++ + if (path->left > 0) { + ix++; + newpath->end_blk = ext2fs_le32_to_cpu(ix->ei_block); +@@ -1630,6 +1634,10 @@ errcode_t ext2fs_extent_delete(ext2_exte + + cp = path->curr; + ++ /* Sanity check before memmove() */ ++ if (path->left < 0) ++ return EXT2_ET_EXTENT_LEAF_BAD; ++ + if (path->left) { + memmove(cp, cp + sizeof(struct ext3_extent_idx), + path->left * sizeof(struct ext3_extent_idx)); diff --git a/package/utils/f2fs-tools/Makefile b/package/utils/f2fs-tools/Makefile index 0d243302c..99d402af6 100644 --- a/package/utils/f2fs-tools/Makefile +++ b/package/utils/f2fs-tools/Makefile @@ -8,16 +8,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=f2fs-tools -PKG_VERSION:=1.14.0 +PKG_VERSION:=1.15.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/snapshot/ -PKG_HASH:=619263d4e2022152a1472c1d912eaae104f20bd227ce0bb9d41d1d6608094bd1 +PKG_HASH:=147d471040b44900283ce2c935f1d35d13d7f40008e7cb8fab2b69f54da01a4f PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:=COPYING +PKG_CPE_ID:=cpe:/a:f2fs-tools_project:f2fs-tools PKG_FIXUP:=autoreconf PKG_BUILD_PARALLEL:=1 @@ -85,6 +86,7 @@ define Package/libf2fs DEPENDS:=+libuuid ABI_VERSION:=6 CONFLICTS:=libf2fs-selinux + VARIANT:=default endef define Package/libf2fs-selinux @@ -93,11 +95,14 @@ define Package/libf2fs-selinux TITLE:=Library for Flash-Friendly File System (F2FS) tools with SELinux support DEPENDS:=+libuuid +libselinux ABI_VERSION:=6 + VARIANT:=selinux endef CONFIGURE_ARGS += \ --disable-static \ - --without-blkid + --without-blkid \ + --without-lzo2 \ + --without-lz4 ifneq ($(BUILD_VARIANT),selinux) CONFIGURE_ARGS += --without-selinux diff --git a/package/utils/f2fs-tools/patches/100-configure.ac-fix-AC_ARG_WITH.patch b/package/utils/f2fs-tools/patches/100-configure.ac-fix-AC_ARG_WITH.patch new file mode 100644 index 000000000..a7fb50a63 --- /dev/null +++ b/package/utils/f2fs-tools/patches/100-configure.ac-fix-AC_ARG_WITH.patch @@ -0,0 +1,88 @@ +From 9af8ee5baceab59d46154c96da62b52935f363fe Mon Sep 17 00:00:00 2001 +From: Nick Hainke +Date: Mon, 27 Jun 2022 20:43:11 +0200 +Subject: [PATCH] configure.ac: fix AC_ARG_WITH + +In the new version the configuration no longer respects the +--without/--with blkid/selinux parameters. Add the tests for +"with_blkid" and "with_selinux" back to configure.ac as described +in the manual. + +Link: https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/External-Software.html + +Fixes: c48335416a09 ("configure.ac: Enable cross-compilation") + +Signed-off-by: Nick Hainke +--- + configure.ac | 44 ++++++++++++++++++++++++++++++-------------- + 1 file changed, 30 insertions(+), 14 deletions(-) + +--- a/configure.ac ++++ b/configure.ac +@@ -39,12 +39,16 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign + + # Test configure options. + AC_ARG_WITH([selinux], +- AS_HELP_STRING([--without-selinux], +- [Ignore presence of libselinux and disable selinux support])) ++ [AS_HELP_STRING([--without-selinux], ++ [Ignore presence of libselinux and disable selinux support])], ++ [], ++ [with_selinux=check]) + + AC_ARG_WITH([blkid], +- AS_HELP_STRING([--without-blkid], +- [Ignore presence of libblkid and disable blkid support])) ++ [AS_HELP_STRING([--without-blkid], ++ [Ignore presence of libblkid and disable blkid support])], ++ [], ++ [with_blkid=check]) + + # Checks for programs. + AC_PROG_CC +@@ -55,11 +59,17 @@ AC_PATH_PROG([LDCONFIG], [ldconfig], + [$PATH:/sbin]) + + # Checks for libraries. +-AC_CHECK_LIB([blkid], [blkid_probe_all], +- [AC_SUBST([libblkid_LIBS], ["-lblkid"]) +- AC_DEFINE([HAVE_LIBBLKID], [1], +- [Define if you have libblkid]) +- ], [], []) ++AS_IF([test "x$with_blkid" != xno], ++ [AC_CHECK_LIB([blkid], [blkid_probe_all], ++ [AC_SUBST([libblkid_LIBS], ["-lblkid"]) ++ AC_DEFINE([HAVE_LIBBLKID], [1], ++ [Define if you have libblkid]) ++ ], ++ [if test "x$with_blkid" != xcheck; then ++ AC_MSG_FAILURE( ++ [--with-blkid was given, but test for blkid failed]) ++ fi ++ ], -lblkid)]) + + AC_CHECK_LIB([lzo2], [main], + [AC_SUBST([liblzo2_LIBS], ["-llzo2"]) +@@ -73,11 +83,17 @@ AC_CHECK_LIB([lz4], [main], + [Define if you have liblz4]) + ], [], []) + +-AC_CHECK_LIB([selinux], [getcon], +- [AC_SUBST([libselinux_LIBS], ["-lselinux"]) +- AC_DEFINE([HAVE_LIBSELINUX], [1], +- [Define if you have libselinux]) +- ], [], []) ++AS_IF([test "x$with_selinux" != xno], ++ [AC_CHECK_LIB([selinux], [getcon], ++ [AC_SUBST([libselinux_LIBS], ["-lselinux"]) ++ AC_DEFINE([HAVE_LIBSELINUX], [1], ++ [Define if you have libselinux]) ++ ], ++ [if test "x$with_selinux" != xcheck; then ++ AC_MSG_FAILURE( ++ [--with-selinux was given, but test for selinux failed]) ++ fi ++ ], -lselinux)]) + + AC_CHECK_LIB([uuid], [uuid_clear], + [AC_SUBST([libuuid_LIBS], ["-luuid"]) diff --git a/package/utils/f2fs-tools/patches/101-configure.ac-fix-cross-compilation.patch b/package/utils/f2fs-tools/patches/101-configure.ac-fix-cross-compilation.patch new file mode 100644 index 000000000..b9edd6634 --- /dev/null +++ b/package/utils/f2fs-tools/patches/101-configure.ac-fix-cross-compilation.patch @@ -0,0 +1,80 @@ +From 821a1d3fcce31c234512a8f4dc4fc97dfbd7ae32 Mon Sep 17 00:00:00 2001 +From: Nick Hainke +Date: Mon, 4 Jul 2022 09:46:10 +0200 +Subject: [PATCH] configure.ac: fix cross compilation + +AC_CHECK_LIB seems to not work correctly with OpenWrt. Add possibility +to disable lz4 and lzo2 manually. + +Fixes errors in the form of: + Package f2fsck is missing dependencies for the following libraries: + liblz4.so.1 + liblzo2.so.2 + +Signed-off-by: Nick Hainke +--- + configure.ac | 44 ++++++++++++++++++++++++++++++++++---------- + 1 file changed, 34 insertions(+), 10 deletions(-) + +--- a/configure.ac ++++ b/configure.ac +@@ -50,6 +50,18 @@ AC_ARG_WITH([blkid], + [], + [with_blkid=check]) + ++AC_ARG_WITH([lzo2], ++ [AS_HELP_STRING([--without-lzo2], ++ [Ignore presence of liblzo2 and disable lzo2 support])], ++ [], ++ [with_lzo2=check]) ++ ++AC_ARG_WITH([lz4], ++ [AS_HELP_STRING([--without-lz4], ++ [Ignore presence of liblz4 and disable lz4 support])], ++ [], ++ [with_lz4=check]) ++ + # Checks for programs. + AC_PROG_CC + AM_PROG_AR +@@ -71,17 +83,29 @@ AS_IF([test "x$with_blkid" != xno], + fi + ], -lblkid)]) + +-AC_CHECK_LIB([lzo2], [main], +- [AC_SUBST([liblzo2_LIBS], ["-llzo2"]) +- AC_DEFINE([HAVE_LIBLZO2], [1], +- [Define if you have liblzo2]) +- ], [], []) +- +-AC_CHECK_LIB([lz4], [main], +- [AC_SUBST([liblz4_LIBS], ["-llz4"]) +- AC_DEFINE([HAVE_LIBLZ4], [1], +- [Define if you have liblz4]) +- ], [], []) ++AS_IF([test "x$with_lzo2" != xno], ++ [AC_CHECK_LIB([lzo2], [main], ++ [AC_SUBST([liblzo2_LIBS], ["-llzo2"]) ++ AC_DEFINE([HAVE_LIBLZO2], [1], ++ [Define if you have liblzo2]) ++ ], ++ [if test "x$with_lzo2" != xcheck; then ++ AC_MSG_FAILURE( ++ [--with-lzo2 was given, but test for lzo2 failed]) ++ fi ++ ], -llzo2)]) ++ ++AS_IF([test "x$with_lz4" != xno], ++ [AC_CHECK_LIB([lz4], [main], ++ [AC_SUBST([liblz4_LIBS], ["-llz4"]) ++ AC_DEFINE([HAVE_LIBLZ4], [1], ++ [Define if you have liblz4]) ++ ], ++ [if test "x$with_lz4" != xcheck; then ++ AC_MSG_FAILURE( ++ [--with-lz4 was given, but test for lz4 failed]) ++ fi ++ ], -llz4)]) + + AS_IF([test "x$with_selinux" != xno], + [AC_CHECK_LIB([selinux], [getcon], diff --git a/package/utils/fritz-tools/src/fritz_tffs_nand_read.c b/package/utils/fritz-tools/src/fritz_tffs_nand_read.c index ded0577cf..05179bb42 100644 --- a/package/utils/fritz-tools/src/fritz_tffs_nand_read.c +++ b/package/utils/fritz-tools/src/fritz_tffs_nand_read.c @@ -73,21 +73,18 @@ static uint8_t readbuf[TFFS_SECTOR_SIZE]; static uint8_t oobbuf[TFFS_SECTOR_OOB_SIZE]; static uint32_t blocksize; static int mtdfd; -struct tffs_sectors *sectors; - -struct tffs_sectors { - uint32_t num_sectors; - uint8_t sectors[0]; -}; +static uint32_t num_sectors; +static uint8_t *sectors; +static uint32_t *sector_ids; static inline void sector_mark_bad(int num) { - sectors->sectors[num / 8] &= ~(0x80 >> (num % 8)); + sectors[num / 8] &= ~(0x80 >> (num % 8)); }; static inline uint8_t sector_get_good(int num) { - return sectors->sectors[num / 8] & 0x80 >> (num % 8); + return sectors[num / 8] & 0x80 >> (num % 8); }; struct tffs_entry_segment { @@ -139,6 +136,8 @@ static int read_sector(off_t pos) return -1; } + sector_ids[pos / TFFS_SECTOR_SIZE] = read_uint32(readbuf, 0x00); + return 0; } @@ -176,25 +175,39 @@ static int find_entry(uint32_t id, struct tffs_entry *entry) off_t pos = 0; uint8_t block_end = 0; - for (uint32_t sector = 0; sector < sectors->num_sectors; sector++, pos += TFFS_SECTOR_SIZE) { + for (uint32_t sector = 0; sector < num_sectors; sector++, pos += TFFS_SECTOR_SIZE) { if (block_end) { if (pos % blocksize == 0) { block_end = 0; } } else if (sector_get_good(sector)) { + if (sector_ids[sector]) { + if (sector_ids[sector] == TFFS_ID_END) { + /* no more entries in this block */ + block_end = 1; + continue; + } + + if (sector_ids[sector] != id) + continue; + } + if (read_sectoroob(pos) || read_sector(pos)) { fprintf(stderr, "ERROR: sector isn't readable, but has been previously!\n"); exit(EXIT_FAILURE); } - uint32_t oob_id = read_uint32(oobbuf, 0x02); - uint32_t oob_len = read_uint32(oobbuf, 0x06); - uint32_t oob_rev = read_uint32(oobbuf, 0x0a); uint32_t read_id = read_uint32(readbuf, 0x00); uint32_t read_len = read_uint32(readbuf, 0x04); uint32_t read_rev = read_uint32(readbuf, 0x0c); - if (read_oob_sector_health && (oob_id != read_id || oob_len != read_len || oob_rev != read_rev)) { - fprintf(stderr, "Warning: sector has inconsistent metadata\n"); - continue; + if (read_oob_sector_health) { + uint32_t oob_id = read_uint32(oobbuf, 0x02); + uint32_t oob_len = read_uint32(oobbuf, 0x06); + uint32_t oob_rev = read_uint32(oobbuf, 0x0a); + + if (oob_id != read_id || oob_len != read_len || oob_rev != read_rev) { + fprintf(stderr, "Warning: sector has inconsistent metadata\n"); + continue; + } } if (read_id == TFFS_ID_END) { /* no more entries in this block */ @@ -340,7 +353,7 @@ static int show_matching_key_value(struct tffs_key_name_table *key_names) for (uint32_t i = 0; i < key_names->size; i++) { name = key_names->entries[i].val; - if (strncmp(name, name_filter, strlen(name)) == 0) { + if (strcmp(name, name_filter) == 0) { if (find_entry(key_names->entries[i].id, &tmp)) { print_entry_value(&tmp); printf("\n"); @@ -414,13 +427,14 @@ static int scan_mtd(void) blocksize = info.erasesize; - sectors = malloc(sizeof(*sectors) + (info.size / TFFS_SECTOR_SIZE + 7) / 8); - if (sectors == NULL) { + num_sectors = info.size / TFFS_SECTOR_SIZE; + sectors = malloc((num_sectors + 7) / 8); + sector_ids = calloc(num_sectors, sizeof(uint32_t)); + if (!sectors || !sector_ids) { fprintf(stderr, "ERROR: memory allocation failed!\n"); exit(EXIT_FAILURE); } - sectors->num_sectors = info.size / TFFS_SECTOR_SIZE; - memset(sectors->sectors, 0xff, (info.size / TFFS_SECTOR_SIZE + 7) / 8); + memset(sectors, 0xff, (num_sectors + 7) / 8); uint32_t sector = 0, valid_blocks = 0; uint8_t block_ok = 0; @@ -564,6 +578,7 @@ int main(int argc, char *argv[]) out_free_entry: free(name_table.val); out_free_sectors: + free(sector_ids); free(sectors); out_close: close(mtdfd); diff --git a/package/utils/fritz-tools/src/fritz_tffs_read.c b/package/utils/fritz-tools/src/fritz_tffs_read.c index d1b3038e6..256c34c41 100644 --- a/package/utils/fritz-tools/src/fritz_tffs_read.c +++ b/package/utils/fritz-tools/src/fritz_tffs_read.c @@ -204,7 +204,7 @@ static int show_matching_key_value(uint8_t *buffer, for (i = 0; i < key_names->size; i++) { name = key_names->entries[i].val; - if (strncmp(name, name_filter, strlen(name)) == 0) { + if (strcmp(name, name_filter) == 0) { id = to_entry_header_id(*key_names->entries[i].id); if (find_entry(buffer, id, &tmp)) { diff --git a/package/utils/lua/Makefile b/package/utils/lua/Makefile index ac85ef24b..e4d2fd1c5 100644 --- a/package/utils/lua/Makefile +++ b/package/utils/lua/Makefile @@ -9,14 +9,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lua PKG_VERSION:=5.1.5 -PKG_RELEASE:=9 +PKG_RELEASE:=10 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://www.lua.org/ftp/ \ https://www.tecgraf.puc-rio.br/lua/ftp/ PKG_HASH:=2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333 PKG_BUILD_PARALLEL:=1 -PKG_FLAGS := nonshared PKG_LICENSE:=MIT PKG_LICENSE_FILES:=COPYRIGHT @@ -100,7 +99,7 @@ define Build/Compile RANLIB="$(TARGET_CROSS)ranlib" \ INSTALL_ROOT=/usr \ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \ - MYLDFLAGS="$(TARGET_LDFLAGS) $(if $(CONFIG_USE_GLIBC),-lm -ldl)" \ + MYLDFLAGS="$(TARGET_LDFLAGS)" \ PKG_VERSION=$(PKG_VERSION) \ linux rm -rf $(PKG_INSTALL_DIR) @@ -126,7 +125,7 @@ endif define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) \ - CC="$(HOSTCC) -std=gnu99" \ + CC="$(HOSTCC) $(HOST_FPIC) -std=gnu99" \ $(LUA_OS) endef @@ -135,8 +134,12 @@ define Host/Install INSTALL_TOP="$(STAGING_DIR_HOSTPKG)" \ install - $(LN) $(STAGING_DIR_HOSTPKG)/bin/lua5.1 $(STAGING_DIR_HOSTPKG)/bin/lua - $(LN) $(STAGING_DIR_HOSTPKG)/bin/luac5.1 $(STAGING_DIR_HOSTPKG)/bin/luac + $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/lib/pkgconfig + $(CP) $(HOST_BUILD_DIR)/etc/lua.pc $(STAGING_DIR_HOSTPKG)/lib/pkgconfig/lua5.1.pc + + $(LN) lua5.1 $(STAGING_DIR_HOSTPKG)/bin/lua + $(LN) luac5.1 $(STAGING_DIR_HOSTPKG)/bin/luac + $(LN) lua5.1.pc $(STAGING_DIR_HOSTPKG)/lib/pkgconfig/lua.pc endef define Build/InstallDev diff --git a/package/utils/lua5.3/Makefile b/package/utils/lua5.3/Makefile index 6d1f98ee1..9a707fbba 100644 --- a/package/utils/lua5.3/Makefile +++ b/package/utils/lua5.3/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lua PKG_VERSION:=5.3.5 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://www.lua.org/ftp/ \ @@ -110,7 +110,7 @@ endif define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) \ - CC="$(HOSTCC) -std=gnu99" \ + CC="$(HOSTCC) $(HOST_FPIC) -std=gnu99" \ $(LUA_OS) endef diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile index f6696bf21..553728194 100644 --- a/package/utils/mdadm/Makefile +++ b/package/utils/mdadm/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mdadm -PKG_VERSION:=4.1 -PKG_RELEASE:=2 +PKG_VERSION:=4.2 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm -PKG_HASH:=ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a +PKG_HASH:=461c215670864bb74a4d1a3620684aa2b2f8296dffa06743f26dda5557acf01d PKG_MAINTAINER:=Felix Fietkau PKG_CPE_ID:=cpe:/a:mdadm_project:mdadm @@ -48,11 +48,16 @@ TARGET_CFLAGS += \ -DCONFFILE='\"/var/etc/mdadm.conf\"' \ -DMAP_DIR='\"/var/run/mdadm\"' \ -DMDMON_DIR='\"/var/run/mdadm\"' \ - -DFAILED_SLOTS_DIR='\"/var/run/mdadm/failed-slots\"' + -DFAILED_SLOTS_DIR='\"/var/run/mdadm/failed-slots\"' \ + -DNO_LIBUDEV + +TARGET_CXFLAGS = -DNO_LIBUDEV TARGET_LDFLAGS += -Wl,--gc-sections -MAKE_FLAGS += CHECK_RUN_DIR=0 +MAKE_FLAGS += \ + CHECK_RUN_DIR=0 \ + CXFLAGS="$(TARGET_CXFLAGS)" define Build/Compile $(call Build/Compile/Default,mdadm) diff --git a/package/utils/mdadm/patches/100-cross_compile.patch b/package/utils/mdadm/patches/100-cross_compile.patch index 0a5fa017c..790d7755b 100644 --- a/package/utils/mdadm/patches/100-cross_compile.patch +++ b/package/utils/mdadm/patches/100-cross_compile.patch @@ -1,6 +1,6 @@ --- a/Makefile +++ b/Makefile -@@ -97,7 +97,7 @@ DLM:=$(shell [ -f /usr/include/libdlm.h +@@ -99,7 +99,7 @@ DLM:=$(shell [ -f /usr/include/libdlm.h DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\" DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\" DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\" diff --git a/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch b/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch deleted file mode 100644 index 356d0deec..000000000 --- a/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 6d369e8f226594632ce4260129509daf7030de0a Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Mon, 9 May 2016 22:03:57 +0000 -Subject: [PATCH] mdadm.h: Undefine dprintf before redefining - -dprintf is also defined in libc see -usr/include/bits/stdio2.h, this comes into -play especially when fortify sources is enabled -and compilers like clang reports the override - -In file included from policy.c:25: -./mdadm.h:1562:9: error: 'dprintf' macro redefined [-Werror,-Wmacro-redefined] - ^ -/mnt/oe/openembedded-core/build/tmp-glibc/sysroots/qemux86/usr/include/bits/stdio2.h:145:12: note: previous definition is here - -Signed-off-by: Khem Raj ---- -Upstream-Status: Pending - - mdadm.h | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/mdadm.h -+++ b/mdadm.h -@@ -1649,11 +1649,13 @@ static inline char *to_subarray(struct m - } - - #ifdef DEBUG -+#undef dprintf - #define dprintf(fmt, arg...) \ - fprintf(stderr, "%s: %s: "fmt, Name, __func__, ##arg) - #define dprintf_cont(fmt, arg...) \ - fprintf(stderr, fmt, ##arg) - #else -+#undef dprintf - #define dprintf(fmt, arg...) \ - ({ if (0) fprintf(stderr, "%s: %s: " fmt, Name, __func__, ##arg); 0; }) - #define dprintf_cont(fmt, arg...) \ diff --git a/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch b/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch deleted file mode 100644 index 891b5c62f..000000000 --- a/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 452dc4d13a012cdcb05088c0dbc699959c4d6c73 Mon Sep 17 00:00:00 2001 -From: Baruch Siach -Date: Tue, 6 Aug 2019 16:05:23 +0300 -Subject: mdadm.h: include sysmacros.h unconditionally - -musl libc now also requires sys/sysmacros.h for the major/minor macros. -All supported libc implementations carry sys/sysmacros.h, including -diet-libc, klibc, and uclibc-ng. - -Cc: Hauke Mehrtens -Signed-off-by: Baruch Siach -Signed-off-by: Jes Sorensen ---- - mdadm.h | 2 -- - 1 file changed, 2 deletions(-) - ---- a/mdadm.h -+++ b/mdadm.h -@@ -45,10 +45,8 @@ extern __off64_t lseek64 __P ((int __fd, - #include - #include - #include --#ifdef __GLIBC__ - /* Newer glibc requires sys/sysmacros.h directly for makedev() */ - #include --#endif - #ifdef __dietlibc__ - #include - /* dietlibc has deprecated random and srandom!! */ diff --git a/package/utils/mdadm/patches/200-reduce_size.patch b/package/utils/mdadm/patches/200-reduce_size.patch index 6905c2ccf..163e125c2 100644 --- a/package/utils/mdadm/patches/200-reduce_size.patch +++ b/package/utils/mdadm/patches/200-reduce_size.patch @@ -1,19 +1,19 @@ --- a/Incremental.c +++ b/Incremental.c -@@ -1619,6 +1619,10 @@ static int Incremental_container(struct - if (ra_all == ra_blocked) - return 0; +@@ -983,6 +983,10 @@ static int array_try_spare(char *devname + goto next; + } -+#ifndef MDADM_FULL -+ return 0; -+#endif ++ #ifndef MDADM_FULL ++ return 0; ++ #endif + - /* Now move all suitable spares from spare container */ - domains = domain_from_array(list, st->ss->name); - memcpy(suuid, uuid_zero, sizeof(int[4])); + dl = domain_from_array(sra, st2->ss->name); + if (domain_test(dl, pol, st2->ss->name) != 1) { + /* domain test fails */ --- a/util.c +++ b/util.c -@@ -1220,7 +1220,9 @@ void wait_for(char *dev, int fd) +@@ -1147,7 +1147,9 @@ void wait_for(char *dev, int fd) struct superswitch *superlist[] = { &super0, &super1, diff --git a/package/utils/mtd-utils/Makefile b/package/utils/mtd-utils/Makefile index 5a4b03da9..afbfbceff 100644 --- a/package/utils/mtd-utils/Makefile +++ b/package/utils/mtd-utils/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtd-utils -PKG_VERSION:=2.1.2 +PKG_VERSION:=2.1.5 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 -PKG_SOURCE_URL:=ftp://ftp.infradead.org/pub/mtd-utils/ -PKG_HASH:=8ad4c5f34716d40646aa28724a2f5616d325a6f119254f914e26976f1f76e9d6 +PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/ +PKG_HASH:=386e27fd121699b6b729bc2e8e04dda987b31cca6b16e12fb6cc6dcf26449f46 PKG_INSTALL:=1 PKG_FIXUP:=autoreconf @@ -24,6 +24,7 @@ PKG_BUILD_DEPENDS:=util-linux PKG_LICENSE:=GPLv2 PKG_LICENSE_FILES:= +PKG_CPE_ID:=cpe:/a:mtd-utils_project:mtd-utils PKG_MAINTAINER:=John Crispin diff --git a/package/utils/mtd-utils/patches/130-lzma_jffs2.patch b/package/utils/mtd-utils/patches/130-lzma_jffs2.patch index 9778aa6d0..db683063d 100644 --- a/package/utils/mtd-utils/patches/130-lzma_jffs2.patch +++ b/package/utils/mtd-utils/patches/130-lzma_jffs2.patch @@ -1,6 +1,6 @@ --- a/jffsX-utils/Makemodule.am +++ b/jffsX-utils/Makemodule.am -@@ -4,11 +4,19 @@ mkfs_jffs2_SOURCES = \ +@@ -4,7 +4,10 @@ mkfs_jffs2_SOURCES = \ jffsX-utils/compr_zlib.c \ jffsX-utils/compr.h \ jffsX-utils/rbtree.c \ @@ -10,7 +10,12 @@ + jffsX-utils/lzma/LzmaEnc.c \ + jffsX-utils/lzma/LzmaDec.c \ jffsX-utils/compr.c \ - jffsX-utils/compr_rtime.c + jffsX-utils/compr_rtime.c \ + jffsX-utils/compr.h \ +@@ -12,8 +15,13 @@ mkfs_jffs2_SOURCES = \ + jffsX-utils/summary.h \ + include/linux/jffs2.h \ + include/mtd/jffs2-user.h + +if !WITHOUT_LZO +mkfs_jffs2_SOURCES += jffsX-utils/compr_lzo.c @@ -20,7 +25,7 @@ -mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) +mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) -I./include/linux/lzma - jffs2reader_SOURCES = jffsX-utils/jffs2reader.c + jffs2reader_SOURCES = jffsX-utils/jffs2reader.c include/mtd/jffs2-user.h jffs2reader_LDADD = libmtd.a $(ZLIB_LIBS) $(LZO_LIBS) --- a/jffsX-utils/compr.c +++ b/jffsX-utils/compr.c @@ -5015,7 +5020,7 @@ +} --- a/jffsX-utils/mkfs.jffs2.c +++ b/jffsX-utils/mkfs.jffs2.c -@@ -1667,11 +1667,11 @@ int main(int argc, char **argv) +@@ -1668,11 +1668,11 @@ int main(int argc, char **argv) } erase_block_size *= units; diff --git a/package/utils/nvram/Makefile b/package/utils/nvram/Makefile index 863b304d0..b95721128 100644 --- a/package/utils/nvram/Makefile +++ b/package/utils/nvram/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nvram -PKG_RELEASE:=10 +PKG_RELEASE:=11 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -44,7 +44,11 @@ define Package/nvram/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/sbin/ ifneq ($(CONFIG_TARGET_bcm47xx),) $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_BIN) ./files/nvram.init $(1)/etc/init.d/nvram + $(INSTALL_BIN) ./files/nvram-bcm47xx.init $(1)/etc/init.d/nvram +endif +ifneq ($(CONFIG_TARGET_bcm53xx),) + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/nvram-bcm53xx.init $(1)/etc/init.d/nvram endif endef diff --git a/package/utils/nvram/files/nvram.init b/package/utils/nvram/files/nvram-bcm47xx.init similarity index 97% rename from package/utils/nvram/files/nvram.init rename to package/utils/nvram/files/nvram-bcm47xx.init index 467ab2819..4a2bcd16f 100755 --- a/package/utils/nvram/files/nvram.init +++ b/package/utils/nvram/files/nvram-bcm47xx.init @@ -1,7 +1,7 @@ #!/bin/sh /etc/rc.common # NVRAM setup # -# This file handles the NVRAM quirks of various hardware. +# This file handles the NVRAM quirks of various hardware of the bcm47xx target. START=02 alias debug=${DEBUG:-:} @@ -71,7 +71,7 @@ fixup_linksys() { esac } -start() { +boot() { # Don't do any fixups on the WGT634U [ "$(cat /proc/diag/model)" = "Netgear WGT634U" ] && return diff --git a/package/utils/nvram/files/nvram-bcm53xx.init b/package/utils/nvram/files/nvram-bcm53xx.init new file mode 100755 index 000000000..0502cd28b --- /dev/null +++ b/package/utils/nvram/files/nvram-bcm53xx.init @@ -0,0 +1,40 @@ +#!/bin/sh /etc/rc.common +# NVRAM setup +# +# This file handles the NVRAM quirks of various hardware of the bcm53xx target. + +START=02 + +clear_partialboots() { + # clear partialboots + + case $(board_name) in + linksys,panamera) + COMMIT=1 + nvram set partialboots=0 + ;; + esac +} + +set_wireless_led_behaviour() { + # set Broadcom wireless LED behaviour for both radios + # 0:ledbh9 -> Behaviour of 2.4GHz LED + # 1:ledbh9 -> Behaviour of 5GHz LED + # 0x7 makes the wireless LEDs on, when radios are enabled, and blink when there's activity + + case $(board_name) in + asus,rt-ac88u) + COMMIT=1 + nvram set 0:ledbh9=0x7 set 1:ledbh9=0x7 + ;; + esac +} + +boot() { + . /lib/functions.sh + + clear_partialboots + set_wireless_led_behaviour + + [ "$COMMIT" = "1" ] && nvram commit +} diff --git a/package/utils/otrx/Makefile b/package/utils/otrx/Makefile index 2a3ac731a..35c59e273 100644 --- a/package/utils/otrx/Makefile +++ b/package/utils/otrx/Makefile @@ -10,7 +10,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=otrx PKG_RELEASE:=1 -PKG_FLAGS:=nonshared +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git +PKG_SOURCE_DATE:=2021-12-02 +PKG_SOURCE_VERSION:=56e8e19151743c923f48604c457850cf8eb52076 +PKG_MIRROR_HASH:=2a40ac73e8eab0a7a4474cb331b8e2fc972635314b0b5e02a9f2b9a32c5d5f3b include $(INCLUDE_DIR)/package.mk @@ -26,10 +30,12 @@ define Package/otrx/description This package contains an utility that allows validating TRX images. endef +TARGET_CFLAGS += -Wall + define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - CC="$(TARGET_CC)" \ - CFLAGS="$(TARGET_CFLAGS) -Wall" + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) \ + -o $(PKG_BUILD_DIR)/otrx \ + $(PKG_BUILD_DIR)/src/otrx.c endef define Package/otrx/install diff --git a/package/utils/otrx/src/Makefile b/package/utils/otrx/src/Makefile deleted file mode 100644 index df50ea446..000000000 --- a/package/utils/otrx/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: otrx - -otrx: - $(CC) $(CFLAGS) -o $@ otrx.c -Wall - -clean: - rm -f otrx diff --git a/package/utils/otrx/src/otrx.c b/package/utils/otrx/src/otrx.c deleted file mode 100644 index 223e032f2..000000000 --- a/package/utils/otrx/src/otrx.c +++ /dev/null @@ -1,592 +0,0 @@ -/* - * otrx - * - * Copyright (C) 2015-2017 Rafał Miłecki - * - * 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; either version 2 of the License, or (at your option) - * any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined(__BYTE_ORDER) -#error "Unknown byte order" -#endif - -#if __BYTE_ORDER == __BIG_ENDIAN -#define cpu_to_le32(x) bswap_32(x) -#define le32_to_cpu(x) bswap_32(x) -#elif __BYTE_ORDER == __LITTLE_ENDIAN -#define cpu_to_le32(x) (x) -#define le32_to_cpu(x) (x) -#else -#error "Unsupported endianness" -#endif - -#define TRX_MAGIC 0x30524448 -#define TRX_FLAGS_OFFSET 12 -#define TRX_MAX_PARTS 3 - -struct trx_header { - uint32_t magic; - uint32_t length; - uint32_t crc32; - uint16_t flags; - uint16_t version; - uint32_t offset[3]; -}; - -char *trx_path; -size_t trx_offset = 0; -char *partition[TRX_MAX_PARTS] = {}; - -static inline size_t otrx_min(size_t x, size_t y) { - return x < y ? x : y; -} - -/************************************************** - * CRC32 - **************************************************/ - -static const uint32_t crc32_tbl[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, - 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, - 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, - 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, - 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, - 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, - 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, - 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, - 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, - 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, - 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, - 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, - 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, - 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, - 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, - 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, - 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, - 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, - 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, - 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, - 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, - 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, - 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, - 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, - 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, - 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, - 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, - 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, - 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, - 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, - 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, - 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, - 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, - 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, - 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, -}; - -uint32_t otrx_crc32(uint32_t crc, uint8_t *buf, size_t len) { - while (len) { - crc = crc32_tbl[(crc ^ *buf) & 0xff] ^ (crc >> 8); - buf++; - len--; - } - - return crc; -} - -/************************************************** - * Check - **************************************************/ - -static void otrx_check_parse_options(int argc, char **argv) { - int c; - - while ((c = getopt(argc, argv, "o:")) != -1) { - switch (c) { - case 'o': - trx_offset = atoi(optarg); - break; - } - } -} - -static int otrx_check(int argc, char **argv) { - FILE *trx; - struct trx_header hdr; - size_t bytes, length; - uint8_t buf[1024]; - uint32_t crc32; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No TRX file passed\n"); - err = -EINVAL; - goto out; - } - trx_path = argv[2]; - - optind = 3; - otrx_check_parse_options(argc, argv); - - trx = fopen(trx_path, "r"); - if (!trx) { - fprintf(stderr, "Couldn't open %s\n", trx_path); - err = -EACCES; - goto out; - } - - fseek(trx, trx_offset, SEEK_SET); - bytes = fread(&hdr, 1, sizeof(hdr), trx); - if (bytes != sizeof(hdr)) { - fprintf(stderr, "Couldn't read %s header\n", trx_path); - err = -EIO; - goto err_close; - } - - if (le32_to_cpu(hdr.magic) != TRX_MAGIC) { - fprintf(stderr, "Invalid TRX magic: 0x%08x\n", le32_to_cpu(hdr.magic)); - err = -EINVAL; - goto err_close; - } - - length = le32_to_cpu(hdr.length); - if (length < sizeof(hdr)) { - fprintf(stderr, "Length read from TRX too low (%zu B)\n", length); - err = -EINVAL; - goto err_close; - } - - crc32 = 0xffffffff; - fseek(trx, trx_offset + TRX_FLAGS_OFFSET, SEEK_SET); - length -= TRX_FLAGS_OFFSET; - while ((bytes = fread(buf, 1, otrx_min(sizeof(buf), length), trx)) > 0) { - crc32 = otrx_crc32(crc32, buf, bytes); - length -= bytes; - } - - if (length) { - fprintf(stderr, "Couldn't read last %zd B of data from %s\n", length, trx_path); - err = -EIO; - goto err_close; - } - - if (crc32 != le32_to_cpu(hdr.crc32)) { - fprintf(stderr, "Invalid data crc32: 0x%08x instead of 0x%08x\n", crc32, le32_to_cpu(hdr.crc32)); - err = -EINVAL; - goto err_close; - } - - printf("Found a valid TRX version %d\n", le32_to_cpu(hdr.version)); - -err_close: - fclose(trx); -out: - return err; -} - -/************************************************** - * Create - **************************************************/ - -static ssize_t otrx_create_append_file(FILE *trx, const char *in_path) { - FILE *in; - size_t bytes; - ssize_t length = 0; - uint8_t buf[1024]; - - in = fopen(in_path, "r"); - if (!in) { - fprintf(stderr, "Couldn't open %s\n", in_path); - return -EACCES; - } - - while ((bytes = fread(buf, 1, sizeof(buf), in)) > 0) { - if (fwrite(buf, 1, bytes, trx) != bytes) { - fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, trx_path); - length = -EIO; - break; - } - length += bytes; - } - - fclose(in); - - return length; -} - -static ssize_t otrx_create_append_zeros(FILE *trx, size_t length) { - uint8_t *buf; - - buf = malloc(length); - if (!buf) - return -ENOMEM; - memset(buf, 0, length); - - if (fwrite(buf, 1, length, trx) != length) { - fprintf(stderr, "Couldn't write %zu B to %s\n", length, trx_path); - free(buf); - return -EIO; - } - - free(buf); - - return length; -} - -static ssize_t otrx_create_align(FILE *trx, size_t curr_offset, size_t alignment) { - if (curr_offset & (alignment - 1)) { - size_t length = alignment - (curr_offset % alignment); - return otrx_create_append_zeros(trx, length); - } - - return 0; -} - -static int otrx_create_write_hdr(FILE *trx, struct trx_header *hdr) { - size_t bytes, length; - uint8_t buf[1024]; - uint32_t crc32; - - hdr->magic = cpu_to_le32(TRX_MAGIC); - hdr->version = 1; - - fseek(trx, 0, SEEK_SET); - bytes = fwrite(hdr, 1, sizeof(struct trx_header), trx); - if (bytes != sizeof(struct trx_header)) { - fprintf(stderr, "Couldn't write TRX header to %s\n", trx_path); - return -EIO; - } - - length = le32_to_cpu(hdr->length); - - crc32 = 0xffffffff; - fseek(trx, TRX_FLAGS_OFFSET, SEEK_SET); - length -= TRX_FLAGS_OFFSET; - while ((bytes = fread(buf, 1, otrx_min(sizeof(buf), length), trx)) > 0) { - crc32 = otrx_crc32(crc32, buf, bytes); - length -= bytes; - } - hdr->crc32 = cpu_to_le32(crc32); - - fseek(trx, 0, SEEK_SET); - bytes = fwrite(hdr, 1, sizeof(struct trx_header), trx); - if (bytes != sizeof(struct trx_header)) { - fprintf(stderr, "Couldn't write TRX header to %s\n", trx_path); - return -EIO; - } - - return 0; -} - -static int otrx_create(int argc, char **argv) { - FILE *trx; - struct trx_header hdr = {}; - ssize_t sbytes; - size_t curr_idx = 0; - size_t curr_offset = sizeof(hdr); - int c; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No TRX file passed\n"); - err = -EINVAL; - goto out; - } - trx_path = argv[2]; - - trx = fopen(trx_path, "w+"); - if (!trx) { - fprintf(stderr, "Couldn't open %s\n", trx_path); - err = -EACCES; - goto out; - } - fseek(trx, curr_offset, SEEK_SET); - - optind = 3; - while ((c = getopt(argc, argv, "f:A:a:b:")) != -1) { - switch (c) { - case 'f': - if (curr_idx >= TRX_MAX_PARTS) { - err = -ENOSPC; - fprintf(stderr, "Reached TRX partitions limit, no place for %s\n", optarg); - goto err_close; - } - - sbytes = otrx_create_append_file(trx, optarg); - if (sbytes < 0) { - fprintf(stderr, "Failed to append file %s\n", optarg); - } else { - hdr.offset[curr_idx++] = curr_offset; - curr_offset += sbytes; - } - - sbytes = otrx_create_align(trx, curr_offset, 4); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - - break; - case 'A': - sbytes = otrx_create_append_file(trx, optarg); - if (sbytes < 0) { - fprintf(stderr, "Failed to append file %s\n", optarg); - } else { - curr_offset += sbytes; - } - - sbytes = otrx_create_align(trx, curr_offset, 4); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - break; - case 'a': - sbytes = otrx_create_align(trx, curr_offset, strtol(optarg, NULL, 0)); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - break; - case 'b': - sbytes = strtol(optarg, NULL, 0) - curr_offset; - if (sbytes < 0) { - fprintf(stderr, "Current TRX length is 0x%zx, can't pad it with zeros to 0x%lx\n", curr_offset, strtol(optarg, NULL, 0)); - } else { - sbytes = otrx_create_append_zeros(trx, sbytes); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - } - break; - } - if (err) - break; - } - - sbytes = otrx_create_align(trx, curr_offset, 0x1000); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - - hdr.length = curr_offset; - otrx_create_write_hdr(trx, &hdr); -err_close: - fclose(trx); -out: - return err; -} - -/************************************************** - * Extract - **************************************************/ - -static void otrx_extract_parse_options(int argc, char **argv) { - int c; - - while ((c = getopt(argc, argv, "c:e:o:1:2:3:")) != -1) { - switch (c) { - case 'o': - trx_offset = atoi(optarg); - break; - case '1': - partition[0] = optarg; - break; - case '2': - partition[1] = optarg; - break; - case '3': - partition[2] = optarg; - break; - } - } -} - -static int otrx_extract_copy(FILE *trx, size_t offset, size_t length, char *out_path) { - FILE *out; - size_t bytes; - uint8_t *buf; - int err = 0; - - out = fopen(out_path, "w"); - if (!out) { - fprintf(stderr, "Couldn't open %s\n", out_path); - err = -EACCES; - goto out; - } - - buf = malloc(length); - if (!buf) { - fprintf(stderr, "Couldn't alloc %zu B buffer\n", length); - err = -ENOMEM; - goto err_close; - } - - fseek(trx, offset, SEEK_SET); - bytes = fread(buf, 1, length, trx); - if (bytes != length) { - fprintf(stderr, "Couldn't read %zu B of data from %s\n", length, trx_path); - err = -ENOMEM; - goto err_free_buf; - }; - - bytes = fwrite(buf, 1, length, out); - if (bytes != length) { - fprintf(stderr, "Couldn't write %zu B to %s\n", length, out_path); - err = -ENOMEM; - goto err_free_buf; - } - - printf("Extracted 0x%zx bytes into %s\n", length, out_path); - -err_free_buf: - free(buf); -err_close: - fclose(out); -out: - return err; -} - -static int otrx_extract(int argc, char **argv) { - FILE *trx; - struct trx_header hdr; - size_t bytes; - int i; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No TRX file passed\n"); - err = -EINVAL; - goto out; - } - trx_path = argv[2]; - - optind = 3; - otrx_extract_parse_options(argc, argv); - - trx = fopen(trx_path, "r"); - if (!trx) { - fprintf(stderr, "Couldn't open %s\n", trx_path); - err = -EACCES; - goto out; - } - - fseek(trx, trx_offset, SEEK_SET); - bytes = fread(&hdr, 1, sizeof(hdr), trx); - if (bytes != sizeof(hdr)) { - fprintf(stderr, "Couldn't read %s header\n", trx_path); - err = -EIO; - goto err_close; - } - - if (le32_to_cpu(hdr.magic) != TRX_MAGIC) { - fprintf(stderr, "Invalid TRX magic: 0x%08x\n", le32_to_cpu(hdr.magic)); - err = -EINVAL; - goto err_close; - } - - for (i = 0; i < TRX_MAX_PARTS; i++) { - size_t length; - - if (!partition[i]) - continue; - if (!hdr.offset[i]) { - printf("TRX doesn't contain partition %d, can't extract %s\n", i + 1, partition[i]); - continue; - } - - if (i + 1 >= TRX_MAX_PARTS || !hdr.offset[i + 1]) - length = le32_to_cpu(hdr.length) - le32_to_cpu(hdr.offset[i]); - else - length = le32_to_cpu(hdr.offset[i + 1]) - le32_to_cpu(hdr.offset[i]); - - otrx_extract_copy(trx, trx_offset + le32_to_cpu(hdr.offset[i]), length, partition[i]); - } - -err_close: - fclose(trx); -out: - return err; -} - -/************************************************** - * Start - **************************************************/ - -static void usage() { - printf("Usage:\n"); - printf("\n"); - printf("Checking TRX file:\n"); - printf("\totrx check [options]\tcheck if file is a valid TRX\n"); - printf("\t-o offset\t\t\toffset of TRX data in file (default: 0)\n"); - printf("\n"); - printf("Creating new TRX file:\n"); - printf("\totrx create [options] [partitions]\n"); - printf("\t-f file\t\t\t\t[partition] start new partition with content copied from file\n"); - printf("\t-A file\t\t\t\t[partition] append current partition with content copied from file\n"); - printf("\t-a alignment\t\t\t[partition] align current partition\n"); - printf("\t-b offset\t\t\t[partition] append zeros to partition till reaching absolute offset\n"); - printf("\n"); - printf("Extracting from TRX file:\n"); - printf("\totrx extract [options]\textract partitions from TRX file\n"); - printf("\t-o offset\t\t\toffset of TRX data in file (default: 0)\n"); - printf("\t-1 file\t\t\t\tfile to extract 1st partition to (optional)\n"); - printf("\t-2 file\t\t\t\tfile to extract 2nd partition to (optional)\n"); - printf("\t-3 file\t\t\t\tfile to extract 3rd partition to (optional)\n"); -} - -int main(int argc, char **argv) { - if (argc > 1) { - if (!strcmp(argv[1], "check")) - return otrx_check(argc, argv); - else if (!strcmp(argv[1], "create")) - return otrx_create(argc, argv); - else if (!strcmp(argv[1], "extract")) - return otrx_extract(argc, argv); - } - - usage(); - return 0; -} diff --git a/package/utils/policycoreutils/Makefile b/package/utils/policycoreutils/Makefile index 249c2afb9..f724deda9 100644 --- a/package/utils/policycoreutils/Makefile +++ b/package/utils/policycoreutils/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=policycoreutils -PKG_VERSION:=3.2 +PKG_VERSION:=3.3 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=d1331c6fa766c547b071c491de90b9f343c8dbffdb119be8a5a7e491199b93a9 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=4199040ced8a81f2ddd0522b4faf2aba62fc821473f4051dc8474fb1c4a01078 PKG_INSTALL:=1 HOST_BUILD_DEPENDS:=libsemanage/host gettext-full/host PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam gettext-full/host diff --git a/package/utils/px5g-wolfssl/Makefile b/package/utils/px5g-wolfssl/Makefile index 90296008d..ea805acd8 100644 --- a/package/utils/px5g-wolfssl/Makefile +++ b/package/utils/px5g-wolfssl/Makefile @@ -5,13 +5,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=px5g-wolfssl -PKG_RELEASE:=$(COMMITCOUNT) +PKG_RELEASE:=$(COMMITCOUNT).1 PKG_LICENSE:=GPL-2.0-or-later PKG_USE_MIPS16:=0 PKG_MAINTAINER:=Paul Spooren +PKG_CONFIG_DEPENDS:=CONFIG_WOLFSSL_ALT_NAMES + include $(INCLUDE_DIR)/package.mk define Package/px5g-wolfssl diff --git a/package/utils/px5g-wolfssl/px5g-wolfssl.c b/package/utils/px5g-wolfssl/px5g-wolfssl.c index 763d7b4b7..cd04a41df 100644 --- a/package/utils/px5g-wolfssl/px5g-wolfssl.c +++ b/package/utils/px5g-wolfssl/px5g-wolfssl.c @@ -142,42 +142,42 @@ int selfsigned(WC_RNG *rng, char **arg) { newCert.isCA = 0; while (*arg && **arg == '-') { - if (!strncmp(*arg, "-der", 4)) { + if (!strcmp(*arg, "-der")) { pem = false; - } else if (!strncmp(*arg, "-newkey", 6) && arg[1]) { + } else if (!strcmp(*arg, "-newkey") && arg[1]) { if (!strncmp(arg[1], "rsa:", 4)) { type = RSA_KEY_TYPE; - keySz = (unsigned int)atoi(arg[1] + 4); - } else if (!strncmp(arg[1], "ec", 2)) { + keySz = atoi(arg[1] + 4); + } else if (!strcmp(arg[1], "ec")) { type = EC_KEY_TYPE; } else { fprintf(stderr, "error: invalid algorithm\n"); return 1; } arg++; - } else if (!strncmp(*arg, "-days", 5) && arg[1]) { + } else if (!strcmp(*arg, "-days") && arg[1]) { days = (unsigned int)atoi(arg[1]); arg++; - } else if (!strncmp(*arg, "-pkeyopt", 8) && arg[1]) { + } else if (!strcmp(*arg, "-pkeyopt") && arg[1]) { if (strncmp(arg[1], "ec_paramgen_curve:", 18)) { fprintf(stderr, "error: invalid pkey option: %s\n", arg[1]); return 1; } - if (!strncmp(arg[1] + 18, "P-256:", 5)) { + if (!strcmp(arg[1] + 18, "P-256")) { curve = ECC_SECP256R1; - } else if (!strncmp(arg[1] + 18, "P-384:", 5)) { + } else if (!strcmp(arg[1] + 18, "P-384")) { curve = ECC_SECP384R1; - } else if (!strncmp(arg[1] + 18, "P-521:", 5)) { + } else if (!strcmp(arg[1] + 18, "P-521")) { curve = ECC_SECP521R1; } else { fprintf(stderr, "error: invalid curve name: %s\n", arg[1] + 18); return 1; } arg++; - } else if (!strncmp(*arg, "-keyout", 7) && arg[1]) { + } else if (!strcmp(*arg, "-keyout") && arg[1]) { keypath = arg[1]; arg++; - } else if (!strncmp(*arg, "-out", 4) && arg[1]) { + } else if (!strcmp(*arg, "-out") && arg[1]) { certpath = arg[1]; arg++; } else if (!strcmp(*arg, "-subj") && arg[1]) { @@ -203,8 +203,23 @@ int selfsigned(WC_RNG *rng, char **arg) { strncpy(newCert.subject.org, val, CTC_NAME_SIZE); else if (!strcmp(key, "OU")) strncpy(newCert.subject.unit, val, CTC_NAME_SIZE); - else if (!strcmp(key, "CN")) + else if (!strcmp(key, "CN")) { strncpy(newCert.subject.commonName, val, CTC_NAME_SIZE); + +#ifdef WOLFSSL_ALT_NAMES + if(strlen(val) + 2 > 256) { + fprintf(stderr, "error: CN is too long: %s\n", val); + return 1; + } + + newCert.altNames[0] = 0x30; //Sequence with one element + newCert.altNames[1] = strlen(val) + 2; // Length of entire sequence + newCert.altNames[2] = 0x82; //8 - String, 2 - DNS Name + newCert.altNames[3] = strlen(val); //DNS Name length + memcpy(newCert.altNames + 4, val, strlen(val)); //DNS Name + newCert.altNamesSz = strlen(val) + 4; +#endif + } else if (!strcmp(key, "EMAIL")) strncpy(newCert.subject.email, val, CTC_NAME_SIZE); else @@ -216,6 +231,9 @@ int selfsigned(WC_RNG *rng, char **arg) { } newCert.daysValid = days; + newCert.keyUsage = KEYUSE_DIGITAL_SIG | KEYUSE_CONTENT_COMMIT | KEYUSE_KEY_ENCIPHER; + newCert.extKeyUsage = EXTKEYUSE_SERVER_AUTH; + gen_key(rng, &ecKey, &rsaKey, type, keySz, exp, curve); write_key(&ecKey, &rsaKey, type, keySz, keypath, pem); @@ -288,25 +306,25 @@ int dokey(WC_RNG *rng, int type, char **arg) { bool pem = true; while (*arg && **arg == '-') { - if (!strncmp(*arg, "-out", 4) && arg[1]) { + if (!strcmp(*arg, "-out") && arg[1]) { path = arg[1]; arg++; - } else if (!strncmp(*arg, "-3", 2)) { + } else if (!strcmp(*arg, "-3")) { exp = 3; - } else if (!strncmp(*arg, "-der", 4)) { + } else if (!strcmp(*arg, "-der")) { pem = false; } arg++; } if (*arg && type == RSA_KEY_TYPE) { - keySz = (unsigned int)atoi(*arg); + keySz = atoi(*arg); } else if (*arg) { - if (!strncmp(*arg, "P-256", 5)) { + if (!strcmp(*arg, "P-256")) { curve = ECC_SECP256R1; - } else if (!strncmp(*arg, "P-384", 5)) { + } else if (!strcmp(*arg, "P-384")) { curve = ECC_SECP384R1; - } else if (!strncmp(*arg, "P-521", 5)) { + } else if (!strcmp(*arg, "P-521")) { curve = ECC_SECP521R1; } else { fprintf(stderr, "Invalid Curve Name: %s\n", *arg); @@ -338,13 +356,13 @@ int main(int argc, char *argv[]) { } if (argv[1]) { - if (!strncmp(argv[1], "eckey", 5)) + if (!strcmp(argv[1], "eckey")) return dokey(&rng, EC_KEY_TYPE, argv + 2); - if (!strncmp(argv[1], "rsakey", 5)) + if (!strcmp(argv[1], "rsakey")) return dokey(&rng, RSA_KEY_TYPE, argv + 2); - if (!strncmp(argv[1], "selfsigned", 10)) + if (!strcmp(argv[1], "selfsigned")) return selfsigned(&rng, argv + 2); } diff --git a/package/utils/secilc/Makefile b/package/utils/secilc/Makefile index 7ed22615c..6f059bfc8 100644 --- a/package/utils/secilc/Makefile +++ b/package/utils/secilc/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=secilc -PKG_VERSION:=3.2 +PKG_VERSION:=3.3 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=5f6e6528a281b29ac5e558babffc3d8aab682fd8df8977daff5f266a50292cc3 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=2c5e1a5d417baf1d2aa3eac294e12c3aac7184a5ef6a779dcbe469ed756e8651 HOST_BUILD_DEPENDS:=libsepol/host PKG_MAINTAINER:=Dominick Grift diff --git a/package/utils/spidev_test/Makefile b/package/utils/spidev_test/Makefile index 0f288ad01..fef5c8f64 100644 --- a/package/utils/spidev_test/Makefile +++ b/package/utils/spidev_test/Makefile @@ -10,7 +10,6 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=spidev-test PKG_RELEASE:=$(LINUX_VERSION) -PKG_FLAGS:=nonshared PKG_BUILD_DIR:=$(LINUX_DIR)/tools/spi-$(TARGET_DIR_NAME) PKG_BUILD_PARALLEL:=1 @@ -19,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk define Package/spidev-test SECTION:=utils CATEGORY:=Utilities - DEPENDS:=+kmod-spi-dev @!IN_SDK + DEPENDS:=+kmod-spi-dev TITLE:=SPI testing utility VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE) URL:=http://www.kernel.org @@ -30,6 +29,8 @@ define Package/spidev-test/description endef define Build/Prepare + # For SDK: Sources are copied by target/sdk/Makefile's + # USERSPACE_UTILS(_FILES) $(CP) $(LINUX_DIR)/tools/spi/* $(PKG_BUILD_DIR)/ endef diff --git a/package/utils/ucode/Makefile b/package/utils/ucode/Makefile index ea317ad49..fafc44909 100644 --- a/package/utils/ucode/Makefile +++ b/package/utils/ucode/Makefile @@ -12,18 +12,31 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=https://github.com/jow-/ucode.git -PKG_SOURCE_DATE:=2022-02-11 -PKG_SOURCE_VERSION:=a29bad9454edcc285f7f37410b6822affede44d1 -PKG_MIRROR_HASH:=eaba0f12c469ef82b772a64f8763e8855dbba81551a78d05f547c0922a7dacad +PKG_SOURCE_DATE:=2022-12-02 +PKG_SOURCE_VERSION:=46d93c9cc5da6fce581df86159bd0fc4357de41c +PKG_MIRROR_HASH:=970a47f1bef719f056d40d17398db492bd4de92b98ef9aba4582cb18b4c9b270 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC -PKG_ABI_VERSION:=20220206 +PKG_ABI_VERSION:=20220812 include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk CMAKE_OPTIONS += -DSOVERSION=$(PKG_ABI_VERSION) +CMAKE_HOST_OPTIONS += \ + -DSOVERSION=$(PKG_ABI_VERSION) \ + -DFS_SUPPORT=ON \ + -DMATH_SUPPORT=ON \ + -DNL80211_SUPPORT=OFF \ + -DRESOLV_SUPPORT=OFF \ + -DRTNL_SUPPORT=OFF \ + -DSTRUCT_SUPPORT=ON \ + -DUBUS_SUPPORT=OFF \ + -DUCI_SUPPORT=OFF \ + -DULOOP_SUPPORT=OFF + define Package/ucode/default SECTION:=utils @@ -143,6 +156,18 @@ define Package/ucode-mod-uci/description endef +define Package/ucode-mod-uloop + $(Package/ucode/default) + TITLE+= (uloop module) + DEPENDS:=ucode +libubox +endef + +define Package/ucode-mod-uloop/description + The uloop module allows ucode scripts to interact with OpenWrt uloop event + loop implementation. +endef + + define Build/InstallDev $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include/ucode $(CP) $(PKG_INSTALL_DIR)/usr/include/ucode/*.h $(1)/usr/include/ucode/ @@ -152,7 +177,7 @@ endef define Package/ucode/install $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ucode $(1)/usr/bin/ucode + $(CP) $(PKG_INSTALL_DIR)/usr/bin/u* $(1)/usr/bin/ endef define Package/libucode/install @@ -200,9 +225,13 @@ define Package/ucode-mod-uci/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/uci.so $(1)/usr/lib/ucode/ endef +define Package/ucode-mod-uloop/install + $(INSTALL_DIR) $(1)/usr/lib/ucode + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/uloop.so $(1)/usr/lib/ucode/ +endef -$(eval $(call BuildPackage,ucode)) $(eval $(call BuildPackage,libucode)) +$(eval $(call BuildPackage,ucode)) $(eval $(call BuildPackage,ucode-mod-fs)) $(eval $(call BuildPackage,ucode-mod-math)) $(eval $(call BuildPackage,ucode-mod-nl80211)) @@ -211,3 +240,5 @@ $(eval $(call BuildPackage,ucode-mod-rtnl)) $(eval $(call BuildPackage,ucode-mod-struct)) $(eval $(call BuildPackage,ucode-mod-ubus)) $(eval $(call BuildPackage,ucode-mod-uci)) +$(eval $(call BuildPackage,ucode-mod-uloop)) +$(eval $(call HostBuild)) diff --git a/package/utils/uencrypt/Makefile b/package/utils/uencrypt/Makefile new file mode 100644 index 000000000..688c38a5b --- /dev/null +++ b/package/utils/uencrypt/Makefile @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2022 Eneas Ulir de Queiroz + +include $(TOPDIR)/rules.mk + +PKG_NAME:=uencrypt +PKG_RELEASE:=2 + +PKG_FLAGS:=nonshared +PKG_LICENSE:=GPL-2.0-or-later +PKG_MAINTAINER:=Eneas U de Queiroz +PKG_CONFIG_DEPENDS:=\ + CONFIG_UENCRYPT_OPENSSL \ + CONFIG_UENCRYPT_WOLFSSL + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +CMAKE_INSTALL:=1 +CMAKE_OPTIONS+=$(if $(CONFIG_UENCRYPT_WOLFSSL),-DUSE_WOLFSSL=1) + +define Package/uencrypt + SECTION:=utils + CATEGORY:=Base system + TITLE:=Decryption utility for Arcadyan WG4xx223 and TP-Link Deco S4 + DEPENDS:=+UENCRYPT_WOLFSSL:libwolfssl +UENCRYPT_OPENSSL:libopenssl +endef + +define Package/uencrypt/description + This is a small encrypton/decryption program. It defaults + to AES-128-CBC, but supports any encryption provided by + the available openssl/wolfssl library. Even though it can + be used for regular encryption and decryption operations, + it is included here to unencrypt the configuration from mtd + on Arcadyan WG430223/WG443223 and TP-Link Deco S4 routers +endef + +define Package/uencrypt/config + if PACKAGE_uencrypt + choice + prompt "Crypto provider" + default UENCRYPT_OPENSSL + + config UENCRYPT_OPENSSL + bool "OpenSSL" + + config UENCRYPT_WOLFSSL + bool "wolfSSL" + endchoice + endif +endef + +define Package/uencrypt/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/uencrypt $(1)/usr/bin +endef + +$(eval $(call BuildPackage,uencrypt)) diff --git a/package/utils/uencrypt/src/CMakeLists.txt b/package/utils/uencrypt/src/CMakeLists.txt new file mode 100644 index 000000000..cd25d2f12 --- /dev/null +++ b/package/utils/uencrypt/src/CMakeLists.txt @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2022 Eneas Ulir de Queiroz + +cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) +project(uencrypt LANGUAGES C) + +option(USE_WOLFSSL "Use WolfSSL as crypto provider" OFF) +if (USE_WOLFSSL) + add_definitions(-DUSE_WOLFSSL) + find_library(WOLFSSL_LIBRARY wolfssl REQUIRED) + set(CRYPTO_LIBRARIES ${WOLFSSL_LIBRARY}) +else() + find_package(OpenSSL REQUIRED) + set(CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) +endif() + +add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c) +target_link_libraries(${PROJECT_NAME} ${CRYPTO_LIBRARIES}) + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) diff --git a/package/utils/uencrypt/src/uencrypt.c b/package/utils/uencrypt/src/uencrypt.c new file mode 100644 index 000000000..ab9a202ce --- /dev/null +++ b/package/utils/uencrypt/src/uencrypt.c @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2022 Eneas Ulir de Queiroz + */ + +#include +#include +#include +#include +#include + +#ifdef USE_WOLFSSL +# include +# include +#else +# include +#endif + +int do_crypt(FILE *infile, FILE *outfile, const EVP_CIPHER *cipher, const char *key, const char *iv, + int enc, int padding) +{ + EVP_CIPHER_CTX *ctx; + unsigned char inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH]; + int inlen, outlen; + + ctx = EVP_CIPHER_CTX_new(); + EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc); + EVP_CIPHER_CTX_set_padding(ctx, padding); + + for (;;) { + inlen = fread(inbuf, 1, 1024, infile); + if (inlen <= 0) + break; + if (!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen)) { + EVP_CIPHER_CTX_free(ctx); + return -1; + } + fwrite(outbuf, 1, outlen, outfile); + } + if (!EVP_CipherFinal_ex(ctx, outbuf, &outlen)) { + EVP_CIPHER_CTX_free(ctx); + return -1; + } + fwrite(outbuf, 1, outlen, outfile); + + EVP_CIPHER_CTX_free(ctx); + return 0; +} + +static void check_enc_dec(const int enc) +{ + if (enc == -1) + return; + fprintf(stderr, "Error: both -d and -e were specified.\n"); + exit(EXIT_FAILURE); +} + +#ifndef USE_WOLFSSL +static void print_ciphers(const OBJ_NAME *name,void *arg) { + fprintf(arg, "\t%s\n", name->name); +} +#endif + +static void check_cipher(const EVP_CIPHER *cipher) +{ + if (cipher == NULL) { + fprintf(stderr, "Error: invalid cipher: %s.\n", optarg); +#ifndef USE_WOLFSSL + fprintf(stderr, "Supported ciphers: \n", optarg); + OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, print_ciphers, stderr); +#endif + exit(EXIT_FAILURE); + } +} + +static void show_usage(const char* name) +{ + fprintf(stderr, "Usage: %s: [-d | -e] [-n] -k key [-i iv] [-c cipher]\n" + "-d = decrypt; -e = encrypt; -n = no padding\n", name); +} + +int main(int argc, char *argv[]) +{ + int enc = -1; + unsigned char *iv = NULL; + unsigned char *key = NULL; + long len; + int opt; + int padding = 1; + int need_iv = 1; + const EVP_CIPHER *cipher = EVP_aes_128_cbc(); + int ret; + + while ((opt = getopt(argc, argv, "c:dei:k:n")) != -1) { + switch (opt) { + case 'c': + cipher = EVP_get_cipherbyname(optarg); + check_cipher(cipher); + int arglen = strlen(optarg); + if (arglen > 3 && strncmp(optarg+arglen-3, "ecb", 3) == 0) //if ends with "ecb" + need_iv = 0; + break; + case 'd': + check_enc_dec(enc); + enc = 0; + break; + case 'e': + check_enc_dec(enc); + enc = 1; + break; + case 'i': + iv = OPENSSL_hexstr2buf((const char *)optarg, &len); + if (iv == NULL) { + fprintf(stderr, "Error setting IV to %s. The IV should be encoded in hex.\n", + optarg); + exit(EINVAL); + } + break; + case 'k': + key = OPENSSL_hexstr2buf((const char *)optarg, &len); + if (key == NULL) { + fprintf(stderr, "Error setting key to %s. The key should be encoded in hex.\n", + optarg); + exit(EINVAL); + } + break; + case 'n': + padding = 0; + break; + default: + show_usage(argv[0]); + exit(EINVAL); + } + } + if (need_iv && iv == NULL) { + fprintf(stderr, "Error: iv not set.\n"); + show_usage(argv[0]); + exit(EXIT_FAILURE); + } + if (key == NULL) { + fprintf(stderr, "Error: key not set.\n"); + show_usage(argv[0]); + exit(EXIT_FAILURE); + } + ret = do_crypt(stdin, stdout, cipher, key, iv, !!enc, padding); + if (ret) + fprintf(stderr, "Error during crypt operation.\n"); + OPENSSL_free(iv); + OPENSSL_free(key); + return ret; +} diff --git a/package/utils/ugps/files/ugps.init b/package/utils/ugps/files/ugps.init index 3cd1ca1b8..77c360306 100644 --- a/package/utils/ugps/files/ugps.init +++ b/package/utils/ugps/files/ugps.init @@ -16,11 +16,16 @@ start_service() { local disabled="$(uci get gps.@gps[-1].disabled || echo 0)" [ "$disabled" == "0" ] || return + [ "$tty" ] || return - [ -c "$tty" ] || { - tty="/dev/$tty" - [ -c "$tty" ] || return - } + case "$tty" in + "/"*) + true + ;; + *) + tty="/dev/$tty" + ;; + esac procd_open_instance procd_set_param command "$PROG" diff --git a/package/utils/util-linux/Makefile b/package/utils/util-linux/Makefile index ce3cd171e..706c3194b 100644 --- a/package/utils/util-linux/Makefile +++ b/package/utils/util-linux/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=util-linux -PKG_VERSION:=2.37.3 +PKG_VERSION:=2.38 PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.37 -PKG_HASH:=590c592e58cd6bf38519cb467af05ce6a1ab18040e3e3418f24bcfb2f55f9776 +PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.38 +PKG_HASH:=6d111cbe4d55b336db2f1fbeffbc65b89908704c01136371d32aa9bec373eb64 PKG_CPE_ID:=cpe:/a:kernel:util-linux PKG_LICENSE:=GPL-2.0-only @@ -25,14 +25,10 @@ PKG_LICENSE_FILES:= COPYING \ libuuid/COPYING \ Documentation/licenses/COPYING.BSD-3 -PKG_BUILD_PARALLEL:=1 - -PKG_FIXUP:=autoreconf PKG_INSTALL:=1 -DISABLE_NLS:=--disable-nls - include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/meson.mk define Package/util-linux/Default SECTION:=utils @@ -339,6 +335,16 @@ define Package/lslocks/description lslocks lists information about all the currently held file locks in a Linux system endef +define Package/lsns +$(call Package/util-linux/Default) + TITLE:=list system namespaces + DEPENDS:= +libblkid +libmount +libsmartcols +endef + +define Package/lsns/description + lsns lists information about all namespaces and their processes +endef + define Package/more $(call Package/util-linux/Default) TITLE:=filter for paging through text one screenful at a time @@ -542,44 +548,69 @@ define Package/wipefs/description libblkid. endef -CONFIGURE_ARGS += \ - --disable-use-tty-group \ - --disable-rpath \ - --disable-tls \ - --disable-su \ - --disable-sulogin \ - --disable-makeinstall-chown \ - --disable-login \ - --disable-nologin \ - --disable-lslogins \ - --disable-runuser \ - --disable-chfn-chsh \ - --disable-raw \ - --without-python \ - --without-udev \ - --without-readline \ - --without-libmagic \ - --with-ncursesw - -TARGET_CFLAGS += $(FPIC) -std=gnu99 +MESON_ARGS += \ + -Dsystemd=disabled \ + -Dtinfo=disabled \ + -Dcryptsetup=disabled \ + -Dlibutil=disabled \ + -Dlibutempter=disabled \ + -Dlibpcre2-posix=disabled \ + -Dlibuser=disabled \ + -Duse-tty-group=false \ + -Duse-tls=false \ + -Dbuild-python=disabled \ + -Dbuild-zramctl=disabled \ + -Dbuild-fsck=disabled \ + -Dbuild-wipefs=disabled \ + -Dbuild-fallocate=disabled \ + -Dbuild-setpriv=disabled \ + -Dbuild-hardlink=disabled \ + -Dbuild-cramfs=disabled \ + -Dbuild-bfs=disabled \ + -Dbuild-minix=disabled \ + -Dbuild-fdformat=disabled \ + -Dbuild-lslogins=disabled \ + -Dbuild-wdctl=disabled \ + -Dbuild-cal=disabled \ + -Dbuild-switch_root=disabled \ + -Dbuild-pivot_root=disabled \ + -Dbuild-lsmem=disabled \ + -Dbuild-lsirq=disabled \ + -Dbuild-irqtop=disabled \ + -Dbuild-chmem=disabled \ + -Dbuild-ipcrm=disabled \ + -Dbuild-rfkill=disabled \ + -Dbuild-tunelp=disabled \ + -Dbuild-kill=disabled \ + -Dbuild-last=disabled \ + -Dbuild-utmpdump=disabled \ + -Dbuild-line=disabled \ + -Dbuild-mesg=disabled \ + -Dbuild-raw=disabled \ + -Dbuild-vipw=disabled \ + -Dbuild-newgrp=disabled \ + -Dbuild-chfn-chsh=disabled \ + -Dbuild-login=disabled \ + -Dbuild-nologin=disabled \ + -Dbuild-sulogin=disabled \ + -Dbuild-su=disabled \ + -Dbuild-runuser=disabled \ + -Dbuild-ul=disabled \ + -Dbuild-pg=disabled \ + -Dbuild-write=disabled \ + -Dbuild-bash-completion=disabled \ + -Dbuild-pylibmount=disabled \ + -Dreadline=disabled \ + -Dmagic=disabled \ + -Dncursesw=enabled define Build/InstallDev $(INSTALL_DIR) $(1)/usr/lib/pkgconfig $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/blkid.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/blkid.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/blkid.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/fdisk.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/fdisk.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/fdisk.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mount.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/mount.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/mount.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/smartcols.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/smartcols.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/smartcols.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/uuid.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/uuid.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/uuid.pc $(INSTALL_DIR) $(1)/usr/include/blkid $(CP) $(PKG_INSTALL_DIR)/usr/include/blkid/blkid.h $(1)/usr/include/blkid @@ -593,43 +624,37 @@ define Build/InstallDev $(CP) $(PKG_INSTALL_DIR)/usr/include/libsmartcols/libsmartcols.h $(1)/usr/include/libsmartcols $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libblkid.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libfdisk.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libmount.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libuuid.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libsmartcols.so* $(1)/usr/lib - - $(LN) libblkid.so.1 $(1)/usr/lib/libblkid.so - $(LN) libfdisk.so.1 $(1)/usr/lib/libfdisk.so - $(LN) libmount.so.1 $(1)/usr/lib/libmount.so - $(LN) libuuid.so.1 $(1)/usr/lib/libuuid.so - $(LN) libsmartcols.so.1 $(1)/usr/lib/libsmartcols.so + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libblkid.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfdisk.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmount.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libuuid.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsmartcols.so* $(1)/usr/lib endef define Package/libfdisk/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libfdisk.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfdisk.so.* $(1)/usr/lib/ endef define Package/libblkid/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libblkid.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libblkid.so.* $(1)/usr/lib/ endef define Package/libmount/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libmount.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmount.so.* $(1)/usr/lib/ endef define Package/libsmartcols/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libsmartcols.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsmartcols.so.* $(1)/usr/lib/ endef define Package/libuuid/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libuuid.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libuuid.so.* $(1)/usr/lib/ endef define Package/agetty/install @@ -737,6 +762,11 @@ define Package/lslocks/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lslocks $(1)/usr/bin/ endef +define Package/lsns/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsns $(1)/usr/bin/ +endef + define Package/more/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/more $(1)/usr/bin/ @@ -866,6 +896,7 @@ $(eval $(call BuildPackage,losetup)) $(eval $(call BuildPackage,lsblk)) $(eval $(call BuildPackage,lscpu)) $(eval $(call BuildPackage,lslocks)) +$(eval $(call BuildPackage,lsns)) $(eval $(call BuildPackage,more)) $(eval $(call BuildPackage,mcookie)) $(eval $(call BuildPackage,mount-utils)) diff --git a/package/utils/util-linux/patches/010-meson-typo.patch b/package/utils/util-linux/patches/010-meson-typo.patch new file mode 100644 index 000000000..466d942d5 --- /dev/null +++ b/package/utils/util-linux/patches/010-meson-typo.patch @@ -0,0 +1,20 @@ +From c387d4fe7a1435a762a5b7d8b75feb13ad613315 Mon Sep 17 00:00:00 2001 +From: Anatoly Pugachev +Date: Fri, 8 Apr 2022 15:34:16 +0300 +Subject: [PATCH] libfdisk: meson.build fix typo + +--- + libfdisk/meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/libfdisk/meson.build ++++ b/libfdisk/meson.build +@@ -11,7 +11,7 @@ libfdisk_h = configure_file( + output : 'libfdisk.h', + configuration : defs, + install : build_libfdisk, +- install_dir : join_paths(get_option('includedir'), 'libfisk'), ++ install_dir : join_paths(get_option('includedir'), 'libfdisk'), + ) + + lib_fdisk_sources = ''' diff --git a/package/utils/util-linux/patches/020-meson-fix-compilation-without-systemd.patch b/package/utils/util-linux/patches/020-meson-fix-compilation-without-systemd.patch new file mode 100644 index 000000000..aa209994e --- /dev/null +++ b/package/utils/util-linux/patches/020-meson-fix-compilation-without-systemd.patch @@ -0,0 +1,22 @@ +From 38b15ca2dc4ca32bbe4a2449e1c7b645e4577840 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Fri, 29 Apr 2022 16:53:43 -0700 +Subject: [PATCH 1/7] meson: fix compilation without systemd + +systemdsystemunitdir is used elsewhere. + +Signed-off-by: Rosen Penev +--- + meson.build | 1 + + 1 file changed, 1 insertion(+) + +--- a/meson.build ++++ b/meson.build +@@ -720,6 +720,7 @@ if fs_search_path_extra != '' + endif + conf.set_quoted('FS_SEARCH_PATH', fs_search_path) + ++systemdsystemunitdir = '' + if systemd.found() + systemdsystemunitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir') + endif diff --git a/package/utils/util-linux/patches/030-meson-don-t-use-run.patch b/package/utils/util-linux/patches/030-meson-don-t-use-run.patch new file mode 100644 index 000000000..7803dd772 --- /dev/null +++ b/package/utils/util-linux/patches/030-meson-don-t-use-run.patch @@ -0,0 +1,34 @@ +From e25db9169450d3d5fb43656a2eae5c08999310f4 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Fri, 29 Apr 2022 16:56:54 -0700 +Subject: [PATCH 2/7] meson: don't use run + +Fixes cross compilation. run is not needed anyway. + +Signed-off-by: Rosen Penev +--- + meson.build | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/meson.build ++++ b/meson.build +@@ -577,8 +577,7 @@ int main(void) { + return tzname ? 0 : 1; + } + '''.format(have ? 1 : 0) +-result = cc.run(code, name : 'using tzname[]') +-have = result.compiled() and result.returncode() == 0 ++have = cc.compiles(code, name : 'using tzname[]') + conf.set('HAVE_TZNAME', have ? 1 : false) + + socket_libs = [] +@@ -641,8 +640,7 @@ int main(void) { + return (*__progname != 0); + } + ''' +-result = cc.run(code, name : 'using __progname') +-have = result.compiled() and result.returncode() == 0 ++have = cc.compiles(code, name : 'using __progname') + conf.set('HAVE___PROGNAME', have ? 1 : false) + + build_plymouth_support = get_option('build-plymouth-support') diff --git a/package/utils/util-linux/patches/040-meson-fix-cpu_set_t-test.patch b/package/utils/util-linux/patches/040-meson-fix-cpu_set_t-test.patch new file mode 100644 index 000000000..bdbfc4bfe --- /dev/null +++ b/package/utils/util-linux/patches/040-meson-fix-cpu_set_t-test.patch @@ -0,0 +1,23 @@ +From 4194bb5b35e9b5f3296bf17b7cabcc5cb1632ba3 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Fri, 29 Apr 2022 16:55:15 -0700 +Subject: [PATCH 3/7] meson: fix cpu_set_t test + +_GNU_SOURCE is needed here. + +Signed-off-by: Rosen Penev +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -379,7 +379,7 @@ endforeach + have = cc.has_header('sched.h') + conf.set10('HAVE_DECL_CPU_ALLOC', have) + # We get -1 if the size cannot be determined +-have_cpu_set_t = cc.sizeof('cpu_set_t', prefix : '#include ') > 0 ++have_cpu_set_t = cc.sizeof('cpu_set_t', prefix : '#define _GNU_SOURCE\n#include ') > 0 + conf.set('HAVE_CPU_SET_T', have_cpu_set_t ? 1 : false) + + have = cc.has_header_symbol('stdlib.h', 'environ') diff --git a/package/utils/util-linux/patches/050-meson-fix-environ-search.patch b/package/utils/util-linux/patches/050-meson-fix-environ-search.patch new file mode 100644 index 000000000..2cd02e5b4 --- /dev/null +++ b/package/utils/util-linux/patches/050-meson-fix-environ-search.patch @@ -0,0 +1,23 @@ +From 1e9e2b9fe365cc4a0025d44dc0a9c54bfffe9058 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Fri, 29 Apr 2022 18:16:17 -0700 +Subject: [PATCH 4/7] meson: fix environ search + +musl has it defined in unistd.h and hidden behind _GNU_SOURCE. + +Signed-off-by: Rosen Penev +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -382,7 +382,7 @@ conf.set10('HAVE_DECL_CPU_ALLOC', have) + have_cpu_set_t = cc.sizeof('cpu_set_t', prefix : '#define _GNU_SOURCE\n#include ') > 0 + conf.set('HAVE_CPU_SET_T', have_cpu_set_t ? 1 : false) + +-have = cc.has_header_symbol('stdlib.h', 'environ') ++have = cc.has_header_symbol('unistd.h', 'environ', prefix : '#define _GNU_SOURCE') + conf.set10('HAVE_ENVIRON_DECL', have) + + have = cc.has_header_symbol('signal.h', 'sighandler_t') diff --git a/package/utils/util-linux/patches/060-meson-add-_GNU_SOURCE-for-sighandler_t.patch b/package/utils/util-linux/patches/060-meson-add-_GNU_SOURCE-for-sighandler_t.patch new file mode 100644 index 000000000..7f9137f8b --- /dev/null +++ b/package/utils/util-linux/patches/060-meson-add-_GNU_SOURCE-for-sighandler_t.patch @@ -0,0 +1,23 @@ +From 5d7557eb3827664b2b78145373907f2a6994bdf9 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Fri, 29 Apr 2022 18:17:52 -0700 +Subject: [PATCH 5/7] meson: add _GNU_SOURCE for sighandler_t + +musl requires it. + +Signed-off-by: Rosen Penev +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -385,7 +385,7 @@ conf.set('HAVE_CPU_SET_T', have_cpu_set_ + have = cc.has_header_symbol('unistd.h', 'environ', prefix : '#define _GNU_SOURCE') + conf.set10('HAVE_ENVIRON_DECL', have) + +-have = cc.has_header_symbol('signal.h', 'sighandler_t') ++have = cc.has_header_symbol('signal.h', 'sighandler_t', prefix : '#define _GNU_SOURCE') + conf.set('HAVE_SIGHANDLER_T', have ? 1 : false) + + have = cc.has_header_symbol('string.h', 'strsignal') diff --git a/package/utils/util-linux/patches/070-meson-fix-isnan-check.patch b/package/utils/util-linux/patches/070-meson-fix-isnan-check.patch new file mode 100644 index 000000000..a0b104f80 --- /dev/null +++ b/package/utils/util-linux/patches/070-meson-fix-isnan-check.patch @@ -0,0 +1,24 @@ +From 777652585924034deeba98ae3192f26bc32bb661 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Fri, 29 Apr 2022 18:19:53 -0700 +Subject: [PATCH 6/7] meson: fix isnan check + +musl only has isnan as a macro, not as a function. Handle the former +case. + +Signed-off-by: Rosen Penev +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -622,7 +622,7 @@ rtas_libs = cc.find_library('rtas', requ + conf.set('HAVE_LIBRTAS', rtas_libs.found() ? 1 : false) + + math_libs = [] +-if not cc.has_function('isnan') ++if not cc.has_header_symbol('math.h', 'isnan') + lib = cc.find_library('m', required : true) + if (cc.has_function('isnan', dependencies : lib) and + cc.has_function('__isnan', dependencies : lib)) diff --git a/package/utils/util-linux/patches/080-meson-fix-tzname-check.patch b/package/utils/util-linux/patches/080-meson-fix-tzname-check.patch new file mode 100644 index 000000000..f5d53c4d3 --- /dev/null +++ b/package/utils/util-linux/patches/080-meson-fix-tzname-check.patch @@ -0,0 +1,23 @@ +From 9a6b2618b46a859388139d1eb18f876886786659 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Fri, 29 Apr 2022 19:00:53 -0700 +Subject: [PATCH] meson: fix tzname check + +tzname is not a type but a variable. sizeof only works on types. + +Signed-off-by: Rosen Penev +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -565,7 +565,7 @@ have = cc.has_member('struct tm', 'tm_zo + prefix : '#include ') + conf.set('HAVE_STRUCT_TM_TM_ZONE', have ? 1 : false) + +-have = cc.sizeof('tzname', prefix : '#include ') > 0 ++have = cc.has_header_symbol('time.h', 'tzname') + conf.set('HAVE_DECL_TZNAME', have ? 1 : false) + + code = ''' diff --git a/package/utils/util-linux/patches/090-meson-libpam.patch b/package/utils/util-linux/patches/090-meson-libpam.patch new file mode 100644 index 000000000..c9a91b993 --- /dev/null +++ b/package/utils/util-linux/patches/090-meson-libpam.patch @@ -0,0 +1,18 @@ +--- a/meson.build ++++ b/meson.build +@@ -299,10 +299,14 @@ conf.set('HAVE_LIBUDEV', lib_udev.found( + + lib_crypt = cc.find_library('crypt') + +-lib_pam = cc.find_library('pam') ++req_libpam = not (get_option('build-login').disabled() or get_option('build-chfn-chsh').disabled() ++ or get_option('build-su').disabled() or get_option('build-runuser').disabled()) ++lib_pam = cc.find_library('pam', required : req_libpam) + if lib_pam.found() + lib_pam_misc = cc.find_library('pam_misc') + lib_pam = [lib_pam, lib_pam_misc] ++else ++ lib_pam_misc = declare_dependency() + endif + + lib_cryptsetup = dependency( diff --git a/package/utils/util-linux/patches/100-meson-make-libcap-ng-dependent-on-setpriv.patch b/package/utils/util-linux/patches/100-meson-make-libcap-ng-dependent-on-setpriv.patch new file mode 100644 index 000000000..d8b119900 --- /dev/null +++ b/package/utils/util-linux/patches/100-meson-make-libcap-ng-dependent-on-setpriv.patch @@ -0,0 +1,31 @@ +From cd23a4336f49ba6a12ade557a09589f2a7c966f4 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Mon, 2 May 2022 16:18:33 -0700 +Subject: [PATCH] meson: make libcap-ng dependent on setpriv + +Signed-off-by: Rosen Penev +--- + meson.build | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/meson.build ++++ b/meson.build +@@ -334,7 +334,8 @@ have = cc.has_function( + conf.set('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', have ? 1 : false) + + lib_cap_ng = dependency( +- 'libcap-ng') ++ 'libcap-ng', ++ required : get_option('build-setpriv')) + + lib_selinux = dependency( + 'libselinux', +@@ -1754,7 +1755,7 @@ if opt and not is_disabler(exe) + exes += exe + endif + +-opt = not get_option('build-setpriv').disabled() ++opt = not get_option('build-setpriv').disabled() and lib_cap_ng.found() + exe = executable( + 'setpriv', + setpriv_sources, diff --git a/package/utils/util-linux/patches/110-meson-fix-when-HAVE_CLOCK_GETTIME-is-set.patch b/package/utils/util-linux/patches/110-meson-fix-when-HAVE_CLOCK_GETTIME-is-set.patch new file mode 100644 index 000000000..bba8baf5a --- /dev/null +++ b/package/utils/util-linux/patches/110-meson-fix-when-HAVE_CLOCK_GETTIME-is-set.patch @@ -0,0 +1,21 @@ +From e51565b653cf09985df57cb7254b16d5af5df223 Mon Sep 17 00:00:00 2001 +From: Nicolas Caramelli +Date: Fri, 29 Apr 2022 18:16:36 +0200 +Subject: [PATCH] meson: fix when HAVE_CLOCK_GETTIME is set + +Signed-off-by: Nicolas Caramelli +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -602,7 +602,7 @@ if not have + have = cc.has_function('clock_gettime', + dependencies : realtime_libs) + endif +-conf.set('HAVE_CLOCK_GETTIME', have_dirfd ? 1 : false) ++conf.set('HAVE_CLOCK_GETTIME', have ? 1 : false) + + thread_libs = dependency('threads') + diff --git a/package/utils/util-linux/patches/120-meson-get-the-project-version-from-the-version-gen-s.patch b/package/utils/util-linux/patches/120-meson-get-the-project-version-from-the-version-gen-s.patch new file mode 100644 index 000000000..8529c8268 --- /dev/null +++ b/package/utils/util-linux/patches/120-meson-get-the-project-version-from-the-version-gen-s.patch @@ -0,0 +1,20 @@ +From e0c1a86bf88b568a7afe8ebaea1b9f84afb892c2 Mon Sep 17 00:00:00 2001 +From: Eli Schwartz +Date: Wed, 4 May 2022 23:52:31 -0400 +Subject: [PATCH] meson: get the project version from the version-gen script + +This matches autotools and ensures that the version number is actually +reliable. +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -1,5 +1,5 @@ + project('util-linux', 'c', +- version : '2.37', ++ version : run_command('tools/git-version-gen', check: true).stdout(), + license : 'GPLv2+') + + pkgconfig = import('pkgconfig') diff --git a/package/utils/util-linux/patches/130-meson-fix-error-in-processing-version-for-pc-files.patch b/package/utils/util-linux/patches/130-meson-fix-error-in-processing-version-for-pc-files.patch new file mode 100644 index 000000000..75e88682e --- /dev/null +++ b/package/utils/util-linux/patches/130-meson-fix-error-in-processing-version-for-pc-files.patch @@ -0,0 +1,26 @@ +From dc307e1cbf73f6dbf72bb049c19d332774cdb4e7 Mon Sep 17 00:00:00 2001 +From: Eli Schwartz +Date: Thu, 5 May 2022 00:16:15 -0400 +Subject: [PATCH] meson: fix error in processing version for pc files + +This awk command was copied verbatim from configure.ac, which included +non-awk syntax because configure.ac cannot contain [ literals. + +Rewrite these autoconf quadrigraphs as their actual values, for meson. + +Fixes always setting the micro version to "0". +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/meson.build ++++ b/meson.build +@@ -41,7 +41,7 @@ conf.set_quoted('PACKAGE_VERSION', meson + + codes = [''' {print $1} ''', + ''' {sub("-.*","",$2); print $2} ''', +- ''' {sub("-.*","",$3); print $3 ~ /^@<:@0-9@:>@+$/ ? $3 : 0} '''] ++ ''' {sub("-.*","",$3); print $3 ~ /^[0-9]+$/ ? $3 : 0} '''] + pc_version = [] + foreach code : codes + res = run_command('bash', '-c', diff --git a/package/utils/util-linux/patches/200-meson-no-po.patch b/package/utils/util-linux/patches/200-meson-no-po.patch new file mode 100644 index 000000000..d626036bb --- /dev/null +++ b/package/utils/util-linux/patches/200-meson-no-po.patch @@ -0,0 +1,10 @@ +--- a/meson.build ++++ b/meson.build +@@ -774,7 +774,6 @@ subdir('disk-utils') + subdir('misc-utils') + subdir('text-utils') + subdir('term-utils') +-subdir('po') + + includes = [dir_include, + dir_libblkid, diff --git a/package/utils/util-linux/patches/100-use_urandom.patch b/package/utils/util-linux/patches/210-use-urandom.patch similarity index 100% rename from package/utils/util-linux/patches/100-use_urandom.patch rename to package/utils/util-linux/patches/210-use-urandom.patch diff --git a/package/utils/zyxel-bootconfig/Makefile b/package/utils/zyxel-bootconfig/Makefile new file mode 100644 index 000000000..eb2dd79b8 --- /dev/null +++ b/package/utils/zyxel-bootconfig/Makefile @@ -0,0 +1,38 @@ +# +# Copyright (C) 2022 David Bauer +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=zyxel-bootconfig +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/zyxel-bootconfig + SECTION:=utils + CATEGORY:=Base system + TITLE:=Utility for handling ZyXEL Bootconfig settings + MAINTAINER:=David Bauer +endef + +define Package/zyxel-bootconfig/description + This package contains an utility that allows handling ZyXEL Bootconfig settings. +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" +endef + +define Package/zyxel-bootconfig/install + $(INSTALL_DIR) $(1)/usr/bin $(1)/lib/preinit + $(INSTALL_BIN) $(PKG_BUILD_DIR)/zyxel-bootconfig $(1)/usr/bin/ + $(CP) ./files/95_apply_bootconfig $(1)/lib/preinit/95_apply_bootconfig +endef + +$(eval $(call BuildPackage,zyxel-bootconfig)) diff --git a/package/utils/zyxel-bootconfig/files/95_apply_bootconfig b/package/utils/zyxel-bootconfig/files/95_apply_bootconfig new file mode 100644 index 000000000..c47857b08 --- /dev/null +++ b/package/utils/zyxel-bootconfig/files/95_apply_bootconfig @@ -0,0 +1,16 @@ +apply_bootconfig() { + . /lib/functions.sh + + local part + + case $(board_name) in + zyxel,nwa50ax|\ + zyxel,nwa55axe) + mtd_idx=$(find_mtd_index "bootconfig") + zyxel-bootconfig "/dev/mtd$mtd_idx" set-image-status 0 valid + zyxel-bootconfig "/dev/mtd$mtd_idx" set-active-image 0 + ;; + esac +} + +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main apply_bootconfig diff --git a/package/utils/zyxel-bootconfig/src/Makefile b/package/utils/zyxel-bootconfig/src/Makefile new file mode 100644 index 000000000..66741c8ac --- /dev/null +++ b/package/utils/zyxel-bootconfig/src/Makefile @@ -0,0 +1,7 @@ +all: zyxel-bootconfig + +zyxel-bootconfig: + $(CC) $(CFLAGS) -Wall zyxel-bootconfig.c -o zyxel-bootconfig + +clean: + rm -f zyxel-bootconfig diff --git a/package/utils/zyxel-bootconfig/src/zyxel-bootconfig.c b/package/utils/zyxel-bootconfig/src/zyxel-bootconfig.c new file mode 100644 index 000000000..6dd2f8969 --- /dev/null +++ b/package/utils/zyxel-bootconfig/src/zyxel-bootconfig.c @@ -0,0 +1,331 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2022 David Bauer */ + +/* + * First byte: Image status + * + * Possible status-codes: + * 0x0: none + * 0x1: new + * 0x2: valid + * 0x3: invalid + * + * Example: Image 0 valid; Image 1 invalid + * 11001000 + * || || + * img1|| + * img0 + * + * Second byte: Active Image + * Possible values: + * 0x0: Image0 active + * 0x1: Image1 active + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#define BOOTCONFIG_SIZE 0x20 +#define BOOTCONFIG_IMAGE_STATUS 0x0 +#define BOOTCONFIG_ACTIVE_IMAGE 0x1 + +#define IMAGE_0_SHIFT 2 +#define IMAGE_0_MASK 0x0c +#define IMAGE_1_SHIFT 6 +#define IMAGE_1_MASK 0xc0 + +#define IMAGE_STATUS(img0, img1) (((img0 << IMAGE_0_SHIFT) & IMAGE_0_MASK) | ((img1 << IMAGE_1_SHIFT) & IMAGE_1_MASK)) + +#define ACTIVE_IMAGE_MASK 0x1 +#define ACTIVE_IMAGE(img) (img & ACTIVE_IMAGE_MASK) + +enum zyxel_bootconfig_image_status { + IMAGE_STATUS_NONE = 0x0, + IMAGE_STATUS_NEW = 0x1, + IMAGE_STATUS_VALID = 0x2, + IMAGE_STATUS_INVALID = 0x3, + __IMAGE_STATUS_EINVAL, +}; + +struct zyxel_bootconfig { + enum zyxel_bootconfig_image_status image0_status; + enum zyxel_bootconfig_image_status image1_status; + unsigned int active_image; +}; + +struct zyxel_bootconfig_mtd { + struct mtd_info_user mtd_info; + int fd; +}; + +struct zyxel_image_status { + enum zyxel_bootconfig_image_status code; + const char *name; +}; + +struct zyxel_image_status image_status_codes[] = { + { .code = IMAGE_STATUS_NONE, .name = "none" }, + { .code = IMAGE_STATUS_NEW, .name = "new" }, + { .code = IMAGE_STATUS_VALID, .name = "valid" }, + { .code = IMAGE_STATUS_INVALID, .name = "invalid" }, + {}, +}; + + +static enum zyxel_bootconfig_image_status zyxel_bootconfig_image_status_parse(const char *status) { + struct zyxel_image_status* s; + + for (s = image_status_codes; s->name; s++) { + if (!strcmp(status, s->name)) { + return s->code; + } + } + + return __IMAGE_STATUS_EINVAL; +} + +const char *zyxel_bootconfig_image_status_name(const enum zyxel_bootconfig_image_status bootconfig) { + struct zyxel_image_status* s; + + for (s = image_status_codes; s->name; s++) { + if (bootconfig == s->code) { + return s->name; + } + } + + return "N/A"; +} + +static void zyxel_bootconfig_mtd_close(struct zyxel_bootconfig_mtd *mtd) { + close(mtd->fd); +} + + +static int zyxel_bootconfig_mtd_open(struct zyxel_bootconfig_mtd *mtd, const char *mtd_name) { + int ret = 0; + + mtd->fd = open(mtd_name, O_RDWR | O_SYNC); + if (mtd->fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd_name); + ret = -1; + goto out; + } + + if (ioctl(mtd->fd, MEMGETINFO, &mtd->mtd_info)) { + fprintf(stderr, "Could not get MTD device info from %s\n", mtd_name); + ret = -1; + zyxel_bootconfig_mtd_close(mtd); + goto out; + } + +out: + return ret; +} + + +static int zyxel_bootconfig_read(struct zyxel_bootconfig *config, struct zyxel_bootconfig_mtd *mtd) { + char *args = NULL; + int ret = 0; + + /* Allocate memory for reading boot-config partition */ + args = calloc(1, mtd->mtd_info.erasesize); + if (!args) { + fprintf(stderr, "Could not allocate memory!\n"); + ret = -1; + goto out; + } + + /* Read bootconfig partition */ + pread(mtd->fd, args, mtd->mtd_info.erasesize, 0); + + /* Parse config */ + memset(config, 0, sizeof(*config)); + + config->image0_status = (args[BOOTCONFIG_IMAGE_STATUS] & IMAGE_0_MASK) >> IMAGE_0_SHIFT; + config->image1_status = (args[BOOTCONFIG_IMAGE_STATUS] & IMAGE_1_MASK) >> IMAGE_1_SHIFT; + config->active_image = (args[BOOTCONFIG_ACTIVE_IMAGE] & ACTIVE_IMAGE_MASK); + +out: + if (args) + free(args); + return ret; +} + + +static int zyxel_bootconfig_write(struct zyxel_bootconfig *config, struct zyxel_bootconfig_mtd *mtd) +{ + struct erase_info_user erase_info; + char img_status, img_active; + char *args = NULL; + int ret = 0; + + /* Allocate memory for reading boot-config partition */ + args = calloc(1, mtd->mtd_info.erasesize); + if (!args) { + fprintf(stderr, "Could not allocate memory!\n"); + ret = -1; + goto out; + } + + /* Read bootconfig partition */ + pread(mtd->fd, args, mtd->mtd_info.erasesize, 0); + + img_status = IMAGE_STATUS(config->image0_status, config->image1_status); + img_active = ACTIVE_IMAGE(config->active_image); + + /* Check if bootconfig has to be written */ + if (args[BOOTCONFIG_IMAGE_STATUS] == img_status && args[BOOTCONFIG_ACTIVE_IMAGE] == img_active) { + ret = 0; + goto out; + } + + /* Erase first block (containing the magic) */ + erase_info.start = 0; + erase_info.length = mtd->mtd_info.erasesize; + ret = ioctl(mtd->fd, MEMERASE, &erase_info); + if (ret < 0) { + fprintf(stderr, "Failed to erase block: %i\n", ret); + goto out; + } + + + /* Write bootconfig */ + args[BOOTCONFIG_IMAGE_STATUS] = img_status; + args[BOOTCONFIG_ACTIVE_IMAGE] = img_active; + + if (pwrite(mtd->fd, args, mtd->mtd_info.erasesize, 0) != mtd->mtd_info.erasesize) { + fprintf(stderr, "Error writing bootconfig!\n"); + ret = -1; + goto out; + } + +out: + if (args) + free(args); + return ret; +} + + +static void zyxel_bootconfig_print_usage(char *programm) +{ + struct zyxel_image_status* s = image_status_codes; + + printf("Usage: %s [args]\n", programm); + printf("Available commands:\n"); + printf(" get-status\n"); + printf(" set-image-status [0/1] ["); + + while (s->name) { + printf("%s", s->name); + s++; + + if (s->name) + printf(","); + } + + printf("]\n"); + printf(" set-active-image [0/1]\n"); +} + +int main(int argc, char *argv[]) +{ + enum zyxel_bootconfig_image_status image_status; + struct zyxel_bootconfig_mtd mtd; + struct zyxel_bootconfig config; + const char *mtd_name, *command; + bool writeback = false; + int image_idx; + + if (argc < 3) { + zyxel_bootconfig_print_usage(argv[0]); + return 1; + } + + mtd_name = argv[1]; + command = argv[2]; + + if (zyxel_bootconfig_mtd_open(&mtd, mtd_name)) { + fprintf(stderr, "Error opening %s!\n", mtd_name); + return 1; + } + + if (zyxel_bootconfig_read(&config, &mtd)) { + fprintf(stderr, "Error reading bootconfig!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + if (!strcmp(command, "set-image-status")) { + if (argc < 5) { + zyxel_bootconfig_print_usage(argv[0]); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + image_idx = atoi(argv[3]); + if (image_idx > 1 || image_idx < 0) { + fprintf(stderr, "Invalid image-slot set!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + image_status = zyxel_bootconfig_image_status_parse(argv[4]); + if (image_status == __IMAGE_STATUS_EINVAL) { + fprintf(stderr, "Invalid image-status!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + if (image_idx == 0) { + config.image0_status = image_status; + } else { + config.image1_status = image_status; + } + + writeback = true; + } else if (!strcmp(command, "set-active-image")) { + if (argc < 4) { + zyxel_bootconfig_print_usage(argv[0]); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + image_idx = atoi(argv[3]); + if (image_idx > 1 || image_idx < 0) { + fprintf(stderr, "Invalid image-slot set!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + config.active_image = image_idx; + + writeback = true; + } else if (!strcmp(command, "get-status")) { + printf("Active Image: %d\n", config.active_image); + printf("Image 0 Status: %s\n", zyxel_bootconfig_image_status_name(config.image0_status)); + printf("Image 1 Status: %s\n", zyxel_bootconfig_image_status_name(config.image1_status)); + + writeback = false; + } + + if (writeback) { + if (zyxel_bootconfig_write(&config, &mtd)) { + fprintf(stderr, "Error writing bootconfig!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + zyxel_bootconfig_mtd_close(&mtd); + } + + return 0; +} diff --git a/scripts/cameo-imghdr.py b/scripts/cameo-imghdr.py new file mode 100755 index 000000000..1f8292b90 --- /dev/null +++ b/scripts/cameo-imghdr.py @@ -0,0 +1,86 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2022 Luiz Angelo Daros de Luca +# +# Cameo Image header geneator, used by some D-Link DGS-1210 switches +# and APRESIA ApresiaLightGS series +# +import argparse +import pathlib +import socket +import struct + +MODEL_LEN = 20 +SIGNATURE_LEN = 16 +LINUXLOAD_LEN = 10 +BUFSIZE = 4096 + +parser = argparse.ArgumentParser(description='Generate Cameo firmware header.') +parser.add_argument('source_file', type=argparse.FileType('rb')) +parser.add_argument('dest_file', type=argparse.FileType('wb')) +parser.add_argument('model') +parser.add_argument('signature') +parser.add_argument('partition', type=int, choices=range(0,10), + metavar="partition=[0-9]",help="partition id") +parser.add_argument('customer_signature', type=int, choices=range(0,10), + metavar="customer_signature=[0-9]", + help="customer signature") +parser.add_argument('board_version', type=int, choices=range(0,2**32), + metavar="board_version=[0-4294967295]", + help="board version") +parser.add_argument('linux_loadaddr', nargs='?', + help="Kernel start address in 0xFFFFFFFF format") +args = parser.parse_args() + +if len(args.model) > MODEL_LEN: + raise ValueError(f"Model '{args.model}' is greater than {MODEL_LEN} bytes") + +if len(args.signature) > SIGNATURE_LEN: + raise ValueError(f"Signature '{args.signature}' is greater than" + f"{SIGNATURE_LEN} bytes") + +if args.signature == "os": + if args.linux_loadaddr: + if len(args.linux_loadaddr) > LINUXLOAD_LEN: + raise ValueError(f"linux_loadaddr '{args.linux_loadaddr}' is greater" + f"than {LINUXLOAD_LEN} bytes") + if (args.linux_loadaddr[0:2] != "0x"): + raise ValueError(f"linux_loadaddr '{args.linux_loadaddr}' must use" + f"the 0x789ABCDE format") + int(args.linux_loadaddr[2:],16) + else: + raise ValueError(f"linux_loadaddr is required for signature 'os'") +else: + args.linux_loadaddr = "" + +checksum = 0 +size = 0 +while True: + buf = args.source_file.read(BUFSIZE) + if not buf: + break + checksum = sum(iter(buf),checksum) % (1<<32) + size += len(buf) + +args.dest_file.write(struct.pack('!I', checksum)) +args.dest_file.write(struct.pack(f'{MODEL_LEN}s', + args.model.encode("ascii"))) +args.dest_file.write(struct.pack(f'{SIGNATURE_LEN}s', + args.signature.encode("ascii"))) +args.dest_file.write(struct.pack('!B', args.partition)) +args.dest_file.write(struct.pack('!B', 0x40)) # ??? This header size? +args.dest_file.write(struct.pack('!B', 0x00)) # ??? Encrypted? +args.dest_file.write(struct.pack('!B', args.customer_signature)) +args.dest_file.write(struct.pack('!I', args.board_version)) +args.dest_file.write(struct.pack('!I', size)) +args.dest_file.write(struct.pack(f'{LINUXLOAD_LEN}s', + args.linux_loadaddr.encode("ascii"))) +args.dest_file.write(struct.pack('!2x')) + +args.source_file.seek(0) +while True: + buf = args.source_file.read(BUFSIZE) + if not buf: + break + args.dest_file.write(buf) diff --git a/scripts/cameo-tag.py b/scripts/cameo-tag.py new file mode 100755 index 000000000..becd69f8e --- /dev/null +++ b/scripts/cameo-tag.py @@ -0,0 +1,117 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2022 OpenWrt.org +# +# ./cameo-tag.py +# +# CAMEO tag generator used for the D-Link DGS-1210 switches. Their U-Boot +# loader checks for the string CAMEOTAG and a checksum in the kernel and +# rootfs partitions. If not found it complains about the boot image. +# Nevertheless it will boot if the tags are available in the secondary +# boot partitions. If some day we want to overwrite the original vendor +# partition we must have the tags in place. To solve this we insert the +# tag two times into the kernel image. +# +# To understand what we do here it is helpful to explain how the original +# CAMEO tag generation/checking works. The firmware consists of two parts. +# A kernel uImage (<1.5MB) and a rootfs image (<12MB) that are written to +# their respective mtd partitions. The default generator simply checksums +# both parts and appends 16 bytes [<0001>] to each part. +# The checksum is only an addition of all preceding bytes (b0+b1+b2+...). +# A tag does not interfere with any data in the images itself. During boot +# the loader will scan all primary/secondary partitions (2*kernel, 2*rootfs) +# until it finds the CAMEO tag. If checksums match everything is fine. +# If all 4 fail we are lost. Luckily the loader does not care about where +# the tags are located and ignores any data beyond a tag. +# +# The OpenWrt image consists of a kernel (>1.5MB) and a rootfs. There is +# no chance to add CAMEO tags at the default locations, since the kernel spans +# both the original kernel partition and the start of the rootfs partition. +# This would leave the kernel partition without a tag. So we must find suitable +# space. +# +# Location for original kernel partition is at the end of the uImage header. +# We will reuse the last bytes of the IH_NAME field. This is the tricky part +# because we have the header CRC and the CAMEO checksum that must match the +# whole header. uImage header CRC checksums all data except the CRC itself. The +# for CAMEO checksum in turn, checksums all preceding data except itself. +# Changing one of both results in a change of the other, but data trailing the +# CAMEO checksum only influences the CRC. +# +# Location for original rootfs partition is very simple. It is behind the +# OpenWrt compressed kernel image file that spans into the rootfs. So +# the tag will be written somewhere to the following rootfs partition and +# can be found by U-Boot. The CAMEO checksum calculation must start at the +# offset of the original rootfs partition and includes the "second" half of the +# "split" kernel uImage. + +import argparse +import os +import zlib + +READ_UNTIL_EOF = -1 +UIMAGE_HEADER_SIZE = 64 +UIMAGE_CRC_OFF = 4 +UIMAGE_CRC_END = 8 +UIMAGE_NAME_OFF = 32 +UIMAGE_NAME_END = 56 +UIMAGE_SUM_OFF = 56 +UIMAGE_SUM_END = 60 +UIMAGE_INV_OFF = 60 +UIMAGE_INV_END = 64 +CAMEO_TAG = bytes([0x43, 0x41, 0x4d, 0x45, 0x4f, 0x54, 0x41, 0x47, 0x00, 0x00, 0x00, 0x01]) +IMAGE_NAME = bytes([0x4f, 0x70, 0x65, 0x6e, 0x57, 0x72, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00]) +CRC_00 = bytes([0x00] * 4) +CRC_FF = bytes([0xff] * 4) + +def read_buffer(offset, count): + args.uimage_file.seek(offset) + return bytearray(args.uimage_file.read(count)) + +def write_buffer(whence, buf): + args.uimage_file.seek(0, whence) + args.uimage_file.write(buf) + +def cameosum(buf): + return (sum(buf) & 0xffffffff).to_bytes(4, 'big') + +def invertcrc(buf): + return (zlib.crc32(buf) ^ 0xffffffff).to_bytes(4, 'little') + +def checksum_header(buf): + # To efficently get a combination, we will make use of the following fact: + # crc32(data + littleendian(crc32(data) ^ 0xffffffff)) = 0xffffffff + # + # After manipulation the uImage header looks like this: + # [......<000000><0001>] + buf[UIMAGE_NAME_OFF:UIMAGE_NAME_END] = IMAGE_NAME + CAMEO_TAG + buf[UIMAGE_CRC_OFF:UIMAGE_CRC_END] = CRC_FF + buf[UIMAGE_SUM_OFF:UIMAGE_SUM_END] = cameosum(buf[0:UIMAGE_NAME_END]) + buf[UIMAGE_CRC_OFF:UIMAGE_CRC_END] = CRC_00 + buf[UIMAGE_INV_OFF:UIMAGE_INV_END] = invertcrc(buf[0:UIMAGE_SUM_END]) + buf[UIMAGE_CRC_OFF:UIMAGE_CRC_END] = CRC_FF + return buf + +parser = argparse.ArgumentParser(description='Insert CAMEO firmware tags.') +parser.add_argument('uimage_file', type=argparse.FileType('r+b')) +parser.add_argument('rootfs_start', type=int) +args = parser.parse_args() + +args.uimage_file.seek(0, os.SEEK_END) +if args.uimage_file.tell() <= args.rootfs_start: + raise ValueError(f"uImage must be larger than {args.rootfs_start} bytes") + +# tag for the uImage Header of 64 bytes inside the kernel +# partition. Read and mangle it so it contains a valid CAMEO tag +# and checksum that matches perfectly to the uImage header CRC. + +buf = checksum_header(read_buffer(0, UIMAGE_HEADER_SIZE)) +write_buffer(os.SEEK_SET, buf) + +# tag for the second part of the kernel that resides in the +# vendor rootfs partition. For this we will add the CAMEO tag +# and the checksum to the end of the image. + +buf = read_buffer(args.rootfs_start, READ_UNTIL_EOF) +write_buffer(os.SEEK_END, CAMEO_TAG + cameosum(buf + CAMEO_TAG)) diff --git a/scripts/cfe-partition-tag.py b/scripts/cfe-partition-tag.py index a2605d520..41495a9af 100755 --- a/scripts/cfe-partition-tag.py +++ b/scripts/cfe-partition-tag.py @@ -17,175 +17,123 @@ CFE Partition Tag import argparse import os import struct +import binascii + PART_NAME_SIZE = 33 PART_VERSION_SIZE = 21 -CRC32_INIT = 0xFFFFFFFF -CRC32_TABLE = [ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -] def auto_int(x): - return int(x, 0) + return int(x, 0) -def crc32(bytes, size, crc): - i = 0 - while (i < size): - crc = (crc >> 8) ^ CRC32_TABLE[(crc ^ bytes[i]) & 0xff] - i += 1 - return crc def str_to_bytes_pad(string, size): - str_bytes = string.encode() - num_bytes = len(str_bytes) - if (num_bytes >= size): - str_bytes = str_bytes[:size - 1] + '\0'.encode() - else: - str_bytes += '\0'.encode() * (size - num_bytes) - return str_bytes + str_bytes = string.encode() + num_bytes = len(str_bytes) + if num_bytes >= size: + str_bytes = str_bytes[: size - 1] + "\0".encode() + else: + str_bytes += "\0".encode() * (size - num_bytes) + return str_bytes + def create_tag(args, in_bytes, size): - crc = crc32(in_bytes, size, CRC32_INIT) + # JAM CRC32 is bitwise not and unsigned + crc = ~binascii.crc32(in_bytes) & 0xFFFFFFFF - tag = bytearray() - tag += struct.pack('>I', args.part_id) - tag += struct.pack('>I', size) - tag += struct.pack('>H', args.part_flags) - tag += str_to_bytes_pad(args.part_name, PART_NAME_SIZE) - tag += str_to_bytes_pad(args.part_version, PART_VERSION_SIZE) - tag += struct.pack('>I', crc) + tag = bytearray() + tag += struct.pack(">I", args.part_id) + tag += struct.pack(">I", size) + tag += struct.pack(">H", args.part_flags) + tag += str_to_bytes_pad(args.part_name, PART_NAME_SIZE) + tag += str_to_bytes_pad(args.part_version, PART_VERSION_SIZE) + tag += struct.pack(">I", crc) + + return tag - return tag def create_output(args): - in_st = os.stat(args.input_file) - in_size = in_st.st_size + in_st = os.stat(args.input_file) + in_size = in_st.st_size - in_f = open(args.input_file, 'r+b') - in_bytes = in_f.read(in_size) - in_f.close() + in_f = open(args.input_file, "r+b") + in_bytes = in_f.read(in_size) + in_f.close() - tag = create_tag(args, in_bytes, in_size) + tag = create_tag(args, in_bytes, in_size) + + out_f = open(args.output_file, "w+b") + out_f.write(tag) + out_f.close() - out_f = open(args.output_file, 'w+b') - out_f.write(tag) - out_f.close() def main(): - global args + global args - parser = argparse.ArgumentParser(description='') + parser = argparse.ArgumentParser(description="") - parser.add_argument('--flags', - dest='part_flags', - action='store', - type=auto_int, - help='Partition Flags') + parser.add_argument( + "--flags", + dest="part_flags", + action="store", + type=auto_int, + help="Partition Flags", + ) - parser.add_argument('--id', - dest='part_id', - action='store', - type=auto_int, - help='Partition ID') + parser.add_argument( + "--id", + dest="part_id", + action="store", + type=auto_int, + help="Partition ID", + ) - parser.add_argument('--input-file', - dest='input_file', - action='store', - type=str, - help='Input file') + parser.add_argument( + "--input-file", + dest="input_file", + action="store", + type=str, + help="Input file", + ) - parser.add_argument('--output-file', - dest='output_file', - action='store', - type=str, - help='Output file') + parser.add_argument( + "--output-file", + dest="output_file", + action="store", + type=str, + help="Output file", + ) - parser.add_argument('--name', - dest='part_name', - action='store', - type=str, - help='Partition Name') + parser.add_argument( + "--name", + dest="part_name", + action="store", + type=str, + help="Partition Name", + ) - parser.add_argument('--version', - dest='part_version', - action='store', - type=str, - help='Partition Version') + parser.add_argument( + "--version", + dest="part_version", + action="store", + type=str, + help="Partition Version", + ) - args = parser.parse_args() + args = parser.parse_args() + + if ( + (not args.part_flags) + or (not args.part_id) + or (not args.input_file) + or (not args.output_file) + or (not args.part_name) + or (not args.part_version) + ): + parser.print_help() + else: + create_output(args) - if ((not args.part_flags) or - (not args.part_id) or - (not args.input_file) or - (not args.output_file) or - (not args.part_name) or - (not args.part_version)): - parser.print_help() - else: - create_output(args) main() diff --git a/scripts/cfe-wfi-tag.py b/scripts/cfe-wfi-tag.py index 78ae869f1..5fac8ee47 100755 --- a/scripts/cfe-wfi-tag.py +++ b/scripts/cfe-wfi-tag.py @@ -43,158 +43,107 @@ Flags: import argparse import os import struct +import binascii -CRC32_INIT = 0xFFFFFFFF -CRC32_TABLE = [ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -] def auto_int(x): - return int(x, 0) + return int(x, 0) -def crc32(bytes, size, crc): - i = 0 - while (i < size): - crc = (crc >> 8) ^ CRC32_TABLE[(crc ^ bytes[i]) & 0xff] - i += 1 - return crc -def create_tag(args, in_bytes, size): - crc = crc32(in_bytes, size, CRC32_INIT) - tag = struct.pack('>IIIII', crc, args.tag_version, args.chip_id, args.flash_type, args.flags) - return tag +def create_tag(args, in_bytes): + # JAM CRC32 is bitwise not and unsigned + crc = ~binascii.crc32(in_bytes) & 0xFFFFFFFF + tag = struct.pack( + ">IIIII", + crc, + args.tag_version, + args.chip_id, + args.flash_type, + args.flags, + ) + return tag + def create_output(args): - in_st = os.stat(args.input_file) - in_size = in_st.st_size + in_st = os.stat(args.input_file) + in_size = in_st.st_size - in_f = open(args.input_file, 'r+b') - in_bytes = in_f.read(in_size) - in_f.close() + in_f = open(args.input_file, "r+b") + in_bytes = in_f.read(in_size) + in_f.close() - tag = create_tag(args, in_bytes, in_size) + tag = create_tag(args, in_bytes) + + out_f = open(args.output_file, "w+b") + out_f.write(in_bytes) + out_f.write(tag) + out_f.close() - out_f = open(args.output_file, 'w+b') - out_f.write(in_bytes) - out_f.write(tag) - out_f.close() def main(): - global args + global args - parser = argparse.ArgumentParser(description='') + parser = argparse.ArgumentParser(description="") - parser.add_argument('--input-file', - dest='input_file', - action='store', - type=str, - help='Input file') + parser.add_argument( + "--input-file", + dest="input_file", + action="store", + type=str, + help="Input file", + ) - parser.add_argument('--output-file', - dest='output_file', - action='store', - type=str, - help='Output file') + parser.add_argument( + "--output-file", + dest="output_file", + action="store", + type=str, + help="Output file", + ) - parser.add_argument('--version', - dest='tag_version', - action='store', - type=auto_int, - help='WFI Tag Version') + parser.add_argument( + "--version", + dest="tag_version", + action="store", + type=auto_int, + help="WFI Tag Version", + ) - parser.add_argument('--chip-id', - dest='chip_id', - action='store', - type=auto_int, - help='WFI Chip ID') + parser.add_argument( + "--chip-id", + dest="chip_id", + action="store", + type=auto_int, + help="WFI Chip ID", + ) - parser.add_argument('--flash-type', - dest='flash_type', - action='store', - type=auto_int, - help='WFI Flash Type') + parser.add_argument( + "--flash-type", + dest="flash_type", + action="store", + type=auto_int, + help="WFI Flash Type", + ) - parser.add_argument('--flags', - dest='flags', - action='store', - type=auto_int, - help='WFI Flags') + parser.add_argument( + "--flags", dest="flags", action="store", type=auto_int, help="WFI Flags" + ) - args = parser.parse_args() + args = parser.parse_args() - if not args.flags: - args.flags = 0 + if not args.flags: + args.flags = 0 + + if ( + (not args.input_file) + or (not args.output_file) + or (not args.tag_version) + or (not args.chip_id) + or (not args.flash_type) + ): + parser.print_help() + else: + create_output(args) - if ((not args.input_file) or - (not args.output_file) or - (not args.tag_version) or - (not args.chip_id) or - (not args.flash_type)): - parser.print_help() - else: - create_output(args) main() diff --git a/scripts/check-toolchain-clean.sh b/scripts/check-toolchain-clean.sh new file mode 100755 index 000000000..455cfb044 --- /dev/null +++ b/scripts/check-toolchain-clean.sh @@ -0,0 +1,14 @@ +#!/bin/sh +eval "$(grep CONFIG_GCC_VERSION .config)" +CONFIG_TOOLCHAIN_BUILD_VER="$CONFIG_GCC_VERSION-$(cat toolchain/build_version)" +touch .toolchain_build_ver +CURRENT_TOOLCHAIN_BUILD_VER="$(cat .toolchain_build_ver)" +[ -z "$CURRENT_TOOLCHAIN_BUILD_VER" ] && { + echo "$CONFIG_TOOLCHAIN_BUILD_VER" > .toolchain_build_ver + exit 0 +} +[ "$CONFIG_TOOLCHAIN_BUILD_VER" = "$CURRENT_TOOLCHAIN_BUILD_VER" ] && exit 0 +echo "Toolchain build version changed ($CONFIG_TOOLCHAIN_BUILD_VER != $CURRENT_TOOLCHAIN_BUILD_VER), running make targetclean" +make targetclean +echo "$CONFIG_TOOLCHAIN_BUILD_VER" > .toolchain_build_ver +exit 0 diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 81b1ffcb5..2adc5efec 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4697,7 +4697,7 @@ sub process { ## $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) { ## ## # Remove any bracketed sections to ensure we do not -## # falsly report the parameters of functions. +## # falsely report the parameters of functions. ## my $ln = $line; ## while ($ln =~ s/\([^\(\)]*\)//g) { ## } diff --git a/scripts/command_all.sh b/scripts/command_all.sh new file mode 100755 index 000000000..452b66f09 --- /dev/null +++ b/scripts/command_all.sh @@ -0,0 +1,11 @@ +#! /bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Reduced version of which -a using command utility + +case $PATH in + (*[!:]:) PATH="$PATH:" ;; +esac + +for ELEMENT in $(echo $PATH | tr ":" "\n"); do + PATH=$ELEMENT command -v "$@" +done diff --git a/scripts/config/.gitignore b/scripts/config/.gitignore index bedb9757e..05c55c3c8 100644 --- a/scripts/config/.gitignore +++ b/scripts/config/.gitignore @@ -1,22 +1,16 @@ -# -# Generated files -# -*.moc -*conf-cfg +# SPDX-License-Identifier: GPL-2.0-only +/conf +/[gmnq]conf +/[gmnq]conf-cfg +/qconf-moc.cc + +# From linux kconfig parent directories +.* + +# OpenWrt-generated files mconf_check -# -# configuration programs -# -conf -mconf -nconf -qconf -gconf - -# -# temporary files from older version. Should be removed -# +# Temporary files from older versions. They should be removed after the +# end of support for OpenWrt 19.07. zconf.???.c zconf.hash.c -.tmp_qtcheck diff --git a/scripts/config/Makefile b/scripts/config/Makefile index 89e761a45..5976a91b9 100644 --- a/scripts/config/Makefile +++ b/scripts/config/Makefile @@ -5,11 +5,11 @@ .PHONY: clean all all: conf mconf clean: - rm -f *.o lxdialog/*.o *.moc $(clean-files) conf mconf qconf nconf + rm -f *.o lxdialog/*.o *.moc .*.cmd $(clean-files) # This clean-files definition is here to ensure that temporary files from the # previous version are removed by make config-clean. -# It should be removed or emptied when this Makefile get updated again. +# It should be emptied after the end of support for OpenWrt 19.07. clean-files := zconf.tab.c zconf.lex.c zconf.hash.c .tmp_qtcheck # =========================================================================== @@ -24,9 +24,11 @@ src:=. obj:=. Q:=$(if $V,,@) cmd = $(cmd_$(1)) -dot-target = $(dir $@).$(notdir $@) -# taken from ../Kbuild.include +# some definitions taken from ../Kbuild.include +dot-target = $(dir $@).$(notdir $@) +squote := ' +escsq = $(subst $(squote),'\$(squote)',$1) define filechk $(Q)set -e; \ mkdir -p $(dir $@); \ @@ -37,23 +39,29 @@ define filechk mv -f $(dot-target).tmp $@; \ fi endef +cmd-check = $(if $(strip $(cmd_$@)),,1) +make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) +newer-prereqs = $(filter-out $(PHONY),$?) +if_changed = $(if $(newer-prereqs)$(cmd-check), \ + $(cmd); \ + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) ### Stripped down upstream Makefile follows: # =========================================================================== # object files used by all kconfig flavours -common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ - symbol.o util.o +common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \ + preprocess.o symbol.o util.o $(obj)/lexer.lex.o: $(obj)/parser.tab.h HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) # conf: Used for defconfig, oldconfig and related targets -hostprogs-y += conf +hostprogs += conf conf-objs := conf.o $(common-objs) # nconf: Used for the nconfig target based on ncurses -hostprogs-y += nconf +hostprogs += nconf nconf-objs := nconf.o nconf.gui.o $(common-objs) HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) @@ -63,7 +71,7 @@ HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) $(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg # mconf: Used for the menuconfig target based on lxdialog -hostprogs-y += mconf +hostprogs += mconf lxdialog := $(addprefix lxdialog/, \ checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) mconf-objs := mconf.o $(lxdialog) $(common-objs) @@ -75,20 +83,23 @@ $(foreach f, mconf.o $(lxdialog), \ $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg # qconf: Used for the xconfig target based on Qt -hostprogs-y += qconf -qconf-cxxobjs := qconf.o +hostprogs += qconf +qconf-cxxobjs := qconf.o qconf-moc.o qconf-objs := images.o $(common-objs) HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) +HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) -$(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc +$(obj)/qconf.o: $(obj)/qconf-cfg quiet_cmd_moc = MOC $@ - cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@ + cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ -$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg - $(call cmd,moc) +$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE + $(call if_changed,moc) + +targets += qconf-moc.cc # check if necessary packages are available, and configure build flags filechk_conf_cfg = $(CONFIG_SHELL) $< @@ -102,6 +113,8 @@ clean-files += *conf-cfg # OpenWrt rules and final adjustments that need to be made after reading the # full upstream Makefile +clean-files += $(targets) $(hostprogs) + FORCE: ifdef BUILD_SHIPPED_FILES @@ -117,24 +130,25 @@ clean-files += $(shipped-files) flex -L -o$@ $< endif -$(foreach f, mconf.o $(lxdialog), \ - $(eval $f: CFLAGS+=$$(HOSTCFLAGS_$f))) +$(foreach f,$(conf-objs) $(filter-out $(common-objs),$(mconf-objs) \ + $(qconf-objs) \ + $(nconf-objs)), \ + $(eval $(obj)/$f: CFLAGS+=$$(HOSTCFLAGS_$f))) -$(obj)/lexer.lex.o: CFLAGS += $(HOSTCFLAGS_lexer.lex.o) -$(obj)/parser.tab.o: CFLAGS += $(HOSTCFLAGS_parser.tab.o) -$(obj)/qconf.o: CXXFLAGS+=$(HOSTCXXFLAGS_qconf.o) +$(foreach f,$(qconf-cxxobjs), \ + $(eval $(obj)/$f: CXXFLAGS+=$$(HOSTCXXFLAGS_$f))) -conf: $(conf-objs) +$(obj)/conf: $(addprefix $(obj)/,$(conf-objs)) # The *conf-cfg file is used (then filtered out) as the first prerequisite to # avoid sourcing it before the script is built, when trying to compute CFLAGS # for the actual first prerequisite. This avoids errors like: # '/bin/sh: ./mconf-cfg: No such file or directory' -mconf: mconf-cfg $(mconf-objs) +$(obj)/mconf: mconf-cfg $(addprefix $(obj)/,$(mconf-objs)) $(CC) -o $@ $(filter-out mconf-cfg,$^) $(HOSTLDLIBS_mconf) -nconf: nconf-cfg $(nconf-objs) +$(obj)/nconf: nconf-cfg $(addprefix $(obj)/,$(nconf-objs)) $(CC) -o $@ $(filter-out nconf-cfg,$^) $(HOSTLDLIBS_nconf) -qconf: qconf-cfg $(qconf-cxxobjs) $(qconf-objs) +$(obj)/qconf: qconf-cfg $(addprefix $(obj)/,$(qconf-cxxobjs) $(qconf-objs)) $(CXX) -o $@ $(filter-out qconf-cfg,$^) $(HOSTLDLIBS_qconf) diff --git a/scripts/config/README b/scripts/config/README index f402cdc74..99a7d535a 100644 --- a/scripts/config/README +++ b/scripts/config/README @@ -1,7 +1,6 @@ -These files were taken from the Linux Kernel Configuration System at commit -089b7d890f972f6b649fedc9259f6b93a18fb970 (Feb 4, 2020) and modified for the -OpenWrt Buildroot: - - Removed gconf, tests and kernel configuration targets. +These files were taken from the Linux 5.14 Kernel Configuration System and +modified for the OpenWrt Buildroot: + - Removed nconf, gconf, tests and kernel configuration targets. - Adjusted the Makefile to compile outside the kernel. - Always use default file when running make all{no,mod,yes}config. - Added a 'reset' command to reset config when the target changes. @@ -24,4 +23,4 @@ OpenWrt Buildroot: BUILD_SHIPPED_FILES defined For a full list of changes, see the repository at: -https://github.com/cotequeiroz/linux/commits/openwrt/scripts/kconfig +https://github.com/cotequeiroz/linux/commits/openwrt-5.14/scripts/kconfig diff --git a/scripts/config/conf.c b/scripts/config/conf.c index 85902663a..978abebe6 100644 --- a/scripts/config/conf.c +++ b/scripts/config/conf.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -39,7 +38,7 @@ enum input_mode { fatalrecursive, }; static enum input_mode input_mode = oldaskconfig; - +static int input_mode_opt; static int indent = 1; static int tty_stdio; static int sync_kconfig; @@ -84,10 +83,243 @@ static void xfgets(char *str, int size, FILE *in) printf("%s", str); } +static void set_randconfig_seed(void) +{ + unsigned int seed; + char *env; + bool seed_set = false; + + env = getenv("KCONFIG_SEED"); + if (env && *env) { + char *endp; + + seed = strtol(env, &endp, 0); + if (*endp == '\0') + seed_set = true; + } + + if (!seed_set) { + struct timeval now; + + /* + * Use microseconds derived seed, compensate for systems where it may + * be zero. + */ + gettimeofday(&now, NULL); + seed = (now.tv_sec + 1) * (now.tv_usec + 1); + } + + printf("KCONFIG_SEED=0x%X\n", seed); + srand(seed); +} + +static bool randomize_choice_values(struct symbol *csym) +{ + struct property *prop; + struct symbol *sym; + struct expr *e; + int cnt, def; + + /* + * If choice is mod then we may have more items selected + * and if no then no-one. + * In both cases stop. + */ + if (csym->curr.tri != yes) + return false; + + prop = sym_get_choice_prop(csym); + + /* count entries in choice block */ + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) + cnt++; + + /* + * find a random value and set it to yes, + * set the rest to no so we have only one set + */ + def = rand() % cnt; + + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) { + if (def == cnt++) { + sym->def[S_DEF_USER].tri = yes; + csym->def[S_DEF_USER].val = sym; + } else { + sym->def[S_DEF_USER].tri = no; + } + sym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + sym->flags &= ~SYMBOL_VALID; + } + csym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + csym->flags &= ~SYMBOL_VALID; + + return true; +} + +enum conf_def_mode { + def_default, + def_yes, + def_mod, + def_y2m, + def_m2y, + def_no, + def_random +}; + +static bool conf_set_all_new_symbols(enum conf_def_mode mode) +{ + struct symbol *sym, *csym; + int i, cnt; + /* + * can't go as the default in switch-case below, otherwise gcc whines + * about -Wmaybe-uninitialized + */ + int pby = 50; /* probability of bool = y */ + int pty = 33; /* probability of tristate = y */ + int ptm = 33; /* probability of tristate = m */ + bool has_changed = false; + + if (mode == def_random) { + int n, p[3]; + char *env = getenv("KCONFIG_PROBABILITY"); + + n = 0; + while (env && *env) { + char *endp; + int tmp = strtol(env, &endp, 10); + + if (tmp >= 0 && tmp <= 100) { + p[n++] = tmp; + } else { + errno = ERANGE; + perror("KCONFIG_PROBABILITY"); + exit(1); + } + env = (*endp == ':') ? endp + 1 : endp; + if (n >= 3) + break; + } + switch (n) { + case 1: + pby = p[0]; + ptm = pby / 2; + pty = pby - ptm; + break; + case 2: + pty = p[0]; + ptm = p[1]; + pby = pty + ptm; + break; + case 3: + pby = p[0]; + pty = p[1]; + ptm = p[2]; + break; + } + + if (pty + ptm > 100) { + errno = ERANGE; + perror("KCONFIG_PROBABILITY"); + exit(1); + } + } + + sym_clear_all_valid(); + + for_all_symbols(i, sym) { + if (sym_has_value(sym) || sym->flags & SYMBOL_VALID) + continue; + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + has_changed = true; + switch (mode) { + case def_yes: + sym->def[S_DEF_USER].tri = yes; + break; + case def_mod: + sym->def[S_DEF_USER].tri = mod; + break; + case def_no: + sym->def[S_DEF_USER].tri = no; + break; + case def_random: + sym->def[S_DEF_USER].tri = no; + cnt = rand() % 100; + if (sym->type == S_TRISTATE) { + if (cnt < pty) + sym->def[S_DEF_USER].tri = yes; + else if (cnt < pty + ptm) + sym->def[S_DEF_USER].tri = mod; + } else if (cnt < pby) + sym->def[S_DEF_USER].tri = yes; + break; + default: + continue; + } + if (!(sym_is_choice(sym) && mode == def_random)) + sym->flags |= SYMBOL_DEF_USER; + break; + default: + break; + } + + } + + /* + * We have different type of choice blocks. + * If curr.tri equals to mod then we can select several + * choice symbols in one block. + * In this case we do nothing. + * If curr.tri equals yes then only one symbol can be + * selected in a choice block and we set it to yes, + * and the rest to no. + */ + if (mode != def_random) { + for_all_symbols(i, csym) { + if ((sym_is_choice(csym) && !sym_has_value(csym)) || + sym_is_choice_value(csym)) + csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; + } + } + + for_all_symbols(i, csym) { + if (sym_has_value(csym) || !sym_is_choice(csym)) + continue; + + sym_calc_value(csym); + if (mode == def_random) + has_changed |= randomize_choice_values(csym); + else { + set_all_choice_values(csym); + has_changed = true; + } + } + + return has_changed; +} + +static void conf_rewrite_mod_or_yes(enum conf_def_mode mode) +{ + struct symbol *sym; + int i; + tristate old_val = (mode == def_y2m) ? yes : mod; + tristate new_val = (mode == def_y2m) ? mod : yes; + + for_all_symbols(i, sym) { + if (sym_get_type(sym) == S_TRISTATE && + sym->def[S_DEF_USER].tri == old_val) + sym->def[S_DEF_USER].tri = new_val; + } + sym_clear_all_valid(); +} + static int conf_askvalue(struct symbol *sym, const char *def) { - enum symbol_type type = sym_get_type(sym); - if (!sym_has_value(sym)) printf("(NEW) "); @@ -109,24 +341,12 @@ static int conf_askvalue(struct symbol *sym, const char *def) return 0; } /* fall through */ - case oldaskconfig: + default: fflush(stdout); xfgets(line, sizeof(line), stdin); - return 1; - default: break; } - switch (type) { - case S_INT: - case S_HEX: - case S_STRING: - printf("%s\n", def); - return 1; - default: - ; - } - printf("%s", line); return 1; } @@ -139,7 +359,7 @@ static int conf_string(struct menu *menu) printf("%*s%s ", indent - 1, "", menu->prompt->text); printf("(%s) ", sym->name); def = sym_get_string_value(sym); - if (sym_get_string_value(sym)) + if (def) printf("[%s] ", def); if (!conf_askvalue(sym, def)) return 0; @@ -421,34 +641,37 @@ static void check_conf(struct menu *menu) return; sym = menu->sym; - if (sym && !sym_has_value(sym)) { - if (sym_is_changeable(sym) || - (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { - if (input_mode == listnewconfig) { - if (sym->name) { - const char *str; + if (sym && !sym_has_value(sym) && + (sym_is_changeable(sym) || + (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes))) { - if (sym->type == S_STRING) { - str = sym_get_string_value(sym); - str = sym_escape_string_value(str); - printf("%s%s=%s\n", CONFIG_, sym->name, str); - free((void *)str); - } else { - str = sym_get_string_value(sym); - printf("%s%s=%s\n", CONFIG_, sym->name, str); - } + switch (input_mode) { + case listnewconfig: + if (sym->name) { + const char *str; + + if (sym->type == S_STRING) { + str = sym_get_string_value(sym); + str = sym_escape_string_value(str); + printf("%s%s=%s\n", CONFIG_, sym->name, str); + free((void *)str); + } else { + str = sym_get_string_value(sym); + printf("%s%s=%s\n", CONFIG_, sym->name, str); } - } else if (input_mode == helpnewconfig) { - printf("-----\n"); - print_help(menu); - printf("-----\n"); - - } else { - if (!conf_cnt++) - printf("*\n* Restart config...\n*\n"); - rootEntry = menu_get_parent_menu(menu); - conf(rootEntry); } + break; + case helpnewconfig: + printf("-----\n"); + print_help(menu); + printf("-----\n"); + break; + default: + if (!conf_cnt++) + printf("*\n* Restart config...\n*\n"); + rootEntry = menu_get_parent_menu(menu); + conf(rootEntry); + break; } } @@ -456,31 +679,38 @@ static void check_conf(struct menu *menu) check_conf(child); } -static struct option long_opts[] = { - {"oldaskconfig", no_argument, NULL, oldaskconfig}, - {"oldconfig", no_argument, NULL, oldconfig}, - {"syncconfig", no_argument, NULL, syncconfig}, - {"defconfig", required_argument, NULL, defconfig}, - {"savedefconfig", required_argument, NULL, savedefconfig}, - {"allnoconfig", no_argument, NULL, allnoconfig}, - {"allyesconfig", no_argument, NULL, allyesconfig}, - {"allmodconfig", no_argument, NULL, allmodconfig}, - {"alldefconfig", no_argument, NULL, alldefconfig}, - {"randconfig", no_argument, NULL, randconfig}, - {"listnewconfig", no_argument, NULL, listnewconfig}, - {"helpnewconfig", no_argument, NULL, helpnewconfig}, - {"olddefconfig", no_argument, NULL, olddefconfig}, - {"yes2modconfig", no_argument, NULL, yes2modconfig}, - {"mod2yesconfig", no_argument, NULL, mod2yesconfig}, - {"fatalrecursive", no_argument, NULL, fatalrecursive}, +static const struct option long_opts[] = { + {"help", no_argument, NULL, 'h'}, + {"silent", no_argument, NULL, 's'}, + {"oldaskconfig", no_argument, &input_mode_opt, oldaskconfig}, + {"oldconfig", no_argument, &input_mode_opt, oldconfig}, + {"syncconfig", no_argument, &input_mode_opt, syncconfig}, + {"defconfig", required_argument, &input_mode_opt, defconfig}, + {"savedefconfig", required_argument, &input_mode_opt, savedefconfig}, + {"allnoconfig", no_argument, &input_mode_opt, allnoconfig}, + {"allyesconfig", no_argument, &input_mode_opt, allyesconfig}, + {"allmodconfig", no_argument, &input_mode_opt, allmodconfig}, + {"alldefconfig", no_argument, &input_mode_opt, alldefconfig}, + {"randconfig", no_argument, &input_mode_opt, randconfig}, + {"listnewconfig", no_argument, &input_mode_opt, listnewconfig}, + {"helpnewconfig", no_argument, &input_mode_opt, helpnewconfig}, + {"olddefconfig", no_argument, &input_mode_opt, olddefconfig}, + {"yes2modconfig", no_argument, &input_mode_opt, yes2modconfig}, + {"mod2yesconfig", no_argument, &input_mode_opt, mod2yesconfig}, + {"fatalrecursive",no_argument, NULL, fatalrecursive}, {NULL, 0, NULL, 0} }; static void conf_usage(const char *progname) { - - printf("Usage: %s [-s] [--fatalrecursive] [option] \n", progname); - printf("[option] is _one_ of the following:\n"); + printf("Usage: %s [options] \n", progname); + printf("\n"); + printf("Generic options:\n"); + printf(" -h, --help Print this message and exit.\n"); + printf(" -s, --silent Do not print log.\n"); + printf(" --fatalrecursive Treat recursive depenendencies as a fatal error\n"); + printf("\n"); + printf("Mode options:\n"); printf(" --listnewconfig List new options\n"); printf(" --helpnewconfig List new options and help text\n"); printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); @@ -497,6 +727,7 @@ static void conf_usage(const char *progname) printf(" --randconfig New config with random answer to all options\n"); printf(" --yes2modconfig Change answers from yes to mod if possible\n"); printf(" --mod2yesconfig Change answers from mod to yes if possible\n"); + printf(" (If none of the above is given, --oldaskconfig is the default)\n"); } int main(int ac, char **av) @@ -509,84 +740,56 @@ int main(int ac, char **av) tty_stdio = isatty(0) && isatty(1); - while ((opt = getopt_long(ac, av, "r:w:s", long_opts, NULL)) != -1) { - if (opt == 's') { - conf_set_message_callback(NULL); - continue; - } + while ((opt = getopt_long(ac, av, "hr:sw:", long_opts, NULL)) != -1) { switch (opt) { - case syncconfig: - /* - * syncconfig is invoked during the build stage. - * Suppress distracting "configuration written to ..." - */ + case 'h': + conf_usage(progname); + exit(1); + break; + case 's': conf_set_message_callback(NULL); - sync_kconfig = 1; - break; - case defconfig: - case savedefconfig: - defconfig_file = optarg; - break; - case randconfig: - { - struct timeval now; - unsigned int seed; - char *seed_env; - - /* - * Use microseconds derived seed, - * compensate for systems where it may be zero - */ - gettimeofday(&now, NULL); - seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); - - seed_env = getenv("KCONFIG_SEED"); - if( seed_env && *seed_env ) { - char *endp; - int tmp = (int)strtol(seed_env, &endp, 0); - if (*endp == '\0') { - seed = tmp; - } - } - fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed ); - srand(seed); - break; - } - case oldaskconfig: - case oldconfig: - case allnoconfig: - case allyesconfig: - case allmodconfig: - case alldefconfig: - case listnewconfig: - case helpnewconfig: - case olddefconfig: - case yes2modconfig: - case mod2yesconfig: break; case fatalrecursive: recursive_is_error = 1; continue; case 'r': input_file = optarg; - continue; + break; case 'w': output_file = optarg; - continue; - case '?': - conf_usage(progname); - exit(1); + break; + case 0: + input_mode = input_mode_opt; + switch (input_mode) { + case syncconfig: + /* + * syncconfig is invoked during the build stage. + * Suppress distracting + * "configuration written to ..." + */ + conf_set_message_callback(NULL); + sync_kconfig = 1; + break; + case defconfig: + case savedefconfig: + defconfig_file = optarg; + break; + case randconfig: + set_randconfig_seed(); + break; + default: + break; + } + default: break; } - input_mode = (enum input_mode)opt; } if (ac == optind) { fprintf(stderr, "%s: Kconfig file missing\n", av[0]); conf_usage(progname); exit(1); } - name = av[optind]; - conf_parse(name); + conf_parse(av[optind]); //zconfdump(stdout); switch (input_mode) { diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c index cff8d4523..dad0b471c 100644 --- a/scripts/config/confdata.c +++ b/scripts/config/confdata.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -32,7 +33,7 @@ static bool is_dir(const char *path) struct stat st; if (stat(path, &st)) - return 0; + return false; return S_ISDIR(st.st_mode); } @@ -129,19 +130,14 @@ static size_t depfile_prefix_len; static int conf_touch_dep(const char *name) { int fd, ret; - const char *s; - char *d, c; + char *d; - /* check overflow: prefix + name + ".h" + '\0' must fit in buffer. */ - if (depfile_prefix_len + strlen(name) + 3 > sizeof(depfile_path)) + /* check overflow: prefix + name + '\0' must fit in buffer. */ + if (depfile_prefix_len + strlen(name) + 1 > sizeof(depfile_path)) return -1; d = depfile_path + depfile_prefix_len; - s = name; - - while ((c = *s++)) - *d++ = (c == '_') ? '/' : tolower(c); - strcpy(d, ".h"); + strcpy(d, name); /* Assume directory path already exists. */ fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); @@ -384,28 +380,46 @@ int conf_read_simple(const char *name, int def) if (name) { in = zconf_fopen(name); } else { - struct property *prop; + char *env; name = conf_get_configname(); in = zconf_fopen(name); if (in) goto load; - sym_add_change_count(1); - if (!sym_defconfig_list) + conf_set_changed(true); + + env = getenv("KCONFIG_DEFCONFIG_LIST"); + if (!env) return 1; - for_all_defaults(sym_defconfig_list, prop) { - if (expr_calc_value(prop->visible.expr) == no || - prop->expr->type != E_SYMBOL) - continue; - sym_calc_value(prop->expr->left.sym); - name = sym_get_string_value(prop->expr->left.sym); - in = zconf_fopen(name); + while (1) { + bool is_last; + + while (isspace(*env)) + env++; + + if (!*env) + break; + + p = env; + while (*p && !isspace(*p)) + p++; + + is_last = (*p == '\0'); + + *p = '\0'; + + in = zconf_fopen(env); if (in) { conf_message("using defaults found in %s", - name); + env); goto load; } + + if (is_last) + break; + + env = p + 1; } } if (!in) @@ -434,7 +448,7 @@ load: if (def == S_DEF_USER) { sym = sym_find(line + 2 + strlen(CONFIG_)); if (!sym) { - sym_add_change_count(1); + conf_set_changed(true); continue; } } else { @@ -470,11 +484,11 @@ load: * Reading from include/config/auto.conf * If CONFIG_FOO previously existed in * auto.conf but it is missing now, - * include/config/foo.h must be touched. + * include/config/FOO must be touched. */ conf_touch_dep(line + strlen(CONFIG_)); else - sym_add_change_count(1); + conf_set_changed(true); continue; } @@ -519,7 +533,7 @@ int conf_read(const char *name) int conf_unsaved = 0; int i; - sym_set_change_count(0); + conf_set_changed(false); if (conf_read_simple(name, S_DEF_USER)) { sym_calc_value(modules_sym); @@ -577,7 +591,8 @@ int conf_read(const char *name) } } - sym_add_change_count(conf_warnings || conf_unsaved); + if (conf_warnings || conf_unsaved) + conf_set_changed(true); return 0; } @@ -922,7 +937,7 @@ next: if (is_same(name, tmpname)) { conf_message("No change to %s", name); unlink(tmpname); - sym_set_change_count(0); + conf_set_changed(false); return 0; } @@ -934,7 +949,7 @@ next: conf_message("configuration written to %s", name); - sym_set_change_count(0); + conf_set_changed(false); return 0; } @@ -1105,26 +1120,20 @@ int conf_write_autoconf(int overwrite) return 0; } -static int sym_change_count; +static bool conf_changed; static void (*conf_changed_callback)(void); -void sym_set_change_count(int count) +void conf_set_changed(bool val) { - int _sym_change_count = sym_change_count; - sym_change_count = count; - if (conf_changed_callback && - (bool)_sym_change_count != (bool)count) + if (conf_changed_callback && conf_changed != val) conf_changed_callback(); -} -void sym_add_change_count(int count) -{ - sym_set_change_count(count + sym_change_count); + conf_changed = val; } bool conf_get_changed(void) { - return sym_change_count; + return conf_changed; } void conf_set_changed_callback(void (*fn)(void)) @@ -1132,54 +1141,6 @@ void conf_set_changed_callback(void (*fn)(void)) conf_changed_callback = fn; } -static bool randomize_choice_values(struct symbol *csym) -{ - struct property *prop; - struct symbol *sym; - struct expr *e; - int cnt, def; - - /* - * If choice is mod then we may have more items selected - * and if no then no-one. - * In both cases stop. - */ - if (csym->curr.tri != yes) - return false; - - prop = sym_get_choice_prop(csym); - - /* count entries in choice block */ - cnt = 0; - expr_list_for_each_sym(prop->expr, e, sym) - cnt++; - - /* - * find a random value and set it to yes, - * set the rest to no so we have only one set - */ - def = (rand() % cnt); - - cnt = 0; - expr_list_for_each_sym(prop->expr, e, sym) { - if (def == cnt++) { - sym->def[S_DEF_USER].tri = yes; - csym->def[S_DEF_USER].val = sym; - } - else { - sym->def[S_DEF_USER].tri = no; - } - sym->flags |= SYMBOL_DEF_USER; - /* clear VALID to get value calculated */ - sym->flags &= ~SYMBOL_VALID; - } - csym->flags |= SYMBOL_DEF_USER; - /* clear VALID to get value calculated */ - csym->flags &= ~(SYMBOL_VALID); - - return true; -} - void set_all_choice_values(struct symbol *csym) { struct property *prop; @@ -1199,147 +1160,3 @@ void set_all_choice_values(struct symbol *csym) /* clear VALID to get value calculated */ csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES); } - -bool conf_set_all_new_symbols(enum conf_def_mode mode) -{ - struct symbol *sym, *csym; - int i, cnt, pby, pty, ptm; /* pby: probability of bool = y - * pty: probability of tristate = y - * ptm: probability of tristate = m - */ - - pby = 50; pty = ptm = 33; /* can't go as the default in switch-case - * below, otherwise gcc whines about - * -Wmaybe-uninitialized */ - if (mode == def_random) { - int n, p[3]; - char *env = getenv("KCONFIG_PROBABILITY"); - n = 0; - while( env && *env ) { - char *endp; - int tmp = strtol( env, &endp, 10 ); - if( tmp >= 0 && tmp <= 100 ) { - p[n++] = tmp; - } else { - errno = ERANGE; - perror( "KCONFIG_PROBABILITY" ); - exit( 1 ); - } - env = (*endp == ':') ? endp+1 : endp; - if( n >=3 ) { - break; - } - } - switch( n ) { - case 1: - pby = p[0]; ptm = pby/2; pty = pby-ptm; - break; - case 2: - pty = p[0]; ptm = p[1]; pby = pty + ptm; - break; - case 3: - pby = p[0]; pty = p[1]; ptm = p[2]; - break; - } - - if( pty+ptm > 100 ) { - errno = ERANGE; - perror( "KCONFIG_PROBABILITY" ); - exit( 1 ); - } - } - bool has_changed = false; - - sym_clear_all_valid(); - - for_all_symbols(i, sym) { - if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) - continue; - switch (sym_get_type(sym)) { - case S_BOOLEAN: - case S_TRISTATE: - has_changed = true; - switch (mode) { - case def_yes: - sym->def[S_DEF_USER].tri = yes; - break; - case def_mod: - sym->def[S_DEF_USER].tri = mod; - break; - case def_no: - if (sym->flags & SYMBOL_ALLNOCONFIG_Y) - sym->def[S_DEF_USER].tri = yes; - else - sym->def[S_DEF_USER].tri = no; - break; - case def_random: - sym->def[S_DEF_USER].tri = no; - cnt = rand() % 100; - if (sym->type == S_TRISTATE) { - if (cnt < pty) - sym->def[S_DEF_USER].tri = yes; - else if (cnt < (pty+ptm)) - sym->def[S_DEF_USER].tri = mod; - } else if (cnt < pby) - sym->def[S_DEF_USER].tri = yes; - break; - default: - continue; - } - if (!(sym_is_choice(sym) && mode == def_random)) - sym->flags |= SYMBOL_DEF_USER; - break; - default: - break; - } - - } - - /* - * We have different type of choice blocks. - * If curr.tri equals to mod then we can select several - * choice symbols in one block. - * In this case we do nothing. - * If curr.tri equals yes then only one symbol can be - * selected in a choice block and we set it to yes, - * and the rest to no. - */ - if (mode != def_random) { - for_all_symbols(i, csym) { - if ((sym_is_choice(csym) && !sym_has_value(csym)) || - sym_is_choice_value(csym)) - csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; - } - } - - for_all_symbols(i, csym) { - if (sym_has_value(csym) || !sym_is_choice(csym)) - continue; - - sym_calc_value(csym); - if (mode == def_random) - has_changed = randomize_choice_values(csym); - else { - set_all_choice_values(csym); - has_changed = true; - } - } - - return has_changed; -} - -void conf_rewrite_mod_or_yes(enum conf_def_mode mode) -{ - struct symbol *sym; - int i; - tristate old_val = (mode == def_y2m) ? yes : mod; - tristate new_val = (mode == def_y2m) ? mod : yes; - - for_all_symbols(i, sym) { - if (sym_get_type(sym) == S_TRISTATE && - sym->def[S_DEF_USER].tri == old_val) { - sym->def[S_DEF_USER].tri = new_val; - sym_add_change_count(1); - } - } -} diff --git a/scripts/config/expr.h b/scripts/config/expr.h index ae67a99d9..c2fa804fe 100644 --- a/scripts/config/expr.h +++ b/scripts/config/expr.h @@ -156,9 +156,6 @@ struct symbol { /* choice values need to be set before calculating this symbol value */ #define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 -/* Set symbol to y if allnoconfig; used for symbols that hide others */ -#define SYMBOL_ALLNOCONFIG_Y 0x200000 - #define SYMBOL_MAXLENGTH 256 #define SYMBOL_HASHSIZE 9973 @@ -282,15 +279,12 @@ struct jump_key { int index; }; -#define JUMP_NB 9 - extern struct file *file_list; extern struct file *current_file; struct file *lookup_file(const char *name); extern struct symbol symbol_yes, symbol_no, symbol_mod; extern struct symbol *modules_sym; -extern struct symbol *sym_defconfig_list; extern int cdebug; struct expr *expr_alloc_symbol(struct symbol *sym); struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); diff --git a/scripts/config/images.c b/scripts/config/images.c index 3765d3356..ea3bfabd9 100644 --- a/scripts/config/images.c +++ b/scripts/config/images.c @@ -5,7 +5,7 @@ #include "images.h" -const char *xpm_load[] = { +const char * const xpm_load[] = { "22 22 5 1", ". c None", "# c #000000", @@ -35,7 +35,7 @@ const char *xpm_load[] = { "###############.......", "......................"}; -const char *xpm_save[] = { +const char * const xpm_save[] = { "22 22 5 1", ". c None", "# c #000000", @@ -65,7 +65,7 @@ const char *xpm_save[] = { "..##################..", "......................"}; -const char *xpm_back[] = { +const char * const xpm_back[] = { "22 22 3 1", ". c None", "# c #000083", @@ -93,7 +93,7 @@ const char *xpm_back[] = { "......................", "......................"}; -const char *xpm_tree_view[] = { +const char * const xpm_tree_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -120,7 +120,7 @@ const char *xpm_tree_view[] = { "......................", "......................"}; -const char *xpm_single_view[] = { +const char * const xpm_single_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -147,7 +147,7 @@ const char *xpm_single_view[] = { "......................", "......................"}; -const char *xpm_split_view[] = { +const char * const xpm_split_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -174,7 +174,7 @@ const char *xpm_split_view[] = { "......................", "......................"}; -const char *xpm_symbol_no[] = { +const char * const xpm_symbol_no[] = { "12 12 2 1", " c white", ". c black", @@ -191,7 +191,7 @@ const char *xpm_symbol_no[] = { " .......... ", " "}; -const char *xpm_symbol_mod[] = { +const char * const xpm_symbol_mod[] = { "12 12 2 1", " c white", ". c black", @@ -208,7 +208,7 @@ const char *xpm_symbol_mod[] = { " .......... ", " "}; -const char *xpm_symbol_yes[] = { +const char * const xpm_symbol_yes[] = { "12 12 2 1", " c white", ". c black", @@ -225,7 +225,7 @@ const char *xpm_symbol_yes[] = { " .......... ", " "}; -const char *xpm_choice_no[] = { +const char * const xpm_choice_no[] = { "12 12 2 1", " c white", ". c black", @@ -242,7 +242,7 @@ const char *xpm_choice_no[] = { " .... ", " "}; -const char *xpm_choice_yes[] = { +const char * const xpm_choice_yes[] = { "12 12 2 1", " c white", ". c black", @@ -259,7 +259,7 @@ const char *xpm_choice_yes[] = { " .... ", " "}; -const char *xpm_menu[] = { +const char * const xpm_menu[] = { "12 12 2 1", " c white", ". c black", @@ -276,7 +276,7 @@ const char *xpm_menu[] = { " .......... ", " "}; -const char *xpm_menu_inv[] = { +const char * const xpm_menu_inv[] = { "12 12 2 1", " c white", ". c black", @@ -293,7 +293,7 @@ const char *xpm_menu_inv[] = { " .......... ", " "}; -const char *xpm_menuback[] = { +const char * const xpm_menuback[] = { "12 12 2 1", " c white", ". c black", @@ -310,7 +310,7 @@ const char *xpm_menuback[] = { " .......... ", " "}; -const char *xpm_void[] = { +const char * const xpm_void[] = { "12 12 2 1", " c white", ". c black", diff --git a/scripts/config/images.h b/scripts/config/images.h index 565466511..1e3c73622 100644 --- a/scripts/config/images.h +++ b/scripts/config/images.h @@ -10,21 +10,21 @@ extern "C" { #endif -extern const char *xpm_load[]; -extern const char *xpm_save[]; -extern const char *xpm_back[]; -extern const char *xpm_tree_view[]; -extern const char *xpm_single_view[]; -extern const char *xpm_split_view[]; -extern const char *xpm_symbol_no[]; -extern const char *xpm_symbol_mod[]; -extern const char *xpm_symbol_yes[]; -extern const char *xpm_choice_no[]; -extern const char *xpm_choice_yes[]; -extern const char *xpm_menu[]; -extern const char *xpm_menu_inv[]; -extern const char *xpm_menuback[]; -extern const char *xpm_void[]; +extern const char * const xpm_load[]; +extern const char * const xpm_save[]; +extern const char * const xpm_back[]; +extern const char * const xpm_tree_view[]; +extern const char * const xpm_single_view[]; +extern const char * const xpm_split_view[]; +extern const char * const xpm_symbol_no[]; +extern const char * const xpm_symbol_mod[]; +extern const char * const xpm_symbol_yes[]; +extern const char * const xpm_choice_no[]; +extern const char * const xpm_choice_yes[]; +extern const char * const xpm_menu[]; +extern const char * const xpm_menu_inv[]; +extern const char * const xpm_menuback[]; +extern const char * const xpm_void[]; #ifdef __cplusplus } diff --git a/scripts/config/internal.h b/scripts/config/internal.h new file mode 100644 index 000000000..2f7298c21 --- /dev/null +++ b/scripts/config/internal.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef INTERNAL_H +#define INTERNAL_H + +struct menu; + +extern struct menu *current_menu, *current_entry; + +#endif /* INTERNAL_H */ diff --git a/scripts/config/lexer.l b/scripts/config/lexer.l index 575b679d3..0df51ec46 100644 --- a/scripts/config/lexer.l +++ b/scripts/config/lexer.l @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -38,7 +37,7 @@ struct buffer { YY_BUFFER_STATE state; }; -struct buffer *current_buf; +static struct buffer *current_buf; static int last_ts, first_ts; @@ -94,7 +93,6 @@ n [A-Za-z0-9_-] [ \t]* /* whitespaces */ \\\n /* escaped new line */ \n return T_EOL; -"allnoconfig_y" return T_ALLNOCONFIG_Y; "bool" return T_BOOL; "choice" return T_CHOICE; "comment" return T_COMMENT; @@ -102,12 +100,11 @@ n [A-Za-z0-9_-] "def_bool" return T_DEF_BOOL; "def_tristate" return T_DEF_TRISTATE; "default" return T_DEFAULT; -"defconfig_list" return T_DEFCONFIG_LIST; "depends" return T_DEPENDS; "endchoice" return T_ENDCHOICE; "endif" return T_ENDIF; "endmenu" return T_ENDMENU; -"help"|"---help---" return T_HELP; +"help" return T_HELP; "hex" return T_HEX; "if" return T_IF; "imply" return T_IMPLY; @@ -117,7 +114,6 @@ n [A-Za-z0-9_-] "menuconfig" return T_MENUCONFIG; "modules" return T_MODULES; "on" return T_ON; -"option" return T_OPTION; "optional" return T_OPTIONAL; "prompt" return T_PROMPT; "range" return T_RANGE; diff --git a/scripts/config/lexer.lex.c b/scripts/config/lexer.lex.c index 190928b2a..826c06e4e 100644 --- a/scripts/config/lexer.lex.c +++ b/scripts/config/lexer.lex.c @@ -357,82 +357,82 @@ extern char *yytext; #endif #define yytext_ptr yytext -static const flex_int16_t yy_nxt[][44] = +static const flex_int16_t yy_nxt[][43] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 + 0, 0, 0 }, { 9, 10, 11, 12, 13, 14, 15, 16, 17, 14, - 18, 19, 20, 21, 22, 22, 23, 24, 25, 26, - 27, 22, 28, 29, 30, 31, 32, 22, 22, 33, - 34, 22, 35, 22, 36, 37, 38, 39, 40, 22, - 41, 22, 22, 42 + 18, 19, 20, 21, 21, 22, 23, 24, 25, 26, + 21, 21, 27, 28, 29, 30, 21, 21, 31, 32, + 21, 33, 21, 34, 35, 36, 37, 38, 21, 39, + 21, 21, 40 }, { 9, 10, 11, 12, 13, 14, 15, 16, 17, 14, - 18, 19, 20, 21, 22, 22, 23, 24, 25, 26, - 27, 22, 28, 29, 30, 31, 32, 22, 22, 33, - 34, 22, 35, 22, 36, 37, 38, 39, 40, 22, - 41, 22, 22, 42 + 18, 19, 20, 21, 21, 22, 23, 24, 25, 26, + 21, 21, 27, 28, 29, 30, 21, 21, 31, 32, + 21, 33, 21, 34, 35, 36, 37, 38, 21, 39, + 21, 21, 40 }, { - 9, 43, 44, 45, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43 + 9, 41, 42, 43, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41 }, { - 9, 43, 44, 45, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43 + 9, 41, 42, 43, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41 }, { - 9, 46, 47, 48, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46 + 9, 44, 45, 46, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44 }, { - 9, 46, 47, 48, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46 + 9, 44, 45, 46, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44 }, { - 9, 49, 49, 50, 49, 51, 49, 52, 49, 51, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 53, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49 + 9, 47, 47, 48, 47, 49, 47, 50, 47, 49, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47 }, { - 9, 49, 49, 50, 49, 51, 49, 52, 49, 51, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 53, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49 + 9, 47, 47, 48, 47, 49, 47, 50, 47, 49, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 51, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47 }, { @@ -440,7 +440,7 @@ static const flex_int16_t yy_nxt[][44] = -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, - -9, -9, -9, -9 + -9, -9, -9 }, @@ -449,15 +449,15 @@ static const flex_int16_t yy_nxt[][44] = -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10 + -10, -10, -10 }, { - 9, -11, 54, -11, -11, -11, -11, -11, -11, -11, + 9, -11, 52, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11 + -11, -11, -11 }, @@ -466,15 +466,15 @@ static const flex_int16_t yy_nxt[][44] = -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12 + -12, -12, -12 }, { 9, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13, 55, -13, + -13, -13, -13, -13, -13, -13, -13, 53, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, - -13, -13, -13, -13 + -13, -13, -13 }, @@ -483,32 +483,32 @@ static const flex_int16_t yy_nxt[][44] = -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14 + -14, -14, -14 }, { - 9, 56, 56, -15, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56 + 9, 54, 54, -15, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54 }, { - 9, -16, -16, -16, -16, -16, -16, 57, -16, -16, - -16, -16, -16, 57, 57, 57, -16, -16, -16, -16, - -16, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, -16 + 9, -16, -16, -16, -16, -16, -16, 55, -16, -16, + -16, -16, -16, 55, 55, -16, -16, -16, -16, -16, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, -16 }, { - 9, -17, -17, -17, -17, -17, -17, -17, 58, -17, + 9, -17, -17, -17, -17, -17, -17, -17, 56, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17 + -17, -17, -17 }, @@ -517,7 +517,7 @@ static const flex_int16_t yy_nxt[][44] = -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -18, -18, -18 + -18, -18, -18 }, { @@ -525,194 +525,194 @@ static const flex_int16_t yy_nxt[][44] = -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, - -19, -19, -19, -19 + -19, -19, -19 }, { 9, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20, 59, -20, + -20, -20, -20, -20, -20, -20, -20, 57, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20 + -20, -20, -20 }, { - 9, -21, -21, -21, -21, -21, -21, 57, -21, -21, - -21, -21, -21, 60, 61, 61, -21, -21, -21, -21, - -21, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -21 + 9, -21, -21, -21, -21, -21, -21, 55, -21, -21, + -21, -21, -21, 58, 58, -21, -21, -21, -21, -21, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -21 }, { - 9, -22, -22, -22, -22, -22, -22, 57, -22, -22, - -22, -22, -22, 61, 61, 61, -22, -22, -22, -22, - -22, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -22 + 9, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, 59, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, + -22, -22, -22 }, { 9, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23, 62, -23, + -23, -23, -23, -23, -23, -23, -23, 60, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23 + -23, -23, -23 }, { 9, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, 63, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24 + -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24 }, { 9, -25, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, -25, -25, 61, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25 + -25, -25, -25 }, { - 9, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26, 64, -26, + 9, -26, -26, 62, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26 + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26 }, { - 9, -27, -27, 65, -27, -27, -27, -27, -27, -27, - -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -27, -27, -27, -27 + 9, -27, -27, -27, -27, -27, -27, 55, -27, -27, + -27, -27, -27, 58, 58, -27, -27, -27, -27, -27, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 63, 58, 58, 58, 58, 58, 58, + 58, 58, -27 }, { - 9, -28, -28, -28, -28, -28, -28, 57, -28, -28, - -28, -28, -28, 61, 61, 61, -28, -28, -28, -28, - -28, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 66, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -28 + 9, -28, -28, -28, -28, -28, -28, 55, -28, -28, + -28, -28, -28, 58, 58, -28, -28, -28, -28, -28, + 58, 58, 58, 58, 58, 58, 58, 58, 64, 58, + 58, 58, 58, 65, 58, 58, 58, 58, 58, 58, + 58, 58, -28 }, { - 9, -29, -29, -29, -29, -29, -29, 57, -29, -29, - -29, -29, -29, 61, 61, 61, -29, -29, -29, -29, - -29, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 67, 61, 61, 61, 61, 61, - 61, 61, 61, -29 + 9, -29, -29, -29, -29, -29, -29, 55, -29, -29, + -29, -29, -29, 58, 58, -29, -29, -29, -29, -29, + 58, 58, 58, 58, 58, 66, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -29 }, { - 9, -30, -30, -30, -30, -30, -30, 57, -30, -30, - -30, -30, -30, 61, 61, 61, -30, -30, -30, -30, - -30, 61, 61, 61, 61, 61, 61, 61, 61, 68, - 61, 61, 61, 61, 69, 61, 61, 61, 61, 61, - 61, 61, 61, -30 + 9, -30, -30, -30, -30, -30, -30, 55, -30, -30, + -30, -30, -30, 58, 58, -30, -30, -30, -30, -30, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 67, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -30 }, { - 9, -31, -31, -31, -31, -31, -31, 57, -31, -31, - -31, -31, -31, 61, 61, 61, -31, -31, -31, -31, - -31, 61, 61, 61, 61, 61, 70, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -31 + 9, -31, -31, -31, -31, -31, -31, 55, -31, -31, + -31, -31, -31, 58, 58, -31, -31, -31, -31, -31, + 58, 58, 58, 58, 58, 68, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -31 }, { - 9, -32, -32, -32, -32, -32, -32, 57, -32, -32, - -32, -32, -32, 61, 61, 61, -32, -32, -32, -32, - -32, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 71, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -32 + 9, -32, -32, -32, -32, -32, -32, 55, -32, -32, + -32, -32, -32, 58, 58, -32, -32, -32, -32, -32, + 58, 58, 58, 58, 58, 58, 69, 58, 58, 58, + 58, 70, 71, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -32 }, { - 9, -33, -33, -33, -33, -33, -33, 57, -33, -33, - -33, -33, -33, 61, 61, 61, -33, -33, -33, -33, - -33, 61, 61, 61, 61, 61, 72, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -33 + 9, -33, -33, -33, -33, -33, -33, 55, -33, -33, + -33, -33, -33, 58, 58, -33, -33, -33, -33, -33, + 58, 72, 58, 58, 58, 73, 58, 58, 58, 58, + 58, 58, 58, 74, 58, 58, 58, 58, 58, 58, + 58, 58, -33 }, { - 9, -34, -34, -34, -34, -34, -34, 57, -34, -34, - -34, -34, -34, 61, 61, 61, -34, -34, -34, -34, - -34, 61, 61, 61, 61, 61, 61, 73, 61, 61, - 61, 61, 74, 75, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -34 + 9, -34, -34, -34, -34, -34, -34, 55, -34, -34, + -34, -34, -34, 58, 58, -34, -34, -34, -34, -34, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 75, 58, 76, 58, 58, 58, 58, 58, + 58, 58, -34 }, { - 9, -35, -35, -35, -35, -35, -35, 57, -35, -35, - -35, -35, -35, 61, 61, 61, -35, -35, -35, -35, - -35, 61, 76, 61, 61, 61, 77, 61, 61, 61, - 61, 61, 61, 61, 78, 61, 61, 61, 61, 61, - 61, 61, 61, -35 + 9, -35, -35, -35, -35, -35, -35, 55, -35, -35, + -35, -35, -35, 58, 58, -35, -35, -35, -35, -35, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 77, 58, 58, 58, 58, + 58, 58, -35 }, { - 9, -36, -36, -36, -36, -36, -36, 57, -36, -36, - -36, -36, -36, 61, 61, 61, -36, -36, -36, -36, - -36, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 79, 61, 80, 61, 61, 61, 61, - 61, 61, 61, -36 + 9, -36, -36, -36, -36, -36, -36, 55, -36, -36, + -36, -36, -36, 58, 58, -36, -36, -36, -36, -36, + 58, 78, 58, 58, 58, 79, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -36 }, { - 9, -37, -37, -37, -37, -37, -37, 57, -37, -37, - -37, -37, -37, 61, 61, 61, -37, -37, -37, -37, - -37, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 81, 61, 61, 61, - 61, 61, 61, -37 + 9, -37, -37, -37, -37, -37, -37, 55, -37, -37, + -37, -37, -37, 58, 58, -37, -37, -37, -37, -37, + 58, 58, 58, 58, 58, 80, 58, 58, 58, 58, + 58, 58, 58, 81, 58, 58, 58, 82, 58, 58, + 58, 58, -37 }, { - 9, -38, -38, -38, -38, -38, -38, 57, -38, -38, - -38, -38, -38, 61, 61, 61, -38, -38, -38, -38, - -38, 61, 82, 61, 61, 61, 83, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -38 + 9, -38, -38, -38, -38, -38, -38, 55, -38, -38, + -38, -38, -38, 58, 58, -38, -38, -38, -38, -38, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 83, 58, 58, 58, 58, + 58, 58, -38 }, { - 9, -39, -39, -39, -39, -39, -39, 57, -39, -39, - -39, -39, -39, 61, 61, 61, -39, -39, -39, -39, - -39, 61, 61, 61, 61, 61, 84, 61, 61, 61, - 61, 61, 61, 61, 85, 61, 61, 61, 86, 61, - 61, 61, 61, -39 + 9, -39, -39, -39, -39, -39, -39, 55, -39, -39, + -39, -39, -39, 58, 58, -39, -39, -39, -39, -39, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 84, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -39 }, { - 9, -40, -40, -40, -40, -40, -40, 57, -40, -40, - -40, -40, -40, 61, 61, 61, -40, -40, -40, -40, - -40, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 87, 61, 61, 61, - 61, 61, 61, -40 + 9, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, 85 }, { - 9, -41, -41, -41, -41, -41, -41, 57, -41, -41, - -41, -41, -41, 61, 61, 61, -41, -41, -41, -41, - -41, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 88, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -41 + 9, 86, 87, -41, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86 }, @@ -721,143 +721,143 @@ static const flex_int16_t yy_nxt[][44] = -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, 89 + -42, -42, -42 }, { - 9, 90, 91, -43, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90 + 9, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43 }, { - 9, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, - -44, -44, -44, -44 + 9, 88, 88, -44, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88 }, { - 9, -45, -45, -45, -45, -45, -45, -45, -45, -45, + 9, -45, 89, 90, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45 + -45, -45, -45 }, { - 9, 92, 92, -46, 92, 92, 92, 92, 92, 92, + 9, 91, -46, -46, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91 + }, + + { + 9, 92, 92, -47, 92, -47, 92, -47, 92, -47, + 92, 92, 92, 92, 92, 92, 92, 92, 92, -47, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, - 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, - 92, 92, 92, 92 - }, - - { - 9, -47, 93, 94, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -47 + 92, 92, 92 }, { - 9, 95, -48, -48, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95 + 9, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48 }, { - 9, 96, 96, -49, 96, -49, 96, -49, 96, -49, - 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - -49, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96 + 9, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49 }, { - 9, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50 + 9, 93, 93, -50, 93, 93, 93, 93, 93, 93, + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, + 93, 93, 93 }, { - 9, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, - -51, -51, -51, -51 + 9, 94, 94, -51, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94 }, { - 9, 97, 97, -52, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97 + 9, -52, 52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52 }, { - 9, 98, 98, -53, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98 + 9, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53 }, { - 9, -54, 54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54 + 9, 54, 54, -54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54 }, { - 9, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55 + 9, -55, -55, -55, -55, -55, -55, 55, -55, -55, + -55, -55, -55, 55, 55, -55, -55, -55, -55, -55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, -55 }, { - 9, 56, 56, -56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56 + 9, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, -56, -56 }, { - 9, -57, -57, -57, -57, -57, -57, 57, -57, -57, - -57, -57, -57, 57, 57, 57, -57, -57, -57, -57, - -57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, -57 + 9, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, -57, -57 }, { - 9, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58 + 9, -58, -58, -58, -58, -58, -58, 55, -58, -58, + -58, -58, -58, 58, 58, -58, -58, -58, -58, -58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -58 }, { @@ -865,24 +865,24 @@ static const flex_int16_t yy_nxt[][44] = -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -59 + -59, -59, -59 }, { - 9, -60, -60, -60, -60, -60, -60, 57, -60, -60, - -60, -60, -60, 99, 61, 61, -60, -60, -60, -60, - -60, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -60 + 9, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, -60, -60 }, { - 9, -61, -61, -61, -61, -61, -61, 57, -61, -61, - -61, -61, -61, 61, 61, 61, -61, -61, -61, -61, - -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -61 + 9, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, + -61, -61, -61 }, @@ -891,1546 +891,1265 @@ static const flex_int16_t yy_nxt[][44] = -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62 + -62, -62, -62 }, { - 9, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63 + 9, -63, -63, -63, -63, -63, -63, 55, -63, -63, + -63, -63, -63, 58, 58, -63, -63, -63, -63, -63, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 95, 58, 58, 58, 58, 58, 58, + 58, 58, -63 }, { - 9, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64 + 9, -64, -64, -64, -64, -64, -64, 55, -64, -64, + -64, -64, -64, 58, 58, -64, -64, -64, -64, -64, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 96, 58, 58, 58, 58, 58, 58, + 58, 58, -64 }, { - 9, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, - -65, -65, -65, -65 + 9, -65, -65, -65, -65, -65, -65, 55, -65, -65, + -65, -65, -65, 58, 58, -65, -65, -65, -65, -65, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 97, 98, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -65 }, { - 9, -66, -66, -66, -66, -66, -66, 57, -66, -66, - -66, -66, -66, 61, 61, 61, -66, -66, -66, -66, - -66, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 100, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -66 + 9, -66, -66, -66, -66, -66, -66, 55, -66, -66, + -66, -66, -66, 58, 58, -66, -66, -66, -66, -66, + 58, 58, 58, 58, 58, 58, 99, 58, 58, 58, + 58, 58, 58, 58, 100, 58, 58, 58, 58, 58, + 58, 58, -66 }, { - 9, -67, -67, -67, -67, -67, -67, 57, -67, -67, - -67, -67, -67, 61, 61, 61, -67, -67, -67, -67, - -67, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 101, 61, 61, 61, 61, 61, - 61, 61, 61, -67 + 9, -67, -67, -67, -67, -67, -67, 55, -67, -67, + -67, -67, -67, 58, 58, -67, -67, -67, -67, -67, + 58, 58, 58, 58, 101, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -67 }, { - 9, -68, -68, -68, -68, -68, -68, 57, -68, -68, - -68, -68, -68, 61, 61, 61, -68, -68, -68, -68, - -68, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 102, 61, 61, 61, 61, 61, - 61, 61, 61, -68 + 9, -68, -68, -68, -68, -68, -68, 55, -68, -68, + -68, -68, -68, 58, 58, -68, -68, -68, -68, -68, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 102, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 103, 58, -68 }, { - 9, -69, -69, -69, -69, -69, -69, 57, -69, -69, - -69, -69, -69, 61, 61, 61, -69, -69, -69, -69, - -69, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 103, 104, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -69 + 9, -69, -69, -69, -69, -69, -69, 55, -69, -69, + -69, -69, -69, 58, 58, -69, -69, -69, -69, -69, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -69 }, { - 9, -70, -70, -70, -70, -70, -70, 57, -70, -70, - -70, -70, -70, 61, 61, 61, -70, -70, -70, -70, - -70, 61, 61, 61, 61, 61, 61, 105, 61, 61, - 61, 61, 61, 61, 61, 106, 61, 61, 61, 61, - 61, 61, 61, -70 + 9, -70, -70, -70, -70, -70, -70, 55, -70, -70, + -70, -70, -70, 58, 58, -70, -70, -70, -70, -70, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 104, 58, 58, 58, 58, 58, + 58, 58, -70 }, { - 9, -71, -71, -71, -71, -71, -71, 57, -71, -71, - -71, -71, -71, 61, 61, 61, -71, -71, -71, -71, - -71, 61, 61, 61, 61, 107, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -71 + 9, -71, -71, -71, -71, -71, -71, 55, -71, -71, + -71, -71, -71, 58, 58, -71, -71, -71, -71, -71, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 105, 58, 58, + 58, 58, -71 }, { - 9, -72, -72, -72, -72, -72, -72, 57, -72, -72, - -72, -72, -72, 61, 61, 61, -72, -72, -72, -72, - -72, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 108, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 109, 61, -72 + 9, -72, -72, -72, -72, -72, -72, 55, -72, -72, + -72, -72, -72, 58, 58, -72, -72, -72, -72, -72, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 106, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -72 }, { - 9, -73, -73, -73, -73, -73, -73, 57, -73, -73, - -73, -73, -73, 61, 61, 61, -73, -73, -73, -73, - -73, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -73 + 9, -73, -73, -73, -73, -73, -73, 55, -73, -73, + -73, -73, -73, 58, 58, -73, -73, -73, -73, -73, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 107, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -73 }, { - 9, -74, -74, -74, -74, -74, -74, 57, -74, -74, - -74, -74, -74, 61, 61, 61, -74, -74, -74, -74, - -74, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 110, 61, 61, 61, 61, - 61, 61, 61, -74 + 9, -74, -74, -74, -74, -74, -74, 55, -74, -74, + -74, -74, -74, 58, 58, -74, -74, -74, -74, -74, + 58, 58, 58, 58, 108, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -74 }, { - 9, -75, -75, -75, -75, -75, -75, 57, -75, -75, - -75, -75, -75, 61, 61, 61, -75, -75, -75, -75, - -75, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 111, 61, - 61, 61, 61, -75 + 9, -75, -75, -75, -75, -75, -75, 55, -75, -75, + -75, -75, -75, 58, 58, -75, -75, -75, -75, -75, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -75 }, { - 9, -76, -76, -76, -76, -76, -76, 57, -76, -76, - -76, -76, -76, 61, 61, 61, -76, -76, -76, -76, - -76, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 112, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -76 + 9, -76, -76, -76, -76, -76, -76, 55, -76, -76, + -76, -76, -76, 58, 58, -76, -76, -76, -76, -76, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 109, 58, 58, + 58, 58, -76 }, { - 9, -77, -77, -77, -77, -77, -77, 57, -77, -77, - -77, -77, -77, 61, 61, 61, -77, -77, -77, -77, - -77, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 113, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -77 + 9, -77, -77, -77, -77, -77, -77, 55, -77, -77, + -77, -77, -77, 58, 58, -77, -77, -77, -77, -77, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 110, 58, 58, 58, 58, 58, 58, + 58, 58, -77 }, { - 9, -78, -78, -78, -78, -78, -78, 57, -78, -78, - -78, -78, -78, 61, 61, 61, -78, -78, -78, -78, - -78, 61, 61, 61, 61, 114, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -78 + 9, -78, -78, -78, -78, -78, -78, 55, -78, -78, + -78, -78, -78, 58, 58, -78, -78, -78, -78, -78, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 111, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -78 }, { - 9, -79, -79, -79, -79, -79, -79, 57, -79, -79, - -79, -79, -79, 61, 61, 61, -79, -79, -79, -79, - -79, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -79 + 9, -79, -79, -79, -79, -79, -79, 55, -79, -79, + -79, -79, -79, 58, 58, -79, -79, -79, -79, -79, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 112, 58, 58, 58, + 58, 58, -79 }, { - 9, -80, -80, -80, -80, -80, -80, 57, -80, -80, - -80, -80, -80, 61, 61, 61, -80, -80, -80, -80, - -80, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 115, 61, - 61, 61, 61, -80 + 9, -80, -80, -80, -80, -80, -80, 55, -80, -80, + -80, -80, -80, 58, 58, -80, -80, -80, -80, -80, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 113, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -80 }, { - 9, -81, -81, -81, -81, -81, -81, 57, -81, -81, - -81, -81, -81, 61, 61, 61, -81, -81, -81, -81, - -81, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 116, 61, 61, 61, 61, 61, - 61, 61, 61, -81 + 9, -81, -81, -81, -81, -81, -81, 55, -81, -81, + -81, -81, -81, 58, 58, -81, -81, -81, -81, -81, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 114, 58, + 58, 58, -81 }, { - 9, -82, -82, -82, -82, -82, -82, 57, -82, -82, - -82, -82, -82, 61, 61, 61, -82, -82, -82, -82, - -82, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 117, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -82 + 9, -82, -82, -82, -82, -82, -82, 55, -82, -82, + -82, -82, -82, 58, 58, -82, -82, -82, -82, -82, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 115, 58, 58, 58, 58, + 58, 58, -82 }, { - 9, -83, -83, -83, -83, -83, -83, 57, -83, -83, - -83, -83, -83, 61, 61, 61, -83, -83, -83, -83, - -83, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 118, 61, 61, - 61, 61, 61, -83 + 9, -83, -83, -83, -83, -83, -83, 55, -83, -83, + -83, -83, -83, 58, 58, -83, -83, -83, -83, -83, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 116, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -83 }, { - 9, -84, -84, -84, -84, -84, -84, 57, -84, -84, - -84, -84, -84, 61, 61, 61, -84, -84, -84, -84, - -84, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 119, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -84 + 9, -84, -84, -84, -84, -84, -84, 55, -84, -84, + -84, -84, -84, 58, 58, -84, -84, -84, -84, -84, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 117, 58, 58, 58, + 58, 58, -84 }, { - 9, -85, -85, -85, -85, -85, -85, 57, -85, -85, - -85, -85, -85, 61, 61, 61, -85, -85, -85, -85, - -85, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 120, - 61, 61, 61, -85 + 9, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, + -85, -85, -85 }, { - 9, -86, -86, -86, -86, -86, -86, 57, -86, -86, - -86, -86, -86, 61, 61, 61, -86, -86, -86, -86, - -86, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 121, 61, 61, 61, - 61, 61, 61, -86 + 9, 86, 87, -86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86 }, { - 9, -87, -87, -87, -87, -87, -87, 57, -87, -87, - -87, -87, -87, 61, 61, 61, -87, -87, -87, -87, - -87, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 122, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -87 + 9, 87, 87, -87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87 }, { - 9, -88, -88, -88, -88, -88, -88, 57, -88, -88, - -88, -88, -88, 61, 61, 61, -88, -88, -88, -88, - -88, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 123, 61, 61, - 61, 61, 61, -88 + 9, 88, 88, -88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88 }, { - 9, -89, -89, -89, -89, -89, -89, -89, -89, -89, + 9, -89, 89, 90, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, - -89, -89, -89, -89 + -89, -89, -89 }, { - 9, 90, 91, -90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90 - }, - - { - 9, 91, 91, -91, 91, 91, 91, 91, 91, 91, + 9, 91, -90, -90, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91 + 91, 91, 91 + }, + + { + 9, -91, -91, -91, -91, -91, -91, -91, -91, -91, + -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, + -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, + -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, + -91, -91, -91 }, { - 9, 92, 92, -92, 92, 92, 92, 92, 92, 92, + 9, 92, 92, -92, 92, -92, 92, -92, 92, -92, + 92, 92, 92, 92, 92, 92, 92, 92, 92, -92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, - 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, - 92, 92, 92, 92 + 92, 92, 92 }, { - 9, -93, 93, 94, -93, -93, -93, -93, -93, -93, - -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, - -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, - -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, - -93, -93, -93, -93 + 9, 93, 93, -93, 93, 93, 93, 93, 93, 93, + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, + 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, + 93, 93, 93 }, { - 9, 95, -94, -94, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95 + 9, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94 }, { - 9, -95, -95, -95, -95, -95, -95, -95, -95, -95, - -95, -95, -95, -95, -95, -95, -95, -95, -95, -95, - -95, -95, -95, -95, -95, -95, -95, -95, -95, -95, - -95, -95, -95, -95, -95, -95, -95, -95, -95, -95, - -95, -95, -95, -95 + 9, -95, -95, -95, -95, -95, -95, 55, -95, -95, + -95, -95, -95, 58, 58, -95, -95, -95, -95, -95, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 118, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -95 }, { - 9, 96, 96, -96, 96, -96, 96, -96, 96, -96, - 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - -96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96 + 9, -96, -96, -96, -96, -96, -96, 55, -96, -96, + -96, -96, -96, 58, 58, -96, -96, -96, -96, -96, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 119, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -96 }, { - 9, 97, 97, -97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97 + 9, -97, -97, -97, -97, -97, -97, 55, -97, -97, + -97, -97, -97, 58, 58, -97, -97, -97, -97, -97, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 120, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -97 }, { - 9, -98, -98, -98, -98, -98, -98, -98, -98, -98, - -98, -98, -98, -98, -98, -98, -98, -98, -98, -98, - -98, -98, -98, -98, -98, -98, -98, -98, -98, -98, - -98, -98, -98, -98, -98, -98, -98, -98, -98, -98, - -98, -98, -98, -98 + 9, -98, -98, -98, -98, -98, -98, 55, -98, -98, + -98, -98, -98, 58, 58, -98, -98, -98, -98, -98, + 58, 58, 58, 58, 58, 58, 121, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -98 }, { - 9, -99, -99, -99, -99, -99, -99, 57, -99, -99, - -99, -99, -99, 61, 61, 61, -99, -99, -99, -99, - -99, 61, 61, 61, 61, 61, 61, 61, 61, 124, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -99 + 9, -99, -99, -99, -99, -99, -99, 55, -99, -99, + -99, -99, -99, 58, 58, -99, -99, -99, -99, -99, + 122, 123, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -99 }, { - 9, -100, -100, -100, -100, -100, -100, 57, -100, -100, - -100, -100, -100, 61, 61, 61, -100, -100, -100, -100, - -100, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 125, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -100 + 9, -100, -100, -100, -100, -100, -100, 55, -100, -100, + -100, -100, -100, 58, 58, -100, -100, -100, -100, -100, + 58, 58, 58, 58, 58, 124, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -100 }, { - 9, -101, -101, -101, -101, -101, -101, 57, -101, -101, - -101, -101, -101, 61, 61, 61, -101, -101, -101, -101, - -101, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 126, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -101 + 9, -101, -101, -101, -101, -101, -101, 55, -101, -101, + -101, -101, -101, 58, 58, -101, -101, -101, -101, -101, + 58, 58, 58, 125, 58, 58, 58, 58, 58, 126, + 58, 127, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -101 }, { - 9, -102, -102, -102, -102, -102, -102, 57, -102, -102, - -102, -102, -102, 61, 61, 61, -102, -102, -102, -102, - -102, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 127, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -102 + 9, -102, -102, -102, -102, -102, -102, 55, -102, -102, + -102, -102, -102, 58, 58, -102, -102, -102, -102, -102, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 128, 58, 58, 58, 58, 58, + 58, 58, -102 }, { - 9, -103, -103, -103, -103, -103, -103, 57, -103, -103, - -103, -103, -103, 61, 61, 61, -103, -103, -103, -103, - -103, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 128, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -103 + 9, -103, -103, -103, -103, -103, -103, 55, -103, -103, + -103, -103, -103, 58, 58, -103, -103, -103, -103, -103, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -103 }, { - 9, -104, -104, -104, -104, -104, -104, 57, -104, -104, - -104, -104, -104, 61, 61, 61, -104, -104, -104, -104, - -104, 61, 61, 61, 61, 61, 61, 129, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -104 + 9, -104, -104, -104, -104, -104, -104, 55, -104, -104, + -104, -104, -104, 58, 58, -104, -104, -104, -104, -104, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 129, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -104 }, { - 9, -105, -105, -105, -105, -105, -105, 57, -105, -105, - -105, -105, -105, 61, 61, 61, -105, -105, -105, -105, - -105, 130, 131, 61, 132, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -105 + 9, -105, -105, -105, -105, -105, -105, 55, -105, -105, + -105, -105, -105, 58, 58, -105, -105, -105, -105, -105, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -105 }, { - 9, -106, -106, -106, -106, -106, -106, 57, -106, -106, - -106, -106, -106, 61, 61, 61, -106, -106, -106, -106, - -106, 61, 61, 61, 61, 61, 133, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -106 + 9, -106, -106, -106, -106, -106, -106, 55, -106, -106, + -106, -106, -106, 58, 58, -106, -106, -106, -106, -106, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 130, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -106 }, { - 9, -107, -107, -107, -107, -107, -107, 57, -107, -107, - -107, -107, -107, 61, 61, 61, -107, -107, -107, -107, - -107, 61, 61, 61, 134, 61, 61, 61, 61, 61, - 135, 61, 136, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -107 + 9, -107, -107, -107, -107, -107, -107, 55, -107, -107, + -107, -107, -107, 58, 58, -107, -107, -107, -107, -107, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 131, 58, + 58, 58, -107 }, { - 9, -108, -108, -108, -108, -108, -108, 57, -108, -108, - -108, -108, -108, 61, 61, 61, -108, -108, -108, -108, - -108, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 137, 61, 61, 61, 61, - 61, 61, 61, -108 + 9, -108, -108, -108, -108, -108, -108, 55, -108, -108, + -108, -108, -108, 58, 58, -108, -108, -108, -108, -108, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 132, 58, + 58, 58, -108 }, { - 9, -109, -109, -109, -109, -109, -109, 57, -109, -109, - -109, -109, -109, 61, 61, 61, -109, -109, -109, -109, - -109, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -109 + 9, -109, -109, -109, -109, -109, -109, 55, -109, -109, + -109, -109, -109, 58, 58, -109, -109, -109, -109, -109, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 133, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -109 }, { - 9, -110, -110, -110, -110, -110, -110, 57, -110, -110, - -110, -110, -110, 61, 61, 61, -110, -110, -110, -110, - -110, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 138, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -110 + 9, -110, -110, -110, -110, -110, -110, 55, -110, -110, + -110, -110, -110, 58, 58, -110, -110, -110, -110, -110, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 134, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -110 }, { - 9, -111, -111, -111, -111, -111, -111, 57, -111, -111, - -111, -111, -111, 61, 61, 61, -111, -111, -111, -111, - -111, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -111 + 9, -111, -111, -111, -111, -111, -111, 55, -111, -111, + -111, -111, -111, 58, 58, -111, -111, -111, -111, -111, + 58, 58, 58, 58, 58, 58, 58, 135, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -111 }, { - 9, -112, -112, -112, -112, -112, -112, 57, -112, -112, - -112, -112, -112, 61, 61, 61, -112, -112, -112, -112, - -112, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 139, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -112 + 9, -112, -112, -112, -112, -112, -112, 55, -112, -112, + -112, -112, -112, 58, 58, -112, -112, -112, -112, -112, + 58, 58, 58, 58, 58, 136, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -112 }, { - 9, -113, -113, -113, -113, -113, -113, 57, -113, -113, - -113, -113, -113, 61, 61, 61, -113, -113, -113, -113, - -113, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 140, - 61, 61, 61, -113 + 9, -113, -113, -113, -113, -113, -113, 55, -113, -113, + -113, -113, -113, 58, 58, -113, -113, -113, -113, -113, + 58, 58, 58, 58, 58, 137, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -113 }, { - 9, -114, -114, -114, -114, -114, -114, 57, -114, -114, - -114, -114, -114, 61, 61, 61, -114, -114, -114, -114, - -114, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 141, - 61, 61, 61, -114 + 9, -114, -114, -114, -114, -114, -114, 55, -114, -114, + -114, -114, -114, 58, 58, -114, -114, -114, -114, -114, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 138, 58, 58, 58, 58, + 58, 58, -114 }, { - 9, -115, -115, -115, -115, -115, -115, 57, -115, -115, - -115, -115, -115, 61, 61, 61, -115, -115, -115, -115, - -115, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 142, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -115 + 9, -115, -115, -115, -115, -115, -115, 55, -115, -115, + -115, -115, -115, 58, 58, -115, -115, -115, -115, -115, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 139, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -115 }, { - 9, -116, -116, -116, -116, -116, -116, 57, -116, -116, - -116, -116, -116, 61, 61, 61, -116, -116, -116, -116, - -116, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 143, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -116 + 9, -116, -116, -116, -116, -116, -116, 55, -116, -116, + -116, -116, -116, 58, 58, -116, -116, -116, -116, -116, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 140, 58, 58, 58, + 58, 58, -116 }, { - 9, -117, -117, -117, -117, -117, -117, 57, -117, -117, - -117, -117, -117, 61, 61, 61, -117, -117, -117, -117, - -117, 61, 61, 61, 61, 61, 61, 61, 144, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -117 + 9, -117, -117, -117, -117, -117, -117, 55, -117, -117, + -117, -117, -117, 58, 58, -117, -117, -117, -117, -117, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 141, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -117 }, { - 9, -118, -118, -118, -118, -118, -118, 57, -118, -118, - -118, -118, -118, 61, 61, 61, -118, -118, -118, -118, - -118, 61, 61, 61, 61, 61, 145, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -118 + 9, -118, -118, -118, -118, -118, -118, 55, -118, -118, + -118, -118, -118, 58, 58, -118, -118, -118, -118, -118, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -118 }, { - 9, -119, -119, -119, -119, -119, -119, 57, -119, -119, - -119, -119, -119, 61, 61, 61, -119, -119, -119, -119, - -119, 61, 61, 61, 61, 61, 146, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -119 + 9, -119, -119, -119, -119, -119, -119, 55, -119, -119, + -119, -119, -119, 58, 58, -119, -119, -119, -119, -119, + 58, 58, 58, 142, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -119 }, { - 9, -120, -120, -120, -120, -120, -120, 57, -120, -120, - -120, -120, -120, 61, 61, 61, -120, -120, -120, -120, - -120, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 147, 61, 61, 61, - 61, 61, 61, -120 + 9, -120, -120, -120, -120, -120, -120, 55, -120, -120, + -120, -120, -120, 58, 58, -120, -120, -120, -120, -120, + 58, 58, 58, 58, 58, 143, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -120 }, { - 9, -121, -121, -121, -121, -121, -121, 57, -121, -121, - -121, -121, -121, 61, 61, 61, -121, -121, -121, -121, - -121, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 148, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -121 + 9, -121, -121, -121, -121, -121, -121, 55, -121, -121, + -121, -121, -121, 58, 58, -121, -121, -121, -121, -121, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 144, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -121 }, { - 9, -122, -122, -122, -122, -122, -122, 57, -122, -122, - -122, -122, -122, 61, 61, 61, -122, -122, -122, -122, - -122, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 149, 61, 61, - 61, 61, 61, -122 + 9, -122, -122, -122, -122, -122, -122, 55, -122, -122, + -122, -122, -122, 58, 58, -122, -122, -122, -122, -122, + 58, 58, 145, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 146, 58, 58, + 58, 58, -122 }, { - 9, -123, -123, -123, -123, -123, -123, 57, -123, -123, - -123, -123, -123, 61, 61, 61, -123, -123, -123, -123, - -123, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 150, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -123 + 9, -123, -123, -123, -123, -123, -123, 55, -123, -123, + -123, -123, -123, 58, 58, -123, -123, -123, -123, -123, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 147, 58, + 58, 58, -123 }, { - 9, -124, -124, -124, -124, -124, -124, 57, -124, -124, - -124, -124, -124, 61, 61, 61, -124, -124, -124, -124, - -124, 61, 61, 61, 61, 61, 151, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -124 + 9, -124, -124, -124, -124, -124, -124, 55, -124, -124, + -124, -124, -124, 58, 58, -124, -124, -124, -124, -124, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 148, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -124 }, { - 9, -125, -125, -125, -125, -125, -125, 57, -125, -125, - -125, -125, -125, 61, 61, 61, -125, -125, -125, -125, - -125, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 152, 61, 61, 61, 61, 61, - 61, 61, 61, -125 + 9, -125, -125, -125, -125, -125, -125, 55, -125, -125, + -125, -125, -125, 58, 58, -125, -125, -125, -125, -125, + 58, 58, 58, 58, 58, 58, 58, 58, 149, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -125 }, { - 9, -126, -126, -126, -126, -126, -126, 57, -126, -126, - -126, -126, -126, 61, 61, 61, -126, -126, -126, -126, - -126, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -126 + 9, -126, -126, -126, -126, -126, -126, 55, -126, -126, + -126, -126, -126, 58, 58, -126, -126, -126, -126, -126, + 58, 58, 58, 58, 58, 58, 150, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -126 }, { - 9, -127, -127, -127, -127, -127, -127, 57, -127, -127, - -127, -127, -127, 61, 61, 61, -127, -127, -127, -127, - -127, 61, 61, 61, 153, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -127 + 9, -127, -127, -127, -127, -127, -127, 55, -127, -127, + -127, -127, -127, 58, 58, -127, -127, -127, -127, -127, + 58, 58, 58, 58, 58, 151, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -127 }, { - 9, -128, -128, -128, -128, -128, -128, 57, -128, -128, - -128, -128, -128, 61, 61, 61, -128, -128, -128, -128, - -128, 61, 61, 61, 61, 61, 154, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -128 + 9, -128, -128, -128, -128, -128, -128, 55, -128, -128, + -128, -128, -128, 58, 58, -128, -128, -128, -128, -128, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -128 }, { - 9, -129, -129, -129, -129, -129, -129, 57, -129, -129, - -129, -129, -129, 61, 61, 61, -129, -129, -129, -129, - -129, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 155, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -129 + 9, -129, -129, -129, -129, -129, -129, 55, -129, -129, + -129, -129, -129, 58, 58, -129, -129, -129, -129, -129, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 152, -129 }, { - 9, -130, -130, -130, -130, -130, -130, 57, -130, -130, - -130, -130, -130, 61, 61, 61, -130, -130, -130, -130, - -130, 61, 61, 156, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 157, 61, - 61, 61, 61, -130 + 9, -130, -130, -130, -130, -130, -130, 55, -130, -130, + -130, -130, -130, 58, 58, -130, -130, -130, -130, -130, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 153, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -130 }, { - 9, -131, -131, -131, -131, -131, -131, 57, -131, -131, - -131, -131, -131, 61, 61, 61, -131, -131, -131, -131, - -131, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 158, - 61, 61, 61, -131 + 9, -131, -131, -131, -131, -131, -131, 55, -131, -131, + -131, -131, -131, 58, 58, -131, -131, -131, -131, -131, + 58, 58, 58, 154, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -131 }, { - 9, -132, -132, -132, -132, -132, -132, 57, -132, -132, - -132, -132, -132, 61, 61, 61, -132, -132, -132, -132, - -132, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 159, 61, 61, 61, 61, 61, - 61, 61, 61, -132 + 9, -132, -132, -132, -132, -132, -132, 55, -132, -132, + -132, -132, -132, 58, 58, -132, -132, -132, -132, -132, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 155, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -132 }, { - 9, -133, -133, -133, -133, -133, -133, 57, -133, -133, - -133, -133, -133, 61, 61, 61, -133, -133, -133, -133, - -133, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 160, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -133 + 9, -133, -133, -133, -133, -133, -133, 55, -133, -133, + -133, -133, -133, 58, 58, -133, -133, -133, -133, -133, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 156, 58, 58, 58, 58, 58, 58, + 58, 58, -133 }, { - 9, -134, -134, -134, -134, -134, -134, 57, -134, -134, - -134, -134, -134, 61, 61, 61, -134, -134, -134, -134, - -134, 61, 61, 61, 61, 61, 61, 61, 61, 161, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -134 + 9, -134, -134, -134, -134, -134, -134, 55, -134, -134, + -134, -134, -134, 58, 58, -134, -134, -134, -134, -134, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 157, 58, 58, 58, 58, 58, + 58, 58, -134 }, { - 9, -135, -135, -135, -135, -135, -135, 57, -135, -135, - -135, -135, -135, 61, 61, 61, -135, -135, -135, -135, - -135, 61, 61, 61, 61, 61, 61, 162, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -135 + 9, -135, -135, -135, -135, -135, -135, 55, -135, -135, + -135, -135, -135, 58, 58, -135, -135, -135, -135, -135, + 58, 58, 58, 58, 58, 158, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -135 }, { - 9, -136, -136, -136, -136, -136, -136, 57, -136, -136, - -136, -136, -136, 61, 61, 61, -136, -136, -136, -136, - -136, 61, 61, 61, 61, 61, 163, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -136 + 9, -136, -136, -136, -136, -136, -136, 55, -136, -136, + -136, -136, -136, 58, 58, -136, -136, -136, -136, -136, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 159, 58, 58, + 58, 58, -136 }, { - 9, -137, -137, -137, -137, -137, -137, 57, -137, -137, - -137, -137, -137, 61, 61, 61, -137, -137, -137, -137, - -137, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -137 + 9, -137, -137, -137, -137, -137, -137, 55, -137, -137, + -137, -137, -137, 58, 58, -137, -137, -137, -137, -137, + 58, 58, 58, 160, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -137 }, { - 9, -138, -138, -138, -138, -138, -138, 57, -138, -138, - -138, -138, -138, 61, 61, 61, -138, -138, -138, -138, - -138, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 164, -138 + 9, -138, -138, -138, -138, -138, -138, 55, -138, -138, + -138, -138, -138, 58, 58, -138, -138, -138, -138, -138, + 58, 58, 58, 161, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -138 }, { - 9, -139, -139, -139, -139, -139, -139, 57, -139, -139, - -139, -139, -139, 61, 61, 61, -139, -139, -139, -139, - -139, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 165, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -139 + 9, -139, -139, -139, -139, -139, -139, 55, -139, -139, + -139, -139, -139, 58, 58, -139, -139, -139, -139, -139, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 162, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -139 }, { - 9, -140, -140, -140, -140, -140, -140, 57, -140, -140, - -140, -140, -140, 61, 61, 61, -140, -140, -140, -140, - -140, 61, 61, 61, 166, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -140 + 9, -140, -140, -140, -140, -140, -140, 55, -140, -140, + -140, -140, -140, 58, 58, -140, -140, -140, -140, -140, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 163, 58, 58, + 58, 58, -140 }, { - 9, -141, -141, -141, -141, -141, -141, 57, -141, -141, - -141, -141, -141, 61, 61, 61, -141, -141, -141, -141, - -141, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 167, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -141 + 9, -141, -141, -141, -141, -141, -141, 55, -141, -141, + -141, -141, -141, 58, 58, -141, -141, -141, -141, -141, + 58, 58, 164, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -141 }, { - 9, -142, -142, -142, -142, -142, -142, 57, -142, -142, - -142, -142, -142, 61, 61, 61, -142, -142, -142, -142, - -142, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 168, 61, 61, 61, 61, 61, - 61, 61, 61, -142 + 9, -142, -142, -142, -142, -142, -142, 55, -142, -142, + -142, -142, -142, 58, 58, -142, -142, -142, -142, -142, + 58, 58, 58, 58, 58, 165, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -142 }, { - 9, -143, -143, -143, -143, -143, -143, 57, -143, -143, - -143, -143, -143, 61, 61, 61, -143, -143, -143, -143, - -143, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 169, 61, 61, 61, 61, - 61, 61, 61, -143 + 9, -143, -143, -143, -143, -143, -143, 55, -143, -143, + -143, -143, -143, 58, 58, -143, -143, -143, -143, -143, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 166, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -143 }, { - 9, -144, -144, -144, -144, -144, -144, 57, -144, -144, - -144, -144, -144, 61, 61, 61, -144, -144, -144, -144, - -144, 61, 61, 61, 61, 61, 170, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -144 + 9, -144, -144, -144, -144, -144, -144, 55, -144, -144, + -144, -144, -144, 58, 58, -144, -144, -144, -144, -144, + 58, 58, 58, 58, 58, 58, 58, 167, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -144 }, { - 9, -145, -145, -145, -145, -145, -145, 57, -145, -145, - -145, -145, -145, 61, 61, 61, -145, -145, -145, -145, - -145, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 171, 61, - 61, 61, 61, -145 + 9, -145, -145, -145, -145, -145, -145, 55, -145, -145, + -145, -145, -145, 58, 58, -145, -145, -145, -145, -145, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 168, 58, 58, 58, 58, 58, 58, + 58, 58, -145 }, { - 9, -146, -146, -146, -146, -146, -146, 57, -146, -146, - -146, -146, -146, 61, 61, 61, -146, -146, -146, -146, - -146, 61, 61, 61, 172, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -146 + 9, -146, -146, -146, -146, -146, -146, 55, -146, -146, + -146, -146, -146, 58, 58, -146, -146, -146, -146, -146, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 169, 58, 58, 58, 58, + 58, 58, -146 }, { - 9, -147, -147, -147, -147, -147, -147, 57, -147, -147, - -147, -147, -147, 61, 61, 61, -147, -147, -147, -147, - -147, 61, 61, 61, 173, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -147 + 9, -147, -147, -147, -147, -147, -147, 55, -147, -147, + -147, -147, -147, 58, 58, -147, -147, -147, -147, -147, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 170, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -147 }, { - 9, -148, -148, -148, -148, -148, -148, 57, -148, -148, - -148, -148, -148, 61, 61, 61, -148, -148, -148, -148, - -148, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 174, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -148 + 9, -148, -148, -148, -148, -148, -148, 55, -148, -148, + -148, -148, -148, 58, 58, -148, -148, -148, -148, -148, + 58, 58, 58, 58, 171, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -148 }, { - 9, -149, -149, -149, -149, -149, -149, 57, -149, -149, - -149, -149, -149, 61, 61, 61, -149, -149, -149, -149, - -149, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 175, 61, - 61, 61, 61, -149 + 9, -149, -149, -149, -149, -149, -149, 55, -149, -149, + -149, -149, -149, 58, 58, -149, -149, -149, -149, -149, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 172, 58, 58, 58, 58, 58, 58, + 58, 58, -149 }, { - 9, -150, -150, -150, -150, -150, -150, 57, -150, -150, - -150, -150, -150, 61, 61, 61, -150, -150, -150, -150, - -150, 61, 61, 176, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -150 + 9, -150, -150, -150, -150, -150, -150, 55, -150, -150, + -150, -150, -150, 58, 58, -150, -150, -150, -150, -150, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -150 }, { - 9, -151, -151, -151, -151, -151, -151, 57, -151, -151, - -151, -151, -151, 61, 61, 61, -151, -151, -151, -151, - -151, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 177, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -151 + 9, -151, -151, -151, -151, -151, -151, 55, -151, -151, + -151, -151, -151, 58, 58, -151, -151, -151, -151, -151, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 173, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -151 }, { - 9, -152, -152, -152, -152, -152, -152, 57, -152, -152, - -152, -152, -152, 61, 61, 61, -152, -152, -152, -152, - -152, 61, 61, 61, 178, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -152 + 9, -152, -152, -152, -152, -152, -152, 55, -152, -152, + -152, -152, -152, 58, 58, -152, -152, -152, -152, -152, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -152 }, { - 9, -153, -153, -153, -153, -153, -153, 57, -153, -153, - -153, -153, -153, 61, 61, 61, -153, -153, -153, -153, - -153, 61, 61, 61, 61, 61, 179, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -153 + 9, -153, -153, -153, -153, -153, -153, 55, -153, -153, + -153, -153, -153, 58, 58, -153, -153, -153, -153, -153, + 58, 58, 58, 58, 58, 174, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -153 }, { - 9, -154, -154, -154, -154, -154, -154, 57, -154, -154, - -154, -154, -154, 61, 61, 61, -154, -154, -154, -154, - -154, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 180, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -154 + 9, -154, -154, -154, -154, -154, -154, 55, -154, -154, + -154, -154, -154, 58, 58, -154, -154, -154, -154, -154, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 175, 58, 58, 58, 58, 58, 58, + 58, 58, -154 }, { - 9, -155, -155, -155, -155, -155, -155, 57, -155, -155, - -155, -155, -155, 61, 61, 61, -155, -155, -155, -155, - -155, 61, 61, 61, 61, 61, 61, 61, 181, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -155 + 9, -155, -155, -155, -155, -155, -155, 55, -155, -155, + -155, -155, -155, 58, 58, -155, -155, -155, -155, -155, + 58, 58, 58, 58, 58, 176, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -155 }, { - 9, -156, -156, -156, -156, -156, -156, 57, -156, -156, - -156, -156, -156, 61, 61, 61, -156, -156, -156, -156, - -156, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 182, 61, 61, 61, 61, 61, - 61, 61, 61, -156 + 9, -156, -156, -156, -156, -156, -156, 55, -156, -156, + -156, -156, -156, 58, 58, -156, -156, -156, -156, -156, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 177, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -156 }, { - 9, -157, -157, -157, -157, -157, -157, 57, -157, -157, - -157, -157, -157, 61, 61, 61, -157, -157, -157, -157, - -157, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 183, 61, 61, 61, - 61, 61, 61, -157 + 9, -157, -157, -157, -157, -157, -157, 55, -157, -157, + -157, -157, -157, 58, 58, -157, -157, -157, -157, -157, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 178, 58, 58, + 58, 58, -157 }, { - 9, -158, -158, -158, -158, -158, -158, 57, -158, -158, - -158, -158, -158, 61, 61, 61, -158, -158, -158, -158, - -158, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 184, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -158 + 9, -158, -158, -158, -158, -158, -158, 55, -158, -158, + -158, -158, -158, 58, 58, -158, -158, -158, -158, -158, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -158 }, { - 9, -159, -159, -159, -159, -159, -159, 57, -159, -159, - -159, -159, -159, 61, 61, 61, -159, -159, -159, -159, - -159, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 185, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -159 + 9, -159, -159, -159, -159, -159, -159, 55, -159, -159, + -159, -159, -159, 58, 58, -159, -159, -159, -159, -159, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -159 }, { - 9, -160, -160, -160, -160, -160, -160, 57, -160, -160, - -160, -160, -160, 61, 61, 61, -160, -160, -160, -160, - -160, 61, 61, 61, 61, 186, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -160 + 9, -160, -160, -160, -160, -160, -160, 55, -160, -160, + -160, -160, -160, 58, 58, -160, -160, -160, -160, -160, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 179, 58, 58, + 58, 58, -160 }, { - 9, -161, -161, -161, -161, -161, -161, 57, -161, -161, - -161, -161, -161, 61, 61, 61, -161, -161, -161, -161, - -161, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 187, 61, 61, 61, 61, 61, - 61, 61, 61, -161 + 9, -161, -161, -161, -161, -161, -161, 55, -161, -161, + -161, -161, -161, 58, 58, -161, -161, -161, -161, -161, + 58, 58, 58, 58, 58, 180, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -161 }, { - 9, -162, -162, -162, -162, -162, -162, 57, -162, -162, - -162, -162, -162, 61, 61, 61, -162, -162, -162, -162, - -162, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -162 + 9, -162, -162, -162, -162, -162, -162, 55, -162, -162, + -162, -162, -162, 58, 58, -162, -162, -162, -162, -162, + 58, 58, 58, 58, 58, 58, 58, 181, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -162 }, { - 9, -163, -163, -163, -163, -163, -163, 57, -163, -163, - -163, -163, -163, 61, 61, 61, -163, -163, -163, -163, - -163, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 188, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -163 + 9, -163, -163, -163, -163, -163, -163, 55, -163, -163, + -163, -163, -163, 58, 58, -163, -163, -163, -163, -163, + 58, 182, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -163 }, { - 9, -164, -164, -164, -164, -164, -164, 57, -164, -164, - -164, -164, -164, 61, 61, 61, -164, -164, -164, -164, - -164, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -164 + 9, -164, -164, -164, -164, -164, -164, 55, -164, -164, + -164, -164, -164, 58, 58, -164, -164, -164, -164, -164, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 183, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -164 }, { - 9, -165, -165, -165, -165, -165, -165, 57, -165, -165, - -165, -165, -165, 61, 61, 61, -165, -165, -165, -165, - -165, 61, 61, 61, 61, 61, 189, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -165 + 9, -165, -165, -165, -165, -165, -165, 55, -165, -165, + -165, -165, -165, 58, 58, -165, -165, -165, -165, -165, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -165 }, { - 9, -166, -166, -166, -166, -166, -166, 57, -166, -166, - -166, -166, -166, 61, 61, 61, -166, -166, -166, -166, - -166, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 190, 61, 61, 61, 61, 61, - 61, 61, 61, -166 + 9, -166, -166, -166, -166, -166, -166, 55, -166, -166, + -166, -166, -166, 58, 58, -166, -166, -166, -166, -166, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 184, 58, 58, + 58, 58, -166 }, { - 9, -167, -167, -167, -167, -167, -167, 57, -167, -167, - -167, -167, -167, 61, 61, 61, -167, -167, -167, -167, - -167, 61, 61, 61, 61, 61, 191, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -167 + 9, -167, -167, -167, -167, -167, -167, 55, -167, -167, + -167, -167, -167, 58, 58, -167, -167, -167, -167, -167, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -167 }, { - 9, -168, -168, -168, -168, -168, -168, 57, -168, -168, - -168, -168, -168, 61, 61, 61, -168, -168, -168, -168, - -168, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 192, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -168 + 9, -168, -168, -168, -168, -168, -168, 55, -168, -168, + -168, -168, -168, 58, 58, -168, -168, -168, -168, -168, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 185, 58, 58, 58, 58, 58, 58, + 58, 58, -168 }, { - 9, -169, -169, -169, -169, -169, -169, 57, -169, -169, - -169, -169, -169, 61, 61, 61, -169, -169, -169, -169, - -169, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 193, 61, - 61, 61, 61, -169 + 9, -169, -169, -169, -169, -169, -169, 55, -169, -169, + -169, -169, -169, 58, 58, -169, -169, -169, -169, -169, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 186, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -169 }, { - 9, -170, -170, -170, -170, -170, -170, 57, -170, -170, - -170, -170, -170, 61, 61, 61, -170, -170, -170, -170, - -170, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -170 + 9, -170, -170, -170, -170, -170, -170, 55, -170, -170, + -170, -170, -170, 58, 58, -170, -170, -170, -170, -170, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 187, 58, 58, + 58, 58, -170 }, { - 9, -171, -171, -171, -171, -171, -171, 57, -171, -171, - -171, -171, -171, 61, 61, 61, -171, -171, -171, -171, - -171, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -171 + 9, -171, -171, -171, -171, -171, -171, 55, -171, -171, + -171, -171, -171, 58, 58, -171, -171, -171, -171, -171, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 188, 58, 58, 58, + 58, 58, -171 }, { - 9, -172, -172, -172, -172, -172, -172, 57, -172, -172, - -172, -172, -172, 61, 61, 61, -172, -172, -172, -172, - -172, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 194, 61, - 61, 61, 61, -172 + 9, -172, -172, -172, -172, -172, -172, 55, -172, -172, + -172, -172, -172, 58, 58, -172, -172, -172, -172, -172, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 189, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -172 }, { - 9, -173, -173, -173, -173, -173, -173, 57, -173, -173, - -173, -173, -173, 61, 61, 61, -173, -173, -173, -173, - -173, 61, 61, 61, 61, 61, 195, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -173 + 9, -173, -173, -173, -173, -173, -173, 55, -173, -173, + -173, -173, -173, 58, 58, -173, -173, -173, -173, -173, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 190, 58, + 58, 58, -173 }, { - 9, -174, -174, -174, -174, -174, -174, 57, -174, -174, - -174, -174, -174, 61, 61, 61, -174, -174, -174, -174, - -174, 61, 61, 61, 61, 61, 61, 61, 196, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -174 + 9, -174, -174, -174, -174, -174, -174, 55, -174, -174, + -174, -174, -174, 58, 58, -174, -174, -174, -174, -174, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 191, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -174 }, { - 9, -175, -175, -175, -175, -175, -175, 57, -175, -175, - -175, -175, -175, 61, 61, 61, -175, -175, -175, -175, - -175, 61, 197, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -175 + 9, -175, -175, -175, -175, -175, -175, 55, -175, -175, + -175, -175, -175, 58, 58, -175, -175, -175, -175, -175, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 192, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -175 }, { - 9, -176, -176, -176, -176, -176, -176, 57, -176, -176, - -176, -176, -176, 61, 61, 61, -176, -176, -176, -176, - -176, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 198, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -176 + 9, -176, -176, -176, -176, -176, -176, 55, -176, -176, + -176, -176, -176, 58, 58, -176, -176, -176, -176, -176, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 193, 58, 58, 58, + 58, 58, -176 }, { - 9, -177, -177, -177, -177, -177, -177, 57, -177, -177, - -177, -177, -177, 61, 61, 61, -177, -177, -177, -177, - -177, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 199, 61, 61, 61, 61, - 61, 61, 61, -177 + 9, -177, -177, -177, -177, -177, -177, 55, -177, -177, + -177, -177, -177, 58, 58, -177, -177, -177, -177, -177, + 58, 194, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -177 }, { - 9, -178, -178, -178, -178, -178, -178, 57, -178, -178, - -178, -178, -178, 61, 61, 61, -178, -178, -178, -178, - -178, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 200, 61, 61, 61, 61, 61, - 61, 61, 61, -178 + 9, -178, -178, -178, -178, -178, -178, 55, -178, -178, + -178, -178, -178, 58, 58, -178, -178, -178, -178, -178, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -178 }, { - 9, -179, -179, -179, -179, -179, -179, 57, -179, -179, - -179, -179, -179, 61, 61, 61, -179, -179, -179, -179, - -179, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -179 + 9, -179, -179, -179, -179, -179, -179, 55, -179, -179, + -179, -179, -179, 58, 58, -179, -179, -179, -179, -179, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -179 }, { - 9, -180, -180, -180, -180, -180, -180, 57, -180, -180, - -180, -180, -180, 61, 61, 61, -180, -180, -180, -180, - -180, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 201, 61, - 61, 61, 61, -180 + 9, -180, -180, -180, -180, -180, -180, 55, -180, -180, + -180, -180, -180, 58, 58, -180, -180, -180, -180, -180, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -180 }, { - 9, -181, -181, -181, -181, -181, -181, 57, -181, -181, - -181, -181, -181, 61, 61, 61, -181, -181, -181, -181, - -181, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -181 + 9, -181, -181, -181, -181, -181, -181, 55, -181, -181, + -181, -181, -181, 58, 58, -181, -181, -181, -181, -181, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -181 }, { - 9, -182, -182, -182, -182, -182, -182, 57, -182, -182, - -182, -182, -182, 61, 61, 61, -182, -182, -182, -182, - -182, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 202, 61, 61, 61, 61, 61, - 61, 61, 61, -182 + 9, -182, -182, -182, -182, -182, -182, 55, -182, -182, + -182, -182, -182, 58, 58, -182, -182, -182, -182, -182, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 195, 58, 58, + 58, 58, -182 }, { - 9, -183, -183, -183, -183, -183, -183, 57, -183, -183, - -183, -183, -183, 61, 61, 61, -183, -183, -183, -183, - -183, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 203, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -183 + 9, -183, -183, -183, -183, -183, -183, 55, -183, -183, + -183, -183, -183, 58, 58, -183, -183, -183, -183, -183, + 58, 58, 58, 58, 58, 196, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -183 }, { - 9, -184, -184, -184, -184, -184, -184, 57, -184, -184, - -184, -184, -184, 61, 61, 61, -184, -184, -184, -184, - -184, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 204, 61, - 61, 61, 61, -184 + 9, -184, -184, -184, -184, -184, -184, 55, -184, -184, + -184, -184, -184, 58, 58, -184, -184, -184, -184, -184, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -184 }, { - 9, -185, -185, -185, -185, -185, -185, 57, -185, -185, - -185, -185, -185, 61, 61, 61, -185, -185, -185, -185, - -185, 61, 61, 61, 61, 61, 61, 205, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -185 + 9, -185, -185, -185, -185, -185, -185, 55, -185, -185, + -185, -185, -185, 58, 58, -185, -185, -185, -185, -185, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 197, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -185 }, { - 9, -186, -186, -186, -186, -186, -186, 57, -186, -186, - -186, -186, -186, 61, 61, 61, -186, -186, -186, -186, - -186, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 206, 61, 61, - 61, 61, 61, -186 + 9, -186, -186, -186, -186, -186, -186, 55, -186, -186, + -186, -186, -186, 58, 58, -186, -186, -186, -186, -186, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 198, 58, 58, 58, + 58, 58, -186 }, { - 9, -187, -187, -187, -187, -187, -187, 57, -187, -187, - -187, -187, -187, 61, 61, 61, -187, -187, -187, -187, - -187, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 207, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -187 + 9, -187, -187, -187, -187, -187, -187, 55, -187, -187, + -187, -187, -187, 58, 58, -187, -187, -187, -187, -187, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -187 }, { - 9, -188, -188, -188, -188, -188, -188, 57, -188, -188, - -188, -188, -188, 61, 61, 61, -188, -188, -188, -188, - -188, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 208, - 61, 61, 61, -188 + 9, -188, -188, -188, -188, -188, -188, 55, -188, -188, + -188, -188, -188, 58, 58, -188, -188, -188, -188, -188, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -188 }, { - 9, -189, -189, -189, -189, -189, -189, 57, -189, -189, - -189, -189, -189, 61, 61, 61, -189, -189, -189, -189, - -189, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 209, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -189 + 9, -189, -189, -189, -189, -189, -189, 55, -189, -189, + -189, -189, -189, 58, 58, -189, -189, -189, -189, -189, + 58, 58, 58, 199, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -189 }, { - 9, -190, -190, -190, -190, -190, -190, 57, -190, -190, - -190, -190, -190, 61, 61, 61, -190, -190, -190, -190, - -190, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 210, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -190 + 9, -190, -190, -190, -190, -190, -190, 55, -190, -190, + -190, -190, -190, 58, 58, -190, -190, -190, -190, -190, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -190 }, { - 9, -191, -191, -191, -191, -191, -191, 57, -191, -191, - -191, -191, -191, 61, 61, 61, -191, -191, -191, -191, - -191, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 211, 61, 61, - 61, 61, 61, -191 + 9, -191, -191, -191, -191, -191, -191, 55, -191, -191, + -191, -191, -191, 58, 58, -191, -191, -191, -191, -191, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 200, 58, + 58, 58, -191 }, { - 9, -192, -192, -192, -192, -192, -192, 57, -192, -192, - -192, -192, -192, 61, 61, 61, -192, -192, -192, -192, - -192, 61, 212, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -192 + 9, -192, -192, -192, -192, -192, -192, 55, -192, -192, + -192, -192, -192, 58, 58, -192, -192, -192, -192, -192, + 58, 58, 58, 58, 58, 58, 201, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -192 }, { - 9, -193, -193, -193, -193, -193, -193, 57, -193, -193, - -193, -193, -193, 61, 61, 61, -193, -193, -193, -193, - -193, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -193 + 9, -193, -193, -193, -193, -193, -193, 55, -193, -193, + -193, -193, -193, 58, 58, -193, -193, -193, -193, -193, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -193 }, { - 9, -194, -194, -194, -194, -194, -194, 57, -194, -194, - -194, -194, -194, 61, 61, 61, -194, -194, -194, -194, - -194, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -194 + 9, -194, -194, -194, -194, -194, -194, 55, -194, -194, + -194, -194, -194, 58, 58, -194, -194, -194, -194, -194, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 202, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -194 }, { - 9, -195, -195, -195, -195, -195, -195, 57, -195, -195, - -195, -195, -195, 61, 61, 61, -195, -195, -195, -195, - -195, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -195 + 9, -195, -195, -195, -195, -195, -195, 55, -195, -195, + -195, -195, -195, 58, 58, -195, -195, -195, -195, -195, + 58, 58, 58, 58, 58, 203, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -195 }, { - 9, -196, -196, -196, -196, -196, -196, 57, -196, -196, - -196, -196, -196, 61, 61, 61, -196, -196, -196, -196, - -196, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -196 + 9, -196, -196, -196, -196, -196, -196, 55, -196, -196, + -196, -196, -196, 58, 58, -196, -196, -196, -196, -196, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -196 }, { - 9, -197, -197, -197, -197, -197, -197, 57, -197, -197, - -197, -197, -197, 61, 61, 61, -197, -197, -197, -197, - -197, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 213, 61, - 61, 61, 61, -197 + 9, -197, -197, -197, -197, -197, -197, 55, -197, -197, + -197, -197, -197, 58, 58, -197, -197, -197, -197, -197, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -197 }, { - 9, -198, -198, -198, -198, -198, -198, 57, -198, -198, - -198, -198, -198, 61, 61, 61, -198, -198, -198, -198, - -198, 61, 61, 61, 61, 61, 214, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -198 + 9, -198, -198, -198, -198, -198, -198, 55, -198, -198, + -198, -198, -198, 58, 58, -198, -198, -198, -198, -198, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 204, 58, 58, + 58, 58, -198 }, { - 9, -199, -199, -199, -199, -199, -199, 57, -199, -199, - -199, -199, -199, 215, 61, 61, -199, -199, -199, -199, - -199, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -199 + 9, -199, -199, -199, -199, -199, -199, 55, -199, -199, + -199, -199, -199, 58, 58, -199, -199, -199, -199, -199, + 58, 58, 58, 58, 58, 205, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -199 }, { - 9, -200, -200, -200, -200, -200, -200, 57, -200, -200, - -200, -200, -200, 61, 61, 61, -200, -200, -200, -200, - -200, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 216, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -200 + 9, -200, -200, -200, -200, -200, -200, 55, -200, -200, + -200, -200, -200, 58, 58, -200, -200, -200, -200, -200, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -200 }, { - 9, -201, -201, -201, -201, -201, -201, 57, -201, -201, - -201, -201, -201, 61, 61, 61, -201, -201, -201, -201, - -201, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -201 + 9, -201, -201, -201, -201, -201, -201, 55, -201, -201, + -201, -201, -201, 58, 58, -201, -201, -201, -201, -201, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 206, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -201 }, { - 9, -202, -202, -202, -202, -202, -202, 57, -202, -202, - -202, -202, -202, 61, 61, 61, -202, -202, -202, -202, - -202, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 217, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -202 + 9, -202, -202, -202, -202, -202, -202, 55, -202, -202, + -202, -202, -202, 58, 58, -202, -202, -202, -202, -202, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -202 }, { - 9, -203, -203, -203, -203, -203, -203, 57, -203, -203, - -203, -203, -203, 61, 61, 61, -203, -203, -203, -203, - -203, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 218, 61, 61, - 61, 61, 61, -203 + 9, -203, -203, -203, -203, -203, -203, 55, -203, -203, + -203, -203, -203, 58, 58, -203, -203, -203, -203, -203, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -203 }, { - 9, -204, -204, -204, -204, -204, -204, 57, -204, -204, - -204, -204, -204, 61, 61, 61, -204, -204, -204, -204, - -204, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -204 + 9, -204, -204, -204, -204, -204, -204, 55, -204, -204, + -204, -204, -204, 58, 58, -204, -204, -204, -204, -204, + 58, 207, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -204 }, { - 9, -205, -205, -205, -205, -205, -205, 57, -205, -205, - -205, -205, -205, 61, 61, 61, -205, -205, -205, -205, - -205, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 219, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -205 + 9, -205, -205, -205, -205, -205, -205, 55, -205, -205, + -205, -205, -205, 58, 58, -205, -205, -205, -205, -205, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -205 }, { - 9, -206, -206, -206, -206, -206, -206, 57, -206, -206, - -206, -206, -206, 61, 61, 61, -206, -206, -206, -206, - -206, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -206 + 9, -206, -206, -206, -206, -206, -206, 55, -206, -206, + -206, -206, -206, 58, 58, -206, -206, -206, -206, -206, + 58, 58, 58, 58, 58, 58, 58, 208, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -206 }, { - 9, -207, -207, -207, -207, -207, -207, 57, -207, -207, - -207, -207, -207, 61, 61, 61, -207, -207, -207, -207, - -207, 61, 61, 61, 220, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -207 + 9, -207, -207, -207, -207, -207, -207, 55, -207, -207, + -207, -207, -207, 58, 58, -207, -207, -207, -207, -207, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 209, 58, 58, + 58, 58, -207 }, { - 9, -208, -208, -208, -208, -208, -208, 57, -208, -208, - -208, -208, -208, 61, 61, 61, -208, -208, -208, -208, - -208, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -208 + 9, -208, -208, -208, -208, -208, -208, 55, -208, -208, + -208, -208, -208, 58, 58, -208, -208, -208, -208, -208, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -208 }, { - 9, -209, -209, -209, -209, -209, -209, 57, -209, -209, - -209, -209, -209, 61, 61, 61, -209, -209, -209, -209, - -209, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 221, - 61, 61, 61, -209 + 9, -209, -209, -209, -209, -209, -209, 55, -209, -209, + -209, -209, -209, 58, 58, -209, -209, -209, -209, -209, + 58, 58, 58, 58, 58, 210, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -209 }, { - 9, -210, -210, -210, -210, -210, -210, 57, -210, -210, - -210, -210, -210, 61, 61, 61, -210, -210, -210, -210, - -210, 61, 61, 61, 61, 61, 61, 222, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -210 - }, - - { - 9, -211, -211, -211, -211, -211, -211, 57, -211, -211, - -211, -211, -211, 61, 61, 61, -211, -211, -211, -211, - -211, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -211 - - }, - - { - 9, -212, -212, -212, -212, -212, -212, 57, -212, -212, - -212, -212, -212, 61, 61, 61, -212, -212, -212, -212, - -212, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 223, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -212 - }, - - { - 9, -213, -213, -213, -213, -213, -213, 57, -213, -213, - -213, -213, -213, 61, 61, 61, -213, -213, -213, -213, - -213, 61, 61, 61, 61, 61, 224, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -213 - - }, - - { - 9, -214, -214, -214, -214, -214, -214, 57, -214, -214, - -214, -214, -214, 61, 61, 61, -214, -214, -214, -214, - -214, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -214 - }, - - { - 9, -215, -215, -215, -215, -215, -215, 57, -215, -215, - -215, -215, -215, 225, 61, 61, -215, -215, -215, -215, - -215, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -215 - - }, - - { - 9, -216, -216, -216, -216, -216, -216, 57, -216, -216, - -216, -216, -216, 61, 61, 61, -216, -216, -216, -216, - -216, 61, 61, 61, 61, 61, 61, 226, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -216 - }, - - { - 9, -217, -217, -217, -217, -217, -217, 57, -217, -217, - -217, -217, -217, 61, 61, 61, -217, -217, -217, -217, - -217, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -217 - - }, - - { - 9, -218, -218, -218, -218, -218, -218, 57, -218, -218, - -218, -218, -218, 61, 61, 61, -218, -218, -218, -218, - -218, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 227, 61, - 61, 61, 61, -218 - }, - - { - 9, -219, -219, -219, -219, -219, -219, 57, -219, -219, - -219, -219, -219, 61, 61, 61, -219, -219, -219, -219, - -219, 61, 61, 61, 61, 61, 61, 61, 228, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -219 - - }, - - { - 9, -220, -220, -220, -220, -220, -220, 57, -220, -220, - -220, -220, -220, 61, 61, 61, -220, -220, -220, -220, - -220, 61, 61, 61, 61, 61, 229, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -220 - }, - - { - 9, -221, -221, -221, -221, -221, -221, 57, -221, -221, - -221, -221, -221, 61, 61, 61, -221, -221, -221, -221, - -221, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -221 - - }, - - { - 9, -222, -222, -222, -222, -222, -222, 57, -222, -222, - -222, -222, -222, 61, 61, 61, -222, -222, -222, -222, - -222, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 230, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -222 - }, - - { - 9, -223, -223, -223, -223, -223, -223, 57, -223, -223, - -223, -223, -223, 61, 61, 61, -223, -223, -223, -223, - -223, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -223 - - }, - - { - 9, -224, -224, -224, -224, -224, -224, 57, -224, -224, - -224, -224, -224, 61, 61, 61, -224, -224, -224, -224, - -224, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -224 - }, - - { - 9, -225, -225, -225, -225, -225, -225, 57, -225, -225, - -225, -225, -225, 137, 61, 61, -225, -225, -225, -225, - -225, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -225 - - }, - - { - 9, -226, -226, -226, -226, -226, -226, 57, -226, -226, - -226, -226, -226, 61, 61, 61, -226, -226, -226, -226, - -226, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 231, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -226 - }, - - { - 9, -227, -227, -227, -227, -227, -227, 57, -227, -227, - -227, -227, -227, 61, 61, 61, -227, -227, -227, -227, - -227, 61, 232, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -227 - - }, - - { - 9, -228, -228, -228, -228, -228, -228, 57, -228, -228, - -228, -228, -228, 61, 61, 61, -228, -228, -228, -228, - -228, 233, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -228 - }, - - { - 9, -229, -229, -229, -229, -229, -229, 57, -229, -229, - -229, -229, -229, 61, 61, 61, -229, -229, -229, -229, - -229, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -229 - - }, - - { - 9, -230, -230, -230, -230, -230, -230, 57, -230, -230, - -230, -230, -230, 61, 61, 61, -230, -230, -230, -230, - -230, 61, 61, 61, 61, 61, 61, 61, 234, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -230 - }, - - { - 9, -231, -231, -231, -231, -231, -231, 57, -231, -231, - -231, -231, -231, 61, 61, 61, -231, -231, -231, -231, - -231, 61, 61, 61, 61, 61, 61, 61, 235, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -231 - - }, - - { - 9, -232, -232, -232, -232, -232, -232, 57, -232, -232, - -232, -232, -232, 61, 61, 61, -232, -232, -232, -232, - -232, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 236, 61, - 61, 61, 61, -232 - }, - - { - 9, -233, -233, -233, -233, -233, -233, 57, -233, -233, - -233, -233, -233, 61, 61, 61, -233, -233, -233, -233, - -233, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 237, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -233 - - }, - - { - 9, -234, -234, -234, -234, -234, -234, 57, -234, -234, - -234, -234, -234, 61, 61, 61, -234, -234, -234, -234, - -234, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -234 - }, - - { - 9, -235, -235, -235, -235, -235, -235, 57, -235, -235, - -235, -235, -235, 61, 61, 61, -235, -235, -235, -235, - -235, 238, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -235 - - }, - - { - 9, -236, -236, -236, -236, -236, -236, 57, -236, -236, - -236, -236, -236, 61, 61, 61, -236, -236, -236, -236, - -236, 61, 61, 61, 61, 61, 239, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -236 - }, - - { - 9, -237, -237, -237, -237, -237, -237, 57, -237, -237, - -237, -237, -237, 61, 61, 61, -237, -237, -237, -237, - -237, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 240, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -237 - - }, - - { - 9, -238, -238, -238, -238, -238, -238, 57, -238, -238, - -238, -238, -238, 61, 61, 61, -238, -238, -238, -238, - -238, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 241, -238 - }, - - { - 9, -239, -239, -239, -239, -239, -239, 57, -239, -239, - -239, -239, -239, 61, 61, 61, -239, -239, -239, -239, - -239, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -239 - - }, - - { - 9, -240, -240, -240, -240, -240, -240, 57, -240, -240, - -240, -240, -240, 61, 61, 61, -240, -240, -240, -240, - -240, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 242, 61, 61, - 61, 61, 61, -240 - }, - - { - 9, -241, -241, -241, -241, -241, -241, 57, -241, -241, - -241, -241, -241, 61, 61, 61, -241, -241, -241, -241, - -241, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -241 - - }, - - { - 9, -242, -242, -242, -242, -242, -242, 57, -242, -242, - -242, -242, -242, 61, 61, 61, -242, -242, -242, -242, - -242, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 243, 61, - 61, 61, 61, -242 - }, - - { - 9, -243, -243, -243, -243, -243, -243, 57, -243, -243, - -243, -243, -243, 61, 61, 61, -243, -243, -243, -243, - -243, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, -243 - + 9, -210, -210, -210, -210, -210, -210, 55, -210, -210, + -210, -210, -210, 58, 58, -210, -210, -210, -210, -210, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, -210 }, } ; @@ -2449,8 +2168,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 67 -#define YY_END_OF_BUFFER 68 +#define YY_NUM_RULES 64 +#define YY_END_OF_BUFFER 65 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -2458,35 +2177,31 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[244] = +static const flex_int16_t yy_accept[211] = { 0, - 2, 2, 0, 0, 0, 0, 0, 0, 68, 54, - 2, 4, 46, 51, 1, 53, 54, 47, 48, 54, - 52, 52, 54, 42, 40, 44, 54, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 54, 55, 57, 56, 66, 63, 65, 59, 62, - 61, 58, 60, 2, 41, 1, 53, 39, 50, 52, - 52, 49, 43, 45, 3, 52, 52, 52, 52, 52, - 52, 52, 20, 52, 52, 52, 52, 52, 27, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 38, 55, - 55, 66, 63, 65, 64, 59, 58, 60, 52, 52, + 2, 2, 0, 0, 0, 0, 0, 0, 65, 51, + 2, 4, 43, 48, 1, 50, 51, 44, 45, 51, + 49, 51, 39, 37, 41, 51, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 51, + 52, 54, 53, 63, 60, 62, 56, 59, 58, 55, + 57, 2, 38, 1, 50, 36, 47, 49, 46, 40, + 42, 3, 49, 49, 49, 49, 49, 49, 18, 49, + 49, 49, 49, 49, 25, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 35, 52, 52, 63, 60, 62, + 61, 56, 55, 57, 49, 49, 49, 49, 49, 49, - 52, 52, 52, 52, 52, 52, 52, 52, 19, 52, - 22, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 6, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 18, 52, 52, 24, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 16, 52, 21, 52, 52, 52, 52, 52, 31, - 32, 52, 52, 52, 52, 52, 52, 52, 7, 52, - 9, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 28, 30, 33, 34, 35, 52, 52, 52, 52, + 49, 49, 17, 49, 20, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 5, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 16, 49, 49, + 22, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 14, + 49, 19, 49, 49, 49, 49, 49, 28, 29, 49, + 49, 49, 49, 49, 6, 49, 8, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 27, 30, 31, + 32, 49, 49, 7, 49, 49, 11, 12, 49, 15, + 49, 49, 24, 49, 49, 34, 9, 49, 49, 21, - 8, 52, 52, 12, 52, 14, 52, 17, 52, 52, - 26, 52, 52, 37, 52, 52, 10, 52, 52, 52, - 23, 52, 29, 36, 52, 52, 52, 52, 15, 52, - 52, 52, 52, 25, 52, 52, 52, 52, 11, 52, - 5, 52, 13 + 49, 26, 33, 49, 13, 49, 49, 23, 49, 10 } ; static const YY_CHAR yy_ec[256] = @@ -2495,16 +2210,16 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 5, 6, 7, 1, 8, 9, 10, - 11, 1, 12, 1, 13, 14, 14, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 16, 1, 17, - 18, 19, 1, 1, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 1, 20, 1, 1, 21, 1, 22, 23, 24, 25, + 11, 1, 12, 1, 13, 14, 14, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 15, 1, 16, + 17, 18, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 1, 19, 1, 1, 20, 1, 21, 22, 23, 24, - 26, 27, 28, 29, 30, 15, 15, 31, 32, 33, - 34, 35, 15, 36, 37, 38, 39, 40, 15, 41, - 42, 15, 1, 43, 1, 1, 1, 1, 1, 1, + 25, 26, 27, 28, 29, 13, 13, 30, 31, 32, + 33, 34, 13, 35, 36, 37, 38, 39, 13, 40, + 41, 13, 1, 42, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -2522,12 +2237,12 @@ static const YY_CHAR yy_ec[256] = } ; /* Table of booleans, true if rule could match eol. */ -static const flex_int32_t yy_rule_can_match_eol[68] = +static const flex_int32_t yy_rule_can_match_eol[65] = { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 1, 0, 1, 1, 0, 0, }; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, + 0, 1, 1, 0, 0, }; extern int yy_flex_debug; int yy_flex_debug = 0; @@ -2550,7 +2265,6 @@ char *yytext; #include #include #include -#include #include #include @@ -2576,7 +2290,7 @@ struct buffer { YY_BUFFER_STATE state; }; -struct buffer *current_buf; +static struct buffer *current_buf; static int last_ts, first_ts; @@ -2885,189 +2599,177 @@ return T_EOL; YY_BREAK case 5: YY_RULE_SETUP -return T_ALLNOCONFIG_Y; +return T_BOOL; YY_BREAK case 6: YY_RULE_SETUP -return T_BOOL; +return T_CHOICE; YY_BREAK case 7: YY_RULE_SETUP -return T_CHOICE; +return T_COMMENT; YY_BREAK case 8: YY_RULE_SETUP -return T_COMMENT; +return T_CONFIG; YY_BREAK case 9: YY_RULE_SETUP -return T_CONFIG; +return T_DEF_BOOL; YY_BREAK case 10: YY_RULE_SETUP -return T_DEF_BOOL; +return T_DEF_TRISTATE; YY_BREAK case 11: YY_RULE_SETUP -return T_DEF_TRISTATE; +return T_DEFAULT; YY_BREAK case 12: YY_RULE_SETUP -return T_DEFAULT; +return T_DEPENDS; YY_BREAK case 13: YY_RULE_SETUP -return T_DEFCONFIG_LIST; +return T_ENDCHOICE; YY_BREAK case 14: YY_RULE_SETUP -return T_DEPENDS; +return T_ENDIF; YY_BREAK case 15: YY_RULE_SETUP -return T_ENDCHOICE; +return T_ENDMENU; YY_BREAK case 16: YY_RULE_SETUP -return T_ENDIF; +return T_HELP; YY_BREAK case 17: YY_RULE_SETUP -return T_ENDMENU; +return T_HEX; YY_BREAK case 18: YY_RULE_SETUP -return T_HELP; +return T_IF; YY_BREAK case 19: YY_RULE_SETUP -return T_HEX; +return T_IMPLY; YY_BREAK case 20: YY_RULE_SETUP -return T_IF; +return T_INT; YY_BREAK case 21: YY_RULE_SETUP -return T_IMPLY; +return T_MAINMENU; YY_BREAK case 22: YY_RULE_SETUP -return T_INT; +return T_MENU; YY_BREAK case 23: YY_RULE_SETUP -return T_MAINMENU; +return T_MENUCONFIG; YY_BREAK case 24: YY_RULE_SETUP -return T_MENU; +return T_MODULES; YY_BREAK case 25: YY_RULE_SETUP -return T_MENUCONFIG; +return T_ON; YY_BREAK case 26: YY_RULE_SETUP -return T_MODULES; +return T_OPTIONAL; YY_BREAK case 27: YY_RULE_SETUP -return T_ON; +return T_PROMPT; YY_BREAK case 28: YY_RULE_SETUP -return T_OPTION; +return T_RANGE; YY_BREAK case 29: YY_RULE_SETUP -return T_OPTIONAL; +return T_RESET; YY_BREAK case 30: YY_RULE_SETUP -return T_PROMPT; +return T_SELECT; YY_BREAK case 31: YY_RULE_SETUP -return T_RANGE; +return T_SOURCE; YY_BREAK case 32: YY_RULE_SETUP -return T_RESET; +return T_STRING; YY_BREAK case 33: YY_RULE_SETUP -return T_SELECT; +return T_TRISTATE; YY_BREAK case 34: YY_RULE_SETUP -return T_SOURCE; +return T_VISIBLE; YY_BREAK case 35: YY_RULE_SETUP -return T_STRING; +return T_OR; YY_BREAK case 36: YY_RULE_SETUP -return T_TRISTATE; +return T_AND; YY_BREAK case 37: YY_RULE_SETUP -return T_VISIBLE; +return T_EQUAL; YY_BREAK case 38: YY_RULE_SETUP -return T_OR; +return T_UNEQUAL; YY_BREAK case 39: YY_RULE_SETUP -return T_AND; +return T_LESS; YY_BREAK case 40: YY_RULE_SETUP -return T_EQUAL; +return T_LESS_EQUAL; YY_BREAK case 41: YY_RULE_SETUP -return T_UNEQUAL; +return T_GREATER; YY_BREAK case 42: YY_RULE_SETUP -return T_LESS; +return T_GREATER_EQUAL; YY_BREAK case 43: YY_RULE_SETUP -return T_LESS_EQUAL; +return T_NOT; YY_BREAK case 44: YY_RULE_SETUP -return T_GREATER; +return T_OPEN_PAREN; YY_BREAK case 45: YY_RULE_SETUP -return T_GREATER_EQUAL; +return T_CLOSE_PAREN; YY_BREAK case 46: YY_RULE_SETUP -return T_NOT; +return T_COLON_EQUAL; YY_BREAK case 47: YY_RULE_SETUP -return T_OPEN_PAREN; - YY_BREAK -case 48: -YY_RULE_SETUP -return T_CLOSE_PAREN; - YY_BREAK -case 49: -YY_RULE_SETUP -return T_COLON_EQUAL; - YY_BREAK -case 50: -YY_RULE_SETUP return T_PLUS_EQUAL; YY_BREAK -case 51: +case 48: YY_RULE_SETUP { str = yytext[0]; @@ -3075,7 +2777,7 @@ YY_RULE_SETUP BEGIN(STRING); } YY_BREAK -case 52: +case 49: YY_RULE_SETUP { alloc_string(yytext, yyleng); @@ -3083,7 +2785,7 @@ YY_RULE_SETUP return T_WORD; } YY_BREAK -case 53: +case 50: YY_RULE_SETUP { /* this token includes at least one '$' */ @@ -3093,12 +2795,12 @@ YY_RULE_SETUP free(yylval.string); } YY_BREAK -case 54: +case 51: YY_RULE_SETUP warn_ignored_character(*yytext); YY_BREAK -case 55: +case 52: YY_RULE_SETUP { alloc_string(yytext, yyleng); @@ -3106,33 +2808,33 @@ YY_RULE_SETUP return T_ASSIGN_VAL; } YY_BREAK -case 56: -/* rule 56 can match eol */ +case 53: +/* rule 53 can match eol */ YY_RULE_SETUP { BEGIN(INITIAL); return T_EOL; } YY_BREAK -case 57: +case 54: YY_RULE_SETUP YY_BREAK -case 58: +case 55: YY_RULE_SETUP append_expanded_string(yytext); YY_BREAK -case 59: +case 56: YY_RULE_SETUP { append_string(yytext, yyleng); } YY_BREAK -case 60: +case 57: YY_RULE_SETUP { append_string(yytext + 1, yyleng - 1); } YY_BREAK -case 61: +case 58: YY_RULE_SETUP { if (str == yytext[0]) { @@ -3143,8 +2845,8 @@ YY_RULE_SETUP append_string(yytext, 1); } YY_BREAK -case 62: -/* rule 62 can match eol */ +case 59: +/* rule 59 can match eol */ YY_RULE_SETUP { fprintf(stderr, @@ -3164,7 +2866,7 @@ case YY_STATE_EOF(STRING): } YY_BREAK -case 63: +case 60: YY_RULE_SETUP { ts = 0; @@ -3189,8 +2891,8 @@ YY_RULE_SETUP } } YY_BREAK -case 64: -/* rule 64 can match eol */ +case 61: +/* rule 61 can match eol */ *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ YY_LINENO_REWIND_TO(yy_cp - 1); (yy_c_buf_p) = yy_cp -= 1; @@ -3201,14 +2903,14 @@ YY_RULE_SETUP return T_HELPTEXT; } YY_BREAK -case 65: -/* rule 65 can match eol */ +case 62: +/* rule 62 can match eol */ YY_RULE_SETUP { append_string("\n", 1); } YY_BREAK -case 66: +case 63: YY_RULE_SETUP { while (yyleng) { @@ -3245,7 +2947,7 @@ case YY_STATE_EOF(ASSIGN_VAL): yyterminate(); } YY_BREAK -case 67: +case 64: YY_RULE_SETUP YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK diff --git a/scripts/config/lkc.h b/scripts/config/lkc.h index 64213b692..a7b18b227 100644 --- a/scripts/config/lkc.h +++ b/scripts/config/lkc.h @@ -6,6 +6,10 @@ #ifndef LKC_H #define LKC_H +#include +#include +#include + #include "expr.h" #ifdef __cplusplus @@ -16,10 +20,6 @@ extern "C" { #define SRCTREE "srctree" -#ifndef PACKAGE -#define PACKAGE "linux" -#endif - #ifndef CONFIG_ #define CONFIG_ "CONFIG_" #endif @@ -30,16 +30,6 @@ static inline const char *CONFIG_prefix(void) #undef CONFIG_ #define CONFIG_ CONFIG_prefix() -enum conf_def_mode { - def_default, - def_yes, - def_mod, - def_y2m, - def_m2y, - def_no, - def_random -}; - extern int yylineno; void zconfdump(FILE *out); void zconf_starthelp(void); @@ -52,10 +42,6 @@ extern int recursive_is_error; /* confdata.c */ const char *conf_get_configname(void); -void sym_set_change_count(int count); -void sym_add_change_count(int count); -bool conf_set_all_new_symbols(enum conf_def_mode mode); -void conf_rewrite_mod_or_yes(enum conf_def_mode mode); void set_all_choice_values(struct symbol *csym); /* confdata.c and expr.c */ @@ -67,24 +53,6 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) fprintf(stderr, "Error in writing or end of file.\n"); } -/* menu.c */ -void _menu_init(void); -void menu_warn(struct menu *menu, const char *fmt, ...); -struct menu *menu_add_menu(void); -void menu_end_menu(void); -void menu_add_entry(struct symbol *sym); -void menu_add_dep(struct expr *dep); -void menu_add_visibility(struct expr *dep); -struct property *menu_add_prop(enum prop_type type, struct expr *expr, struct expr *dep); -struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); -void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); -void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); -void menu_add_option_modules(void); -void menu_add_option_defconfig_list(void); -void menu_add_option_allnoconfig_y(void); -void menu_finalize(struct menu *parent); -void menu_set_type(int type); - /* util.c */ struct file *file_lookup(const char *name); void *xmalloc(size_t size); @@ -111,6 +79,34 @@ void str_append(struct gstr *gs, const char *s); void str_printf(struct gstr *gs, const char *fmt, ...); const char *str_get(struct gstr *gs); +/* menu.c */ +void _menu_init(void); +void menu_warn(struct menu *menu, const char *fmt, ...); +struct menu *menu_add_menu(void); +void menu_end_menu(void); +void menu_add_entry(struct symbol *sym); +void menu_add_dep(struct expr *dep); +void menu_add_visibility(struct expr *dep); +struct property *menu_add_prop(enum prop_type type, struct expr *expr, struct expr *dep); +struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); +void menu_finalize(struct menu *parent); +void menu_set_type(int type); + +extern struct menu rootmenu; + +bool menu_is_empty(struct menu *menu); +bool menu_is_visible(struct menu *menu); +bool menu_has_prompt(struct menu *menu); +const char *menu_get_prompt(struct menu *menu); +struct menu *menu_get_root_menu(struct menu *menu); +struct menu *menu_get_parent_menu(struct menu *menu); +bool menu_has_help(struct menu *menu); +const char *menu_get_help(struct menu *menu); +struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); +void menu_get_ext_help(struct menu *menu, struct gstr *help); + /* symbol.c */ void sym_clear_all_valid(void); struct symbol *sym_choice_default(struct symbol *sym); diff --git a/scripts/config/lkc_proto.h b/scripts/config/lkc_proto.h index 386b10f98..ebedd230b 100644 --- a/scripts/config/lkc_proto.h +++ b/scripts/config/lkc_proto.h @@ -9,24 +9,11 @@ void conf_reset(int def); int conf_write_defconfig(const char *name); int conf_write(const char *name); int conf_write_autoconf(int overwrite); +void conf_set_changed(bool val); bool conf_get_changed(void); void conf_set_changed_callback(void (*fn)(void)); void conf_set_message_callback(void (*fn)(const char *s)); -/* menu.c */ -extern struct menu rootmenu; - -bool menu_is_empty(struct menu *menu); -bool menu_is_visible(struct menu *menu); -bool menu_has_prompt(struct menu *menu); -const char * menu_get_prompt(struct menu *menu); -struct menu * menu_get_root_menu(struct menu *menu); -struct menu * menu_get_parent_menu(struct menu *menu); -bool menu_has_help(struct menu *menu); -const char * menu_get_help(struct menu *menu); -struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); -void menu_get_ext_help(struct menu *menu, struct gstr *help); - /* symbol.c */ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; diff --git a/scripts/config/lxdialog/util.c b/scripts/config/lxdialog/util.c index 0de2b0535..f2bfc5cfe 100644 --- a/scripts/config/lxdialog/util.c +++ b/scripts/config/lxdialog/util.c @@ -363,7 +363,7 @@ void print_title(WINDOW *dialog, const char *title, int width) /* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline - * characters '\n' are propperly processed. We start on a new line + * characters '\n' are properly processed. We start on a new line * if there is no room for at least 4 nonblanks following a double-space. */ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) @@ -541,7 +541,7 @@ int first_alpha(const char *string, const char *exempt) * lxdialog suggest which is correctly translated to two * times esc. But then we need to ignore the second esc to avoid stepping * out one menu too much. Filter away all escaped key sequences since - * keypad(FALSE) turn off ncurses support for escape sequences - and thats + * keypad(FALSE) turn off ncurses support for escape sequences - and that's * needed to make notimeout() do as expected. */ int on_key_esc(WINDOW *win) diff --git a/scripts/config/mconf-cfg.sh b/scripts/config/mconf-cfg.sh index 0244b90b3..357236928 100755 --- a/scripts/config/mconf-cfg.sh +++ b/scripts/config/mconf-cfg.sh @@ -33,7 +33,9 @@ if [ -f /usr/include/ncurses/ncurses.h ]; then exit 0 fi -if [ -f /usr/include/ncurses.h ]; then +# As a final fallback before giving up, check if $HOSTCC knows of a default +# ncurses installation (e.g. from a vendor-specific sysroot). +if echo '#include ' | ${HOSTCC} -E - >/dev/null 2>&1; then echo cflags=\"-D_GNU_SOURCE\" echo libs=\"-lncurses\" exit 0 diff --git a/scripts/config/mconf.c b/scripts/config/mconf.c index 69eb3083c..81d232b66 100644 --- a/scripts/config/mconf.c +++ b/scripts/config/mconf.c @@ -22,6 +22,8 @@ #include "lkc.h" #include "lxdialog/dialog.h" +#define JUMP_NB 9 + static const char mconf_readme[] = "OpenWrt config is based on Kernel kconfig\n" "so ipkg packages are referred here as modules.\n" @@ -300,17 +302,12 @@ static char filename[PATH_MAX+1]; static void set_config_filename(const char *config_filename) { static char menu_backtitle[PATH_MAX+128]; - int size; - size = snprintf(menu_backtitle, sizeof(menu_backtitle), - "%s - %s", config_filename, rootmenu.prompt->text); - if (size >= sizeof(menu_backtitle)) - menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + snprintf(menu_backtitle, sizeof(menu_backtitle), "%s - %s", + config_filename, rootmenu.prompt->text); set_dialog_backtitle(menu_backtitle); - size = snprintf(filename, sizeof(filename), "%s", config_filename); - if (size >= sizeof(filename)) - filename[sizeof(filename)-1] = '\0'; + snprintf(filename, sizeof(filename), "%s", config_filename); } struct subtitle_part { @@ -921,7 +918,7 @@ static void conf_load(void) return; if (!conf_read(dialog_input_result)) { set_config_filename(dialog_input_result); - sym_set_change_count(1); + conf_set_changed(true); return; } show_textbox(NULL, "File does not exist!", 5, 38); diff --git a/scripts/config/menu.c b/scripts/config/menu.c index 9bb5fe158..22fd26a9f 100644 --- a/scripts/config/menu.c +++ b/scripts/config/menu.c @@ -9,6 +9,7 @@ #include #include "lkc.h" +#include "internal.h" static const char nohelp_text[] = "There is no help available for this option."; @@ -65,7 +66,8 @@ void menu_add_entry(struct symbol *sym) struct menu *menu_add_menu(void) { last_entry_ptr = ¤t_entry->list; - return current_menu = current_entry; + current_menu = current_entry; + return current_menu; } void menu_end_menu(void) @@ -210,28 +212,6 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) menu_add_prop(type, expr_alloc_symbol(sym), dep); } -void menu_add_option_modules(void) -{ - if (modules_sym) - zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'", - current_entry->sym->name, modules_sym->name); - modules_sym = current_entry->sym; -} - -void menu_add_option_defconfig_list(void) -{ - if (!sym_defconfig_list) - sym_defconfig_list = current_entry->sym; - else if (sym_defconfig_list != current_entry->sym) - zconf_error("trying to redefine defconfig symbol"); - sym_defconfig_list->flags |= SYMBOL_NO_WRITE; -} - -void menu_add_option_allnoconfig_y(void) -{ - current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; -} - static int menu_validate_number(struct symbol *sym, struct symbol *sym2) { return sym2->type == S_INT || sym2->type == S_HEX || diff --git a/scripts/config/nconf.c b/scripts/config/nconf.c index 66c823449..b75cabe01 100644 --- a/scripts/config/nconf.c +++ b/scripts/config/nconf.c @@ -271,7 +271,7 @@ static int mwin_max_cols; static MENU *curses_menu; static ITEM *curses_menu_items[MAX_MENU_ITEMS]; static struct mitem k_menu_items[MAX_MENU_ITEMS]; -static int items_num; +static unsigned int items_num; static int global_exit; /* the currently selected button */ static const char *current_instructions = menu_instructions; @@ -373,18 +373,18 @@ static void print_function_line(void) int lines = getmaxy(stdscr); for (i = 0; i < function_keys_num; i++) { - (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); + wattrset(main_window, attr_function_highlight); mvwprintw(main_window, lines-3, offset, "%s", function_keys[i].key_str); - (void) wattrset(main_window, attributes[FUNCTION_TEXT]); + wattrset(main_window, attr_function_text); offset += strlen(function_keys[i].key_str); mvwprintw(main_window, lines-3, offset, "%s", function_keys[i].func); offset += strlen(function_keys[i].func) + skip; } - (void) wattrset(main_window, attributes[NORMAL]); + wattrset(main_window, attr_normal); } /* help */ @@ -499,16 +499,20 @@ typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN, /* return the index of the matched item, or -1 if no such item exists */ static int get_mext_match(const char *match_str, match_f flag) { - int match_start = item_index(current_item(curses_menu)); - int index; + int match_start, index; + + /* Do not search if the menu is empty (i.e. items_num == 0) */ + match_start = item_index(current_item(curses_menu)); + if (match_start == ERR) + return -1; if (flag == FIND_NEXT_MATCH_DOWN) ++match_start; else if (flag == FIND_NEXT_MATCH_UP) --match_start; + match_start = (match_start + items_num) % items_num; index = match_start; - index = (index + items_num) % items_num; while (true) { char *str = k_menu_items[index].str; if (strcasestr(str, match_str) != NULL) @@ -630,19 +634,12 @@ static int item_is_tag(char tag) static char filename[PATH_MAX+1]; static char menu_backtitle[PATH_MAX+128]; -static const char *set_config_filename(const char *config_filename) +static void set_config_filename(const char *config_filename) { - int size; + snprintf(menu_backtitle, sizeof(menu_backtitle), "%s - %s", + config_filename, rootmenu.prompt->text); - size = snprintf(menu_backtitle, sizeof(menu_backtitle), - "%s - %s", config_filename, rootmenu.prompt->text); - if (size >= sizeof(menu_backtitle)) - menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; - - size = snprintf(filename, sizeof(filename), "%s", config_filename); - if (size >= sizeof(filename)) - filename[sizeof(filename)-1] = '\0'; - return menu_backtitle; + snprintf(filename, sizeof(filename), "%s", config_filename); } /* return = 0 means we are successful. @@ -758,7 +755,6 @@ static void build_conf(struct menu *menu) switch (ptype) { case P_MENU: child_count++; - prompt = prompt; if (single_menu_mode) { item_make(menu, 'm', "%s%*c%s", @@ -960,16 +956,15 @@ static void show_menu(const char *prompt, const char *instructions, current_instructions = instructions; clear(); - (void) wattrset(main_window, attributes[NORMAL]); - print_in_middle(stdscr, 1, 0, getmaxx(stdscr), + print_in_middle(stdscr, 1, getmaxx(stdscr), menu_backtitle, - attributes[MAIN_HEADING]); + attr_main_heading); - (void) wattrset(main_window, attributes[MAIN_MENU_BOX]); + wattrset(main_window, attr_main_menu_box); box(main_window, 0, 0); - (void) wattrset(main_window, attributes[MAIN_MENU_HEADING]); + wattrset(main_window, attr_main_menu_heading); mvwprintw(main_window, 0, 3, " %s ", prompt); - (void) wattrset(main_window, attributes[NORMAL]); + wattrset(main_window, attr_normal); set_menu_items(curses_menu, curses_menu_items); @@ -1072,7 +1067,6 @@ static int do_match(int key, struct match_state *state, int *ans) static void conf(struct menu *menu) { struct menu *submenu = NULL; - const char *prompt = menu_get_prompt(menu); struct symbol *sym; int res; int current_index = 0; @@ -1090,9 +1084,8 @@ static void conf(struct menu *menu) if (!child_count) break; - show_menu(prompt ? prompt : "Main Menu", - menu_instructions, - current_index, &last_top_row); + show_menu(menu_get_prompt(menu), menu_instructions, + current_index, &last_top_row); keypad((menu_win(curses_menu)), TRUE); while (!global_exit) { if (match_state.in_search) { @@ -1418,7 +1411,7 @@ static void conf_load(void) return; if (!conf_read(dialog_input_result)) { set_config_filename(dialog_input_result); - sym_set_change_count(1); + conf_set_changed(true); return; } btn_dialog(main_window, "File does not exist!", 0); @@ -1537,9 +1530,9 @@ int main(int ac, char **av) menu_opts_on(curses_menu, O_NONCYCLIC); menu_opts_on(curses_menu, O_IGNORECASE); set_menu_mark(curses_menu, " "); - set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]); - set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]); - set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]); + set_menu_fore(curses_menu, attr_main_menu_fore); + set_menu_back(curses_menu, attr_main_menu_back); + set_menu_grey(curses_menu, attr_main_menu_grey); set_config_filename(conf_get_configname()); setup_windows(); diff --git a/scripts/config/nconf.gui.c b/scripts/config/nconf.gui.c index cd7249b31..c72d61a77 100644 --- a/scripts/config/nconf.gui.c +++ b/scripts/config/nconf.gui.c @@ -7,169 +7,120 @@ #include "nconf.h" #include "lkc.h" -/* a list of all the different widgets we use */ -attributes_t attributes[ATTR_MAX+1] = {0}; +int attr_normal; +int attr_main_heading; +int attr_main_menu_box; +int attr_main_menu_fore; +int attr_main_menu_back; +int attr_main_menu_grey; +int attr_main_menu_heading; +int attr_scrollwin_text; +int attr_scrollwin_heading; +int attr_scrollwin_box; +int attr_dialog_text; +int attr_dialog_menu_fore; +int attr_dialog_menu_back; +int attr_dialog_box; +int attr_input_box; +int attr_input_heading; +int attr_input_text; +int attr_input_field; +int attr_function_text; +int attr_function_highlight; -/* available colors: - COLOR_BLACK 0 - COLOR_RED 1 - COLOR_GREEN 2 - COLOR_YELLOW 3 - COLOR_BLUE 4 - COLOR_MAGENTA 5 - COLOR_CYAN 6 - COLOR_WHITE 7 - */ -static void set_normal_colors(void) -{ - init_pair(NORMAL, -1, -1); - init_pair(MAIN_HEADING, COLOR_MAGENTA, -1); +#define COLOR_ATTR(_at, _fg, _bg, _hl) \ + { .attr = &(_at), .has_color = true, .color_fg = _fg, .color_bg = _bg, .highlight = _hl } +#define NO_COLOR_ATTR(_at, _hl) \ + { .attr = &(_at), .has_color = false, .highlight = _hl } +#define COLOR_DEFAULT -1 - /* FORE is for the selected item */ - init_pair(MAIN_MENU_FORE, -1, -1); - /* BACK for all the rest */ - init_pair(MAIN_MENU_BACK, -1, -1); - init_pair(MAIN_MENU_GREY, -1, -1); - init_pair(MAIN_MENU_HEADING, COLOR_GREEN, -1); - init_pair(MAIN_MENU_BOX, COLOR_YELLOW, -1); +struct nconf_attr_param { + int *attr; + bool has_color; + int color_fg; + int color_bg; + int highlight; +}; - init_pair(SCROLLWIN_TEXT, -1, -1); - init_pair(SCROLLWIN_HEADING, COLOR_GREEN, -1); - init_pair(SCROLLWIN_BOX, COLOR_YELLOW, -1); +static const struct nconf_attr_param color_theme_params[] = { + COLOR_ATTR(attr_normal, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_main_heading, COLOR_MAGENTA, COLOR_DEFAULT, A_BOLD | A_UNDERLINE), + COLOR_ATTR(attr_main_menu_box, COLOR_YELLOW, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_main_menu_fore, COLOR_DEFAULT, COLOR_DEFAULT, A_REVERSE), + COLOR_ATTR(attr_main_menu_back, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_main_menu_grey, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_main_menu_heading, COLOR_GREEN, COLOR_DEFAULT, A_BOLD), + COLOR_ATTR(attr_scrollwin_text, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_scrollwin_heading, COLOR_GREEN, COLOR_DEFAULT, A_BOLD), + COLOR_ATTR(attr_scrollwin_box, COLOR_YELLOW, COLOR_DEFAULT, A_BOLD), + COLOR_ATTR(attr_dialog_text, COLOR_DEFAULT, COLOR_DEFAULT, A_BOLD), + COLOR_ATTR(attr_dialog_menu_fore, COLOR_RED, COLOR_DEFAULT, A_STANDOUT), + COLOR_ATTR(attr_dialog_menu_back, COLOR_YELLOW, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_dialog_box, COLOR_YELLOW, COLOR_DEFAULT, A_BOLD), + COLOR_ATTR(attr_input_box, COLOR_YELLOW, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_input_heading, COLOR_GREEN, COLOR_DEFAULT, A_BOLD), + COLOR_ATTR(attr_input_text, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), + COLOR_ATTR(attr_input_field, COLOR_DEFAULT, COLOR_DEFAULT, A_UNDERLINE), + COLOR_ATTR(attr_function_text, COLOR_YELLOW, COLOR_DEFAULT, A_REVERSE), + COLOR_ATTR(attr_function_highlight, COLOR_DEFAULT, COLOR_DEFAULT, A_BOLD), + { /* sentinel */ } +}; - init_pair(DIALOG_TEXT, -1, -1); - init_pair(DIALOG_BOX, COLOR_YELLOW, -1); - init_pair(DIALOG_MENU_BACK, COLOR_YELLOW, -1); - init_pair(DIALOG_MENU_FORE, COLOR_RED, -1); - - init_pair(INPUT_BOX, COLOR_YELLOW, -1); - init_pair(INPUT_HEADING, COLOR_GREEN, -1); - init_pair(INPUT_TEXT, -1, -1); - init_pair(INPUT_FIELD, -1, -1); - - init_pair(FUNCTION_HIGHLIGHT, -1, -1); - init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1); -} - -/* available attributes: - A_NORMAL Normal display (no highlight) - A_STANDOUT Best highlighting mode of the terminal. - A_UNDERLINE Underlining - A_REVERSE Reverse video - A_BLINK Blinking - A_DIM Half bright - A_BOLD Extra bright or bold - A_PROTECT Protected mode - A_INVIS Invisible or blank mode - A_ALTCHARSET Alternate character set - A_CHARTEXT Bit-mask to extract a character - COLOR_PAIR(n) Color-pair number n - */ -static void normal_color_theme(void) -{ - /* automatically add color... */ -#define mkattr(name, attr) do { \ -attributes[name] = attr | COLOR_PAIR(name); } while (0) - mkattr(NORMAL, NORMAL); - mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE); - - mkattr(MAIN_MENU_FORE, A_REVERSE); - mkattr(MAIN_MENU_BACK, A_NORMAL); - mkattr(MAIN_MENU_GREY, A_NORMAL); - mkattr(MAIN_MENU_HEADING, A_BOLD); - mkattr(MAIN_MENU_BOX, A_NORMAL); - - mkattr(SCROLLWIN_TEXT, A_NORMAL); - mkattr(SCROLLWIN_HEADING, A_BOLD); - mkattr(SCROLLWIN_BOX, A_BOLD); - - mkattr(DIALOG_TEXT, A_BOLD); - mkattr(DIALOG_BOX, A_BOLD); - mkattr(DIALOG_MENU_FORE, A_STANDOUT); - mkattr(DIALOG_MENU_BACK, A_NORMAL); - - mkattr(INPUT_BOX, A_NORMAL); - mkattr(INPUT_HEADING, A_BOLD); - mkattr(INPUT_TEXT, A_NORMAL); - mkattr(INPUT_FIELD, A_UNDERLINE); - - mkattr(FUNCTION_HIGHLIGHT, A_BOLD); - mkattr(FUNCTION_TEXT, A_REVERSE); -} - -static void no_colors_theme(void) -{ - /* automatically add highlight, no color */ -#define mkattrn(name, attr) { attributes[name] = attr; } - - mkattrn(NORMAL, NORMAL); - mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE); - - mkattrn(MAIN_MENU_FORE, A_STANDOUT); - mkattrn(MAIN_MENU_BACK, A_NORMAL); - mkattrn(MAIN_MENU_GREY, A_NORMAL); - mkattrn(MAIN_MENU_HEADING, A_BOLD); - mkattrn(MAIN_MENU_BOX, A_NORMAL); - - mkattrn(SCROLLWIN_TEXT, A_NORMAL); - mkattrn(SCROLLWIN_HEADING, A_BOLD); - mkattrn(SCROLLWIN_BOX, A_BOLD); - - mkattrn(DIALOG_TEXT, A_NORMAL); - mkattrn(DIALOG_BOX, A_BOLD); - mkattrn(DIALOG_MENU_FORE, A_STANDOUT); - mkattrn(DIALOG_MENU_BACK, A_NORMAL); - - mkattrn(INPUT_BOX, A_BOLD); - mkattrn(INPUT_HEADING, A_BOLD); - mkattrn(INPUT_TEXT, A_NORMAL); - mkattrn(INPUT_FIELD, A_UNDERLINE); - - mkattrn(FUNCTION_HIGHLIGHT, A_BOLD); - mkattrn(FUNCTION_TEXT, A_REVERSE); -} +static const struct nconf_attr_param no_color_theme_params[] = { + NO_COLOR_ATTR(attr_normal, A_NORMAL), + NO_COLOR_ATTR(attr_main_heading, A_BOLD | A_UNDERLINE), + NO_COLOR_ATTR(attr_main_menu_box, A_NORMAL), + NO_COLOR_ATTR(attr_main_menu_fore, A_STANDOUT), + NO_COLOR_ATTR(attr_main_menu_back, A_NORMAL), + NO_COLOR_ATTR(attr_main_menu_grey, A_NORMAL), + NO_COLOR_ATTR(attr_main_menu_heading, A_BOLD), + NO_COLOR_ATTR(attr_scrollwin_text, A_NORMAL), + NO_COLOR_ATTR(attr_scrollwin_heading, A_BOLD), + NO_COLOR_ATTR(attr_scrollwin_box, A_BOLD), + NO_COLOR_ATTR(attr_dialog_text, A_NORMAL), + NO_COLOR_ATTR(attr_dialog_menu_fore, A_STANDOUT), + NO_COLOR_ATTR(attr_dialog_menu_back, A_NORMAL), + NO_COLOR_ATTR(attr_dialog_box, A_BOLD), + NO_COLOR_ATTR(attr_input_box, A_BOLD), + NO_COLOR_ATTR(attr_input_heading, A_BOLD), + NO_COLOR_ATTR(attr_input_text, A_NORMAL), + NO_COLOR_ATTR(attr_input_field, A_UNDERLINE), + NO_COLOR_ATTR(attr_function_text, A_REVERSE), + NO_COLOR_ATTR(attr_function_highlight, A_BOLD), + { /* sentinel */ } +}; void set_colors(void) { - start_color(); - use_default_colors(); - set_normal_colors(); + const struct nconf_attr_param *p; + int pair = 0; + if (has_colors()) { - normal_color_theme(); + start_color(); + use_default_colors(); + p = color_theme_params; } else { - /* give defaults */ - no_colors_theme(); + p = no_color_theme_params; + } + + for (; p->attr; p++) { + int attr = p->highlight; + + if (p->has_color) { + pair++; + init_pair(pair, p->color_fg, p->color_bg); + attr |= COLOR_PAIR(pair); + } + + *p->attr = attr; } } - /* this changes the windows attributes !!! */ -void print_in_middle(WINDOW *win, - int starty, - int startx, - int width, - const char *string, - chtype color) -{ int length, x, y; - float temp; - - - if (win == NULL) - win = stdscr; - getyx(win, y, x); - if (startx != 0) - x = startx; - if (starty != 0) - y = starty; - if (width == 0) - width = 80; - - length = strlen(string); - temp = (width - length) / 2; - x = startx + (int)temp; - (void) wattrset(win, color); - mvwprintw(win, y, x, "%s", string); - refresh(); +void print_in_middle(WINDOW *win, int y, int width, const char *str, int attrs) +{ + wattrset(win, attrs); + mvwprintw(win, y, (width - strlen(str)) / 2, "%s", str); } int get_line_no(const char *text) @@ -294,14 +245,14 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...) msg_win = derwin(win, win_rows-2, msg_width, 1, 1+(total_width+2-msg_width)/2); - set_menu_fore(menu, attributes[DIALOG_MENU_FORE]); - set_menu_back(menu, attributes[DIALOG_MENU_BACK]); + set_menu_fore(menu, attr_dialog_menu_fore); + set_menu_back(menu, attr_dialog_menu_back); - (void) wattrset(win, attributes[DIALOG_BOX]); + wattrset(win, attr_dialog_box); box(win, 0, 0); /* print message */ - (void) wattrset(msg_win, attributes[DIALOG_TEXT]); + wattrset(msg_win, attr_dialog_text); fill_window(msg_win, msg); set_menu_win(menu, win); @@ -405,16 +356,16 @@ int dialog_inputbox(WINDOW *main_window, form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2); keypad(form_win, TRUE); - (void) wattrset(form_win, attributes[INPUT_FIELD]); + wattrset(form_win, attr_input_field); - (void) wattrset(win, attributes[INPUT_BOX]); + wattrset(win, attr_input_box); box(win, 0, 0); - (void) wattrset(win, attributes[INPUT_HEADING]); + wattrset(win, attr_input_heading); if (title) mvwprintw(win, 0, 3, "%s", title); /* print message */ - (void) wattrset(prompt_win, attributes[INPUT_TEXT]); + wattrset(prompt_win, attr_input_text); fill_window(prompt_win, prompt); mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); @@ -576,7 +527,7 @@ void show_scroll_win(WINDOW *main_window, /* create the pad */ pad = newpad(total_lines+10, total_cols+10); - (void) wattrset(pad, attributes[SCROLLWIN_TEXT]); + wattrset(pad, attr_scrollwin_text); fill_window(pad, text); win_lines = min(total_lines+4, lines-2); @@ -591,9 +542,9 @@ void show_scroll_win(WINDOW *main_window, win = newwin(win_lines, win_cols, y, x); keypad(win, TRUE); /* show the help in the help window, and show the help panel */ - (void) wattrset(win, attributes[SCROLLWIN_BOX]); + wattrset(win, attr_scrollwin_box); box(win, 0, 0); - (void) wattrset(win, attributes[SCROLLWIN_HEADING]); + wattrset(win, attr_scrollwin_heading); mvwprintw(win, 0, 3, " %s ", title); panel = new_panel(win); @@ -604,10 +555,9 @@ void show_scroll_win(WINDOW *main_window, text_cols, 0); print_in_middle(win, text_lines+2, - 0, text_cols, "", - attributes[DIALOG_MENU_FORE]); + attr_dialog_menu_fore); wrefresh(win); res = wgetch(win); diff --git a/scripts/config/nconf.h b/scripts/config/nconf.h index eab138b30..6e127c63d 100644 --- a/scripts/config/nconf.h +++ b/scripts/config/nconf.h @@ -32,30 +32,26 @@ typeof(b) _b = b;\ _a < _b ? _a : _b; }) -typedef enum { - NORMAL = 1, - MAIN_HEADING, - MAIN_MENU_BOX, - MAIN_MENU_FORE, - MAIN_MENU_BACK, - MAIN_MENU_GREY, - MAIN_MENU_HEADING, - SCROLLWIN_TEXT, - SCROLLWIN_HEADING, - SCROLLWIN_BOX, - DIALOG_TEXT, - DIALOG_MENU_FORE, - DIALOG_MENU_BACK, - DIALOG_BOX, - INPUT_BOX, - INPUT_HEADING, - INPUT_TEXT, - INPUT_FIELD, - FUNCTION_TEXT, - FUNCTION_HIGHLIGHT, - ATTR_MAX -} attributes_t; -extern attributes_t attributes[]; +extern int attr_normal; +extern int attr_main_heading; +extern int attr_main_menu_box; +extern int attr_main_menu_fore; +extern int attr_main_menu_back; +extern int attr_main_menu_grey; +extern int attr_main_menu_heading; +extern int attr_scrollwin_text; +extern int attr_scrollwin_heading; +extern int attr_scrollwin_box; +extern int attr_dialog_text; +extern int attr_dialog_menu_fore; +extern int attr_dialog_menu_back; +extern int attr_dialog_box; +extern int attr_input_box; +extern int attr_input_heading; +extern int attr_input_text; +extern int attr_input_field; +extern int attr_function_text; +extern int attr_function_highlight; typedef enum { F_HELP = 1, @@ -72,12 +68,7 @@ typedef enum { void set_colors(void); /* this changes the windows attributes !!! */ -void print_in_middle(WINDOW *win, - int starty, - int startx, - int width, - const char *string, - chtype color); +void print_in_middle(WINDOW *win, int y, int width, const char *str, int attrs); int get_line_length(const char *line); int get_line_no(const char *text); const char *get_line(const char *text, int line_no); diff --git a/scripts/config/parser.tab.c b/scripts/config/parser.tab.c index 1b291145a..18137050a 100644 --- a/scripts/config/parser.tab.c +++ b/scripts/config/parser.tab.c @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.1. */ +/* A Bison parser, made by GNU Bison 3.7.6. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. 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 @@ -15,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -33,6 +34,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -40,11 +45,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output. */ -#define YYBISON 1 +/* Identify Bison output, and Bison version. */ +#define YYBISON 30706 -/* Bison version. */ -#define YYBISON_VERSION "3.1" +/* Bison version string. */ +#define YYBISON_VERSION "3.7.6" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,8 +66,7 @@ -/* Copy the first part of user declarations. */ - +/* First part of user prologue. */ #include @@ -73,6 +77,7 @@ #include #include "lkc.h" +#include "internal.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) @@ -89,128 +94,137 @@ static bool zconf_endtoken(const char *tokenname, struct symbol *symbol_hash[SYMBOL_HASHSIZE]; -static struct menu *current_menu, *current_entry; +struct menu *current_menu, *current_entry; - -# ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) # else -# define YY_NULLPTR 0 +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# else +# define YY_NULLPTR ((void*)0) # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "parser.tab.h". */ -#ifndef YY_YY_PARSER_TAB_H_INCLUDED -# define YY_YY_PARSER_TAB_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - T_HELPTEXT = 258, - T_WORD = 259, - T_WORD_QUOTE = 260, - T_ALLNOCONFIG_Y = 261, - T_BOOL = 262, - T_CHOICE = 263, - T_CLOSE_PAREN = 264, - T_COLON_EQUAL = 265, - T_COMMENT = 266, - T_CONFIG = 267, - T_DEFAULT = 268, - T_DEFCONFIG_LIST = 269, - T_DEF_BOOL = 270, - T_DEF_TRISTATE = 271, - T_DEPENDS = 272, - T_ENDCHOICE = 273, - T_ENDIF = 274, - T_ENDMENU = 275, - T_HELP = 276, - T_HEX = 277, - T_IF = 278, - T_IMPLY = 279, - T_INT = 280, - T_MAINMENU = 281, - T_MENU = 282, - T_MENUCONFIG = 283, - T_MODULES = 284, - T_ON = 285, - T_OPEN_PAREN = 286, - T_OPTION = 287, - T_OPTIONAL = 288, - T_PLUS_EQUAL = 289, - T_PROMPT = 290, - T_RANGE = 291, - T_RESET = 292, - T_SELECT = 293, - T_SOURCE = 294, - T_STRING = 295, - T_TRISTATE = 296, - T_VISIBLE = 297, - T_EOL = 298, - T_ASSIGN_VAL = 299, - T_OR = 300, - T_AND = 301, - T_EQUAL = 302, - T_UNEQUAL = 303, - T_LESS = 304, - T_LESS_EQUAL = 305, - T_GREATER = 306, - T_GREATER_EQUAL = 307, - T_NOT = 308 - }; -#endif - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -union YYSTYPE +#include "parser.tab.h" +/* Symbol kind. */ +enum yysymbol_kind_t { - - - char *string; - struct symbol *symbol; - struct expr *expr; - struct menu *menu; - enum symbol_type type; - enum variable_flavor flavor; - - + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_T_HELPTEXT = 3, /* T_HELPTEXT */ + YYSYMBOL_T_WORD = 4, /* T_WORD */ + YYSYMBOL_T_WORD_QUOTE = 5, /* T_WORD_QUOTE */ + YYSYMBOL_T_BOOL = 6, /* T_BOOL */ + YYSYMBOL_T_CHOICE = 7, /* T_CHOICE */ + YYSYMBOL_T_CLOSE_PAREN = 8, /* T_CLOSE_PAREN */ + YYSYMBOL_T_COLON_EQUAL = 9, /* T_COLON_EQUAL */ + YYSYMBOL_T_COMMENT = 10, /* T_COMMENT */ + YYSYMBOL_T_CONFIG = 11, /* T_CONFIG */ + YYSYMBOL_T_DEFAULT = 12, /* T_DEFAULT */ + YYSYMBOL_T_DEF_BOOL = 13, /* T_DEF_BOOL */ + YYSYMBOL_T_DEF_TRISTATE = 14, /* T_DEF_TRISTATE */ + YYSYMBOL_T_DEPENDS = 15, /* T_DEPENDS */ + YYSYMBOL_T_ENDCHOICE = 16, /* T_ENDCHOICE */ + YYSYMBOL_T_ENDIF = 17, /* T_ENDIF */ + YYSYMBOL_T_ENDMENU = 18, /* T_ENDMENU */ + YYSYMBOL_T_HELP = 19, /* T_HELP */ + YYSYMBOL_T_HEX = 20, /* T_HEX */ + YYSYMBOL_T_IF = 21, /* T_IF */ + YYSYMBOL_T_IMPLY = 22, /* T_IMPLY */ + YYSYMBOL_T_INT = 23, /* T_INT */ + YYSYMBOL_T_MAINMENU = 24, /* T_MAINMENU */ + YYSYMBOL_T_MENU = 25, /* T_MENU */ + YYSYMBOL_T_MENUCONFIG = 26, /* T_MENUCONFIG */ + YYSYMBOL_T_MODULES = 27, /* T_MODULES */ + YYSYMBOL_T_ON = 28, /* T_ON */ + YYSYMBOL_T_OPEN_PAREN = 29, /* T_OPEN_PAREN */ + YYSYMBOL_T_OPTIONAL = 30, /* T_OPTIONAL */ + YYSYMBOL_T_PLUS_EQUAL = 31, /* T_PLUS_EQUAL */ + YYSYMBOL_T_PROMPT = 32, /* T_PROMPT */ + YYSYMBOL_T_RANGE = 33, /* T_RANGE */ + YYSYMBOL_T_RESET = 34, /* T_RESET */ + YYSYMBOL_T_SELECT = 35, /* T_SELECT */ + YYSYMBOL_T_SOURCE = 36, /* T_SOURCE */ + YYSYMBOL_T_STRING = 37, /* T_STRING */ + YYSYMBOL_T_TRISTATE = 38, /* T_TRISTATE */ + YYSYMBOL_T_VISIBLE = 39, /* T_VISIBLE */ + YYSYMBOL_T_EOL = 40, /* T_EOL */ + YYSYMBOL_T_ASSIGN_VAL = 41, /* T_ASSIGN_VAL */ + YYSYMBOL_T_OR = 42, /* T_OR */ + YYSYMBOL_T_AND = 43, /* T_AND */ + YYSYMBOL_T_EQUAL = 44, /* T_EQUAL */ + YYSYMBOL_T_UNEQUAL = 45, /* T_UNEQUAL */ + YYSYMBOL_T_LESS = 46, /* T_LESS */ + YYSYMBOL_T_LESS_EQUAL = 47, /* T_LESS_EQUAL */ + YYSYMBOL_T_GREATER = 48, /* T_GREATER */ + YYSYMBOL_T_GREATER_EQUAL = 49, /* T_GREATER_EQUAL */ + YYSYMBOL_T_NOT = 50, /* T_NOT */ + YYSYMBOL_YYACCEPT = 51, /* $accept */ + YYSYMBOL_input = 52, /* input */ + YYSYMBOL_mainmenu_stmt = 53, /* mainmenu_stmt */ + YYSYMBOL_stmt_list = 54, /* stmt_list */ + YYSYMBOL_stmt_list_in_choice = 55, /* stmt_list_in_choice */ + YYSYMBOL_config_entry_start = 56, /* config_entry_start */ + YYSYMBOL_config_stmt = 57, /* config_stmt */ + YYSYMBOL_menuconfig_entry_start = 58, /* menuconfig_entry_start */ + YYSYMBOL_menuconfig_stmt = 59, /* menuconfig_stmt */ + YYSYMBOL_config_option_list = 60, /* config_option_list */ + YYSYMBOL_config_option = 61, /* config_option */ + YYSYMBOL_choice = 62, /* choice */ + YYSYMBOL_choice_entry = 63, /* choice_entry */ + YYSYMBOL_choice_end = 64, /* choice_end */ + YYSYMBOL_choice_stmt = 65, /* choice_stmt */ + YYSYMBOL_choice_option_list = 66, /* choice_option_list */ + YYSYMBOL_choice_option = 67, /* choice_option */ + YYSYMBOL_type = 68, /* type */ + YYSYMBOL_logic_type = 69, /* logic_type */ + YYSYMBOL_default = 70, /* default */ + YYSYMBOL_if_entry = 71, /* if_entry */ + YYSYMBOL_if_end = 72, /* if_end */ + YYSYMBOL_if_stmt = 73, /* if_stmt */ + YYSYMBOL_if_stmt_in_choice = 74, /* if_stmt_in_choice */ + YYSYMBOL_menu = 75, /* menu */ + YYSYMBOL_menu_entry = 76, /* menu_entry */ + YYSYMBOL_menu_end = 77, /* menu_end */ + YYSYMBOL_menu_stmt = 78, /* menu_stmt */ + YYSYMBOL_menu_option_list = 79, /* menu_option_list */ + YYSYMBOL_source_stmt = 80, /* source_stmt */ + YYSYMBOL_comment = 81, /* comment */ + YYSYMBOL_comment_stmt = 82, /* comment_stmt */ + YYSYMBOL_comment_option_list = 83, /* comment_option_list */ + YYSYMBOL_help_start = 84, /* help_start */ + YYSYMBOL_help = 85, /* help */ + YYSYMBOL_depends = 86, /* depends */ + YYSYMBOL_visible = 87, /* visible */ + YYSYMBOL_prompt_stmt_opt = 88, /* prompt_stmt_opt */ + YYSYMBOL_end = 89, /* end */ + YYSYMBOL_if_expr = 90, /* if_expr */ + YYSYMBOL_expr = 91, /* expr */ + YYSYMBOL_nonconst_symbol = 92, /* nonconst_symbol */ + YYSYMBOL_symbol = 93, /* symbol */ + YYSYMBOL_word_opt = 94, /* word_opt */ + YYSYMBOL_assignment_stmt = 95, /* assignment_stmt */ + YYSYMBOL_assign_op = 96, /* assign_op */ + YYSYMBOL_assign_val = 97 /* assign_val */ }; +typedef enum yysymbol_kind_t yysymbol_kind_t; -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - -int yyparse (void); - -#endif /* !YY_YY_PARSER_TAB_H_INCLUDED */ - -/* Copy the second part of user declarations. */ @@ -218,36 +232,95 @@ int yyparse (void); # undef short #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else typedef short yytype_int16; #endif +/* Work around bug in HP-UX 11.23, which defines these macros + incorrectly for preprocessor constants. This workaround can likely + be removed in 2023, as HPE has promised support for HP-UX 11.23 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of + . */ +#ifdef __hpux +# undef UINT_LEAST8_MAX +# undef UINT_LEAST16_MAX +# define UINT_LEAST8_MAX 255 +# define UINT_LEAST16_MAX 65535 +#endif + +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; +#else +typedef short yytype_uint8; +#endif + +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; +#else +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif +#endif + #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -255,7 +328,20 @@ typedef short yytype_int16; # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_uint8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -269,47 +355,37 @@ typedef short yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) + +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else -# define YY_ATTRIBUTE(Spec) /* empty */ +# define YY_ATTRIBUTE_PURE # endif #endif -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) +# define YY_USE(E) ((void) (E)) #else -# define YYUSE(E) /* empty */ +# define YY_USE(E) /* empty */ #endif #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -322,8 +398,22 @@ typedef short yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif -#if ! defined yyoverflow || YYERROR_VERBOSE + +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -388,8 +478,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -398,17 +487,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -421,11 +510,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -437,12 +526,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -457,25 +546,28 @@ union yyalloc #define YYLAST 194 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 54 +#define YYNTOKENS 51 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 47 /* YYNRULES -- Number of rules. */ -#define YYNRULES 105 +#define YYNRULES 106 /* YYNSTATES -- Number of states. */ #define YYNSTATES 187 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 308 +/* YYMAXUTOK -- Last valid token kind. */ +#define YYMAXUTOK 305 -#define YYTRANSLATE(YYX) \ - ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -507,149 +599,161 @@ static const yytype_uint8 yytranslate[] = 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 + 45, 46, 47, 48, 49, 50 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +static const yytype_int16 yyrline[] = { - 0, 112, 112, 112, 116, 121, 123, 124, 125, 126, - 127, 131, 132, 133, 134, 135, 136, 141, 148, 153, - 160, 169, 171, 172, 173, 176, 184, 190, 200, 206, - 212, 218, 223, 228, 235, 245, 250, 258, 261, 263, - 264, 265, 268, 274, 281, 287, 292, 300, 301, 302, - 303, 306, 307, 310, 311, 312, 314, 316, 321, 329, - 337, 342, 349, 354, 362, 365, 367, 368, 371, 380, - 387, 390, 392, 397, 403, 415, 422, 429, 431, 436, - 437, 438, 441, 442, 445, 446, 447, 448, 449, 450, - 451, 452, 453, 454, 455, 459, 461, 462, 465, 466, - 470, 473, 474, 475, 479, 480 + 0, 110, 110, 110, 114, 119, 121, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 133, 135, 136, 137, + 138, 143, 150, 155, 162, 171, 173, 174, 175, 178, + 186, 192, 202, 208, 214, 220, 230, 240, 245, 253, + 256, 258, 259, 260, 263, 269, 276, 282, 287, 295, + 296, 297, 298, 301, 302, 305, 306, 307, 311, 319, + 327, 330, 335, 342, 347, 355, 358, 360, 361, 364, + 373, 380, 383, 385, 390, 396, 408, 415, 422, 424, + 429, 430, 431, 434, 435, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 452, 454, 455, 458, + 459, 463, 466, 467, 468, 472, 473 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "T_HELPTEXT", "T_WORD", "T_WORD_QUOTE", - "T_ALLNOCONFIG_Y", "T_BOOL", "T_CHOICE", "T_CLOSE_PAREN", - "T_COLON_EQUAL", "T_COMMENT", "T_CONFIG", "T_DEFAULT", - "T_DEFCONFIG_LIST", "T_DEF_BOOL", "T_DEF_TRISTATE", "T_DEPENDS", - "T_ENDCHOICE", "T_ENDIF", "T_ENDMENU", "T_HELP", "T_HEX", "T_IF", - "T_IMPLY", "T_INT", "T_MAINMENU", "T_MENU", "T_MENUCONFIG", "T_MODULES", - "T_ON", "T_OPEN_PAREN", "T_OPTION", "T_OPTIONAL", "T_PLUS_EQUAL", + "\"end of file\"", "error", "\"invalid token\"", "T_HELPTEXT", "T_WORD", + "T_WORD_QUOTE", "T_BOOL", "T_CHOICE", "T_CLOSE_PAREN", "T_COLON_EQUAL", + "T_COMMENT", "T_CONFIG", "T_DEFAULT", "T_DEF_BOOL", "T_DEF_TRISTATE", + "T_DEPENDS", "T_ENDCHOICE", "T_ENDIF", "T_ENDMENU", "T_HELP", "T_HEX", + "T_IF", "T_IMPLY", "T_INT", "T_MAINMENU", "T_MENU", "T_MENUCONFIG", + "T_MODULES", "T_ON", "T_OPEN_PAREN", "T_OPTIONAL", "T_PLUS_EQUAL", "T_PROMPT", "T_RANGE", "T_RESET", "T_SELECT", "T_SOURCE", "T_STRING", "T_TRISTATE", "T_VISIBLE", "T_EOL", "T_ASSIGN_VAL", "T_OR", "T_AND", "T_EQUAL", "T_UNEQUAL", "T_LESS", "T_LESS_EQUAL", "T_GREATER", "T_GREATER_EQUAL", "T_NOT", "$accept", "input", "mainmenu_stmt", - "stmt_list", "common_stmt", "config_entry_start", "config_stmt", + "stmt_list", "stmt_list_in_choice", "config_entry_start", "config_stmt", "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", "choice_option_list", "choice_option", "type", "logic_type", "default", - "choice_block", "if_entry", "if_end", "if_stmt", "menu", "menu_entry", - "menu_end", "menu_stmt", "menu_option_list", "source_stmt", "comment", - "comment_stmt", "comment_option_list", "help_start", "help", "depends", - "visible", "prompt_stmt_opt", "end", "if_expr", "expr", + "if_entry", "if_end", "if_stmt", "if_stmt_in_choice", "menu", + "menu_entry", "menu_end", "menu_stmt", "menu_option_list", "source_stmt", + "comment", "comment_stmt", "comment_option_list", "help_start", "help", + "depends", "visible", "prompt_stmt_opt", "end", "if_expr", "expr", "nonconst_symbol", "symbol", "word_opt", "assignment_stmt", "assign_op", "assign_val", YY_NULLPTR }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308 + 305 }; -# endif +#endif -#define YYPACT_NINF -107 +#define YYPACT_NINF (-105) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-107))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -4 +#define YYTABLE_NINF (-4) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { - -6, 24, 33, -107, 65, -7, -107, 71, -4, 12, - 49, 53, 63, -1, 69, 63, 76, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, 25, -107, -107, -107, - 26, -107, 46, 47, -107, 54, -107, -1, -1, -22, - -107, 142, 58, 60, 68, 134, 134, 147, 114, 101, - 2, 101, 67, -107, -107, 72, -107, -107, -107, 5, - -107, -107, -1, -1, 44, 44, 44, 44, 44, 44, - -107, -107, -107, -107, -107, -107, -107, 66, 73, -107, - 63, -107, 94, 109, 44, 63, -107, -107, -107, 112, - -107, -1, 103, -107, -107, 63, 79, 122, 107, -107, - 112, -107, -107, 8, 88, 92, 93, -107, -107, -107, - -107, -107, 107, -107, -107, -107, -107, -107, -107, -107, - 97, -107, -107, -107, -107, -107, -107, -107, -1, -107, - 107, 95, 96, 102, 107, 44, 107, 107, 105, 41, - -107, 107, -107, 107, -1, 118, 119, -107, -107, -107, - 120, 17, 124, -107, -107, -107, 128, 107, 130, -107, - -107, 133, 135, 136, 11, -107, -107, -107, -107, -107, - -107, 138, -107, -107, -107, -107, -107 + -5, 17, 37, -105, 57, 8, -105, 91, 39, 15, + 46, 72, 80, 10, 82, 80, 83, -105, -105, -105, + -105, -105, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -105, -105, -105, -105, 45, -105, -105, -105, 48, + -105, 50, 59, -105, 60, -105, 10, 10, -7, -105, + 25, 63, 64, 65, 132, 132, 156, 162, 114, 14, + 114, 95, -105, -105, 71, -105, -105, -105, 9, -105, + -105, 10, 10, 27, 27, 27, 27, 27, 27, -105, + -105, -105, -105, -105, -105, -105, 69, 73, -105, 80, + -105, 74, 115, 27, 80, -105, -105, -105, 117, -105, + 10, 116, -105, -105, 80, 86, 118, 107, -105, 117, + -105, -105, 89, 93, 94, 96, -105, -105, -105, -105, + -105, -105, -105, -105, 107, -105, -105, -105, -105, -105, + -105, -105, 98, -105, -105, -105, -105, -105, -105, -105, + 10, -105, 107, -105, 107, 27, 107, 107, 97, 13, + -105, 107, -105, 107, 10, 102, 103, -105, -105, -105, + -105, 162, 108, 23, 109, 113, 107, 120, -105, -105, + 121, 126, 134, 33, -105, -105, -105, -105, -105, -105, + -105, 136, -105, -105, -105, -105, -105 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ -static const yytype_uint8 yydefact[] = +static const yytype_int8 yydefact[] = { 5, 0, 0, 5, 0, 0, 1, 0, 0, 0, - 98, 0, 0, 0, 0, 0, 0, 6, 21, 13, - 21, 14, 38, 56, 7, 5, 11, 65, 5, 8, - 15, 71, 12, 16, 4, 10, 0, 102, 103, 101, - 104, 99, 0, 0, 95, 0, 97, 0, 0, 0, - 96, 84, 0, 0, 0, 18, 20, 35, 0, 0, - 62, 0, 70, 9, 105, 0, 34, 69, 17, 0, - 92, 58, 0, 0, 0, 0, 0, 0, 0, 0, - 61, 19, 68, 51, 53, 54, 55, 0, 0, 49, - 0, 48, 0, 0, 0, 0, 50, 52, 22, 77, - 47, 0, 0, 24, 23, 0, 0, 0, 82, 39, - 77, 41, 40, 0, 0, 0, 0, 57, 37, 36, - 60, 59, 82, 67, 66, 64, 63, 72, 100, 91, - 93, 94, 89, 90, 85, 86, 87, 88, 0, 73, - 82, 0, 0, 0, 82, 0, 82, 82, 0, 82, - 74, 82, 44, 82, 0, 0, 0, 80, 81, 79, - 0, 0, 0, 33, 32, 31, 0, 82, 0, 78, - 25, 0, 0, 0, 83, 45, 43, 76, 75, 29, - 26, 0, 28, 27, 46, 42, 30 + 99, 0, 0, 0, 0, 0, 0, 25, 9, 25, + 12, 40, 16, 7, 5, 10, 66, 5, 11, 13, + 72, 8, 6, 4, 15, 0, 103, 104, 102, 105, + 100, 0, 0, 96, 0, 98, 0, 0, 0, 97, + 85, 0, 0, 0, 22, 24, 37, 0, 0, 63, + 0, 71, 14, 106, 0, 36, 70, 21, 0, 93, + 58, 0, 0, 0, 0, 0, 0, 0, 0, 62, + 23, 69, 53, 55, 56, 57, 0, 0, 51, 0, + 50, 0, 0, 0, 0, 52, 54, 26, 78, 49, + 0, 0, 28, 27, 0, 0, 0, 83, 41, 78, + 43, 42, 0, 0, 0, 0, 18, 39, 16, 19, + 17, 38, 60, 59, 83, 68, 67, 65, 64, 73, + 101, 92, 94, 95, 90, 91, 86, 87, 88, 89, + 0, 74, 83, 35, 83, 0, 83, 83, 0, 83, + 75, 83, 46, 83, 0, 0, 0, 20, 81, 82, + 80, 0, 0, 0, 0, 0, 83, 0, 79, 29, + 0, 0, 0, 84, 47, 45, 61, 77, 76, 33, + 30, 0, 32, 31, 48, 44, 34 }; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = +static const yytype_int16 yypgoto[] = { - -107, -107, -107, 3, 86, -107, -107, -107, -107, 126, - -107, -107, -107, -107, -107, -107, -107, -107, 100, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, 108, -25, -107, 42, -44, -106, - -47, -10, -67, -107, -107, -107, -107 + -105, -105, -105, 3, 38, -105, -55, -105, -105, 138, + -105, -105, -105, -105, -105, -105, -105, -105, 125, -105, + -54, -3, -105, -105, -105, -105, -105, -105, -105, -105, + -105, -52, -105, -105, 128, -38, -105, 68, -16, -104, + -46, -8, -65, -105, -105, -105, -105 }; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = +static const yytype_uint8 yydefgoto[] = { - -1, 2, 3, 4, 17, 18, 19, 20, 21, 55, - 98, 22, 23, 118, 24, 57, 109, 99, 100, 101, - 58, 25, 120, 26, 27, 28, 125, 29, 60, 30, - 31, 32, 62, 102, 103, 104, 124, 148, 119, 155, - 49, 50, 51, 42, 33, 40, 65 + 0, 2, 3, 4, 57, 17, 18, 19, 20, 54, + 97, 21, 22, 117, 23, 56, 108, 98, 99, 100, + 24, 122, 25, 119, 26, 27, 127, 28, 59, 29, + 30, 31, 61, 101, 102, 103, 126, 148, 123, 155, + 48, 49, 50, 41, 32, 39, 64 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -657,114 +761,114 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 69, 70, 45, 44, 46, 53, 7, 132, 133, 134, - 135, 136, 137, 36, 129, 121, 160, 126, 37, 87, - 1, 71, 37, 72, 73, 130, 131, 145, 59, 5, - 47, 61, 112, 6, 162, 123, 34, 127, 166, 35, - 168, 169, 38, 171, 122, 172, 38, 173, 44, 46, - 72, 73, 48, 41, 149, 39, 72, 73, 43, 39, - 178, 181, 72, 73, 154, -3, 8, 44, 63, 9, - 64, -2, 8, 10, 52, 9, 11, 12, 167, 10, - 140, 54, 11, 12, 87, 146, 72, 73, 13, 66, - 67, 161, 14, 15, 13, 151, 138, 68, 14, 15, - 141, 80, 8, 81, 16, 9, 150, 174, 142, 10, - 16, 82, 11, 12, 144, 128, 139, 147, 113, 114, - 115, 116, 152, 143, 13, 11, 12, 153, 14, 15, - 154, 157, 114, 115, 116, 158, 159, 13, 163, 164, - 16, 83, 15, 73, 117, 165, 56, 84, 170, 85, - 86, 87, 156, 16, 83, 88, 89, 110, 90, 91, - 105, 175, 176, 177, 87, 111, 92, 179, 88, 93, - 94, 180, 95, 182, 96, 97, 183, 0, 184, 185, - 106, 186, 107, 0, 108, 0, 0, 0, 97, 74, - 75, 76, 77, 78, 79 + 68, 69, 116, 118, 44, 120, 7, 52, 134, 135, + 136, 137, 138, 139, 43, 45, 35, 131, 111, 1, + 162, 125, 5, 129, 36, 132, 133, 58, 145, 86, + 60, 43, 45, 70, 154, 71, 72, 6, 164, 46, + 165, 121, 167, 168, 128, 170, 37, 171, 33, 172, + 40, 71, 72, 124, 149, 71, 72, -3, 8, 38, + 47, 9, 181, 178, 10, 71, 72, 11, 12, 73, + 74, 75, 76, 77, 78, 71, 72, 42, 13, 34, + 166, 142, 14, 15, 43, 62, 146, 51, 53, 63, + 65, -2, 8, 16, 163, 9, 151, 140, 10, 66, + 67, 11, 12, 79, 80, 81, 116, 118, 173, 120, + 86, 130, 13, 141, 143, 8, 14, 15, 9, 150, + 144, 10, 147, 153, 11, 12, 152, 16, 154, 157, + 113, 114, 115, 158, 159, 13, 160, 169, 82, 14, + 15, 72, 174, 175, 83, 84, 85, 86, 177, 179, + 16, 87, 88, 180, 89, 90, 161, 55, 176, 91, + 182, 183, 82, 112, 92, 93, 184, 94, 104, 95, + 96, 86, 11, 12, 185, 87, 186, 156, 113, 114, + 115, 109, 0, 13, 110, 0, 105, 0, 106, 0, + 107, 0, 0, 0, 96 }; static const yytype_int16 yycheck[] = { - 47, 48, 12, 4, 5, 15, 3, 74, 75, 76, - 77, 78, 79, 1, 9, 59, 122, 61, 10, 17, - 26, 43, 10, 45, 46, 72, 73, 94, 25, 5, - 31, 28, 57, 0, 140, 60, 43, 62, 144, 43, - 146, 147, 34, 149, 42, 151, 34, 153, 4, 5, - 45, 46, 53, 4, 101, 47, 45, 46, 5, 47, - 43, 167, 45, 46, 23, 0, 1, 4, 43, 4, - 44, 0, 1, 8, 5, 4, 11, 12, 145, 8, - 90, 5, 11, 12, 17, 95, 45, 46, 23, 43, - 43, 138, 27, 28, 23, 105, 30, 43, 27, 28, - 6, 43, 1, 43, 39, 4, 3, 154, 14, 8, - 39, 43, 11, 12, 5, 43, 43, 5, 4, 18, - 19, 20, 43, 29, 23, 11, 12, 5, 27, 28, - 23, 43, 18, 19, 20, 43, 43, 23, 43, 43, - 39, 7, 28, 46, 58, 43, 20, 13, 43, 15, - 16, 17, 110, 39, 7, 21, 22, 57, 24, 25, - 13, 43, 43, 43, 17, 57, 32, 43, 21, 35, - 36, 43, 38, 43, 40, 41, 43, -1, 43, 43, - 33, 43, 35, -1, 37, -1, -1, -1, 41, 47, - 48, 49, 50, 51, 52 + 46, 47, 57, 57, 12, 57, 3, 15, 73, 74, + 75, 76, 77, 78, 4, 5, 1, 8, 56, 24, + 124, 59, 5, 61, 9, 71, 72, 24, 93, 15, + 27, 4, 5, 40, 21, 42, 43, 0, 142, 29, + 144, 57, 146, 147, 60, 149, 31, 151, 40, 153, + 4, 42, 43, 39, 100, 42, 43, 0, 1, 44, + 50, 4, 166, 40, 7, 42, 43, 10, 11, 44, + 45, 46, 47, 48, 49, 42, 43, 5, 21, 40, + 145, 89, 25, 26, 4, 40, 94, 5, 5, 41, + 40, 0, 1, 36, 140, 4, 104, 28, 7, 40, + 40, 10, 11, 40, 40, 40, 161, 161, 154, 161, + 15, 40, 21, 40, 40, 1, 25, 26, 4, 3, + 5, 7, 5, 5, 10, 11, 40, 36, 21, 40, + 16, 17, 18, 40, 40, 21, 40, 40, 6, 25, + 26, 43, 40, 40, 12, 13, 14, 15, 40, 40, + 36, 19, 20, 40, 22, 23, 118, 19, 161, 27, + 40, 40, 6, 1, 32, 33, 40, 35, 12, 37, + 38, 15, 10, 11, 40, 19, 40, 109, 16, 17, + 18, 56, -1, 21, 56, -1, 30, -1, 32, -1, + 34, -1, -1, -1, 38 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +static const yytype_int8 yystos[] = { - 0, 26, 55, 56, 57, 5, 0, 57, 1, 4, - 8, 11, 12, 23, 27, 28, 39, 58, 59, 60, - 61, 62, 65, 66, 68, 75, 77, 78, 79, 81, - 83, 84, 85, 98, 43, 43, 1, 10, 34, 47, - 99, 4, 97, 5, 4, 95, 5, 31, 53, 94, - 95, 96, 5, 95, 5, 63, 63, 69, 74, 57, - 82, 57, 86, 43, 44, 100, 43, 43, 43, 94, - 94, 43, 45, 46, 47, 48, 49, 50, 51, 52, - 43, 43, 43, 7, 13, 15, 16, 17, 21, 22, - 24, 25, 32, 35, 36, 38, 40, 41, 64, 71, - 72, 73, 87, 88, 89, 13, 33, 35, 37, 70, - 72, 88, 89, 4, 18, 19, 20, 58, 67, 92, - 76, 92, 42, 89, 90, 80, 92, 89, 43, 9, - 94, 94, 96, 96, 96, 96, 96, 96, 30, 43, - 95, 6, 14, 29, 5, 96, 95, 5, 91, 94, - 3, 95, 43, 5, 23, 93, 91, 43, 43, 43, - 93, 94, 93, 43, 43, 43, 93, 96, 93, 93, - 43, 93, 93, 93, 94, 43, 43, 43, 43, 43, - 43, 93, 43, 43, 43, 43, 43 + 0, 24, 52, 53, 54, 5, 0, 54, 1, 4, + 7, 10, 11, 21, 25, 26, 36, 56, 57, 58, + 59, 62, 63, 65, 71, 73, 75, 76, 78, 80, + 81, 82, 95, 40, 40, 1, 9, 31, 44, 96, + 4, 94, 5, 4, 92, 5, 29, 50, 91, 92, + 93, 5, 92, 5, 60, 60, 66, 55, 54, 79, + 54, 83, 40, 41, 97, 40, 40, 40, 91, 91, + 40, 42, 43, 44, 45, 46, 47, 48, 49, 40, + 40, 40, 6, 12, 13, 14, 15, 19, 20, 22, + 23, 27, 32, 33, 35, 37, 38, 61, 68, 69, + 70, 84, 85, 86, 12, 30, 32, 34, 67, 69, + 85, 86, 1, 16, 17, 18, 57, 64, 71, 74, + 82, 89, 72, 89, 39, 86, 87, 77, 89, 86, + 40, 8, 91, 91, 93, 93, 93, 93, 93, 93, + 28, 40, 92, 40, 5, 93, 92, 5, 88, 91, + 3, 92, 40, 5, 21, 90, 88, 40, 40, 40, + 40, 55, 90, 91, 90, 90, 93, 90, 90, 40, + 90, 90, 90, 91, 40, 40, 72, 40, 40, 40, + 40, 90, 40, 40, 40, 40, 40 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +static const yytype_int8 yyr1[] = { - 0, 54, 55, 55, 56, 57, 57, 57, 57, 57, - 57, 58, 58, 58, 58, 58, 58, 59, 60, 61, - 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 65, 66, 67, 68, 69, 69, - 69, 69, 70, 70, 70, 70, 70, 71, 71, 71, - 71, 72, 72, 73, 73, 73, 74, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 82, 82, 83, 84, - 85, 86, 86, 87, 88, 89, 90, 91, 91, 92, - 92, 92, 93, 93, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 95, 96, 96, 97, 97, - 98, 99, 99, 99, 100, 100 + 0, 51, 52, 52, 53, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, + 55, 56, 57, 58, 59, 60, 60, 60, 60, 61, + 61, 61, 61, 61, 61, 61, 62, 63, 64, 65, + 66, 66, 66, 66, 67, 67, 67, 67, 67, 68, + 68, 68, 68, 69, 69, 70, 70, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 79, 79, 80, + 81, 82, 83, 83, 84, 85, 86, 87, 88, 88, + 89, 89, 89, 90, 90, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 92, 93, 93, 94, + 94, 95, 96, 96, 96, 97, 97 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { - 0, 2, 2, 1, 3, 0, 2, 2, 2, 4, - 3, 1, 1, 1, 1, 1, 1, 3, 2, 3, - 2, 0, 2, 2, 2, 3, 4, 4, 4, 4, - 5, 3, 3, 3, 3, 2, 1, 3, 0, 2, - 2, 2, 4, 3, 2, 3, 4, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 2, 3, 1, - 3, 3, 2, 1, 3, 0, 2, 2, 3, 3, - 2, 0, 2, 2, 2, 4, 3, 0, 2, 2, - 2, 2, 0, 2, 1, 3, 3, 3, 3, 3, - 3, 3, 2, 3, 3, 1, 1, 1, 0, 1, - 4, 1, 1, 1, 0, 1 + 0, 2, 2, 1, 3, 0, 2, 2, 2, 2, + 2, 2, 2, 2, 4, 3, 0, 2, 2, 2, + 3, 3, 2, 3, 2, 0, 2, 2, 2, 3, + 4, 4, 4, 4, 5, 2, 3, 2, 1, 3, + 0, 2, 2, 2, 4, 3, 2, 3, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, + 3, 3, 3, 2, 1, 3, 0, 2, 2, 3, + 3, 2, 0, 2, 2, 2, 4, 3, 0, 2, + 2, 2, 2, 0, 2, 1, 3, 3, 3, 3, + 3, 3, 3, 2, 3, 3, 1, 1, 1, 0, + 1, 4, 1, 1, 1, 0, 1 }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -773,27 +877,26 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF /* Enable debugging if requested. */ @@ -811,54 +914,58 @@ do { \ } while (0) /* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif +# ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Kind, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YY_USE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -867,7 +974,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -890,21 +997,21 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) { - unsigned long yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); YYFPRINTF (stderr, "\n"); } } @@ -919,8 +1026,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -943,278 +1050,53 @@ int yydebug; #endif -#if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - default: /* Avoid compiler warnings. */ - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) { - YYUSE (yyvaluep); + YY_USE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - switch (yytype) + switch (yykind) { - case 66: /* choice_entry */ - - { + case YYSYMBOL_choice_entry: /* choice_entry */ + { fprintf(stderr, "%s:%d: missing end statement for this entry\n", ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno); if (current_menu == ((*yyvaluep).menu)) menu_end_menu(); } - break; - case 75: /* if_entry */ - - { + case YYSYMBOL_if_entry: /* if_entry */ + { fprintf(stderr, "%s:%d: missing end statement for this entry\n", ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno); if (current_menu == ((*yyvaluep).menu)) menu_end_menu(); } - break; - case 79: /* menu_entry */ - - { + case YYSYMBOL_menu_entry: /* menu_entry */ + { fprintf(stderr, "%s:%d: missing end statement for this entry\n", ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno); if (current_menu == ((*yyvaluep).menu)) menu_end_menu(); } - break; - default: break; } @@ -1222,9 +1104,7 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) } - - -/* The lookahead symbol. */ +/* Lookahead token kind. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1233,6 +1113,8 @@ YYSTYPE yylval; int yynerrs; + + /*----------. | yyparse. | `----------*/ @@ -1240,43 +1122,36 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yyerrstatus = 0; - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow + /* Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; - /* The semantic value stack. */ + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; + + /* The semantic value stack: array, bottom, top. */ YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; int yyn; + /* The return value of yyparse. */ int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1284,58 +1159,60 @@ yyparse (void) Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1344,9 +1221,10 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); @@ -1356,30 +1234,30 @@ yyparse (void) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1390,18 +1268,29 @@ yybackup: /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = yytoken = YYEOF; + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -1429,15 +1318,13 @@ yybackup: /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1452,7 +1339,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1472,89 +1359,74 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: - - { + case 4: /* mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL */ +{ menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL); } - break; - case 9: - - { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); } - + case 14: /* stmt_list: stmt_list T_WORD error T_EOL */ + { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); } break; - case 10: - - { zconf_error("invalid statement"); } - + case 15: /* stmt_list: stmt_list error T_EOL */ + { zconf_error("invalid statement"); } break; - case 17: + case 20: /* stmt_list_in_choice: stmt_list_in_choice error T_EOL */ + { zconf_error("invalid statement"); } + break; - { + case 21: /* config_entry_start: T_CONFIG nonconst_symbol T_EOL */ +{ (yyvsp[-1].symbol)->flags |= SYMBOL_OPTIONAL; menu_add_entry((yyvsp[-1].symbol)); printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].symbol)->name); } - break; - case 18: - - { + case 22: /* config_stmt: config_entry_start config_option_list */ +{ printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); } - break; - case 19: - - { + case 23: /* menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL */ +{ (yyvsp[-1].symbol)->flags |= SYMBOL_OPTIONAL; menu_add_entry((yyvsp[-1].symbol)); printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].symbol)->name); } - break; - case 20: - - { + case 24: /* menuconfig_stmt: menuconfig_entry_start config_option_list */ +{ if (current_entry->prompt) current_entry->prompt->type = P_MENU; else zconfprint("warning: menuconfig statement without prompt"); printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); } - break; - case 25: - - { + case 29: /* config_option: type prompt_stmt_opt T_EOL */ +{ menu_set_type((yyvsp[-2].type)); printd(DEBUG_PARSE, "%s:%d:type(%u)\n", zconf_curname(), zconf_lineno(), (yyvsp[-2].type)); } - break; - case 26: - - { + case 30: /* config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL */ +{ menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); } - break; - case 27: - - { + case 31: /* config_option: default expr if_expr T_EOL */ +{ menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr)); if ((yyvsp[-3].type) != S_UNKNOWN) menu_set_type((yyvsp[-3].type)); @@ -1562,63 +1434,40 @@ yyreduce: zconf_curname(), zconf_lineno(), (yyvsp[-3].type)); } - break; - case 28: - - { + case 32: /* config_option: T_SELECT nonconst_symbol if_expr T_EOL */ +{ menu_add_symbol(P_SELECT, (yyvsp[-2].symbol), (yyvsp[-1].expr)); printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); } - break; - case 29: - - { + case 33: /* config_option: T_IMPLY nonconst_symbol if_expr T_EOL */ +{ menu_add_symbol(P_IMPLY, (yyvsp[-2].symbol), (yyvsp[-1].expr)); printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno()); } - break; - case 30: - - { + case 34: /* config_option: T_RANGE symbol symbol if_expr T_EOL */ +{ menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr)); printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); } - break; - case 31: - - { - menu_add_option_modules(); + case 35: /* config_option: T_MODULES T_EOL */ +{ + if (modules_sym) + zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'", + current_entry->sym->name, modules_sym->name); + modules_sym = current_entry->sym; } - break; - case 32: - - { - menu_add_option_defconfig_list(); -} - - break; - - case 33: - - { - menu_add_option_allnoconfig_y(); -} - - break; - - case 34: - - { + case 36: /* choice: T_CHOICE word_opt T_EOL */ +{ struct symbol *sym = sym_lookup((yyvsp[-1].string), SYMBOL_CHOICE); sym->flags |= SYMBOL_NO_WRITE; menu_add_entry(sym); @@ -1626,205 +1475,157 @@ yyreduce: free((yyvsp[-1].string)); printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); } - break; - case 35: - - { + case 37: /* choice_entry: choice choice_option_list */ +{ (yyval.menu) = menu_add_menu(); } - break; - case 36: - - { + case 38: /* choice_end: end */ +{ if (zconf_endtoken((yyvsp[0].string), "choice")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); } } - break; - case 42: - - { + case 44: /* choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL */ +{ menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); } - break; - case 43: - - { + case 45: /* choice_option: logic_type prompt_stmt_opt T_EOL */ +{ menu_set_type((yyvsp[-2].type)); printd(DEBUG_PARSE, "%s:%d:type(%u)\n", zconf_curname(), zconf_lineno(), (yyvsp[-2].type)); } - break; - case 44: - - { + case 46: /* choice_option: T_OPTIONAL T_EOL */ +{ current_entry->sym->flags |= SYMBOL_OPTIONAL; printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); } - break; - case 45: - - { + case 47: /* choice_option: T_RESET if_expr T_EOL */ +{ menu_add_prop(P_RESET, NULL, (yyvsp[-1].expr)); } - break; - case 46: - - { + case 48: /* choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL */ +{ menu_add_symbol(P_DEFAULT, (yyvsp[-2].symbol), (yyvsp[-1].expr)); printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); } - break; - case 48: - - { (yyval.type) = S_INT; } - + case 50: /* type: T_INT */ + { (yyval.type) = S_INT; } break; - case 49: - - { (yyval.type) = S_HEX; } - + case 51: /* type: T_HEX */ + { (yyval.type) = S_HEX; } break; - case 50: - - { (yyval.type) = S_STRING; } - + case 52: /* type: T_STRING */ + { (yyval.type) = S_STRING; } break; - case 51: - - { (yyval.type) = S_BOOLEAN; } - + case 53: /* logic_type: T_BOOL */ + { (yyval.type) = S_BOOLEAN; } break; - case 52: - - { (yyval.type) = S_TRISTATE; } - + case 54: /* logic_type: T_TRISTATE */ + { (yyval.type) = S_TRISTATE; } break; - case 53: - - { (yyval.type) = S_UNKNOWN; } - + case 55: /* default: T_DEFAULT */ + { (yyval.type) = S_UNKNOWN; } break; - case 54: - - { (yyval.type) = S_BOOLEAN; } - + case 56: /* default: T_DEF_BOOL */ + { (yyval.type) = S_BOOLEAN; } break; - case 55: - - { (yyval.type) = S_TRISTATE; } - + case 57: /* default: T_DEF_TRISTATE */ + { (yyval.type) = S_TRISTATE; } break; - case 58: - - { + case 58: /* if_entry: T_IF expr T_EOL */ +{ printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); menu_add_entry(NULL); menu_add_dep((yyvsp[-1].expr)); (yyval.menu) = menu_add_menu(); } - break; - case 59: - - { + case 59: /* if_end: end */ +{ if (zconf_endtoken((yyvsp[0].string), "if")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); } } - break; - case 61: - - { + case 62: /* menu: T_MENU T_WORD_QUOTE T_EOL */ +{ menu_add_entry(NULL); menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL); printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); } - break; - case 62: - - { + case 63: /* menu_entry: menu menu_option_list */ +{ (yyval.menu) = menu_add_menu(); } - break; - case 63: - - { + case 64: /* menu_end: end */ +{ if (zconf_endtoken((yyvsp[0].string), "menu")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); } } - break; - case 68: - - { + case 69: /* source_stmt: T_SOURCE T_WORD_QUOTE T_EOL */ +{ printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); zconf_nextfile((yyvsp[-1].string)); free((yyvsp[-1].string)); } - break; - case 69: - - { + case 70: /* comment: T_COMMENT T_WORD_QUOTE T_EOL */ +{ menu_add_entry(NULL); menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL); printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); } - break; - case 73: - - { + case 74: /* help_start: T_HELP T_EOL */ +{ printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); zconf_starthelp(); } - break; - case 74: - - { + case 75: /* help: help_start T_HELPTEXT */ +{ /* Is the help text empty or all whitespace? */ if ((yyvsp[0].string)[strspn((yyvsp[0].string), " \f\n\r\t\v")] == '\0') zconfprint("warning: '%s' defined with blank help text", @@ -1832,176 +1633,121 @@ yyreduce: current_entry->help = (yyvsp[0].string); } - break; - case 75: - - { + case 76: /* depends: T_DEPENDS T_ON expr T_EOL */ +{ menu_add_dep((yyvsp[-1].expr)); printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); } - break; - case 76: - - { + case 77: /* visible: T_VISIBLE if_expr T_EOL */ +{ menu_add_visibility((yyvsp[-1].expr)); } - break; - case 78: - - { + case 79: /* prompt_stmt_opt: T_WORD_QUOTE if_expr */ +{ menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr)); } - break; - case 79: - - { (yyval.string) = "menu"; } - + case 80: /* end: T_ENDMENU T_EOL */ + { (yyval.string) = "menu"; } break; - case 80: - - { (yyval.string) = "choice"; } - + case 81: /* end: T_ENDCHOICE T_EOL */ + { (yyval.string) = "choice"; } break; - case 81: - - { (yyval.string) = "if"; } - + case 82: /* end: T_ENDIF T_EOL */ + { (yyval.string) = "if"; } break; - case 82: - - { (yyval.expr) = NULL; } - + case 83: /* if_expr: %empty */ + { (yyval.expr) = NULL; } break; - case 83: - - { (yyval.expr) = (yyvsp[0].expr); } - + case 84: /* if_expr: T_IF expr */ + { (yyval.expr) = (yyvsp[0].expr); } break; - case 84: - - { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); } - + case 85: /* expr: symbol */ + { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); } break; - case 85: - - { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } - + case 86: /* expr: symbol T_LESS symbol */ + { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 86: - - { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } - + case 87: /* expr: symbol T_LESS_EQUAL symbol */ + { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 87: - - { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } - + case 88: /* expr: symbol T_GREATER symbol */ + { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 88: - - { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } - + case 89: /* expr: symbol T_GREATER_EQUAL symbol */ + { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 89: - - { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } - + case 90: /* expr: symbol T_EQUAL symbol */ + { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 90: - - { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } - + case 91: /* expr: symbol T_UNEQUAL symbol */ + { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 91: - - { (yyval.expr) = (yyvsp[-1].expr); } - + case 92: /* expr: T_OPEN_PAREN expr T_CLOSE_PAREN */ + { (yyval.expr) = (yyvsp[-1].expr); } break; - case 92: - - { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); } - + case 93: /* expr: T_NOT expr */ + { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); } break; - case 93: - - { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); } - + case 94: /* expr: expr T_OR expr */ + { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); } break; - case 94: - - { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); } - + case 95: /* expr: expr T_AND expr */ + { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); } break; - case 95: - - { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); } - + case 96: /* nonconst_symbol: T_WORD */ + { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); } break; - case 97: - - { (yyval.symbol) = sym_lookup((yyvsp[0].string), SYMBOL_CONST); free((yyvsp[0].string)); } - + case 98: /* symbol: T_WORD_QUOTE */ + { (yyval.symbol) = sym_lookup((yyvsp[0].string), SYMBOL_CONST); free((yyvsp[0].string)); } break; - case 98: - - { (yyval.string) = NULL; } - + case 99: /* word_opt: %empty */ + { (yyval.string) = NULL; } break; - case 100: - - { variable_add((yyvsp[-3].string), (yyvsp[-1].string), (yyvsp[-2].flavor)); free((yyvsp[-3].string)); free((yyvsp[-1].string)); } - + case 101: /* assignment_stmt: T_WORD assign_op assign_val T_EOL */ + { variable_add((yyvsp[-3].string), (yyvsp[-1].string), (yyvsp[-2].flavor)); free((yyvsp[-3].string)); free((yyvsp[-1].string)); } break; - case 101: - - { (yyval.flavor) = VAR_RECURSIVE; } - + case 102: /* assign_op: T_EQUAL */ + { (yyval.flavor) = VAR_RECURSIVE; } break; - case 102: - - { (yyval.flavor) = VAR_SIMPLE; } - + case 103: /* assign_op: T_COLON_EQUAL */ + { (yyval.flavor) = VAR_SIMPLE; } break; - case 103: - - { (yyval.flavor) = VAR_APPEND; } - + case 104: /* assign_op: T_PLUS_EQUAL */ + { (yyval.flavor) = VAR_APPEND; } break; - case 104: - - { (yyval.string) = xstrdup(""); } - + case 105: /* assign_val: %empty */ + { (yyval.string) = xstrdup(""); } break; @@ -2019,25 +1765,23 @@ yyreduce: case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -2048,50 +1792,14 @@ yyreduce: yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif } - - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an @@ -2120,12 +1828,10 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2142,13 +1848,14 @@ yyerrorlab: yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -2162,7 +1869,7 @@ yyerrlab1: yydestruct ("Error: popping", - yystos[yystate], yyvsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -2174,7 +1881,7 @@ yyerrlab1: /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -2187,6 +1894,7 @@ yyacceptlab: yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -2194,16 +1902,21 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE + +#if !defined yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ + goto yyreturn; #endif + +/*-------------------------------------------------------. +| yyreturn -- parsing is finished, clean up and return. | +`-------------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2220,17 +1933,14 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } @@ -2271,7 +1981,7 @@ void conf_parse(const char *name) } if (yynerrs) exit(1); - sym_set_change_count(1); + conf_set_changed(true); } static bool zconf_endtoken(const char *tokenname, @@ -2477,5 +2187,3 @@ void zconfdump(FILE *out) } } } - -#include "menu.c" diff --git a/scripts/config/parser.tab.h b/scripts/config/parser.tab.h index d26b8bdcc..aac457ce3 100644 --- a/scripts/config/parser.tab.h +++ b/scripts/config/parser.tab.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.1. */ +/* A Bison parser, made by GNU Bison 3.7.6. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. 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 @@ -15,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -30,6 +31,10 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + #ifndef YY_YY_PARSER_TAB_H_INCLUDED # define YY_YY_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -40,72 +45,72 @@ extern int yydebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - T_HELPTEXT = 258, - T_WORD = 259, - T_WORD_QUOTE = 260, - T_ALLNOCONFIG_Y = 261, - T_BOOL = 262, - T_CHOICE = 263, - T_CLOSE_PAREN = 264, - T_COLON_EQUAL = 265, - T_COMMENT = 266, - T_CONFIG = 267, - T_DEFAULT = 268, - T_DEFCONFIG_LIST = 269, - T_DEF_BOOL = 270, - T_DEF_TRISTATE = 271, - T_DEPENDS = 272, - T_ENDCHOICE = 273, - T_ENDIF = 274, - T_ENDMENU = 275, - T_HELP = 276, - T_HEX = 277, - T_IF = 278, - T_IMPLY = 279, - T_INT = 280, - T_MAINMENU = 281, - T_MENU = 282, - T_MENUCONFIG = 283, - T_MODULES = 284, - T_ON = 285, - T_OPEN_PAREN = 286, - T_OPTION = 287, - T_OPTIONAL = 288, - T_PLUS_EQUAL = 289, - T_PROMPT = 290, - T_RANGE = 291, - T_RESET = 292, - T_SELECT = 293, - T_SOURCE = 294, - T_STRING = 295, - T_TRISTATE = 296, - T_VISIBLE = 297, - T_EOL = 298, - T_ASSIGN_VAL = 299, - T_OR = 300, - T_AND = 301, - T_EQUAL = 302, - T_UNEQUAL = 303, - T_LESS = 304, - T_LESS_EQUAL = 305, - T_GREATER = 306, - T_GREATER_EQUAL = 307, - T_NOT = 308 + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + T_HELPTEXT = 258, /* T_HELPTEXT */ + T_WORD = 259, /* T_WORD */ + T_WORD_QUOTE = 260, /* T_WORD_QUOTE */ + T_BOOL = 261, /* T_BOOL */ + T_CHOICE = 262, /* T_CHOICE */ + T_CLOSE_PAREN = 263, /* T_CLOSE_PAREN */ + T_COLON_EQUAL = 264, /* T_COLON_EQUAL */ + T_COMMENT = 265, /* T_COMMENT */ + T_CONFIG = 266, /* T_CONFIG */ + T_DEFAULT = 267, /* T_DEFAULT */ + T_DEF_BOOL = 268, /* T_DEF_BOOL */ + T_DEF_TRISTATE = 269, /* T_DEF_TRISTATE */ + T_DEPENDS = 270, /* T_DEPENDS */ + T_ENDCHOICE = 271, /* T_ENDCHOICE */ + T_ENDIF = 272, /* T_ENDIF */ + T_ENDMENU = 273, /* T_ENDMENU */ + T_HELP = 274, /* T_HELP */ + T_HEX = 275, /* T_HEX */ + T_IF = 276, /* T_IF */ + T_IMPLY = 277, /* T_IMPLY */ + T_INT = 278, /* T_INT */ + T_MAINMENU = 279, /* T_MAINMENU */ + T_MENU = 280, /* T_MENU */ + T_MENUCONFIG = 281, /* T_MENUCONFIG */ + T_MODULES = 282, /* T_MODULES */ + T_ON = 283, /* T_ON */ + T_OPEN_PAREN = 284, /* T_OPEN_PAREN */ + T_OPTIONAL = 285, /* T_OPTIONAL */ + T_PLUS_EQUAL = 286, /* T_PLUS_EQUAL */ + T_PROMPT = 287, /* T_PROMPT */ + T_RANGE = 288, /* T_RANGE */ + T_RESET = 289, /* T_RESET */ + T_SELECT = 290, /* T_SELECT */ + T_SOURCE = 291, /* T_SOURCE */ + T_STRING = 292, /* T_STRING */ + T_TRISTATE = 293, /* T_TRISTATE */ + T_VISIBLE = 294, /* T_VISIBLE */ + T_EOL = 295, /* T_EOL */ + T_ASSIGN_VAL = 296, /* T_ASSIGN_VAL */ + T_OR = 297, /* T_OR */ + T_AND = 298, /* T_AND */ + T_EQUAL = 299, /* T_EQUAL */ + T_UNEQUAL = 300, /* T_UNEQUAL */ + T_LESS = 301, /* T_LESS */ + T_LESS_EQUAL = 302, /* T_LESS_EQUAL */ + T_GREATER = 303, /* T_GREATER */ + T_GREATER_EQUAL = 304, /* T_GREATER_EQUAL */ + T_NOT = 305 /* T_NOT */ }; + typedef enum yytokentype yytoken_kind_t; #endif /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { - char *string; struct symbol *symbol; struct expr *expr; @@ -115,7 +120,6 @@ union YYSTYPE }; - typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 diff --git a/scripts/config/parser.y b/scripts/config/parser.y index 6b9de46c0..523c9a95a 100644 --- a/scripts/config/parser.y +++ b/scripts/config/parser.y @@ -12,6 +12,7 @@ #include #include "lkc.h" +#include "internal.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) @@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname, struct symbol *symbol_hash[SYMBOL_HASHSIZE]; -static struct menu *current_menu, *current_entry; +struct menu *current_menu, *current_entry; %} @@ -45,7 +46,6 @@ static struct menu *current_menu, *current_entry; %token T_HELPTEXT %token T_WORD %token T_WORD_QUOTE -%token T_ALLNOCONFIG_Y %token T_BOOL %token T_CHOICE %token T_CLOSE_PAREN @@ -53,7 +53,6 @@ static struct menu *current_menu, *current_entry; %token T_COMMENT %token T_CONFIG %token T_DEFAULT -%token T_DEFCONFIG_LIST %token T_DEF_BOOL %token T_DEF_TRISTATE %token T_DEPENDS @@ -71,7 +70,6 @@ static struct menu *current_menu, *current_entry; %token T_MODULES %token T_ON %token T_OPEN_PAREN -%token T_OPTION %token T_OPTIONAL %token T_PLUS_EQUAL %token T_PROMPT @@ -120,20 +118,24 @@ mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL stmt_list: /* empty */ - | stmt_list common_stmt + | stmt_list assignment_stmt | stmt_list choice_stmt + | stmt_list comment_stmt + | stmt_list config_stmt + | stmt_list if_stmt | stmt_list menu_stmt + | stmt_list menuconfig_stmt + | stmt_list source_stmt | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } | stmt_list error T_EOL { zconf_error("invalid statement"); } ; -common_stmt: - if_stmt - | comment_stmt - | config_stmt - | menuconfig_stmt - | source_stmt - | assignment_stmt +stmt_list_in_choice: + /* empty */ + | stmt_list_in_choice comment_stmt + | stmt_list_in_choice config_stmt + | stmt_list_in_choice if_stmt_in_choice + | stmt_list_in_choice error T_EOL { zconf_error("invalid statement"); } ; /* config/menuconfig entry */ @@ -215,19 +217,12 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; -config_option: T_OPTION T_MODULES T_EOL +config_option: T_MODULES T_EOL { - menu_add_option_modules(); -}; - -config_option: T_OPTION T_DEFCONFIG_LIST T_EOL -{ - menu_add_option_defconfig_list(); -}; - -config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL -{ - menu_add_option_allnoconfig_y(); + if (modules_sym) + zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'", + current_entry->sym->name, modules_sym->name); + modules_sym = current_entry->sym; }; /* choice entry */ @@ -255,7 +250,7 @@ choice_end: end } }; -choice_stmt: choice_entry choice_block choice_end +choice_stmt: choice_entry stmt_list_in_choice choice_end ; choice_option_list: @@ -311,11 +306,6 @@ default: | T_DEF_BOOL { $$ = S_BOOLEAN; } | T_DEF_TRISTATE { $$ = S_TRISTATE; } -choice_block: - /* empty */ - | choice_block common_stmt -; - /* if entry */ if_entry: T_IF expr T_EOL @@ -337,6 +327,9 @@ if_end: end if_stmt: if_entry stmt_list if_end ; +if_stmt_in_choice: if_entry stmt_list_in_choice if_end +; + /* menu entry */ menu: T_MENU T_WORD_QUOTE T_EOL @@ -517,7 +510,7 @@ void conf_parse(const char *name) } if (yynerrs) exit(1); - sym_set_change_count(1); + conf_set_changed(true); } static bool zconf_endtoken(const char *tokenname, @@ -723,5 +716,3 @@ void zconfdump(FILE *out) } } } - -#include "menu.c" diff --git a/scripts/config/preprocess.c b/scripts/config/preprocess.c index 92bed1725..3c7a35a72 100644 --- a/scripts/config/preprocess.c +++ b/scripts/config/preprocess.c @@ -114,7 +114,7 @@ static char *do_error_if(int argc, char *argv[]) if (!strcmp(argv[0], "y")) pperror("%s", argv[1]); - return NULL; + return xstrdup(""); } static char *do_filename(int argc, char *argv[]) diff --git a/scripts/config/qconf-cfg.sh b/scripts/config/qconf-cfg.sh index ebbc7ab47..609bb818e 100755 --- a/scripts/config/qconf-cfg.sh +++ b/scripts/config/qconf-cfg.sh @@ -2,7 +2,6 @@ # SPDX-License-Identifier: GPL-2.0-only PKG="Qt5Core Qt5Gui Qt5Widgets" -PKG2="QtCore QtGui" if [ -z "$(command -v pkg-config)" ]; then echo >&2 "*" @@ -12,21 +11,14 @@ if [ -z "$(command -v pkg-config)" ]; then fi if pkg-config --exists $PKG; then - echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\" + echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags $PKG)\" echo libs=\"$(pkg-config --libs $PKG)\" echo moc=\"$(pkg-config --variable=host_bins Qt5Core)/moc\" exit 0 fi -if pkg-config --exists $PKG2; then - echo cflags=\"$(pkg-config --cflags $PKG2)\" - echo libs=\"$(pkg-config --libs $PKG2)\" - echo moc=\"$(pkg-config --variable=moc_location QtCore)\" - exit 0 -fi - echo >&2 "*" -echo >&2 "* Could not find Qt via pkg-config." -echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH" +echo >&2 "* Could not find Qt5 via pkg-config." +echo >&2 "* Please install Qt5 and make sure it's in PKG_CONFIG_PATH" echo >&2 "*" exit 1 diff --git a/scripts/config/qconf.cc b/scripts/config/qconf.cc index a1e4d263e..ed7b3e3e2 100644 --- a/scripts/config/qconf.cc +++ b/scripts/config/qconf.cc @@ -4,34 +4,25 @@ * Copyright (C) 2015 Boris Barbulovski */ -#include - -#include -#include -#include #include +#include +#include +#include +#include #include +#include +#include +#include #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include #include "lkc.h" #include "qconf.h" -#include "qconf.moc" #include "images.h" @@ -40,11 +31,6 @@ static ConfigSettings *configSettings; QAction *ConfigMainWindow::saveAction; -static inline QString qgettext(const char* str) -{ - return QString::fromLocal8Bit(str); -} - ConfigSettings::ConfigSettings() : QSettings("kernel.org", "qconf") { @@ -88,14 +74,13 @@ bool ConfigSettings::writeSizes(const QString& key, const QList& value) return true; } - -/* - * set the new data - * TODO check the value - */ -void ConfigItem::okRename(int col) -{ -} +QIcon ConfigItem::symbolYesIcon; +QIcon ConfigItem::symbolModIcon; +QIcon ConfigItem::symbolNoIcon; +QIcon ConfigItem::choiceYesIcon; +QIcon ConfigItem::choiceNoIcon; +QIcon ConfigItem::menuIcon; +QIcon ConfigItem::menubackIcon; /* * update the displayed of a menu entry @@ -111,14 +96,14 @@ void ConfigItem::updateMenu(void) list = listView(); if (goParent) { - setPixmap(promptColIdx, list->menuBackPix); + setIcon(promptColIdx, menubackIcon); prompt = ".."; goto set_prompt; } sym = menu->sym; prop = menu->prompt; - prompt = qgettext(menu_get_prompt(menu)); + prompt = menu_get_prompt(menu); if (prop) switch (prop->type) { case P_MENU: @@ -128,15 +113,16 @@ void ConfigItem::updateMenu(void) */ if (sym && list->rootEntry == menu) break; - setPixmap(promptColIdx, list->menuPix); + setIcon(promptColIdx, menuIcon); } else { if (sym) break; - setPixmap(promptColIdx, QIcon()); + setIcon(promptColIdx, QIcon()); } goto set_prompt; case P_COMMENT: - setPixmap(promptColIdx, QIcon()); + setIcon(promptColIdx, QIcon()); + prompt = "*** " + prompt + " ***"; goto set_prompt; default: ; @@ -144,7 +130,7 @@ void ConfigItem::updateMenu(void) if (!sym) goto set_prompt; - setText(nameColIdx, QString::fromLocal8Bit(sym->name)); + setText(nameColIdx, sym->name); type = sym_get_type(sym); switch (type) { @@ -153,57 +139,37 @@ void ConfigItem::updateMenu(void) char ch; if (!sym_is_changeable(sym) && list->optMode == normalOpt) { - setPixmap(promptColIdx, QIcon()); - setText(noColIdx, QString::null); - setText(modColIdx, QString::null); - setText(yesColIdx, QString::null); + setIcon(promptColIdx, QIcon()); break; } expr = sym_get_tristate_value(sym); switch (expr) { case yes: if (sym_is_choice_value(sym) && type == S_BOOLEAN) - setPixmap(promptColIdx, list->choiceYesPix); + setIcon(promptColIdx, choiceYesIcon); else - setPixmap(promptColIdx, list->symbolYesPix); - setText(yesColIdx, "Y"); + setIcon(promptColIdx, symbolYesIcon); ch = 'Y'; break; case mod: - setPixmap(promptColIdx, list->symbolModPix); - setText(modColIdx, "M"); + setIcon(promptColIdx, symbolModIcon); ch = 'M'; break; default: if (sym_is_choice_value(sym) && type == S_BOOLEAN) - setPixmap(promptColIdx, list->choiceNoPix); + setIcon(promptColIdx, choiceNoIcon); else - setPixmap(promptColIdx, list->symbolNoPix); - setText(noColIdx, "N"); + setIcon(promptColIdx, symbolNoIcon); ch = 'N'; break; } - if (expr != no) - setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); - if (expr != mod) - setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); - if (expr != yes) - setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); setText(dataColIdx, QChar(ch)); break; case S_INT: case S_HEX: case S_STRING: - const char* data; - - data = sym_get_string_value(sym); - - setText(dataColIdx, data); - if (type == S_STRING) - prompt = QString("%1: %2").arg(prompt).arg(data); - else - prompt = QString("(%2) %1").arg(prompt).arg(data); + setText(dataColIdx, sym_get_string_value(sym)); break; } if (!sym_has_value(sym) && visible) @@ -244,6 +210,17 @@ void ConfigItem::init(void) if (list->mode != fullMode) setExpanded(true); sym_calc_value(menu->sym); + + if (menu->sym) { + enum symbol_type type = menu->sym->type; + + // Allow to edit "int", "hex", and "string" in-place in + // the data column. Unfortunately, you cannot specify + // the flags per column. Set ItemIsEditable for all + // columns here, and check the column in createEditor(). + if (type == S_INT || type == S_HEX || type == S_STRING) + setFlags(flags() | Qt::ItemIsEditable); + } } updateMenu(); } @@ -264,53 +241,67 @@ ConfigItem::~ConfigItem(void) } } -ConfigLineEdit::ConfigLineEdit(ConfigView* parent) - : Parent(parent) +QWidget *ConfigItemDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const { - connect(this, SIGNAL(editingFinished()), SLOT(hide())); + ConfigItem *item; + + // Only the data column is editable + if (index.column() != dataColIdx) + return nullptr; + + // You cannot edit invisible menus + item = static_cast(index.internalPointer()); + if (!item || !item->menu || !menu_is_visible(item->menu)) + return nullptr; + + return QStyledItemDelegate::createEditor(parent, option, index); } -void ConfigLineEdit::show(ConfigItem* i) +void ConfigItemDelegate::setModelData(QWidget *editor, + QAbstractItemModel *model, + const QModelIndex &index) const { - item = i; - if (sym_get_string_value(item->menu->sym)) - setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym))); - else - setText(QString::null); - Parent::show(); - setFocus(); -} + QLineEdit *lineEdit; + ConfigItem *item; + struct symbol *sym; + bool success; -void ConfigLineEdit::keyPressEvent(QKeyEvent* e) -{ - switch (e->key()) { - case Qt::Key_Escape: - break; - case Qt::Key_Return: - case Qt::Key_Enter: - sym_set_string_value(item->menu->sym, text().toLatin1()); - parent()->updateList(item); - break; - default: - Parent::keyPressEvent(e); - return; + lineEdit = qobject_cast(editor); + // If this is not a QLineEdit, use the parent's default. + // (does this happen?) + if (!lineEdit) + goto parent; + + item = static_cast(index.internalPointer()); + if (!item || !item->menu) + goto parent; + + sym = item->menu->sym; + if (!sym) + goto parent; + + success = sym_set_string_value(sym, lineEdit->text().toUtf8().data()); + if (success) { + ConfigList::updateListForAll(); + } else { + QMessageBox::information(editor, "qconf", + "Cannot set the data (maybe due to out of range).\n" + "Setting the old value."); + lineEdit->setText(sym_get_string_value(sym)); } - e->accept(); - parent()->list->setFocus(); - hide(); + +parent: + QStyledItemDelegate::setModelData(editor, model, index); } -ConfigList::ConfigList(ConfigView* p, const char *name) - : Parent(p), +ConfigList::ConfigList(QWidget *parent, const char *name) + : QTreeWidget(parent), updateAll(false), - symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), - choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), - menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), - showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt), + showName(false), mode(singleMode), optMode(normalOpt), rootEntry(0), headerPopup(0) { - int i; - setObjectName(name); setSortingEnabled(false); setRootIsDecorated(true); @@ -318,26 +309,34 @@ ConfigList::ConfigList(ConfigView* p, const char *name) setVerticalScrollMode(ScrollPerPixel); setHorizontalScrollMode(ScrollPerPixel); - setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); + setHeaderLabels(QStringList() << "Option" << "Name" << "Value"); - connect(this, SIGNAL(itemSelectionChanged(void)), - SLOT(updateSelection(void))); + connect(this, &ConfigList::itemSelectionChanged, + this, &ConfigList::updateSelection); if (name) { configSettings->beginGroup(name); showName = configSettings->value("/showName", false).toBool(); - showRange = configSettings->value("/showRange", false).toBool(); - showData = configSettings->value("/showData", false).toBool(); optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt(); configSettings->endGroup(); - connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); + connect(configApp, &QApplication::aboutToQuit, + this, &ConfigList::saveSettings); } - addColumn(promptColIdx); + showColumn(promptColIdx); + + setItemDelegate(new ConfigItemDelegate(this)); + + allLists.append(this); reinit(); } +ConfigList::~ConfigList() +{ + allLists.removeOne(this); +} + bool ConfigList::menuSkip(struct menu *menu) { if (optMode == normalOpt && menu_is_visible(menu)) @@ -351,21 +350,22 @@ bool ConfigList::menuSkip(struct menu *menu) void ConfigList::reinit(void) { - removeColumn(dataColIdx); - removeColumn(yesColIdx); - removeColumn(modColIdx); - removeColumn(noColIdx); - removeColumn(nameColIdx); + hideColumn(nameColIdx); if (showName) - addColumn(nameColIdx); - if (showRange) { - addColumn(noColIdx); - addColumn(modColIdx); - addColumn(yesColIdx); - } - if (showData) - addColumn(dataColIdx); + showColumn(nameColIdx); + + updateListAll(); +} + +void ConfigList::setOptionMode(QAction *action) +{ + if (action == showNormalAction) + optMode = normalOpt; + else if (action == showAllAction) + optMode = allOpt; + else + optMode = promptOpt; updateListAll(); } @@ -375,8 +375,6 @@ void ConfigList::saveSettings(void) if (!objectName().isEmpty()) { configSettings->beginGroup(objectName()); configSettings->setValue("/showName", showName); - configSettings->setValue("/showRange", showRange); - configSettings->setValue("/showData", showData); configSettings->setValue("/optionMode", (int)optMode); configSettings->endGroup(); } @@ -415,15 +413,15 @@ void ConfigList::updateSelection(void) emit menuSelected(menu); } -void ConfigList::updateList(ConfigItem* item) +void ConfigList::updateList() { ConfigItem* last = 0; + ConfigItem *item; if (!rootEntry) { if (mode != listMode) goto update; QTreeWidgetItemIterator it(this); - ConfigItem* item; while (*it) { item = (ConfigItem*)(*it); @@ -445,7 +443,7 @@ void ConfigList::updateList(ConfigItem* item) } if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) && rootEntry->sym && rootEntry->prompt) { - item = last ? last->nextSibling() : firstChild(); + item = last ? last->nextSibling() : nullptr; if (!item) item = new ConfigItem(this, last, rootEntry, true); else @@ -457,11 +455,33 @@ void ConfigList::updateList(ConfigItem* item) return; } update: - updateMenuList(this, rootEntry); + updateMenuList(rootEntry); update(); resizeColumnToContents(0); } +void ConfigList::updateListForAll() +{ + QListIterator it(allLists); + + while (it.hasNext()) { + ConfigList *list = it.next(); + + list->updateList(); + } +} + +void ConfigList::updateListAllForAll() +{ + QListIterator it(allLists); + + while (it.hasNext()) { + ConfigList *list = it.next(); + + list->updateList(); + } +} + void ConfigList::setValue(ConfigItem* item, tristate val) { struct symbol* sym; @@ -482,7 +502,7 @@ void ConfigList::setValue(ConfigItem* item, tristate val) return; if (oldval == no && item->menu->list) item->setExpanded(true); - parent()->updateList(item); + ConfigList::updateListForAll(); break; } } @@ -516,12 +536,9 @@ void ConfigList::changeValue(ConfigItem* item) item->setExpanded(true); } if (oldexpr != newexpr) - parent()->updateList(item); + ConfigList::updateListForAll(); break; - case S_INT: - case S_HEX: - case S_STRING: - parent()->lineEdit->show(item); + default: break; } } @@ -535,11 +552,11 @@ void ConfigList::setRootMenu(struct menu *menu) type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; if (type != P_MENU) return; - updateMenuList(this, 0); + updateMenuList(0); rootEntry = menu; updateListAll(); if (currentItem()) { - currentItem()->setSelected(hasFocus()); + setSelected(currentItem(), hasFocus()); scrollToItem(currentItem()); } } @@ -627,7 +644,7 @@ void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu) last = item; continue; } - hide: +hide: if (item && item->menu == child) { last = parent->firstChild(); if (last == item) @@ -639,7 +656,7 @@ void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu) } } -void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) +void ConfigList::updateMenuList(struct menu *menu) { struct menu* child; ConfigItem* item; @@ -648,19 +665,19 @@ void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) enum prop_type type; if (!menu) { - while (parent->topLevelItemCount() > 0) + while (topLevelItemCount() > 0) { - delete parent->takeTopLevelItem(0); + delete takeTopLevelItem(0); } return; } - last = (ConfigItem*)parent->topLevelItem(0); + last = (ConfigItem *)topLevelItem(0); if (last && !last->goParent) last = 0; for (child = menu->list; child; child = child->next) { - item = last ? last->nextSibling() : (ConfigItem*)parent->topLevelItem(0); + item = last ? last->nextSibling() : (ConfigItem *)topLevelItem(0); type = child->prompt ? child->prompt->type : P_UNKNOWN; switch (mode) { @@ -681,7 +698,7 @@ void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) if (!child->sym && !child->list && !child->prompt) continue; if (!item || item->menu != child) - item = new ConfigItem(parent, last, child, visible); + item = new ConfigItem(this, last, child, visible); else item->testUpdateMenu(visible); @@ -692,9 +709,9 @@ void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) last = item; continue; } - hide: +hide: if (item && item->menu == child) { - last = (ConfigItem*)parent->topLevelItem(0); + last = (ConfigItem *)topLevelItem(0); if (last == item) last = 0; else while (last->nextSibling() != item) @@ -736,7 +753,10 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) type = menu->prompt ? menu->prompt->type : P_UNKNOWN; if (type == P_MENU && rootEntry != menu && mode != fullMode && mode != menuMode) { - emit menuSelected(menu); + if (mode == menuMode) + emit menuSelected(menu); + else + emit itemSelected(menu); break; } case Qt::Key_Space: @@ -782,7 +802,7 @@ void ConfigList::mouseReleaseEvent(QMouseEvent* e) idx = header()->logicalIndexAt(x); switch (idx) { case promptColIdx: - icon = item->pixmap(promptColIdx); + icon = item->icon(promptColIdx); if (!icon.isNull()) { int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly. if (x >= off && x < off + icon.availableSizes().first().width()) { @@ -793,22 +813,14 @@ void ConfigList::mouseReleaseEvent(QMouseEvent* e) break; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; if (ptype == P_MENU && rootEntry != menu && - mode != fullMode && mode != menuMode) + mode != fullMode && mode != menuMode && + mode != listMode) emit menuSelected(menu); else changeValue(item); } } break; - case noColIdx: - setValue(item, no); - break; - case modColIdx: - setValue(item, mod); - break; - case yesColIdx: - setValue(item, yes); - break; case dataColIdx: changeValue(item); break; @@ -828,7 +840,7 @@ void ConfigList::mouseMoveEvent(QMouseEvent* e) void ConfigList::mouseDoubleClickEvent(QMouseEvent* e) { - QPoint p = e->pos(); // TODO: Check if this works(was contentsToViewport). + QPoint p = e->pos(); ConfigItem* item = (ConfigItem*)itemAt(p); struct menu *menu; enum prop_type ptype; @@ -843,9 +855,12 @@ void ConfigList::mouseDoubleClickEvent(QMouseEvent* e) if (!menu) goto skip; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; - if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) - emit menuSelected(menu); - else if (menu->sym) + if (ptype == P_MENU && mode != listMode) { + if (mode == singleMode) + emit itemSelected(menu); + else if (mode == symbolMode) + emit menuSelected(menu); + } else if (menu->sym) changeValue(item); skip: @@ -861,7 +876,7 @@ void ConfigList::focusInEvent(QFocusEvent *e) ConfigItem* item = (ConfigItem *)currentItem(); if (item) { - item->setSelected(true); + setSelected(item, true); menu = item->menu; } emit gotFocus(menu); @@ -869,114 +884,38 @@ void ConfigList::focusInEvent(QFocusEvent *e) void ConfigList::contextMenuEvent(QContextMenuEvent *e) { - if (e->y() <= header()->geometry().bottom()) { - if (!headerPopup) { - QAction *action; + if (!headerPopup) { + QAction *action; - headerPopup = new QMenu(this); - action = new QAction("Show Name", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowName(bool))); - connect(parent(), SIGNAL(showNameChanged(bool)), - action, SLOT(setOn(bool))); - action->setChecked(showName); - headerPopup->addAction(action); - action = new QAction("Show Range", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowRange(bool))); - connect(parent(), SIGNAL(showRangeChanged(bool)), - action, SLOT(setOn(bool))); - action->setChecked(showRange); - headerPopup->addAction(action); - action = new QAction("Show Data", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowData(bool))); - connect(parent(), SIGNAL(showDataChanged(bool)), - action, SLOT(setOn(bool))); - action->setChecked(showData); - headerPopup->addAction(action); - } - headerPopup->exec(e->globalPos()); - e->accept(); - } else - e->ignore(); -} - -ConfigView*ConfigView::viewList; -QAction *ConfigView::showNormalAction; -QAction *ConfigView::showAllAction; -QAction *ConfigView::showPromptAction; - -ConfigView::ConfigView(QWidget* parent, const char *name) - : Parent(parent) -{ - setObjectName(name); - QVBoxLayout *verticalLayout = new QVBoxLayout(this); - verticalLayout->setContentsMargins(0, 0, 0, 0); - - list = new ConfigList(this); - verticalLayout->addWidget(list); - lineEdit = new ConfigLineEdit(this); - lineEdit->hide(); - verticalLayout->addWidget(lineEdit); - - this->nextView = viewList; - viewList = this; -} - -ConfigView::~ConfigView(void) -{ - ConfigView** vp; - - for (vp = &viewList; *vp; vp = &(*vp)->nextView) { - if (*vp == this) { - *vp = nextView; - break; - } + headerPopup = new QMenu(this); + action = new QAction("Show Name", this); + action->setCheckable(true); + connect(action, &QAction::toggled, + this, &ConfigList::setShowName); + connect(this, &ConfigList::showNameChanged, + action, &QAction::setChecked); + action->setChecked(showName); + headerPopup->addAction(action); } + + headerPopup->exec(e->globalPos()); + e->accept(); } -void ConfigView::setOptionMode(QAction *act) +void ConfigList::setShowName(bool on) { - if (act == showNormalAction) - list->optMode = normalOpt; - else if (act == showAllAction) - list->optMode = allOpt; - else - list->optMode = promptOpt; + if (showName == on) + return; - list->updateListAll(); + showName = on; + reinit(); + emit showNameChanged(on); } -void ConfigView::setShowName(bool b) -{ - if (list->showName != b) { - list->showName = b; - list->reinit(); - emit showNameChanged(b); - } -} - -void ConfigView::setShowRange(bool b) -{ - if (list->showRange != b) { - list->showRange = b; - list->reinit(); - emit showRangeChanged(b); - } -} - -void ConfigView::setShowData(bool b) -{ - if (list->showData != b) { - list->showData = b; - list->reinit(); - emit showDataChanged(b); - } -} +QList ConfigList::allLists; +QAction *ConfigList::showNormalAction; +QAction *ConfigList::showAllAction; +QAction *ConfigList::showPromptAction; void ConfigList::setAllOpen(bool open) { @@ -989,34 +928,31 @@ void ConfigList::setAllOpen(bool open) } } -void ConfigView::updateList(ConfigItem* item) -{ - ConfigView* v; - - for (v = viewList; v; v = v->nextView) - v->list->updateList(item); -} - -void ConfigView::updateListAll(void) -{ - ConfigView* v; - - for (v = viewList; v; v = v->nextView) - v->list->updateListAll(); -} - ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) : Parent(parent), sym(0), _menu(0) { setObjectName(name); - + setOpenLinks(false); if (!objectName().isEmpty()) { configSettings->beginGroup(objectName()); setShowDebug(configSettings->value("/showDebug", false).toBool()); configSettings->endGroup(); - connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); + connect(configApp, &QApplication::aboutToQuit, + this, &ConfigInfoView::saveSettings); } + + contextMenu = createStandardContextMenu(); + QAction *action = new QAction("Show Debug Info", contextMenu); + + action->setCheckable(true); + connect(action, &QAction::toggled, + this, &ConfigInfoView::setShowDebug); + connect(this, &ConfigInfoView::showDebugChanged, + action, &QAction::setChecked); + action->setChecked(showDebug()); + contextMenu->addSeparator(); + contextMenu->addAction(action); } void ConfigInfoView::saveSettings(void) @@ -1071,108 +1007,119 @@ void ConfigInfoView::symbolInfo(void) void ConfigInfoView::menuInfo(void) { struct symbol* sym; - QString head, debug, help; + QString info; + QTextStream stream(&info); sym = _menu->sym; if (sym) { if (_menu->prompt) { - head += ""; - head += print_filter(_menu->prompt->text); - head += ""; + stream << ""; + stream << print_filter(_menu->prompt->text); + stream << ""; if (sym->name) { - head += " ("; + stream << " ("; if (showDebug()) - head += QString().sprintf("", sym); - head += print_filter(sym->name); + stream << "name << "\">"; + stream << print_filter(sym->name); if (showDebug()) - head += ""; - head += ")"; + stream << ""; + stream << ")"; } } else if (sym->name) { - head += ""; + stream << ""; if (showDebug()) - head += QString().sprintf("", sym); - head += print_filter(sym->name); + stream << "name << "\">"; + stream << print_filter(sym->name); if (showDebug()) - head += ""; - head += ""; + stream << ""; + stream << ""; } - head += "

"; + stream << "

"; if (showDebug()) - debug = debug_info(sym); + stream << debug_info(sym); struct gstr help_gstr = str_new(); + menu_get_ext_help(_menu, &help_gstr); - help = print_filter(str_get(&help_gstr)); + stream << print_filter(str_get(&help_gstr)); str_free(&help_gstr); } else if (_menu->prompt) { - head += ""; - head += print_filter(_menu->prompt->text); - head += "

"; + stream << ""; + stream << print_filter(_menu->prompt->text); + stream << "

"; if (showDebug()) { if (_menu->prompt->visible.expr) { - debug += "  dep: "; - expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); - debug += "

"; + stream << "  dep: "; + expr_print(_menu->prompt->visible.expr, + expr_print_help, &stream, E_NONE); + stream << "

"; } + + stream << "defined at " << _menu->file->name << ":" + << _menu->lineno << "

"; } } - if (showDebug()) - debug += QString().sprintf("defined at %s:%d

", _menu->file->name, _menu->lineno); - setText(head + debug + help); + setText(info); } QString ConfigInfoView::debug_info(struct symbol *sym) { QString debug; + QTextStream stream(&debug); - debug += "type: "; - debug += print_filter(sym_type_name(sym->type)); + stream << "type: "; + stream << print_filter(sym_type_name(sym->type)); if (sym_is_choice(sym)) - debug += " (choice)"; + stream << " (choice)"; debug += "
"; if (sym->rev_dep.expr) { - debug += "reverse dep: "; - expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); - debug += "
"; + stream << "reverse dep: "; + expr_print(sym->rev_dep.expr, expr_print_help, &stream, E_NONE); + stream << "
"; } for (struct property *prop = sym->prop; prop; prop = prop->next) { switch (prop->type) { case P_PROMPT: case P_MENU: - debug += QString().sprintf("prompt: ", prop->menu); - debug += print_filter(prop->text); - debug += "
"; + stream << "prompt: name << "\">"; + stream << print_filter(prop->text); + stream << "
"; break; case P_DEFAULT: case P_SELECT: case P_RANGE: - debug += prop_get_type_name(prop->type); - debug += ": "; - expr_print(prop->expr, expr_print_help, &debug, E_NONE); - debug += "
"; + case P_COMMENT: + case P_IMPLY: + case P_SYMBOL: + stream << prop_get_type_name(prop->type); + stream << ": "; + expr_print(prop->expr, expr_print_help, + &stream, E_NONE); + stream << "
"; break; case P_CHOICE: if (sym_is_choice(sym)) { - debug += "choice: "; - expr_print(prop->expr, expr_print_help, &debug, E_NONE); - debug += "
"; + stream << "choice: "; + expr_print(prop->expr, expr_print_help, + &stream, E_NONE); + stream << "
"; } break; default: - debug += "unknown property: "; - debug += prop_get_type_name(prop->type); - debug += "
"; + stream << "unknown property: "; + stream << prop_get_type_name(prop->type); + stream << "
"; } if (prop->visible.expr) { - debug += "    dep: "; - expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); - debug += "
"; + stream << "    dep: "; + expr_print(prop->visible.expr, expr_print_help, + &stream, E_NONE); + stream << "
"; } } - debug += "
"; + stream << "
"; return debug; } @@ -1210,88 +1157,125 @@ QString ConfigInfoView::print_filter(const QString &str) void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str) { - QString* text = reinterpret_cast(data); - QString str2 = print_filter(str); + QTextStream *stream = reinterpret_cast(data); if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) { - *text += QString().sprintf("", sym); - *text += str2; - *text += ""; - } else - *text += str2; + *stream << "name << "\">"; + *stream << print_filter(str); + *stream << ""; + } else { + *stream << print_filter(str); + } } -QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos) +void ConfigInfoView::clicked(const QUrl &url) { - QMenu* popup = Parent::createStandardContextMenu(pos); - QAction* action = new QAction("Show Debug Info", popup); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); - connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); - action->setChecked(showDebug()); - popup->addSeparator(); - popup->addAction(action); - return popup; + QByteArray str = url.toEncoded(); + const std::size_t count = str.size(); + char *data = new char[count + 1]; + struct symbol **result; + struct menu *m = NULL; + + if (count < 1) { + delete[] data; + return; + } + + memcpy(data, str.constData(), count); + data[count] = '\0'; + + /* Seek for exact match */ + data[0] = '^'; + strcat(data, "$"); + result = sym_re_search(data); + if (!result) { + delete[] data; + return; + } + + sym = *result; + + /* Seek for the menu which holds the symbol */ + for (struct property *prop = sym->prop; prop; prop = prop->next) { + if (prop->type != P_PROMPT && prop->type != P_MENU) + continue; + m = prop->menu; + break; + } + + if (!m) { + /* Symbol is not visible as a menu */ + symbolInfo(); + emit showDebugChanged(true); + } else { + emit menuSelected(m); + } + + free(result); + delete[] data; } -void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e) +void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event) { - Parent::contextMenuEvent(e); + contextMenu->popup(event->globalPos()); + event->accept(); } -ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) +ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent) : Parent(parent), result(NULL) { - setObjectName(name); + setObjectName("search"); setWindowTitle("Search Config"); QVBoxLayout* layout1 = new QVBoxLayout(this); layout1->setContentsMargins(11, 11, 11, 11); layout1->setSpacing(6); - QHBoxLayout* layout2 = new QHBoxLayout(0); + + QHBoxLayout* layout2 = new QHBoxLayout(); layout2->setContentsMargins(0, 0, 0, 0); layout2->setSpacing(6); layout2->addWidget(new QLabel("Find:", this)); editField = new QLineEdit(this); - connect(editField, SIGNAL(returnPressed()), SLOT(search())); + connect(editField, &QLineEdit::returnPressed, + this, &ConfigSearchWindow::search); layout2->addWidget(editField); searchButton = new QPushButton("Search", this); searchButton->setAutoDefault(false); - connect(searchButton, SIGNAL(clicked()), SLOT(search())); + connect(searchButton, &QPushButton::clicked, + this, &ConfigSearchWindow::search); layout2->addWidget(searchButton); layout1->addLayout(layout2); split = new QSplitter(this); split->setOrientation(Qt::Vertical); - list = new ConfigView(split, name); - list->list->mode = listMode; - info = new ConfigInfoView(split, name); - connect(list->list, SIGNAL(menuChanged(struct menu *)), - info, SLOT(setInfo(struct menu *))); - connect(list->list, SIGNAL(menuChanged(struct menu *)), - parent, SLOT(setMenuLink(struct menu *))); + list = new ConfigList(split, "search"); + list->mode = listMode; + info = new ConfigInfoView(split, "search"); + connect(list, &ConfigList::menuChanged, + info, &ConfigInfoView::setInfo); + connect(list, &ConfigList::menuChanged, + parent, &ConfigMainWindow::setMenuLink); layout1->addWidget(split); - if (name) { - QVariant x, y; - int width, height; - bool ok; + QVariant x, y; + int width, height; + bool ok; - configSettings->beginGroup(name); - width = configSettings->value("/window width", parent->width() / 2).toInt(); - height = configSettings->value("/window height", parent->height() / 2).toInt(); - resize(width, height); - x = configSettings->value("/window x"); - y = configSettings->value("/window y"); - if ((x.isValid())&&(y.isValid())) - move(x.toInt(), y.toInt()); - QList sizes = configSettings->readSizes("/split", &ok); - if (ok) - split->setSizes(sizes); - configSettings->endGroup(); - connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); - } + configSettings->beginGroup("search"); + width = configSettings->value("/window width", parent->width() / 2).toInt(); + height = configSettings->value("/window height", parent->height() / 2).toInt(); + resize(width, height); + x = configSettings->value("/window x"); + y = configSettings->value("/window y"); + if (x.isValid() && y.isValid()) + move(x.toInt(), y.toInt()); + QList sizes = configSettings->readSizes("/split", &ok); + if (ok) + split->setSizes(sizes); + configSettings->endGroup(); + connect(configApp, &QApplication::aboutToQuit, + this, &ConfigSearchWindow::saveSettings); } void ConfigSearchWindow::saveSettings(void) @@ -1314,7 +1298,7 @@ void ConfigSearchWindow::search(void) ConfigItem *lastItem = NULL; free(result); - list->list->clear(); + list->clear(); info->clear(); result = sym_re_search(editField->text().toLatin1()); @@ -1322,7 +1306,7 @@ void ConfigSearchWindow::search(void) return; for (p = result; *p; p++) { for_all_prompts((*p), prop) - lastItem = new ConfigItem(list->list, lastItem, prop->menu, + lastItem = new ConfigItem(list, lastItem, prop->menu, menu_is_visible(prop->menu)); } } @@ -1333,7 +1317,6 @@ void ConfigSearchWindow::search(void) ConfigMainWindow::ConfigMainWindow(void) : searchWindow(0) { - QMenuBar* menu; bool ok = true; QVariant x, y; int width, height; @@ -1354,97 +1337,123 @@ ConfigMainWindow::ConfigMainWindow(void) if ((x.isValid())&&(y.isValid())) move(x.toInt(), y.toInt()); - split1 = new QSplitter(this); + // set up icons + ConfigItem::symbolYesIcon = QIcon(QPixmap(xpm_symbol_yes)); + ConfigItem::symbolModIcon = QIcon(QPixmap(xpm_symbol_mod)); + ConfigItem::symbolNoIcon = QIcon(QPixmap(xpm_symbol_no)); + ConfigItem::choiceYesIcon = QIcon(QPixmap(xpm_choice_yes)); + ConfigItem::choiceNoIcon = QIcon(QPixmap(xpm_choice_no)); + ConfigItem::menuIcon = QIcon(QPixmap(xpm_menu)); + ConfigItem::menubackIcon = QIcon(QPixmap(xpm_menuback)); + + QWidget *widget = new QWidget(this); + QVBoxLayout *layout = new QVBoxLayout(widget); + setCentralWidget(widget); + + split1 = new QSplitter(widget); split1->setOrientation(Qt::Horizontal); - setCentralWidget(split1); + split1->setChildrenCollapsible(false); - menuView = new ConfigView(split1, "menu"); - menuList = menuView->list; + menuList = new ConfigList(widget, "menu"); - split2 = new QSplitter(split1); + split2 = new QSplitter(widget); + split2->setChildrenCollapsible(false); split2->setOrientation(Qt::Vertical); // create config tree - configView = new ConfigView(split2, "config"); - configList = configView->list; + configList = new ConfigList(widget, "config"); - helpText = new ConfigInfoView(split2, "help"); + helpText = new ConfigInfoView(widget, "help"); + + layout->addWidget(split2); + split2->addWidget(split1); + split1->addWidget(configList); + split1->addWidget(menuList); + split2->addWidget(helpText); setTabOrder(configList, helpText); configList->setFocus(); - menu = menuBar(); - toolBar = new QToolBar("Tools", this); - addToolBar(toolBar); - backAction = new QAction(QPixmap(xpm_back), "Back", this); - connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack())); - backAction->setEnabled(false); + connect(backAction, &QAction::triggered, + this, &ConfigMainWindow::goBack); + QAction *quitAction = new QAction("&Quit", this); quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); - connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); + connect(quitAction, &QAction::triggered, + this, &ConfigMainWindow::close); + QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); loadAction->setShortcut(Qt::CTRL + Qt::Key_L); - connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); + connect(loadAction, &QAction::triggered, + this, &ConfigMainWindow::loadConfig); + saveAction = new QAction(QPixmap(xpm_save), "&Save", this); saveAction->setShortcut(Qt::CTRL + Qt::Key_S); - connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); + connect(saveAction, &QAction::triggered, + this, &ConfigMainWindow::saveConfig); + conf_set_changed_callback(conf_changed); + // Set saveAction's initial state conf_changed(); configname = xstrdup(conf_get_configname()); QAction *saveAsAction = new QAction("Save &As...", this); - connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs())); + connect(saveAsAction, &QAction::triggered, + this, &ConfigMainWindow::saveConfigAs); QAction *searchAction = new QAction("&Find", this); searchAction->setShortcut(Qt::CTRL + Qt::Key_F); - connect(searchAction, SIGNAL(triggered(bool)), SLOT(searchConfig())); + connect(searchAction, &QAction::triggered, + this, &ConfigMainWindow::searchConfig); singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this); singleViewAction->setCheckable(true); - connect(singleViewAction, SIGNAL(triggered(bool)), SLOT(showSingleView())); + connect(singleViewAction, &QAction::triggered, + this, &ConfigMainWindow::showSingleView); splitViewAction = new QAction(QPixmap(xpm_split_view), "Split View", this); splitViewAction->setCheckable(true); - connect(splitViewAction, SIGNAL(triggered(bool)), SLOT(showSplitView())); + connect(splitViewAction, &QAction::triggered, + this, &ConfigMainWindow::showSplitView); fullViewAction = new QAction(QPixmap(xpm_tree_view), "Full View", this); fullViewAction->setCheckable(true); - connect(fullViewAction, SIGNAL(triggered(bool)), SLOT(showFullView())); + connect(fullViewAction, &QAction::triggered, + this, &ConfigMainWindow::showFullView); QAction *showNameAction = new QAction("Show Name", this); showNameAction->setCheckable(true); - connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); - showNameAction->setChecked(configView->showName()); - QAction *showRangeAction = new QAction("Show Range", this); - showRangeAction->setCheckable(true); - connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); - QAction *showDataAction = new QAction("Show Data", this); - showDataAction->setCheckable(true); - connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); + connect(showNameAction, &QAction::toggled, + configList, &ConfigList::setShowName); + showNameAction->setChecked(configList->showName); QActionGroup *optGroup = new QActionGroup(this); optGroup->setExclusive(true); - connect(optGroup, SIGNAL(triggered(QAction*)), configView, - SLOT(setOptionMode(QAction *))); - connect(optGroup, SIGNAL(triggered(QAction *)), menuView, - SLOT(setOptionMode(QAction *))); + connect(optGroup, &QActionGroup::triggered, + configList, &ConfigList::setOptionMode); + connect(optGroup, &QActionGroup::triggered, + menuList, &ConfigList::setOptionMode); - configView->showNormalAction = new QAction("Show Normal Options", optGroup); - configView->showAllAction = new QAction("Show All Options", optGroup); - configView->showPromptAction = new QAction("Show Prompt Options", optGroup); - configView->showNormalAction->setCheckable(true); - configView->showAllAction->setCheckable(true); - configView->showPromptAction->setCheckable(true); + ConfigList::showNormalAction = new QAction("Show Normal Options", optGroup); + ConfigList::showNormalAction->setCheckable(true); + ConfigList::showAllAction = new QAction("Show All Options", optGroup); + ConfigList::showAllAction->setCheckable(true); + ConfigList::showPromptAction = new QAction("Show Prompt Options", optGroup); + ConfigList::showPromptAction->setCheckable(true); QAction *showDebugAction = new QAction("Show Debug Info", this); showDebugAction->setCheckable(true); - connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); + connect(showDebugAction, &QAction::toggled, + helpText, &ConfigInfoView::setShowDebug); showDebugAction->setChecked(helpText->showDebug()); QAction *showIntroAction = new QAction("Introduction", this); - connect(showIntroAction, SIGNAL(triggered(bool)), SLOT(showIntro())); + connect(showIntroAction, &QAction::triggered, + this, &ConfigMainWindow::showIntro); QAction *showAboutAction = new QAction("About", this); - connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout())); + connect(showAboutAction, &QAction::triggered, + this, &ConfigMainWindow::showAbout); // init tool bar + QToolBar *toolBar = addToolBar("Tools"); toolBar->addAction(backAction); toolBar->addSeparator(); toolBar->addAction(loadAction); @@ -1454,53 +1463,55 @@ ConfigMainWindow::ConfigMainWindow(void) toolBar->addAction(splitViewAction); toolBar->addAction(fullViewAction); - // create config menu - QMenu* config = menu->addMenu("&File"); - config->addAction(loadAction); - config->addAction(saveAction); - config->addAction(saveAsAction); - config->addSeparator(); - config->addAction(quitAction); + // create file menu + QMenu *menu = menuBar()->addMenu("&File"); + menu->addAction(loadAction); + menu->addAction(saveAction); + menu->addAction(saveAsAction); + menu->addSeparator(); + menu->addAction(quitAction); // create edit menu - QMenu* editMenu = menu->addMenu("&Edit"); - editMenu->addAction(searchAction); + menu = menuBar()->addMenu("&Edit"); + menu->addAction(searchAction); // create options menu - QMenu* optionMenu = menu->addMenu("&Option"); - optionMenu->addAction(showNameAction); - optionMenu->addAction(showRangeAction); - optionMenu->addAction(showDataAction); - optionMenu->addSeparator(); - optionMenu->addActions(optGroup->actions()); - optionMenu->addSeparator(); - optionMenu->addAction(showDebugAction); + menu = menuBar()->addMenu("&Option"); + menu->addAction(showNameAction); + menu->addSeparator(); + menu->addActions(optGroup->actions()); + menu->addSeparator(); + menu->addAction(showDebugAction); // create help menu - menu->addSeparator(); - QMenu* helpMenu = menu->addMenu("&Help"); - helpMenu->addAction(showIntroAction); - helpMenu->addAction(showAboutAction); + menu = menuBar()->addMenu("&Help"); + menu->addAction(showIntroAction); + menu->addAction(showAboutAction); - connect(configList, SIGNAL(menuChanged(struct menu *)), - helpText, SLOT(setInfo(struct menu *))); - connect(configList, SIGNAL(menuSelected(struct menu *)), - SLOT(changeMenu(struct menu *))); - connect(configList, SIGNAL(parentSelected()), - SLOT(goBack())); - connect(menuList, SIGNAL(menuChanged(struct menu *)), - helpText, SLOT(setInfo(struct menu *))); - connect(menuList, SIGNAL(menuSelected(struct menu *)), - SLOT(changeMenu(struct menu *))); + connect(helpText, &ConfigInfoView::anchorClicked, + helpText, &ConfigInfoView::clicked); - connect(configList, SIGNAL(gotFocus(struct menu *)), - helpText, SLOT(setInfo(struct menu *))); - connect(menuList, SIGNAL(gotFocus(struct menu *)), - helpText, SLOT(setInfo(struct menu *))); - connect(menuList, SIGNAL(gotFocus(struct menu *)), - SLOT(listFocusChanged(void))); - connect(helpText, SIGNAL(menuSelected(struct menu *)), - SLOT(setMenuLink(struct menu *))); + connect(configList, &ConfigList::menuChanged, + helpText, &ConfigInfoView::setInfo); + connect(configList, &ConfigList::menuSelected, + this, &ConfigMainWindow::changeMenu); + connect(configList, &ConfigList::itemSelected, + this, &ConfigMainWindow::changeItens); + connect(configList, &ConfigList::parentSelected, + this, &ConfigMainWindow::goBack); + connect(menuList, &ConfigList::menuChanged, + helpText, &ConfigInfoView::setInfo); + connect(menuList, &ConfigList::menuSelected, + this, &ConfigMainWindow::changeMenu); + + connect(configList, &ConfigList::gotFocus, + helpText, &ConfigInfoView::setInfo); + connect(menuList, &ConfigList::gotFocus, + helpText, &ConfigInfoView::setInfo); + connect(menuList, &ConfigList::gotFocus, + this, &ConfigMainWindow::listFocusChanged); + connect(helpText, &ConfigInfoView::menuSelected, + this, &ConfigMainWindow::setMenuLink); QString listMode = configSettings->value("/listMode", "symbol").toString(); if (listMode == "single") @@ -1539,7 +1550,7 @@ void ConfigMainWindow::loadConfig(void) free(configname); configname = xstrdup(name); - ConfigView::updateListAll(); + ConfigList::updateListAllForAll(); } bool ConfigMainWindow::saveConfig(void) @@ -1578,17 +1589,18 @@ void ConfigMainWindow::saveConfigAs(void) void ConfigMainWindow::searchConfig(void) { if (!searchWindow) - searchWindow = new ConfigSearchWindow(this, "search"); + searchWindow = new ConfigSearchWindow(this); searchWindow->show(); } +void ConfigMainWindow::changeItens(struct menu *menu) +{ + configList->setRootMenu(menu); +} + void ConfigMainWindow::changeMenu(struct menu *menu) { - configList->setRootMenu(menu); - if (configList->rootEntry->parent == &rootmenu) - backAction->setEnabled(false); - else - backAction->setEnabled(true); + menuList->setRootMenu(menu); } void ConfigMainWindow::setMenuLink(struct menu *menu) @@ -1608,22 +1620,26 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) return; list->setRootMenu(parent); break; - case symbolMode: + case menuMode: if (menu->flags & MENU_ROOT) { - configList->setRootMenu(menu); + menuList->setRootMenu(menu); configList->clearSelection(); - list = menuList; - } else { list = configList; + } else { parent = menu_get_parent_menu(menu->parent); if (!parent) return; - item = menuList->findConfigItem(parent); + + /* Select the config view */ + item = configList->findConfigItem(parent); if (item) { - item->setSelected(true); - menuList->scrollToItem(item); + configList->setSelected(item, true); + configList->scrollToItem(item); } - list->setRootMenu(parent); + + menuList->setRootMenu(parent); + menuList->clearSelection(); + list = menuList; } break; case fullMode: @@ -1636,9 +1652,10 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) if (list) { item = list->findConfigItem(menu); if (item) { - item->setSelected(true); + list->setSelected(item, true); list->scrollToItem(item); list->setFocus(); + helpText->setInfo(menu); } } } @@ -1651,25 +1668,10 @@ void ConfigMainWindow::listFocusChanged(void) void ConfigMainWindow::goBack(void) { - ConfigItem* item, *oldSelection; - - configList->setParentMenu(); if (configList->rootEntry == &rootmenu) - backAction->setEnabled(false); - - if (menuList->selectedItems().count() == 0) return; - item = (ConfigItem*)menuList->selectedItems().first(); - oldSelection = item; - while (item) { - if (item->menu == configList->rootEntry) { - oldSelection->setSelected(false); - item->setSelected(true); - break; - } - item = (ConfigItem*)item->parent(); - } + configList->setParentMenu(); } void ConfigMainWindow::showSingleView(void) @@ -1681,7 +1683,9 @@ void ConfigMainWindow::showSingleView(void) fullViewAction->setEnabled(true); fullViewAction->setChecked(false); - menuView->hide(); + backAction->setEnabled(true); + + menuList->hide(); menuList->setRootMenu(0); configList->mode = singleMode; if (configList->rootEntry == &rootmenu) @@ -1700,17 +1704,19 @@ void ConfigMainWindow::showSplitView(void) fullViewAction->setEnabled(true); fullViewAction->setChecked(false); - configList->mode = symbolMode; + backAction->setEnabled(false); + + configList->mode = menuMode; if (configList->rootEntry == &rootmenu) configList->updateListAll(); else configList->setRootMenu(&rootmenu); configList->setAllOpen(true); configApp->processEvents(); - menuList->mode = menuMode; + menuList->mode = symbolMode; menuList->setRootMenu(&rootmenu); menuList->setAllOpen(true); - menuView->show(); + menuList->show(); menuList->setFocus(); } @@ -1723,7 +1729,9 @@ void ConfigMainWindow::showFullView(void) fullViewAction->setEnabled(false); fullViewAction->setChecked(true); - menuView->hide(); + backAction->setEnabled(false); + + menuList->hide(); menuList->setRootMenu(0); configList->mode = fullMode; if (configList->rootEntry == &rootmenu) @@ -1735,7 +1743,6 @@ void ConfigMainWindow::showFullView(void) /* * ask for saving configuration before quitting - * TODO ask only when something changed */ void ConfigMainWindow::closeEvent(QCloseEvent* e) { @@ -1766,17 +1773,26 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) void ConfigMainWindow::showIntro(void) { - static const QString str = "Welcome to the qconf graphical configuration tool.\n\n" - "For each option, a blank box indicates the feature is disabled, a check\n" - "indicates it is enabled, and a dot indicates that it is to be compiled\n" - "as a module. Clicking on the box will cycle through the three states.\n\n" - "If you do not see an option (e.g., a device driver) that you believe\n" - "should be present, try turning on Show All Options under the Options menu.\n" - "Although there is no cross reference yet to help you figure out what other\n" - "options must be enabled to support the option you are interested in, you can\n" - "still view the help of a grayed-out option.\n\n" - "Toggling Show Debug Info under the Options menu will show the dependencies,\n" - "which you can then match by examining other options.\n\n"; + static const QString str = + "Welcome to the qconf graphical configuration tool.\n" + "\n" + "For bool and tristate options, a blank box indicates the " + "feature is disabled, a check indicates it is enabled, and a " + "dot indicates that it is to be compiled as a module. Clicking " + "on the box will cycle through the three states. For int, hex, " + "and string options, double-clicking or pressing F2 on the " + "Value cell will allow you to edit the value.\n" + "\n" + "If you do not see an option (e.g., a device driver) that you " + "believe should be present, try turning on Show All Options " + "under the Options menu. Enabling Show Debug Info will help you" + "figure out what other options must be enabled to support the " + "option you are interested in, and hyperlinks will navigate to " + "them.\n" + "\n" + "Toggling Show Debug Info under the Options menu will show the " + "dependencies, which you can then match by examining other " + "options.\n"; QMessageBox::information(this, "qconf", str); } @@ -1784,10 +1800,13 @@ void ConfigMainWindow::showIntro(void) void ConfigMainWindow::showAbout(void) { static const QString str = "qconf is Copyright (C) 2002 Roman Zippel .\n" - "Copyright (C) 2015 Boris Barbulovski .\n\n" - "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; + "Copyright (C) 2015 Boris Barbulovski .\n" + "\n" + "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n" + "\n" + "Qt Version: "; - QMessageBox::information(this, "qconf", str); + QMessageBox::information(this, "qconf", str + qVersion()); } void ConfigMainWindow::saveSettings(void) @@ -1856,7 +1875,6 @@ int main(int ac, char** av) const char *name; progname = av[0]; - configApp = new QApplication(ac, av); if (ac > 1 && av[1][0] == '-') { switch (av[1][1]) { case 's': @@ -1877,6 +1895,8 @@ int main(int ac, char** av) conf_read(NULL); //zconfdump(stdout); + configApp = new QApplication(ac, av); + configSettings = new ConfigSettings(); configSettings->beginGroup("/kconfig/qconf"); v = new ConfigMainWindow(); diff --git a/scripts/config/qconf.h b/scripts/config/qconf.h index 61ecd5bda..c50d19215 100644 --- a/scripts/config/qconf.h +++ b/scripts/config/qconf.h @@ -3,23 +3,22 @@ * Copyright (C) 2002 Roman Zippel */ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "expr.h" -class ConfigView; class ConfigList; class ConfigItem; -class ConfigLineEdit; class ConfigMainWindow; class ConfigSettings : public QSettings { @@ -30,7 +29,7 @@ public: }; enum colIdx { - promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr + promptColIdx, nameColIdx, dataColIdx }; enum listMode { singleMode, menuMode, symbolMode, fullMode, listMode @@ -43,13 +42,16 @@ class ConfigList : public QTreeWidget { Q_OBJECT typedef class QTreeWidget Parent; public: - ConfigList(ConfigView* p, const char *name = 0); + ConfigList(QWidget *parent, const char *name = 0); + ~ConfigList(); void reinit(void); - ConfigView* parent(void) const - { - return (ConfigView*)Parent::parent(); - } ConfigItem* findConfigItem(struct menu *); + void setSelected(QTreeWidgetItem *item, bool enable) { + for (int i = 0; i < selectedItems().size(); i++) + selectedItems().at(i)->setSelected(false); + + item->setSelected(enable); + } protected: void keyPressEvent(QKeyEvent *e); @@ -63,61 +65,52 @@ protected: public slots: void setRootMenu(struct menu *menu); - void updateList(ConfigItem *item); + void updateList(); void setValue(ConfigItem* item, tristate val); void changeValue(ConfigItem* item); void updateSelection(void); void saveSettings(void); + void setOptionMode(QAction *action); + void setShowName(bool on); + signals: void menuChanged(struct menu *menu); void menuSelected(struct menu *menu); + void itemSelected(struct menu *menu); void parentSelected(void); void gotFocus(struct menu *); + void showNameChanged(bool on); public: void updateListAll(void) { updateAll = true; - updateList(NULL); + updateList(); updateAll = false; } - ConfigList* listView() - { - return this; - } - ConfigItem* firstChild() const - { - return (ConfigItem *)children().first(); - } - void addColumn(colIdx idx) - { - showColumn(idx); - } - void removeColumn(colIdx idx) - { - hideColumn(idx); - } void setAllOpen(bool open); void setParentMenu(void); bool menuSkip(struct menu *); void updateMenuList(ConfigItem *parent, struct menu*); - void updateMenuList(ConfigList *parent, struct menu*); + void updateMenuList(struct menu *menu); bool updateAll; - QPixmap symbolYesPix, symbolModPix, symbolNoPix; - QPixmap choiceYesPix, choiceNoPix; - QPixmap menuPix, menuInvPix, menuBackPix, voidPix; - - bool showName, showRange, showData; + bool showName; enum listMode mode; enum optionMode optMode; struct menu *rootEntry; QPalette disabledColorGroup; QPalette inactivedColorGroup; QMenu* headerPopup; + + static QList allLists; + static void updateListForAll(); + static void updateListAllForAll(); + + static QAction *showNormalAction, *showAllAction, *showPromptAction; }; class ConfigItem : public QTreeWidgetItem { @@ -140,7 +133,6 @@ public: } ~ConfigItem(void); void init(void); - void okRename(int col); void updateMenu(void); void testUpdateMenu(bool v); ConfigList* listView() const @@ -165,82 +157,36 @@ public: return ret; } - void setText(colIdx idx, const QString& text) - { - Parent::setText(idx, text); - } - QString text(colIdx idx) const - { - return Parent::text(idx); - } - void setPixmap(colIdx idx, const QIcon &icon) - { - Parent::setIcon(idx, icon); - } - const QIcon pixmap(colIdx idx) const - { - return icon(idx); - } // TODO: Implement paintCell ConfigItem* nextItem; struct menu *menu; bool visible; bool goParent; + + static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon; + static QIcon choiceYesIcon, choiceNoIcon; + static QIcon menuIcon, menubackIcon; }; -class ConfigLineEdit : public QLineEdit { - Q_OBJECT - typedef class QLineEdit Parent; +class ConfigItemDelegate : public QStyledItemDelegate +{ +private: + struct menu *menu; public: - ConfigLineEdit(ConfigView* parent); - ConfigView* parent(void) const - { - return (ConfigView*)Parent::parent(); - } - void show(ConfigItem *i); - void keyPressEvent(QKeyEvent *e); - -public: - ConfigItem *item; -}; - -class ConfigView : public QWidget { - Q_OBJECT - typedef class QWidget Parent; -public: - ConfigView(QWidget* parent, const char *name = 0); - ~ConfigView(void); - static void updateList(ConfigItem* item); - static void updateListAll(void); - - bool showName(void) const { return list->showName; } - bool showRange(void) const { return list->showRange; } - bool showData(void) const { return list->showData; } -public slots: - void setShowName(bool); - void setShowRange(bool); - void setShowData(bool); - void setOptionMode(QAction *); -signals: - void showNameChanged(bool); - void showRangeChanged(bool); - void showDataChanged(bool); -public: - ConfigList* list; - ConfigLineEdit* lineEdit; - - static ConfigView* viewList; - ConfigView* nextView; - - static QAction *showNormalAction; - static QAction *showAllAction; - static QAction *showPromptAction; + ConfigItemDelegate(QObject *parent = nullptr) + : QStyledItemDelegate(parent) {} + QWidget *createEditor(QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const override; }; class ConfigInfoView : public QTextBrowser { Q_OBJECT typedef class QTextBrowser Parent; + QMenu *contextMenu; public: ConfigInfoView(QWidget* parent, const char *name = 0); bool showDebug(void) const { return _showDebug; } @@ -249,6 +195,7 @@ public slots: void setInfo(struct menu *menu); void saveSettings(void); void setShowDebug(bool); + void clicked (const QUrl &url); signals: void showDebugChanged(bool); @@ -260,8 +207,7 @@ protected: QString debug_info(struct symbol *sym); static QString print_filter(const QString &str); static void expr_print_help(void *data, struct symbol *sym, const char *str); - QMenu *createStandardContextMenu(const QPoint & pos); - void contextMenuEvent(QContextMenuEvent *e); + void contextMenuEvent(QContextMenuEvent *event); struct symbol *sym; struct menu *_menu; @@ -272,7 +218,7 @@ class ConfigSearchWindow : public QDialog { Q_OBJECT typedef class QDialog Parent; public: - ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); + ConfigSearchWindow(ConfigMainWindow *parent); public slots: void saveSettings(void); @@ -282,7 +228,7 @@ protected: QLineEdit* editField; QPushButton* searchButton; QSplitter* split; - ConfigView* list; + ConfigList *list; ConfigInfoView* info; struct symbol **result; @@ -298,6 +244,7 @@ public: ConfigMainWindow(void); public slots: void changeMenu(struct menu *); + void changeItens(struct menu *); void setMenuLink(struct menu *); void listFocusChanged(void); void goBack(void); @@ -316,12 +263,9 @@ protected: void closeEvent(QCloseEvent *e); ConfigSearchWindow *searchWindow; - ConfigView *menuView; ConfigList *menuList; - ConfigView *configView; ConfigList *configList; ConfigInfoView *helpText; - QToolBar *toolBar; QAction *backAction; QAction *singleViewAction; QAction *splitViewAction; diff --git a/scripts/config/symbol.c b/scripts/config/symbol.c index b85e5cab7..d97b56ab0 100644 --- a/scripts/config/symbol.c +++ b/scripts/config/symbol.c @@ -3,11 +3,11 @@ * Copyright (C) 2002 Roman Zippel */ +#include #include #include #include #include -#include #include "lkc.h" @@ -15,23 +15,28 @@ struct symbol symbol_yes = { .name = "y", .curr = { "y", yes }, .flags = SYMBOL_CONST|SYMBOL_VALID, -}, symbol_mod = { +}; + +struct symbol symbol_mod = { .name = "m", .curr = { "m", mod }, .flags = SYMBOL_CONST|SYMBOL_VALID, -}, symbol_no = { +}; + +struct symbol symbol_no = { .name = "n", .curr = { "n", no }, .flags = SYMBOL_CONST|SYMBOL_VALID, -}, symbol_empty = { +}; + +static struct symbol symbol_empty = { .name = "", .curr = { "", no }, .flags = SYMBOL_VALID, }; -struct symbol *sym_defconfig_list; struct symbol *modules_sym; -tristate modules_val; +static tristate modules_val; int recursive_is_error; enum symbol_type sym_get_type(struct symbol *sym) @@ -222,7 +227,7 @@ static void sym_calc_visibility(struct symbol *sym) sym_set_changed(sym); } tri = no; - if (sym->implied.expr && sym->dir_dep.tri != no) + if (sym->implied.expr) tri = expr_calc_value(sym->implied.expr); if (tri == mod && sym_get_type(sym) == S_BOOLEAN) tri = yes; @@ -373,6 +378,8 @@ void sym_calc_value(struct symbol *sym) if (sym->implied.tri != no) { sym->flags |= SYMBOL_WRITE; newval.tri = EXPR_OR(newval.tri, sym->implied.tri); + newval.tri = EXPR_AND(newval.tri, + sym->dir_dep.tri); } } calc_newval: @@ -381,8 +388,7 @@ void sym_calc_value(struct symbol *sym) else newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); } - if (newval.tri == mod && - (sym_get_type(sym) == S_BOOLEAN || sym->implied.tri == yes)) + if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) newval.tri = yes; break; case S_STRING: @@ -446,7 +452,7 @@ void sym_clear_all_valid(void) for_all_symbols(i, sym) sym->flags &= ~SYMBOL_VALID; - sym_add_change_count(1); + conf_set_changed(true); sym_calc_value(modules_sym); } @@ -464,8 +470,6 @@ bool sym_tristate_within_range(struct symbol *sym, tristate val) return false; if (sym->visible <= sym->rev_dep.tri) return false; - if (sym->implied.tri == yes && val == mod) - return false; if (sym_is_choice_value(sym) && sym->visible == yes) return val == yes; return val >= sym->rev_dep.tri && val <= sym->visible; @@ -812,7 +816,7 @@ struct symbol *sym_lookup(const char *name, int flags) memset(symbol, 0, sizeof(*symbol)); symbol->name = new_name; symbol->type = S_UNKNOWN; - symbol->flags |= flags; + symbol->flags = flags; symbol->next = symbol_hash[hash]; symbol_hash[hash] = symbol; diff --git a/scripts/dl_cleanup.py b/scripts/dl_cleanup.py index 1acb04958..cdbcb83f2 100755 --- a/scripts/dl_cleanup.py +++ b/scripts/dl_cleanup.py @@ -13,230 +13,319 @@ import sys import os import re import getopt +import shutil # Commandline options opt_dryrun = False def parseVer_1234(match, filepath): - progname = match.group(1) - progversion = (int(match.group(2)) << 64) |\ - (int(match.group(3)) << 48) |\ - (int(match.group(4)) << 32) |\ - (int(match.group(5)) << 16) - return (progname, progversion) + progname = match.group(1) + progversion = ( + (int(match.group(2)) << 64) + | (int(match.group(3)) << 48) + | (int(match.group(4)) << 32) + | (int(match.group(5)) << 16) + ) + return (progname, progversion) + def parseVer_123(match, filepath): - progname = match.group(1) - try: - patchlevel = match.group(5) - except IndexError as e: - patchlevel = None - if patchlevel: - patchlevel = ord(patchlevel[0]) - else: - patchlevel = 0 - progversion = (int(match.group(2)) << 64) |\ - (int(match.group(3)) << 48) |\ - (int(match.group(4)) << 32) |\ - patchlevel - return (progname, progversion) + progname = match.group(1) + try: + patchlevel = match.group(5) + except IndexError as e: + patchlevel = None + if patchlevel: + patchlevel = ord(patchlevel[0]) + else: + patchlevel = 0 + progversion = ( + (int(match.group(2)) << 64) + | (int(match.group(3)) << 48) + | (int(match.group(4)) << 32) + | patchlevel + ) + return (progname, progversion) + def parseVer_12(match, filepath): - progname = match.group(1) - try: - patchlevel = match.group(4) - except IndexError as e: - patchlevel = None - if patchlevel: - patchlevel = ord(patchlevel[0]) - else: - patchlevel = 0 - progversion = (int(match.group(2)) << 64) |\ - (int(match.group(3)) << 48) |\ - patchlevel - return (progname, progversion) + progname = match.group(1) + try: + patchlevel = match.group(4) + except IndexError as e: + patchlevel = None + if patchlevel: + patchlevel = ord(patchlevel[0]) + else: + patchlevel = 0 + progversion = (int(match.group(2)) << 64) | (int(match.group(3)) << 48) | patchlevel + return (progname, progversion) + def parseVer_r(match, filepath): - progname = match.group(1) - progversion = (int(match.group(2)) << 64) - return (progname, progversion) + progname = match.group(1) + progversion = int(match.group(2)) << 64 + return (progname, progversion) + + +def parseVer_ymd_GIT_SHASUM(match, filepath): + progname = match.group(1) + progversion = ( + (int(match.group(2)) << 64) + | (int(match.group(3)) << 48) + | (int(match.group(4)) << 32) + ) + return (progname, progversion) + def parseVer_ymd(match, filepath): - progname = match.group(1) - progversion = (int(match.group(2)) << 64) |\ - (int(match.group(3)) << 48) |\ - (int(match.group(4)) << 32) - return (progname, progversion) + progname = match.group(1) + progversion = ( + (int(match.group(2)) << 64) + | (int(match.group(3)) << 48) + | (int(match.group(4)) << 32) + ) + return (progname, progversion) + def parseVer_GIT(match, filepath): - progname = match.group(1) - st = os.stat(filepath) - progversion = int(st.st_mtime) << 64 - return (progname, progversion) + progname = match.group(1) + st = os.stat(filepath) + progversion = int(st.st_mtime) << 64 + return (progname, progversion) + extensions = ( - ".tar.gz", - ".tar.bz2", - ".tar.xz", - ".orig.tar.gz", - ".orig.tar.bz2", - ".orig.tar.xz", - ".zip", - ".tgz", - ".tbz", - ".txz", + ".tar.gz", + ".tar.bz2", + ".tar.xz", + ".orig.tar.gz", + ".orig.tar.bz2", + ".orig.tar.xz", + ".zip", + ".tgz", + ".tbz", + ".txz", ) versionRegex = ( - (re.compile(r"(.+)[-_](\d+)\.(\d+)\.(\d+)\.(\d+)"), parseVer_1234), # xxx-1.2.3.4 - (re.compile(r"(.+)[-_](\d\d\d\d)-?(\d\d)-?(\d\d)"), parseVer_ymd), # xxx-YYYY-MM-DD - (re.compile(r"(.+)[-_]([0-9a-fA-F]{40,40})"), parseVer_GIT), # xxx-GIT_SHASUM - (re.compile(r"(.+)[-_](\d+)\.(\d+)\.(\d+)(\w?)"), parseVer_123), # xxx-1.2.3a - (re.compile(r"(.+)[-_](\d+)_(\d+)_(\d+)"), parseVer_123), # xxx-1_2_3 - (re.compile(r"(.+)[-_](\d+)\.(\d+)(\w?)"), parseVer_12), # xxx-1.2a - (re.compile(r"(.+)[-_]r?(\d+)"), parseVer_r), # xxx-r1111 + (re.compile(r"(gcc[-_]\d+)\.(\d+)\.(\d+)"), parseVer_12), # gcc.1.2 + (re.compile(r"(linux[-_]\d+\.\d+)\.(\d+)"), parseVer_r), # linux.1 + (re.compile(r"(.+)[-_](\d+)\.(\d+)\.(\d+)\.(\d+)"), parseVer_1234), # xxx-1.2.3.4 + ( + re.compile(r"(.+)[-_](\d\d\d\d)-?(\d\d)-?(\d\d)-"), + parseVer_ymd_GIT_SHASUM, + ), # xxx-YYYY-MM-DD-GIT_SHASUM + (re.compile(r"(.+)[-_](\d\d\d\d)-?(\d\d)-?(\d\d)"), parseVer_ymd), # xxx-YYYY-MM-DD + (re.compile(r"(.+)[-_]([0-9a-fA-F]{40,40})"), parseVer_GIT), # xxx-GIT_SHASUM + (re.compile(r"(.+)[-_](\d+)\.(\d+)\.(\d+)(\w?)"), parseVer_123), # xxx-1.2.3a + (re.compile(r"(.+)[-_]v(\d+)\.(\d+)\.(\d+)(\w?)"), parseVer_123), # xxx-v1.2.3a + (re.compile(r"(.+)[-_](\d+)_(\d+)_(\d+)"), parseVer_123), # xxx-1_2_3 + (re.compile(r"(.+)[-_](\d+)\.(\d+)(\w?)"), parseVer_12), # xxx-1.2a + (re.compile(r"(.+)[-_]v(\d+)\.(\d+)(\w?)"), parseVer_12), # xxx-v1.2a + (re.compile(r"(.+)[-_]r?(\d+)"), parseVer_r), # xxx-r1111 ) blacklist = [ - ("linux", re.compile(r"linux-\d.*")), - ("gcc", re.compile(r"gcc-.*")), - ("wl_apsta", re.compile(r"wl_apsta.*")), - (".fw", re.compile(r".*\.fw")), - (".arm", re.compile(r".*\.arm")), - (".bin", re.compile(r".*\.bin")), - ("rt-firmware", re.compile(r"RT[\d\w]+_Firmware.*")), + ("wl_apsta", re.compile(r"wl_apsta.*")), + (".fw", re.compile(r".*\.fw")), + (".arm", re.compile(r".*\.arm")), + (".bin", re.compile(r".*\.bin")), + ("rt-firmware", re.compile(r"RT[\d\w]+_Firmware.*")), ] -class EntryParseError(Exception): pass + +class EntryParseError(Exception): + pass + class Entry: - def __init__(self, directory, filename): - self.directory = directory - self.filename = filename - self.progname = "" - self.fileext = "" + def __init__(self, directory, builddir, filename): + self.directory = directory + self.filename = filename + self.builddir = builddir + self.progname = "" + self.fileext = "" + self.filenoext = "" - for ext in extensions: - if filename.endswith(ext): - filename = filename[0:0-len(ext)] - self.fileext = ext - break - else: - print(self.filename, "has an unknown file-extension") - raise EntryParseError("ext") - for (regex, parseVersion) in versionRegex: - match = regex.match(filename) - if match: - (self.progname, self.version) = parseVersion( - match, directory + "/" + filename + self.fileext) - break - else: - print(self.filename, "has an unknown version pattern") - raise EntryParseError("ver") + if os.path.isdir(self.getPath()): + self.filenoext = filename + else: + for ext in extensions: + if filename.endswith(ext): + filename = filename[0 : 0 - len(ext)] + self.filenoext = filename + self.fileext = ext + break + else: + print(self.filename, "has an unknown file-extension") + raise EntryParseError("ext") + for (regex, parseVersion) in versionRegex: + match = regex.match(filename) + if match: + (self.progname, self.version) = parseVersion( + match, directory + "/" + filename + self.fileext + ) + break + else: + print(self.filename, "has an unknown version pattern") + raise EntryParseError("ver") - def getPath(self): - return (self.directory + "/" + self.filename).replace("//", "/") + def getPath(self): + return (self.directory + "/" + self.filename).replace("//", "/") - def deleteFile(self): - path = self.getPath() - print("Deleting", path) - if not opt_dryrun: - os.unlink(path) + def getBuildPaths(self): + paths = [] + for subdir in os.scandir(self.builddir): + package_build_dir = os.path.join(subdir.path, self.filenoext) + if os.path.exists(package_build_dir): + paths.append(package_build_dir) + return paths + + def deleteFile(self): + path = self.getPath() + print("Deleting", path) + if not opt_dryrun: + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.unlink(path) + + def deleteBuildDir(self): + paths = self.getBuildPaths() + for path in paths: + print("Deleting BuildDir", path) + if not opt_dryrun: + shutil.rmtree(path) + + def __ge__(self, y): + return self.version >= y.version - def __ge__(self, y): - return self.version >= y.version def usage(): - print("OpenWrt download directory cleanup utility") - print("Usage: " + sys.argv[0] + " [OPTIONS] ") - print("") - print(" -d|--dry-run Do a dry-run. Don't delete any files") - print(" -B|--show-blacklist Show the blacklist and exit") - print(" -w|--whitelist ITEM Remove ITEM from blacklist") + print("OpenWrt download directory cleanup utility") + print("Usage: " + sys.argv[0] + " [OPTIONS] ") + print("") + print(" -d|--dry-run Do a dry-run. Don't delete any files") + print(" -B|--show-blacklist Show the blacklist and exit") + print(" -w|--whitelist ITEM Remove ITEM from blacklist") + print( + " -D|--download-dir Provide path to dl dir to clean also the build directory" + ) + print( + " -b|--build-dir Provide path to build dir to clean also the build directory" + ) + def main(argv): - global opt_dryrun + global opt_dryrun - try: - (opts, args) = getopt.getopt(argv[1:], - "hdBw:", - [ "help", "dry-run", "show-blacklist", "whitelist=", ]) - if len(args) != 1: - usage() - return 1 - except getopt.GetoptError as e: - usage() - return 1 - directory = args[0] + try: + (opts, args) = getopt.getopt( + argv[1:], + "hdBw:D:b:", + [ + "help", + "dry-run", + "show-blacklist", + "whitelist=", + "download-dir=", + "build-dir=", + ], + ) + except getopt.GetoptError as e: + usage() + return 1 - if not os.path.exists(directory): - print("Can't find dl path", directory) - return 1 + directory = "dl/" + builddir = "build_dir/" - for (o, v) in opts: - if o in ("-h", "--help"): - usage() - return 0 - if o in ("-d", "--dry-run"): - opt_dryrun = True - if o in ("-w", "--whitelist"): - for i in range(0, len(blacklist)): - (name, regex) = blacklist[i] - if name == v: - del blacklist[i] - break - else: - print("Whitelist error: Item", v,\ - "is not in blacklist") - return 1 - if o in ("-B", "--show-blacklist"): - for (name, regex) in blacklist: - sep = "\t\t" - if len(name) >= 8: - sep = "\t" - print("%s%s(%s)" % (name, sep, regex.pattern)) - return 0 + for (o, v) in opts: + if o in ("-h", "--help"): + usage() + return 0 + if o in ("-d", "--dry-run"): + opt_dryrun = True + if o in ("-w", "--whitelist"): + for i in range(0, len(blacklist)): + (name, regex) = blacklist[i] + if name == v: + del blacklist[i] + break + else: + print("Whitelist error: Item", v, "is not in blacklist") + return 1 + if o in ("-B", "--show-blacklist"): + for (name, regex) in blacklist: + sep = "\t\t" + if len(name) >= 8: + sep = "\t" + print("%s%s(%s)" % (name, sep, regex.pattern)) + return 0 + if o in ("-D", "--download-dir"): + directory = v + if o in ("-b", "--build-dir"): + builddir = v - # Create a directory listing and parse the file names. - entries = [] - for filename in os.listdir(directory): - if filename == "." or filename == "..": - continue - for (name, regex) in blacklist: - if regex.match(filename): - if opt_dryrun: - print(filename, "is blacklisted") - break - else: - try: - entries.append(Entry(directory, filename)) - except EntryParseError as e: - pass + if args: + directory = args[0] - # Create a map of programs - progmap = {} - for entry in entries: - if entry.progname in progmap.keys(): - progmap[entry.progname].append(entry) - else: - progmap[entry.progname] = [entry,] + if not os.path.exists(directory): + print("Can't find download directory", directory) + return 1 - # Traverse the program map and delete everything but the last version - for prog in progmap: - lastVersion = None - versions = progmap[prog] - for version in versions: - if lastVersion is None or version >= lastVersion: - lastVersion = version - if lastVersion: - for version in versions: - if version is not lastVersion: - version.deleteFile() - if opt_dryrun: - print("Keeping", lastVersion.getPath()) + if not os.path.exists(builddir): + print("Can't find build directory", builddir) + return 1 + + # Create a directory listing and parse the file names. + entries = [] + for filename in os.listdir(directory): + if filename == "." or filename == "..": + continue + for (name, regex) in blacklist: + if regex.match(filename): + if opt_dryrun: + print(filename, "is blacklisted") + break + else: + try: + entries.append(Entry(directory, builddir, filename)) + except EntryParseError as e: + pass + + # Create a map of programs + progmap = {} + for entry in entries: + if entry.progname in progmap.keys(): + progmap[entry.progname].append(entry) + else: + progmap[entry.progname] = [ + entry, + ] + + # Traverse the program map and delete everything but the last version + for prog in progmap: + lastVersion = None + versions = progmap[prog] + for version in versions: + if lastVersion: + if os.path.isdir(lastVersion.getPath()) and not os.path.isdir(version.getPath()): + continue + if lastVersion is None or version >= lastVersion: + lastVersion = version + if lastVersion: + for version in versions: + if version is not lastVersion: + version.deleteFile() + if builddir: + version.deleteBuildDir() + if opt_dryrun: + print("Keeping", lastVersion.getPath()) + + return 0 - return 0 if __name__ == "__main__": - sys.exit(main(sys.argv)) + sys.exit(main(sys.argv)) diff --git a/scripts/dl_github_archive.py b/scripts/dl_github_archive.py index 59fd7067b..b992227dc 100755 --- a/scripts/dl_github_archive.py +++ b/scripts/dl_github_archive.py @@ -207,7 +207,7 @@ class GitHubCommitTsCache(object): class DownloadGitHubTarball(object): - """Download and repack archive tarabll from GitHub. + """Download and repack archive tarball from GitHub. Compared with the method of packing after cloning the whole repo, this method is more friendly to users with fragile internet connection. @@ -220,7 +220,7 @@ class DownloadGitHubTarball(object): - GitHub archives do not contain source codes for submodules. - - GitHub archives seem to respect .gitattributes and ignore pathes with + - GitHub archives seem to respect .gitattributes and ignore paths with export-ignore attributes. For the first two issues, the method will fail loudly to allow fallback to diff --git a/scripts/download.pl b/scripts/download.pl index a73c9d1bc..9a0f48f38 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -249,16 +249,14 @@ foreach my $mirror (@ARGV) { } elsif ($mirror =~ /^\@OPENWRT$/) { # use OpenWrt source server directly } elsif ($mirror =~ /^\@DEBIAN\/(.+)$/) { + push @mirrors, "https://mirrors.aliyun.com/debian/$1"; push @mirrors, "https://mirrors.tencent.com/debian/$1"; - push @mirrors, "https://mirrors.tuna.tsinghua.edu.cn/debian/$1"; - push @mirrors, "https://mirrors.ustc.edu.cn/debian/$1"; push @mirrors, "https://ftp.debian.org/debian/$1"; push @mirrors, "https://mirror.leaseweb.com/debian/$1"; push @mirrors, "https://mirror.netcologne.de/debian/$1"; } elsif ($mirror =~ /^\@APACHE\/(.+)$/) { - push @mirrors, "https://mirrors.cloud.tencent.com/apache/$1"; - push @mirrors, "https://mirrors.tuna.tsinghua.edu.cn/apache/$1"; - push @mirrors, "https://mirrors.ustc.edu.cn/apache/$1"; + push @mirrors, "https://mirrors.aliyun.com/apache/$1"; + push @mirrors, "https://mirrors.tencent.com/apache/$1"; push @mirrors, "https://mirror.netcologne.de/apache.org/$1"; push @mirrors, "https://mirror.aarnet.edu.au/pub/apache/$1"; push @mirrors, "https://mirror.csclub.uwaterloo.ca/apache/$1"; @@ -274,8 +272,8 @@ foreach my $mirror (@ARGV) { push @mirrors, "https://raw.githubusercontent.com/$1"; } } elsif ($mirror =~ /^\@GNU\/(.+)$/) { - push @mirrors, "https://mirrors.tuna.tsinghua.edu.cn/gnu/$1"; - push @mirrors, "https://mirrors.ustc.edu.cn/gnu/$1"; + push @mirrors, "https://mirrors.aliyun.com/gnu/$1"; + push @mirrors, "https://mirrors.tencent.com/gnu/$1"; push @mirrors, "https://mirror.csclub.uwaterloo.ca/gnu/$1"; push @mirrors, "https://mirror.netcologne.de/gnu/$1"; push @mirrors, "http://ftp.kddilabs.jp/GNU/gnu/$1"; @@ -301,7 +299,7 @@ foreach my $mirror (@ARGV) { push @extra, "$extra[0]/longterm/v$1"; } foreach my $dir (@extra) { - push @mirrors, "https://mirrors.tuna.tsinghua.edu.cn/kernel/$dir"; + push @mirrors, "https://mirror.iscas.ac.cn/kernel.org/$dir"; push @mirrors, "https://mirrors.ustc.edu.cn/kernel.org/$dir"; push @mirrors, "https://cdn.kernel.org/pub/$dir"; push @mirrors, "https://download.xs4all.nl/ftp.kernel.org/pub/$dir"; diff --git a/scripts/dump-target-info.pl b/scripts/dump-target-info.pl index aa97f8d60..0e4af17fe 100755 --- a/scripts/dump-target-info.pl +++ b/scripts/dump-target-info.pl @@ -4,7 +4,7 @@ use strict; use warnings; use Cwd; -my (%targets, %architectures); +my (%targets, %architectures, %kernels); $ENV{'TOPDIR'} = Cwd::getcwd(); @@ -13,7 +13,7 @@ sub parse_targetinfo { my ($target_dir, $subtarget) = @_; if (open M, "make -C '$target_dir' --no-print-directory DUMP=1 TARGET_BUILD=1 SUBTARGET='$subtarget' |") { - my ($target_name, $target_arch, @target_features); + my ($target_name, $target_arch, $target_kernel, $target_testing_kernel, @target_features); while (defined(my $line = readline M)) { chomp $line; @@ -23,19 +23,32 @@ sub parse_targetinfo { elsif ($line =~ /^Target-Arch-Packages: (.+)$/) { $target_arch = $1; } + elsif ($line =~ /^Linux-Version: (\d\.\d+)\.\d+$/) { + $target_kernel = $1; + } + elsif ($line =~ /^Linux-Testing-Version: (\d\.\d+)\.\d+$/) { + $target_testing_kernel = $1; + } elsif ($line =~ /^Target-Features: (.+)$/) { @target_features = split /\s+/, $1; } elsif ($line =~ /^@\@$/) { - if ($target_name && $target_arch && + if ($target_name && $target_arch && $target_kernel && !grep { $_ eq 'broken' or $_ eq 'source-only' } @target_features) { $targets{$target_name} = $target_arch; $architectures{$target_arch} ||= []; push @{$architectures{$target_arch}}, $target_name; + $kernels{$target_name} ||= []; + push @{$kernels{$target_name}}, $target_kernel; + if ($target_testing_kernel) { + push @{$kernels{$target_name}}, $target_testing_kernel; + } } undef $target_name; undef $target_arch; + undef $target_kernel; + undef $target_testing_kernel; @target_features = (); } } @@ -85,7 +98,14 @@ elsif (@ARGV == 1 && $ARGV[0] eq 'architectures') { printf "%s %s\n", $target_arch, join ' ', @{$architectures{$target_arch}}; } } +elsif (@ARGV == 1 && $ARGV[0] eq 'kernels') { + get_targetinfo(); + foreach my $target_name (sort keys %targets) { + printf "%s %s\n", $target_name, join ' ', @{$kernels{$target_name}}; + } +} else { print "Usage: $0 targets\n"; print "Usage: $0 architectures\n"; + print "Usage: $0 kernels\n"; } diff --git a/scripts/env b/scripts/env index df8b486bf..5987b4160 100755 --- a/scripts/env +++ b/scripts/env @@ -61,7 +61,7 @@ env_init() { mkdir -p "$ENVDIR" || error "Failed to create the environment directory" cd "$ENVDIR" || error "Failed to switch to the environment directory" [ -d .git ] || { - git init && + git init -b master && touch .config && mkdir files && git add . && diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index ee7d9532f..fe1024c18 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -50,6 +50,7 @@ BIN_SPECS=" gdbserver: gdbserver " +OVERWRITE_CONFIG="" test_c() { cat <<-EOT | "${CC:-false}" $CFLAGS -o /dev/null -x c - 2>/dev/null @@ -281,8 +282,11 @@ print_config() { local mksubtarget local target="$("$CC" $CFLAGS -dumpmachine)" + local version="$("$CC" $CFLAGS -dumpversion)" local cpuarch="${target%%-*}" - local prefix="${CC##*/}"; prefix="${prefix%-*}-" + + # get CC; strip version; strip gcc and add - suffix + local prefix="${CC##*/}"; prefix="${prefix%-$version}"; prefix="${prefix%-*}-" local config="${0%/scripts/*}/.config" # if no target specified, print choice list and exit @@ -317,9 +321,13 @@ print_config() { fi # bail out if there is a .config already - if [ -f "${0%/scripts/*}/.config" ]; then - echo "There already is a .config file, refusing to overwrite!" >&2 - return 1 + if [ -f "$config" ]; then + if [ "$OVERWRITE_CONFIG" == "" ]; then + echo "There already is a .config file, refusing to overwrite!" >&2 + return 1 + else + echo "There already is a .config file, trying to overwrite!" + fi fi case "$mktarget" in */*) @@ -327,8 +335,11 @@ print_config() { mktarget="${mktarget%/*}" ;; esac + if [ ! -f "$config" ]; then + touch "$config" + fi - echo "CONFIG_TARGET_${mktarget}=y" > "$config" + echo "CONFIG_TARGET_${mktarget}=y" >> "$config" if [ -n "$mksubtarget" ]; then echo "CONFIG_TARGET_${mktarget}_${mksubtarget}=y" >> "$config" @@ -358,8 +369,18 @@ print_config() { echo "CONFIG_TOOLCHAIN_PREFIX=\"$prefix\"" >> "$config" echo "CONFIG_TARGET_NAME=\"$target\"" >> "$config" - if [ "$LIBC_TYPE" != glibc ]; then - echo "CONFIG_TOOLCHAIN_LIBC=\"$LIBC_TYPE\"" >> "$config" + if [ -f "$config" ]; then + sed -i '/CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL/d' "$config" + sed -i '/CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_GLIBC/d' "$config" + fi + + if [ "$LIBC_TYPE" == glibc ]; then + echo "CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_GLIBC=y" >> "$config" + elif [ "$LIBC_TYPE" == musl ]; then + echo "CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL=y" >> "$config" + else + echo "Can't detect LIBC type. Aborting!" >&2 + return 1 fi local lib @@ -452,6 +473,13 @@ probe_cpp() { } probe_libc() { + if [ -f $TOOLCHAIN/info.mk ]; then + LIBC_TYPE=$(grep LIBC_TYPE $TOOLCHAIN/info.mk | sed 's/LIBC_TYPE=//') + return 0 + fi + + echo "Warning! Can't find info.mk, trying to detect with alternative way." + if [ -z "$LIBC_TYPE" ]; then if test_uclibc; then LIBC_TYPE="uclibc" @@ -529,8 +557,13 @@ while [ -n "$1" ]; do exit $? ;; + --overwrite-config) + OVERWRITE_CONFIG=y + ;; + --config) if probe_cc; then + probe_libc print_config "$1" exit $? fi @@ -569,7 +602,9 @@ while [ -n "$1" ]; do echo -e " Most commands also take a --cflags parameter which " >&2 echo -e " is used to specify C flags to be passed to the " >&2 echo -e " cross compiler when performing tests." >&2 - echo -e " This paremter may be repeated multiple times." >&2 + echo -e " This parameter may be repeated multiple times." >&2 + echo -e " Use --overwrite-config before --config to overwrite" >&2 + echo -e " an already present config with the required changes.">&2 exit 1 ;; diff --git a/scripts/ext-tools.sh b/scripts/ext-tools.sh new file mode 100755 index 000000000..bf56f4d9e --- /dev/null +++ b/scripts/ext-tools.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +TOOLS_TAR="" +HOST_BUILD_DIR=$(pwd)/"build_dir/host" +HOST_STAGING_DIR_STAMP=$(pwd)/"staging_dir/host/stamp" + +refresh_timestamps() { + find "$1" -not -type l -print0 | xargs -0 touch +} + +extract_prebuilt_tar() { + tar -xf "$1" +} + +install_prebuilt_tools() { + extract_prebuilt_tar "$TOOLS_TAR" + + if [ ! -d "$HOST_BUILD_DIR" ]; then + echo "Can't find Host Build Dir "$HOST_BUILD_DIR"" >&2 + exit 1 + fi + + refresh_timestamps "$HOST_BUILD_DIR" + sleep 1 + + if [ ! -d "$HOST_STAGING_DIR_STAMP" ]; then + echo "Can't find Host Staging Dir Stamp "$HOST_STAGING_DIR_STAMP"" >&2 + exit 1 + fi + + refresh_timestamps "$HOST_STAGING_DIR_STAMP" + + return 0 +} + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + --host-build-dir) + [ -d "$1" ] || { + echo "Directory '$1' does not exist." >&2 + exit 1 + } + HOST_BUILD_DIR="$(cd "$1"; pwd)"; shift + ;; + + --host-staging-dir-stamp) + [ -d "$1" ] || { + echo "Directory '$1' does not exist." >&2 + exit 1 + } + HOST_STAGING_DIR_STAMP="$(cd "$1"; pwd)"; shift + ;; + + --tools) + [ -f "$1" ] || { + echo "Tools tar file '$1' does not exist." >&2 + exit 1 + } + TOOLS_TAR="$1"; shift + install_prebuilt_tools + + exit $? + ;; + + -h|--help) + me="$(basename "$0")" + echo -e "\nUsage:\n" >&2 + echo -e " $me --host-build-dir {directory}" >&2 + echo -e " Set to refresh timestamp of this build directory" >&2 + echo -e " with --tools." >&2 + echo -e " THIS OPTION MUST BE SET BEFORE --tools." >&2 + echo -e " If not provided the default directory is:" >&2 + echo -e " $(pwd)/build_dir/host\n" >&2 + echo -e " $me --host-staging-dir-stamp {directory}" >&2 + echo -e " Set to refresh staging timestamp present in this" >&2 + echo -e " directory with --tools." >&2 + echo -e " THIS OPTION MUST BE SET BEFORE --tools." >&2 + echo -e " If not provided the default directory is:" >&2 + echo -e " $(pwd)/staging_dir/host/stamp\n" >&2 + echo -e " $me --tools {tar}" >&2 + echo -e " Install the prebuilt tools present in the passed" >&2 + echo -e " tar and prepare them." >&2 + echo -e " To correctly use them it's needed to update the." >&2 + echo -e " timestamp of each tools to skip recompilation.\n" >&2 + echo -e " $me --help" >&2 + echo -e " Display this help text and exit.\n\n" >&2 + exit 1 + ;; + + *) + echo "Unknown argument '$arg'" >&2 + exec $0 --help + ;; + esac +done + +exec $0 --help diff --git a/scripts/feeds b/scripts/feeds index bbfd832c4..aee73e793 100755 --- a/scripts/feeds +++ b/scripts/feeds @@ -14,7 +14,7 @@ chdir $ENV{TOPDIR}; $ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'"; $ENV{GREP_OPTIONS}=""; -my $mk=`which gmake 2>/dev/null`; # select the right 'make' program +my $mk=`command -v gmake 2>/dev/null`; # select the right 'make' program chomp($mk); # trim trailing newline $mk or $mk = "make"; # default to 'make' @@ -167,8 +167,8 @@ my %update_method = ( 'init' => "git clone '%s' '%s'", 'init_branch' => "git clone --branch '%s' '%s' '%s'", 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -", - 'update' => "git pull --ff", - 'update_force' => "git pull --ff || (git reset --hard HEAD; git pull --ff; exit 1)", + 'update' => "git pull --ff-only", + 'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)", 'post_update' => "git submodule update --init --recursive", 'controldir' => ".git", 'revision' => "git rev-parse --short HEAD | tr -d '\n'"}, @@ -434,14 +434,16 @@ sub do_install_target($) { $path =~ s/\/Makefile$//; my $name = $path; $name =~ s/.*\///; - my $dest = "./target/linux/$name"; + my $dest = "./target/linux/feeds/$name"; + + -d "./target/linux/feeds" or mkdir "./target/linux/feeds"; -e $dest and do { warn "Path $dest already exists"; return 1; }; - system("ln -sf ../../$path ./target/linux/"); + system("ln -sf ../../../$path ./target/linux/feeds/"); } else { warn "Target is not valid\n"; return 1; @@ -498,16 +500,34 @@ sub is_core_src($) { sub install_target { my $feed = shift; my $name = shift; + my $force = shift; - $installed_targets{$name} and return 0; + $feed = lookup_target($feed, $name); + my $feed_name = $feed->[1]; - $feed = $feed_cache{$feed->[1]}->[2]; + -e "target/linux/feeds/$name" and return 0; + + # enable force flag if feed src line was declared with --force + if (exists($feed->[3]{force})) { + $force = 1; + } + + $feed = $feed_cache{$feed_name}->[2]; $feed or return 0; my $target = $feed->{$name}; $target or return 0; - warn "Installing target '$name'\n"; + if (-e "target/linux/$name") { + if ($force) { + warn "Overriding target '$name' with version from '$feed_name'\n"; + } else { + warn "WARNING: Not overriding core target '$name'; use -f to force\n"; + return 0; + } + } else { + warn "Installing target '$name'\n"; + } return do_install_target($target); } @@ -618,7 +638,7 @@ sub install_target_or_package { my $force = shift; lookup_target($feed, $name) and do { - return install_target($feed, $name); + return install_target($feed, $name, $force); }; lookup_src($feed, $name) and do { @@ -734,7 +754,7 @@ sub uninstall { } get_installed(); while ($name = shift @ARGV) { - my $target = "target/linux/$name"; + my $target = "target/linux/feeds/$name"; -l "$target" and do { uninstall_target($target); $uninstall = 1; @@ -901,7 +921,7 @@ my %commands = ( 'uninstall' => \&uninstall, 'feed_config' => \&feed_config, 'clean' => sub { - system("rm -rf ./feeds ./package/feeds"); + system("rm -rf ./feeds ./package/feeds ./target/linux/feeds"); } ); diff --git a/scripts/flashing/eva_ramboot.py b/scripts/flashing/eva_ramboot.py index b182f09d2..365fceecf 100755 --- a/scripts/flashing/eva_ramboot.py +++ b/scripts/flashing/eva_ramboot.py @@ -3,7 +3,6 @@ import argparse from ftplib import FTP -from sys import argv from os import stat parser = argparse.ArgumentParser(description='Tool to boot AVM EVA ramdisk images.') diff --git a/scripts/gen-rddependencies.sh b/scripts/gen-rddependencies.sh new file mode 100755 index 000000000..509d6a4fa --- /dev/null +++ b/scripts/gen-rddependencies.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +TARGETS=$* +READELF="${READELF:-readelf}" +XARGS="${XARGS:-xargs -r}" + +find $TARGETS -type f -a -exec file {} \; | \ + sed -n -e 's/^\(.*\):.*ELF.*\(executable\|shared object\).*,.*/\1/p' | \ + $XARGS -n1 $READELF -l | grep 'Requesting' | cut -d':' -f2 | tr -d ' ]' | \ + $XARGS basename + +cd `dirname ${0}` +./gen-dependencies.sh ${TARGETS} diff --git a/scripts/gen_image_generic.sh b/scripts/gen_image_generic.sh index 17888eac6..ef1362440 100755 --- a/scripts/gen_image_generic.sh +++ b/scripts/gen_image_generic.sh @@ -26,15 +26,33 @@ KERNELSIZE="$2" ROOTFSOFFSET="$(($3 / 512))" ROOTFSSIZE="$(($4 / 512))" +# Using mcopy -s ... is using READDIR(3) to iterate through the directory +# entries, hence they end up in the FAT filesystem in traversal order which +# breaks reproducibility. +# Implement recursive copy with reproducible order. +dos_dircopy() { + local entry + local baseentry + for entry in "$1"/* ; do + if [ -f "$entry" ]; then + mcopy -i "$OUTPUT.kernel" "$entry" ::"$2" + elif [ -d "$entry" ]; then + baseentry="$(basename "$entry")" + mmd -i "$OUTPUT.kernel" ::"$2""$baseentry" + dos_dircopy "$entry" "$2""$baseentry"/ + fi + done +} + [ -n "$PADDING" ] && dd if=/dev/zero of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc count="$ROOTFSSIZE" dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc if [ -n "$GUID" ]; then [ -n "$PADDING" ] && dd if=/dev/zero of="$OUTPUT" bs=512 seek="$((ROOTFSOFFSET + ROOTFSSIZE))" conv=notrunc count="$sect" - mkfs.fat -n kernel -C "$OUTPUT.kernel" -S 512 "$((KERNELSIZE / 1024))" - mcopy -s -i "$OUTPUT.kernel" "$KERNELDIR"/* ::/ + mkfs.fat --invariant -n kernel -C "$OUTPUT.kernel" -S 512 "$((KERNELSIZE / 1024))" + LC_ALL=C dos_dircopy "$KERNELDIR" / else - make_ext4fs -J -L kernel -l "$KERNELSIZE" "$OUTPUT.kernel" "$KERNELDIR" + make_ext4fs -J -L kernel -l "$KERNELSIZE" ${SOURCE_DATE_EPOCH:+-T ${SOURCE_DATE_EPOCH}} "$OUTPUT.kernel" "$KERNELDIR" fi dd if="$OUTPUT.kernel" of="$OUTPUT" bs=512 seek="$KERNELOFFSET" conv=notrunc rm -f "$OUTPUT.kernel" diff --git a/scripts/gen_image_gpt.sh b/scripts/gen_image_gpt.sh deleted file mode 100755 index 68af1f2ff..000000000 --- a/scripts/gen_image_gpt.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Copyright (C) 2006-2012 OpenWrt.org -set -e -x -if [ $# -ne 5 ] && [ $# -ne 6 ]; then - echo "SYNTAX: $0 " - exit 1 -fi - -OUTPUT="$1" -KERNELSIZE="$2" -KERNELDIR="$3" -ROOTFSSIZE="$4" -ROOTFSIMAGE="$5" - -UBOOTSIZE=8 -UBOOTOFFSET=8 -KERNELOFFSET="$(($UBOOTOFFSET + $UBOOTSIZE))" -ROOTFSOFFSET="$(($KERNELSIZE + $KERNELOFFSET))" - -rm -f "$OUTPUT" - -# create partition table -set $(ptgen -g -o "$OUTPUT" -a 2 -N uboot -p "$UBOOTSIZE"M@"$UBOOTOFFSET"M -N kernel -p "$KERNELSIZE"M@"$KERNELOFFSET"M -N rootfs -p "$ROOTFSSIZE"M@"$ROOTFSOFFSET"M) - -KERNELOFFSET="$(($3 / 512))" -KERNELSIZE="$4" -ROOTFSOFFSET="$(($5 / 512))" -ROOTFSSIZE="$(($6 / 512))" - -[ -n "$PADDING" ] && dd if=/dev/zero of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc count="$ROOTFSSIZE" -dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc - -if [ -n "$GUID" ]; then - [ -n "$PADDING" ] && dd if=/dev/zero of="$OUTPUT" bs=512 seek="$((ROOTFSOFFSET + ROOTFSSIZE))" conv=notrunc count="$sect" - mkfs.fat -n kernel -C "$OUTPUT.kernel" -S 512 "$((KERNELSIZE / 1024))" - mcopy -s -i "$OUTPUT.kernel" "$KERNELDIR"/* ::/ -else - make_ext4fs -J -L kernel -l "$KERNELSIZE" "$OUTPUT.kernel" "$KERNELDIR" -fi -dd if="$OUTPUT.kernel" of="$OUTPUT" bs=512 seek="$KERNELOFFSET" conv=notrunc -rm -f "$OUTPUT.kernel" diff --git a/scripts/ipkg-build b/scripts/ipkg-build index c112270a2..122cca2cb 100755 --- a/scripts/ipkg-build +++ b/scripts/ipkg-build @@ -58,7 +58,8 @@ pkg_appears_sane() { rm "$CONTROL"/conffiles if [ -f "$CONTROL"/conffiles.resolved ]; then - mv "$CONTROL"/conffiles.resolved "$CONTROL"/conffiles + LC_ALL=C sort -o "$CONTROL"/conffiles "$CONTROL"/conffiles.resolved + rm "$CONTROL"/conffiles.resolved chmod 0644 "$CONTROL"/conffiles fi fi @@ -178,20 +179,20 @@ for file_mode in $file_modes; do chown "$uid:$gid" "$pkg_dir/$path" chmod "$mode" "$pkg_dir/$path" done -$TAR -X "$tmp_dir"/tarX --format=gnu --sort=name -cpf - --mtime="$TIMESTAMP" . | gzip -n - > "$tmp_dir"/data.tar.gz +$TAR -X "$tmp_dir"/tarX --format=gnu --numeric-owner --sort=name -cpf - --mtime="$TIMESTAMP" . | gzip -n - > "$tmp_dir"/data.tar.gz installed_size=$(stat -c "%s" "$tmp_dir"/data.tar.gz) sed -i -e "s/^Installed-Size: .*/Installed-Size: $installed_size/" \ "$pkg_dir"/$CONTROL/control -( cd "$pkg_dir"/$CONTROL && $TAR --format=gnu --sort=name -cf - --mtime="$TIMESTAMP" . | gzip -n - > "$tmp_dir"/control.tar.gz ) +( cd "$pkg_dir"/$CONTROL && $TAR --format=gnu --numeric-owner --sort=name -cf - --mtime="$TIMESTAMP" . | gzip -n - > "$tmp_dir"/control.tar.gz ) rm "$tmp_dir"/tarX echo "2.0" > "$tmp_dir"/debian-binary pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk rm -f "$pkg_file" -( cd "$tmp_dir" && $TAR --format=gnu --sort=name -cf - --mtime="$TIMESTAMP" ./debian-binary ./data.tar.gz ./control.tar.gz | gzip -n - > "$pkg_file" ) +( cd "$tmp_dir" && $TAR --format=gnu --numeric-owner --sort=name -cf - --mtime="$TIMESTAMP" ./debian-binary ./data.tar.gz ./control.tar.gz | gzip -n - > "$pkg_file" ) rm "$tmp_dir"/debian-binary "$tmp_dir"/data.tar.gz "$tmp_dir"/control.tar.gz rmdir "$tmp_dir" diff --git a/scripts/json_add_image_info.py b/scripts/json_add_image_info.py index 38cd3c487..9aa2a19e4 100755 --- a/scripts/json_add_image_info.py +++ b/scripts/json_add_image_info.py @@ -11,11 +11,11 @@ if len(argv) != 2: exit(1) json_path = Path(argv[1]) -bin_dir = Path(getenv("BIN_DIR")) -image_file = bin_dir / getenv("DEVICE_IMG_NAME") +file_path = Path(getenv("FILE_DIR")) / getenv("FILE_NAME") -if not image_file.is_file(): - print("Skip JSON creation for non existing image ", image_file) + +if not file_path.is_file(): + print("Skip JSON creation for non existing file", file_path) exit(0) @@ -37,23 +37,30 @@ def get_titles(): device_id = getenv("DEVICE_ID") -image_hash = hashlib.sha256(image_file.read_bytes()).hexdigest() +hash_file = hashlib.sha256(file_path.read_bytes()).hexdigest() -image_info = { +if file_path.with_suffix(file_path.suffix + ".sha256sum").exists(): + hash_unsigned = ( + file_path.with_suffix(file_path.suffix + ".sha256sum").read_text().strip() + ) +else: + hash_unsigned = hash_file + +file_info = { "metadata_version": 1, "target": "{}/{}".format(getenv("TARGET"), getenv("SUBTARGET")), "version_code": getenv("VERSION_CODE"), "version_number": getenv("VERSION_NUMBER"), - "source_date_epoch": getenv("SOURCE_DATE_EPOCH"), + "source_date_epoch": int(getenv("SOURCE_DATE_EPOCH")), "profiles": { device_id: { "image_prefix": getenv("DEVICE_IMG_PREFIX"), "images": [ { - "type": getenv("IMAGE_TYPE"), - "filesystem": getenv("IMAGE_FILESYSTEM"), - "name": getenv("DEVICE_IMG_NAME"), - "sha256": image_hash, + "type": getenv("FILE_TYPE"), + "name": getenv("FILE_NAME"), + "sha256": hash_file, + "sha256_unsigned": hash_unsigned, } ], "device_packages": getenv("DEVICE_PACKAGES").split(), @@ -63,4 +70,9 @@ image_info = { }, } -json_path.write_text(json.dumps(image_info, separators=(",", ":"))) +if getenv("FILE_FILESYSTEM"): + file_info["profiles"][device_id]["images"][0]["filesystem"] = getenv( + "FILE_FILESYSTEM" + ) + +json_path.write_text(json.dumps(file_info, separators=(",", ":"))) diff --git a/scripts/json_overview_image_info.py b/scripts/json_overview_image_info.py index 45c05012b..89b7d4fe2 100755 --- a/scripts/json_overview_image_info.py +++ b/scripts/json_overview_image_info.py @@ -7,7 +7,7 @@ from sys import argv import json if len(argv) != 2: - print("JSON info files script requires ouput file as argument") + print("JSON info files script requires output file as argument") exit(1) output_path = Path(argv[1]) @@ -42,7 +42,7 @@ for json_file in work_dir.glob("*.json"): output["profiles"][device_id]["images"].extend(profile["images"]) # make image lists unique by name, keep last/latest -for device_id, profile in output["profiles"].items(): +for device_id, profile in output.get("profiles", {}).items(): profile["images"] = list({e["name"]: e for e in profile["images"]}.values()) diff --git a/scripts/linksys-image.sh b/scripts/linksys-image.sh index 36a676d96..d251b5da8 100755 --- a/scripts/linksys-image.sh +++ b/scripts/linksys-image.sh @@ -11,13 +11,12 @@ # This is appended to the factory image and is tested by the Linksys Upgrader - as observed in civic. # The footer is 256 bytes. The format is: # .LINKSYS. This is detected by the Linksys upgrader before continuing with upgrade. (9 bytes) -# The version number of upgrade. Not checked so use arbitary value (8 bytes) +# The version number of upgrade. Not checked so use arbitrary value (8 bytes) # Model of target device, padded (0x20) to (15 bytes) # CRC checksum of the image to flash (8 byte) -# Padding (0x20) (7 bytes) -# Signature of signer. Not checked so use Arbitary value (16 bytes) +# Padding ('0' + 0x20 *7) (8 bytes) +# Signature of signer. Not checked so use arbitrary value (16 bytes) # Padding (0x00) (192 bytes) -# 0x0A (1 byte) ## version history # * version 1: initial commit @@ -58,10 +57,8 @@ IMG_OUT="${IMG_IN}.new" dd if="${IMG_IN}" of="${IMG_TMP_OUT}" CRC=$(printf "%08X" $(dd if="${IMG_IN}" bs=$(stat -c%s "${IMG_IN}") count=1|cksum| cut -d ' ' -f1)) -printf ".LINKSYS.01000409%-15s%-8s%-7s%-16s" "${TYPE}" "${CRC}" "" "K0000000F0246434" >> "${IMG_TMP_OUT}" +printf ".LINKSYS.01000409%-15s%-8s%-8s%-16s" "${TYPE}" "${CRC}" "0" "K0000000F0246434" >> "${IMG_TMP_OUT}" dd if=/dev/zero bs=1 count=192 conv=notrunc >> "${IMG_TMP_OUT}" -printf '\12' >> "${IMG_TMP_OUT}" - cp "${IMG_TMP_OUT}" "${IMG_OUT}" diff --git a/scripts/metadata.pm b/scripts/metadata.pm index 5fbb77a36..ee5a2945c 100644 --- a/scripts/metadata.pm +++ b/scripts/metadata.pm @@ -290,17 +290,24 @@ sub parse_package_metadata($) { }; /^Config:\s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline(*FILE, "\t"); /^Prereq-Check:/ and $pkg->{prereq} = 1; + /^Maintainer: \s*(.+)\s*$/ and $pkg->{maintainer} = [ split /, /, $1 ]; /^Require-User:\s*(.*?)\s*$/ and do { my @ugspecs = split /\s+/, $1; for my $ugspec (@ugspecs) { - my @ugspec = split /:/, $ugspec, 2; + my @ugspec = split /:/, $ugspec, 3; if ($ugspec[0]) { parse_package_metadata_usergroup($src->{makefile}, "user", \%usernames, \%userids, $ugspec[0]) or return 0; } if ($ugspec[1]) { parse_package_metadata_usergroup($src->{makefile}, "group", \%groupnames, \%groupids, $ugspec[1]) or return 0; } + if ($ugspec[2]) { + my @addngroups = split /,/, $ugspec[2]; + for my $addngroup (@addngroups) { + parse_package_metadata_usergroup($src->{makefile}, "group", \%groupnames, \%groupids, $addngroup) or return 0; + } + } } }; } diff --git a/scripts/mkhash.c b/scripts/mkhash.c index ed3d42d4c..a28d5fd53 100644 --- a/scripts/mkhash.c +++ b/scripts/mkhash.c @@ -105,7 +105,6 @@ be32enc(void *buf, uint32_t u) p[2] = ((uint8_t) ((u >> 8) & 0xff)); p[3] = ((uint8_t) (u & 0xff)); } -#endif static void be64enc(void *buf, uint64_t u) @@ -132,6 +131,7 @@ be32dec(const void *buf) return (((uint32_t) be16dec(p)) << 16) | be16dec(p + 2); } +#endif #define MD5_DIGEST_LENGTH 16 diff --git a/scripts/mkits-zyxel-fit.sh b/scripts/mkits-zyxel-fit.sh new file mode 100755 index 000000000..8ace1941e --- /dev/null +++ b/scripts/mkits-zyxel-fit.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# Licensed under the terms of the GNU GPL License version 2 or later. +# Author: David Bauer , based on mkits-zyxel-factory.sh. + +usage() { + echo "Usage: `basename $0` output file compat-models" + exit 1 +} + +# We need at least 3 arguments +[ "$#" -lt 3 ] && usage + +# Target output file +OUTPUT="$1"; shift +FILE="$1"; shift +MODELS="$1"; shift + +# Create a default, fully populated DTS file +echo "\ +/dts-v1/; + +/ { + description = \"Zyxel FIT (Flattened Image Tree)\"; + compat-models = [${MODELS}]; + #address-cells = <1>; + + images { + firmware { + data = /incbin/(\"${FILE}\"); + type = \"firmware\"; + compression = \"none\"; + hash@1 { + algo = \"sha1\"; + }; + }; + }; +};" > ${OUTPUT} diff --git a/scripts/mkits.sh b/scripts/mkits.sh index 1add8087b..bf75d69f0 100755 --- a/scripts/mkits.sh +++ b/scripts/mkits.sh @@ -32,12 +32,15 @@ usage() { printf "\n\t-d ==> include Device Tree Blob 'dtb'" printf "\n\t-r ==> include RootFS blob 'rootfs'" printf "\n\t-H ==> specify hash algo instead of SHA1" + printf "\n\t-l ==> legacy mode character (@ etc otherwise -)" printf "\n\t-o ==> create output file 'its_file'" printf "\n\t-O ==> create config with dt overlay 'name:dtb'" + printf "\n\t-s ==> set FDT load address to 'addr' (hex)" printf "\n\t\t(can be specified more than once)\n" exit 1 } +REFERENCE_CHAR='-' FDTNUM=1 ROOTFSNUM=1 INITRDNUM=1 @@ -46,7 +49,7 @@ LOADABLES= DTOVERLAY= DTADDR= -while getopts ":A:a:c:C:D:d:e:f:i:k:n:o:O:v:r:H:" OPTION +while getopts ":A:a:c:C:D:d:e:f:i:k:l:n:o:O:v:r:s:H:" OPTION do case $OPTION in A ) ARCH=$OPTARG;; @@ -59,10 +62,12 @@ do f ) COMPATIBLE=$OPTARG;; i ) INITRD=$OPTARG;; k ) KERNEL=$OPTARG;; + l ) REFERENCE_CHAR=$OPTARG;; n ) FDTNUM=$OPTARG;; o ) OUTPUT=$OPTARG;; O ) DTOVERLAY="$DTOVERLAY ${OPTARG}";; r ) ROOTFS=$OPTARG;; + s ) FDTADDR=$OPTARG;; H ) HASH=$OPTARG;; v ) VERSION=$OPTARG;; * ) echo "Invalid option passed to '$0' (options:$*)" @@ -84,14 +89,18 @@ if [ -n "${COMPATIBLE}" ]; then fi [ "$DTOVERLAY" ] && { - dtbsize=$(wc -c "$DTB" | cut -d' ' -f1) + dtbsize=$(wc -c "$DTB" | awk '{print $1}') DTADDR=$(printf "0x%08x" $(($LOAD_ADDR - $dtbsize)) ) } +[ "$FDTADDR" ] && { + DTADDR="$FDTADDR" +} + # Conditionally create fdt information if [ -n "${DTB}" ]; then FDT_NODE=" - fdt-$FDTNUM { + fdt${REFERENCE_CHAR}$FDTNUM { description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree blob\"; ${COMPATIBLE_PROP} data = /incbin/(\"${DTB}\"); @@ -107,12 +116,12 @@ if [ -n "${DTB}" ]; then }; }; " - FDT_PROP="fdt = \"fdt-$FDTNUM\";" + FDT_PROP="fdt = \"fdt${REFERENCE_CHAR}$FDTNUM\";" fi if [ -n "${INITRD}" ]; then INITRD_NODE=" - initrd-$INITRDNUM { + initrd${REFERENCE_CHAR}$INITRDNUM { description = \"${ARCH_UPPER} OpenWrt ${DEVICE} initrd\"; ${COMPATIBLE_PROP} data = /incbin/(\"${INITRD}\"); @@ -127,14 +136,14 @@ if [ -n "${INITRD}" ]; then }; }; " - INITRD_PROP="ramdisk=\"initrd-${INITRDNUM}\";" + INITRD_PROP="ramdisk=\"initrd${REFERENCE_CHAR}${INITRDNUM}\";" fi if [ -n "${ROOTFS}" ]; then dd if="${ROOTFS}" of="${ROOTFS}.pagesync" bs=4096 conv=sync ROOTFS_NODE=" - rootfs-$ROOTFSNUM { + rootfs${REFERENCE_CHAR}$ROOTFSNUM { description = \"${ARCH_UPPER} OpenWrt ${DEVICE} rootfs\"; ${COMPATIBLE_PROP} data = /incbin/(\"${ROOTFS}.pagesync\"); @@ -149,7 +158,7 @@ if [ -n "${ROOTFS}" ]; then }; }; " - LOADABLES="${LOADABLES:+$LOADABLES, }\"rootfs-${ROOTFSNUM}\"" + LOADABLES="${LOADABLES:+$LOADABLES, }\"rootfs${REFERENCE_CHAR}${ROOTFSNUM}\"" fi # add DT overlay blobs @@ -159,7 +168,7 @@ OVCONFIGS="" overlay_blob=${overlay##*:} ovname=${overlay%%:*} ovnode="fdt-$ovname" - ovsize=$(wc -c "$overlay_blob" | cut -d' ' -f1) + ovsize=$(wc -c "$overlay_blob" | awk '{print $1}') echo "$ovname ($overlay_blob) : $ovsize" >&2 DTADDR=$(printf "0x%08x" $(($DTADDR - $ovsize))) FDTOVERLAY_NODE="$FDTOVERLAY_NODE @@ -184,8 +193,8 @@ OVCONFIGS="" config-$ovname { description = \"OpenWrt ${DEVICE} with $ovname\"; - kernel = \"kernel-1\"; - fdt = \"fdt-$FDTNUM\", \"$ovnode\"; + kernel = \"kernel${REFERENCE_CHAR}1\"; + fdt = \"fdt${REFERENCE_CHAR}$FDTNUM\", \"$ovnode\"; ${LOADABLES:+loadables = ${LOADABLES};} ${COMPATIBLE_PROP} ${INITRD_PROP} @@ -201,7 +210,7 @@ DATA="/dts-v1/; #address-cells = <1>; images { - kernel-1 { + kernel${REFERENCE_CHAR}1 { description = \"${ARCH_UPPER} OpenWrt Linux-${VERSION}\"; data = /incbin/(\"${KERNEL}\"); type = \"kernel\"; @@ -227,7 +236,7 @@ ${ROOTFS_NODE} default = \"${CONFIG}\"; ${CONFIG} { description = \"OpenWrt ${DEVICE}\"; - kernel = \"kernel-1\"; + kernel = \"kernel${REFERENCE_CHAR}1\"; ${FDT_PROP} ${LOADABLES:+loadables = ${LOADABLES};} ${COMPATIBLE_PROP} diff --git a/scripts/netgear-encrypted-factory.py b/scripts/netgear-encrypted-factory.py new file mode 100755 index 000000000..b6bb72f3b --- /dev/null +++ b/scripts/netgear-encrypted-factory.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +import argparse +import re +import struct +import subprocess +import zlib + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--input-file', type=str, required=True) + parser.add_argument('--output-file', type=str, required=True) + parser.add_argument('--model', type=str, required=True) + parser.add_argument('--region', type=str, required=True) + parser.add_argument('--version', type=str, required=True) + parser.add_argument('--encryption-block-size', type=str, required=True) + parser.add_argument('--openssl-bin', type=str, required=True) + parser.add_argument('--key', type=str, required=True) + parser.add_argument('--iv', type=str, required=True) + args = parser.parse_args() + + assert re.match(r'V[0-9]\.[0-9]\.[0-9]\.[0-9]', + args.version), 'Version must start with Vx.x.x.x' + encryption_block_size = int(args.encryption_block_size, 0) + assert (encryption_block_size > 0 and encryption_block_size % 16 == + 0), 'Encryption block size must be a multiple of the AES block size (16)' + + image = open(args.input_file, 'rb').read() + image_enc = [] + for i in range(0, len(image), encryption_block_size): + chunk = image[i:i + encryption_block_size] + chunk += b'\x00' * ((-len(chunk)) % 16) # pad to AES block size (16) + res = subprocess.run([ + args.openssl_bin, + 'enc', + '-aes-256-cbc', + '-nosalt', + '-nopad', + '-K', args.key, + '-iv', args.iv + ], + check=True, input=chunk, stdout=subprocess.PIPE) + image_enc.append(res.stdout) + image_enc = b''.join(image_enc) + + image_with_header = struct.pack( + '>32s32s64s64s64s256s12sII', + args.model.encode('ascii'), + args.region.encode('ascii'), + args.version.encode('ascii'), + b'Thu Jan 1 00:00:00 1970', # static date for reproducibility + b'', # reserved + b'', # RSA signature - omitted for now + b'encrpted_img', + len(image_enc), + encryption_block_size, + ) + image_enc + + checksum = zlib.crc32(image_with_header, 0xffffffff) ^ 0xffffffff + + with open(args.output_file, 'wb') as outfile: + outfile.write(image_with_header) + outfile.write(struct.pack('>I', checksum)) + + +if __name__ == "__main__": + main() diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl index 02102be8f..6288584d6 100755 --- a/scripts/package-metadata.pl +++ b/scripts/package-metadata.pl @@ -585,6 +585,40 @@ sub gen_usergroup_list() { } } +sub gen_package_manifest_json() { + my $json; + parse_package_metadata($ARGV[0]) or exit 1; + foreach my $name (sort {uc($a) cmp uc($b)} keys %package) { + my %depends; + my $pkg = $package{$name}; + foreach my $dep (@{$pkg->{depends} || []}) { + if ($dep =~ m!^\+?(?:[^:]+:)?([^@]+)$!) { + $depends{$1}++; + } + } + my @depends = sort keys %depends; + my $pkg_deps = join ' ', map { qq/"$_",/ } @depends; + $pkg_deps =~ s/\,$//; + + my $pkg_maintainer = join ' ', map { qq/"$_",/ } @{$pkg->{maintainer} || []}; + $pkg_maintainer =~ s/\,$//; + + $json = <<"END_JSON"; +${json}{ +"name":"$name", +"version":"$pkg->{version}", +"category":"$pkg->{category}", +"license":"$pkg->{license}", +"maintainer": [$pkg_maintainer], +"depends":[$pkg_deps]}, +END_JSON + } + + $json =~ s/[\n\r]//g; + $json =~ s/\,$//; + print "[$json]"; +} + sub parse_command() { GetOptions("ignore=s", \@ignore); my $cmd = shift @ARGV; @@ -594,6 +628,7 @@ sub parse_command() { /^kconfig/ and return gen_kconfig_overrides(); /^source$/ and return gen_package_source(); /^pkgaux$/ and return gen_package_auxiliary(); + /^pkgmanifestjson$/ and return gen_package_manifest_json(); /^license$/ and return gen_package_license(0); /^licensefull$/ and return gen_package_license(1); /^usergroup$/ and return gen_usergroup_list(); @@ -606,6 +641,7 @@ Available Commands: $0 kconfig [file] [config] [patchver] Kernel config overrides $0 source [file] Package source file information $0 pkgaux [file] Package auxiliary variables in makefile format + $0 pkgmanifestjson [file] Package manifests in JSON format $0 license [file] Package license information $0 licensefull [file] Package license information (full list) $0 usergroup [file] Package usergroup allocation list diff --git a/scripts/pad_image b/scripts/pad_image index b1941a28d..871063af3 100755 --- a/scripts/pad_image +++ b/scripts/pad_image @@ -2,7 +2,7 @@ function usage { echo "Usage: prepare_image image_type kernel_image rootfs_image header_size" - echo "Padd root and kernel image to the correct size and append the jffs2 start marker as needed" + echo "Pad root and kernel image to the correct size and append the jffs2 start marker as needed" exit 1 } diff --git a/scripts/rstrip.sh b/scripts/rstrip.sh index 59f8624df..e47960a94 100755 --- a/scripts/rstrip.sh +++ b/scripts/rstrip.sh @@ -27,6 +27,7 @@ find $TARGETS -type f -a -exec file {} \; | \ while read F S; do echo "$SELF: $F: $S" [ "${S}" = "relocatable" ] && { + [ "${F##*.}" == "o" ] && continue eval "$STRIP_KMOD $F" } || { b=$(stat -c '%a' $F) diff --git a/scripts/sercomm-kernel-header.py b/scripts/sercomm-kernel-header.py new file mode 100755 index 000000000..bfb29c6fe --- /dev/null +++ b/scripts/sercomm-kernel-header.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +""" +# SPDX-License-Identifier: GPL-2.0-or-later +# +# sercomm-kernel-header.py: Creates Sercomm kernel header +# +# Copyright © 2022 Mikhail Zhilkin +""" + +import argparse +import binascii +import os +import struct + +KERNEL_HEADER_SIZE = 0x100 +PADDING = 0xff +ROOTFS_FAKE_HEADER = "UBI#" + +def auto_int(x): + return int(x, 0) + +def create_kernel_header(args): + out_file = open(args.header_file, "wb") + header = get_kernel_header(args) + out_file.write(header) + out_file.close() + +def get_kernel_header(args): + header = bytearray([PADDING] * KERNEL_HEADER_SIZE) + + struct.pack_into('8s', buf, 0x0, enc) + + enc = binascii.hexlify(args.hw_id.encode()) + struct.pack_into('>6s', buf, 0x8, enc) + + enc = args.sw_version.rjust(4, '0').encode('ascii') + struct.pack_into('>4s', buf, 0x64, enc) + + if (args.extra_padd_size): + tail = bytearray([PADDING_TAIL] * args.extra_padd_size) + if (args.extra_padd_byte): + struct.pack_into ('{'name'}, $filename); } - # If the next parition is before the end of the current image, then rewind. + # If the next partition is before the end of the current image, then rewind. elsif ($_->{'offset'} < $end_point) { $debug and printf("Rewound %s before <%s> in \"%s\"\n", (($end_point - $_->{'offset'}) >= $block_size ? @@ -971,7 +971,7 @@ if (!GetOptions("d|debug" => \$debug, print " [-b|--redboot] Input/Output RedBoot filename\n"; print " [-s|--sysconf] Input/Output SysConf filename\n"; print " [-L|--loader] Second stage boot loader filename\n"; - print " [-k|--kernel] Input/Ouptut Kernel filename\n"; + print " [-k|--kernel] Input/Output Kernel filename\n"; print " [-r|--ramdisk] Input/Output Ramdisk filename(s)\n"; print " [-f|--fisdir] Input/Output FIS directory filename\n"; print " [-m|--microcode] Input/Output Microcode filename\n"; diff --git a/scripts/target-metadata.pl b/scripts/target-metadata.pl index 91a201c5e..223b5aaec 100755 --- a/scripts/target-metadata.pl +++ b/scripts/target-metadata.pl @@ -10,43 +10,44 @@ sub target_config_features(@) { while ($_ = shift @_) { /^arm_v(\w+)$/ and $ret .= "\tselect arm_v$1\n"; - /^broken$/ and $ret .= "\tdepends on BROKEN\n"; /^audio$/ and $ret .= "\tselect AUDIO_SUPPORT\n"; + /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n"; + /^broken$/ and $ret .= "\tdepends on BROKEN\n"; + /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n"; /^display$/ and $ret .= "\tselect DISPLAY_SUPPORT\n"; /^dt$/ and $ret .= "\tselect USES_DEVICETREE\n"; - /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n"; - /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n"; - /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n"; - /^usb$/ and $ret .= "\tselect USB_SUPPORT\n"; - /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n"; - /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n"; - /^pwm$/ and $ret .= "\select PWM_SUPPORT\n"; - /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n"; - /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n"; + /^dt-overlay$/ and $ret .= "\tselect HAS_DT_OVERLAY_SUPPORT\n"; /^emmc$/ and $ret .= "\tselect EMMC_SUPPORT\n"; + /^ext4$/ and $ret .= "\tselect USES_EXT4\n"; + /^fpu$/ and $ret .= "\tselect HAS_FPU\n"; + /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n"; /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n"; /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n"; - /^ext4$/ and $ret .= "\tselect USES_EXT4\n"; - /^targz$/ and $ret .= "\tselect USES_TARGZ\n"; - /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n"; - /^minor$/ and $ret .= "\tselect USES_MINOR\n"; - /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n"; - /^fpu$/ and $ret .= "\tselect HAS_FPU\n"; - /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n"; - /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n"; - /^separate_ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n\tselect USES_SEPARATE_INITRAMFS\n"; - /^powerpc64$/ and $ret .= "\tselect powerpc64\n"; - /^nommu$/ and $ret .= "\tselect NOMMU\n"; - /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n"; - /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n"; + /^legacy-sdcard$/ and $ret .= "\tselect LEGACY_SDCARD_SUPPORT\n"; /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n"; - /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n"; + /^minor$/ and $ret .= "\tselect USES_MINOR\n"; + /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n"; /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n"; - /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n"; + /^nommu$/ and $ret .= "\tselect NOMMU\n"; + /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n"; + /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n"; + /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n"; + /^powerpc64$/ and $ret .= "\tselect powerpc64\n"; + /^pwm$/ and $ret .= "\select PWM_SUPPORT\n"; + /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n"; + /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n"; /^rootfs-part$/ and $ret .= "\tselect USES_ROOTFS_PART\n"; - /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n"; + /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n"; + /^separate_ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n\tselect USES_SEPARATE_INITRAMFS\n"; + /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n"; + /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n"; + /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n"; + /^targz$/ and $ret .= "\tselect USES_TARGZ\n"; /^testing-kernel$/ and $ret .= "\tselect HAS_TESTING_KERNEL\n"; - /^dt-overlay$/ and $ret .= "\tselect HAS_DT_OVERLAY_SUPPORT\n"; + /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n"; + /^usb$/ and $ret .= "\tselect USB_SUPPORT\n"; + /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n"; + /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n"; } return $ret; } diff --git a/scripts/ubinize-image.sh b/scripts/ubinize-image.sh index c6f8bcefe..323eae547 100755 --- a/scripts/ubinize-image.sh +++ b/scripts/ubinize-image.sh @@ -66,20 +66,22 @@ ubilayout() { vol_id=$(( $vol_id + 1 )) fi - case "$rootfs_type" in - "ubifs") - autoresize=1 - ;; - "squashfs") - # squashfs uses 1k block size, ensure we do not - # violate that - rootsize="$( round_up "$( stat -c%s "$2" )" 1024 )" - ;; - esac - ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize" + if [ "$2" ]; then + case "$rootfs_type" in + "ubifs") + autoresize=1 + ;; + "squashfs") + # squashfs uses 1k block size, ensure we do not + # violate that + rootsize="$( round_up "$( stat -c%s "$2" )" 1024 )" + ;; + esac + ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize" - vol_id=$(( $vol_id + 1 )) - [ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1 + vol_id=$(( $vol_id + 1 )) + [ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1 + fi } set_ubinize_seq() { @@ -101,6 +103,12 @@ while [ "$1" ]; do shift continue ;; + "--rootfs") + rootfs="$2" + shift + shift + continue + ;; "--part") parts="$parts $2" shift @@ -112,11 +120,6 @@ while [ "$1" ]; do break ;; *) - if [ ! "$rootfs" ]; then - rootfs=$1 - shift - continue - fi if [ ! "$outfile" ]; then outfile=$1 shift @@ -126,12 +129,12 @@ while [ "$1" ]; do esac done -if [ ! -r "$rootfs" -o ! -r "$kernel" -a ! "$outfile" ]; then - echo "syntax: $0 [--uboot-env] [--part =] [--kernel kernelimage] rootfs out [ubinize opts]" +if [ ! -r "$rootfs" -a ! -r "$kernel" -a ! "$outfile" ]; then + echo "syntax: $0 [--uboot-env] [--part =] [--kernel kernelimage] [--rootfs rootfsimage] out [ubinize opts]" exit 1 fi -ubinize="$( which ubinize )" +ubinize="$( command -v ubinize )" if [ ! -x "$ubinize" ]; then echo "ubinize tool not found or not usable" exit 1 diff --git a/scripts/xxdi.pl b/scripts/xxdi.pl new file mode 100755 index 000000000..f7bb3c2f9 --- /dev/null +++ b/scripts/xxdi.pl @@ -0,0 +1,66 @@ +#!/usr/bin/env perl +# +# xxdi.pl - perl implementation of 'xxd -i' mode +# +# Copyright 2013 Greg Kroah-Hartman +# Copyright 2013 Linux Foundation +# +# Released under the GPLv2. +# +# Implements the "basic" functionality of 'xxd -i' in perl to keep build +# systems from having to build/install/rely on vim-core, which not all +# distros want to do. But everyone has perl, so use it instead. +# + +use strict; +use warnings; + +my $indata; +my $var_name = "stdin"; +my $full_output = (@ARGV > 0 && $ARGV[0] eq '-i') ? shift @ARGV : undef; + +{ + local $/; + my $fh; + + if (@ARGV) { + $var_name = $ARGV[0]; + open($fh, '<:raw', $var_name) || die("xxdi.pl: Unable to open $var_name: $!\n"); + } elsif (! -t STDIN) { + $fh = \*STDIN; + undef $full_output; + } else { + die "usage: xxdi.pl [-i] [infile]\n"; + } + + $indata = readline $fh; + + close $fh; +} + +my $len_data = length($indata); +my $num_digits_per_line = 12; +my $outdata = ""; + +# Use the variable name of the file we read from, converting '/' and '. +# to '_', or, if this is stdin, just use "stdin" as the name. +$var_name =~ s/\//_/g; +$var_name =~ s/\./_/g; +$var_name = "__$var_name" if $var_name =~ /^\d/; + +$outdata = "unsigned char $var_name\[] = { " if $full_output; + +for (my $key= 0; $key < $len_data; $key++) { + if ($key % $num_digits_per_line == 0) { + $outdata = substr($outdata, 0, -1)."\n "; + } + $outdata .= sprintf("0x%.2x, ", ord(substr($indata, $key, 1))); +} + +$outdata = substr($outdata, 0, -2); +$outdata .= "\n"; + +$outdata .= "};\nunsigned int $var_name\_len = $len_data;\n" if $full_output; + +binmode STDOUT; +print $outdata; diff --git a/toolchain/Config.in b/toolchain/Config.in index 2d29ec09e..6d3cc0a20 100644 --- a/toolchain/Config.in +++ b/toolchain/Config.in @@ -37,6 +37,7 @@ menuconfig TARGET_OPTIONS Most people will answer N. + choice BPF_TOOLCHAIN prompt "BPF toolchain" if DEVEL default BPF_TOOLCHAIN_BUILD_LLVM if BUILDBOT @@ -168,6 +169,7 @@ menuconfig EXTERNAL_TOOLCHAIN string prompt "Toolchain include path" if DEVEL depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN + default "./usr/include ./include/fortify ./include" if EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL default "./usr/include ./include" help Specify additional directories searched for header files (override @@ -307,7 +309,7 @@ config GDB_PYTHON help Enable the python bindings for GDB to allow using python in the gdb shell. - + config HAS_BPF_TOOLCHAIN bool @@ -326,7 +328,7 @@ config USE_LLVM_PREBUILT config USE_LLVM_BUILD default y if !DEVEL && BUILDBOT select HAS_BPF_TOOLCHAIN - bool + bool config USE_GLIBC default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && (arc) diff --git a/toolchain/binutils/Config.in b/toolchain/binutils/Config.in index 50829ad36..7fe797a5a 100644 --- a/toolchain/binutils/Config.in +++ b/toolchain/binutils/Config.in @@ -2,7 +2,7 @@ choice prompt "Binutils Version" if TOOLCHAINOPTS - default BINUTILS_USE_VERSION_2_37 + default BINUTILS_USE_VERSION_2_39 help Select the version of binutils you wish to use. @@ -13,7 +13,7 @@ choice config BINUTILS_USE_VERSION_2_38 bool "Binutils 2.38" select BINUTILS_VERSION_2_38 - + config BINUTILS_USE_VERSION_2_39 bool "Binutils 2.39" select BINUTILS_VERSION_2_39 diff --git a/toolchain/binutils/Config.version b/toolchain/binutils/Config.version index aa1325969..eac97877f 100644 --- a/toolchain/binutils/Config.version +++ b/toolchain/binutils/Config.version @@ -1,12 +1,12 @@ config BINUTILS_VERSION_2_37 - default y if !TOOLCHAINOPTS bool config BINUTILS_VERSION_2_38 bool - + config BINUTILS_VERSION_2_39 + default y if !TOOLCHAINOPTS bool config BINUTILS_VERSION diff --git a/toolchain/binutils/patches/2.39/005-ld-fix-NEWS-typos.patch b/toolchain/binutils/patches/2.39/005-ld-fix-NEWS-typos.patch new file mode 100644 index 000000000..39c61d931 --- /dev/null +++ b/toolchain/binutils/patches/2.39/005-ld-fix-NEWS-typos.patch @@ -0,0 +1,27 @@ +From 9284b63ea39cecbfc1522d9e143ecb7727d77eb5 Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Mon, 8 Aug 2022 13:22:26 +0200 +Subject: [PATCH 005/160] ld: fix NEWS typos + +ld/ChangeLog: + + * NEWS: Fix 2 typos. +--- + ld/NEWS | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/ld/NEWS ++++ b/ld/NEWS +@@ -27,10 +27,10 @@ Changes in 2.39: + --enable-warn-rwx-segments=no + will make --no-warn-rwx-segments enabled by default. + +- --enable-defaul-execstack=no ++ --enable-default-execstack=no + will stop the creation of an executable stack simply because an input file + is missing a .note.GNU-stack section, even on architectures where this +- ehaviour is the default. ++ behaviour is the default. + + * TYPE= is now supported in an output section description to set the + section type value. diff --git a/toolchain/binutils/patches/2.39/008-gas-Dwarf-properly-skip-zero-size-functions.patch b/toolchain/binutils/patches/2.39/008-gas-Dwarf-properly-skip-zero-size-functions.patch new file mode 100644 index 000000000..055da8412 --- /dev/null +++ b/toolchain/binutils/patches/2.39/008-gas-Dwarf-properly-skip-zero-size-functions.patch @@ -0,0 +1,90 @@ +From e8cf73215187b0c08679d726a5cc7c019fa3ea2e Mon Sep 17 00:00:00 2001 +From: Jan Beulich +Date: Wed, 10 Aug 2022 10:34:22 +0200 +Subject: [PATCH 008/160] gas/Dwarf: properly skip zero-size functions + +PR gas/29451 + +While out_debug_abbrev() properly skips such functions, out_debug_info() +mistakenly didn't. It needs to calculate the high_pc expression ahead of +time, in order to skip emitting any data for the function if the value +is zero. + +The one case which would still leave a zero-size entry is when +symbol_get_obj(symp)->size ends up evaluating to zero. I hope we can +expect that to not be the case, otherwise we'd need to have a way to +post-process .debug_info contents between resolving expressions and +actually writing the data out to the file. Even then it wouldn't be +entirely obvious in which way to alter the data. + +(cherry picked from commit d7abcbcea5ddd40a3bf28758b62f35933c59f996) +--- + gas/dwarf2dbg.c | 39 ++++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +--- a/gas/dwarf2dbg.c ++++ b/gas/dwarf2dbg.c +@@ -2882,6 +2882,7 @@ out_debug_info (segT info_seg, segT abbr + { + const char *name; + size_t len; ++ expressionS size = { .X_op = O_constant }; + + /* Skip warning constructs (see above). */ + if (symbol_get_bfdsym (symp)->flags & BSF_WARNING) +@@ -2895,6 +2896,18 @@ out_debug_info (segT info_seg, segT abbr + if (!S_IS_DEFINED (symp) || !S_IS_FUNCTION (symp)) + continue; + ++#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ ++ size.X_add_number = S_GET_SIZE (symp); ++ if (size.X_add_number == 0 && IS_ELF ++ && symbol_get_obj (symp)->size != NULL) ++ { ++ size.X_op = O_add; ++ size.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size); ++ } ++#endif ++ if (size.X_op == O_constant && size.X_add_number == 0) ++ continue; ++ + subseg_set (str_seg, 0); + name_sym = symbol_temp_new_now_octets (); + name = S_GET_NAME (symp); +@@ -2920,29 +2933,17 @@ out_debug_info (segT info_seg, segT abbr + emit_expr (&exp, sizeof_address); + + /* DW_AT_high_pc */ +- exp.X_op = O_constant; +-#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ +- exp.X_add_number = S_GET_SIZE (symp); +- if (exp.X_add_number == 0 && IS_ELF +- && symbol_get_obj (symp)->size != NULL) +- { +- exp.X_op = O_add; +- exp.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size); +- } +-#else +- exp.X_add_number = 0; +-#endif + if (DWARF2_VERSION < 4) + { +- if (exp.X_op == O_constant) +- exp.X_op = O_symbol; +- exp.X_add_symbol = symp; +- emit_expr (&exp, sizeof_address); ++ if (size.X_op == O_constant) ++ size.X_op = O_symbol; ++ size.X_add_symbol = symp; ++ emit_expr (&size, sizeof_address); + } +- else if (exp.X_op == O_constant) +- out_uleb128 (exp.X_add_number); ++ else if (size.X_op == O_constant) ++ out_uleb128 (size.X_add_number); + else +- emit_leb128_expr (symbol_get_value_expression (exp.X_op_symbol), 0); ++ emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0); + } + + /* End of children. */ diff --git a/toolchain/binutils/patches/2.39/009-PR29462-internal-error-in-relocate-at-powerpc.cc-107.patch b/toolchain/binutils/patches/2.39/009-PR29462-internal-error-in-relocate-at-powerpc.cc-107.patch new file mode 100644 index 000000000..e325d3bcb --- /dev/null +++ b/toolchain/binutils/patches/2.39/009-PR29462-internal-error-in-relocate-at-powerpc.cc-107.patch @@ -0,0 +1,270 @@ +From e3b5d935247084dca057dea72be61b063fe2357a Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Wed, 10 Aug 2022 10:38:52 +0930 +Subject: [PATCH 009/160] PR29462, internal error in relocate, at + powerpc.cc:10796 + +Prior to the inline plt call support (commit 08be322439), the only +local syms with plt entries were local ifunc symbols. There shouldn't +be stubs for other local symbols so don't look for them. The patch +also fixes minor bugs in get_reference_flags; Many relocs are valid +only for ppc64 and a couple only for ppc32. + + PR 29462 + * powerpc.cc (Target_powerpc::Relocate::relocate): Rename + use_plt_offset to pltcal_to_direct, invert logic. For relocs + not used with inline plt sequences against local symbols, only + look for stubs when the symbol is an ifunc. + (Target_powerpc::Scan::get_reference_flags): Correct reloc + handling for relocs not valid for both 32-bit and 64-bit. + +(cherry picked from commit 6158b25f77db11712b84e6a4609898f2615ac749) +--- + gold/powerpc.cc | 129 ++++++++++++++++++++++++++++-------------------- + 1 file changed, 75 insertions(+), 54 deletions(-) + +--- a/gold/powerpc.cc ++++ b/gold/powerpc.cc +@@ -7675,22 +7675,18 @@ Target_powerpc::Scan:: + + switch (r_type) + { ++ case elfcpp::R_PPC64_TOC: ++ if (size != 64) ++ break; ++ // Fall through. + case elfcpp::R_POWERPC_NONE: + case elfcpp::R_POWERPC_GNU_VTINHERIT: + case elfcpp::R_POWERPC_GNU_VTENTRY: +- case elfcpp::R_PPC64_TOC: + // No symbol reference. + break; + + case elfcpp::R_PPC64_ADDR64: + case elfcpp::R_PPC64_UADDR64: +- case elfcpp::R_POWERPC_ADDR32: +- case elfcpp::R_POWERPC_UADDR32: +- case elfcpp::R_POWERPC_ADDR16: +- case elfcpp::R_POWERPC_UADDR16: +- case elfcpp::R_POWERPC_ADDR16_LO: +- case elfcpp::R_POWERPC_ADDR16_HI: +- case elfcpp::R_POWERPC_ADDR16_HA: + case elfcpp::R_PPC64_ADDR16_HIGHER34: + case elfcpp::R_PPC64_ADDR16_HIGHERA34: + case elfcpp::R_PPC64_ADDR16_HIGHEST34: +@@ -7700,6 +7696,16 @@ Target_powerpc::Scan:: + case elfcpp::R_PPC64_D34_HI30: + case elfcpp::R_PPC64_D34_HA30: + case elfcpp::R_PPC64_D28: ++ if (size != 64) ++ break; ++ // Fall through. ++ case elfcpp::R_POWERPC_ADDR32: ++ case elfcpp::R_POWERPC_UADDR32: ++ case elfcpp::R_POWERPC_ADDR16: ++ case elfcpp::R_POWERPC_UADDR16: ++ case elfcpp::R_POWERPC_ADDR16_LO: ++ case elfcpp::R_POWERPC_ADDR16_HI: ++ case elfcpp::R_POWERPC_ADDR16_HA: + ref = Symbol::ABSOLUTE_REF; + break; + +@@ -7710,13 +7716,14 @@ Target_powerpc::Scan:: + ref = Symbol::FUNCTION_CALL | Symbol::ABSOLUTE_REF; + break; + +- case elfcpp::R_PPC64_REL64: +- case elfcpp::R_POWERPC_REL32: + case elfcpp::R_PPC_LOCAL24PC: +- case elfcpp::R_POWERPC_REL16: +- case elfcpp::R_POWERPC_REL16_LO: +- case elfcpp::R_POWERPC_REL16_HI: +- case elfcpp::R_POWERPC_REL16_HA: ++ if (size != 32) ++ break; ++ // Fall through. ++ ref = Symbol::RELATIVE_REF; ++ break; ++ ++ case elfcpp::R_PPC64_REL64: + case elfcpp::R_PPC64_REL16_HIGH: + case elfcpp::R_PPC64_REL16_HIGHA: + case elfcpp::R_PPC64_REL16_HIGHER: +@@ -7729,36 +7736,45 @@ Target_powerpc::Scan:: + case elfcpp::R_PPC64_REL16_HIGHEST34: + case elfcpp::R_PPC64_REL16_HIGHESTA34: + case elfcpp::R_PPC64_PCREL28: ++ if (size != 64) ++ break; ++ // Fall through. ++ case elfcpp::R_POWERPC_REL32: ++ case elfcpp::R_POWERPC_REL16: ++ case elfcpp::R_POWERPC_REL16_LO: ++ case elfcpp::R_POWERPC_REL16_HI: ++ case elfcpp::R_POWERPC_REL16_HA: + ref = Symbol::RELATIVE_REF; + break; + ++ case elfcpp::R_PPC_PLTREL24: ++ if (size != 32) ++ break; ++ ref = Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; ++ break; ++ + case elfcpp::R_PPC64_REL24_NOTOC: +- if (size == 32) ++ case elfcpp::R_PPC64_REL24_P9NOTOC: ++ case elfcpp::R_PPC64_PLT16_LO_DS: ++ case elfcpp::R_PPC64_PLTSEQ_NOTOC: ++ case elfcpp::R_PPC64_PLTCALL_NOTOC: ++ case elfcpp::R_PPC64_PLT_PCREL34: ++ case elfcpp::R_PPC64_PLT_PCREL34_NOTOC: ++ if (size != 64) + break; + // Fall through. +- case elfcpp::R_PPC64_REL24_P9NOTOC: + case elfcpp::R_POWERPC_REL24: +- case elfcpp::R_PPC_PLTREL24: + case elfcpp::R_POWERPC_REL14: + case elfcpp::R_POWERPC_REL14_BRTAKEN: + case elfcpp::R_POWERPC_REL14_BRNTAKEN: + case elfcpp::R_POWERPC_PLT16_LO: + case elfcpp::R_POWERPC_PLT16_HI: + case elfcpp::R_POWERPC_PLT16_HA: +- case elfcpp::R_PPC64_PLT16_LO_DS: + case elfcpp::R_POWERPC_PLTSEQ: +- case elfcpp::R_PPC64_PLTSEQ_NOTOC: + case elfcpp::R_POWERPC_PLTCALL: +- case elfcpp::R_PPC64_PLTCALL_NOTOC: +- case elfcpp::R_PPC64_PLT_PCREL34: +- case elfcpp::R_PPC64_PLT_PCREL34_NOTOC: + ref = Symbol::FUNCTION_CALL | Symbol::RELATIVE_REF; + break; + +- case elfcpp::R_POWERPC_GOT16: +- case elfcpp::R_POWERPC_GOT16_LO: +- case elfcpp::R_POWERPC_GOT16_HI: +- case elfcpp::R_POWERPC_GOT16_HA: + case elfcpp::R_PPC64_GOT16_DS: + case elfcpp::R_PPC64_GOT16_LO_DS: + case elfcpp::R_PPC64_GOT_PCREL34: +@@ -7768,11 +7784,16 @@ Target_powerpc::Scan:: + case elfcpp::R_PPC64_TOC16_HA: + case elfcpp::R_PPC64_TOC16_DS: + case elfcpp::R_PPC64_TOC16_LO_DS: ++ if (size != 64) ++ break; ++ // Fall through. ++ case elfcpp::R_POWERPC_GOT16: ++ case elfcpp::R_POWERPC_GOT16_LO: ++ case elfcpp::R_POWERPC_GOT16_HI: ++ case elfcpp::R_POWERPC_GOT16_HA: + ref = Symbol::RELATIVE_REF; + break; + +- case elfcpp::R_POWERPC_GOT_TPREL16: +- case elfcpp::R_POWERPC_TLS: + case elfcpp::R_PPC64_TLSGD: + case elfcpp::R_PPC64_TLSLD: + case elfcpp::R_PPC64_TPREL34: +@@ -7781,6 +7802,11 @@ Target_powerpc::Scan:: + case elfcpp::R_PPC64_GOT_TLSLD_PCREL34: + case elfcpp::R_PPC64_GOT_TPREL_PCREL34: + case elfcpp::R_PPC64_GOT_DTPREL_PCREL34: ++ if (size != 64) ++ break; ++ // Fall through. ++ case elfcpp::R_POWERPC_GOT_TPREL16: ++ case elfcpp::R_POWERPC_TLS: + ref = Symbol::TLS_REF; + break; + +@@ -10671,10 +10697,8 @@ Target_powerpc::Reloca + bool has_stub_value = false; + bool localentry0 = false; + unsigned int r_sym = elfcpp::elf_r_sym(rela.get_r_info()); +- bool use_plt_offset +- = (gsym != NULL +- ? gsym->use_plt_offset(Scan::get_reference_flags(r_type, target)) +- : object->local_has_plt_offset(r_sym)); ++ bool pltcall_to_direct = false; ++ + if (is_plt16_reloc(r_type) + || r_type == elfcpp::R_PPC64_PLT_PCREL34 + || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC +@@ -10688,21 +10712,18 @@ Target_powerpc::Reloca + // that the decision depends on the PLTCALL reloc, and we don't + // know the address of that instruction when processing others + // in the sequence. So the decision needs to be made in +- // do_relax(). For now, don't optimise inline plt calls. +- if (gsym) +- use_plt_offset = gsym->has_plt_offset(); +- } +- if (use_plt_offset +- && !is_got_reloc(r_type) +- && !is_plt16_reloc(r_type) +- && r_type != elfcpp::R_PPC64_PLT_PCREL34 +- && r_type != elfcpp::R_PPC64_PLT_PCREL34_NOTOC +- && r_type != elfcpp::R_POWERPC_PLTSEQ +- && r_type != elfcpp::R_POWERPC_PLTCALL +- && r_type != elfcpp::R_PPC64_PLTSEQ_NOTOC +- && r_type != elfcpp::R_PPC64_PLTCALL_NOTOC +- && (!psymval->is_ifunc_symbol() +- || Scan::reloc_needs_plt_for_ifunc(target, object, r_type, false))) ++ // do_relax(). ++ pltcall_to_direct = !(gsym != NULL ++ ? gsym->has_plt_offset() ++ : object->local_has_plt_offset(r_sym)); ++ } ++ else if ((gsym != NULL ++ ? gsym->use_plt_offset(Scan::get_reference_flags(r_type, target)) ++ : psymval->is_ifunc_symbol() && object->local_has_plt_offset(r_sym)) ++ && !is_got_reloc(r_type) ++ && (!psymval->is_ifunc_symbol() ++ || Scan::reloc_needs_plt_for_ifunc(target, object, r_type, ++ false))) + { + if (size == 64 + && gsym != NULL +@@ -10796,9 +10817,9 @@ Target_powerpc::Reloca + gold_assert(has_stub_value || !(os->flags() & elfcpp::SHF_ALLOC)); + } + +- if (use_plt_offset && (is_plt16_reloc(r_type) +- || r_type == elfcpp::R_PPC64_PLT_PCREL34 +- || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC)) ++ if (!pltcall_to_direct && (is_plt16_reloc(r_type) ++ || r_type == elfcpp::R_PPC64_PLT_PCREL34 ++ || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC)) + { + const Output_data_plt_powerpc* plt; + if (gsym) +@@ -10826,7 +10847,7 @@ Target_powerpc::Reloca + value -= target->toc_pointer(); + } + } +- else if (!use_plt_offset ++ else if (pltcall_to_direct + && (is_plt16_reloc(r_type) + || r_type == elfcpp::R_POWERPC_PLTSEQ + || r_type == elfcpp::R_PPC64_PLTSEQ_NOTOC)) +@@ -10835,7 +10856,7 @@ Target_powerpc::Reloca + elfcpp::Swap<32, big_endian>::writeval(iview, nop); + r_type = elfcpp::R_POWERPC_NONE; + } +- else if (!use_plt_offset ++ else if (pltcall_to_direct + && (r_type == elfcpp::R_PPC64_PLT_PCREL34 + || r_type == elfcpp::R_PPC64_PLT_PCREL34_NOTOC)) + { +@@ -11316,8 +11337,8 @@ Target_powerpc::Reloca + } + else if (!has_stub_value) + { +- if (!use_plt_offset && (r_type == elfcpp::R_POWERPC_PLTCALL +- || r_type == elfcpp::R_PPC64_PLTCALL_NOTOC)) ++ if (pltcall_to_direct && (r_type == elfcpp::R_POWERPC_PLTCALL ++ || r_type == elfcpp::R_PPC64_PLTCALL_NOTOC)) + { + // PLTCALL without plt entry => convert to direct call + Insn* iview = reinterpret_cast(view); diff --git a/toolchain/binutils/patches/2.39/011-PR29466-APP-NO_APP-with-.linefile.patch b/toolchain/binutils/patches/2.39/011-PR29466-APP-NO_APP-with-.linefile.patch new file mode 100644 index 000000000..f7b581992 --- /dev/null +++ b/toolchain/binutils/patches/2.39/011-PR29466-APP-NO_APP-with-.linefile.patch @@ -0,0 +1,167 @@ +From 9e855cffa1fda44629e7f9b76dfa3e5a51a440e9 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Thu, 11 Aug 2022 09:51:03 +0930 +Subject: [PATCH 011/160] PR29466, APP/NO_APP with .linefile + +Commit 53f2b36a54b9 exposed a bug in sb_scrub_and_add_sb that could +result in losing input. If scrubbing results in expansion past the +holding capacity of do_scrub_chars output buffer, then do_scrub_chars +stashes the extra input for the next call. That call never came +because sb_scrub_and_add_sb wrongly decided it was done. Fix that by +allowing sb_scrub_and_add_sb to see whether there is pending input. +Also allow a little extra space so that in most cases we won't need +to resize the output buffer. + +sb_scrub_and_add_sb also limited output to the size of the input, +rather than the actual output buffer size. Fixing that resulted in a +fail of gas/testsuite/macros/dot with an extra warning: "end of file +not at end of a line; newline inserted". OK, so the macro in dot.s +really does finish without end-of-line. Apparently the macro +expansion code relied on do_scrub_chars returning early. So fix that +too by adding a newline if needed in macro_expand_body. + + PR 29466 + * app.c (do_scrub_pending): New function. + * as.h: Declare it. + * input-scrub.c (input_scrub_include_sb): Add extra space for + two .linefile directives. + * sb.c (sb_scrub_and_add_sb): Take into account pending input. + Allow output to max. + * macro.c (macro_expand_body): Add terminating newline. + * testsuite/config/default.exp (SIZE, SIZEFLAGS): Define. + * testsuite/gas/macros/app5.d, + * testsuite/gas/macros/app5.s: New test. + * testsuite/gas/macros/macros.exp: Run it. + +(cherry picked from commit 4d74aab7aa562fe79d4669cdad0c32610531cbc0) +--- + gas/app.c | 13 +++++++++++++ + gas/as.h | 1 + + gas/input-scrub.c | 6 ++++-- + gas/macro.c | 2 ++ + gas/sb.c | 5 +++-- + gas/testsuite/config/default.exp | 8 ++++++++ + gas/testsuite/gas/macros/app5.d | 6 ++++++ + gas/testsuite/gas/macros/app5.s | 5 +++++ + gas/testsuite/gas/macros/macros.exp | 1 + + 9 files changed, 43 insertions(+), 4 deletions(-) + create mode 100644 gas/testsuite/gas/macros/app5.d + create mode 100644 gas/testsuite/gas/macros/app5.s + +--- a/gas/app.c ++++ b/gas/app.c +@@ -1537,3 +1537,16 @@ do_scrub_chars (size_t (*get) (char *, s + last_char = to[-1]; + return to - tostart; + } ++ ++/* Return amount of pending input. */ ++ ++size_t ++do_scrub_pending (void) ++{ ++ size_t len = 0; ++ if (saved_input) ++ len += saved_input_len; ++ if (state == -1) ++ len += strlen (out_string); ++ return len; ++} +--- a/gas/as.h ++++ b/gas/as.h +@@ -460,6 +460,7 @@ void input_scrub_insert_file (char *); + char * input_scrub_new_file (const char *); + char * input_scrub_next_buffer (char **bufp); + size_t do_scrub_chars (size_t (*get) (char *, size_t), char *, size_t); ++size_t do_scrub_pending (void); + bool scan_for_multibyte_characters (const unsigned char *, const unsigned char *, bool); + int gen_to_words (LITTLENUM_TYPE *, int, long); + int had_err (void); +--- a/gas/input-scrub.c ++++ b/gas/input-scrub.c +@@ -278,9 +278,11 @@ input_scrub_include_sb (sb *from, char * + + next_saved_file = input_scrub_push (position); + +- /* Allocate sufficient space: from->len + optional newline. */ ++ /* Allocate sufficient space: from->len plus optional newline ++ plus two ".linefile " directives, plus a little more for other ++ expansion. */ + newline = from->len >= 1 && from->ptr[0] != '\n'; +- sb_build (&from_sb, from->len + newline); ++ sb_build (&from_sb, from->len + newline + 2 * sizeof (".linefile") + 30); + if (expansion == expanding_repeat && from_sb_expansion >= expanding_macro) + expansion = expanding_nested; + from_sb_expansion = expansion; +--- a/gas/macro.c ++++ b/gas/macro.c +@@ -1056,6 +1056,8 @@ macro_expand_body (sb *in, sb *out, form + loclist = f; + } + ++ if (!err && (out->len == 0 || out->ptr[out->len - 1] != '\n')) ++ sb_add_char (out, '\n'); + return err; + } + +--- a/gas/sb.c ++++ b/gas/sb.c +@@ -119,11 +119,12 @@ sb_scrub_and_add_sb (sb *ptr, sb *s) + So we loop until the input S is consumed. */ + while (1) + { +- size_t copy = s->len - (scrub_position - s->ptr); ++ size_t copy = s->len - (scrub_position - s->ptr) + do_scrub_pending (); + if (copy == 0) + break; + sb_check (ptr, copy); +- ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len, copy); ++ ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len, ++ ptr->max - ptr->len); + } + + sb_to_scrub = 0; +--- a/gas/testsuite/config/default.exp ++++ b/gas/testsuite/config/default.exp +@@ -52,6 +52,14 @@ if ![info exists NMFLAGS] then { + set NMFLAGS {} + } + ++if ![info exists SIZE] then { ++ set SIZE [findfile $base_dir/size] ++} ++ ++if ![info exists SIZEFLAGS] then { ++ set SIZEFLAGS "" ++} ++ + if ![info exists OBJCOPY] then { + set OBJCOPY [findfile $base_dir/../../binutils/objcopy] + } +--- /dev/null ++++ b/gas/testsuite/gas/macros/app5.d +@@ -0,0 +1,6 @@ ++#name: APP with linefile ++#xfail: tic30-*-* ++#size: -G ++# pr29466 just check that the test assembles ++ ++#pass +--- /dev/null ++++ b/gas/testsuite/gas/macros/app5.s +@@ -0,0 +1,5 @@ ++#NO_APP ++#APP ++# 5 "foo.c" 1 ++# 0 "" 2 ++#NO_APP +--- a/gas/testsuite/gas/macros/macros.exp ++++ b/gas/testsuite/gas/macros/macros.exp +@@ -70,6 +70,7 @@ run_dump_test app2 + run_dump_test app3 + remote_download host "$srcdir/$subdir/app4b.s" + run_dump_test app4 ++run_dump_test app5 + + run_list_test badarg "" + diff --git a/toolchain/binutils/patches/2.39/039-LoongArch-ld-Fix-relocation-error-of-pcrel.patch b/toolchain/binutils/patches/2.39/039-LoongArch-ld-Fix-relocation-error-of-pcrel.patch new file mode 100644 index 000000000..67e499de6 --- /dev/null +++ b/toolchain/binutils/patches/2.39/039-LoongArch-ld-Fix-relocation-error-of-pcrel.patch @@ -0,0 +1,128 @@ +From 509a2ec6ad3ea7eb3f4cf59538cf636a2126e4c3 Mon Sep 17 00:00:00 2001 +From: liuzhensong +Date: Fri, 2 Sep 2022 16:29:14 +0800 +Subject: [PATCH 039/160] LoongArch:ld: Fix relocation error of pcrel. + + Patch for branch 2.39. + Need to reduce the address of pc when using + reloction R_LARCH_SOP_PUSH_PCREL. + + bfd/ + * elfnn-loongarch.c +--- + bfd/elfnn-loongarch.c | 3 +- + ld/testsuite/ld-loongarch-elf/pcrel-const.d | 14 +++++++ + ld/testsuite/ld-loongarch-elf/pcrel-const.lds | 14 +++++++ + ld/testsuite/ld-loongarch-elf/pcrel-const.s | 12 ++++++ + ld/testsuite/ld-loongarch-elf/pr.exp | 39 +++++++++++++++++++ + 5 files changed, 81 insertions(+), 1 deletion(-) + create mode 100644 ld/testsuite/ld-loongarch-elf/pcrel-const.d + create mode 100644 ld/testsuite/ld-loongarch-elf/pcrel-const.lds + create mode 100644 ld/testsuite/ld-loongarch-elf/pcrel-const.s + create mode 100644 ld/testsuite/ld-loongarch-elf/pr.exp + +--- a/bfd/elfnn-loongarch.c ++++ b/bfd/elfnn-loongarch.c +@@ -2341,9 +2341,10 @@ loongarch_elf_relocate_section (bfd *out + case R_LARCH_SOP_PUSH_PLT_PCREL: + unresolved_reloc = false; + +- if (resolved_to_const) ++ if (!is_undefweak && resolved_to_const) + { + relocation += rel->r_addend; ++ relocation -= pc; + break; + } + else if (is_undefweak) +--- /dev/null ++++ b/ld/testsuite/ld-loongarch-elf/pcrel-const.d +@@ -0,0 +1,14 @@ ++#as: -mla-global-with-pcrel ++#objdump: -Drsz ++ ++.*:[ ]+file format .* ++ ++ ++Disassembly of section .text: ++ ++.* : ++#... ++[ ]+8:[ ]+02c04084[ ]+addi.d[ ]+\$a0,[ ]+\$a0,[ ]+16\(0x10\) ++#... ++0+14 <__sec_end>: ++#pass +--- /dev/null ++++ b/ld/testsuite/ld-loongarch-elf/pcrel-const.lds +@@ -0,0 +1,14 @@ ++ENTRY(foo); ++SECTIONS ++{ ++ .text : { ++ *(.text*) ++ } ++ ++ .data : { ++ __sec_start = .; ++ *(.gzdata) ++ __sec_end = .; ++ } ++} ++PROVIDE(__sec_size = __sec_end); +--- /dev/null ++++ b/ld/testsuite/ld-loongarch-elf/pcrel-const.s +@@ -0,0 +1,12 @@ ++ .text ++ .align 2 ++ .globl foo ++ .type foo, @function ++foo: ++ nop ++ la.global $r4,__sec_size ++ ldptr.w $r4,$r4,0 ++ jr $r1 ++ .size foo, .-foo ++ .data ++ .word 1 +--- /dev/null ++++ b/ld/testsuite/ld-loongarch-elf/pr.exp +@@ -0,0 +1,39 @@ ++# Expect script for LoongArch ELF linker tests ++# Copyright (C) 2022 Free Software Foundation, Inc. ++# ++# This file is part of the GNU Binutils. ++# ++# 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; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++# MA 02110-1301, USA. ++# ++ ++if ![istarget loongarch64-*-*] { ++ return ++} ++ ++set link_tests [list \ ++ [list \ ++ "pcrel const" \ ++ "-T pcrel-const.lds" "" \ ++ "-mla-global-with-pcrel" \ ++ { pcrel-const.s } \ ++ [list \ ++ [list objdump -D pcrel-const.d] \ ++ ] \ ++ "pcrel-const" \ ++ ] \ ++] ++ ++run_ld_link_tests $link_tests diff --git a/toolchain/binutils/patches/2.39/043-Re-PR29466-APP-NO_APP-with-linefile.patch b/toolchain/binutils/patches/2.39/043-Re-PR29466-APP-NO_APP-with-linefile.patch new file mode 100644 index 000000000..1de501a1a --- /dev/null +++ b/toolchain/binutils/patches/2.39/043-Re-PR29466-APP-NO_APP-with-linefile.patch @@ -0,0 +1,27 @@ +From 4233be14a34d754a70b8b6f6fa42d21f35c6e030 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Sat, 10 Sep 2022 07:30:57 +0930 +Subject: [PATCH 043/160] Re: PR29466, APP/NO_APP with linefile + +It looks like I copied the SIZE init across from +binutils/testsuite/config/default.exp without some necessary editing. + + PR 29466 + * testsuite/config/default.exp (SIZE): Adjust relative path. + +(cherry picked from commit 1180f540d5f2f7751b5309bdd6c38d69fcf699e7) +--- + gas/testsuite/config/default.exp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/gas/testsuite/config/default.exp ++++ b/gas/testsuite/config/default.exp +@@ -53,7 +53,7 @@ if ![info exists NMFLAGS] then { + } + + if ![info exists SIZE] then { +- set SIZE [findfile $base_dir/size] ++ set SIZE [findfile $base_dir/../../binutils/size] + } + + if ![info exists SIZEFLAGS] then { diff --git a/toolchain/binutils/patches/2.39/050-PowerPC64-pcrel-got-relocs-against-local-symbols.patch b/toolchain/binutils/patches/2.39/050-PowerPC64-pcrel-got-relocs-against-local-symbols.patch new file mode 100644 index 000000000..5c89f6804 --- /dev/null +++ b/toolchain/binutils/patches/2.39/050-PowerPC64-pcrel-got-relocs-against-local-symbols.patch @@ -0,0 +1,38 @@ +From 4d7bba23a39fba18d6d13a2941a3c232011a7064 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Fri, 16 Sep 2022 18:08:44 +0930 +Subject: [PATCH 050/160] PowerPC64 pcrel got relocs against local symbols + +Not that anyone would want to indirect via the GOT when an address can +be loaded directly with pla, the following: + + pld 3,x@got@pcrel +x: + +leads to "Internal error in md_apply_fix", because the generic parts +of assembler fixup handling convert the fx_pcrel fixup to one without +a symbol. Stop that happening. + + * config/tc-ppc.c (ppc_force_relocation): Add PLT_PCREL34 and + assorted GOT_PCREL34 relocs. + +(cherry picked from commit 49c3ed081fed6b8e2b48fdc48f805f11e4589514) +--- + gas/config/tc-ppc.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/gas/config/tc-ppc.c ++++ b/gas/config/tc-ppc.c +@@ -6676,6 +6676,12 @@ ppc_force_relocation (fixS *fix) + case BFD_RELOC_PPC_BA16_BRNTAKEN: + case BFD_RELOC_24_PLT_PCREL: + case BFD_RELOC_PPC64_TOC: ++ case BFD_RELOC_PPC64_PLT_PCREL34: ++ case BFD_RELOC_PPC64_GOT_PCREL34: ++ case BFD_RELOC_PPC64_GOT_TLSGD_PCREL34: ++ case BFD_RELOC_PPC64_GOT_TLSLD_PCREL34: ++ case BFD_RELOC_PPC64_GOT_TPREL_PCREL34: ++ case BFD_RELOC_PPC64_GOT_DTPREL_PCREL34: + return 1; + case BFD_RELOC_PPC_B26: + case BFD_RELOC_PPC_BA26: diff --git a/toolchain/binutils/patches/2.39/055-Re-PowerPC64-pcrel-got-relocs-against-local-symbols.patch b/toolchain/binutils/patches/2.39/055-Re-PowerPC64-pcrel-got-relocs-against-local-symbols.patch new file mode 100644 index 000000000..19b80c344 --- /dev/null +++ b/toolchain/binutils/patches/2.39/055-Re-PowerPC64-pcrel-got-relocs-against-local-symbols.patch @@ -0,0 +1,94 @@ +From 010db38b54b589ca3e95b498aba2831064970171 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Wed, 21 Sep 2022 09:06:29 +0930 +Subject: [PATCH 055/160] Re: PowerPC64 pcrel got relocs against local symbols + +The last patch wasn't all that shiny. There are rather a lot more +relocations that can hit the assertion in md_apply_fix if the symbol +is local or absolute. Fix them all. + + * config/tc-ppc.c (ppc_force_relocation): Add all relocs that + expect a symbol in md_apply_fix. Remove tls pcrel relocs + already covered in general tls match range. + +(cherry picked from commit 8b168f1a1e09e337d2a970f204a0230c091bbe58) +--- + gas/config/tc-ppc.c | 58 ++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 52 insertions(+), 6 deletions(-) + +--- a/gas/config/tc-ppc.c ++++ b/gas/config/tc-ppc.c +@@ -6666,8 +6666,6 @@ ppc_force_relocation (fixS *fix) + int + ppc_force_relocation (fixS *fix) + { +- /* Branch prediction relocations must force a relocation, as must +- the vtable description relocs. */ + switch (fix->fx_r_type) + { + case BFD_RELOC_PPC_B16_BRTAKEN: +@@ -6676,12 +6674,60 @@ ppc_force_relocation (fixS *fix) + case BFD_RELOC_PPC_BA16_BRNTAKEN: + case BFD_RELOC_24_PLT_PCREL: + case BFD_RELOC_PPC64_TOC: ++ case BFD_RELOC_16_GOTOFF: ++ case BFD_RELOC_LO16_GOTOFF: ++ case BFD_RELOC_HI16_GOTOFF: ++ case BFD_RELOC_HI16_S_GOTOFF: ++ case BFD_RELOC_LO16_PLTOFF: ++ case BFD_RELOC_HI16_PLTOFF: ++ case BFD_RELOC_HI16_S_PLTOFF: ++ case BFD_RELOC_GPREL16: ++ case BFD_RELOC_16_BASEREL: ++ case BFD_RELOC_LO16_BASEREL: ++ case BFD_RELOC_HI16_BASEREL: ++ case BFD_RELOC_HI16_S_BASEREL: ++ case BFD_RELOC_PPC_TOC16: ++ case BFD_RELOC_PPC64_TOC16_LO: ++ case BFD_RELOC_PPC64_TOC16_HI: ++ case BFD_RELOC_PPC64_TOC16_HA: ++ case BFD_RELOC_PPC64_PLTGOT16: ++ case BFD_RELOC_PPC64_PLTGOT16_LO: ++ case BFD_RELOC_PPC64_PLTGOT16_HI: ++ case BFD_RELOC_PPC64_PLTGOT16_HA: ++ case BFD_RELOC_PPC64_GOT16_DS: ++ case BFD_RELOC_PPC64_GOT16_LO_DS: ++ case BFD_RELOC_PPC64_PLT16_LO_DS: ++ case BFD_RELOC_PPC64_SECTOFF_DS: ++ case BFD_RELOC_PPC64_SECTOFF_LO_DS: ++ case BFD_RELOC_PPC64_TOC16_DS: ++ case BFD_RELOC_PPC64_TOC16_LO_DS: ++ case BFD_RELOC_PPC64_PLTGOT16_DS: ++ case BFD_RELOC_PPC64_PLTGOT16_LO_DS: ++ case BFD_RELOC_PPC_EMB_NADDR16: ++ case BFD_RELOC_PPC_EMB_NADDR16_LO: ++ case BFD_RELOC_PPC_EMB_NADDR16_HI: ++ case BFD_RELOC_PPC_EMB_NADDR16_HA: ++ case BFD_RELOC_PPC_EMB_SDAI16: ++ case BFD_RELOC_PPC_EMB_SDA2I16: ++ case BFD_RELOC_PPC_EMB_SDA2REL: ++ case BFD_RELOC_PPC_EMB_SDA21: ++ case BFD_RELOC_PPC_EMB_MRKREF: ++ case BFD_RELOC_PPC_EMB_RELSEC16: ++ case BFD_RELOC_PPC_EMB_RELST_LO: ++ case BFD_RELOC_PPC_EMB_RELST_HI: ++ case BFD_RELOC_PPC_EMB_RELST_HA: ++ case BFD_RELOC_PPC_EMB_BIT_FLD: ++ case BFD_RELOC_PPC_EMB_RELSDA: ++ case BFD_RELOC_PPC_VLE_SDA21: ++ case BFD_RELOC_PPC_VLE_SDA21_LO: ++ case BFD_RELOC_PPC_VLE_SDAREL_LO16A: ++ case BFD_RELOC_PPC_VLE_SDAREL_LO16D: ++ case BFD_RELOC_PPC_VLE_SDAREL_HI16A: ++ case BFD_RELOC_PPC_VLE_SDAREL_HI16D: ++ case BFD_RELOC_PPC_VLE_SDAREL_HA16A: ++ case BFD_RELOC_PPC_VLE_SDAREL_HA16D: + case BFD_RELOC_PPC64_PLT_PCREL34: + case BFD_RELOC_PPC64_GOT_PCREL34: +- case BFD_RELOC_PPC64_GOT_TLSGD_PCREL34: +- case BFD_RELOC_PPC64_GOT_TLSLD_PCREL34: +- case BFD_RELOC_PPC64_GOT_TPREL_PCREL34: +- case BFD_RELOC_PPC64_GOT_DTPREL_PCREL34: + return 1; + case BFD_RELOC_PPC_B26: + case BFD_RELOC_PPC_BA26: diff --git a/toolchain/binutils/patches/2.39/058-elf-Reset-alignment-for-each-PT_LOAD-segment.patch b/toolchain/binutils/patches/2.39/058-elf-Reset-alignment-for-each-PT_LOAD-segment.patch new file mode 100644 index 000000000..aaf7a1b05 --- /dev/null +++ b/toolchain/binutils/patches/2.39/058-elf-Reset-alignment-for-each-PT_LOAD-segment.patch @@ -0,0 +1,89 @@ +From a98316d5cf970cbc99689797d84c2ea832bcdcbb Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Mon, 1 Aug 2022 16:02:39 -0700 +Subject: [PATCH 058/160] elf: Reset alignment for each PT_LOAD segment + +Reset alignment for each PT_LOAD segment to avoid using alignment from +the previous PT_LOAD segment. + +bfd/ + + PR ld/29435 + * elf.c (assign_file_positions_for_load_sections): Reset + alignment for each PT_LOAD segment. + +ld/ + + PR ld/29435 + * testsuite/ld-elf/pr29435.d: New file. + * testsuite/ld-elf/pr29435.s: Likewise. + +(cherry picked from commit 59f214544c50ec7ebbca285ff2b4949f48671690) +--- + bfd/elf.c | 7 ++++--- + ld/testsuite/ld-elf/pr29435.d | 11 +++++++++++ + ld/testsuite/ld-elf/pr29435.s | 6 ++++++ + 3 files changed, 21 insertions(+), 3 deletions(-) + create mode 100644 ld/testsuite/ld-elf/pr29435.d + create mode 100644 ld/testsuite/ld-elf/pr29435.s + +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -5438,8 +5438,6 @@ assign_file_positions_for_load_sections + Elf_Internal_Phdr *p; + file_ptr off; /* Octets. */ + bfd_size_type maxpagesize; +- bfd_size_type p_align; +- bool p_align_p = false; + unsigned int alloc, actual; + unsigned int i, j; + struct elf_segment_map **sorted_seg_map; +@@ -5524,7 +5522,6 @@ assign_file_positions_for_load_sections + qsort (sorted_seg_map, alloc, sizeof (*sorted_seg_map), + elf_sort_segments); + +- p_align = bed->p_align; + maxpagesize = 1; + if ((abfd->flags & D_PAGED) != 0) + { +@@ -5559,6 +5556,8 @@ assign_file_positions_for_load_sections + asection **secpp; + bfd_vma off_adjust; /* Octets. */ + bool no_contents; ++ bfd_size_type p_align; ++ bool p_align_p; + + /* An ELF segment (described by Elf_Internal_Phdr) may contain a + number of sections with contents contributing to both p_filesz +@@ -5569,6 +5568,8 @@ assign_file_positions_for_load_sections + p = phdrs + m->idx; + p->p_type = m->p_type; + p->p_flags = m->p_flags; ++ p_align = bed->p_align; ++ p_align_p = false; + + if (m->count == 0) + p->p_vaddr = m->p_vaddr_offset * opb; +--- /dev/null ++++ b/ld/testsuite/ld-elf/pr29435.d +@@ -0,0 +1,11 @@ ++#ld: -shared -z separate-code -z relro ++#xfail: ![check_shared_lib_support] ++#xfail: ![check_relro_support] ++#readelf: -Wl ++ ++#failif ++#... ++ +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ .* 0x8000 ++#... ++ +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ .* 0x8000 ++#... +--- /dev/null ++++ b/ld/testsuite/ld-elf/pr29435.s +@@ -0,0 +1,6 @@ ++ .text ++ .balign 0x8000 ++ .globl foo ++ .type foo, %function ++foo: ++ .byte 0 diff --git a/toolchain/binutils/patches/2.39/063-PR29542-PowerPC-gold-internal-error-in-get_output_vi.patch b/toolchain/binutils/patches/2.39/063-PR29542-PowerPC-gold-internal-error-in-get_output_vi.patch new file mode 100644 index 000000000..0d66b7750 --- /dev/null +++ b/toolchain/binutils/patches/2.39/063-PR29542-PowerPC-gold-internal-error-in-get_output_vi.patch @@ -0,0 +1,29 @@ +From 041c22e35de06d22566f4c71e4425c3351215e66 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Sun, 25 Sep 2022 12:07:36 +0930 +Subject: [PATCH 063/160] PR29542, PowerPC gold internal error in + get_output_view, + +We were attempting to set a BSS style section contents. + + PR 29542 + * powerpc.cc (Output_data_plt_powerpc::do_write): Don't set .plt, + .iplt or .lplt section contents when position independent. + +(cherry picked from commit c21736aed1d4877e090df60362413669dbdc391d) +--- + gold/powerpc.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/gold/powerpc.cc ++++ b/gold/powerpc.cc +@@ -4338,7 +4338,8 @@ template + void + Output_data_plt_powerpc::do_write(Output_file* of) + { +- if (!this->sym_ents_.empty()) ++ if (!this->sym_ents_.empty() ++ && !parameters->options().output_is_position_independent()) + { + const section_size_type offset = this->offset(); + const section_size_type oview_size diff --git a/toolchain/binutils/patches/2.39/116-arm-Use-DWARF-numbering-convention-for-pseudo-regist.patch b/toolchain/binutils/patches/2.39/116-arm-Use-DWARF-numbering-convention-for-pseudo-regist.patch new file mode 100644 index 000000000..82a015ee2 --- /dev/null +++ b/toolchain/binutils/patches/2.39/116-arm-Use-DWARF-numbering-convention-for-pseudo-regist.patch @@ -0,0 +1,301 @@ +From 88ac930a725b8aac8284a2738f03b843f4343dd0 Mon Sep 17 00:00:00 2001 +From: Victor Do Nascimento +Date: Thu, 17 Nov 2022 14:48:37 +0000 +Subject: [PATCH 116/160] arm: Use DWARF numbering convention for + pseudo-register representation + +The patch, initially submitted to trunk in +https://sourceware.org/pipermail/binutils/2022-July/122092.html ensures correct +support for handling .save directives for mixed-register type lists involving +the ra_auth_code pseudo-register, whereby the support first introduced in 2.39 +(https://sourceware.org/pipermail/binutils/2022-May/120672.html) led to the +generation of unwinder code popping registers in reversed order. + +gas/Changelog: + + * config/tc-arm.c (REG_RA_AUTH_CODE): New. + (parse_dot_save): Likewise. + (parse_reg_list): Remove obsolete code. + (reg_names): Set ra_auth_code to 143. + (s_arm_unwind_save): Handle core and pseudo-register lists via + parse_dot_save. + (s_arm_unwind_save_mixed): Deleted. + (s_arm_unwind_save_pseudo): Handle one register at a time. + * testsuite/gas/arm/unwind-pacbti-m-readelf.d: Fix test. + * testsuite/gas/arm/unwind-pacbti-m.d: Likewise. + +(cherry picked from commit 3a368c4c248f6e9f4bda3a5369befa17a4560293) +--- + gas/config/tc-arm.c | 159 ++++++++++-------- + .../gas/arm/unwind-pacbti-m-readelf.d | 4 +- + gas/testsuite/gas/arm/unwind-pacbti-m.d | 2 +- + 3 files changed, 95 insertions(+), 70 deletions(-) + +--- a/gas/config/tc-arm.c ++++ b/gas/config/tc-arm.c +@@ -742,6 +742,7 @@ const char * const reg_expected_msgs[] = + #define REG_SP 13 + #define REG_LR 14 + #define REG_PC 15 ++#define REG_RA_AUTH_CODE 143 + + /* ARM instructions take 4bytes in the object file, Thumb instructions + take 2: */ +@@ -1943,21 +1944,6 @@ parse_reg_list (char ** strp, enum reg_l + + reg = arm_reg_parse (&str, rt); + +- /* Skip over allowed registers of alternative types in mixed-type +- register lists. */ +- if (reg == FAIL && rt == REG_TYPE_PSEUDO +- && ((reg = arm_reg_parse (&str, REG_TYPE_RN)) != FAIL)) +- { +- cur_reg = reg; +- continue; +- } +- else if (reg == FAIL && rt == REG_TYPE_RN +- && ((reg = arm_reg_parse (&str, REG_TYPE_PSEUDO)) != FAIL)) +- { +- cur_reg = reg; +- continue; +- } +- + if (etype == REGLIST_CLRM) + { + if (reg == REG_SP || reg == REG_PC) +@@ -4139,7 +4125,6 @@ s_arm_unwind_fnstart (int ignored ATTRIB + unwind.sp_restored = 0; + } + +- + /* Parse a handlerdata directive. Creates the exception handling table entry + for the function. */ + +@@ -4297,15 +4282,19 @@ s_arm_unwind_personality (int ignored AT + /* Parse a directive saving pseudo registers. */ + + static void +-s_arm_unwind_save_pseudo (long range) ++s_arm_unwind_save_pseudo (int regno) + { + valueT op; + +- if (range & (1 << 12)) ++ switch (regno) + { ++ case REG_RA_AUTH_CODE: + /* Opcode for restoring RA_AUTH_CODE. */ + op = 0xb4; + add_unwind_opcode (op, 1); ++ break; ++ default: ++ as_bad (_("Unknown register %d encountered\n"), regno); + } + } + +@@ -4375,6 +4364,80 @@ s_arm_unwind_save_core (long range) + } + } + ++/* Implement correct handling of .save lists enabling the split into ++sublists where necessary, while preserving correct sublist ordering. */ ++ ++static void ++parse_dot_save (char **str_p, int prev_reg) ++{ ++ long core_regs = 0; ++ int reg; ++ int in_range = 0; ++ ++ if (**str_p == ',') ++ *str_p += 1; ++ if (**str_p == '}') ++ { ++ *str_p += 1; ++ return; ++ } ++ ++ while ((reg = arm_reg_parse (str_p, REG_TYPE_RN)) != FAIL) ++ { ++ if (!in_range) ++ { ++ if (core_regs & (1 << reg)) ++ as_tsktsk (_("Warning: duplicated register (r%d) in register list"), ++ reg); ++ else if (reg <= prev_reg) ++ as_tsktsk (_("Warning: register list not in ascending order")); ++ ++ core_regs |= (1 << reg); ++ prev_reg = reg; ++ if (skip_past_char(str_p, '-') != FAIL) ++ in_range = 1; ++ else if (skip_past_comma(str_p) == FAIL) ++ first_error (_("bad register list")); ++ } ++ else ++ { ++ int i; ++ if (reg <= prev_reg) ++ first_error (_("bad range in register list")); ++ for (i = prev_reg + 1; i <= reg; i++) ++ { ++ if (core_regs & (1 << i)) ++ as_tsktsk (_("Warning: duplicated register (r%d) in register list"), ++ i); ++ else ++ core_regs |= 1 << i; ++ } ++ in_range = 0; ++ } ++ } ++ if (core_regs) ++ { ++ /* Higher register numbers go in higher memory addresses. When splitting a list, ++ right-most sublist should therefore be .saved first. Use recursion for this. */ ++ parse_dot_save (str_p, reg); ++ /* We're back from recursion, so emit .save insn for sublist. */ ++ s_arm_unwind_save_core (core_regs); ++ return; ++ } ++ /* Handle pseudo-regs, under assumption these are emitted singly. */ ++ else if ((reg = arm_reg_parse (str_p, REG_TYPE_PSEUDO)) != FAIL) ++ { ++ /* Recurse for remainder of input. Note: No assumption is made regarding which ++ register in core register set holds pseudo-register. It's not considered in ++ ordering check beyond ensuring it's not sandwiched between 2 consecutive ++ registers. */ ++ parse_dot_save (str_p, prev_reg + 1); ++ s_arm_unwind_save_pseudo (reg); ++ return; ++ } ++ else ++ as_bad (BAD_SYNTAX); ++} + + /* Parse a directive saving FPA registers. */ + +@@ -4716,39 +4779,13 @@ s_arm_unwind_save_mmxwcg (void) + ignore_rest_of_line (); + } + +-/* Convert range and mask_range into a sequence of s_arm_unwind_core +- and s_arm_unwind_pseudo operations. We assume that mask_range will +- not have consecutive bits set, or that one operation per bit is +- acceptable. */ +- +-static void +-s_arm_unwind_save_mixed (long range, long mask_range) +-{ +- while (mask_range) +- { +- long mask_bit = mask_range & -mask_range; +- long subrange = range & (mask_bit - 1); +- +- if (subrange) +- s_arm_unwind_save_core (subrange); +- +- s_arm_unwind_save_pseudo (mask_bit); +- range &= ~subrange; +- mask_range &= ~mask_bit; +- } +- +- if (range) +- s_arm_unwind_save_core (range); +-} +- + /* Parse an unwind_save directive. + If the argument is non-zero, this is a .vsave directive. */ + + static void + s_arm_unwind_save (int arch_v6) + { +- char *peek, *mask_peek; +- long range, mask_range; ++ char *peek; + struct reg_entry *reg; + bool had_brace = false; + +@@ -4756,7 +4793,7 @@ s_arm_unwind_save (int arch_v6) + as_bad (MISSING_FNSTART); + + /* Figure out what sort of save we have. */ +- peek = mask_peek = input_line_pointer; ++ peek = input_line_pointer; + + if (*peek == '{') + { +@@ -4788,20 +4825,13 @@ s_arm_unwind_save (int arch_v6) + + case REG_TYPE_PSEUDO: + case REG_TYPE_RN: +- mask_range = parse_reg_list (&mask_peek, REGLIST_PSEUDO); +- range = parse_reg_list (&input_line_pointer, REGLIST_RN); +- +- if (range == FAIL || mask_range == FAIL) +- { +- as_bad (_("expected register list")); +- ignore_rest_of_line (); +- return; +- } +- +- demand_empty_rest_of_line (); +- +- s_arm_unwind_save_mixed (range, mask_range); +- return; ++ { ++ if (had_brace) ++ input_line_pointer++; ++ parse_dot_save (&input_line_pointer, -1); ++ demand_empty_rest_of_line (); ++ return; ++ } + + case REG_TYPE_VFD: + if (arch_v6) +@@ -23993,12 +24023,8 @@ static const struct reg_entry reg_names[ + /* XScale accumulator registers. */ + REGNUM(acc,0,XSCALE), REGNUM(ACC,0,XSCALE), + +- /* DWARF ABI defines RA_AUTH_CODE to 143. It also reserves 134-142 for future +- expansion. RA_AUTH_CODE here is given the value 143 % 134 to make it easy +- for tc_arm_regname_to_dw2regnum to translate to DWARF reg number using +- 134 + reg_number should the range 134 to 142 be used for more pseudo regs +- in the future. This also helps fit RA_AUTH_CODE into a bitmask. */ +- REGDEF(ra_auth_code,12,PSEUDO), ++ /* AADWARF32 defines RA_AUTH_CODE to 143. */ ++ REGDEF(ra_auth_code,143,PSEUDO), + }; + #undef REGDEF + #undef REGNUM +@@ -27905,7 +27931,6 @@ create_unwind_entry (int have_data) + return 0; + } + +- + /* Initialize the DWARF-2 unwind information for this procedure. */ + + void +--- a/gas/testsuite/gas/arm/unwind-pacbti-m-readelf.d ++++ b/gas/testsuite/gas/arm/unwind-pacbti-m-readelf.d +@@ -10,11 +10,11 @@ Unwind section '.ARM.exidx' at offset 0x + + 0x0 : @0x0 + Compact model index: 1 +- 0x84 0x00 pop {r14} + 0xb4 pop {ra_auth_code} + 0x84 0x00 pop {r14} +- 0xb4 pop {ra_auth_code} + 0xa3 pop {r4, r5, r6, r7} + 0xb4 pop {ra_auth_code} ++ 0x84 0x00 pop {r14} ++ 0xb4 pop {ra_auth_code} + 0xa8 pop {r4, r14} + 0xb0 finish +--- a/gas/testsuite/gas/arm/unwind-pacbti-m.d ++++ b/gas/testsuite/gas/arm/unwind-pacbti-m.d +@@ -8,4 +8,4 @@ + .*: file format.* + + Contents of section .ARM.extab: +- 0000 (00840281 b40084b4 b0a8b4a3|81028400 b48400b4 a3b4a8b0) 00000000 .* ++ 0000 (84b40281 84b4a300 b0a8b400|8102b484 00a3b484 00b4a8b0) 00000000 .* diff --git a/toolchain/build_version b/toolchain/build_version new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/toolchain/build_version @@ -0,0 +1 @@ +1 diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in index 69eacaef9..8a31bf0d2 100644 --- a/toolchain/gcc/Config.in +++ b/toolchain/gcc/Config.in @@ -10,12 +10,9 @@ choice config GCC_USE_VERSION_8 bool "gcc 8.x" - config GCC_USE_VERSION_10 - bool "gcc 10.x" - config GCC_USE_VERSION_11 bool "gcc 11.x" - + config GCC_USE_VERSION_12 bool "gcc 12.x" endchoice diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version index 8bfb17d03..da915851a 100644 --- a/toolchain/gcc/Config.version +++ b/toolchain/gcc/Config.version @@ -3,10 +3,6 @@ config GCC_VERSION_8 default y if mips || mipsel || mips64 || mips64el bool -config GCC_VERSION_10 - default y if GCC_USE_VERSION_10 - bool - config GCC_VERSION_12 default y if GCC_USE_VERSION_12 bool @@ -14,6 +10,5 @@ config GCC_VERSION_12 config GCC_VERSION string default "8.4.0" if GCC_VERSION_8 - default "10.3.0" if GCC_VERSION_10 default "12.2.0" if GCC_VERSION_12 default "11.3.0" diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk index e7d45bcb6..1a4a849e4 100644 --- a/toolchain/gcc/common.mk +++ b/toolchain/gcc/common.mk @@ -33,10 +33,6 @@ ifeq ($(PKG_VERSION),8.4.0) PKG_HASH:=e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4 endif -ifeq ($(PKG_VERSION),10.3.0) - PKG_HASH:=64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344 -endif - ifeq ($(PKG_VERSION),11.3.0) PKG_HASH:=b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39 endif @@ -113,6 +109,7 @@ GCC_CONFIGURE:= \ $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \ --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \ $(if $(CONFIG_arc),--with-cpu=$(CONFIG_CPU_TYPE)) \ + $(if $(CONFIG_powerpc64), $(if $(CONFIG_USE_MUSL),--with-abi=elfv2)) \ --with-gmp=$(TOPDIR)/staging_dir/host \ --with-mpfr=$(TOPDIR)/staging_dir/host \ --with-mpc=$(TOPDIR)/staging_dir/host \ diff --git a/toolchain/gcc/patches-10.x/002-case_insensitive.patch b/toolchain/gcc/patches-10.x/002-case_insensitive.patch deleted file mode 100644 index 409497e5a..000000000 --- a/toolchain/gcc/patches-10.x/002-case_insensitive.patch +++ /dev/null @@ -1,24 +0,0 @@ -commit 81cc26c706b2bc8c8c1eb1a322e5c5157900836e -Author: Felix Fietkau -Date: Sun Oct 19 21:45:51 2014 +0000 - - gcc: do not assume that the Mac OS X filesystem is case insensitive - - Signed-off-by: Felix Fietkau - - SVN-Revision: 42973 - ---- a/include/filenames.h -+++ b/include/filenames.h -@@ -44,11 +44,6 @@ extern "C" { - # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c) - # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f) - #else /* not DOSish */ --# if defined(__APPLE__) --# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM --# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1 --# endif --# endif /* __APPLE__ */ - # define HAS_DRIVE_SPEC(f) (0) - # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c) - # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f) diff --git a/toolchain/gcc/patches-10.x/010-documentation.patch b/toolchain/gcc/patches-10.x/010-documentation.patch deleted file mode 100644 index 85990e5ac..000000000 --- a/toolchain/gcc/patches-10.x/010-documentation.patch +++ /dev/null @@ -1,35 +0,0 @@ -commit 098bd91f5eae625c7d2ee621e10930fc4434e5e2 -Author: Luka Perkov -Date: Tue Feb 26 16:16:33 2013 +0000 - - gcc: don't build documentation - - This closes #13039. - - Signed-off-by: Luka Perkov - - SVN-Revision: 35807 - ---- a/gcc/Makefile.in -+++ b/gcc/Makefile.in -@@ -3285,18 +3285,10 @@ doc/gcc.info: $(TEXI_GCC_FILES) - doc/gccint.info: $(TEXI_GCCINT_FILES) - doc/cppinternals.info: $(TEXI_CPPINT_FILES) - --doc/%.info: %.texi -- if [ x$(BUILD_INFO) = xinfo ]; then \ -- $(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \ -- -I $(gcc_docdir)/include -o $@ $<; \ -- fi -+doc/%.info: - - # Duplicate entry to handle renaming of gccinstall.info --doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES) -- if [ x$(BUILD_INFO) = xinfo ]; then \ -- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \ -- -I $(gcc_docdir)/include -o $@ $<; \ -- fi -+doc/gccinstall.info: - - doc/cpp.dvi: $(TEXI_CPP_FILES) - doc/gcc.dvi: $(TEXI_GCC_FILES) diff --git a/toolchain/gcc/patches-10.x/110-Fix-MIPS-PR-84790.patch b/toolchain/gcc/patches-10.x/110-Fix-MIPS-PR-84790.patch deleted file mode 100644 index 82ac013d3..000000000 --- a/toolchain/gcc/patches-10.x/110-Fix-MIPS-PR-84790.patch +++ /dev/null @@ -1,20 +0,0 @@ -Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84790. -MIPS16 functions have a static assembler prologue which clobbers -registers v0 and v1. Add these register clobbers to function call -instructions. - ---- a/gcc/config/mips/mips.c -+++ b/gcc/config/mips/mips.c -@@ -3132,6 +3132,12 @@ mips_emit_call_insn (rtx pattern, rtx or - emit_insn (gen_update_got_version ()); - } - -+ if (TARGET_MIPS16 && TARGET_USE_GOT) -+ { -+ clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), MIPS16_PIC_TEMP); -+ clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), MIPS_PROLOGUE_TEMP (word_mode)); -+ } -+ - if (TARGET_MIPS16 - && TARGET_EXPLICIT_RELOCS - && TARGET_CALL_CLOBBERED_GP) diff --git a/toolchain/gcc/patches-10.x/230-musl_libssp.patch b/toolchain/gcc/patches-10.x/230-musl_libssp.patch deleted file mode 100644 index 63f37662f..000000000 --- a/toolchain/gcc/patches-10.x/230-musl_libssp.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -875,7 +875,9 @@ proper position among the other output f - #endif - - #ifndef LINK_SSP_SPEC --#ifdef TARGET_LIBC_PROVIDES_SSP -+#if DEFAULT_LIBC == LIBC_MUSL -+#define LINK_SSP_SPEC "-lssp_nonshared" -+#elif defined(TARGET_LIBC_PROVIDES_SSP) - #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ - "|fstack-protector-strong|fstack-protector-explicit:}" - #else diff --git a/toolchain/gcc/patches-10.x/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches-10.x/300-mips_Os_cpu_rtx_cost_model.patch deleted file mode 100644 index 8c4a5fce1..000000000 --- a/toolchain/gcc/patches-10.x/300-mips_Os_cpu_rtx_cost_model.patch +++ /dev/null @@ -1,21 +0,0 @@ -commit ecf7671b769fe96f7b5134be442089f8bdba55d2 -Author: Felix Fietkau -Date: Thu Aug 4 20:29:45 2016 +0200 - -gcc: add a patch to generate better code with Os on mips - -Also happens to reduce compressed code size a bit - -Signed-off-by: Felix Fietkau - ---- a/gcc/config/mips/mips.c -+++ b/gcc/config/mips/mips.c -@@ -20041,7 +20041,7 @@ mips_option_override (void) - flag_pcc_struct_return = 0; - - /* Decide which rtx_costs structure to use. */ -- if (optimize_size) -+ if (0 && optimize_size) - mips_cost = &mips_rtx_cost_optimize_size; - else - mips_cost = &mips_rtx_cost_data[mips_tune]; diff --git a/toolchain/gcc/patches-10.x/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches-10.x/810-arm-softfloat-libgcc.patch deleted file mode 100644 index 5c9d86aea..000000000 --- a/toolchain/gcc/patches-10.x/810-arm-softfloat-libgcc.patch +++ /dev/null @@ -1,33 +0,0 @@ -commit 8570c4be394cff7282f332f97da2ff569a927ddb -Author: Imre Kaloz -Date: Wed Feb 2 20:06:12 2011 +0000 - - fixup arm soft-float symbols - - SVN-Revision: 25325 - ---- a/libgcc/config/arm/t-linux -+++ b/libgcc/config/arm/t-linux -@@ -1,6 +1,10 @@ - LIB1ASMSRC = arm/lib1funcs.S - LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \ -- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 -+ _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 \ -+ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \ -+ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \ -+ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \ -+ _arm_fixsfsi _arm_fixunssfsi - - # Just for these, we omit the frame pointer since it makes such a big - # difference. ---- a/gcc/config/arm/linux-elf.h -+++ b/gcc/config/arm/linux-elf.h -@@ -58,8 +58,6 @@ - %{shared:-lc} \ - %{!shared:%{profile:-lc_p}%{!profile:-lc}}" - --#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc" -- - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" - - #define LINUX_TARGET_LINK_SPEC "%{h*} \ diff --git a/toolchain/gcc/patches-10.x/820-libgcc_pic.patch b/toolchain/gcc/patches-10.x/820-libgcc_pic.patch deleted file mode 100644 index ddd6cf873..000000000 --- a/toolchain/gcc/patches-10.x/820-libgcc_pic.patch +++ /dev/null @@ -1,44 +0,0 @@ -commit c96312958c0621e72c9b32da5bc224ffe2161384 -Author: Felix Fietkau -Date: Mon Oct 19 23:26:09 2009 +0000 - - gcc: create a proper libgcc_pic.a static library for relinking (4.3.3+ for now, backport will follow) - - SVN-Revision: 18086 - ---- a/libgcc/Makefile.in -+++ b/libgcc/Makefile.in -@@ -929,11 +929,12 @@ $(libgcov-driver-objects): %$(objext): $ - - # Static libraries. - libgcc.a: $(libgcc-objects) -+libgcc_pic.a: $(libgcc-s-objects) - libgcov.a: $(libgcov-objects) - libunwind.a: $(libunwind-objects) - libgcc_eh.a: $(libgcc-eh-objects) - --libgcc.a libgcov.a libunwind.a libgcc_eh.a: -+libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a: - -rm -f $@ - - objects="$(objects)"; \ -@@ -957,7 +958,7 @@ all: libunwind.a - endif - - ifeq ($(enable_shared),yes) --all: libgcc_eh.a libgcc_s$(SHLIB_EXT) -+all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT) - ifneq ($(LIBUNWIND),) - all: libunwind$(SHLIB_EXT) - libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) -@@ -1163,6 +1164,10 @@ install-shared: - chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a - $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a - -+ $(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/ -+ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a -+ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a -+ - $(subst @multilib_dir@,$(MULTIDIR),$(subst \ - @shlib_base_name@,libgcc_s,$(subst \ - @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL)))) diff --git a/toolchain/gcc/patches-10.x/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches-10.x/840-armv4_pass_fix-v4bx_to_ld.patch deleted file mode 100644 index e3cb616c4..000000000 --- a/toolchain/gcc/patches-10.x/840-armv4_pass_fix-v4bx_to_ld.patch +++ /dev/null @@ -1,28 +0,0 @@ -commit 7edc8ca5456d9743dd0075eb3cc5b04f4f24c8cc -Author: Imre Kaloz -Date: Wed Feb 2 19:34:36 2011 +0000 - - add armv4 fixup patches - - SVN-Revision: 25322 - - ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -91,10 +91,15 @@ - #define MUSL_DYNAMIC_LINKER \ - "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" - -+/* For armv4 we pass --fix-v4bx to linker to support EABI */ -+#undef TARGET_FIX_V4BX_SPEC -+#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\ -+ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}" -+ - /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to - use the GNU/Linux version, not the generic BPABI version. */ - #undef LINK_SPEC --#define LINK_SPEC EABI_LINK_SPEC \ -+#define LINK_SPEC EABI_LINK_SPEC TARGET_FIX_V4BX_SPEC \ - LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ - LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) - diff --git a/toolchain/gcc/patches-10.x/850-use_shared_libgcc.patch b/toolchain/gcc/patches-10.x/850-use_shared_libgcc.patch deleted file mode 100644 index 8b17f1374..000000000 --- a/toolchain/gcc/patches-10.x/850-use_shared_libgcc.patch +++ /dev/null @@ -1,54 +0,0 @@ -commit dcfc40358b5a3cae7320c17f8d1cebd5ad5540cd -Author: Felix Fietkau -Date: Sun Feb 12 20:25:47 2012 +0000 - - gcc 4.6: port over the missing patch 850-use_shared_libgcc.patch to prevent libgcc crap from leaking into every single binary - - SVN-Revision: 30486 ---- a/gcc/config/arm/linux-eabi.h -+++ b/gcc/config/arm/linux-eabi.h -@@ -132,10 +132,6 @@ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} " \ - LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) - --/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we -- do not use -lfloat. */ --#undef LIBGCC_SPEC -- - /* Clear the instruction cache from `beg' to `end'. This is - implemented in lib1funcs.S, so ensure an error if this definition - is used. */ ---- a/gcc/config/linux.h -+++ b/gcc/config/linux.h -@@ -66,6 +66,10 @@ see the files COPYING3 and COPYING.RUNTI - builtin_version ("CRuntime_Musl"); \ - } while (0) - -+#ifndef LIBGCC_SPEC -+#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}" -+#endif -+ - /* Determine which dynamic linker to use depending on whether GLIBC or - uClibc or Bionic or musl is the default C library and whether - -muclibc or -mglibc or -mbionic or -mmusl has been passed to change ---- a/libgcc/mkmap-symver.awk -+++ b/libgcc/mkmap-symver.awk -@@ -136,5 +136,5 @@ function output(lib) { - else if (inherit[lib]) - printf("} %s;\n", inherit[lib]); - else -- printf ("\n local:\n\t*;\n};\n"); -+ printf ("\n\t*;\n};\n"); - } ---- a/gcc/config/rs6000/linux.h -+++ b/gcc/config/rs6000/linux.h -@@ -62,6 +62,9 @@ - #undef CPP_OS_DEFAULT_SPEC - #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)" - -+#undef LIBGCC_SPEC -+#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc" -+ - #undef LINK_SHLIB_SPEC - #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}} \ - %{static-pie:-static -pie --no-dynamic-linker -z text}" diff --git a/toolchain/gcc/patches-10.x/851-libgcc_no_compat.patch b/toolchain/gcc/patches-10.x/851-libgcc_no_compat.patch deleted file mode 100644 index d710e4071..000000000 --- a/toolchain/gcc/patches-10.x/851-libgcc_no_compat.patch +++ /dev/null @@ -1,22 +0,0 @@ -commit 64661de100da1ec1061ef3e5e400285dce115e6b -Author: Felix Fietkau -Date: Sun May 10 13:16:35 2015 +0000 - - gcc: add some size optimization patches - - Signed-off-by: Felix Fietkau - - SVN-Revision: 45664 - ---- a/libgcc/config/t-libunwind -+++ b/libgcc/config/t-libunwind -@@ -2,8 +2,7 @@ - - HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER - --LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \ -- $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c -+LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c - LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c - - # Override the default value from t-slibgcc-elf-ver and mention -lunwind diff --git a/toolchain/gcc/patches-10.x/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches-10.x/870-ppc_no_crtsavres.patch deleted file mode 100644 index bc182f0ce..000000000 --- a/toolchain/gcc/patches-10.x/870-ppc_no_crtsavres.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/gcc/config/rs6000/rs6000-logue.c -+++ b/gcc/config/rs6000/rs6000-logue.c -@@ -348,7 +348,7 @@ rs6000_savres_strategy (rs6000_stack_t * - /* Define cutoff for using out-of-line functions to save registers. */ - if (DEFAULT_ABI == ABI_V4 || TARGET_ELF) - { -- if (!optimize_size) -+ if (1) - { - strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS; - strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS; diff --git a/toolchain/gcc/patches-10.x/881-no_tm_section.patch b/toolchain/gcc/patches-10.x/881-no_tm_section.patch deleted file mode 100644 index 2029910fd..000000000 --- a/toolchain/gcc/patches-10.x/881-no_tm_section.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libgcc/crtstuff.c -+++ b/libgcc/crtstuff.c -@@ -152,7 +152,7 @@ call_ ## FUNC (void) \ - #endif - - #if !defined(USE_TM_CLONE_REGISTRY) && defined(OBJECT_FORMAT_ELF) --# define USE_TM_CLONE_REGISTRY 1 -+# define USE_TM_CLONE_REGISTRY 0 - #elif !defined(USE_TM_CLONE_REGISTRY) - # define USE_TM_CLONE_REGISTRY 0 - #endif diff --git a/toolchain/gcc/patches-10.x/900-bad-mips16-crt.patch b/toolchain/gcc/patches-10.x/900-bad-mips16-crt.patch deleted file mode 100644 index dd6e9dc88..000000000 --- a/toolchain/gcc/patches-10.x/900-bad-mips16-crt.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/libgcc/config/mips/t-mips16 -+++ b/libgcc/config/mips/t-mips16 -@@ -43,3 +43,6 @@ SYNC_CFLAGS = -mno-mips16 - - # Version these symbols if building libgcc.so. - SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver -+ -+CRTSTUFF_T_CFLAGS += -mno-mips16 -+CRTSTUFF_T_CFLAGS_S += -mno-mips16 diff --git a/toolchain/gcc/patches-10.x/910-mbsd_multi.patch b/toolchain/gcc/patches-10.x/910-mbsd_multi.patch deleted file mode 100644 index 3ed623831..000000000 --- a/toolchain/gcc/patches-10.x/910-mbsd_multi.patch +++ /dev/null @@ -1,146 +0,0 @@ -commit 99368862e44740ff4fd33760893f04e14f9dbdf1 -Author: Felix Fietkau -Date: Tue Jul 31 00:52:27 2007 +0000 - - Port the mbsd_multi patch from freewrt, which adds -fhonour-copts. This will emit warnings in packages that don't use our target cflags properly - - SVN-Revision: 8256 - - This patch brings over a feature from MirBSD: - * -fhonour-copts - If this option is not given, it's warned (depending - on environment variables). This is to catch errors - of misbuilt packages which override CFLAGS themselves. - - This patch was authored by Thorsten Glaser - with copyright assignment to the FSF in effect. - ---- a/gcc/c-family/c-opts.c -+++ b/gcc/c-family/c-opts.c -@@ -107,6 +107,9 @@ static dump_flags_t original_dump_flags; - /* Whether any standard preincluded header has been preincluded. */ - static bool done_preinclude; - -+/* Check if a port honours COPTS. */ -+static int honour_copts = 0; -+ - static void handle_OPT_d (const char *); - static void set_std_cxx98 (int); - static void set_std_cxx11 (int); -@@ -455,6 +458,12 @@ c_common_handle_option (size_t scode, co - flag_no_builtin = !value; - break; - -+ case OPT_fhonour_copts: -+ if (c_language == clk_c) { -+ honour_copts++; -+ } -+ break; -+ - case OPT_fconstant_string_class_: - constant_string_class_name = arg; - break; -@@ -1168,6 +1177,47 @@ c_common_init (void) - return false; - } - -+ if (c_language == clk_c) { -+ char *ev = getenv ("GCC_HONOUR_COPTS"); -+ int evv; -+ if (ev == NULL) -+ evv = -1; -+ else if ((*ev == '0') || (*ev == '\0')) -+ evv = 0; -+ else if (*ev == '1') -+ evv = 1; -+ else if (*ev == '2') -+ evv = 2; -+ else if (*ev == 's') -+ evv = -1; -+ else { -+ warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1"); -+ evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */ -+ } -+ if (evv == 1) { -+ if (honour_copts == 0) { -+ error ("someone does not honour COPTS at all in lenient mode"); -+ return false; -+ } else if (honour_copts != 1) { -+ warning (0, "someone does not honour COPTS correctly, passed %d times", -+ honour_copts); -+ } -+ } else if (evv == 2) { -+ if (honour_copts == 0) { -+ error ("someone does not honour COPTS at all in strict mode"); -+ return false; -+ } else if (honour_copts != 1) { -+ error ("someone does not honour COPTS correctly, passed %d times", -+ honour_copts); -+ return false; -+ } -+ } else if (evv == 0) { -+ if (honour_copts != 1) -+ inform (UNKNOWN_LOCATION, "someone does not honour COPTS correctly, passed %d times", -+ honour_copts); -+ } -+ } -+ - return true; - } - ---- a/gcc/c-family/c.opt -+++ b/gcc/c-family/c.opt -@@ -1590,6 +1590,9 @@ C++ ObjC++ Optimization Alias(fexception - fhonor-std - C++ ObjC++ WarnRemoved - -+fhonour-copts -+C ObjC C++ ObjC++ RejectNegative -+ - fhosted - C ObjC - Assume normal C execution environment. ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -1660,6 +1660,9 @@ fguess-branch-probability - Common Report Var(flag_guess_branch_prob) Optimization - Enable guessing of branch probabilities. - -+fhonour-copts -+Common RejectNegative -+ - ; Nonzero means ignore `#ident' directives. 0 means handle them. - ; Generate position-independent code for executables if possible - ; On SVR4 targets, it also controls whether or not to emit a ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -8171,6 +8171,17 @@ This option is only supported for C and - @option{-Wall} and by @option{-Wpedantic}, which can be disabled with - @option{-Wno-pointer-sign}. - -+@item -fhonour-copts -+@opindex fhonour-copts -+If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not -+given at least once, and warn if it is given more than once. -+If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not -+given exactly once. -+If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option -+is not given exactly once. -+The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}. -+This flag and environment variable only affect the C language. -+ - @item -Wstack-protector - @opindex Wstack-protector - @opindex Wno-stack-protector ---- a/gcc/opts.c -+++ b/gcc/opts.c -@@ -2318,6 +2318,9 @@ common_handle_option (struct gcc_options - /* Currently handled in a prescan. */ - break; - -+ case OPT_fhonour_copts: -+ break; -+ - case OPT_Werror: - dc->warning_as_error_requested = value; - break; diff --git a/toolchain/gcc/patches-10.x/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches-10.x/920-specs_nonfatal_getenv.patch deleted file mode 100644 index 487b9e47c..000000000 --- a/toolchain/gcc/patches-10.x/920-specs_nonfatal_getenv.patch +++ /dev/null @@ -1,22 +0,0 @@ -Author: Jo-Philipp Wich -Date: Sat Apr 21 03:02:39 2012 +0000 - - gcc: add patch to make the getenv() spec function nonfatal if requested environment variable is unset - - SVN-Revision: 31390 - ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -9396,8 +9396,10 @@ getenv_spec_function (int argc, const ch - } - - if (!value) -- fatal_error (input_location, -- "environment variable %qs not defined", varname); -+ { -+ warning (input_location, "environment variable %qs not defined", varname); -+ value = ""; -+ } - - /* We have to escape every character of the environment variable so - they are not interpreted as active spec characters. A diff --git a/toolchain/gcc/patches-10.x/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches-10.x/930-fix-mips-noexecstack.patch deleted file mode 100644 index e795acd1d..000000000 --- a/toolchain/gcc/patches-10.x/930-fix-mips-noexecstack.patch +++ /dev/null @@ -1,111 +0,0 @@ -From da45b3fde60095756f5f6030f6012c23a3d34429 Mon Sep 17 00:00:00 2001 -From: Andrew McDonnell -Date: Fri, 3 Oct 2014 19:09:00 +0930 -Subject: Add .note.GNU-stack section - -See http://lists.busybox.net/pipermail/uclibc/2014-October/048671.html -Below copied from https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02430.html - -Re: [Patch, MIPS] Add .note.GNU-stack section - - From: Steve Ellcey - -On Wed, 2014-09-10 at 10:15 -0700, Eric Christopher wrote: -> -> -> On Wed, Sep 10, 2014 at 9:27 AM, wrote: - -> This works except you did not update the assembly files in -> libgcc or glibc. We (Cavium) have the same patch in our tree -> for a few released versions. - -> Mind just checking yours in then Andrew? - -> Thanks! -> -eric - -I talked to Andrew about what files he changed in GCC and created and -tested this new patch. Andrew also mentioned changing some assembly -files in glibc but I don't see any use of '.section .note.GNU-stack' in -any assembly files in glibc (for any platform) so I wasn't planning on -creating a glibc to add them to mips glibc assembly language files. - -OK to check in this patch? - -Steve Ellcey -sellcey@mips.com - - - -2014-09-26 Steve Ellcey ---- - gcc/config/mips/mips.c | 3 +++ - libgcc/config/mips/crti.S | 4 ++++ - libgcc/config/mips/crtn.S | 3 +++ - libgcc/config/mips/mips16.S | 4 ++++ - libgcc/config/mips/vr4120-div.S | 4 ++++ - 5 files changed, 18 insertions(+) - ---- a/gcc/config/mips/mips.c -+++ b/gcc/config/mips/mips.c -@@ -22881,6 +22881,9 @@ mips_asm_file_end (void) - #define TARGET_ASM_FILE_END mips_asm_file_end - - -+#undef TARGET_ASM_FILE_END -+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack -+ - struct gcc_target targetm = TARGET_INITIALIZER; - - #include "gt-mips.h" ---- a/libgcc/config/mips/crti.S -+++ b/libgcc/config/mips/crti.S -@@ -24,6 +24,10 @@ see the files COPYING3 and COPYING.RUNTI - /* An executable stack is *not* required for these functions. */ - #include "gnustack.h" - -+ -+/* An executable stack is *not* required for these functions. */ -+ .section .note.GNU-stack,"",%progbits -+ - /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack. - Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */ - ---- a/libgcc/config/mips/crtn.S -+++ b/libgcc/config/mips/crtn.S -@@ -24,6 +24,9 @@ see the files COPYING3 and COPYING.RUNTI - /* An executable stack is *not* required for these functions. */ - #include "gnustack.h" - -+/* An executable stack is *not* required for these functions. */ -+ .section .note.GNU-stack,"",%progbits -+ - /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack. - Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */ - ---- a/libgcc/config/mips/mips16.S -+++ b/libgcc/config/mips/mips16.S -@@ -51,6 +51,10 @@ see the files COPYING3 and COPYING.RUNTI - values using the soft-float calling convention, but do the actual - operation using the hard floating point instructions. */ - -+/* An executable stack is *not* required for these functions. */ -+ .section .note.GNU-stack,"",%progbits -+ .previous -+ - #if defined _MIPS_SIM && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64) - - /* This file contains 32-bit assembly code. */ ---- a/libgcc/config/mips/vr4120-div.S -+++ b/libgcc/config/mips/vr4120-div.S -@@ -29,6 +29,10 @@ see the files COPYING3 and COPYING.RUNTI - -mfix-vr4120. div and ddiv do not give the correct result when one - of the operands is negative. */ - -+/* An executable stack is *not* required for these functions. */ -+ .section .note.GNU-stack,"",%progbits -+ .previous -+ - .set nomips16 - - #define DIV \ diff --git a/toolchain/gcc/patches-10.x/931-libffi-fix-MIPS-softfloat-build-issue.patch b/toolchain/gcc/patches-10.x/931-libffi-fix-MIPS-softfloat-build-issue.patch deleted file mode 100644 index fb4cb1533..000000000 --- a/toolchain/gcc/patches-10.x/931-libffi-fix-MIPS-softfloat-build-issue.patch +++ /dev/null @@ -1,168 +0,0 @@ -From c0c62fa4256f805389f16ebfc4a60cf789129b50 Mon Sep 17 00:00:00 2001 -From: BangLang Huang -Date: Wed, 9 Nov 2016 10:36:49 +0800 -Subject: [PATCH] libffi: fix MIPS softfloat build issue - -Backported from github.com/libffi/libffi#272 - -Signed-off-by: BangLang Huang -Signed-off-by: Yousong Zhou ---- - libffi/src/mips/n32.S | 17 +++++++++++++++++ - libffi/src/mips/o32.S | 17 +++++++++++++++++ - 2 files changed, 34 insertions(+) - ---- a/libffi/src/mips/n32.S -+++ b/libffi/src/mips/n32.S -@@ -107,6 +107,16 @@ loadregs: - - REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6. - -+#ifdef __mips_soft_float -+ REG_L a0, 0*FFI_SIZEOF_ARG(t9) -+ REG_L a1, 1*FFI_SIZEOF_ARG(t9) -+ REG_L a2, 2*FFI_SIZEOF_ARG(t9) -+ REG_L a3, 3*FFI_SIZEOF_ARG(t9) -+ REG_L a4, 4*FFI_SIZEOF_ARG(t9) -+ REG_L a5, 5*FFI_SIZEOF_ARG(t9) -+ REG_L a6, 6*FFI_SIZEOF_ARG(t9) -+ REG_L a7, 7*FFI_SIZEOF_ARG(t9) -+#else - and t4, t6, ((1< -Date: Fri, 4 May 2018 18:20:53 +0800 -Subject: [PATCH] gotools: fix compilation when making cross compiler - -libgo is "the runtime support library for the Go programming language. -This library is intended for use with the Go frontend." - -gccgo will link target files with libgo.so which depends on libgcc_s.so.1, but -the linker will complain that it cannot find it. That's because shared libgcc -is not present in the install directory yet. libgo.so was made without problem -because gcc will emit -lgcc_s when compiled with -shared option. When gotools -were being made, it was supplied with -static-libgcc thus no link option was -provided. Check LIBGO in gcc/go/gcc-spec.c for how gccgo make a builtin spec -for linking with libgo.so - -- GccgoCrossCompilation, https://github.com/golang/go/wiki/GccgoCrossCompilation -- Cross-building instructions, http://www.eglibc.org/archives/patches/msg00078.html - -When 3-pass GCC compilation is used, shared libgcc runtime libraries will be -available after gcc pass2 completed and will meet the gotools link requirement -at gcc pass3 ---- - gotools/Makefile.am | 4 +++- - gotools/Makefile.in | 4 +++- - 2 files changed, 6 insertions(+), 2 deletions(-) - ---- a/gotools/Makefile.am -+++ b/gotools/Makefile.am -@@ -26,6 +26,7 @@ PWD_COMMAND = $${PWDCMD-pwd} - STAMP = echo timestamp > - - libgodir = ../$(target_noncanonical)/libgo -+libgccdir = ../$(target_noncanonical)/libgcc - LIBGODEP = $(libgodir)/libgo.la - - LIBGOTOOL = $(libgodir)/libgotool.a -@@ -41,7 +42,8 @@ GOCFLAGS = $(CFLAGS_FOR_TARGET) - GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS) - - AM_GOCFLAGS = -I $(libgodir) --AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs -+AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \ -+ -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s - GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@ - - libgosrcdir = $(srcdir)/../libgo/go ---- a/gotools/Makefile.in -+++ b/gotools/Makefile.in -@@ -337,6 +337,7 @@ mkinstalldirs = $(SHELL) $(toplevel_srcd - PWD_COMMAND = $${PWDCMD-pwd} - STAMP = echo timestamp > - libgodir = ../$(target_noncanonical)/libgo -+libgccdir = ../$(target_noncanonical)/libgcc - LIBGODEP = $(libgodir)/libgo.la - LIBGOTOOL = $(libgodir)/libgotool.a - @NATIVE_FALSE@GOCOMPILER = $(GOC) -@@ -346,7 +347,8 @@ LIBGOTOOL = $(libgodir)/libgotool.a - GOCFLAGS = $(CFLAGS_FOR_TARGET) - GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS) - AM_GOCFLAGS = -I $(libgodir) --AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs -+AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \ -+ -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s - GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@ - libgosrcdir = $(srcdir)/../libgo/go - cmdsrcdir = $(libgosrcdir)/cmd diff --git a/toolchain/gcc/patches-11.x/400-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch b/toolchain/gcc/patches-11.x/400-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch new file mode 100644 index 000000000..39869b474 --- /dev/null +++ b/toolchain/gcc/patches-11.x/400-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch @@ -0,0 +1,39 @@ +From d2356ebb0084a0d80dbfe33040c9afe938c15d19 Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Mon, 11 Jul 2022 22:03:14 +0200 +Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream + +9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include to resolve fsconfig_command/mount_attr conflict with glibc 2.36 + +(cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe) +--- + .../sanitizer_platform_limits_posix.cpp | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp +@@ -72,7 +72,9 @@ + #include + #include + #include ++#if SANITIZER_ANDROID + #include ++#endif + #include + #include + #include +@@ -828,10 +830,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El + unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT; + unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT; + #endif +- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS; +- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION; +- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS; +- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION; ++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long); ++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long); ++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long); ++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long); + unsigned IOCTL_GIO_CMAP = GIO_CMAP; + unsigned IOCTL_GIO_FONT = GIO_FONT; + unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP; diff --git a/toolchain/gdb/Makefile b/toolchain/gdb/Makefile index 6ed3b190c..4587c591f 100644 --- a/toolchain/gdb/Makefile +++ b/toolchain/gdb/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gdb -PKG_VERSION:=11.2 +PKG_VERSION:=12.1 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/gdb -PKG_HASH:=1497c36a71881b8671a9a84a0ee40faab788ca30d7ba19d8463c3cc787152e32 +PKG_HASH:=0e1793bf8f2b54d53f46dea84ccfd446f48f81b297b28c4f7fc017b818d69fed GDB_DIR:=$(PKG_NAME)-$(PKG_VERSION) HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GDB_DIR) @@ -33,12 +33,12 @@ HOST_CONFIGURE_ARGS = \ --with-gmp=$(TOPDIR)/staging_dir/host \ --with-mpfr=$(TOPDIR)/staging_dir/host \ --with-mpc=$(TOPDIR)/staging_dir/host \ + --with-expat=$(TOPDIR)/staging_dir/host \ --disable-werror \ --without-uiout \ --enable-tui --disable-gdbtk --without-x \ --without-included-gettext \ --enable-threads \ - --with-expat \ --disable-unit-tests \ --disable-ubsan \ --disable-binutils \ diff --git a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch index 99c91a030..118bebe3c 100644 --- a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch +++ b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch @@ -1,6 +1,6 @@ --- a/gdbserver/configure +++ b/gdbserver/configure -@@ -2661,7 +2661,7 @@ $as_echo "$as_me: error: \`$ac_var' was +@@ -2664,7 +2664,7 @@ $as_echo "$as_me: error: \`$ac_var' was ac_cache_corrupted=: ;; ,);; *) diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk index 51d13c457..314144eea 100644 --- a/toolchain/glibc/common.mk +++ b/toolchain/glibc/common.mk @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=glibc -PKG_VERSION:=2.34 +PKG_VERSION:=2.36 PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=72123e1b56f53f9205bb105f8a62d0869b837b22 -PKG_MIRROR_HASH:=934ec7067d41da0b76b8f29a1cd03b10ba9d98c2f761f7b32f8595e59ac2b428 +PKG_SOURCE_VERSION:=3aae843e9e9e6a2502e98ff44d2671b20a023f8e +PKG_MIRROR_HASH:=29bdd6ca699f297de500ea457741d0706d57a69836fa7d45e6cc2cc20484cad4 PKG_SOURCE_URL:=https://sourceware.org/git/glibc.git PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz diff --git a/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch b/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch index 7dfc8a558..c9db70393 100644 --- a/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch +++ b/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch @@ -82,7 +82,7 @@ provides them. int totfails = 0; int main (int argc, char *argv[]); -@@ -120,13 +104,3 @@ put8 (char *cp) +@@ -119,13 +103,3 @@ put8 (char *cp) printf("%02x", t); } } @@ -627,7 +627,7 @@ provides them. range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h -@@ -971,6 +971,12 @@ extern int getsubopt (char **__restrict +@@ -984,6 +984,12 @@ extern int getsubopt (char **__restrict #endif diff --git a/toolchain/glibc/patches/200-add-dl-search-paths.patch b/toolchain/glibc/patches/200-add-dl-search-paths.patch index fd4af3694..e927d86f2 100644 --- a/toolchain/glibc/patches/200-add-dl-search-paths.patch +++ b/toolchain/glibc/patches/200-add-dl-search-paths.patch @@ -2,7 +2,7 @@ add /usr/lib to default search path for the dynamic linker --- a/Makeconfig +++ b/Makeconfig -@@ -618,6 +618,9 @@ else +@@ -631,6 +631,9 @@ else default-rpath = $(libdir) endif diff --git a/tools/Makefile b/tools/Makefile index 30614af9b..c7c7d0075 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -17,15 +17,48 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) BUILD_ISL = y endif endif -ifneq ($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_PACKAGE_b43legacy-firmware)$(CONFIG_BRCMSMAC_USE_FW_FROM_WL),) +ifneq ($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_BRCMSMAC_USE_FW_FROM_WL),) BUILD_B43_TOOLS = y endif -tools-y += autoconf autoconf-archive automake bc bison cmake cpio dosfstools -tools-y += e2fsprogs expat fakeroot findutils firmware-utils flex gengetopt -tools-y += libressl libtool lzma m4 make-ext4fs meson missing-macros mkimage -tools-y += mklibs mtd-utils mtools ninja padjffs2 patch-image -tools-y += patchelf pkgconf quilt squashfskit4 sstrip ucl upx zip zlib zstd +tools-y += autoconf +tools-y += autoconf-archive +tools-y += automake +tools-y += bc +tools-y += bison +tools-y += cmake +tools-y += cpio +tools-y += dosfstools +tools-y += e2fsprogs +tools-y += expat +tools-y += fakeroot +tools-y += findutils +tools-y += firmware-utils +tools-y += flex +tools-y += gengetopt +tools-y += libdeflate +tools-y += libressl +tools-y += libtool +tools-y += lzma +tools-y += m4 +tools-y += make-ext4fs +tools-y += meson +tools-y += missing-macros +tools-y += mkimage +tools-y += mklibs +tools-y += mtd-utils +tools-y += mtools +tools-y += ninja +tools-y += padjffs2 +tools-y += patch-image +tools-y += patchelf +tools-y += pkgconf +tools-y += quilt +tools-y += squashfskit4 +tools-y += sstrip +tools-y += zip +tools-y += zlib +tools-y += zstd tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_B43_TOOLS),y) += b43-tools tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_ISL),y) += isl tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_TOOLCHAIN),y) += gmp mpc mpfr @@ -43,7 +76,6 @@ $(curdir)/autoconf/compile := $(curdir)/m4/compile $(curdir)/automake/compile := $(curdir)/autoconf/compile $(curdir)/pkgconf/compile $(curdir)/xz/compile $(curdir)/b43-tools/compile := $(curdir)/bison/compile $(curdir)/bc/compile := $(curdir)/bison/compile $(curdir)/libtool/compile -$(curdir)/upx/compile := $(curdir)/ucl/compile $(curdir)/bison/compile := $(curdir)/flex/compile $(curdir)/cbootimage/compile += $(curdir)/automake/compile $(curdir)/cmake/compile += $(curdir)/libressl/compile $(curdir)/ninja/compile $(curdir)/expat/compile $(curdir)/xz/compile $(curdir)/zlib/compile $(curdir)/zstd/compile @@ -57,6 +89,7 @@ $(curdir)/genext2fs/compile := $(curdir)/libtool/compile $(curdir)/gengetopt/compile := $(curdir)/libtool/compile $(curdir)/gmp/compile := $(curdir)/libtool/compile $(curdir)/isl/compile := $(curdir)/gmp/compile +$(curdir)/libdeflate/compile := $(curdir)/cmake/compile $(curdir)/libressl/compile := $(curdir)/pkgconf/compile $(curdir)/libtool/compile := $(curdir)/automake/compile $(curdir)/missing-macros/compile $(curdir)/lzma-old/compile := $(curdir)/zlib/compile diff --git a/tools/bash/Makefile b/tools/bash/Makefile index e5cf3b594..f4bfc0739 100644 --- a/tools/bash/Makefile +++ b/tools/bash/Makefile @@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bash PKG_CPE_ID:=cpe:/a:gnu:bash -PKG_VERSION:=5.2 +PKG_VERSION:=5.2.15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/bash -PKG_HASH:=a139c166df7ff4471c5e0733051642ee5556c1cc8a4a78f145583c5c81ab32fb +PKG_HASH:=13720965b5f4fc3a0d4b61dd37e7565c741da9a5be24edc2ae00182fc1b3588c HOST_BUILD_PARALLEL := 1 diff --git a/tools/ccache/Makefile b/tools/ccache/Makefile index 0cf528bb5..25ab4a46e 100644 --- a/tools/ccache/Makefile +++ b/tools/ccache/Makefile @@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/target.mk PKG_NAME:=ccache -PKG_VERSION:=4.6.3 +PKG_VERSION:=4.7.4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://github.com/ccache/ccache/releases/download/v$(PKG_VERSION) -PKG_HASH:=1e3a251bb112632553b8255a78661fe526c3a16598496d51128c32b218fd8b22 +PKG_HASH:=df0c64d15d3efaf0b4f6837dd6b1467e40eeaaa807db25ce79c3a08a46a84e36 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/tools/ccache/patches/100-honour-copts.patch b/tools/ccache/patches/100-honour-copts.patch index c8f2fc0fe..5358d425c 100644 --- a/tools/ccache/patches/100-honour-copts.patch +++ b/tools/ccache/patches/100-honour-copts.patch @@ -1,10 +1,10 @@ --- a/src/ccache.cpp +++ b/src/ccache.cpp -@@ -1756,6 +1756,7 @@ calculate_result_and_manifest_key(Contex - "CPLUS_INCLUDE_PATH", - "OBJC_INCLUDE_PATH", - "OBJCPLUS_INCLUDE_PATH", // clang -+ "GCC_HONOUR_COPTS", - nullptr}; - for (const char** p = envvars; *p; ++p) { - const char* v = getenv(*p); +@@ -1779,6 +1779,7 @@ get_manifest_key(Context& ctx, Hash& has + "CPLUS_INCLUDE_PATH", + "OBJC_INCLUDE_PATH", + "OBJCPLUS_INCLUDE_PATH", // clang ++ "GCC_HONOUR_COPTS", + nullptr}; + for (const char** p = envvars; *p; ++p) { + const char* v = getenv(*p); diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile index 07e2a4321..b7dadee73 100644 --- a/tools/cmake/Makefile +++ b/tools/cmake/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=cmake -PKG_VERSION:=3.24.2 +PKG_VERSION:=3.25.1 PKG_VERSION_MAJOR:=$(word 1,$(subst ., ,$(PKG_VERSION))).$(word 2,$(subst ., ,$(PKG_VERSION))) PKG_RELEASE:=1 PKG_CPE_ID:=cpe:/a:kitware:cmake @@ -15,7 +15,7 @@ PKG_CPE_ID:=cpe:/a:kitware:cmake PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/Kitware/CMake/releases/download/v$(PKG_VERSION)/ \ https://cmake.org/files/v$(PKG_VERSION_MAJOR)/ -PKG_HASH:=0d9020f06f3ddf17fb537dc228e1a56c927ee506b486f55fe2dc19f69bf0c8db +PKG_HASH:=1c511d09516af493694ed9baf13c55947a36389674d657a2d5e0ccedc6b291d8 HOST_BUILD_PARALLEL:=1 HOST_CONFIGURE_PARALLEL:=1 diff --git a/tools/cmake/patches/120-curl-fix-libressl-linking.patch b/tools/cmake/patches/120-curl-fix-libressl-linking.patch index 6ef37c22c..1744fe5b0 100644 --- a/tools/cmake/patches/120-curl-fix-libressl-linking.patch +++ b/tools/cmake/patches/120-curl-fix-libressl-linking.patch @@ -20,7 +20,7 @@ Signed-off-by: Jo-Philipp Wich --- --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt -@@ -594,6 +594,14 @@ if(CURL_USE_OPENSSL) +@@ -611,6 +611,14 @@ if(CURL_USE_OPENSSL) endif() set(SSL_ENABLED ON) set(USE_OPENSSL ON) diff --git a/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch b/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch index 2b3ba361b..70d122c9d 100644 --- a/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch +++ b/tools/cmake/patches/130-bootstrap_parallel_make_flag.patch @@ -1,6 +1,6 @@ --- a/bootstrap +++ b/bootstrap -@@ -1441,7 +1441,10 @@ int main(){ printf("1%c", (char)0x0a); r +@@ -1449,7 +1449,10 @@ int main(){ printf("1%c", (char)0x0a); r ' > "test.c" cmake_original_make_flags="${cmake_make_flags}" if test "x${cmake_parallel_make}" != "x"; then diff --git a/tools/cmake/patches/150-zstd-libarchive.patch b/tools/cmake/patches/150-zstd-libarchive.patch index 603ac0377..34f7240fe 100644 --- a/tools/cmake/patches/150-zstd-libarchive.patch +++ b/tools/cmake/patches/150-zstd-libarchive.patch @@ -1,6 +1,6 @@ --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt -@@ -630,8 +630,13 @@ IF(ENABLE_ZSTD) +@@ -632,8 +632,13 @@ IF(ENABLE_ZSTD) SET(ZSTD_FIND_QUIETLY TRUE) ENDIF (ZSTD_INCLUDE_DIR) diff --git a/tools/dosfstools/Makefile b/tools/dosfstools/Makefile index 7c834dfd4..b332efdb9 100644 --- a/tools/dosfstools/Makefile +++ b/tools/dosfstools/Makefile @@ -11,10 +11,10 @@ PKG_NAME:=dosfstools PKG_CPE_ID:=cpe:/a:dosfstools_project:dosfstools PKG_VERSION:=4.2 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/dosfstools/dosfstools/releases/download/v$(PKG_VERSION)/ \ http://fossies.org/linux/misc -PKG_HASH:=ba7c716ff9b8208a3bba5094a77584a7dc814141de09ab4ce1ae9b84bbcd7844 +PKG_HASH:=64926eebf90092dca21b14259a5301b7b98e7b1943e8a201c7d726084809b527 HOST_FIXUP:=autoreconf diff --git a/tools/dwarves/Makefile b/tools/dwarves/Makefile index d9a121aab..00833b957 100644 --- a/tools/dwarves/Makefile +++ b/tools/dwarves/Makefile @@ -13,8 +13,6 @@ PKG_HASH:=576bc112b95937dfbcd347c423696ee9e1992a338fdca1acacca736fd95f69c2 PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:=COPYING -HOST_BUILD_PARALLEL:=1 - include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/tools/e2fsprogs/Makefile b/tools/e2fsprogs/Makefile index 004a04ea2..a8bd745af 100644 --- a/tools/e2fsprogs/Makefile +++ b/tools/e2fsprogs/Makefile @@ -11,7 +11,7 @@ PKG_NAME:=e2fsprogs PKG_CPE_ID:=cpe:/a:e2fsprogs_project:e2fsprogs PKG_VERSION:=1.46.5 PKG_HASH:=2f16c9176704cf645dc69d5b15ff704ae722d665df38b2ed3cfc249757d8d81e -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/kernel/people/tytso/e2fsprogs/v$(PKG_VERSION)/ diff --git a/tools/e2fsprogs/patches/004-CVE-2022-1304-libext2fs-add-sanity-check-to-extent-manipulation.patch b/tools/e2fsprogs/patches/004-CVE-2022-1304-libext2fs-add-sanity-check-to-extent-manipulation.patch new file mode 100644 index 000000000..e5a76161f --- /dev/null +++ b/tools/e2fsprogs/patches/004-CVE-2022-1304-libext2fs-add-sanity-check-to-extent-manipulation.patch @@ -0,0 +1,50 @@ +From ab51d587bb9b229b1fade1afd02e1574c1ba5c76 Mon Sep 17 00:00:00 2001 +From: Lukas Czerner +Date: Thu, 21 Apr 2022 19:31:48 +0200 +Subject: libext2fs: add sanity check to extent manipulation + +It is possible to have a corrupted extent tree in such a way that a leaf +node contains zero extents in it. Currently if that happens and we try +to traverse the tree we can end up accessing wrong data, or possibly +even uninitialized memory. Make sure we don't do that. + +Additionally make sure that we have a sane number of bytes passed to +memmove() in ext2fs_extent_delete(). + +Note that e2fsck is currently unable to spot and fix such corruption in +pass1. + +Signed-off-by: Lukas Czerner +Reported-by: Nils Bars +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2068113 +Addresses: CVE-2022-1304 +Addresses-Debian-Bug: #1010263 +Signed-off-by: Theodore Ts'o +--- + lib/ext2fs/extent.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/lib/ext2fs/extent.c ++++ b/lib/ext2fs/extent.c +@@ -495,6 +495,10 @@ retry: + ext2fs_le16_to_cpu(eh->eh_entries); + newpath->max_entries = ext2fs_le16_to_cpu(eh->eh_max); + ++ /* Make sure there is at least one extent present */ ++ if (newpath->left <= 0) ++ return EXT2_ET_EXTENT_NO_DOWN; ++ + if (path->left > 0) { + ix++; + newpath->end_blk = ext2fs_le32_to_cpu(ix->ei_block); +@@ -1630,6 +1634,10 @@ errcode_t ext2fs_extent_delete(ext2_exte + + cp = path->curr; + ++ /* Sanity check before memmove() */ ++ if (path->left < 0) ++ return EXT2_ET_EXTENT_LEAF_BAD; ++ + if (path->left) { + memmove(cp, cp + sizeof(struct ext3_extent_idx), + path->left * sizeof(struct ext3_extent_idx)); diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile index 37e0d545f..4461e45b6 100644 --- a/tools/elfutils/Makefile +++ b/tools/elfutils/Makefile @@ -3,12 +3,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=elfutils -PKG_VERSION:=0.187 +PKG_VERSION:=0.188 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) -PKG_HASH:=e70b0dfbe610f90c4d1fe0d71af142a4e25c3c4ef9ebab8d2d72b65159d454c8 +PKG_HASH:=fb8b0e8d0802005b9a309c60c1d8de32dd2951b56f0c3a3cb56d21ce01595dff PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3 diff --git a/tools/expat/Makefile b/tools/expat/Makefile index 22acf45e0..c1a8cb8d9 100644 --- a/tools/expat/Makefile +++ b/tools/expat/Makefile @@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk PKG_NAME:=expat PKG_CPE_ID:=cpe:/a:libexpat:expat -PKG_VERSION:=2.4.9 +PKG_VERSION:=2.5.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_HASH:=6e8c0728fe5c7cd3f93a6acce43046c5e4736c7b4b68e032e9350daa0efc0354 +PKG_HASH:=ef2420f0232c087801abf705e89ae65f6257df6b7931d37846a193ef2e8cdcbe PKG_SOURCE_URL:=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$(PKG_VERSION)) HOST_BUILD_PARALLEL:=1 diff --git a/tools/fakeroot/Makefile b/tools/fakeroot/Makefile index efd9227d1..66ccbcb50 100644 --- a/tools/fakeroot/Makefile +++ b/tools/fakeroot/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fakeroot -PKG_VERSION:=1.29 +PKG_VERSION:=1.30.1 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz PKG_SOURCE_URL:=@DEBIAN/pool/main/f/fakeroot -PKG_HASH:=8fbbafb780c9173e3ace4a04afbc1d900f337f3216883939f5c7db3431be7c20 +PKG_HASH:=32ebb1f421aca0db7141c32a8c104eb95d2b45c393058b9435fbf903dd2b6a75 PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE_FILES:=COPYING PKG_FIXUP:=autoreconf diff --git a/tools/fakeroot/patches/600-macOS.patch b/tools/fakeroot/patches/600-macOS.patch index 730367f07..5cfcc8128 100644 --- a/tools/fakeroot/patches/600-macOS.patch +++ b/tools/fakeroot/patches/600-macOS.patch @@ -24,7 +24,7 @@ #include --- a/wrapfunc.inp +++ b/wrapfunc.inp -@@ -48,9 +48,11 @@ getattrlist$UNIX2003;int;(const char *pa +@@ -50,9 +50,11 @@ getattrlist$UNIX2003;int;(const char *pa #endif #endif #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 @@ -36,7 +36,7 @@ posix_spawn;int;(pid_t * __restrict pid, const char * __restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t * __restrict attrp, char *const argv[ __restrict], char *const envp[ __restrict]);(pid, path, file_actions, attrp, argv, envp) posix_spawnp;int;(pid_t * __restrict pid, const char * __restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t * __restrict attrp, char *const argv[ __restrict], char *const envp[ __restrict]);(pid, path, file_actions, attrp, argv, envp) #endif -@@ -229,7 +231,7 @@ facl;int;(int fd, int cmd, int cnt, void +@@ -231,7 +233,7 @@ facl;int;(int fd, int cmd, int cnt, void #ifdef HAVE_FTS_READ fts_read;FTSENT *;(FTS *ftsp);(ftsp) #ifdef __APPLE__ @@ -45,7 +45,7 @@ fts_read$INODE64;FTSENT *;(FTS *ftsp);(ftsp) #endif #endif /* ifdef __APPLE__ */ -@@ -237,7 +239,7 @@ fts_read$INODE64;FTSENT *;(FTS *ftsp);(f +@@ -239,7 +241,7 @@ fts_read$INODE64;FTSENT *;(FTS *ftsp);(f #ifdef HAVE_FTS_CHILDREN fts_children;FTSENT *;(FTS *ftsp, int options);(ftsp, options) #ifdef __APPLE__ diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 731bc8a04..1c47a3109 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -11,9 +11,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git -PKG_SOURCE_DATE:=2022-09-12 -PKG_SOURCE_VERSION:=0c92b20ad488a4fb5fb290f6d1b893df45761275 -PKG_MIRROR_HASH:=2cfd36e749b51d539cffe22c77a4c3ccd3bac2eca482affe23e1cab539e8bd16 +PKG_SOURCE_DATE:=2022-12-15 +PKG_SOURCE_VERSION:=bd856eff48509fa4511169ee55f639ede8dd4ac6 +PKG_MIRROR_HASH:=4dc754b403b10f43dc2871f17ef7b223c85ad3b14c57899497f0b6bb304756d9 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/tools/libdeflate/Makefile b/tools/libdeflate/Makefile new file mode 100644 index 000000000..d30a8ca67 --- /dev/null +++ b/tools/libdeflate/Makefile @@ -0,0 +1,31 @@ +# +# Copyright (C) 2022 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libdeflate +PKG_VERSION:=1.15 +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=https://github.com/ebiggers/libdeflate.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=v$(PKG_VERSION) +PKG_MIRROR_HASH:=122feff4543541b547dc89e832adf262c81911ae1acbccdc591f0353a85b600a + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/cmake.mk + +define Host/Install + $(INSTALL_BIN) $(HOST_BUILD_DIR)/programs/libdeflate-gzip $(STAGING_DIR_HOST)/bin/ + $(LN) libdeflate-gzip $(STAGING_DIR_HOST)/bin/libdeflate-gunzip +endef + +define Host/Clean + rm -f $(STAGING_DIR_HOST)/bin/libdeflate-gzip + rm -f $(STAGING_DIR_HOST)/bin/libdeflate-gunzip +endef + +$(eval $(call HostBuild)) diff --git a/tools/libressl/Makefile b/tools/libressl/Makefile index fe73e7cde..f687f6b41 100644 --- a/tools/libressl/Makefile +++ b/tools/libressl/Makefile @@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libressl -PKG_VERSION:=3.5.3 -PKG_HASH:=3ab5e5eaef69ce20c6b170ee64d785b42235f48f2e62b095fca5d7b6672b8b28 +PKG_VERSION:=3.7.0 +PKG_HASH:=3fc1290f4007ec75f6e9acecbb25512630d1b9ab8c53ba79844e395868c3e006 PKG_RELEASE:=1 PKG_CPE_ID:=cpe:/a:openbsd:libressl diff --git a/tools/llvm-bpf/Makefile b/tools/llvm-bpf/Makefile index 775e1af89..2a0cc0ab3 100644 --- a/tools/llvm-bpf/Makefile +++ b/tools/llvm-bpf/Makefile @@ -7,17 +7,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=llvm-project -PKG_VERSION:=14.0.6 +PKG_VERSION:=15.0.6 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).src.tar.xz PKG_SOURCE_URL:=https://github.com/llvm/llvm-project/releases/download/llvmorg-$(PKG_VERSION) -PKG_HASH:=8b3cfd7bc695bd6cea0f37f53f0981f34f87496e79e2529874fd03a2f9dd3a8a +PKG_HASH:=9d53ad04dc60cb7b30e810faf64c5ab8157dadef46c8766f67f286238256ff92 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION).src -HOST_BUILD_PARALLEL:=1 - CMAKE_BINARY_SUBDIR := build CMAKE_SOURCE_SUBDIR := llvm diff --git a/tools/mkimage/patches/020-tools-mtk_image-split-gfh-header-verification-into-a.patch b/tools/mkimage/patches/020-tools-mtk_image-split-gfh-header-verification-into-a.patch new file mode 100644 index 000000000..c8747ae15 --- /dev/null +++ b/tools/mkimage/patches/020-tools-mtk_image-split-gfh-header-verification-into-a.patch @@ -0,0 +1,89 @@ +From b6bb61fd3818f4a3025fedbe4d15dbeeaef6ee82 Mon Sep 17 00:00:00 2001 +From: Weijie Gao +Date: Tue, 2 Aug 2022 17:21:34 +0800 +Subject: [PATCH 28/31] tools: mtk_image: split gfh header verification into a + new function + +The verification code of gfh header for NAND and non-NAND are identical. +It's better to define a individual function to reduce redundancy. + +Reviewed-by: Simon Glass +Signed-off-by: Weijie Gao +--- + tools/mtk_image.c | 51 +++++++++++++++++++---------------------------- + 1 file changed, 21 insertions(+), 30 deletions(-) + +--- a/tools/mtk_image.c ++++ b/tools/mtk_image.c +@@ -480,6 +480,25 @@ static int mtk_image_vrec_header(struct + return SHA256_SUM_LEN; + } + ++static int mtk_image_verify_gfh(struct gfh_header *gfh, uint32_t type, int print) ++{ ++ if (strcmp(gfh->file_info.name, GFH_FILE_INFO_NAME)) ++ return -1; ++ ++ if (le32_to_cpu(gfh->file_info.flash_type) != type) ++ return -1; ++ ++ if (print) ++ printf("Load Address: %08x\n", ++ le32_to_cpu(gfh->file_info.load_addr) + ++ le32_to_cpu(gfh->file_info.jump_offset)); ++ ++ if (print) ++ printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM"); ++ ++ return 0; ++} ++ + static int mtk_image_verify_gen_header(const uint8_t *ptr, int print) + { + union gen_boot_header *gbh = (union gen_boot_header *)ptr; +@@ -542,21 +561,7 @@ static int mtk_image_verify_gen_header(c + + gfh = (struct gfh_header *)(ptr + gfh_offset); + +- if (strcmp(gfh->file_info.name, GFH_FILE_INFO_NAME)) +- return -1; +- +- if (le32_to_cpu(gfh->file_info.flash_type) != GFH_FLASH_TYPE_GEN) +- return -1; +- +- if (print) +- printf("Load Address: %08x\n", +- le32_to_cpu(gfh->file_info.load_addr) + +- le32_to_cpu(gfh->file_info.jump_offset)); +- +- if (print) +- printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM"); +- +- return 0; ++ return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_GEN, print); + } + + static int mtk_image_verify_nand_header(const uint8_t *ptr, int print) +@@ -610,21 +615,7 @@ static int mtk_image_verify_nand_header( + + gfh = (struct gfh_header *)(ptr + 2 * le16_to_cpu(nh->pagesize)); + +- if (strcmp(gfh->file_info.name, GFH_FILE_INFO_NAME)) +- return -1; +- +- if (le32_to_cpu(gfh->file_info.flash_type) != GFH_FLASH_TYPE_NAND) +- return -1; +- +- if (print) +- printf("Load Address: %08x\n", +- le32_to_cpu(gfh->file_info.load_addr) + +- le32_to_cpu(gfh->file_info.jump_offset)); +- +- if (print) +- printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM"); +- +- return 0; ++ return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_NAND, print); + } + + static uint32_t crc32be_cal(const void *data, size_t length) diff --git a/tools/mkimage/patches/021-tools-mtk_image-split-the-code-of-generating-NAND-he.patch b/tools/mkimage/patches/021-tools-mtk_image-split-the-code-of-generating-NAND-he.patch new file mode 100644 index 000000000..9a5332f69 --- /dev/null +++ b/tools/mkimage/patches/021-tools-mtk_image-split-the-code-of-generating-NAND-he.patch @@ -0,0 +1,821 @@ +From 20ebf03eab571b25e9f62b2764ab84932111dcd6 Mon Sep 17 00:00:00 2001 +From: Weijie Gao +Date: Tue, 2 Aug 2022 17:23:57 +0800 +Subject: [PATCH 29/31] tools: mtk_image: split the code of generating NAND + header into a new file + +The predefined NAND headers take too much spaces in the mtk_image.c. +Moving them into a new file can significantly improve the readability of +both mtk_image.c and the new mtk_nand_headers.c. + +This is a preparation for adding more NAND headers. + +Reviewed-by: Simon Glass +Signed-off-by: Weijie Gao +--- + tools/Makefile | 1 + + tools/mtk_image.c | 305 ++++++--------------------------------- + tools/mtk_image.h | 25 ---- + tools/mtk_nand_headers.c | 286 ++++++++++++++++++++++++++++++++++++ + tools/mtk_nand_headers.h | 61 ++++++++ + 5 files changed, 389 insertions(+), 289 deletions(-) + create mode 100644 tools/mtk_nand_headers.c + create mode 100644 tools/mtk_nand_headers.h + +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -147,6 +147,7 @@ dumpimage-mkimage-objs := aisimage.o \ + gpimage.o \ + gpimage-common.o \ + mtk_image.o \ ++ mtk_nand_headers.o \ + $(ECDSA_OBJS-y) \ + $(RSA_OBJS-y) \ + $(AES_OBJS-y) +--- a/tools/mtk_image.c ++++ b/tools/mtk_image.c +@@ -12,216 +12,7 @@ + #include + #include "imagetool.h" + #include "mtk_image.h" +- +-/* NAND header for SPI-NAND with 2KB page + 64B spare */ +-static const union nand_boot_header snand_hdr_2k_64_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x08, 0x03, 0x00, 0x40, 0x00, +- 0x40, 0x00, 0x00, 0x08, 0x10, 0x00, 0x16, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x7B, 0xC4, 0x17, 0x9D, +- 0xCA, 0x42, 0x90, 0xD0, 0x98, 0xD0, 0xE0, 0xF7, +- 0xDB, 0xCD, 0x16, 0xF6, 0x03, 0x73, 0xD2, 0xB8, +- 0x93, 0xB2, 0x56, 0x5A, 0x84, 0x6E, 0x00, 0x00 +- } +-}; +- +-/* NAND header for SPI-NAND with 2KB page + 120B/128B spare */ +-static const union nand_boot_header snand_hdr_2k_128_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x70, 0x00, +- 0x40, 0x00, 0x00, 0x08, 0x10, 0x00, 0x16, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x90, 0x28, 0xED, 0x13, +- 0x7F, 0x12, 0x22, 0xCD, 0x3D, 0x06, 0xF1, 0xB3, +- 0x6F, 0x2E, 0xD9, 0xA0, 0x9D, 0x7A, 0xBD, 0xD7, +- 0xB3, 0x28, 0x3C, 0x13, 0xDB, 0x4E, 0x00, 0x00 +- } +-}; +- +-/* NAND header for SPI-NAND with 4KB page + 256B spare */ +-static const union nand_boot_header snand_hdr_4k_256_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x10, 0x05, 0x00, 0xE0, 0x00, +- 0x40, 0x00, 0x00, 0x08, 0x10, 0x00, 0x16, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x47, 0xED, 0x0E, 0xC3, +- 0x83, 0xBF, 0x41, 0xD2, 0x85, 0x21, 0x97, 0x57, +- 0xC4, 0x2E, 0x6B, 0x7A, 0x40, 0xE0, 0xCF, 0x8F, +- 0x37, 0xBD, 0x17, 0xB6, 0xC7, 0xFE, 0x00, 0x00 +- } +-}; +- +-/* NAND header for Parallel NAND 1Gb with 2KB page + 64B spare */ +-static const union nand_boot_header nand_hdr_1gb_2k_64_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x40, 0x00, +- 0x40, 0x00, 0x00, 0x04, 0x0B, 0x00, 0x11, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x12, 0x28, 0x1C, 0x12, +- 0x8F, 0xFD, 0xF8, 0x32, 0x6F, 0x6D, 0xCF, 0x6C, +- 0xDA, 0x21, 0x70, 0x8C, 0xDA, 0x0A, 0x22, 0x82, +- 0xAA, 0x59, 0xFA, 0x7C, 0x42, 0x2D, 0x00, 0x00 +- } +-}; +- +-/* NAND header for Parallel NAND 2Gb with 2KB page + 64B spare */ +-static const union nand_boot_header nand_hdr_2gb_2k_64_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x40, 0x00, +- 0x40, 0x00, 0x00, 0x08, 0x0B, 0x00, 0x11, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x20, 0x9C, 0x3D, 0x2D, +- 0x7B, 0x68, 0x63, 0x52, 0x2E, 0x04, 0x63, 0xF1, +- 0x35, 0x4E, 0x44, 0x3E, 0xF8, 0xAC, 0x9B, 0x95, +- 0xAB, 0xFE, 0xE4, 0xE1, 0xD5, 0xF9, 0x00, 0x00 +- } +-}; +- +-/* NAND header for Parallel NAND 4Gb with 2KB page + 64B spare */ +-static const union nand_boot_header nand_hdr_4gb_2k_64_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x40, 0x00, +- 0x40, 0x00, 0x00, 0x10, 0x0B, 0x00, 0x11, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0xE3, 0x0F, 0x86, 0x32, +- 0x68, 0x05, 0xD9, 0xC8, 0x13, 0xDF, 0xC5, 0x0B, +- 0x35, 0x3A, 0x68, 0xA5, 0x3C, 0x0C, 0x73, 0x87, +- 0x63, 0xB0, 0xBE, 0xCC, 0x84, 0x47, 0x00, 0x00 +- } +-}; +- +-/* NAND header for Parallel NAND 2Gb with 2KB page + 128B spare */ +-static const union nand_boot_header nand_hdr_2gb_2k_128_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x70, 0x00, +- 0x40, 0x00, 0x00, 0x08, 0x0B, 0x00, 0x11, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x01, 0xA5, 0xE9, 0x5A, +- 0xDF, 0x58, 0x62, 0x41, 0xD6, 0x26, 0x77, 0xBC, +- 0x76, 0x1F, 0x27, 0x4E, 0x4F, 0x6C, 0xC3, 0xF0, +- 0x36, 0xDE, 0xD9, 0xB3, 0xFF, 0x93, 0x00, 0x00 +- } +-}; +- +-/* NAND header for Parallel NAND 4Gb with 2KB page + 128B spare */ +-static const union nand_boot_header nand_hdr_4gb_2k_128_data = { +- .data = { +- 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, +- 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, +- 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, +- 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x70, 0x00, +- 0x40, 0x00, 0x00, 0x10, 0x0B, 0x00, 0x11, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +- 0x00, 0x00, 0x00, 0x00, 0xC2, 0x36, 0x52, 0x45, +- 0xCC, 0x35, 0xD8, 0xDB, 0xEB, 0xFD, 0xD1, 0x46, +- 0x76, 0x6B, 0x0B, 0xD5, 0x8B, 0xCC, 0x2B, 0xE2, +- 0xFE, 0x90, 0x83, 0x9E, 0xAE, 0x2D, 0x00, 0x00 +- } +-}; +- +-static const struct nand_header_type { +- const char *name; +- const union nand_boot_header *data; +-} nand_headers[] = { +- { +- .name = "2k+64", +- .data = &snand_hdr_2k_64_data +- }, { +- .name = "2k+120", +- .data = &snand_hdr_2k_128_data +- }, { +- .name = "2k+128", +- .data = &snand_hdr_2k_128_data +- }, { +- .name = "4k+256", +- .data = &snand_hdr_4k_256_data +- }, { +- .name = "1g:2k+64", +- .data = &nand_hdr_1gb_2k_64_data +- }, { +- .name = "2g:2k+64", +- .data = &nand_hdr_2gb_2k_64_data +- }, { +- .name = "4g:2k+64", +- .data = &nand_hdr_4gb_2k_64_data +- }, { +- .name = "2g:2k+128", +- .data = &nand_hdr_2gb_2k_128_data +- }, { +- .name = "4g:2k+128", +- .data = &nand_hdr_4gb_2k_128_data +- } +-}; ++#include "mtk_nand_headers.h" + + static const struct brom_img_type { + const char *name; +@@ -264,6 +55,7 @@ static uint32_t crc32tbl[256]; + + /* NAND header selected by user */ + static const union nand_boot_header *hdr_nand; ++static uint32_t hdr_nand_size; + + /* GFH header + 2 * 4KB pages of NAND */ + static char hdr_tmp[sizeof(struct gfh_header) + 0x2000]; +@@ -402,12 +194,7 @@ static int mtk_brom_parse_imagename(cons + } + + /* parse nand header type */ +- for (i = 0; i < ARRAY_SIZE(nand_headers); i++) { +- if (!strcmp(nand_headers[i].name, nandinfo)) { +- hdr_nand = nand_headers[i].data; +- break; +- } +- } ++ hdr_nand = mtk_nand_header_find(nandinfo); + + /* parse device header offset */ + if (hdr_offs && hdr_offs[0]) +@@ -432,6 +219,9 @@ static int mtk_brom_parse_imagename(cons + return -EINVAL; + } + ++ if (hdr_media == BRLYT_TYPE_NAND || hdr_media == BRLYT_TYPE_SNAND) ++ hdr_nand_size = mtk_nand_header_size(hdr_nand); ++ + return 0; + } + +@@ -468,7 +258,7 @@ static int mtk_image_vrec_header(struct + } + + if (hdr_media == BRLYT_TYPE_NAND || hdr_media == BRLYT_TYPE_SNAND) +- tparams->header_size = 2 * le16_to_cpu(hdr_nand->pagesize); ++ tparams->header_size = hdr_nand_size; + else + tparams->header_size = sizeof(struct gen_device_header); + +@@ -566,16 +356,17 @@ static int mtk_image_verify_gen_header(c + + static int mtk_image_verify_nand_header(const uint8_t *ptr, int print) + { +- union nand_boot_header *nh = (union nand_boot_header *)ptr; + struct brom_layout_header *bh; ++ struct nand_header_info info; + struct gfh_header *gfh; + const char *bootmedia; ++ int ret; + +- if (strncmp(nh->version, NAND_BOOT_VERSION, sizeof(nh->version)) || +- strcmp(nh->id, NAND_BOOT_ID)) +- return -1; ++ ret = mtk_nand_header_info(ptr, &info); ++ if (ret < 0) ++ return ret; + +- bh = (struct brom_layout_header *)(ptr + le16_to_cpu(nh->pagesize)); ++ bh = (struct brom_layout_header *)(ptr + info.page_size); + + if (strcmp(bh->name, BRLYT_NAME)) + return -1; +@@ -586,34 +377,23 @@ static int mtk_image_verify_nand_header( + if (le32_to_cpu(bh->type) == BRLYT_TYPE_NAND) + bootmedia = "Parallel NAND"; + else if (le32_to_cpu(bh->type) == BRLYT_TYPE_SNAND) +- bootmedia = "Serial NAND"; ++ bootmedia = "Serial NAND (SNFI/AP)"; + else + return -1; + } + + if (print) { +- printf("Boot Media: %s\n", bootmedia); +- +- if (le32_to_cpu(bh->type) == BRLYT_TYPE_NAND) { +- uint64_t capacity = +- (uint64_t)le16_to_cpu(nh->numblocks) * +- (uint64_t)le16_to_cpu(nh->pages_of_block) * +- (uint64_t)le16_to_cpu(nh->pagesize) * 8; +- printf("Capacity: %dGb\n", +- (uint32_t)(capacity >> 30)); +- } ++ printf("Boot Media: %s\n", bootmedia); + +- if (le16_to_cpu(nh->pagesize) >= 1024) +- printf("Page Size: %dKB\n", +- le16_to_cpu(nh->pagesize) >> 10); ++ if (info.page_size >= 1024) ++ printf("Page Size: %dKB\n", info.page_size >> 10); + else +- printf("Page Size: %dB\n", +- le16_to_cpu(nh->pagesize)); ++ printf("Page Size: %dB\n", info.page_size); + +- printf("Spare Size: %dB\n", le16_to_cpu(nh->oobsize)); ++ printf("Spare Size: %dB\n", info.spare_size); + } + +- gfh = (struct gfh_header *)(ptr + 2 * le16_to_cpu(nh->pagesize)); ++ gfh = (struct gfh_header *)(ptr + info.gfh_offset); + + return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_NAND, print); + } +@@ -713,7 +493,7 @@ static int mtk_image_verify_header(unsig + if (image_get_magic(hdr) == IH_MAGIC) + return mtk_image_verify_mt7621_header(ptr, 0); + +- if (!strcmp((char *)ptr, NAND_BOOT_NAME)) ++ if (is_mtk_nand_header(ptr)) + return mtk_image_verify_nand_header(ptr, 0); + else + return mtk_image_verify_gen_header(ptr, 0); +@@ -739,7 +519,7 @@ static void mtk_image_print_header(const + return; + } + +- if (!strcmp((char *)ptr, NAND_BOOT_NAME)) ++ if (is_mtk_nand_header(ptr)) + mtk_image_verify_nand_header(ptr, 1); + else + mtk_image_verify_gen_header(ptr, 1); +@@ -870,36 +650,33 @@ static void mtk_image_set_gen_header(voi + static void mtk_image_set_nand_header(void *ptr, off_t filesize, + uint32_t loadaddr) + { +- union nand_boot_header *nh = (union nand_boot_header *)ptr; + struct brom_layout_header *brlyt; + struct gfh_header *gfh; +- uint32_t payload_pages; +- int i; ++ uint32_t payload_pages, nand_page_size; + +- /* NAND device header, repeat 4 times */ +- for (i = 0; i < 4; i++) +- memcpy(nh + i, hdr_nand, sizeof(union nand_boot_header)); ++ /* NAND header */ ++ nand_page_size = mtk_nand_header_put(hdr_nand, ptr); + +- /* BRLYT header */ +- payload_pages = (filesize + le16_to_cpu(hdr_nand->pagesize) - 1) / +- le16_to_cpu(hdr_nand->pagesize); +- brlyt = (struct brom_layout_header *) +- (ptr + le16_to_cpu(hdr_nand->pagesize)); +- put_brom_layout_header(brlyt, hdr_media); +- brlyt->header_size = cpu_to_le32(2); +- brlyt->total_size = cpu_to_le32(payload_pages); +- brlyt->header_size_2 = brlyt->header_size; +- brlyt->total_size_2 = brlyt->total_size; +- brlyt->unused = cpu_to_le32(1); ++ if (nand_page_size) { ++ /* BRLYT header */ ++ payload_pages = (filesize + nand_page_size - 1) / ++ nand_page_size; ++ brlyt = (struct brom_layout_header *)(ptr + nand_page_size); ++ put_brom_layout_header(brlyt, hdr_media); ++ brlyt->header_size = cpu_to_le32(2); ++ brlyt->total_size = cpu_to_le32(payload_pages); ++ brlyt->header_size_2 = brlyt->header_size; ++ brlyt->total_size_2 = brlyt->total_size; ++ brlyt->unused = cpu_to_le32(1); ++ } + + /* GFH header */ +- gfh = (struct gfh_header *)(ptr + 2 * le16_to_cpu(hdr_nand->pagesize)); +- put_ghf_header(gfh, filesize, 2 * le16_to_cpu(hdr_nand->pagesize), +- loadaddr, GFH_FLASH_TYPE_NAND); ++ gfh = (struct gfh_header *)(ptr + hdr_nand_size); ++ put_ghf_header(gfh, filesize, hdr_nand_size, loadaddr, ++ GFH_FLASH_TYPE_NAND); + + /* Generate SHA256 hash */ +- put_hash((uint8_t *)gfh, +- filesize - 2 * le16_to_cpu(hdr_nand->pagesize) - SHA256_SUM_LEN); ++ put_hash((uint8_t *)gfh, filesize - hdr_nand_size - SHA256_SUM_LEN); + } + + static void mtk_image_set_mt7621_header(void *ptr, off_t filesize, +--- a/tools/mtk_image.h ++++ b/tools/mtk_image.h +@@ -26,31 +26,6 @@ union gen_boot_header { + #define SF_BOOT_NAME "SF_BOOT" + #define SDMMC_BOOT_NAME "SDMMC_BOOT" + +-/* Header for NAND */ +-union nand_boot_header { +- struct { +- char name[12]; +- char version[4]; +- char id[8]; +- uint16_t ioif; +- uint16_t pagesize; +- uint16_t addrcycles; +- uint16_t oobsize; +- uint16_t pages_of_block; +- uint16_t numblocks; +- uint16_t writesize_shift; +- uint16_t erasesize_shift; +- uint8_t dummy[60]; +- uint8_t ecc_parity[28]; +- }; +- +- uint8_t data[0x80]; +-}; +- +-#define NAND_BOOT_NAME "BOOTLOADER!" +-#define NAND_BOOT_VERSION "V006" +-#define NAND_BOOT_ID "NFIINFO" +- + /* BootROM layout header */ + struct brom_layout_header { + char name[8]; +--- /dev/null ++++ b/tools/mtk_nand_headers.c +@@ -0,0 +1,286 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * MediaTek BootROM NAND header definitions ++ * ++ * Copyright (C) 2022 MediaTek Inc. ++ * Author: Weijie Gao ++ */ ++ ++#include ++#include ++#include "imagetool.h" ++#include "mtk_image.h" ++#include "mtk_nand_headers.h" ++ ++/* NAND header for SPI-NAND with 2KB page + 64B spare */ ++static const union nand_boot_header snand_hdr_2k_64_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x08, 0x03, 0x00, 0x40, 0x00, ++ 0x40, 0x00, 0x00, 0x08, 0x10, 0x00, 0x16, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x7B, 0xC4, 0x17, 0x9D, ++ 0xCA, 0x42, 0x90, 0xD0, 0x98, 0xD0, 0xE0, 0xF7, ++ 0xDB, 0xCD, 0x16, 0xF6, 0x03, 0x73, 0xD2, 0xB8, ++ 0x93, 0xB2, 0x56, 0x5A, 0x84, 0x6E, 0x00, 0x00 ++ } ++}; ++ ++/* NAND header for SPI-NAND with 2KB page + 120B/128B spare */ ++static const union nand_boot_header snand_hdr_2k_128_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x70, 0x00, ++ 0x40, 0x00, 0x00, 0x08, 0x10, 0x00, 0x16, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x90, 0x28, 0xED, 0x13, ++ 0x7F, 0x12, 0x22, 0xCD, 0x3D, 0x06, 0xF1, 0xB3, ++ 0x6F, 0x2E, 0xD9, 0xA0, 0x9D, 0x7A, 0xBD, 0xD7, ++ 0xB3, 0x28, 0x3C, 0x13, 0xDB, 0x4E, 0x00, 0x00 ++ } ++}; ++ ++/* NAND header for SPI-NAND with 4KB page + 256B spare */ ++static const union nand_boot_header snand_hdr_4k_256_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x10, 0x05, 0x00, 0xE0, 0x00, ++ 0x40, 0x00, 0x00, 0x08, 0x10, 0x00, 0x16, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x47, 0xED, 0x0E, 0xC3, ++ 0x83, 0xBF, 0x41, 0xD2, 0x85, 0x21, 0x97, 0x57, ++ 0xC4, 0x2E, 0x6B, 0x7A, 0x40, 0xE0, 0xCF, 0x8F, ++ 0x37, 0xBD, 0x17, 0xB6, 0xC7, 0xFE, 0x00, 0x00 ++ } ++}; ++ ++/* NAND header for Parallel NAND 1Gb with 2KB page + 64B spare */ ++static const union nand_boot_header nand_hdr_1gb_2k_64_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x40, 0x00, ++ 0x40, 0x00, 0x00, 0x04, 0x0B, 0x00, 0x11, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x12, 0x28, 0x1C, 0x12, ++ 0x8F, 0xFD, 0xF8, 0x32, 0x6F, 0x6D, 0xCF, 0x6C, ++ 0xDA, 0x21, 0x70, 0x8C, 0xDA, 0x0A, 0x22, 0x82, ++ 0xAA, 0x59, 0xFA, 0x7C, 0x42, 0x2D, 0x00, 0x00 ++ } ++}; ++ ++/* NAND header for Parallel NAND 2Gb with 2KB page + 64B spare */ ++static const union nand_boot_header nand_hdr_2gb_2k_64_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x40, 0x00, ++ 0x40, 0x00, 0x00, 0x08, 0x0B, 0x00, 0x11, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x20, 0x9C, 0x3D, 0x2D, ++ 0x7B, 0x68, 0x63, 0x52, 0x2E, 0x04, 0x63, 0xF1, ++ 0x35, 0x4E, 0x44, 0x3E, 0xF8, 0xAC, 0x9B, 0x95, ++ 0xAB, 0xFE, 0xE4, 0xE1, 0xD5, 0xF9, 0x00, 0x00 ++ } ++}; ++ ++/* NAND header for Parallel NAND 4Gb with 2KB page + 64B spare */ ++static const union nand_boot_header nand_hdr_4gb_2k_64_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x40, 0x00, ++ 0x40, 0x00, 0x00, 0x10, 0x0B, 0x00, 0x11, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0xE3, 0x0F, 0x86, 0x32, ++ 0x68, 0x05, 0xD9, 0xC8, 0x13, 0xDF, 0xC5, 0x0B, ++ 0x35, 0x3A, 0x68, 0xA5, 0x3C, 0x0C, 0x73, 0x87, ++ 0x63, 0xB0, 0xBE, 0xCC, 0x84, 0x47, 0x00, 0x00 ++ } ++}; ++ ++/* NAND header for Parallel NAND 2Gb with 2KB page + 128B spare */ ++static const union nand_boot_header nand_hdr_2gb_2k_128_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x70, 0x00, ++ 0x40, 0x00, 0x00, 0x08, 0x0B, 0x00, 0x11, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x01, 0xA5, 0xE9, 0x5A, ++ 0xDF, 0x58, 0x62, 0x41, 0xD6, 0x26, 0x77, 0xBC, ++ 0x76, 0x1F, 0x27, 0x4E, 0x4F, 0x6C, 0xC3, 0xF0, ++ 0x36, 0xDE, 0xD9, 0xB3, 0xFF, 0x93, 0x00, 0x00 ++ } ++}; ++ ++/* NAND header for Parallel NAND 4Gb with 2KB page + 128B spare */ ++static const union nand_boot_header nand_hdr_4gb_2k_128_data = { ++ .data = { ++ 0x42, 0x4F, 0x4F, 0x54, 0x4C, 0x4F, 0x41, 0x44, ++ 0x45, 0x52, 0x21, 0x00, 0x56, 0x30, 0x30, 0x36, ++ 0x4E, 0x46, 0x49, 0x49, 0x4E, 0x46, 0x4F, 0x00, ++ 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x70, 0x00, ++ 0x40, 0x00, 0x00, 0x10, 0x0B, 0x00, 0x11, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0xC2, 0x36, 0x52, 0x45, ++ 0xCC, 0x35, 0xD8, 0xDB, 0xEB, 0xFD, 0xD1, 0x46, ++ 0x76, 0x6B, 0x0B, 0xD5, 0x8B, 0xCC, 0x2B, 0xE2, ++ 0xFE, 0x90, 0x83, 0x9E, 0xAE, 0x2D, 0x00, 0x00 ++ } ++}; ++ ++static const struct nand_header_type { ++ const char *name; ++ const union nand_boot_header *data; ++} nand_headers[] = { ++ { ++ .name = "2k+64", ++ .data = &snand_hdr_2k_64_data ++ }, { ++ .name = "2k+120", ++ .data = &snand_hdr_2k_128_data ++ }, { ++ .name = "2k+128", ++ .data = &snand_hdr_2k_128_data ++ }, { ++ .name = "4k+256", ++ .data = &snand_hdr_4k_256_data ++ }, { ++ .name = "1g:2k+64", ++ .data = &nand_hdr_1gb_2k_64_data ++ }, { ++ .name = "2g:2k+64", ++ .data = &nand_hdr_2gb_2k_64_data ++ }, { ++ .name = "4g:2k+64", ++ .data = &nand_hdr_4gb_2k_64_data ++ }, { ++ .name = "2g:2k+128", ++ .data = &nand_hdr_2gb_2k_128_data ++ }, { ++ .name = "4g:2k+128", ++ .data = &nand_hdr_4gb_2k_128_data ++ } ++}; ++ ++const union nand_boot_header *mtk_nand_header_find(const char *name) ++{ ++ uint32_t i; ++ ++ for (i = 0; i < ARRAY_SIZE(nand_headers); i++) { ++ if (!strcmp(nand_headers[i].name, name)) ++ return nand_headers[i].data; ++ } ++ ++ return NULL; ++} ++ ++uint32_t mtk_nand_header_size(const union nand_boot_header *hdr_nand) ++{ ++ return 2 * le16_to_cpu(hdr_nand->pagesize); ++} ++ ++static int mtk_nand_header_ap_info(const void *ptr, ++ struct nand_header_info *info) ++{ ++ union nand_boot_header *nh = (union nand_boot_header *)ptr; ++ ++ if (strncmp(nh->version, NAND_BOOT_VERSION, sizeof(nh->version)) || ++ strcmp(nh->id, NAND_BOOT_ID)) ++ return -1; ++ ++ info->page_size = le16_to_cpu(nh->pagesize); ++ info->spare_size = le16_to_cpu(nh->oobsize); ++ info->gfh_offset = 2 * info->page_size; ++ ++ return 0; ++} ++ ++int mtk_nand_header_info(const void *ptr, struct nand_header_info *info) ++{ ++ if (!strcmp((char *)ptr, NAND_BOOT_NAME)) ++ return mtk_nand_header_ap_info(ptr, info); ++ ++ return -1; ++} ++ ++bool is_mtk_nand_header(const void *ptr) ++{ ++ struct nand_header_info info; ++ ++ if (mtk_nand_header_info(ptr, &info) >= 0) ++ return true; ++ ++ return false; ++} ++ ++uint32_t mtk_nand_header_put(const union nand_boot_header *hdr_nand, void *ptr) ++{ ++ union nand_boot_header *nh = (union nand_boot_header *)ptr; ++ int i; ++ ++ /* NAND device header, repeat 4 times */ ++ for (i = 0; i < 4; i++) ++ memcpy(nh + i, hdr_nand, sizeof(union nand_boot_header)); ++ ++ return le16_to_cpu(hdr_nand->pagesize); ++} +--- /dev/null ++++ b/tools/mtk_nand_headers.h +@@ -0,0 +1,61 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * MediaTek BootROM NAND header definitions ++ * ++ * Copyright (C) 2022 MediaTek Inc. ++ * Author: Weijie Gao ++ */ ++ ++#ifndef _MTK_NAND_HEADERS_H ++#define _MTK_NAND_HEADERS_H ++ ++#include ++#include ++ ++struct nand_header_info { ++ uint32_t page_size; ++ uint32_t spare_size; ++ uint32_t gfh_offset; ++}; ++ ++/* AP BROM Header for NAND */ ++union nand_boot_header { ++ struct { ++ char name[12]; ++ char version[4]; ++ char id[8]; ++ uint16_t ioif; /* I/O interface */ ++ uint16_t pagesize; /* NAND page size */ ++ uint16_t addrcycles; /* Address cycles */ ++ uint16_t oobsize; /* NAND page spare size */ ++ uint16_t pages_of_block; /* Pages of one block */ ++ uint16_t numblocks; /* Total blocks of NAND chip */ ++ uint16_t writesize_shift; ++ uint16_t erasesize_shift; ++ uint8_t dummy[60]; ++ uint8_t ecc_parity[28]; /* ECC parity of this header */ ++ }; ++ ++ uint8_t data[0x80]; ++}; ++ ++#define NAND_BOOT_NAME "BOOTLOADER!" ++#define NAND_BOOT_VERSION "V006" ++#define NAND_BOOT_ID "NFIINFO" ++ ++/* Find nand header data by name */ ++const union nand_boot_header *mtk_nand_header_find(const char *name); ++ ++/* Device header size using this nand header */ ++uint32_t mtk_nand_header_size(const union nand_boot_header *hdr_nand); ++ ++/* Get nand info from nand header (page size, spare size, ...) */ ++int mtk_nand_header_info(const void *ptr, struct nand_header_info *info); ++ ++/* Whether given header data is valid */ ++bool is_mtk_nand_header(const void *ptr); ++ ++/* Generate Device header using give nand header */ ++uint32_t mtk_nand_header_put(const union nand_boot_header *hdr_nand, void *ptr); ++ ++#endif /* _MTK_NAND_HEADERS_H */ diff --git a/tools/mkimage/patches/022-tools-mtk_image-add-support-for-nand-headers-used-by.patch b/tools/mkimage/patches/022-tools-mtk_image-add-support-for-nand-headers-used-by.patch new file mode 100644 index 000000000..0ce095998 --- /dev/null +++ b/tools/mkimage/patches/022-tools-mtk_image-add-support-for-nand-headers-used-by.patch @@ -0,0 +1,702 @@ +From fbf296f9ed5daab70020686e9ba072efe663bbab Mon Sep 17 00:00:00 2001 +From: Weijie Gao +Date: Wed, 3 Aug 2022 11:14:36 +0800 +Subject: [PATCH 30/31] tools: mtk_image: add support for nand headers used by + newer chips + +This patch adds more nand headers in two new types: +1. HSM header, used for spi-nand thru SNFI interface +2. SPIM header, used for spi-nand thru spi-mem interface + +The original nand header is renamed to AP header. + +Signed-off-by: Weijie Gao +--- + tools/mtk_image.c | 23 ++- + tools/mtk_nand_headers.c | 422 +++++++++++++++++++++++++++++++++++++-- + tools/mtk_nand_headers.h | 110 +++++++++- + 3 files changed, 525 insertions(+), 30 deletions(-) + +--- a/tools/mtk_image.c ++++ b/tools/mtk_image.c +@@ -33,6 +33,9 @@ static const struct brom_img_type { + }, { + .name = "snand", + .type = BRLYT_TYPE_SNAND ++ }, { ++ .name = "spim-nand", ++ .type = BRLYT_TYPE_SNAND + } + }; + +@@ -54,7 +57,7 @@ static char lk_name[32] = "U-Boot"; + static uint32_t crc32tbl[256]; + + /* NAND header selected by user */ +-static const union nand_boot_header *hdr_nand; ++static const struct nand_header_type *hdr_nand; + static uint32_t hdr_nand_size; + + /* GFH header + 2 * 4KB pages of NAND */ +@@ -366,20 +369,26 @@ static int mtk_image_verify_nand_header( + if (ret < 0) + return ret; + +- bh = (struct brom_layout_header *)(ptr + info.page_size); ++ if (!ret) { ++ bh = (struct brom_layout_header *)(ptr + info.page_size); + +- if (strcmp(bh->name, BRLYT_NAME)) +- return -1; ++ if (strcmp(bh->name, BRLYT_NAME)) ++ return -1; ++ ++ if (le32_to_cpu(bh->magic) != BRLYT_MAGIC) ++ return -1; + +- if (le32_to_cpu(bh->magic) != BRLYT_MAGIC) { +- return -1; +- } else { + if (le32_to_cpu(bh->type) == BRLYT_TYPE_NAND) + bootmedia = "Parallel NAND"; + else if (le32_to_cpu(bh->type) == BRLYT_TYPE_SNAND) + bootmedia = "Serial NAND (SNFI/AP)"; + else + return -1; ++ } else { ++ if (info.snfi) ++ bootmedia = "Serial NAND (SNFI/HSM)"; ++ else ++ bootmedia = "Serial NAND (SPIM)"; + } + + if (print) { +--- a/tools/mtk_nand_headers.c ++++ b/tools/mtk_nand_headers.c +@@ -188,55 +188,346 @@ static const union nand_boot_header nand + } + }; + +-static const struct nand_header_type { ++/* HSM BROM NAND header for SPI NAND with 2KB page + 64B spare */ ++static const union hsm_nand_boot_header hsm_nand_hdr_2k_64_data = { ++ .data = { ++ 0x4E, 0x41, 0x4E, 0x44, 0x43, 0x46, 0x47, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x08, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, ++ 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, ++ 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, ++ 0xFF, 0x00, 0x00, 0x00, 0x21, 0xD2, 0xEE, 0xF6, ++ 0xAE, 0xDD, 0x5E, 0xC2, 0x82, 0x8E, 0x9A, 0x62, ++ 0x09, 0x8E, 0x80, 0xE2, 0x37, 0x0D, 0xC9, 0xFA, ++ 0xA9, 0xDD, 0xFC, 0x92, 0x34, 0x2A, 0xED, 0x51, ++ 0xA4, 0x1B, 0xF7, 0x63, 0xCC, 0x5A, 0xC7, 0xFB, ++ 0xED, 0x21, 0x02, 0x23, 0x51, 0x31 ++ } ++}; ++ ++/* HSM BROM NAND header for SPI NAND with 2KB page + 128B spare */ ++static const union hsm_nand_boot_header hsm_nand_hdr_2k_128_data = { ++ .data = { ++ 0x4E, 0x41, 0x4E, 0x44, 0x43, 0x46, 0x47, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x08, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, ++ 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, ++ 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, ++ 0xFF, 0x00, 0x00, 0x00, 0x71, 0x7f, 0x71, 0xAC, ++ 0x42, 0xD0, 0x5B, 0xD2, 0x12, 0x81, 0x15, 0x0A, ++ 0x0C, 0xD4, 0xF6, 0x32, 0x1E, 0x63, 0xE7, 0x81, ++ 0x8A, 0x7F, 0xDE, 0xF9, 0x4B, 0x91, 0xEC, 0xC2, ++ 0x70, 0x00, 0x7F, 0x57, 0xAF, 0xDC, 0xE4, 0x24, ++ 0x57, 0x09, 0xBC, 0xC5, 0x35, 0xDC ++ } ++}; ++ ++/* HSM BROM NAND header for SPI NAND with 4KB page + 256B spare */ ++static const union hsm_nand_boot_header hsm_nand_hdr_4k_256_data = { ++ .data = { ++ 0x4E, 0x41, 0x4E, 0x44, 0x43, 0x46, 0x47, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, ++ 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, ++ 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, ++ 0xFF, 0x00, 0x00, 0x00, 0x62, 0x04, 0xD6, 0x1F, ++ 0x2B, 0x57, 0x7A, 0x2D, 0xFE, 0xBB, 0x4A, 0x50, ++ 0xEC, 0xF8, 0x70, 0x1A, 0x44, 0x15, 0xF6, 0xA2, ++ 0x8E, 0xB0, 0xFD, 0xFA, 0xDC, 0xAA, 0x5A, 0x4E, ++ 0xCB, 0x8E, 0xC9, 0x72, 0x08, 0xDC, 0x20, 0xB9, ++ 0x98, 0xC8, 0x82, 0xD8, 0xBE, 0x44 ++ } ++}; ++ ++/* HSM2.0 BROM NAND header for SPI NAND with 2KB page + 64B spare */ ++static const union hsm20_nand_boot_header hsm20_nand_hdr_2k_64_data = { ++ .data = { ++ 0x4E, 0x41, 0x4E, 0x44, 0x43, 0x46, 0x47, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, ++ 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x08, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, ++ 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, ++ 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, ++ 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x5F, 0x4B, 0xB2, 0x5B, 0x8B, 0x1C, 0x35, 0xDA, ++ 0x83, 0xE6, 0x6C, 0xC3, 0xFB, 0x8C, 0x78, 0x23, ++ 0xD0, 0x89, 0x24, 0xD9, 0x6C, 0x35, 0x2C, 0x5D, ++ 0x8F, 0xBB, 0xFC, 0x10, 0xD0, 0xE2, 0x22, 0x7D, ++ 0xC8, 0x97, 0x9A, 0xEF, 0xC6, 0xB5, 0xA7, 0x4E, ++ 0x4E, 0x0E ++ } ++}; ++ ++/* HSM2.0 BROM NAND header for SPI NAND with 2KB page + 128B spare */ ++static const union hsm20_nand_boot_header hsm20_nand_hdr_2k_128_data = { ++ .data = { ++ 0x4E, 0x41, 0x4E, 0x44, 0x43, 0x46, 0x47, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, ++ 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x08, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, ++ 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, ++ 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, ++ 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0xF8, 0x7E, 0xC1, 0x5D, 0x61, 0x54, 0xEA, 0x9F, ++ 0x5E, 0x66, 0x39, 0x66, 0x21, 0xFF, 0x8C, 0x3B, ++ 0xBE, 0xA7, 0x5A, 0x9E, 0xD7, 0xBD, 0x9E, 0x89, ++ 0xEE, 0x7E, 0x10, 0x31, 0x9A, 0x1D, 0x82, 0x49, ++ 0xA3, 0x4E, 0xD8, 0x47, 0xD7, 0x19, 0xF4, 0x2D, ++ 0x8E, 0x53 ++ } ++}; ++ ++/* HSM2.0 BROM NAND header for SPI NAND with 4KB page + 256B spare */ ++static const union hsm20_nand_boot_header hsm20_nand_hdr_4k_256_data = { ++ .data = { ++ 0x4E, 0x41, 0x4E, 0x44, 0x43, 0x46, 0x47, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, ++ 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, ++ 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, ++ 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, ++ 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, ++ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x79, 0x01, 0x1F, 0x86, 0x62, 0x6A, 0x43, 0xAE, ++ 0xE6, 0xF8, 0xDD, 0x5B, 0x29, 0xB7, 0xA2, 0x7F, ++ 0x29, 0x72, 0x54, 0x37, 0xBE, 0x50, 0xD4, 0x24, ++ 0xAB, 0x60, 0xF4, 0x44, 0x97, 0x3B, 0x65, 0x21, ++ 0x73, 0x24, 0x1F, 0x93, 0x0E, 0x9E, 0x96, 0x88, ++ 0x78, 0x6C ++ } ++}; ++ ++/* SPIM-NAND header for SPI NAND with 2KB page + 64B spare */ ++static const union spim_nand_boot_header spim_nand_hdr_2k_64_data = { ++ .data = { ++ 0x53, 0x50, 0x49, 0x4e, 0x41, 0x4e, 0x44, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, ++ 0x00, 0x08, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, ++ 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x30, ++ 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ++ } ++}; ++ ++/* SPIM-NAND header for SPI NAND with 2KB page + 128B spare */ ++static const union spim_nand_boot_header spim_nand_hdr_2k_128_data = { ++ .data = { ++ 0x53, 0x50, 0x49, 0x4e, 0x41, 0x4e, 0x44, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, ++ 0x00, 0x08, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, ++ 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x30, ++ 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ++ } ++}; ++ ++/* SPIM-NAND header for SPI NAND with 4KB page + 256B spare */ ++static const union spim_nand_boot_header spim_nand_hdr_4k_256_data = { ++ .data = { ++ 0x53, 0x50, 0x49, 0x4e, 0x41, 0x4e, 0x44, 0x21, ++ 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, ++ 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, ++ 0x40, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x20, 0x30, ++ 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ++ } ++}; ++ ++struct nand_header_type { + const char *name; +- const union nand_boot_header *data; ++ enum nand_boot_header_type type; ++ union { ++ const union nand_boot_header *ap; ++ const union hsm_nand_boot_header *hsm; ++ const union hsm20_nand_boot_header *hsm20; ++ const union spim_nand_boot_header *spim; ++ }; + } nand_headers[] = { + { + .name = "2k+64", +- .data = &snand_hdr_2k_64_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &snand_hdr_2k_64_data, + }, { + .name = "2k+120", +- .data = &snand_hdr_2k_128_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &snand_hdr_2k_128_data, + }, { + .name = "2k+128", +- .data = &snand_hdr_2k_128_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &snand_hdr_2k_128_data, + }, { + .name = "4k+256", +- .data = &snand_hdr_4k_256_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &snand_hdr_4k_256_data, + }, { + .name = "1g:2k+64", +- .data = &nand_hdr_1gb_2k_64_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &nand_hdr_1gb_2k_64_data, + }, { + .name = "2g:2k+64", +- .data = &nand_hdr_2gb_2k_64_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &nand_hdr_2gb_2k_64_data, + }, { + .name = "4g:2k+64", +- .data = &nand_hdr_4gb_2k_64_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &nand_hdr_4gb_2k_64_data, + }, { + .name = "2g:2k+128", +- .data = &nand_hdr_2gb_2k_128_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &nand_hdr_2gb_2k_128_data, + }, { + .name = "4g:2k+128", +- .data = &nand_hdr_4gb_2k_128_data ++ .type = NAND_BOOT_AP_HEADER, ++ .ap = &nand_hdr_4gb_2k_128_data, ++ }, { ++ .name = "hsm:2k+64", ++ .type = NAND_BOOT_HSM_HEADER, ++ .hsm = &hsm_nand_hdr_2k_64_data, ++ }, { ++ .name = "hsm:2k+128", ++ .type = NAND_BOOT_HSM_HEADER, ++ .hsm = &hsm_nand_hdr_2k_128_data, ++ }, { ++ .name = "hsm:4k+256", ++ .type = NAND_BOOT_HSM_HEADER, ++ .hsm = &hsm_nand_hdr_4k_256_data, ++ }, { ++ .name = "hsm20:2k+64", ++ .type = NAND_BOOT_HSM20_HEADER, ++ .hsm20 = &hsm20_nand_hdr_2k_64_data, ++ }, { ++ .name = "hsm20:2k+128", ++ .type = NAND_BOOT_HSM20_HEADER, ++ .hsm20 = &hsm20_nand_hdr_2k_128_data, ++ }, { ++ .name = "hsm20:4k+256", ++ .type = NAND_BOOT_HSM20_HEADER, ++ .hsm20 = &hsm20_nand_hdr_4k_256_data, ++ }, { ++ .name = "spim:2k+64", ++ .type = NAND_BOOT_SPIM_HEADER, ++ .spim = &spim_nand_hdr_2k_64_data, ++ }, { ++ .name = "spim:2k+128", ++ .type = NAND_BOOT_SPIM_HEADER, ++ .spim = &spim_nand_hdr_2k_128_data, ++ }, { ++ .name = "spim:4k+256", ++ .type = NAND_BOOT_SPIM_HEADER, ++ .spim = &spim_nand_hdr_4k_256_data, + } + }; + +-const union nand_boot_header *mtk_nand_header_find(const char *name) ++const struct nand_header_type *mtk_nand_header_find(const char *name) + { + uint32_t i; + + for (i = 0; i < ARRAY_SIZE(nand_headers); i++) { + if (!strcmp(nand_headers[i].name, name)) +- return nand_headers[i].data; ++ return &nand_headers[i]; + } + + return NULL; + } + +-uint32_t mtk_nand_header_size(const union nand_boot_header *hdr_nand) ++uint32_t mtk_nand_header_size(const struct nand_header_type *hdr_nand) + { +- return 2 * le16_to_cpu(hdr_nand->pagesize); ++ switch (hdr_nand->type) { ++ case NAND_BOOT_HSM_HEADER: ++ return le32_to_cpu(hdr_nand->hsm->page_size); ++ ++ case NAND_BOOT_HSM20_HEADER: ++ return le32_to_cpu(hdr_nand->hsm20->page_size); ++ ++ case NAND_BOOT_SPIM_HEADER: ++ return le32_to_cpu(hdr_nand->spim->page_size); ++ ++ default: ++ return 2 * le16_to_cpu(hdr_nand->ap->pagesize); ++ } + } + + static int mtk_nand_header_ap_info(const void *ptr, +@@ -251,14 +542,45 @@ static int mtk_nand_header_ap_info(const + info->page_size = le16_to_cpu(nh->pagesize); + info->spare_size = le16_to_cpu(nh->oobsize); + info->gfh_offset = 2 * info->page_size; ++ info->snfi = true; + + return 0; + } + ++static int mtk_nand_header_hsm_info(const void *ptr, ++ struct nand_header_info *info) ++{ ++ union hsm_nand_boot_header *nh = (union hsm_nand_boot_header *)ptr; ++ ++ info->page_size = le16_to_cpu(nh->page_size); ++ info->spare_size = le16_to_cpu(nh->spare_size); ++ info->gfh_offset = info->page_size; ++ info->snfi = true; ++ ++ return 1; ++} ++ ++static int mtk_nand_header_spim_info(const void *ptr, ++ struct nand_header_info *info) ++{ ++ union spim_nand_boot_header *nh = (union spim_nand_boot_header *)ptr; ++ ++ info->page_size = le16_to_cpu(nh->page_size); ++ info->spare_size = le16_to_cpu(nh->spare_size); ++ info->gfh_offset = info->page_size; ++ info->snfi = false; ++ ++ return 1; ++} ++ + int mtk_nand_header_info(const void *ptr, struct nand_header_info *info) + { + if (!strcmp((char *)ptr, NAND_BOOT_NAME)) + return mtk_nand_header_ap_info(ptr, info); ++ else if (!strncmp((char *)ptr, HSM_NAND_BOOT_NAME, 8)) ++ return mtk_nand_header_hsm_info(ptr, info); ++ else if (!strncmp((char *)ptr, SPIM_NAND_BOOT_NAME, 8)) ++ return mtk_nand_header_spim_info(ptr, info); + + return -1; + } +@@ -273,14 +595,74 @@ bool is_mtk_nand_header(const void *ptr) + return false; + } + +-uint32_t mtk_nand_header_put(const union nand_boot_header *hdr_nand, void *ptr) ++static uint16_t crc16(const uint8_t *p, uint32_t len) ++{ ++ uint16_t crc = 0x4f4e; ++ uint32_t i; ++ ++ while (len--) { ++ crc ^= *p++ << 8; ++ for (i = 0; i < 8; i++) ++ crc = (crc << 1) ^ ((crc & 0x8000) ? 0x8005 : 0); ++ } ++ ++ return crc; ++} ++ ++static uint32_t mtk_nand_header_put_ap(const struct nand_header_type *hdr_nand, ++ void *ptr) + { +- union nand_boot_header *nh = (union nand_boot_header *)ptr; + int i; + + /* NAND device header, repeat 4 times */ +- for (i = 0; i < 4; i++) +- memcpy(nh + i, hdr_nand, sizeof(union nand_boot_header)); ++ for (i = 0; i < 4; i++) { ++ memcpy(ptr, hdr_nand->ap, sizeof(*hdr_nand->ap)); ++ ptr += sizeof(*hdr_nand->ap); ++ } ++ ++ return le16_to_cpu(hdr_nand->ap->pagesize); ++} + +- return le16_to_cpu(hdr_nand->pagesize); ++static uint32_t mtk_nand_header_put_hsm(const struct nand_header_type *hdr_nand, ++ void *ptr) ++{ ++ memcpy(ptr, hdr_nand->hsm, sizeof(*hdr_nand->hsm)); ++ return 0; ++} ++ ++static uint32_t mtk_nand_header_put_hsm20(const struct nand_header_type *hdr_nand, ++ void *ptr) ++{ ++ memcpy(ptr, hdr_nand->hsm20, sizeof(*hdr_nand->hsm20)); ++ return 0; ++} ++ ++static uint32_t mtk_nand_header_put_spim(const struct nand_header_type *hdr_nand, ++ void *ptr) ++{ ++ uint16_t crc; ++ ++ memcpy(ptr, hdr_nand->spim, sizeof(*hdr_nand->spim)); ++ ++ crc = crc16(ptr, 0x4e); ++ memcpy(ptr + 0x4e, &crc, sizeof(uint16_t)); ++ ++ return 0; ++} ++ ++uint32_t mtk_nand_header_put(const struct nand_header_type *hdr_nand, void *ptr) ++{ ++ switch (hdr_nand->type) { ++ case NAND_BOOT_HSM_HEADER: ++ return mtk_nand_header_put_hsm(hdr_nand, ptr); ++ ++ case NAND_BOOT_HSM20_HEADER: ++ return mtk_nand_header_put_hsm20(hdr_nand, ptr); ++ ++ case NAND_BOOT_SPIM_HEADER: ++ return mtk_nand_header_put_spim(hdr_nand, ptr); ++ ++ default: ++ return mtk_nand_header_put_ap(hdr_nand, ptr); ++ } + } +--- a/tools/mtk_nand_headers.h ++++ b/tools/mtk_nand_headers.h +@@ -16,6 +16,7 @@ struct nand_header_info { + uint32_t page_size; + uint32_t spare_size; + uint32_t gfh_offset; ++ bool snfi; + }; + + /* AP BROM Header for NAND */ +@@ -39,15 +40,117 @@ union nand_boot_header { + uint8_t data[0x80]; + }; + ++/* HSM BROM Header for NAND */ ++union hsm_nand_boot_header { ++ struct { ++ char id[8]; ++ uint32_t version; /* Header version */ ++ uint32_t config; /* Header config */ ++ uint32_t sector_size; /* ECC step size */ ++ uint32_t fdm_size; /* User OOB size of a step */ ++ uint32_t fdm_ecc_size; /* ECC parity size of a step */ ++ uint32_t lbs; ++ uint32_t page_size; /* NAND page size */ ++ uint32_t spare_size; /* NAND page spare size */ ++ uint32_t page_per_block; /* Pages of one block */ ++ uint32_t blocks; /* Total blocks of NAND chip */ ++ uint32_t plane_sel_position; /* Plane bit position */ ++ uint32_t pll; /* Value of pll reg */ ++ uint32_t acccon; /* Value of access timing reg */ ++ uint32_t strobe_sel; /* Value of DQS selection reg*/ ++ uint32_t acccon1; /* Value of access timing reg */ ++ uint32_t dqs_mux; /* Value of DQS mux reg */ ++ uint32_t dqs_ctrl; /* Value of DQS control reg */ ++ uint32_t delay_ctrl; /* Value of delay ctrl reg */ ++ uint32_t latch_lat; /* Value of latch latency reg */ ++ uint32_t sample_delay; /* Value of sample delay reg */ ++ uint32_t driving; /* Value of driving reg */ ++ uint32_t bl_start; /* Bootloader start addr */ ++ uint32_t bl_end; /* Bootloader end addr */ ++ uint8_t ecc_parity[42]; /* ECC parity of this header */ ++ }; ++ ++ uint8_t data[0x8E]; ++}; ++ ++/* HSM2.0 BROM Header for NAND */ ++union hsm20_nand_boot_header { ++ struct { ++ char id[8]; ++ uint32_t version; /* Header version */ ++ uint32_t config; /* Header config */ ++ uint32_t sector_size; /* ECC step size */ ++ uint32_t fdm_size; /* User OOB size of a step */ ++ uint32_t fdm_ecc_size; /* ECC parity size of a step */ ++ uint32_t lbs; ++ uint32_t page_size; /* NAND page size */ ++ uint32_t spare_size; /* NAND page spare size */ ++ uint32_t page_per_block; /* Pages of one block */ ++ uint32_t blocks; /* Total blocks of NAND chip */ ++ uint32_t plane_sel_position; /* Plane bit position */ ++ uint32_t pll; /* Value of pll reg */ ++ uint32_t acccon; /* Value of access timing reg */ ++ uint32_t strobe_sel; /* Value of DQS selection reg*/ ++ uint32_t acccon1; /* Value of access timing reg */ ++ uint32_t dqs_mux; /* Value of DQS mux reg */ ++ uint32_t dqs_ctrl; /* Value of DQS control reg */ ++ uint32_t delay_ctrl; /* Value of delay ctrl reg */ ++ uint32_t latch_lat; /* Value of latch latency reg */ ++ uint32_t sample_delay; /* Value of sample delay reg */ ++ uint32_t driving; /* Value of driving reg */ ++ uint32_t reserved; ++ uint32_t bl0_start; /* Bootloader start addr */ ++ uint32_t bl0_end; /* Bootloader end addr */ ++ uint32_t bl0_type; /* Bootloader type */ ++ uint8_t bl_reserve[84]; ++ uint8_t ecc_parity[42]; /* ECC parity of this header */ ++ }; ++ ++ uint8_t data[0xEA]; ++}; ++ ++/* SPIM BROM Header for SPI-NAND */ ++union spim_nand_boot_header { ++ struct { ++ char id[8]; ++ uint32_t version; /* Header version */ ++ uint32_t config; /* Header config */ ++ uint32_t page_size; /* NAND page size */ ++ uint32_t spare_size; /* NAND page spare size */ ++ uint16_t page_per_block; /* Pages of one block */ ++ uint16_t plane_sel_position; /* Plane bit position */ ++ uint16_t reserve_reg; ++ uint16_t reserve_val; ++ uint16_t ecc_error; /* ECC error reg addr */ ++ uint16_t ecc_mask; /* ECC error bit mask */ ++ uint32_t bl_start; /* Bootloader start addr */ ++ uint32_t bl_end; /* Bootloader end addr */ ++ uint8_t ecc_parity[32]; /* ECC parity of this header */ ++ uint32_t integrity_crc; /* CRC of this header */ ++ }; ++ ++ uint8_t data[0x50]; ++}; ++ ++enum nand_boot_header_type { ++ NAND_BOOT_AP_HEADER, ++ NAND_BOOT_HSM_HEADER, ++ NAND_BOOT_HSM20_HEADER, ++ NAND_BOOT_SPIM_HEADER ++}; ++ + #define NAND_BOOT_NAME "BOOTLOADER!" + #define NAND_BOOT_VERSION "V006" + #define NAND_BOOT_ID "NFIINFO" + ++#define HSM_NAND_BOOT_NAME "NANDCFG!" ++#define SPIM_NAND_BOOT_NAME "SPINAND!" ++ + /* Find nand header data by name */ +-const union nand_boot_header *mtk_nand_header_find(const char *name); ++const struct nand_header_type *mtk_nand_header_find(const char *name); + + /* Device header size using this nand header */ +-uint32_t mtk_nand_header_size(const union nand_boot_header *hdr_nand); ++uint32_t mtk_nand_header_size(const struct nand_header_type *hdr_nand); + + /* Get nand info from nand header (page size, spare size, ...) */ + int mtk_nand_header_info(const void *ptr, struct nand_header_info *info); +@@ -56,6 +159,7 @@ int mtk_nand_header_info(const void *ptr + bool is_mtk_nand_header(const void *ptr); + + /* Generate Device header using give nand header */ +-uint32_t mtk_nand_header_put(const union nand_boot_header *hdr_nand, void *ptr); ++uint32_t mtk_nand_header_put(const struct nand_header_type *hdr_nand, ++ void *ptr); + + #endif /* _MTK_NAND_HEADERS_H */ diff --git a/tools/mpc/Makefile b/tools/mpc/Makefile index b170043c1..5c196a27e 100644 --- a/tools/mpc/Makefile +++ b/tools/mpc/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mpc -PKG_VERSION:=1.2.1 +PKG_VERSION:=1.3.1 PKG_SOURCE_URL:=@GNU/mpc/ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_HASH:=17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459 +PKG_HASH:=ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8 HOST_BUILD_PARALLEL:=1 diff --git a/tools/mpfr/Makefile b/tools/mpfr/Makefile index 4562c128d..6a13be739 100644 --- a/tools/mpfr/Makefile +++ b/tools/mpfr/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mpfr -PKG_VERSION:=4.1.0 +PKG_VERSION:=4.1.1 PKG_CPE_ID:=cpe:/a:mpfr:gnu_mpfr PKG_SOURCE_URL:=@GNU/mpfr http://www.mpfr.org/mpfr-$(PKG_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_HASH:=0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f +PKG_HASH:=ffd195bd567dbaffc3b98b23fd00aad0537680c9896171e44fe3ff79e28ac33d HOST_BUILD_PARALLEL:=1 HOST_FIXUP:=autoreconf diff --git a/tools/mpfr/patches/001-only_src.patch b/tools/mpfr/patches/001-only_src.patch index dbc7d3234..68312276c 100644 --- a/tools/mpfr/patches/001-only_src.patch +++ b/tools/mpfr/patches/001-only_src.patch @@ -1,6 +1,6 @@ --- a/Makefile.am +++ b/Makefile.am -@@ -24,7 +24,7 @@ AUTOMAKE_OPTIONS = gnu +@@ -34,7 +34,7 @@ AUTOMAKE_OPTIONS = gnu # old Automake version. ACLOCAL_AMFLAGS = -I m4 @@ -11,7 +11,7 @@ pkgconfig_DATA = mpfr.pc --- a/Makefile.in +++ b/Makefile.in -@@ -384,7 +384,7 @@ AUTOMAKE_OPTIONS = gnu +@@ -397,7 +397,7 @@ AUTOMAKE_OPTIONS = gnu # libtoolize and in case some developer needs to switch back to an # old Automake version. ACLOCAL_AMFLAGS = -I m4 diff --git a/tools/mpfr/patches/002-Fix-mpfr_custom_get_kind-macro-bug.patch b/tools/mpfr/patches/002-Fix-mpfr_custom_get_kind-macro-bug.patch new file mode 100644 index 000000000..bb66a9067 --- /dev/null +++ b/tools/mpfr/patches/002-Fix-mpfr_custom_get_kind-macro-bug.patch @@ -0,0 +1,76 @@ +From 0ce17bae34a6c54de31b126f969d3ddd72c6bc37 Mon Sep 17 00:00:00 2001 +From: Vincent Lefevre +Date: Tue, 22 Nov 2022 16:33:00 +0100 +Subject: [PATCH] Fix mpfr_custom_get_kind() macro bug. + +* src/mpfr.h: in the mpfr_custom_get_kind() macro, changed mpfr_ptr to + mpfr_srcptr for _x to agree with the function prototype, in order to + avoid a compilation failure of user code in some cases. This bug was + introduced by commit 9f94e0311ed53d0c64d4fbca249d19cc4888027e, which + introduced the temporary variable _x to avoid an incorrect number of + evaluations of the x argument. +* tests/tstckintc.c: improved the tests to detect this bug. + +This should fix mpfr bug #1. + +Bug initially reported by FX Coudert: + https://github.com/CGAL/cgal/issues/7064 + +It affects Fedora Linux: + https://bugzilla.redhat.com/show_bug.cgi?id=2144197 +--- + src/mpfr.h | 2 +- + tests/tstckintc.c | 10 +++++++--- + 2 files changed, 8 insertions(+), 4 deletions(-) + +--- a/src/mpfr.h ++++ b/src/mpfr.h +@@ -1027,7 +1027,7 @@ __MPFR_DECLSPEC int mpfr_total_order_p ( + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 + #define mpfr_custom_get_kind(x) \ + __extension__ ({ \ +- mpfr_ptr _x = (x); \ ++ mpfr_srcptr _x = (x); \ + _x->_mpfr_exp > __MPFR_EXP_INF ? \ + (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (_x) \ + : _x->_mpfr_exp == __MPFR_EXP_INF ? \ +--- a/tests/tstckintc.c ++++ b/tests/tstckintc.c +@@ -295,14 +295,16 @@ static void + test_nan_inf_zero (void) + { + mpfr_ptr val; ++ mpfr_srcptr sval; /* for compilation error checking */ + int sign; + int kind; + + reset_stack (); + + val = new_mpfr (MPFR_PREC_MIN); ++ sval = val; + mpfr_set_nan (val); +- kind = (mpfr_custom_get_kind) (val); ++ kind = (mpfr_custom_get_kind) (sval); + if (kind != MPFR_NAN_KIND) + { + printf ("mpfr_custom_get_kind error: "); +@@ -380,7 +382,8 @@ static long * + dummy_set_si (long si) + { + mpfr_t x; +- long * r = dummy_new (); ++ mpfr_srcptr px; /* for compilation error checking */ ++ long *r = dummy_new (); + int i1, i2, i3, i4, i5; + + /* Check that the type "void *" can be used, like with the function. +@@ -405,7 +408,8 @@ dummy_set_si (long si) + MPFR_ASSERTN (i5 == 1); + + mpfr_set_si (x, si, MPFR_RNDN); +- r[0] = mpfr_custom_get_kind (x); ++ px = x; ++ r[0] = mpfr_custom_get_kind (px); + + /* Check that the type "void *" can be used in C, like with the function + (forbidden in C++). Also check side effects. */ diff --git a/tools/mtd-utils/Makefile b/tools/mtd-utils/Makefile index e4b951acf..14f11acaf 100644 --- a/tools/mtd-utils/Makefile +++ b/tools/mtd-utils/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtd-utils -PKG_VERSION:=2.1.4 +PKG_VERSION:=2.1.5 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/ -PKG_HASH:=2c6711d15d282c47cb3867b6857340597e26d332c238465134c602e5eef71b99 +PKG_HASH:=386e27fd121699b6b729bc2e8e04dda987b31cca6b16e12fb6cc6dcf26449f46 PKG_FIXUP:=autoreconf diff --git a/tools/mtd-utils/patches/130-lzma_jffs2.patch b/tools/mtd-utils/patches/130-lzma_jffs2.patch index 55930ddc8..db683063d 100644 --- a/tools/mtd-utils/patches/130-lzma_jffs2.patch +++ b/tools/mtd-utils/patches/130-lzma_jffs2.patch @@ -5020,7 +5020,7 @@ +} --- a/jffsX-utils/mkfs.jffs2.c +++ b/jffsX-utils/mkfs.jffs2.c -@@ -1667,11 +1667,11 @@ int main(int argc, char **argv) +@@ -1668,11 +1668,11 @@ int main(int argc, char **argv) } erase_block_size *= units; diff --git a/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch b/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch index f3ba4d327..a1703eb64 100644 --- a/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch +++ b/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch @@ -20,7 +20,7 @@ } entry = xcalloc(1, sizeof(struct filesystem_entry)); -@@ -1558,6 +1558,20 @@ static void parse_image(void){ +@@ -1559,6 +1559,20 @@ static void parse_image(void){ close(in_fd); } @@ -41,7 +41,7 @@ int main(int argc, char **argv) { int c, opt; -@@ -1576,6 +1590,7 @@ int main(int argc, char **argv) +@@ -1577,6 +1591,7 @@ int main(int argc, char **argv) warn_page_size = 1; /* warn user if page size not 4096 */ jffs2_compressors_init(); @@ -49,7 +49,7 @@ while ((opt = getopt_long(argc, argv, "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:", long_options, &c)) >= 0) -@@ -1626,7 +1641,7 @@ int main(int argc, char **argv) +@@ -1627,7 +1642,7 @@ int main(int argc, char **argv) break; case 'f': diff --git a/tools/mtools/Makefile b/tools/mtools/Makefile index 964ef9db3..c0c36a9d0 100644 --- a/tools/mtools/Makefile +++ b/tools/mtools/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtools -PKG_VERSION:=4.0.41 +PKG_VERSION:=4.0.42 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_HASH:=2542152264fb3eff7ed70662abf4f4eef8133bc37d0b7a686c240df2b5f80a13 +PKG_HASH:=64bfdfde4d82af6b22f3c1c72c3e231cbb618f4c2309cc46f54d16d5502ccf15 HOST_BUILD_PARALLEL:=1 diff --git a/tools/ninja/Makefile b/tools/ninja/Makefile index c5c83d9b1..4763e759d 100644 --- a/tools/ninja/Makefile +++ b/tools/ninja/Makefile @@ -1,12 +1,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ninja -PKG_VERSION:=1.11.0 +PKG_VERSION:=1.11.1 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/ninja-build/ninja/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=3c6ba2e66400fe3f1ae83deb4b235faf3137ec20bd5b08c29bfc368db143e4c6 +PKG_HASH:=31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/ninja/patches/100-make_jobserver_support.patch b/tools/ninja/patches/100-make_jobserver_support.patch index 7dac8ef81..b62717943 100644 --- a/tools/ninja/patches/100-make_jobserver_support.patch +++ b/tools/ninja/patches/100-make_jobserver_support.patch @@ -1,58 +1,99 @@ -From 17d13fd7881fd3ce9f9b9d44ce435d6caf4b8f28 Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Tue, 22 Mar 2016 13:48:07 +0200 -Subject: [PATCH 01/11] Add GNU make jobserver client support - -- add new TokenPool interface -- GNU make implementation for TokenPool parses and verifies the magic - information from the MAKEFLAGS environment variable -- RealCommandRunner tries to acquire TokenPool - * if no token pool is available then there is no change in behaviour -- When a token pool is available then RealCommandRunner behaviour - changes as follows - * CanRunMore() only returns true if TokenPool::Acquire() returns true - * StartCommand() calls TokenPool::Reserve() - * WaitForCommand() calls TokenPool::Release() - -Documentation for GNU make jobserver - - http://make.mad-scientist.net/papers/jobserver-implementation/ - -Fixes https://github.com/ninja-build/ninja/issues/1139 ---- - configure.py | 2 + - src/build.cc | 63 ++++++++---- - src/build.h | 3 + - src/tokenpool-gnu-make.cc | 211 ++++++++++++++++++++++++++++++++++++++ - src/tokenpool-none.cc | 27 +++++ - src/tokenpool.h | 26 +++++ - 6 files changed, 310 insertions(+), 22 deletions(-) - create mode 100644 src/tokenpool-gnu-make.cc - create mode 100644 src/tokenpool-none.cc - create mode 100644 src/tokenpool.h - -diff --git a/configure.py b/configure.py -index 43904349a8..db3492c93c 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -112,6 +112,7 @@ add_library(libninja OBJECT + src/state.cc + src/status.cc + src/string_piece_util.cc ++ src/tokenpool-gnu-make.cc + src/util.cc + src/version.cc + ) +@@ -123,9 +124,13 @@ if(WIN32) + src/msvc_helper_main-win32.cc + src/getopt.c + src/minidump-win32.cc ++ src/tokenpool-gnu-make-win32.cc + ) + else() +- target_sources(libninja PRIVATE src/subprocess-posix.cc) ++ target_sources(libninja PRIVATE ++ src/subprocess-posix.cc ++ src/tokenpool-gnu-make-posix.cc ++ ) + if(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR CMAKE_SYSTEM_NAME STREQUAL "AIX") + target_sources(libninja PRIVATE src/getopt.c) + endif() +@@ -204,6 +209,7 @@ if(BUILD_TESTING) + src/string_piece_util_test.cc + src/subprocess_test.cc + src/test.cc ++ src/tokenpool_test.cc + src/util_test.cc + ) + if(WIN32) +--- a/README.md ++++ b/README.md +@@ -1,3 +1,25 @@ ++Kitware maintains this branch of Ninja in order to provide features ++that have not yet been integrated upstream: ++ ++* make-style jobserver support ++ ++This branch may be *rebased* without notice for maintenance on top of ++the upstream `master` branch. It will be removed once upstream has ++integrated the features. ++ ++Parts of this branch are under upstream consideration: ++ ++* https://github.com/ninja-build/ninja/pull/1140 ++ ++As each PR is accepted additional parts of this branch will be submitted ++incrementally. ++ ++Binaries built from versions of this branch are available here: ++ ++* https://github.com/Kitware/ninja/releases ++ ++----------------------------------------------------------------------------- ++ + # Ninja + + Ninja is a small build system with a focus on speed. --- a/configure.py +++ b/configure.py -@@ -522,6 +522,7 @@ def has_re2c(): +@@ -517,11 +517,13 @@ for name in ['build', + 'state', + 'status', + 'string_piece_util', ++ 'tokenpool-gnu-make', + 'util', + 'version']: objs += cxx(name, variables=cxxvariables) if platform.is_windows(): for name in ['subprocess-win32', -+ 'tokenpool-none', ++ 'tokenpool-gnu-make-win32', 'includes_normalize-win32', 'msvc_helper-win32', 'msvc_helper_main-win32']: -@@ -531,6 +532,7 @@ def has_re2c(): +@@ -530,7 +532,9 @@ if platform.is_windows(): + objs += cxx('minidump-win32', variables=cxxvariables) objs += cc('getopt') else: - objs += cxx('subprocess-posix') -+ objs += cxx('tokenpool-gnu-make') +- objs += cxx('subprocess-posix') ++ for name in ['subprocess-posix', ++ 'tokenpool-gnu-make-posix']: ++ objs += cxx(name) if platform.is_aix(): objs += cc('getopt') if platform.is_msvc(): -diff --git a/src/build.cc b/src/build.cc -index 6f11ed7a3c..fa096eac33 100644 +@@ -588,6 +592,7 @@ for name in ['build_log_test', + 'string_piece_util_test', + 'subprocess_test', + 'test', ++ 'tokenpool_test', + 'util_test']: + objs += cxx(name, variables=cxxvariables) + if platform.is_windows(): --- a/src/build.cc +++ b/src/build.cc @@ -35,6 +35,7 @@ @@ -63,7 +104,36 @@ index 6f11ed7a3c..fa096eac33 100644 #include "util.h" using namespace std; -@@ -149,7 +150,7 @@ void Plan::EdgeWanted(const Edge* edge) { +@@ -47,8 +48,9 @@ struct DryRunCommandRunner : public Comm + + // Overridden from CommandRunner: + virtual bool CanRunMore() const; ++ virtual bool AcquireToken(); + virtual bool StartCommand(Edge* edge); +- virtual bool WaitForCommand(Result* result); ++ virtual bool WaitForCommand(Result* result, bool more_ready); + + private: + queue finished_; +@@ -58,12 +60,16 @@ bool DryRunCommandRunner::CanRunMore() c + return true; + } + ++bool DryRunCommandRunner::AcquireToken() { ++ return true; ++} ++ + bool DryRunCommandRunner::StartCommand(Edge* edge) { + finished_.push(edge); + return true; + } + +-bool DryRunCommandRunner::WaitForCommand(Result* result) { ++bool DryRunCommandRunner::WaitForCommand(Result* result, bool more_ready) { + if (finished_.empty()) + return false; + +@@ -149,7 +155,7 @@ void Plan::EdgeWanted(const Edge* edge) } Edge* Plan::FindWork() { @@ -72,7 +142,7 @@ index 6f11ed7a3c..fa096eac33 100644 return NULL; EdgeSet::iterator e = ready_.begin(); Edge* edge = *e; -@@ -448,8 +449,8 @@ void Plan::Dump() const { +@@ -448,19 +454,39 @@ void Plan::Dump() const { } struct RealCommandRunner : public CommandRunner { @@ -81,18 +151,31 @@ index 6f11ed7a3c..fa096eac33 100644 + explicit RealCommandRunner(const BuildConfig& config); + virtual ~RealCommandRunner(); virtual bool CanRunMore() const; ++ virtual bool AcquireToken(); virtual bool StartCommand(Edge* edge); - virtual bool WaitForCommand(Result* result); -@@ -458,9 +459,18 @@ struct RealCommandRunner : public CommandRunner { +- virtual bool WaitForCommand(Result* result); ++ virtual bool WaitForCommand(Result* result, bool more_ready); + virtual vector GetActiveEdges(); + virtual void Abort(); const BuildConfig& config_; ++ // copy of config_.max_load_average; can be modified by TokenPool setup ++ double max_load_average_; SubprocessSet subprocs_; -+ TokenPool *tokens_; ++ TokenPool* tokens_; map subproc_to_edge_; }; +RealCommandRunner::RealCommandRunner(const BuildConfig& config) : config_(config) { -+ tokens_ = TokenPool::Get(); ++ max_load_average_ = config.max_load_average; ++ if ((tokens_ = TokenPool::Get()) != NULL) { ++ if (!tokens_->Setup(config_.parallelism_from_cmdline, ++ config_.verbosity == BuildConfig::VERBOSE, ++ max_load_average_)) { ++ delete tokens_; ++ tokens_ = NULL; ++ } ++ } +} + +RealCommandRunner::~RealCommandRunner() { @@ -102,7 +185,7 @@ index 6f11ed7a3c..fa096eac33 100644 vector RealCommandRunner::GetActiveEdges() { vector edges; for (map::iterator e = subproc_to_edge_.begin(); -@@ -471,14 +481,18 @@ vector RealCommandRunner::GetActiveEdges() { +@@ -471,14 +497,23 @@ vector RealCommandRunner::GetActi void RealCommandRunner::Abort() { subprocs_.Clear(); @@ -111,19 +194,27 @@ index 6f11ed7a3c..fa096eac33 100644 } bool RealCommandRunner::CanRunMore() const { - size_t subproc_number = - subprocs_.running_.size() + subprocs_.finished_.size(); - return (int)subproc_number < config_.parallelism +- size_t subproc_number = +- subprocs_.running_.size() + subprocs_.finished_.size(); +- return (int)subproc_number < config_.parallelism - && ((subprocs_.running_.empty() || config_.max_load_average <= 0.0f) - || GetLoadAverage() < config_.max_load_average); ++ bool parallelism_limit_not_reached = ++ tokens_ || // ignore config_.parallelism ++ ((int) (subprocs_.running_.size() + ++ subprocs_.finished_.size()) < config_.parallelism); ++ return parallelism_limit_not_reached + && (subprocs_.running_.empty() || -+ ((config_.max_load_average <= 0.0f || -+ GetLoadAverage() < config_.max_load_average) -+ && (!tokens_ || tokens_->Acquire()))); ++ (max_load_average_ <= 0.0f || ++ GetLoadAverage() < max_load_average_)); ++} ++ ++bool RealCommandRunner::AcquireToken() { ++ return (!tokens_ || tokens_->Acquire()); } bool RealCommandRunner::StartCommand(Edge* edge) { -@@ -486,6 +500,8 @@ bool RealCommandRunner::StartCommand(Edge* edge) { +@@ -486,19 +521,33 @@ bool RealCommandRunner::StartCommand(Edg Subprocess* subproc = subprocs_.Add(command, edge->use_console()); if (!subproc) return false; @@ -132,37 +223,63 @@ index 6f11ed7a3c..fa096eac33 100644 subproc_to_edge_.insert(make_pair(subproc, edge)); return true; -@@ -499,6 +515,9 @@ bool RealCommandRunner::WaitForCommand(Result* result) { + } + +-bool RealCommandRunner::WaitForCommand(Result* result) { ++bool RealCommandRunner::WaitForCommand(Result* result, bool more_ready) { + Subprocess* subproc; +- while ((subproc = subprocs_.NextFinished()) == NULL) { +- bool interrupted = subprocs_.DoWork(); ++ subprocs_.ResetTokenAvailable(); ++ while (((subproc = subprocs_.NextFinished()) == NULL) && ++ !subprocs_.IsTokenAvailable()) { ++ bool interrupted = subprocs_.DoWork(more_ready ? tokens_ : NULL); + if (interrupted) return false; } ++ // token became available ++ if (subproc == NULL) { ++ result->status = ExitTokenAvailable; ++ return true; ++ } ++ ++ // command completed + if (tokens_) + tokens_->Release(); + result->status = subproc->Finish(); result->output = subproc->GetOutput(); -@@ -621,31 +640,31 @@ bool Builder::Build(string* err) { +@@ -620,38 +669,42 @@ bool Builder::Build(string* err) { + // command runner. // Second, we attempt to wait for / reap the next finished command. while (plan_.more_to_do()) { - // See if we can start any more commands. +- // See if we can start any more commands. - if (failures_allowed && command_runner_->CanRunMore()) { - if (Edge* edge = plan_.FindWork()) { - if (edge->GetBindingBool("generator")) { -+ if (failures_allowed && plan_.more_ready() && -+ command_runner_->CanRunMore()) { +- scan_.build_log()->Close(); +- } ++ // See if we can start any more commands... ++ bool can_run_more = ++ failures_allowed && ++ plan_.more_ready() && ++ command_runner_->CanRunMore(); ++ ++ // ... but we also need a token to do that. ++ if (can_run_more && command_runner_->AcquireToken()) { + Edge* edge = plan_.FindWork(); + if (edge->GetBindingBool("generator")) { - scan_.build_log()->Close(); - } - -- if (!StartEdge(edge, err)) { ++ scan_.build_log()->Close(); ++ } + if (!StartEdge(edge, err)) { + Cleanup(); + status_->BuildFinished(); + return false; + } -+ + +- if (!StartEdge(edge, err)) { + if (edge->is_phony()) { + if (!plan_.EdgeFinished(edge, Plan::kEdgeSucceeded, err)) { Cleanup(); @@ -191,8 +308,24 @@ index 6f11ed7a3c..fa096eac33 100644 } // See if we can reap any finished commands. -diff --git a/src/build.h b/src/build.h -index d697dfb89e..7dcd111e61 100644 + if (pending_commands) { + CommandRunner::Result result; +- if (!command_runner_->WaitForCommand(&result) || ++ if (!command_runner_->WaitForCommand(&result, can_run_more) || + result.status == ExitInterrupted) { + Cleanup(); + status_->BuildFinished(); +@@ -659,6 +712,10 @@ bool Builder::Build(string* err) { + return false; + } + ++ // We might be able to start another command; start the main loop over. ++ if (result.status == ExitTokenAvailable) ++ continue; ++ + --pending_commands; + if (!FinishCommand(&result, err)) { + Cleanup(); --- a/src/build.h +++ b/src/build.h @@ -52,6 +52,9 @@ struct Plan { @@ -205,446 +338,7 @@ index d697dfb89e..7dcd111e61 100644 /// Dumps the current state of the plan. void Dump() const; -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -new file mode 100644 -index 0000000000..a8f9b7139d ---- /dev/null -+++ b/src/tokenpool-gnu-make.cc -@@ -0,0 +1,211 @@ -+// Copyright 2016 Google Inc. All Rights Reserved. -+// -+// Licensed under the Apache License, Version 2.0 (the "License"); -+// you may not use this file except in compliance with the License. -+// You may obtain a copy of the License at -+// -+// http://www.apache.org/licenses/LICENSE-2.0 -+// -+// Unless required by applicable law or agreed to in writing, software -+// distributed under the License is distributed on an "AS IS" BASIS, -+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+// See the License for the specific language governing permissions and -+// limitations under the License. -+ -+#include "tokenpool.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+// TokenPool implementation for GNU make jobserver -+// (http://make.mad-scientist.net/papers/jobserver-implementation/) -+struct GNUmakeTokenPool : public TokenPool { -+ GNUmakeTokenPool(); -+ virtual ~GNUmakeTokenPool(); -+ -+ virtual bool Acquire(); -+ virtual void Reserve(); -+ virtual void Release(); -+ virtual void Clear(); -+ -+ bool Setup(); -+ -+ private: -+ int available_; -+ int used_; -+ -+#ifdef _WIN32 -+ // @TODO -+#else -+ int rfd_; -+ int wfd_; -+ -+ struct sigaction old_act_; -+ bool restore_; -+ -+ static int dup_rfd_; -+ static void CloseDupRfd(int signum); -+ -+ bool CheckFd(int fd); -+ bool SetAlarmHandler(); -+#endif -+ -+ void Return(); -+}; -+ -+// every instance owns an implicit token -> available_ == 1 -+GNUmakeTokenPool::GNUmakeTokenPool() : available_(1), used_(0), -+ rfd_(-1), wfd_(-1), restore_(false) { -+} -+ -+GNUmakeTokenPool::~GNUmakeTokenPool() { -+ Clear(); -+ if (restore_) -+ sigaction(SIGALRM, &old_act_, NULL); -+} -+ -+bool GNUmakeTokenPool::CheckFd(int fd) { -+ if (fd < 0) -+ return false; -+ int ret = fcntl(fd, F_GETFD); -+ if (ret < 0) -+ return false; -+ return true; -+} -+ -+int GNUmakeTokenPool::dup_rfd_ = -1; -+ -+void GNUmakeTokenPool::CloseDupRfd(int signum) { -+ close(dup_rfd_); -+ dup_rfd_ = -1; -+} -+ -+bool GNUmakeTokenPool::SetAlarmHandler() { -+ struct sigaction act; -+ memset(&act, 0, sizeof(act)); -+ act.sa_handler = CloseDupRfd; -+ if (sigaction(SIGALRM, &act, &old_act_) < 0) { -+ perror("sigaction:"); -+ return(false); -+ } else { -+ restore_ = true; -+ return(true); -+ } -+} -+ -+bool GNUmakeTokenPool::Setup() { -+ const char *value = getenv("MAKEFLAGS"); -+ if (value) { -+ // GNU make <= 4.1 -+ const char *jobserver = strstr(value, "--jobserver-fds="); -+ // GNU make => 4.2 -+ if (!jobserver) -+ jobserver = strstr(value, "--jobserver-auth="); -+ if (jobserver) { -+ int rfd = -1; -+ int wfd = -1; -+ if ((sscanf(jobserver, "%*[^=]=%d,%d", &rfd, &wfd) == 2) && -+ CheckFd(rfd) && -+ CheckFd(wfd) && -+ SetAlarmHandler()) { -+ printf("ninja: using GNU make jobserver.\n"); -+ rfd_ = rfd; -+ wfd_ = wfd; -+ return true; -+ } -+ } -+ } -+ -+ return false; -+} -+ -+bool GNUmakeTokenPool::Acquire() { -+ if (available_ > 0) -+ return true; -+ -+#ifdef USE_PPOLL -+ pollfd pollfds[] = {{rfd_, POLLIN, 0}}; -+ int ret = poll(pollfds, 1, 0); -+#else -+ fd_set set; -+ struct timeval timeout = { 0, 0 }; -+ FD_ZERO(&set); -+ FD_SET(rfd_, &set); -+ int ret = select(rfd_ + 1, &set, NULL, NULL, &timeout); -+#endif -+ if (ret > 0) { -+ dup_rfd_ = dup(rfd_); -+ -+ if (dup_rfd_ != -1) { -+ struct sigaction act, old_act; -+ int ret = 0; -+ -+ memset(&act, 0, sizeof(act)); -+ act.sa_handler = CloseDupRfd; -+ if (sigaction(SIGCHLD, &act, &old_act) == 0) { -+ char buf; -+ -+ // block until token read, child exits or timeout -+ alarm(1); -+ ret = read(dup_rfd_, &buf, 1); -+ alarm(0); -+ -+ sigaction(SIGCHLD, &old_act, NULL); -+ } -+ -+ CloseDupRfd(0); -+ -+ if (ret > 0) { -+ available_++; -+ return true; -+ } -+ } -+ } -+ return false; -+} -+ -+void GNUmakeTokenPool::Reserve() { -+ available_--; -+ used_++; -+} -+ -+void GNUmakeTokenPool::Return() { -+ const char buf = '+'; -+ while (1) { -+ int ret = write(wfd_, &buf, 1); -+ if (ret > 0) -+ available_--; -+ if ((ret != -1) || (errno != EINTR)) -+ return; -+ // write got interrupted - retry -+ } -+} -+ -+void GNUmakeTokenPool::Release() { -+ available_++; -+ used_--; -+ if (available_ > 1) -+ Return(); -+} -+ -+void GNUmakeTokenPool::Clear() { -+ while (used_ > 0) -+ Release(); -+ while (available_ > 1) -+ Return(); -+} -+ -+struct TokenPool *TokenPool::Get(void) { -+ GNUmakeTokenPool *tokenpool = new GNUmakeTokenPool; -+ if (tokenpool->Setup()) -+ return tokenpool; -+ else -+ delete tokenpool; -+ return NULL; -+} -diff --git a/src/tokenpool-none.cc b/src/tokenpool-none.cc -new file mode 100644 -index 0000000000..602b3316f5 ---- /dev/null -+++ b/src/tokenpool-none.cc -@@ -0,0 +1,27 @@ -+// Copyright 2016 Google Inc. All Rights Reserved. -+// -+// Licensed under the Apache License, Version 2.0 (the "License"); -+// you may not use this file except in compliance with the License. -+// You may obtain a copy of the License at -+// -+// http://www.apache.org/licenses/LICENSE-2.0 -+// -+// Unless required by applicable law or agreed to in writing, software -+// distributed under the License is distributed on an "AS IS" BASIS, -+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+// See the License for the specific language governing permissions and -+// limitations under the License. -+ -+#include "tokenpool.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+// No-op TokenPool implementation -+struct TokenPool *TokenPool::Get(void) { -+ return NULL; -+} -diff --git a/src/tokenpool.h b/src/tokenpool.h -new file mode 100644 -index 0000000000..f560b1083b ---- /dev/null -+++ b/src/tokenpool.h -@@ -0,0 +1,26 @@ -+// Copyright 2016 Google Inc. All Rights Reserved. -+// -+// Licensed under the Apache License, Version 2.0 (the "License"); -+// you may not use this file except in compliance with the License. -+// You may obtain a copy of the License at -+// -+// http://www.apache.org/licenses/LICENSE-2.0 -+// -+// Unless required by applicable law or agreed to in writing, software -+// distributed under the License is distributed on an "AS IS" BASIS, -+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+// See the License for the specific language governing permissions and -+// limitations under the License. -+ -+// interface to token pool -+struct TokenPool { -+ virtual ~TokenPool() {} -+ -+ virtual bool Acquire() = 0; -+ virtual void Reserve() = 0; -+ virtual void Release() = 0; -+ virtual void Clear() = 0; -+ -+ // returns NULL if token pool is not available -+ static struct TokenPool *Get(void); -+}; - -From ccaccc610cd456f6068758f82e72006364c7380b Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Fri, 27 May 2016 16:47:10 +0300 -Subject: [PATCH 02/11] Add TokenPool monitoring to SubprocessSet::DoWork() - -Improve on the original jobserver client implementation. This makes -ninja a more aggressive GNU make jobserver client. - -- add monitor interface to TokenPool -- TokenPool is passed down when main loop indicates that more work is - ready and would be allowed to start if a token becomes available -- posix: update DoWork() to monitor TokenPool read file descriptor -- WaitForCommand() exits when DoWork() sets token flag -- Main loop starts over when WaitForCommand() sets token exit status ---- - src/build.cc | 53 +++++++++++++++++++++++++++++---------- - src/build.h | 3 ++- - src/build_test.cc | 9 +++++-- - src/exit_status.h | 3 ++- - src/subprocess-posix.cc | 33 ++++++++++++++++++++++-- - src/subprocess-win32.cc | 2 +- - src/subprocess.h | 8 +++++- - src/subprocess_test.cc | 47 +++++++++++++++++++++++----------- - src/tokenpool-gnu-make.cc | 5 ++++ - src/tokenpool.h | 6 +++++ - 10 files changed, 134 insertions(+), 35 deletions(-) - -diff --git a/src/build.cc b/src/build.cc -index fa096eac33..a25c349050 100644 ---- a/src/build.cc -+++ b/src/build.cc -@@ -48,8 +48,9 @@ struct DryRunCommandRunner : public CommandRunner { - - // Overridden from CommandRunner: - virtual bool CanRunMore() const; -+ virtual bool AcquireToken(); - virtual bool StartCommand(Edge* edge); -- virtual bool WaitForCommand(Result* result); -+ virtual bool WaitForCommand(Result* result, bool more_ready); - - private: - queue finished_; -@@ -59,12 +60,16 @@ bool DryRunCommandRunner::CanRunMore() const { - return true; - } - -+bool DryRunCommandRunner::AcquireToken() { -+ return true; -+} -+ - bool DryRunCommandRunner::StartCommand(Edge* edge) { - finished_.push(edge); - return true; - } - --bool DryRunCommandRunner::WaitForCommand(Result* result) { -+bool DryRunCommandRunner::WaitForCommand(Result* result, bool more_ready) { - if (finished_.empty()) - return false; - -@@ -452,8 +457,9 @@ struct RealCommandRunner : public CommandRunner { - explicit RealCommandRunner(const BuildConfig& config); - virtual ~RealCommandRunner(); - virtual bool CanRunMore() const; -+ virtual bool AcquireToken(); - virtual bool StartCommand(Edge* edge); -- virtual bool WaitForCommand(Result* result); -+ virtual bool WaitForCommand(Result* result, bool more_ready); - virtual vector GetActiveEdges(); - virtual void Abort(); - -@@ -490,9 +496,12 @@ bool RealCommandRunner::CanRunMore() const { - subprocs_.running_.size() + subprocs_.finished_.size(); - return (int)subproc_number < config_.parallelism - && (subprocs_.running_.empty() || -- ((config_.max_load_average <= 0.0f || -- GetLoadAverage() < config_.max_load_average) -- && (!tokens_ || tokens_->Acquire()))); -+ (config_.max_load_average <= 0.0f || -+ GetLoadAverage() < config_.max_load_average)); -+} -+ -+bool RealCommandRunner::AcquireToken() { -+ return (!tokens_ || tokens_->Acquire()); - } - - bool RealCommandRunner::StartCommand(Edge* edge) { -@@ -507,14 +516,23 @@ bool RealCommandRunner::StartCommand(Edge* edge) { - return true; - } - --bool RealCommandRunner::WaitForCommand(Result* result) { -+bool RealCommandRunner::WaitForCommand(Result* result, bool more_ready) { - Subprocess* subproc; -- while ((subproc = subprocs_.NextFinished()) == NULL) { -- bool interrupted = subprocs_.DoWork(); -+ subprocs_.ResetTokenAvailable(); -+ while (((subproc = subprocs_.NextFinished()) == NULL) && -+ !subprocs_.IsTokenAvailable()) { -+ bool interrupted = subprocs_.DoWork(more_ready ? tokens_ : NULL); - if (interrupted) - return false; - } - -+ // token became available -+ if (subproc == NULL) { -+ result->status = ExitTokenAvailable; -+ return true; -+ } -+ -+ // command completed - if (tokens_) - tokens_->Release(); - -@@ -639,9 +657,14 @@ bool Builder::Build(string* err) { - // command runner. - // Second, we attempt to wait for / reap the next finished command. - while (plan_.more_to_do()) { -- // See if we can start any more commands. -- if (failures_allowed && plan_.more_ready() && -- command_runner_->CanRunMore()) { -+ // See if we can start any more commands... -+ bool can_run_more = -+ failures_allowed && -+ plan_.more_ready() && -+ command_runner_->CanRunMore(); -+ -+ // ... but we also need a token to do that. -+ if (can_run_more && command_runner_->AcquireToken()) { - Edge* edge = plan_.FindWork(); - if (edge->GetBindingBool("generator")) { - scan_.build_log()->Close(); -@@ -670,7 +693,7 @@ bool Builder::Build(string* err) { - // See if we can reap any finished commands. - if (pending_commands) { - CommandRunner::Result result; -- if (!command_runner_->WaitForCommand(&result) || -+ if (!command_runner_->WaitForCommand(&result, can_run_more) || - result.status == ExitInterrupted) { - Cleanup(); - status_->BuildFinished(); -@@ -678,6 +701,10 @@ bool Builder::Build(string* err) { - return false; - } - -+ // We might be able to start another command; start the main loop over. -+ if (result.status == ExitTokenAvailable) -+ continue; -+ - --pending_commands; - if (!FinishCommand(&result, err)) { - Cleanup(); -diff --git a/src/build.h b/src/build.h -index 7dcd111e61..35c7b97d12 100644 ---- a/src/build.h -+++ b/src/build.h -@@ -139,6 +139,7 @@ struct Plan { +@@ -136,6 +139,7 @@ private: struct CommandRunner { virtual ~CommandRunner() {} virtual bool CanRunMore() const = 0; @@ -652,456 +346,18 @@ index 7dcd111e61..35c7b97d12 100644 virtual bool StartCommand(Edge* edge) = 0; /// The result of waiting for a command. -@@ -150,7 +151,7 @@ struct CommandRunner { +@@ -147,7 +151,9 @@ struct CommandRunner { bool success() const { return status == ExitSuccess; } }; /// Wait for a command to complete, or return false if interrupted. - virtual bool WaitForCommand(Result* result) = 0; ++ /// If more_ready is true then the optional TokenPool is monitored too ++ /// and we return when a token becomes available. + virtual bool WaitForCommand(Result* result, bool more_ready) = 0; virtual std::vector GetActiveEdges() { return std::vector(); } virtual void Abort() {} -diff --git a/src/build_test.cc b/src/build_test.cc -index 4ef62b2113..7a5ff4015a 100644 ---- a/src/build_test.cc -+++ b/src/build_test.cc -@@ -474,8 +474,9 @@ struct FakeCommandRunner : public CommandRunner { - - // CommandRunner impl - virtual bool CanRunMore() const; -+ virtual bool AcquireToken(); - virtual bool StartCommand(Edge* edge); -- virtual bool WaitForCommand(Result* result); -+ virtual bool WaitForCommand(Result* result, bool more_ready); - virtual vector GetActiveEdges(); - virtual void Abort(); - -@@ -578,6 +579,10 @@ bool FakeCommandRunner::CanRunMore() const { - return active_edges_.size() < max_active_edges_; - } - -+bool FakeCommandRunner::AcquireToken() { -+ return true; -+} -+ - bool FakeCommandRunner::StartCommand(Edge* edge) { - assert(active_edges_.size() < max_active_edges_); - assert(find(active_edges_.begin(), active_edges_.end(), edge) -@@ -649,7 +654,7 @@ bool FakeCommandRunner::StartCommand(Edge* edge) { - return true; - } - --bool FakeCommandRunner::WaitForCommand(Result* result) { -+bool FakeCommandRunner::WaitForCommand(Result* result, bool more_ready) { - if (active_edges_.empty()) - return false; - -diff --git a/src/exit_status.h b/src/exit_status.h -index a714ece791..75ebf6a7a0 100644 ---- a/src/exit_status.h -+++ b/src/exit_status.h -@@ -18,7 +18,8 @@ - enum ExitStatus { - ExitSuccess, - ExitFailure, -- ExitInterrupted -+ ExitTokenAvailable, -+ ExitInterrupted, - }; - - #endif // NINJA_EXIT_STATUS_H_ -diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc -index 8e785406c9..74451b0be2 100644 ---- a/src/subprocess-posix.cc -+++ b/src/subprocess-posix.cc -@@ -13,6 +13,7 @@ - // limitations under the License. - - #include "subprocess.h" -+#include "tokenpool.h" - - #include - #include -@@ -249,7 +250,7 @@ Subprocess *SubprocessSet::Add(const string& command, bool use_console) { - } - - #ifdef USE_PPOLL --bool SubprocessSet::DoWork() { -+bool SubprocessSet::DoWork(struct TokenPool* tokens) { - vector fds; - nfds_t nfds = 0; - -@@ -263,6 +264,12 @@ bool SubprocessSet::DoWork() { - ++nfds; - } - -+ if (tokens) { -+ pollfd pfd = { tokens->GetMonitorFd(), POLLIN | POLLPRI, 0 }; -+ fds.push_back(pfd); -+ ++nfds; -+ } -+ - interrupted_ = 0; - int ret = ppoll(&fds.front(), nfds, NULL, &old_mask_); - if (ret == -1) { -@@ -295,11 +302,20 @@ bool SubprocessSet::DoWork() { - ++i; - } - -+ if (tokens) { -+ pollfd *pfd = &fds[nfds - 1]; -+ if (pfd->fd >= 0) { -+ assert(pfd->fd == tokens->GetMonitorFd()); -+ if (pfd->revents != 0) -+ token_available_ = true; -+ } -+ } -+ - return IsInterrupted(); - } - - #else // !defined(USE_PPOLL) --bool SubprocessSet::DoWork() { -+bool SubprocessSet::DoWork(struct TokenPool* tokens) { - fd_set set; - int nfds = 0; - FD_ZERO(&set); -@@ -314,6 +330,13 @@ bool SubprocessSet::DoWork() { - } - } - -+ if (tokens) { -+ int fd = tokens->GetMonitorFd(); -+ FD_SET(fd, &set); -+ if (nfds < fd+1) -+ nfds = fd+1; -+ } -+ - interrupted_ = 0; - int ret = pselect(nfds, &set, 0, 0, 0, &old_mask_); - if (ret == -1) { -@@ -342,6 +365,12 @@ bool SubprocessSet::DoWork() { - ++i; - } - -+ if (tokens) { -+ int fd = tokens->GetMonitorFd(); -+ if ((fd >= 0) && FD_ISSET(fd, &set)) -+ token_available_ = true; -+ } -+ - return IsInterrupted(); - } - #endif // !defined(USE_PPOLL) -diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc -index ff3baaca7f..66d2c2c430 100644 ---- a/src/subprocess-win32.cc -+++ b/src/subprocess-win32.cc -@@ -251,7 +251,7 @@ Subprocess *SubprocessSet::Add(const string& command, bool use_console) { - return subprocess; - } - --bool SubprocessSet::DoWork() { -+bool SubprocessSet::DoWork(struct TokenPool* tokens) { - DWORD bytes_read; - Subprocess* subproc; - OVERLAPPED* overlapped; -diff --git a/src/subprocess.h b/src/subprocess.h -index 9e3d2ee98f..9ea67ea477 100644 ---- a/src/subprocess.h -+++ b/src/subprocess.h -@@ -76,6 +76,8 @@ struct Subprocess { - friend struct SubprocessSet; - }; - -+struct TokenPool; -+ - /// SubprocessSet runs a ppoll/pselect() loop around a set of Subprocesses. - /// DoWork() waits for any state change in subprocesses; finished_ - /// is a queue of subprocesses as they finish. -@@ -84,13 +86,17 @@ struct SubprocessSet { - ~SubprocessSet(); - - Subprocess* Add(const std::string& command, bool use_console = false); -- bool DoWork(); -+ bool DoWork(struct TokenPool* tokens); - Subprocess* NextFinished(); - void Clear(); - - std::vector running_; - std::queue finished_; - -+ bool token_available_; -+ bool IsTokenAvailable() { return token_available_; } -+ void ResetTokenAvailable() { token_available_ = false; } -+ - #ifdef _WIN32 - static BOOL WINAPI NotifyInterrupted(DWORD dwCtrlType); - static HANDLE ioport_; -diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc -index 073fe86931..4bc8083e26 100644 ---- a/src/subprocess_test.cc -+++ b/src/subprocess_test.cc -@@ -45,10 +45,12 @@ TEST_F(SubprocessTest, BadCommandStderr) { - Subprocess* subproc = subprocs_.Add("cmd /c ninja_no_such_command"); - ASSERT_NE((Subprocess *) 0, subproc); - -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { - // Pretend we discovered that stderr was ready for writing. -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitFailure, subproc->Finish()); - EXPECT_NE("", subproc->GetOutput()); -@@ -59,10 +61,12 @@ TEST_F(SubprocessTest, NoSuchCommand) { - Subprocess* subproc = subprocs_.Add("ninja_no_such_command"); - ASSERT_NE((Subprocess *) 0, subproc); - -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { - // Pretend we discovered that stderr was ready for writing. -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitFailure, subproc->Finish()); - EXPECT_NE("", subproc->GetOutput()); -@@ -78,9 +82,11 @@ TEST_F(SubprocessTest, InterruptChild) { - Subprocess* subproc = subprocs_.Add("kill -INT $$"); - ASSERT_NE((Subprocess *) 0, subproc); - -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitInterrupted, subproc->Finish()); - } -@@ -90,7 +96,7 @@ TEST_F(SubprocessTest, InterruptParent) { - ASSERT_NE((Subprocess *) 0, subproc); - - while (!subproc->Done()) { -- bool interrupted = subprocs_.DoWork(); -+ bool interrupted = subprocs_.DoWork(NULL); - if (interrupted) - return; - } -@@ -102,9 +108,11 @@ TEST_F(SubprocessTest, InterruptChildWithSigTerm) { - Subprocess* subproc = subprocs_.Add("kill -TERM $$"); - ASSERT_NE((Subprocess *) 0, subproc); - -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitInterrupted, subproc->Finish()); - } -@@ -114,7 +122,7 @@ TEST_F(SubprocessTest, InterruptParentWithSigTerm) { - ASSERT_NE((Subprocess *) 0, subproc); - - while (!subproc->Done()) { -- bool interrupted = subprocs_.DoWork(); -+ bool interrupted = subprocs_.DoWork(NULL); - if (interrupted) - return; - } -@@ -126,9 +134,11 @@ TEST_F(SubprocessTest, InterruptChildWithSigHup) { - Subprocess* subproc = subprocs_.Add("kill -HUP $$"); - ASSERT_NE((Subprocess *) 0, subproc); - -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitInterrupted, subproc->Finish()); - } -@@ -138,7 +148,7 @@ TEST_F(SubprocessTest, InterruptParentWithSigHup) { - ASSERT_NE((Subprocess *) 0, subproc); - - while (!subproc->Done()) { -- bool interrupted = subprocs_.DoWork(); -+ bool interrupted = subprocs_.DoWork(NULL); - if (interrupted) - return; - } -@@ -153,9 +163,11 @@ TEST_F(SubprocessTest, Console) { - subprocs_.Add("test -t 0 -a -t 1 -a -t 2", /*use_console=*/true); - ASSERT_NE((Subprocess*)0, subproc); - -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitSuccess, subproc->Finish()); - } -@@ -167,9 +179,11 @@ TEST_F(SubprocessTest, SetWithSingle) { - Subprocess* subproc = subprocs_.Add(kSimpleCommand); - ASSERT_NE((Subprocess *) 0, subproc); - -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - ASSERT_EQ(ExitSuccess, subproc->Finish()); - ASSERT_NE("", subproc->GetOutput()); - -@@ -200,12 +214,13 @@ TEST_F(SubprocessTest, SetWithMulti) { - ASSERT_EQ("", processes[i]->GetOutput()); - } - -+ subprocs_.ResetTokenAvailable(); - while (!processes[0]->Done() || !processes[1]->Done() || - !processes[2]->Done()) { - ASSERT_GT(subprocs_.running_.size(), 0u); -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -- -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - ASSERT_EQ(0u, subprocs_.running_.size()); - ASSERT_EQ(3u, subprocs_.finished_.size()); - -@@ -237,8 +252,10 @@ TEST_F(SubprocessTest, SetWithLots) { - ASSERT_NE((Subprocess *) 0, subproc); - procs.push_back(subproc); - } -+ subprocs_.ResetTokenAvailable(); - while (!subprocs_.running_.empty()) -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - for (size_t i = 0; i < procs.size(); ++i) { - ASSERT_EQ(ExitSuccess, procs[i]->Finish()); - ASSERT_NE("", procs[i]->GetOutput()); -@@ -254,9 +271,11 @@ TEST_F(SubprocessTest, SetWithLots) { - // that stdin is closed. - TEST_F(SubprocessTest, ReadStdin) { - Subprocess* subproc = subprocs_.Add("cat -"); -+ subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { -- subprocs_.DoWork(); -+ subprocs_.DoWork(NULL); - } -+ ASSERT_EQ(false, subprocs_.IsTokenAvailable()); - ASSERT_EQ(ExitSuccess, subproc->Finish()); - ASSERT_EQ(1u, subprocs_.finished_.size()); - } -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -index a8f9b7139d..396bb7d874 100644 ---- a/src/tokenpool-gnu-make.cc -+++ b/src/tokenpool-gnu-make.cc -@@ -33,6 +33,7 @@ struct GNUmakeTokenPool : public TokenPool { - virtual void Reserve(); - virtual void Release(); - virtual void Clear(); -+ virtual int GetMonitorFd(); - - bool Setup(); - -@@ -201,6 +202,10 @@ void GNUmakeTokenPool::Clear() { - Return(); - } - -+int GNUmakeTokenPool::GetMonitorFd() { -+ return(rfd_); -+} -+ - struct TokenPool *TokenPool::Get(void) { - GNUmakeTokenPool *tokenpool = new GNUmakeTokenPool; - if (tokenpool->Setup()) -diff --git a/src/tokenpool.h b/src/tokenpool.h -index f560b1083b..301e1998ee 100644 ---- a/src/tokenpool.h -+++ b/src/tokenpool.h -@@ -21,6 +21,12 @@ struct TokenPool { - virtual void Release() = 0; - virtual void Clear() = 0; - -+#ifdef _WIN32 -+ // @TODO -+#else -+ virtual int GetMonitorFd() = 0; -+#endif -+ - // returns NULL if token pool is not available - static struct TokenPool *Get(void); - }; - -From d09f3d77821b3b1fdf09fc0ef8e814907675eafb Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Sun, 12 Nov 2017 16:58:55 +0200 -Subject: [PATCH 03/11] Ignore jobserver when -jN is forced on command line - -This emulates the behaviour of GNU make. - -- add parallelism_from_cmdline flag to build configuration -- set the flag when -jN is given on command line -- pass the flag to TokenPool::Get() -- GNUmakeTokenPool::Setup() - * prints a warning when the flag is true and jobserver was detected - * returns false, i.e. jobserver will be ignored -- ignore config.parallelism in CanRunMore() when we have a valid - TokenPool, because it gets always initialized to a default when not - given on the command line ---- - src/build.cc | 10 ++++++---- - src/build.h | 4 +++- - src/ninja.cc | 1 + - src/tokenpool-gnu-make.cc | 34 +++++++++++++++++++--------------- - src/tokenpool-none.cc | 4 ++-- - src/tokenpool.h | 4 ++-- - 6 files changed, 33 insertions(+), 24 deletions(-) - -diff --git a/src/build.cc b/src/build.cc -index a25c349050..406a84ec39 100644 ---- a/src/build.cc -+++ b/src/build.cc -@@ -470,7 +470,7 @@ struct RealCommandRunner : public CommandRunner { - }; - - RealCommandRunner::RealCommandRunner(const BuildConfig& config) : config_(config) { -- tokens_ = TokenPool::Get(); -+ tokens_ = TokenPool::Get(config_.parallelism_from_cmdline); - } - - RealCommandRunner::~RealCommandRunner() { -@@ -492,9 +492,11 @@ void RealCommandRunner::Abort() { - } - - bool RealCommandRunner::CanRunMore() const { -- size_t subproc_number = -- subprocs_.running_.size() + subprocs_.finished_.size(); -- return (int)subproc_number < config_.parallelism -+ bool parallelism_limit_not_reached = -+ tokens_ || // ignore config_.parallelism -+ ((int) (subprocs_.running_.size() + -+ subprocs_.finished_.size()) < config_.parallelism); -+ return parallelism_limit_not_reached - && (subprocs_.running_.empty() || - (config_.max_load_average <= 0.0f || - GetLoadAverage() < config_.max_load_average)); -diff --git a/src/build.h b/src/build.h -index 35c7b97d12..dfde576573 100644 ---- a/src/build.h -+++ b/src/build.h -@@ -159,7 +159,8 @@ struct CommandRunner { +@@ -155,7 +161,8 @@ struct CommandRunner { /// Options (e.g. verbosity, parallelism) passed to a build. struct BuildConfig { @@ -1111,7 +367,7 @@ index 35c7b97d12..dfde576573 100644 failures_allowed(1), max_load_average(-0.0f) {} enum Verbosity { -@@ -171,6 +172,7 @@ struct BuildConfig { +@@ -167,6 +174,7 @@ struct BuildConfig { Verbosity verbosity; bool dry_run; int parallelism; @@ -1119,897 +375,6 @@ index 35c7b97d12..dfde576573 100644 int failures_allowed; /// The maximum load average we must not exceed. A negative value /// means that we do not have any limit. -diff --git a/src/ninja.cc b/src/ninja.cc -index df39ba92d1..d904c56c4e 100644 ---- a/src/ninja.cc -+++ b/src/ninja.cc -@@ -1447,6 +1447,7 @@ int ReadFlags(int* argc, char*** argv, - // We want to run N jobs in parallel. For N = 0, INT_MAX - // is close enough to infinite for most sane builds. - config->parallelism = value > 0 ? value : INT_MAX; -+ config->parallelism_from_cmdline = true; - deferGuessParallelism.needGuess = false; - break; - } -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -index 396bb7d874..af4be05a31 100644 ---- a/src/tokenpool-gnu-make.cc -+++ b/src/tokenpool-gnu-make.cc -@@ -1,4 +1,4 @@ --// Copyright 2016 Google Inc. All Rights Reserved. -+// Copyright 2016-2017 Google Inc. All Rights Reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. -@@ -35,7 +35,7 @@ struct GNUmakeTokenPool : public TokenPool { - virtual void Clear(); - virtual int GetMonitorFd(); - -- bool Setup(); -+ bool Setup(bool ignore); - - private: - int available_; -@@ -100,7 +100,7 @@ bool GNUmakeTokenPool::SetAlarmHandler() { - } - } - --bool GNUmakeTokenPool::Setup() { -+bool GNUmakeTokenPool::Setup(bool ignore) { - const char *value = getenv("MAKEFLAGS"); - if (value) { - // GNU make <= 4.1 -@@ -109,16 +109,20 @@ bool GNUmakeTokenPool::Setup() { - if (!jobserver) - jobserver = strstr(value, "--jobserver-auth="); - if (jobserver) { -- int rfd = -1; -- int wfd = -1; -- if ((sscanf(jobserver, "%*[^=]=%d,%d", &rfd, &wfd) == 2) && -- CheckFd(rfd) && -- CheckFd(wfd) && -- SetAlarmHandler()) { -- printf("ninja: using GNU make jobserver.\n"); -- rfd_ = rfd; -- wfd_ = wfd; -- return true; -+ if (ignore) { -+ printf("ninja: warning: -jN forced on command line; ignoring GNU make jobserver.\n"); -+ } else { -+ int rfd = -1; -+ int wfd = -1; -+ if ((sscanf(jobserver, "%*[^=]=%d,%d", &rfd, &wfd) == 2) && -+ CheckFd(rfd) && -+ CheckFd(wfd) && -+ SetAlarmHandler()) { -+ printf("ninja: using GNU make jobserver.\n"); -+ rfd_ = rfd; -+ wfd_ = wfd; -+ return true; -+ } - } - } - } -@@ -206,9 +210,9 @@ int GNUmakeTokenPool::GetMonitorFd() { - return(rfd_); - } - --struct TokenPool *TokenPool::Get(void) { -+struct TokenPool *TokenPool::Get(bool ignore) { - GNUmakeTokenPool *tokenpool = new GNUmakeTokenPool; -- if (tokenpool->Setup()) -+ if (tokenpool->Setup(ignore)) - return tokenpool; - else - delete tokenpool; -diff --git a/src/tokenpool-none.cc b/src/tokenpool-none.cc -index 602b3316f5..199b22264b 100644 ---- a/src/tokenpool-none.cc -+++ b/src/tokenpool-none.cc -@@ -1,4 +1,4 @@ --// Copyright 2016 Google Inc. All Rights Reserved. -+// Copyright 2016-2017 Google Inc. All Rights Reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. -@@ -22,6 +22,6 @@ - #include - - // No-op TokenPool implementation --struct TokenPool *TokenPool::Get(void) { -+struct TokenPool *TokenPool::Get(bool ignore) { - return NULL; - } -diff --git a/src/tokenpool.h b/src/tokenpool.h -index 301e1998ee..878a0933c2 100644 ---- a/src/tokenpool.h -+++ b/src/tokenpool.h -@@ -1,4 +1,4 @@ --// Copyright 2016 Google Inc. All Rights Reserved. -+// Copyright 2016-2017 Google Inc. All Rights Reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. -@@ -28,5 +28,5 @@ struct TokenPool { - #endif - - // returns NULL if token pool is not available -- static struct TokenPool *Get(void); -+ static struct TokenPool *Get(bool ignore); - }; - -From dfe4ca753caee65bf9041e2b4e883dfa172a5c6a Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Sun, 12 Nov 2017 18:04:12 +0200 -Subject: [PATCH 04/11] Honor -lN from MAKEFLAGS - -This emulates the behaviour of GNU make. - -- build: make a copy of max_load_average and pass it to TokenPool. -- GNUmakeTokenPool: if we detect a jobserver and a valid -lN argument in - MAKEFLAGS then set max_load_average to N. ---- - src/build.cc | 10 +++++++--- - src/tokenpool-gnu-make.cc | 19 +++++++++++++++---- - src/tokenpool-none.cc | 2 +- - src/tokenpool.h | 2 +- - 4 files changed, 24 insertions(+), 9 deletions(-) - -diff --git a/src/build.cc b/src/build.cc -index 406a84ec39..9e6272d035 100644 ---- a/src/build.cc -+++ b/src/build.cc -@@ -464,13 +464,17 @@ struct RealCommandRunner : public CommandRunner { - virtual void Abort(); - - const BuildConfig& config_; -+ // copy of config_.max_load_average; can be modified by TokenPool setup -+ double max_load_average_; - SubprocessSet subprocs_; - TokenPool *tokens_; - map subproc_to_edge_; - }; - - RealCommandRunner::RealCommandRunner(const BuildConfig& config) : config_(config) { -- tokens_ = TokenPool::Get(config_.parallelism_from_cmdline); -+ max_load_average_ = config.max_load_average; -+ tokens_ = TokenPool::Get(config_.parallelism_from_cmdline, -+ max_load_average_); - } - - RealCommandRunner::~RealCommandRunner() { -@@ -498,8 +502,8 @@ bool RealCommandRunner::CanRunMore() const { - subprocs_.finished_.size()) < config_.parallelism); - return parallelism_limit_not_reached - && (subprocs_.running_.empty() || -- (config_.max_load_average <= 0.0f || -- GetLoadAverage() < config_.max_load_average)); -+ (max_load_average_ <= 0.0f || -+ GetLoadAverage() < max_load_average_)); - } - - bool RealCommandRunner::AcquireToken() { -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -index af4be05a31..fb654c4d88 100644 ---- a/src/tokenpool-gnu-make.cc -+++ b/src/tokenpool-gnu-make.cc -@@ -35,7 +35,7 @@ struct GNUmakeTokenPool : public TokenPool { - virtual void Clear(); - virtual int GetMonitorFd(); - -- bool Setup(bool ignore); -+ bool Setup(bool ignore, double& max_load_average); - - private: - int available_; -@@ -100,7 +100,7 @@ bool GNUmakeTokenPool::SetAlarmHandler() { - } - } - --bool GNUmakeTokenPool::Setup(bool ignore) { -+bool GNUmakeTokenPool::Setup(bool ignore, double& max_load_average) { - const char *value = getenv("MAKEFLAGS"); - if (value) { - // GNU make <= 4.1 -@@ -118,9 +118,20 @@ bool GNUmakeTokenPool::Setup(bool ignore) { - CheckFd(rfd) && - CheckFd(wfd) && - SetAlarmHandler()) { -+ const char *l_arg = strstr(value, " -l"); -+ int load_limit = -1; -+ - printf("ninja: using GNU make jobserver.\n"); - rfd_ = rfd; - wfd_ = wfd; -+ -+ // translate GNU make -lN to ninja -lN -+ if (l_arg && -+ (sscanf(l_arg + 3, "%d ", &load_limit) == 1) && -+ (load_limit > 0)) { -+ max_load_average = load_limit; -+ } -+ - return true; - } - } -@@ -210,9 +221,9 @@ int GNUmakeTokenPool::GetMonitorFd() { - return(rfd_); - } - --struct TokenPool *TokenPool::Get(bool ignore) { -+struct TokenPool *TokenPool::Get(bool ignore, double& max_load_average) { - GNUmakeTokenPool *tokenpool = new GNUmakeTokenPool; -- if (tokenpool->Setup(ignore)) -+ if (tokenpool->Setup(ignore, max_load_average)) - return tokenpool; - else - delete tokenpool; -diff --git a/src/tokenpool-none.cc b/src/tokenpool-none.cc -index 199b22264b..e8e25426c3 100644 ---- a/src/tokenpool-none.cc -+++ b/src/tokenpool-none.cc -@@ -22,6 +22,6 @@ - #include - - // No-op TokenPool implementation --struct TokenPool *TokenPool::Get(bool ignore) { -+struct TokenPool *TokenPool::Get(bool ignore, double& max_load_average) { - return NULL; - } -diff --git a/src/tokenpool.h b/src/tokenpool.h -index 878a0933c2..f9e8cc2ee0 100644 ---- a/src/tokenpool.h -+++ b/src/tokenpool.h -@@ -28,5 +28,5 @@ struct TokenPool { - #endif - - // returns NULL if token pool is not available -- static struct TokenPool *Get(bool ignore); -+ static struct TokenPool *Get(bool ignore, double& max_load_average); - }; - -From 1c10047fc6a3269ba42839da19361e09cbc06ff0 Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Wed, 6 Dec 2017 22:14:21 +0200 -Subject: [PATCH 05/11] Use LinePrinter for TokenPool messages - -- replace printf() with calls to LinePrinter -- print GNU make jobserver message only when verbose build is requested ---- - src/build.cc | 1 + - src/tokenpool-gnu-make.cc | 22 ++++++++++++++++------ - src/tokenpool-none.cc | 4 +++- - src/tokenpool.h | 4 +++- - 4 files changed, 23 insertions(+), 8 deletions(-) - -diff --git a/src/build.cc b/src/build.cc -index 9e6272d035..662e4bd7be 100644 ---- a/src/build.cc -+++ b/src/build.cc -@@ -474,6 +474,7 @@ struct RealCommandRunner : public CommandRunner { - RealCommandRunner::RealCommandRunner(const BuildConfig& config) : config_(config) { - max_load_average_ = config.max_load_average; - tokens_ = TokenPool::Get(config_.parallelism_from_cmdline, -+ config_.verbosity == BuildConfig::VERBOSE, - max_load_average_); - } - -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -index fb654c4d88..b0d3e6ebc4 100644 ---- a/src/tokenpool-gnu-make.cc -+++ b/src/tokenpool-gnu-make.cc -@@ -23,6 +23,8 @@ - #include - #include - -+#include "line_printer.h" -+ - // TokenPool implementation for GNU make jobserver - // (http://make.mad-scientist.net/papers/jobserver-implementation/) - struct GNUmakeTokenPool : public TokenPool { -@@ -35,7 +37,7 @@ struct GNUmakeTokenPool : public TokenPool { - virtual void Clear(); - virtual int GetMonitorFd(); - -- bool Setup(bool ignore, double& max_load_average); -+ bool Setup(bool ignore, bool verbose, double& max_load_average); - - private: - int available_; -@@ -100,7 +102,9 @@ bool GNUmakeTokenPool::SetAlarmHandler() { - } - } - --bool GNUmakeTokenPool::Setup(bool ignore, double& max_load_average) { -+bool GNUmakeTokenPool::Setup(bool ignore, -+ bool verbose, -+ double& max_load_average) { - const char *value = getenv("MAKEFLAGS"); - if (value) { - // GNU make <= 4.1 -@@ -109,8 +113,10 @@ bool GNUmakeTokenPool::Setup(bool ignore, double& max_load_average) { - if (!jobserver) - jobserver = strstr(value, "--jobserver-auth="); - if (jobserver) { -+ LinePrinter printer; -+ - if (ignore) { -- printf("ninja: warning: -jN forced on command line; ignoring GNU make jobserver.\n"); -+ printer.PrintOnNewLine("ninja: warning: -jN forced on command line; ignoring GNU make jobserver.\n"); - } else { - int rfd = -1; - int wfd = -1; -@@ -121,7 +127,9 @@ bool GNUmakeTokenPool::Setup(bool ignore, double& max_load_average) { - const char *l_arg = strstr(value, " -l"); - int load_limit = -1; - -- printf("ninja: using GNU make jobserver.\n"); -+ if (verbose) { -+ printer.PrintOnNewLine("ninja: using GNU make jobserver.\n"); -+ } - rfd_ = rfd; - wfd_ = wfd; - -@@ -221,9 +229,11 @@ int GNUmakeTokenPool::GetMonitorFd() { - return(rfd_); - } - --struct TokenPool *TokenPool::Get(bool ignore, double& max_load_average) { -+struct TokenPool *TokenPool::Get(bool ignore, -+ bool verbose, -+ double& max_load_average) { - GNUmakeTokenPool *tokenpool = new GNUmakeTokenPool; -- if (tokenpool->Setup(ignore, max_load_average)) -+ if (tokenpool->Setup(ignore, verbose, max_load_average)) - return tokenpool; - else - delete tokenpool; -diff --git a/src/tokenpool-none.cc b/src/tokenpool-none.cc -index e8e25426c3..1c1c499c8d 100644 ---- a/src/tokenpool-none.cc -+++ b/src/tokenpool-none.cc -@@ -22,6 +22,8 @@ - #include - - // No-op TokenPool implementation --struct TokenPool *TokenPool::Get(bool ignore, double& max_load_average) { -+struct TokenPool *TokenPool::Get(bool ignore, -+ bool verbose, -+ double& max_load_average) { - return NULL; - } -diff --git a/src/tokenpool.h b/src/tokenpool.h -index f9e8cc2ee0..4bf477f20c 100644 ---- a/src/tokenpool.h -+++ b/src/tokenpool.h -@@ -28,5 +28,7 @@ struct TokenPool { - #endif - - // returns NULL if token pool is not available -- static struct TokenPool *Get(bool ignore, double& max_load_average); -+ static struct TokenPool *Get(bool ignore, -+ bool verbose, -+ double& max_load_average); - }; - -From fdbf68416e3574add3bffd0b637d0694fbaba320 Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Sat, 7 Apr 2018 17:11:21 +0300 -Subject: [PATCH 06/11] Prepare PR for merging - -- fix Windows build error in no-op TokenPool implementation -- improve Acquire() to block for a maximum of 100ms -- address review comments ---- - src/build.h | 2 ++ - src/tokenpool-gnu-make.cc | 53 +++++++++++++++++++++++++++++++++------ - src/tokenpool-none.cc | 7 +----- - 3 files changed, 49 insertions(+), 13 deletions(-) - -diff --git a/src/build.h b/src/build.h -index dfde576573..66ddefb888 100644 ---- a/src/build.h -+++ b/src/build.h -@@ -151,6 +151,8 @@ struct CommandRunner { - bool success() const { return status == ExitSuccess; } - }; - /// Wait for a command to complete, or return false if interrupted. -+ /// If more_ready is true then the optional TokenPool is monitored too -+ /// and we return when a token becomes available. - virtual bool WaitForCommand(Result* result, bool more_ready) = 0; - - virtual std::vector GetActiveEdges() { return std::vector(); } -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -index b0d3e6ebc4..4132bb06d9 100644 ---- a/src/tokenpool-gnu-make.cc -+++ b/src/tokenpool-gnu-make.cc -@@ -1,4 +1,4 @@ --// Copyright 2016-2017 Google Inc. All Rights Reserved. -+// Copyright 2016-2018 Google Inc. All Rights Reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -153,6 +154,15 @@ bool GNUmakeTokenPool::Acquire() { - if (available_ > 0) - return true; - -+ // Please read -+ // -+ // http://make.mad-scientist.net/papers/jobserver-implementation/ -+ // -+ // for the reasoning behind the following code. -+ // -+ // Try to read one character from the pipe. Returns true on success. -+ // -+ // First check if read() would succeed without blocking. - #ifdef USE_PPOLL - pollfd pollfds[] = {{rfd_, POLLIN, 0}}; - int ret = poll(pollfds, 1, 0); -@@ -164,33 +174,62 @@ bool GNUmakeTokenPool::Acquire() { - int ret = select(rfd_ + 1, &set, NULL, NULL, &timeout); - #endif - if (ret > 0) { -+ // Handle potential race condition: -+ // - the above check succeeded, i.e. read() should not block -+ // - the character disappears before we call read() -+ // -+ // Create a duplicate of rfd_. The duplicate file descriptor dup_rfd_ -+ // can safely be closed by signal handlers without affecting rfd_. - dup_rfd_ = dup(rfd_); - - if (dup_rfd_ != -1) { - struct sigaction act, old_act; - int ret = 0; - -+ // Temporarily replace SIGCHLD handler with our own - memset(&act, 0, sizeof(act)); - act.sa_handler = CloseDupRfd; - if (sigaction(SIGCHLD, &act, &old_act) == 0) { -- char buf; -- -- // block until token read, child exits or timeout -- alarm(1); -- ret = read(dup_rfd_, &buf, 1); -- alarm(0); -+ struct itimerval timeout; -+ -+ // install a 100ms timeout that generates SIGALARM on expiration -+ memset(&timeout, 0, sizeof(timeout)); -+ timeout.it_value.tv_usec = 100 * 1000; // [ms] -> [usec] -+ if (setitimer(ITIMER_REAL, &timeout, NULL) == 0) { -+ char buf; -+ -+ // Now try to read() from dup_rfd_. Return values from read(): -+ // -+ // 1. token read -> 1 -+ // 2. pipe closed -> 0 -+ // 3. alarm expires -> -1 (EINTR) -+ // 4. child exits -> -1 (EINTR) -+ // 5. alarm expired before entering read() -> -1 (EBADF) -+ // 6. child exited before entering read() -> -1 (EBADF) -+ // 7. child exited before handler is installed -> go to 1 - 3 -+ ret = read(dup_rfd_, &buf, 1); -+ -+ // disarm timer -+ memset(&timeout, 0, sizeof(timeout)); -+ setitimer(ITIMER_REAL, &timeout, NULL); -+ } - - sigaction(SIGCHLD, &old_act, NULL); - } - - CloseDupRfd(0); - -+ // Case 1 from above list - if (ret > 0) { - available_++; - return true; - } - } - } -+ -+ // read() would block, i.e. no token available, -+ // cases 2-6 from above list or -+ // select() / poll() / dup() / sigaction() / setitimer() failed - return false; - } - -diff --git a/src/tokenpool-none.cc b/src/tokenpool-none.cc -index 1c1c499c8d..4c592875b4 100644 ---- a/src/tokenpool-none.cc -+++ b/src/tokenpool-none.cc -@@ -1,4 +1,4 @@ --// Copyright 2016-2017 Google Inc. All Rights Reserved. -+// Copyright 2016-2018 Google Inc. All Rights Reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. -@@ -14,11 +14,6 @@ - - #include "tokenpool.h" - --#include --#include --#include --#include --#include - #include - - // No-op TokenPool implementation - -From ec6220a0baf7d3a6eaf1a2b75bf8960ddfe24c2f Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Fri, 25 May 2018 00:17:07 +0300 -Subject: [PATCH 07/11] Add tests for TokenPool - -- TokenPool setup -- GetMonitorFd() API -- implicit token and tokens in jobserver pipe -- Acquire() / Reserve() / Release() protocol -- Clear() API ---- - configure.py | 1 + - src/tokenpool_test.cc | 198 ++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 199 insertions(+) - create mode 100644 src/tokenpool_test.cc - -diff --git a/configure.py b/configure.py -index db3492c93c..dc8a0066b7 100755 ---- a/configure.py -+++ b/configure.py -@@ -590,6 +590,7 @@ def has_re2c(): - 'string_piece_util_test', - 'subprocess_test', - 'test', -+ 'tokenpool_test', - 'util_test']: - objs += cxx(name, variables=cxxvariables) - if platform.is_windows(): -diff --git a/src/tokenpool_test.cc b/src/tokenpool_test.cc -new file mode 100644 -index 0000000000..6c89064ca4 ---- /dev/null -+++ b/src/tokenpool_test.cc -@@ -0,0 +1,198 @@ -+// Copyright 2018 Google Inc. All Rights Reserved. -+// -+// Licensed under the Apache License, Version 2.0 (the "License"); -+// you may not use this file except in compliance with the License. -+// You may obtain a copy of the License at -+// -+// http://www.apache.org/licenses/LICENSE-2.0 -+// -+// Unless required by applicable law or agreed to in writing, software -+// distributed under the License is distributed on an "AS IS" BASIS, -+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+// See the License for the specific language governing permissions and -+// limitations under the License. -+ -+#include "tokenpool.h" -+ -+#include "test.h" -+ -+#ifndef _WIN32 -+#include -+#include -+#include -+ -+#define ENVIRONMENT_CLEAR() unsetenv("MAKEFLAGS") -+#define ENVIRONMENT_INIT(v) setenv("MAKEFLAGS", v, true); -+#endif -+ -+namespace { -+ -+const double kLoadAverageDefault = -1.23456789; -+ -+struct TokenPoolTest : public testing::Test { -+ double load_avg_; -+ TokenPool *tokens_; -+#ifndef _WIN32 -+ char buf_[1024]; -+ int fds_[2]; -+#endif -+ -+ virtual void SetUp() { -+ load_avg_ = kLoadAverageDefault; -+ tokens_ = NULL; -+#ifndef _WIN32 -+ ENVIRONMENT_CLEAR(); -+ if (pipe(fds_) < 0) -+ ASSERT_TRUE(false); -+#endif -+ } -+ -+ void CreatePool(const char *format, bool ignore_jobserver) { -+#ifndef _WIN32 -+ if (format) { -+ sprintf(buf_, format, fds_[0], fds_[1]); -+ ENVIRONMENT_INIT(buf_); -+ } -+#endif -+ tokens_ = TokenPool::Get(ignore_jobserver, false, load_avg_); -+ } -+ -+ void CreateDefaultPool() { -+ CreatePool("foo --jobserver-auth=%d,%d bar", false); -+ } -+ -+ virtual void TearDown() { -+ if (tokens_) -+ delete tokens_; -+#ifndef _WIN32 -+ close(fds_[0]); -+ close(fds_[1]); -+ ENVIRONMENT_CLEAR(); -+#endif -+ } -+}; -+ -+} // anonymous namespace -+ -+// verifies none implementation -+TEST_F(TokenPoolTest, NoTokenPool) { -+ CreatePool(NULL, false); -+ -+ EXPECT_EQ(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+} -+ -+#ifndef _WIN32 -+TEST_F(TokenPoolTest, SuccessfulOldSetup) { -+ // GNUmake <= 4.1 -+ CreatePool("foo --jobserver-fds=%d,%d bar", false); -+ -+ EXPECT_NE(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+} -+ -+TEST_F(TokenPoolTest, SuccessfulNewSetup) { -+ // GNUmake => 4.2 -+ CreateDefaultPool(); -+ -+ EXPECT_NE(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+} -+ -+TEST_F(TokenPoolTest, IgnoreWithJN) { -+ CreatePool("foo --jobserver-auth=%d,%d bar", true); -+ -+ EXPECT_EQ(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+} -+ -+TEST_F(TokenPoolTest, HonorLN) { -+ CreatePool("foo -l9 --jobserver-auth=%d,%d bar", false); -+ -+ EXPECT_NE(NULL, tokens_); -+ EXPECT_EQ(9.0, load_avg_); -+} -+ -+TEST_F(TokenPoolTest, MonitorFD) { -+ CreateDefaultPool(); -+ -+ ASSERT_NE(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+ -+ EXPECT_EQ(fds_[0], tokens_->GetMonitorFd()); -+} -+ -+TEST_F(TokenPoolTest, ImplicitToken) { -+ CreateDefaultPool(); -+ -+ ASSERT_NE(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+ -+ EXPECT_TRUE(tokens_->Acquire()); -+ tokens_->Reserve(); -+ EXPECT_FALSE(tokens_->Acquire()); -+ tokens_->Release(); -+ EXPECT_TRUE(tokens_->Acquire()); -+} -+ -+TEST_F(TokenPoolTest, TwoTokens) { -+ CreateDefaultPool(); -+ -+ ASSERT_NE(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+ -+ // implicit token -+ EXPECT_TRUE(tokens_->Acquire()); -+ tokens_->Reserve(); -+ EXPECT_FALSE(tokens_->Acquire()); -+ -+ // jobserver offers 2nd token -+ ASSERT_EQ(1u, write(fds_[1], "T", 1)); -+ EXPECT_TRUE(tokens_->Acquire()); -+ tokens_->Reserve(); -+ EXPECT_FALSE(tokens_->Acquire()); -+ -+ // release 2nd token -+ tokens_->Release(); -+ EXPECT_TRUE(tokens_->Acquire()); -+ -+ // release implict token - must return 2nd token back to jobserver -+ tokens_->Release(); -+ EXPECT_TRUE(tokens_->Acquire()); -+ -+ // there must be one token in the pipe -+ EXPECT_EQ(1u, read(fds_[0], buf_, sizeof(buf_))); -+ -+ // implicit token -+ EXPECT_TRUE(tokens_->Acquire()); -+} -+ -+TEST_F(TokenPoolTest, Clear) { -+ CreateDefaultPool(); -+ -+ ASSERT_NE(NULL, tokens_); -+ EXPECT_EQ(kLoadAverageDefault, load_avg_); -+ -+ // implicit token -+ EXPECT_TRUE(tokens_->Acquire()); -+ tokens_->Reserve(); -+ EXPECT_FALSE(tokens_->Acquire()); -+ -+ // jobserver offers 2nd & 3rd token -+ ASSERT_EQ(2u, write(fds_[1], "TT", 2)); -+ EXPECT_TRUE(tokens_->Acquire()); -+ tokens_->Reserve(); -+ EXPECT_TRUE(tokens_->Acquire()); -+ tokens_->Reserve(); -+ EXPECT_FALSE(tokens_->Acquire()); -+ -+ tokens_->Clear(); -+ EXPECT_TRUE(tokens_->Acquire()); -+ -+ // there must be two tokens in the pipe -+ EXPECT_EQ(2u, read(fds_[0], buf_, sizeof(buf_))); -+ -+ // implicit token -+ EXPECT_TRUE(tokens_->Acquire()); -+} -+#endif - -From e59d8858327126d1593fd0b8e607975a79072e92 Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Thu, 24 May 2018 18:52:45 +0300 -Subject: [PATCH 08/11] Add tests for subprocess module - -- add TokenPoolTest stub to provide TokenPool::GetMonitorFd() -- add two tests - * both tests set up a dummy GNUmake jobserver pipe - * both tests call DoWork() with TokenPoolTest - * test 1: verify that DoWork() detects when a token is available - * test 2: verify that DoWork() works as before without a token -- the tests are not compiled in under Windows ---- - src/subprocess_test.cc | 76 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 76 insertions(+) - -diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc -index 4bc8083e26..6264c8bf11 100644 ---- a/src/subprocess_test.cc -+++ b/src/subprocess_test.cc -@@ -13,6 +13,7 @@ - // limitations under the License. - - #include "subprocess.h" -+#include "tokenpool.h" - - #include "test.h" - -@@ -34,8 +35,23 @@ const char* kSimpleCommand = "cmd /c dir \\"; - const char* kSimpleCommand = "ls /"; - #endif - -+struct TokenPoolTest : public TokenPool { -+ bool Acquire() { return false; } -+ void Reserve() {} -+ void Release() {} -+ void Clear() {} -+ -+#ifdef _WIN32 -+ // @TODO -+#else -+ int _fd; -+ int GetMonitorFd() { return _fd; } -+#endif -+}; -+ - struct SubprocessTest : public testing::Test { - SubprocessSet subprocs_; -+ TokenPoolTest tokens_; - }; - - } // anonymous namespace -@@ -280,3 +296,63 @@ TEST_F(SubprocessTest, ReadStdin) { - ASSERT_EQ(1u, subprocs_.finished_.size()); - } - #endif // _WIN32 -+ -+// @TODO: remove once TokenPool implementation for Windows is available -+#ifndef _WIN32 -+TEST_F(SubprocessTest, TokenAvailable) { -+ Subprocess* subproc = subprocs_.Add(kSimpleCommand); -+ ASSERT_NE((Subprocess *) 0, subproc); -+ -+ // simulate GNUmake jobserver pipe with 1 token -+ int fds[2]; -+ ASSERT_EQ(0u, pipe(fds)); -+ tokens_._fd = fds[0]; -+ ASSERT_EQ(1u, write(fds[1], "T", 1)); -+ -+ subprocs_.ResetTokenAvailable(); -+ subprocs_.DoWork(&tokens_); -+ -+ EXPECT_TRUE(subprocs_.IsTokenAvailable()); -+ EXPECT_EQ(0u, subprocs_.finished_.size()); -+ -+ // remove token to let DoWork() wait for command again -+ char token; -+ ASSERT_EQ(1u, read(fds[0], &token, 1)); -+ -+ while (!subproc->Done()) { -+ subprocs_.DoWork(&tokens_); -+ } -+ -+ close(fds[1]); -+ close(fds[0]); -+ -+ EXPECT_EQ(ExitSuccess, subproc->Finish()); -+ EXPECT_NE("", subproc->GetOutput()); -+ -+ EXPECT_EQ(1u, subprocs_.finished_.size()); -+} -+ -+TEST_F(SubprocessTest, TokenNotAvailable) { -+ Subprocess* subproc = subprocs_.Add(kSimpleCommand); -+ ASSERT_NE((Subprocess *) 0, subproc); -+ -+ // simulate GNUmake jobserver pipe with 0 tokens -+ int fds[2]; -+ ASSERT_EQ(0u, pipe(fds)); -+ tokens_._fd = fds[0]; -+ -+ subprocs_.ResetTokenAvailable(); -+ while (!subproc->Done()) { -+ subprocs_.DoWork(&tokens_); -+ } -+ -+ close(fds[1]); -+ close(fds[0]); -+ -+ EXPECT_FALSE(subprocs_.IsTokenAvailable()); -+ EXPECT_EQ(ExitSuccess, subproc->Finish()); -+ EXPECT_NE("", subproc->GetOutput()); -+ -+ EXPECT_EQ(1u, subprocs_.finished_.size()); -+} -+#endif // _WIN32 - -From 0145e2d4db64ea6c21aeb371928e4071f65164eb Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Sat, 26 May 2018 23:17:51 +0300 -Subject: [PATCH 09/11] Add tests for build module - -Add tests that verify the token functionality of the builder main loop. -We replace the default fake command runner with a special version where -the tests can control each call to AcquireToken(), CanRunMore() and -WaitForCommand(). ---- - src/build_test.cc | 364 ++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 364 insertions(+) - -diff --git a/src/build_test.cc b/src/build_test.cc -index 7a5ff4015a..dd41dfbe1d 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -15,6 +15,7 @@ @@ -2020,7 +385,38 @@ index 7a5ff4015a..dd41dfbe1d 100644 #include "build_log.h" #include "deps_log.h" -@@ -3990,3 +3991,366 @@ TEST_F(BuildTest, ValidationWithCircularDependency) { +@@ -474,8 +475,9 @@ struct FakeCommandRunner : public Comman + + // CommandRunner impl + virtual bool CanRunMore() const; ++ virtual bool AcquireToken(); + virtual bool StartCommand(Edge* edge); +- virtual bool WaitForCommand(Result* result); ++ virtual bool WaitForCommand(Result* result, bool more_ready); + virtual vector GetActiveEdges(); + virtual void Abort(); + +@@ -578,6 +580,10 @@ bool FakeCommandRunner::CanRunMore() con + return active_edges_.size() < max_active_edges_; + } + ++bool FakeCommandRunner::AcquireToken() { ++ return true; ++} ++ + bool FakeCommandRunner::StartCommand(Edge* edge) { + assert(active_edges_.size() < max_active_edges_); + assert(find(active_edges_.begin(), active_edges_.end(), edge) +@@ -649,7 +655,7 @@ bool FakeCommandRunner::StartCommand(Edg + return true; + } + +-bool FakeCommandRunner::WaitForCommand(Result* result) { ++bool FakeCommandRunner::WaitForCommand(Result* result, bool more_ready) { + if (active_edges_.empty()) + return false; + +@@ -3985,3 +3991,356 @@ TEST_F(BuildTest, ValidationWithCircular EXPECT_FALSE(builder_.AddTarget("out", &err)); EXPECT_EQ("dependency cycle: validate -> validate_in -> validate", err); } @@ -2177,16 +573,6 @@ index 7a5ff4015a..dd41dfbe1d 100644 + } +} + -+TEST_F(BuildTokenTest, CompleteNoWork) { -+ // plan should not execute anything -+ string err; -+ -+ EXPECT_TRUE(builder_.Build(&err)); -+ EXPECT_EQ("", err); -+ -+ EXPECT_EQ(0u, token_command_runner_.commands_ran_.size()); -+} -+ +TEST_F(BuildTokenTest, DoNotAquireToken) { + // plan should execute one command + string err; @@ -2387,106 +773,109 @@ index 7a5ff4015a..dd41dfbe1d 100644 + token_command_runner_.commands_ran_[1] == "cat in1 > out1")); + EXPECT_TRUE(token_command_runner_.commands_ran_[2] == "cat out1 out2 > out12"); +} - -From f016e5430c9123d34a73ea7ad28693b20ee59d6d Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Mon, 8 Oct 2018 17:47:50 +0300 -Subject: [PATCH 10/11] Add Win32 implementation for GNUmakeTokenPool - -GNU make uses a semaphore as jobserver protocol on Win32. See also - - https://www.gnu.org/software/make/manual/html_node/Windows-Jobserver.html - -Usage is pretty simple and straightforward, i.e. WaitForSingleObject() -to obtain a token and ReleaseSemaphore() to return it. - -Unfortunately subprocess-win32.cc uses an I/O completion port (IOCP). -IOCPs aren't waitable objects, i.e. we can't use WaitForMultipleObjects() -to wait on the IOCP and the token semaphore at the same time. - -Therefore GNUmakeTokenPoolWin32 creates a child thread that waits on the -token semaphore and posts a dummy I/O completion status on the IOCP when -it was able to obtain a token. That unblocks SubprocessSet::DoWork() and -it can then check if a token became available or not. - -- split existing GNUmakeTokenPool into common and platform bits -- add GNUmakeTokenPool interface -- move the Posix bits to GNUmakeTokenPoolPosix -- add the Win32 bits as GNUmakeTokenPoolWin32 -- move Setup() method up to TokenPool interface -- update Subprocess & TokenPool tests accordingly ---- - configure.py | 8 +- - src/build.cc | 11 +- - src/subprocess-win32.cc | 9 ++ - src/subprocess_test.cc | 34 ++++- - src/tokenpool-gnu-make-posix.cc | 203 +++++++++++++++++++++++++++ - src/tokenpool-gnu-make-win32.cc | 237 ++++++++++++++++++++++++++++++++ - src/tokenpool-gnu-make.cc | 203 ++------------------------- - src/tokenpool-gnu-make.h | 40 ++++++ - src/tokenpool-none.cc | 4 +- - src/tokenpool.h | 18 ++- - src/tokenpool_test.cc | 113 ++++++++++++--- - 11 files changed, 653 insertions(+), 227 deletions(-) - create mode 100644 src/tokenpool-gnu-make-posix.cc - create mode 100644 src/tokenpool-gnu-make-win32.cc - create mode 100644 src/tokenpool-gnu-make.h - -diff --git a/configure.py b/configure.py -index dc8a0066b7..a239b90eef 100755 ---- a/configure.py -+++ b/configure.py -@@ -517,12 +517,13 @@ def has_re2c(): - 'state', - 'status', - 'string_piece_util', -+ 'tokenpool-gnu-make', - 'util', - 'version']: - objs += cxx(name, variables=cxxvariables) - if platform.is_windows(): - for name in ['subprocess-win32', -- 'tokenpool-none', -+ 'tokenpool-gnu-make-win32', - 'includes_normalize-win32', - 'msvc_helper-win32', - 'msvc_helper_main-win32']: -@@ -531,8 +532,9 @@ def has_re2c(): - objs += cxx('minidump-win32', variables=cxxvariables) - objs += cc('getopt') - else: -- objs += cxx('subprocess-posix') -- objs += cxx('tokenpool-gnu-make') -+ for name in ['subprocess-posix', -+ 'tokenpool-gnu-make-posix']: -+ objs += cxx(name) - if platform.is_aix(): - objs += cc('getopt') - if platform.is_msvc(): -diff --git a/src/build.cc b/src/build.cc -index 662e4bd7be..20c3bdc2a0 100644 ---- a/src/build.cc -+++ b/src/build.cc -@@ -473,9 +473,14 @@ struct RealCommandRunner : public CommandRunner { +--- a/src/exit_status.h ++++ b/src/exit_status.h +@@ -18,7 +18,8 @@ + enum ExitStatus { + ExitSuccess, + ExitFailure, +- ExitInterrupted ++ ExitTokenAvailable, ++ ExitInterrupted, + }; - RealCommandRunner::RealCommandRunner(const BuildConfig& config) : config_(config) { - max_load_average_ = config.max_load_average; -- tokens_ = TokenPool::Get(config_.parallelism_from_cmdline, -- config_.verbosity == BuildConfig::VERBOSE, -- max_load_average_); -+ if ((tokens_ = TokenPool::Get()) != NULL) { -+ if (!tokens_->Setup(config_.parallelism_from_cmdline, -+ config_.verbosity == BuildConfig::VERBOSE, -+ max_load_average_)) { -+ delete tokens_; -+ tokens_ = NULL; -+ } -+ } + #endif // NINJA_EXIT_STATUS_H_ +--- a/src/ninja.cc ++++ b/src/ninja.cc +@@ -1447,6 +1447,7 @@ int ReadFlags(int* argc, char*** argv, + // We want to run N jobs in parallel. For N = 0, INT_MAX + // is close enough to infinite for most sane builds. + config->parallelism = value > 0 ? value : INT_MAX; ++ config->parallelism_from_cmdline = true; + deferGuessParallelism.needGuess = false; + break; + } +--- a/src/subprocess-posix.cc ++++ b/src/subprocess-posix.cc +@@ -13,6 +13,7 @@ + // limitations under the License. + + #include "subprocess.h" ++#include "tokenpool.h" + + #include + #include +@@ -249,7 +250,7 @@ Subprocess *SubprocessSet::Add(const str } - RealCommandRunner::~RealCommandRunner() { -diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc -index 66d2c2c430..ce3e2c20a4 100644 + #ifdef USE_PPOLL +-bool SubprocessSet::DoWork() { ++bool SubprocessSet::DoWork(TokenPool* tokens) { + vector fds; + nfds_t nfds = 0; + +@@ -263,6 +264,12 @@ bool SubprocessSet::DoWork() { + ++nfds; + } + ++ if (tokens) { ++ pollfd pfd = { tokens->GetMonitorFd(), POLLIN | POLLPRI, 0 }; ++ fds.push_back(pfd); ++ ++nfds; ++ } ++ + interrupted_ = 0; + int ret = ppoll(&fds.front(), nfds, NULL, &old_mask_); + if (ret == -1) { +@@ -295,11 +302,20 @@ bool SubprocessSet::DoWork() { + ++i; + } + ++ if (tokens) { ++ pollfd *pfd = &fds[nfds - 1]; ++ if (pfd->fd >= 0) { ++ assert(pfd->fd == tokens->GetMonitorFd()); ++ if (pfd->revents != 0) ++ token_available_ = true; ++ } ++ } ++ + return IsInterrupted(); + } + + #else // !defined(USE_PPOLL) +-bool SubprocessSet::DoWork() { ++bool SubprocessSet::DoWork(TokenPool* tokens) { + fd_set set; + int nfds = 0; + FD_ZERO(&set); +@@ -314,6 +330,13 @@ bool SubprocessSet::DoWork() { + } + } + ++ if (tokens) { ++ int fd = tokens->GetMonitorFd(); ++ FD_SET(fd, &set); ++ if (nfds < fd+1) ++ nfds = fd+1; ++ } ++ + interrupted_ = 0; + int ret = pselect(nfds, &set, 0, 0, 0, &old_mask_); + if (ret == -1) { +@@ -342,6 +365,12 @@ bool SubprocessSet::DoWork() { + ++i; + } + ++ if (tokens) { ++ int fd = tokens->GetMonitorFd(); ++ if ((fd >= 0) && FD_ISSET(fd, &set)) ++ token_available_ = true; ++ } ++ + return IsInterrupted(); + } + #endif // !defined(USE_PPOLL) --- a/src/subprocess-win32.cc +++ b/src/subprocess-win32.cc @@ -13,6 +13,7 @@ @@ -2497,7 +886,13 @@ index 66d2c2c430..ce3e2c20a4 100644 #include #include -@@ -256,6 +257,9 @@ bool SubprocessSet::DoWork(struct TokenPool* tokens) { +@@ -251,11 +252,14 @@ Subprocess *SubprocessSet::Add(const str + return subprocess; + } + +-bool SubprocessSet::DoWork() { ++bool SubprocessSet::DoWork(TokenPool* tokens) { + DWORD bytes_read; Subprocess* subproc; OVERLAPPED* overlapped; @@ -2507,7 +902,7 @@ index 66d2c2c430..ce3e2c20a4 100644 if (!GetQueuedCompletionStatus(ioport_, &bytes_read, (PULONG_PTR)&subproc, &overlapped, INFINITE)) { if (GetLastError() != ERROR_BROKEN_PIPE) -@@ -266,6 +270,11 @@ bool SubprocessSet::DoWork(struct TokenPool* tokens) { +@@ -266,6 +270,11 @@ bool SubprocessSet::DoWork() { // delivered by NotifyInterrupted above. return true; @@ -2519,18 +914,58 @@ index 66d2c2c430..ce3e2c20a4 100644 subproc->OnPipeReady(); if (subproc->Done()) { -diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc -index 6264c8bf11..f625963462 100644 +--- a/src/subprocess.h ++++ b/src/subprocess.h +@@ -76,6 +76,8 @@ struct Subprocess { + friend struct SubprocessSet; + }; + ++struct TokenPool; ++ + /// SubprocessSet runs a ppoll/pselect() loop around a set of Subprocesses. + /// DoWork() waits for any state change in subprocesses; finished_ + /// is a queue of subprocesses as they finish. +@@ -84,13 +86,17 @@ struct SubprocessSet { + ~SubprocessSet(); + + Subprocess* Add(const std::string& command, bool use_console = false); +- bool DoWork(); ++ bool DoWork(TokenPool* tokens); + Subprocess* NextFinished(); + void Clear(); + + std::vector running_; + std::queue finished_; + ++ bool token_available_; ++ bool IsTokenAvailable() { return token_available_; } ++ void ResetTokenAvailable() { token_available_ = false; } ++ + #ifdef _WIN32 + static BOOL WINAPI NotifyInterrupted(DWORD dwCtrlType); + static HANDLE ioport_; --- a/src/subprocess_test.cc +++ b/src/subprocess_test.cc -@@ -40,9 +40,16 @@ struct TokenPoolTest : public TokenPool { - void Reserve() {} - void Release() {} - void Clear() {} -+ bool Setup(bool ignore_unused, bool verbose, double& max_load_average) { return false; } +@@ -13,6 +13,7 @@ + // limitations under the License. - #ifdef _WIN32 -- // @TODO + #include "subprocess.h" ++#include "tokenpool.h" + + #include "test.h" + +@@ -34,8 +35,30 @@ const char* kSimpleCommand = "cmd /c dir + const char* kSimpleCommand = "ls /"; + #endif + ++struct TestTokenPool : public TokenPool { ++ bool Acquire() { return false; } ++ void Reserve() {} ++ void Release() {} ++ void Clear() {} ++ bool Setup(bool ignore_unused, bool verbose, double& max_load_average) { return false; } ++ ++#ifdef _WIN32 + bool _token_available; + void WaitForTokenAvailability(HANDLE ioport) { + if (_token_available) @@ -2538,31 +973,197 @@ index 6264c8bf11..f625963462 100644 + PostQueuedCompletionStatus(ioport, 0, (ULONG_PTR) this, NULL); + } + bool TokenIsAvailable(ULONG_PTR key) { return key == (ULONG_PTR) this; } - #else - int _fd; - int GetMonitorFd() { return _fd; } -@@ -297,34 +304,48 @@ TEST_F(SubprocessTest, ReadStdin) { - } - #endif // _WIN32 ++#else ++ int _fd; ++ int GetMonitorFd() { return _fd; } ++#endif ++}; ++ + struct SubprocessTest : public testing::Test { + SubprocessSet subprocs_; ++ TestTokenPool tokens_; + }; --// @TODO: remove once TokenPool implementation for Windows is available --#ifndef _WIN32 - TEST_F(SubprocessTest, TokenAvailable) { + } // anonymous namespace +@@ -45,10 +68,12 @@ TEST_F(SubprocessTest, BadCommandStderr) + Subprocess* subproc = subprocs_.Add("cmd /c ninja_no_such_command"); + ASSERT_NE((Subprocess *) 0, subproc); + ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { + // Pretend we discovered that stderr was ready for writing. +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + + EXPECT_EQ(ExitFailure, subproc->Finish()); + EXPECT_NE("", subproc->GetOutput()); +@@ -59,10 +84,12 @@ TEST_F(SubprocessTest, NoSuchCommand) { + Subprocess* subproc = subprocs_.Add("ninja_no_such_command"); + ASSERT_NE((Subprocess *) 0, subproc); + ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { + // Pretend we discovered that stderr was ready for writing. +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + + EXPECT_EQ(ExitFailure, subproc->Finish()); + EXPECT_NE("", subproc->GetOutput()); +@@ -78,9 +105,11 @@ TEST_F(SubprocessTest, InterruptChild) { + Subprocess* subproc = subprocs_.Add("kill -INT $$"); + ASSERT_NE((Subprocess *) 0, subproc); + ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + + EXPECT_EQ(ExitInterrupted, subproc->Finish()); + } +@@ -90,7 +119,7 @@ TEST_F(SubprocessTest, InterruptParent) + ASSERT_NE((Subprocess *) 0, subproc); + + while (!subproc->Done()) { +- bool interrupted = subprocs_.DoWork(); ++ bool interrupted = subprocs_.DoWork(NULL); + if (interrupted) + return; + } +@@ -102,9 +131,11 @@ TEST_F(SubprocessTest, InterruptChildWit + Subprocess* subproc = subprocs_.Add("kill -TERM $$"); + ASSERT_NE((Subprocess *) 0, subproc); + ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + + EXPECT_EQ(ExitInterrupted, subproc->Finish()); + } +@@ -114,7 +145,7 @@ TEST_F(SubprocessTest, InterruptParentWi + ASSERT_NE((Subprocess *) 0, subproc); + + while (!subproc->Done()) { +- bool interrupted = subprocs_.DoWork(); ++ bool interrupted = subprocs_.DoWork(NULL); + if (interrupted) + return; + } +@@ -126,9 +157,11 @@ TEST_F(SubprocessTest, InterruptChildWit + Subprocess* subproc = subprocs_.Add("kill -HUP $$"); + ASSERT_NE((Subprocess *) 0, subproc); + ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + + EXPECT_EQ(ExitInterrupted, subproc->Finish()); + } +@@ -138,7 +171,7 @@ TEST_F(SubprocessTest, InterruptParentWi + ASSERT_NE((Subprocess *) 0, subproc); + + while (!subproc->Done()) { +- bool interrupted = subprocs_.DoWork(); ++ bool interrupted = subprocs_.DoWork(NULL); + if (interrupted) + return; + } +@@ -153,9 +186,11 @@ TEST_F(SubprocessTest, Console) { + subprocs_.Add("test -t 0 -a -t 1 -a -t 2", /*use_console=*/true); + ASSERT_NE((Subprocess*)0, subproc); + ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + + EXPECT_EQ(ExitSuccess, subproc->Finish()); + } +@@ -167,9 +202,11 @@ TEST_F(SubprocessTest, SetWithSingle) { Subprocess* subproc = subprocs_.Add(kSimpleCommand); ASSERT_NE((Subprocess *) 0, subproc); - // simulate GNUmake jobserver pipe with 1 token ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + ASSERT_EQ(ExitSuccess, subproc->Finish()); + ASSERT_NE("", subproc->GetOutput()); + +@@ -200,12 +237,13 @@ TEST_F(SubprocessTest, SetWithMulti) { + ASSERT_EQ("", processes[i]->GetOutput()); + } + ++ subprocs_.ResetTokenAvailable(); + while (!processes[0]->Done() || !processes[1]->Done() || + !processes[2]->Done()) { + ASSERT_GT(subprocs_.running_.size(), 0u); +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } +- ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + ASSERT_EQ(0u, subprocs_.running_.size()); + ASSERT_EQ(3u, subprocs_.finished_.size()); + +@@ -237,8 +275,10 @@ TEST_F(SubprocessTest, SetWithLots) { + ASSERT_NE((Subprocess *) 0, subproc); + procs.push_back(subproc); + } ++ subprocs_.ResetTokenAvailable(); + while (!subprocs_.running_.empty()) +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + for (size_t i = 0; i < procs.size(); ++i) { + ASSERT_EQ(ExitSuccess, procs[i]->Finish()); + ASSERT_NE("", procs[i]->GetOutput()); +@@ -254,10 +294,91 @@ TEST_F(SubprocessTest, SetWithLots) { + // that stdin is closed. + TEST_F(SubprocessTest, ReadStdin) { + Subprocess* subproc = subprocs_.Add("cat -"); ++ subprocs_.ResetTokenAvailable(); + while (!subproc->Done()) { +- subprocs_.DoWork(); ++ subprocs_.DoWork(NULL); + } ++ ASSERT_FALSE(subprocs_.IsTokenAvailable()); + ASSERT_EQ(ExitSuccess, subproc->Finish()); + ASSERT_EQ(1u, subprocs_.finished_.size()); + } + #endif // _WIN32 ++ ++TEST_F(SubprocessTest, TokenAvailable) { ++ Subprocess* subproc = subprocs_.Add(kSimpleCommand); ++ ASSERT_NE((Subprocess *) 0, subproc); ++ ++ // simulate GNUmake jobserver pipe with 1 token +#ifdef _WIN32 + tokens_._token_available = true; +#else - int fds[2]; - ASSERT_EQ(0u, pipe(fds)); - tokens_._fd = fds[0]; - ASSERT_EQ(1u, write(fds[1], "T", 1)); ++ int fds[2]; ++ ASSERT_EQ(0u, pipe(fds)); ++ tokens_._fd = fds[0]; ++ ASSERT_EQ(1u, write(fds[1], "T", 1)); +#endif - - subprocs_.ResetTokenAvailable(); - subprocs_.DoWork(&tokens_); ++ ++ subprocs_.ResetTokenAvailable(); ++ subprocs_.DoWork(&tokens_); +#ifdef _WIN32 + tokens_._token_available = false; + // we need to loop here as we have no conrol where the token @@ -2571,62 +1172,63 @@ index 6264c8bf11..f625963462 100644 + subprocs_.DoWork(&tokens_); + } +#endif - - EXPECT_TRUE(subprocs_.IsTokenAvailable()); - EXPECT_EQ(0u, subprocs_.finished_.size()); - - // remove token to let DoWork() wait for command again ++ ++ EXPECT_TRUE(subprocs_.IsTokenAvailable()); ++ EXPECT_EQ(0u, subprocs_.finished_.size()); ++ ++ // remove token to let DoWork() wait for command again +#ifndef _WIN32 - char token; - ASSERT_EQ(1u, read(fds[0], &token, 1)); ++ char token; ++ ASSERT_EQ(1u, read(fds[0], &token, 1)); +#endif - - while (!subproc->Done()) { - subprocs_.DoWork(&tokens_); - } - ++ ++ while (!subproc->Done()) { ++ subprocs_.DoWork(&tokens_); ++ } ++ +#ifndef _WIN32 - close(fds[1]); - close(fds[0]); ++ close(fds[1]); ++ close(fds[0]); +#endif - - EXPECT_EQ(ExitSuccess, subproc->Finish()); - EXPECT_NE("", subproc->GetOutput()); -@@ -337,17 +358,23 @@ TEST_F(SubprocessTest, TokenNotAvailable) { - ASSERT_NE((Subprocess *) 0, subproc); - - // simulate GNUmake jobserver pipe with 0 tokens ++ ++ EXPECT_EQ(ExitSuccess, subproc->Finish()); ++ EXPECT_NE("", subproc->GetOutput()); ++ ++ EXPECT_EQ(1u, subprocs_.finished_.size()); ++} ++ ++TEST_F(SubprocessTest, TokenNotAvailable) { ++ Subprocess* subproc = subprocs_.Add(kSimpleCommand); ++ ASSERT_NE((Subprocess *) 0, subproc); ++ ++ // simulate GNUmake jobserver pipe with 0 tokens +#ifdef _WIN32 + tokens_._token_available = false; +#else - int fds[2]; - ASSERT_EQ(0u, pipe(fds)); - tokens_._fd = fds[0]; ++ int fds[2]; ++ ASSERT_EQ(0u, pipe(fds)); ++ tokens_._fd = fds[0]; +#endif - - subprocs_.ResetTokenAvailable(); - while (!subproc->Done()) { - subprocs_.DoWork(&tokens_); - } - ++ ++ subprocs_.ResetTokenAvailable(); ++ while (!subproc->Done()) { ++ subprocs_.DoWork(&tokens_); ++ } ++ +#ifndef _WIN32 - close(fds[1]); - close(fds[0]); ++ close(fds[1]); ++ close(fds[0]); +#endif - - EXPECT_FALSE(subprocs_.IsTokenAvailable()); - EXPECT_EQ(ExitSuccess, subproc->Finish()); -@@ -355,4 +382,3 @@ TEST_F(SubprocessTest, TokenNotAvailable) { - - EXPECT_EQ(1u, subprocs_.finished_.size()); - } --#endif // _WIN32 -diff --git a/src/tokenpool-gnu-make-posix.cc b/src/tokenpool-gnu-make-posix.cc -new file mode 100644 -index 0000000000..70d84bfff7 ++ ++ EXPECT_FALSE(subprocs_.IsTokenAvailable()); ++ EXPECT_EQ(ExitSuccess, subproc->Finish()); ++ EXPECT_NE("", subproc->GetOutput()); ++ ++ EXPECT_EQ(1u, subprocs_.finished_.size()); ++} --- /dev/null +++ b/src/tokenpool-gnu-make-posix.cc -@@ -0,0 +1,203 @@ +@@ -0,0 +1,202 @@ +// Copyright 2016-2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); @@ -2661,8 +1263,8 @@ index 0000000000..70d84bfff7 + + virtual int GetMonitorFd(); + -+ virtual const char *GetEnv(const char *name) { return getenv(name); }; -+ virtual bool ParseAuth(const char *jobserver); ++ virtual const char* GetEnv(const char* name) { return getenv(name); }; ++ virtual bool ParseAuth(const char* jobserver); + virtual bool AcquireToken(); + virtual bool ReturnToken(); + @@ -2711,14 +1313,13 @@ index 0000000000..70d84bfff7 + act.sa_handler = CloseDupRfd; + if (sigaction(SIGALRM, &act, &old_act_) < 0) { + perror("sigaction:"); -+ return(false); -+ } else { -+ restore_ = true; -+ return(true); ++ return false; + } ++ restore_ = true; ++ return true; +} + -+bool GNUmakeTokenPoolPosix::ParseAuth(const char *jobserver) { ++bool GNUmakeTokenPoolPosix::ParseAuth(const char* jobserver) { + int rfd = -1; + int wfd = -1; + if ((sscanf(jobserver, "%*[^=]=%d,%d", &rfd, &wfd) == 2) && @@ -2824,18 +1425,15 @@ index 0000000000..70d84bfff7 +} + +int GNUmakeTokenPoolPosix::GetMonitorFd() { -+ return(rfd_); ++ return rfd_; +} + -+struct TokenPool *TokenPool::Get() { ++TokenPool* TokenPool::Get() { + return new GNUmakeTokenPoolPosix; +} -diff --git a/src/tokenpool-gnu-make-win32.cc b/src/tokenpool-gnu-make-win32.cc -new file mode 100644 -index 0000000000..2719f2c1fc --- /dev/null +++ b/src/tokenpool-gnu-make-win32.cc -@@ -0,0 +1,237 @@ +@@ -0,0 +1,239 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); @@ -2852,7 +1450,8 @@ index 0000000000..2719f2c1fc + +#include "tokenpool-gnu-make.h" + -+// always include first to make sure other headers do the correct thing... ++// Always include this first. ++// Otherwise the other system headers don't work correctly under Win32 +#include + +#include @@ -2870,8 +1469,8 @@ index 0000000000..2719f2c1fc + virtual void WaitForTokenAvailability(HANDLE ioport); + virtual bool TokenIsAvailable(ULONG_PTR key); + -+ virtual const char *GetEnv(const char *name); -+ virtual bool ParseAuth(const char *jobserver); ++ virtual const char* GetEnv(const char* name); ++ virtual bool ParseAuth(const char* jobserver); + virtual bool AcquireToken(); + virtual bool ReturnToken(); + @@ -2936,19 +1535,19 @@ index 0000000000..2719f2c1fc + } +} + -+const char *GNUmakeTokenPoolWin32::GetEnv(const char *name) { ++const char* GNUmakeTokenPoolWin32::GetEnv(const char* name) { + // getenv() does not work correctly together with tokenpool_tests.cc + static char buffer[MAX_PATH + 1]; -+ if (GetEnvironmentVariable("MAKEFLAGS", buffer, sizeof(buffer)) == 0) ++ if (GetEnvironmentVariable(name, buffer, sizeof(buffer)) == 0) + return NULL; -+ return(buffer); ++ return buffer; +} + -+bool GNUmakeTokenPoolWin32::ParseAuth(const char *jobserver) { ++bool GNUmakeTokenPoolWin32::ParseAuth(const char* jobserver) { + // match "--jobserver-auth=gmake_semaphore_..." -+ const char *start = strchr(jobserver, '='); ++ const char* start = strchr(jobserver, '='); + if (start) { -+ const char *end = start; ++ const char* end = start; + unsigned int len; + char c, *auth; + @@ -2957,14 +1556,15 @@ index 0000000000..2719f2c1fc + break; + len = end - start; // includes string terminator in count + -+ if ((len > 1) && ((auth = (char *)malloc(len)) != NULL)) { ++ if ((len > 1) && ((auth = (char*)malloc(len)) != NULL)) { + strncpy(auth, start + 1, len - 1); + auth[len - 1] = '\0'; + -+ if ((semaphore_jobserver_ = OpenSemaphore(SEMAPHORE_ALL_ACCESS, /* Semaphore access setting */ -+ FALSE, /* Child processes DON'T inherit */ -+ auth /* Semaphore name */ -+ )) != NULL) { ++ if ((semaphore_jobserver_ = ++ OpenSemaphore(SEMAPHORE_ALL_ACCESS, /* Semaphore access setting */ ++ FALSE, /* Child processes DON'T inherit */ ++ auth /* Semaphore name */ ++ )) != NULL) { + free(auth); + return true; + } @@ -3009,7 +1609,7 @@ index 0000000000..2719f2c1fc +} + +DWORD WINAPI GNUmakeTokenPoolWin32::SemaphoreThreadWrapper(LPVOID param) { -+ GNUmakeTokenPoolWin32 *This = (GNUmakeTokenPoolWin32 *) param; ++ GNUmakeTokenPoolWin32* This = (GNUmakeTokenPoolWin32*) param; + return This->SemaphoreThread(); +} + @@ -3054,7 +1654,7 @@ index 0000000000..2719f2c1fc + +bool GNUmakeTokenPoolWin32::TokenIsAvailable(ULONG_PTR key) { + // alert child thread to break wait on token semaphore -+ QueueUserAPC(&NoopAPCFunc, child_, (ULONG_PTR)NULL); ++ QueueUserAPC((PAPCFUNC)&NoopAPCFunc, child_, (ULONG_PTR)NULL); + + // return true when GetQueuedCompletionStatus() returned our key + return key == (ULONG_PTR) this; @@ -3070,273 +1670,120 @@ index 0000000000..2719f2c1fc + Win32Fatal("WaitForSingleObject"); +} + -+struct TokenPool *TokenPool::Get() { ++TokenPool* TokenPool::Get() { + return new GNUmakeTokenPoolWin32; +} -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -index 4132bb06d9..92ff611721 100644 ---- a/src/tokenpool-gnu-make.cc +--- /dev/null +++ b/src/tokenpool-gnu-make.cc -@@ -12,101 +12,26 @@ - // See the License for the specific language governing permissions and - // limitations under the License. - --#include "tokenpool.h" +@@ -0,0 +1,108 @@ ++// Copyright 2016-2018 Google Inc. All Rights Reserved. ++// ++// Licensed under the Apache License, Version 2.0 (the "License"); ++// you may not use this file except in compliance with the License. ++// You may obtain a copy of the License at ++// ++// http://www.apache.org/licenses/LICENSE-2.0 ++// ++// Unless required by applicable law or agreed to in writing, software ++// distributed under the License is distributed on an "AS IS" BASIS, ++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++// See the License for the specific language governing permissions and ++// limitations under the License. ++ +#include "tokenpool-gnu-make.h" - --#include --#include --#include --#include --#include --#include ++ +#include - #include - #include --#include - - #include "line_printer.h" - --// TokenPool implementation for GNU make jobserver --// (http://make.mad-scientist.net/papers/jobserver-implementation/) --struct GNUmakeTokenPool : public TokenPool { -- GNUmakeTokenPool(); -- virtual ~GNUmakeTokenPool(); -- -- virtual bool Acquire(); -- virtual void Reserve(); -- virtual void Release(); -- virtual void Clear(); -- virtual int GetMonitorFd(); -- -- bool Setup(bool ignore, bool verbose, double& max_load_average); -- -- private: -- int available_; -- int used_; -- --#ifdef _WIN32 -- // @TODO --#else -- int rfd_; -- int wfd_; -- -- struct sigaction old_act_; -- bool restore_; -- -- static int dup_rfd_; -- static void CloseDupRfd(int signum); -- -- bool CheckFd(int fd); -- bool SetAlarmHandler(); --#endif -- -- void Return(); --}; -- ++#include ++#include ++ ++#include "line_printer.h" ++ +// TokenPool implementation for GNU make jobserver - common bits - // every instance owns an implicit token -> available_ == 1 --GNUmakeTokenPool::GNUmakeTokenPool() : available_(1), used_(0), -- rfd_(-1), wfd_(-1), restore_(false) { ++// every instance owns an implicit token -> available_ == 1 +GNUmakeTokenPool::GNUmakeTokenPool() : available_(1), used_(0) { - } - - GNUmakeTokenPool::~GNUmakeTokenPool() { -- Clear(); -- if (restore_) -- sigaction(SIGALRM, &old_act_, NULL); --} -- --bool GNUmakeTokenPool::CheckFd(int fd) { -- if (fd < 0) -- return false; -- int ret = fcntl(fd, F_GETFD); -- if (ret < 0) -- return false; -- return true; --} -- --int GNUmakeTokenPool::dup_rfd_ = -1; -- --void GNUmakeTokenPool::CloseDupRfd(int signum) { -- close(dup_rfd_); -- dup_rfd_ = -1; --} -- --bool GNUmakeTokenPool::SetAlarmHandler() { -- struct sigaction act; -- memset(&act, 0, sizeof(act)); -- act.sa_handler = CloseDupRfd; -- if (sigaction(SIGALRM, &act, &old_act_) < 0) { -- perror("sigaction:"); -- return(false); -- } else { -- restore_ = true; -- return(true); -- } - } - - bool GNUmakeTokenPool::Setup(bool ignore, - bool verbose, - double& max_load_average) { -- const char *value = getenv("MAKEFLAGS"); -+ const char *value = GetEnv("MAKEFLAGS"); - if (value) { - // GNU make <= 4.1 - const char *jobserver = strstr(value, "--jobserver-fds="); -@@ -119,20 +44,13 @@ bool GNUmakeTokenPool::Setup(bool ignore, - if (ignore) { - printer.PrintOnNewLine("ninja: warning: -jN forced on command line; ignoring GNU make jobserver.\n"); - } else { -- int rfd = -1; -- int wfd = -1; -- if ((sscanf(jobserver, "%*[^=]=%d,%d", &rfd, &wfd) == 2) && -- CheckFd(rfd) && -- CheckFd(wfd) && -- SetAlarmHandler()) { -+ if (ParseAuth(jobserver)) { - const char *l_arg = strstr(value, " -l"); - int load_limit = -1; - - if (verbose) { - printer.PrintOnNewLine("ninja: using GNU make jobserver.\n"); - } -- rfd_ = rfd; -- wfd_ = wfd; - - // translate GNU make -lN to ninja -lN - if (l_arg && -@@ -154,83 +72,14 @@ bool GNUmakeTokenPool::Acquire() { - if (available_ > 0) - return true; - -- // Please read -- // -- // http://make.mad-scientist.net/papers/jobserver-implementation/ -- // -- // for the reasoning behind the following code. -- // -- // Try to read one character from the pipe. Returns true on success. -- // -- // First check if read() would succeed without blocking. --#ifdef USE_PPOLL -- pollfd pollfds[] = {{rfd_, POLLIN, 0}}; -- int ret = poll(pollfds, 1, 0); --#else -- fd_set set; -- struct timeval timeout = { 0, 0 }; -- FD_ZERO(&set); -- FD_SET(rfd_, &set); -- int ret = select(rfd_ + 1, &set, NULL, NULL, &timeout); --#endif -- if (ret > 0) { -- // Handle potential race condition: -- // - the above check succeeded, i.e. read() should not block -- // - the character disappears before we call read() -- // -- // Create a duplicate of rfd_. The duplicate file descriptor dup_rfd_ -- // can safely be closed by signal handlers without affecting rfd_. -- dup_rfd_ = dup(rfd_); -- -- if (dup_rfd_ != -1) { -- struct sigaction act, old_act; -- int ret = 0; -- -- // Temporarily replace SIGCHLD handler with our own -- memset(&act, 0, sizeof(act)); -- act.sa_handler = CloseDupRfd; -- if (sigaction(SIGCHLD, &act, &old_act) == 0) { -- struct itimerval timeout; -- -- // install a 100ms timeout that generates SIGALARM on expiration -- memset(&timeout, 0, sizeof(timeout)); -- timeout.it_value.tv_usec = 100 * 1000; // [ms] -> [usec] -- if (setitimer(ITIMER_REAL, &timeout, NULL) == 0) { -- char buf; -- -- // Now try to read() from dup_rfd_. Return values from read(): -- // -- // 1. token read -> 1 -- // 2. pipe closed -> 0 -- // 3. alarm expires -> -1 (EINTR) -- // 4. child exits -> -1 (EINTR) -- // 5. alarm expired before entering read() -> -1 (EBADF) -- // 6. child exited before entering read() -> -1 (EBADF) -- // 7. child exited before handler is installed -> go to 1 - 3 -- ret = read(dup_rfd_, &buf, 1); -- -- // disarm timer -- memset(&timeout, 0, sizeof(timeout)); -- setitimer(ITIMER_REAL, &timeout, NULL); -- } -- -- sigaction(SIGCHLD, &old_act, NULL); -- } -- -- CloseDupRfd(0); -- -- // Case 1 from above list -- if (ret > 0) { -- available_++; -- return true; -- } -- } ++} ++ ++GNUmakeTokenPool::~GNUmakeTokenPool() { ++} ++ ++bool GNUmakeTokenPool::Setup(bool ignore, ++ bool verbose, ++ double& max_load_average) { ++ const char* value = GetEnv("MAKEFLAGS"); ++ if (!value) ++ return false; ++ ++ // GNU make <= 4.1 ++ const char* jobserver = strstr(value, "--jobserver-fds="); ++ if (!jobserver) ++ // GNU make => 4.2 ++ jobserver = strstr(value, "--jobserver-auth="); ++ if (jobserver) { ++ LinePrinter printer; ++ ++ if (ignore) { ++ printer.PrintOnNewLine("ninja: warning: -jN forced on command line; ignoring GNU make jobserver.\n"); ++ } else { ++ if (ParseAuth(jobserver)) { ++ const char* l_arg = strstr(value, " -l"); ++ int load_limit = -1; ++ ++ if (verbose) { ++ printer.PrintOnNewLine("ninja: using GNU make jobserver.\n"); ++ } ++ ++ // translate GNU make -lN to ninja -lN ++ if (l_arg && ++ (sscanf(l_arg + 3, "%d ", &load_limit) == 1) && ++ (load_limit > 0)) { ++ max_load_average = load_limit; ++ } ++ ++ return true; ++ } ++ } ++ } ++ ++ return false; ++} ++ ++bool GNUmakeTokenPool::Acquire() { ++ if (available_ > 0) ++ return true; ++ + if (AcquireToken()) { + // token acquired + available_++; + return true; -+ } else { -+ // no token available -+ return false; - } -- -- // read() would block, i.e. no token available, -- // cases 2-6 from above list or -- // select() / poll() / dup() / sigaction() / setitimer() failed -- return false; - } - - void GNUmakeTokenPool::Reserve() { -@@ -239,15 +88,8 @@ void GNUmakeTokenPool::Reserve() { - } - - void GNUmakeTokenPool::Return() { -- const char buf = '+'; -- while (1) { -- int ret = write(wfd_, &buf, 1); -- if (ret > 0) -- available_--; -- if ((ret != -1) || (errno != EINTR)) -- return; -- // write got interrupted - retry -- } ++ } ++ ++ // no token available ++ return false; ++} ++ ++void GNUmakeTokenPool::Reserve() { ++ available_--; ++ used_++; ++} ++ ++void GNUmakeTokenPool::Return() { + if (ReturnToken()) + available_--; - } - - void GNUmakeTokenPool::Release() { -@@ -263,18 +105,3 @@ void GNUmakeTokenPool::Clear() { - while (available_ > 1) - Return(); - } -- --int GNUmakeTokenPool::GetMonitorFd() { -- return(rfd_); --} -- --struct TokenPool *TokenPool::Get(bool ignore, -- bool verbose, -- double& max_load_average) { -- GNUmakeTokenPool *tokenpool = new GNUmakeTokenPool; -- if (tokenpool->Setup(ignore, verbose, max_load_average)) -- return tokenpool; -- else -- delete tokenpool; -- return NULL; --} -diff --git a/src/tokenpool-gnu-make.h b/src/tokenpool-gnu-make.h -new file mode 100644 -index 0000000000..d3852088e2 ++} ++ ++void GNUmakeTokenPool::Release() { ++ available_++; ++ used_--; ++ if (available_ > 1) ++ Return(); ++} ++ ++void GNUmakeTokenPool::Clear() { ++ while (used_ > 0) ++ Release(); ++ while (available_ > 1) ++ Return(); ++} --- /dev/null +++ b/src/tokenpool-gnu-make.h @@ -0,0 +1,40 @@ @@ -3359,7 +1806,7 @@ index 0000000000..d3852088e2 +// interface to GNU make token pool +struct GNUmakeTokenPool : public TokenPool { + GNUmakeTokenPool(); -+ virtual ~GNUmakeTokenPool(); ++ ~GNUmakeTokenPool(); + + // token pool implementation + virtual bool Acquire(); @@ -3369,8 +1816,8 @@ index 0000000000..d3852088e2 + virtual bool Setup(bool ignore, bool verbose, double& max_load_average); + + // platform specific implementation -+ virtual const char *GetEnv(const char *name) = 0; -+ virtual bool ParseAuth(const char *jobserver) = 0; ++ virtual const char* GetEnv(const char* name) = 0; ++ virtual bool ParseAuth(const char* jobserver) = 0; + virtual bool AcquireToken() = 0; + virtual bool ReturnToken() = 0; + @@ -3380,83 +1827,81 @@ index 0000000000..d3852088e2 + + void Return(); +}; -diff --git a/src/tokenpool-none.cc b/src/tokenpool-none.cc -index 4c592875b4..613d16882d 100644 ---- a/src/tokenpool-none.cc -+++ b/src/tokenpool-none.cc -@@ -17,8 +17,6 @@ - #include - - // No-op TokenPool implementation --struct TokenPool *TokenPool::Get(bool ignore, -- bool verbose, -- double& max_load_average) { -+struct TokenPool *TokenPool::Get() { - return NULL; - } -diff --git a/src/tokenpool.h b/src/tokenpool.h -index 4bf477f20c..1be8e1d5ce 100644 ---- a/src/tokenpool.h +--- /dev/null +++ b/src/tokenpool.h -@@ -1,4 +1,4 @@ --// Copyright 2016-2017 Google Inc. All Rights Reserved. +@@ -0,0 +1,42 @@ +// Copyright 2016-2018 Google Inc. All Rights Reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. -@@ -12,6 +12,10 @@ - // See the License for the specific language governing permissions and - // limitations under the License. - ++// ++// Licensed under the Apache License, Version 2.0 (the "License"); ++// you may not use this file except in compliance with the License. ++// You may obtain a copy of the License at ++// ++// http://www.apache.org/licenses/LICENSE-2.0 ++// ++// Unless required by applicable law or agreed to in writing, software ++// distributed under the License is distributed on an "AS IS" BASIS, ++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++// See the License for the specific language governing permissions and ++// limitations under the License. ++ +#ifdef _WIN32 +#include +#endif + - // interface to token pool - struct TokenPool { - virtual ~TokenPool() {} -@@ -21,14 +25,18 @@ struct TokenPool { - virtual void Release() = 0; - virtual void Clear() = 0; - ++// interface to token pool ++struct TokenPool { ++ virtual ~TokenPool() {} ++ ++ virtual bool Acquire() = 0; ++ virtual void Reserve() = 0; ++ virtual void Release() = 0; ++ virtual void Clear() = 0; ++ + // returns false if token pool setup failed + virtual bool Setup(bool ignore, bool verbose, double& max_load_average) = 0; + - #ifdef _WIN32 -- // @TODO ++#ifdef _WIN32 + virtual void WaitForTokenAvailability(HANDLE ioport) = 0; + // returns true if a token has become available + // key is result from GetQueuedCompletionStatus() + virtual bool TokenIsAvailable(ULONG_PTR key) = 0; - #else - virtual int GetMonitorFd() = 0; - #endif - - // returns NULL if token pool is not available -- static struct TokenPool *Get(bool ignore, -- bool verbose, -- double& max_load_average); -+ static struct TokenPool *Get(); - }; -diff --git a/src/tokenpool_test.cc b/src/tokenpool_test.cc -index 6c89064ca4..8d4fd7d33a 100644 ---- a/src/tokenpool_test.cc ++#else ++ virtual int GetMonitorFd() = 0; ++#endif ++ ++ // returns NULL if token pool is not available ++ static TokenPool* Get(); ++}; +--- /dev/null +++ b/src/tokenpool_test.cc -@@ -16,13 +16,25 @@ - - #include "test.h" - --#ifndef _WIN32 +@@ -0,0 +1,269 @@ ++// Copyright 2018 Google Inc. All Rights Reserved. ++// ++// Licensed under the Apache License, Version 2.0 (the "License"); ++// you may not use this file except in compliance with the License. ++// You may obtain a copy of the License at ++// ++// http://www.apache.org/licenses/LICENSE-2.0 ++// ++// Unless required by applicable law or agreed to in writing, software ++// distributed under the License is distributed on an "AS IS" BASIS, ++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++// See the License for the specific language governing permissions and ++// limitations under the License. ++ ++#include "tokenpool.h" ++ ++#include "test.h" ++ +#ifdef _WIN32 +#include +#else +#include +#endif + - #include - #include --#include - ++#include ++#include ++ +#ifdef _WIN32 +// should contain all valid characters +#define SEMAPHORE_NAME "abcdefghijklmnopqrstwxyz01234567890_" @@ -3465,45 +1910,40 @@ index 6c89064ca4..8d4fd7d33a 100644 +#define ENVIRONMENT_INIT(v) SetEnvironmentVariable("MAKEFLAGS", v) +#else +#define AUTH_FORMAT(tmpl) "foo " tmpl "=%d,%d bar" - #define ENVIRONMENT_CLEAR() unsetenv("MAKEFLAGS") --#define ENVIRONMENT_INIT(v) setenv("MAKEFLAGS", v, true); ++#define ENVIRONMENT_CLEAR() unsetenv("MAKEFLAGS") +#define ENVIRONMENT_INIT(v) setenv("MAKEFLAGS", v, true) - #endif - - namespace { -@@ -32,43 +44,60 @@ const double kLoadAverageDefault = -1.23456789; - struct TokenPoolTest : public testing::Test { - double load_avg_; - TokenPool *tokens_; --#ifndef _WIN32 - char buf_[1024]; ++#endif ++ ++namespace { ++ ++const double kLoadAverageDefault = -1.23456789; ++ ++struct TokenPoolTest : public testing::Test { ++ double load_avg_; ++ TokenPool* tokens_; ++ char buf_[1024]; +#ifdef _WIN32 -+ const char *semaphore_name_; ++ const char* semaphore_name_; + HANDLE semaphore_; +#else - int fds_[2]; - #endif - - virtual void SetUp() { - load_avg_ = kLoadAverageDefault; - tokens_ = NULL; --#ifndef _WIN32 - ENVIRONMENT_CLEAR(); ++ int fds_[2]; ++#endif ++ ++ virtual void SetUp() { ++ load_avg_ = kLoadAverageDefault; ++ tokens_ = NULL; ++ ENVIRONMENT_CLEAR(); +#ifdef _WIN32 + semaphore_name_ = SEMAPHORE_NAME; + if ((semaphore_ = CreateSemaphore(0, 0, 2, SEMAPHORE_NAME)) == NULL) +#else - if (pipe(fds_) < 0) -- ASSERT_TRUE(false); - #endif ++ if (pipe(fds_) < 0) ++#endif + ASSERT_TRUE(false); - } - -- void CreatePool(const char *format, bool ignore_jobserver) { --#ifndef _WIN32 -+ void CreatePool(const char *format, bool ignore_jobserver = false) { - if (format) { -- sprintf(buf_, format, fds_[0], fds_[1]); ++ } ++ ++ void CreatePool(const char* format, bool ignore_jobserver = false) { ++ if (format) { + sprintf(buf_, format, +#ifdef _WIN32 + semaphore_name_ @@ -3511,69 +1951,73 @@ index 6c89064ca4..8d4fd7d33a 100644 + fds_[0], fds_[1] +#endif + ); - ENVIRONMENT_INIT(buf_); - } --#endif -- tokens_ = TokenPool::Get(ignore_jobserver, false, load_avg_); ++ ENVIRONMENT_INIT(buf_); ++ } + if ((tokens_ = TokenPool::Get()) != NULL) { + if (!tokens_->Setup(ignore_jobserver, false, load_avg_)) { + delete tokens_; + tokens_ = NULL; + } + } - } - - void CreateDefaultPool() { -- CreatePool("foo --jobserver-auth=%d,%d bar", false); ++ } ++ ++ void CreateDefaultPool() { + CreatePool(AUTH_FORMAT("--jobserver-auth")); - } - - virtual void TearDown() { - if (tokens_) - delete tokens_; --#ifndef _WIN32 ++ } ++ ++ virtual void TearDown() { ++ if (tokens_) ++ delete tokens_; +#ifdef _WIN32 + CloseHandle(semaphore_); +#else - close(fds_[0]); - close(fds_[1]); -- ENVIRONMENT_CLEAR(); - #endif ++ close(fds_[0]); ++ close(fds_[1]); ++#endif + ENVIRONMENT_CLEAR(); - } - }; - -@@ -82,10 +111,9 @@ TEST_F(TokenPoolTest, NoTokenPool) { - EXPECT_EQ(kLoadAverageDefault, load_avg_); - } - --#ifndef _WIN32 - TEST_F(TokenPoolTest, SuccessfulOldSetup) { - // GNUmake <= 4.1 -- CreatePool("foo --jobserver-fds=%d,%d bar", false); ++ } ++}; ++ ++} // anonymous namespace ++ ++// verifies none implementation ++TEST_F(TokenPoolTest, NoTokenPool) { ++ CreatePool(NULL, false); ++ ++ EXPECT_EQ(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++} ++ ++TEST_F(TokenPoolTest, SuccessfulOldSetup) { ++ // GNUmake <= 4.1 + CreatePool(AUTH_FORMAT("--jobserver-fds")); - - EXPECT_NE(NULL, tokens_); - EXPECT_EQ(kLoadAverageDefault, load_avg_); -@@ -100,19 +128,37 @@ TEST_F(TokenPoolTest, SuccessfulNewSetup) { - } - - TEST_F(TokenPoolTest, IgnoreWithJN) { -- CreatePool("foo --jobserver-auth=%d,%d bar", true); ++ ++ EXPECT_NE(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++} ++ ++TEST_F(TokenPoolTest, SuccessfulNewSetup) { ++ // GNUmake => 4.2 ++ CreateDefaultPool(); ++ ++ EXPECT_NE(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++} ++ ++TEST_F(TokenPoolTest, IgnoreWithJN) { + CreatePool(AUTH_FORMAT("--jobserver-auth"), true); - - EXPECT_EQ(NULL, tokens_); - EXPECT_EQ(kLoadAverageDefault, load_avg_); - } - - TEST_F(TokenPoolTest, HonorLN) { -- CreatePool("foo -l9 --jobserver-auth=%d,%d bar", false); ++ ++ EXPECT_EQ(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++} ++ ++TEST_F(TokenPoolTest, HonorLN) { + CreatePool(AUTH_FORMAT("-l9 --jobserver-auth")); - - EXPECT_NE(NULL, tokens_); - EXPECT_EQ(9.0, load_avg_); - } - ++ ++ EXPECT_NE(NULL, tokens_); ++ EXPECT_EQ(9.0, load_avg_); ++} ++ +#ifdef _WIN32 +TEST_F(TokenPoolTest, SemaphoreNotFound) { + semaphore_name_ = SEMAPHORE_NAME "_foobar"; @@ -3592,66 +2036,101 @@ index 6c89064ca4..8d4fd7d33a 100644 + EXPECT_TRUE(tokens_->TokenIsAvailable((ULONG_PTR)tokens_)); +} +#else - TEST_F(TokenPoolTest, MonitorFD) { - CreateDefaultPool(); - -@@ -121,6 +167,7 @@ TEST_F(TokenPoolTest, MonitorFD) { - - EXPECT_EQ(fds_[0], tokens_->GetMonitorFd()); - } ++TEST_F(TokenPoolTest, MonitorFD) { ++ CreateDefaultPool(); ++ ++ ASSERT_NE(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++ ++ EXPECT_EQ(fds_[0], tokens_->GetMonitorFd()); ++} +#endif - - TEST_F(TokenPoolTest, ImplicitToken) { - CreateDefaultPool(); -@@ -147,7 +194,13 @@ TEST_F(TokenPoolTest, TwoTokens) { - EXPECT_FALSE(tokens_->Acquire()); - - // jobserver offers 2nd token ++ ++TEST_F(TokenPoolTest, ImplicitToken) { ++ CreateDefaultPool(); ++ ++ ASSERT_NE(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++ ++ EXPECT_TRUE(tokens_->Acquire()); ++ tokens_->Reserve(); ++ EXPECT_FALSE(tokens_->Acquire()); ++ tokens_->Release(); ++ EXPECT_TRUE(tokens_->Acquire()); ++} ++ ++TEST_F(TokenPoolTest, TwoTokens) { ++ CreateDefaultPool(); ++ ++ ASSERT_NE(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++ ++ // implicit token ++ EXPECT_TRUE(tokens_->Acquire()); ++ tokens_->Reserve(); ++ EXPECT_FALSE(tokens_->Acquire()); ++ ++ // jobserver offers 2nd token +#ifdef _WIN32 + LONG previous; + ASSERT_TRUE(ReleaseSemaphore(semaphore_, 1, &previous)); + ASSERT_EQ(0, previous); +#else - ASSERT_EQ(1u, write(fds_[1], "T", 1)); ++ ASSERT_EQ(1u, write(fds_[1], "T", 1)); +#endif - EXPECT_TRUE(tokens_->Acquire()); - tokens_->Reserve(); - EXPECT_FALSE(tokens_->Acquire()); -@@ -160,8 +213,14 @@ TEST_F(TokenPoolTest, TwoTokens) { - tokens_->Release(); - EXPECT_TRUE(tokens_->Acquire()); - -- // there must be one token in the pipe ++ EXPECT_TRUE(tokens_->Acquire()); ++ tokens_->Reserve(); ++ EXPECT_FALSE(tokens_->Acquire()); ++ ++ // release 2nd token ++ tokens_->Release(); ++ EXPECT_TRUE(tokens_->Acquire()); ++ ++ // release implict token - must return 2nd token back to jobserver ++ tokens_->Release(); ++ EXPECT_TRUE(tokens_->Acquire()); ++ + // there must be one token available +#ifdef _WIN32 + EXPECT_EQ(WAIT_OBJECT_0, WaitForSingleObject(semaphore_, 0)); + EXPECT_TRUE(ReleaseSemaphore(semaphore_, 1, &previous)); + EXPECT_EQ(0, previous); +#else - EXPECT_EQ(1u, read(fds_[0], buf_, sizeof(buf_))); ++ EXPECT_EQ(1u, read(fds_[0], buf_, sizeof(buf_))); +#endif - - // implicit token - EXPECT_TRUE(tokens_->Acquire()); -@@ -179,7 +238,13 @@ TEST_F(TokenPoolTest, Clear) { - EXPECT_FALSE(tokens_->Acquire()); - - // jobserver offers 2nd & 3rd token ++ ++ // implicit token ++ EXPECT_TRUE(tokens_->Acquire()); ++} ++ ++TEST_F(TokenPoolTest, Clear) { ++ CreateDefaultPool(); ++ ++ ASSERT_NE(NULL, tokens_); ++ EXPECT_EQ(kLoadAverageDefault, load_avg_); ++ ++ // implicit token ++ EXPECT_TRUE(tokens_->Acquire()); ++ tokens_->Reserve(); ++ EXPECT_FALSE(tokens_->Acquire()); ++ ++ // jobserver offers 2nd & 3rd token +#ifdef _WIN32 + LONG previous; + ASSERT_TRUE(ReleaseSemaphore(semaphore_, 2, &previous)); + ASSERT_EQ(0, previous); +#else - ASSERT_EQ(2u, write(fds_[1], "TT", 2)); ++ ASSERT_EQ(2u, write(fds_[1], "TT", 2)); +#endif - EXPECT_TRUE(tokens_->Acquire()); - tokens_->Reserve(); - EXPECT_TRUE(tokens_->Acquire()); -@@ -189,10 +254,16 @@ TEST_F(TokenPoolTest, Clear) { - tokens_->Clear(); - EXPECT_TRUE(tokens_->Acquire()); - -- // there must be two tokens in the pipe ++ EXPECT_TRUE(tokens_->Acquire()); ++ tokens_->Reserve(); ++ EXPECT_TRUE(tokens_->Acquire()); ++ tokens_->Reserve(); ++ EXPECT_FALSE(tokens_->Acquire()); ++ ++ tokens_->Clear(); ++ EXPECT_TRUE(tokens_->Acquire()); ++ + // there must be two tokens available +#ifdef _WIN32 + EXPECT_EQ(WAIT_OBJECT_0, WaitForSingleObject(semaphore_, 0)); @@ -3659,632 +2138,20 @@ index 6c89064ca4..8d4fd7d33a 100644 + EXPECT_TRUE(ReleaseSemaphore(semaphore_, 2, &previous)); + EXPECT_EQ(0, previous); +#else - EXPECT_EQ(2u, read(fds_[0], buf_, sizeof(buf_))); ++ EXPECT_EQ(2u, read(fds_[0], buf_, sizeof(buf_))); +#endif - - // implicit token - EXPECT_TRUE(tokens_->Acquire()); - } --#endif - -From 2b9c81c0ec1226d8795e7725529f13be41eaa385 Mon Sep 17 00:00:00 2001 -From: Stefan Becker -Date: Fri, 14 Dec 2018 13:27:11 +0200 -Subject: [PATCH 11/11] Prepare PR for merging - part II - -- remove unnecessary "struct" from TokenPool -- add PAPCFUNC cast to QueryUserAPC() -- remove hard-coded MAKEFLAGS string from win32 -- remove useless build test CompleteNoWork -- rename TokenPoolTest to TestTokenPool -- add tokenpool modules to CMake build -- remove unused no-op TokenPool implementation -- fix errors flagged by codespell & clang-tidy -- address review comments from - -https://github.com/ninja-build/ninja/pull/1140#pullrequestreview-195195803 -https://github.com/ninja-build/ninja/pull/1140#pullrequestreview-185089255 -https://github.com/ninja-build/ninja/pull/1140#issuecomment-473898963 -https://github.com/ninja-build/ninja/pull/1140#issuecomment-596624610 ---- - CMakeLists.txt | 8 ++++- - src/build.cc | 2 +- - src/build_test.cc | 12 +------ - src/subprocess-posix.cc | 4 +-- - src/subprocess-win32.cc | 2 +- - src/subprocess.h | 2 +- - src/subprocess_test.cc | 26 +++++++------- - src/tokenpool-gnu-make-posix.cc | 21 +++++------ - src/tokenpool-gnu-make-win32.cc | 36 ++++++++++--------- - src/tokenpool-gnu-make.cc | 63 +++++++++++++++++---------------- - src/tokenpool-gnu-make.h | 6 ++-- - src/tokenpool-none.cc | 22 ------------ - src/tokenpool.h | 2 +- - src/tokenpool_test.cc | 8 ++--- - 14 files changed, 94 insertions(+), 120 deletions(-) - delete mode 100644 src/tokenpool-none.cc - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 57ae548f5b..e2876fe413 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -112,6 +112,7 @@ add_library(libninja OBJECT - src/state.cc - src/status.cc - src/string_piece_util.cc -+ src/tokenpool-gnu-make.cc - src/util.cc - src/version.cc - ) -@@ -123,9 +124,13 @@ if(WIN32) - src/msvc_helper_main-win32.cc - src/getopt.c - src/minidump-win32.cc -+ src/tokenpool-gnu-make-win32.cc - ) - else() -- target_sources(libninja PRIVATE src/subprocess-posix.cc) -+ target_sources(libninja PRIVATE -+ src/subprocess-posix.cc -+ src/tokenpool-gnu-make-posix.cc -+ ) - if(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR CMAKE_SYSTEM_NAME STREQUAL "AIX") - target_sources(libninja PRIVATE src/getopt.c) - endif() -@@ -204,6 +209,7 @@ if(BUILD_TESTING) - src/string_piece_util_test.cc - src/subprocess_test.cc - src/test.cc -+ src/tokenpool_test.cc - src/util_test.cc - ) - if(WIN32) -diff --git a/src/build.cc b/src/build.cc -index 20c3bdc2a0..854df08c2a 100644 ---- a/src/build.cc -+++ b/src/build.cc -@@ -467,7 +467,7 @@ struct RealCommandRunner : public CommandRunner { - // copy of config_.max_load_average; can be modified by TokenPool setup - double max_load_average_; - SubprocessSet subprocs_; -- TokenPool *tokens_; -+ TokenPool* tokens_; - map subproc_to_edge_; - }; - -diff --git a/src/build_test.cc b/src/build_test.cc -index dd41dfbe1d..8901c9518f 100644 ---- a/src/build_test.cc -+++ b/src/build_test.cc -@@ -4098,7 +4098,7 @@ struct BuildTokenTest : public BuildTest { - void ExpectWaitForCommand(int count, ...); - - private: -- void EnqueueBooleans(vector& booleans, int count, va_list ao); -+ void EnqueueBooleans(vector& booleans, int count, va_list ap); - }; - - void BuildTokenTest::SetUp() { -@@ -4144,16 +4144,6 @@ void BuildTokenTest::EnqueueBooleans(vector& booleans, int count, va_list - } - } - --TEST_F(BuildTokenTest, CompleteNoWork) { -- // plan should not execute anything -- string err; -- -- EXPECT_TRUE(builder_.Build(&err)); -- EXPECT_EQ("", err); -- -- EXPECT_EQ(0u, token_command_runner_.commands_ran_.size()); --} -- - TEST_F(BuildTokenTest, DoNotAquireToken) { - // plan should execute one command - string err; -diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc -index 74451b0be2..31839276c4 100644 ---- a/src/subprocess-posix.cc -+++ b/src/subprocess-posix.cc -@@ -250,7 +250,7 @@ Subprocess *SubprocessSet::Add(const string& command, bool use_console) { - } - - #ifdef USE_PPOLL --bool SubprocessSet::DoWork(struct TokenPool* tokens) { -+bool SubprocessSet::DoWork(TokenPool* tokens) { - vector fds; - nfds_t nfds = 0; - -@@ -315,7 +315,7 @@ bool SubprocessSet::DoWork(struct TokenPool* tokens) { - } - - #else // !defined(USE_PPOLL) --bool SubprocessSet::DoWork(struct TokenPool* tokens) { -+bool SubprocessSet::DoWork(TokenPool* tokens) { - fd_set set; - int nfds = 0; - FD_ZERO(&set); -diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc -index ce3e2c20a4..2926e9a221 100644 ---- a/src/subprocess-win32.cc -+++ b/src/subprocess-win32.cc -@@ -252,7 +252,7 @@ Subprocess *SubprocessSet::Add(const string& command, bool use_console) { - return subprocess; - } - --bool SubprocessSet::DoWork(struct TokenPool* tokens) { -+bool SubprocessSet::DoWork(TokenPool* tokens) { - DWORD bytes_read; - Subprocess* subproc; - OVERLAPPED* overlapped; -diff --git a/src/subprocess.h b/src/subprocess.h -index 9ea67ea477..1ec78171e8 100644 ---- a/src/subprocess.h -+++ b/src/subprocess.h -@@ -86,7 +86,7 @@ struct SubprocessSet { - ~SubprocessSet(); - - Subprocess* Add(const std::string& command, bool use_console = false); -- bool DoWork(struct TokenPool* tokens); -+ bool DoWork(TokenPool* tokens); - Subprocess* NextFinished(); - void Clear(); - -diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc -index f625963462..7b146f31be 100644 ---- a/src/subprocess_test.cc -+++ b/src/subprocess_test.cc -@@ -35,7 +35,7 @@ const char* kSimpleCommand = "cmd /c dir \\"; - const char* kSimpleCommand = "ls /"; - #endif - --struct TokenPoolTest : public TokenPool { -+struct TestTokenPool : public TokenPool { - bool Acquire() { return false; } - void Reserve() {} - void Release() {} -@@ -58,7 +58,7 @@ struct TokenPoolTest : public TokenPool { - - struct SubprocessTest : public testing::Test { - SubprocessSet subprocs_; -- TokenPoolTest tokens_; -+ TestTokenPool tokens_; - }; - - } // anonymous namespace -@@ -73,7 +73,7 @@ TEST_F(SubprocessTest, BadCommandStderr) { - // Pretend we discovered that stderr was ready for writing. - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitFailure, subproc->Finish()); - EXPECT_NE("", subproc->GetOutput()); -@@ -89,7 +89,7 @@ TEST_F(SubprocessTest, NoSuchCommand) { - // Pretend we discovered that stderr was ready for writing. - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitFailure, subproc->Finish()); - EXPECT_NE("", subproc->GetOutput()); -@@ -109,7 +109,7 @@ TEST_F(SubprocessTest, InterruptChild) { - while (!subproc->Done()) { - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitInterrupted, subproc->Finish()); - } -@@ -135,7 +135,7 @@ TEST_F(SubprocessTest, InterruptChildWithSigTerm) { - while (!subproc->Done()) { - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitInterrupted, subproc->Finish()); - } -@@ -161,7 +161,7 @@ TEST_F(SubprocessTest, InterruptChildWithSigHup) { - while (!subproc->Done()) { - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitInterrupted, subproc->Finish()); - } -@@ -190,7 +190,7 @@ TEST_F(SubprocessTest, Console) { - while (!subproc->Done()) { - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - - EXPECT_EQ(ExitSuccess, subproc->Finish()); - } -@@ -206,7 +206,7 @@ TEST_F(SubprocessTest, SetWithSingle) { - while (!subproc->Done()) { - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - ASSERT_EQ(ExitSuccess, subproc->Finish()); - ASSERT_NE("", subproc->GetOutput()); - -@@ -243,7 +243,7 @@ TEST_F(SubprocessTest, SetWithMulti) { - ASSERT_GT(subprocs_.running_.size(), 0u); - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - ASSERT_EQ(0u, subprocs_.running_.size()); - ASSERT_EQ(3u, subprocs_.finished_.size()); - -@@ -278,7 +278,7 @@ TEST_F(SubprocessTest, SetWithLots) { - subprocs_.ResetTokenAvailable(); - while (!subprocs_.running_.empty()) - subprocs_.DoWork(NULL); -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - for (size_t i = 0; i < procs.size(); ++i) { - ASSERT_EQ(ExitSuccess, procs[i]->Finish()); - ASSERT_NE("", procs[i]->GetOutput()); -@@ -298,7 +298,7 @@ TEST_F(SubprocessTest, ReadStdin) { - while (!subproc->Done()) { - subprocs_.DoWork(NULL); - } -- ASSERT_EQ(false, subprocs_.IsTokenAvailable()); -+ ASSERT_FALSE(subprocs_.IsTokenAvailable()); - ASSERT_EQ(ExitSuccess, subproc->Finish()); - ASSERT_EQ(1u, subprocs_.finished_.size()); - } -@@ -322,7 +322,7 @@ TEST_F(SubprocessTest, TokenAvailable) { - subprocs_.DoWork(&tokens_); - #ifdef _WIN32 - tokens_._token_available = false; -- // we need to loop here as we have no conrol where the token -+ // we need to loop here as we have no control where the token - // I/O completion post ends up in the queue - while (!subproc->Done() && !subprocs_.IsTokenAvailable()) { - subprocs_.DoWork(&tokens_); -diff --git a/src/tokenpool-gnu-make-posix.cc b/src/tokenpool-gnu-make-posix.cc -index 70d84bfff7..353bda226a 100644 ---- a/src/tokenpool-gnu-make-posix.cc -+++ b/src/tokenpool-gnu-make-posix.cc -@@ -32,8 +32,8 @@ struct GNUmakeTokenPoolPosix : public GNUmakeTokenPool { - - virtual int GetMonitorFd(); - -- virtual const char *GetEnv(const char *name) { return getenv(name); }; -- virtual bool ParseAuth(const char *jobserver); -+ virtual const char* GetEnv(const char* name) { return getenv(name); }; -+ virtual bool ParseAuth(const char* jobserver); - virtual bool AcquireToken(); - virtual bool ReturnToken(); - -@@ -64,9 +64,7 @@ bool GNUmakeTokenPoolPosix::CheckFd(int fd) { - if (fd < 0) - return false; - int ret = fcntl(fd, F_GETFD); -- if (ret < 0) -- return false; -- return true; -+ return ret >= 0; - } - - int GNUmakeTokenPoolPosix::dup_rfd_ = -1; -@@ -82,14 +80,13 @@ bool GNUmakeTokenPoolPosix::SetAlarmHandler() { - act.sa_handler = CloseDupRfd; - if (sigaction(SIGALRM, &act, &old_act_) < 0) { - perror("sigaction:"); -- return(false); -- } else { -- restore_ = true; -- return(true); -+ return false; - } -+ restore_ = true; -+ return true; - } - --bool GNUmakeTokenPoolPosix::ParseAuth(const char *jobserver) { -+bool GNUmakeTokenPoolPosix::ParseAuth(const char* jobserver) { - int rfd = -1; - int wfd = -1; - if ((sscanf(jobserver, "%*[^=]=%d,%d", &rfd, &wfd) == 2) && -@@ -195,9 +192,9 @@ bool GNUmakeTokenPoolPosix::ReturnToken() { - } - - int GNUmakeTokenPoolPosix::GetMonitorFd() { -- return(rfd_); -+ return rfd_; - } - --struct TokenPool *TokenPool::Get() { -+TokenPool* TokenPool::Get() { - return new GNUmakeTokenPoolPosix; - } -diff --git a/src/tokenpool-gnu-make-win32.cc b/src/tokenpool-gnu-make-win32.cc -index 2719f2c1fc..b2bb52fadb 100644 ---- a/src/tokenpool-gnu-make-win32.cc -+++ b/src/tokenpool-gnu-make-win32.cc -@@ -14,7 +14,8 @@ - - #include "tokenpool-gnu-make.h" - --// always include first to make sure other headers do the correct thing... -+// Always include this first. -+// Otherwise the other system headers don't work correctly under Win32 - #include - - #include -@@ -32,8 +33,8 @@ struct GNUmakeTokenPoolWin32 : public GNUmakeTokenPool { - virtual void WaitForTokenAvailability(HANDLE ioport); - virtual bool TokenIsAvailable(ULONG_PTR key); - -- virtual const char *GetEnv(const char *name); -- virtual bool ParseAuth(const char *jobserver); -+ virtual const char* GetEnv(const char* name); -+ virtual bool ParseAuth(const char* jobserver); - virtual bool AcquireToken(); - virtual bool ReturnToken(); - -@@ -98,19 +99,19 @@ GNUmakeTokenPoolWin32::~GNUmakeTokenPoolWin32() { - } - } - --const char *GNUmakeTokenPoolWin32::GetEnv(const char *name) { -+const char* GNUmakeTokenPoolWin32::GetEnv(const char* name) { - // getenv() does not work correctly together with tokenpool_tests.cc - static char buffer[MAX_PATH + 1]; -- if (GetEnvironmentVariable("MAKEFLAGS", buffer, sizeof(buffer)) == 0) -+ if (GetEnvironmentVariable(name, buffer, sizeof(buffer)) == 0) - return NULL; -- return(buffer); -+ return buffer; - } - --bool GNUmakeTokenPoolWin32::ParseAuth(const char *jobserver) { -+bool GNUmakeTokenPoolWin32::ParseAuth(const char* jobserver) { - // match "--jobserver-auth=gmake_semaphore_..." -- const char *start = strchr(jobserver, '='); -+ const char* start = strchr(jobserver, '='); - if (start) { -- const char *end = start; -+ const char* end = start; - unsigned int len; - char c, *auth; - -@@ -119,14 +120,15 @@ bool GNUmakeTokenPoolWin32::ParseAuth(const char *jobserver) { - break; - len = end - start; // includes string terminator in count - -- if ((len > 1) && ((auth = (char *)malloc(len)) != NULL)) { -+ if ((len > 1) && ((auth = (char*)malloc(len)) != NULL)) { - strncpy(auth, start + 1, len - 1); - auth[len - 1] = '\0'; - -- if ((semaphore_jobserver_ = OpenSemaphore(SEMAPHORE_ALL_ACCESS, /* Semaphore access setting */ -- FALSE, /* Child processes DON'T inherit */ -- auth /* Semaphore name */ -- )) != NULL) { -+ if ((semaphore_jobserver_ = -+ OpenSemaphore(SEMAPHORE_ALL_ACCESS, /* Semaphore access setting */ -+ FALSE, /* Child processes DON'T inherit */ -+ auth /* Semaphore name */ -+ )) != NULL) { - free(auth); - return true; - } -@@ -171,7 +173,7 @@ DWORD GNUmakeTokenPoolWin32::SemaphoreThread() { - } - - DWORD WINAPI GNUmakeTokenPoolWin32::SemaphoreThreadWrapper(LPVOID param) { -- GNUmakeTokenPoolWin32 *This = (GNUmakeTokenPoolWin32 *) param; -+ GNUmakeTokenPoolWin32* This = (GNUmakeTokenPoolWin32*) param; - return This->SemaphoreThread(); - } - -@@ -216,7 +218,7 @@ void GNUmakeTokenPoolWin32::WaitForTokenAvailability(HANDLE ioport) { - - bool GNUmakeTokenPoolWin32::TokenIsAvailable(ULONG_PTR key) { - // alert child thread to break wait on token semaphore -- QueueUserAPC(&NoopAPCFunc, child_, (ULONG_PTR)NULL); -+ QueueUserAPC((PAPCFUNC)&NoopAPCFunc, child_, (ULONG_PTR)NULL); - - // return true when GetQueuedCompletionStatus() returned our key - return key == (ULONG_PTR) this; -@@ -232,6 +234,6 @@ void GNUmakeTokenPoolWin32::WaitForObject(HANDLE object) { - Win32Fatal("WaitForSingleObject"); - } - --struct TokenPool *TokenPool::Get() { -+TokenPool* TokenPool::Get() { - return new GNUmakeTokenPoolWin32; - } -diff --git a/src/tokenpool-gnu-make.cc b/src/tokenpool-gnu-make.cc -index 92ff611721..60e0552924 100644 ---- a/src/tokenpool-gnu-make.cc -+++ b/src/tokenpool-gnu-make.cc -@@ -31,36 +31,37 @@ GNUmakeTokenPool::~GNUmakeTokenPool() { - bool GNUmakeTokenPool::Setup(bool ignore, - bool verbose, - double& max_load_average) { -- const char *value = GetEnv("MAKEFLAGS"); -- if (value) { -- // GNU make <= 4.1 -- const char *jobserver = strstr(value, "--jobserver-fds="); -+ const char* value = GetEnv("MAKEFLAGS"); -+ if (!value) -+ return false; + -+ // GNU make <= 4.1 -+ const char* jobserver = strstr(value, "--jobserver-fds="); -+ if (!jobserver) - // GNU make => 4.2 -- if (!jobserver) -- jobserver = strstr(value, "--jobserver-auth="); -- if (jobserver) { -- LinePrinter printer; -- -- if (ignore) { -- printer.PrintOnNewLine("ninja: warning: -jN forced on command line; ignoring GNU make jobserver.\n"); -- } else { -- if (ParseAuth(jobserver)) { -- const char *l_arg = strstr(value, " -l"); -- int load_limit = -1; -- -- if (verbose) { -- printer.PrintOnNewLine("ninja: using GNU make jobserver.\n"); -- } -- -- // translate GNU make -lN to ninja -lN -- if (l_arg && -- (sscanf(l_arg + 3, "%d ", &load_limit) == 1) && -- (load_limit > 0)) { -- max_load_average = load_limit; -- } -- -- return true; -+ jobserver = strstr(value, "--jobserver-auth="); -+ if (jobserver) { -+ LinePrinter printer; -+ -+ if (ignore) { -+ printer.PrintOnNewLine("ninja: warning: -jN forced on command line; ignoring GNU make jobserver.\n"); -+ } else { -+ if (ParseAuth(jobserver)) { -+ const char* l_arg = strstr(value, " -l"); -+ int load_limit = -1; -+ -+ if (verbose) { -+ printer.PrintOnNewLine("ninja: using GNU make jobserver.\n"); -+ } -+ -+ // translate GNU make -lN to ninja -lN -+ if (l_arg && -+ (sscanf(l_arg + 3, "%d ", &load_limit) == 1) && -+ (load_limit > 0)) { -+ max_load_average = load_limit; - } -+ -+ return true; - } - } - } -@@ -76,10 +77,10 @@ bool GNUmakeTokenPool::Acquire() { - // token acquired - available_++; - return true; -- } else { -- // no token available -- return false; - } -+ -+ // no token available -+ return false; - } ++ // implicit token ++ EXPECT_TRUE(tokens_->Acquire()); ++} +--- a/src/version.cc ++++ b/src/version.cc +@@ -20,7 +20,7 @@ - void GNUmakeTokenPool::Reserve() { -diff --git a/src/tokenpool-gnu-make.h b/src/tokenpool-gnu-make.h -index d3852088e2..c94cca5e2d 100644 ---- a/src/tokenpool-gnu-make.h -+++ b/src/tokenpool-gnu-make.h -@@ -17,7 +17,7 @@ - // interface to GNU make token pool - struct GNUmakeTokenPool : public TokenPool { - GNUmakeTokenPool(); -- virtual ~GNUmakeTokenPool(); -+ ~GNUmakeTokenPool(); + using namespace std; - // token pool implementation - virtual bool Acquire(); -@@ -27,8 +27,8 @@ struct GNUmakeTokenPool : public TokenPool { - virtual bool Setup(bool ignore, bool verbose, double& max_load_average); - - // platform specific implementation -- virtual const char *GetEnv(const char *name) = 0; -- virtual bool ParseAuth(const char *jobserver) = 0; -+ virtual const char* GetEnv(const char* name) = 0; -+ virtual bool ParseAuth(const char* jobserver) = 0; - virtual bool AcquireToken() = 0; - virtual bool ReturnToken() = 0; - -diff --git a/src/tokenpool-none.cc b/src/tokenpool-none.cc -deleted file mode 100644 -index 613d16882d..0000000000 ---- a/src/tokenpool-none.cc -+++ /dev/null -@@ -1,22 +0,0 @@ --// Copyright 2016-2018 Google Inc. All Rights Reserved. --// --// Licensed under the Apache License, Version 2.0 (the "License"); --// you may not use this file except in compliance with the License. --// You may obtain a copy of the License at --// --// http://www.apache.org/licenses/LICENSE-2.0 --// --// Unless required by applicable law or agreed to in writing, software --// distributed under the License is distributed on an "AS IS" BASIS, --// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --// See the License for the specific language governing permissions and --// limitations under the License. -- --#include "tokenpool.h" -- --#include -- --// No-op TokenPool implementation --struct TokenPool *TokenPool::Get() { -- return NULL; --} -diff --git a/src/tokenpool.h b/src/tokenpool.h -index 1be8e1d5ce..931c22754d 100644 ---- a/src/tokenpool.h -+++ b/src/tokenpool.h -@@ -38,5 +38,5 @@ struct TokenPool { - #endif - - // returns NULL if token pool is not available -- static struct TokenPool *Get(); -+ static TokenPool* Get(); - }; -diff --git a/src/tokenpool_test.cc b/src/tokenpool_test.cc -index 8d4fd7d33a..8d3061cb30 100644 ---- a/src/tokenpool_test.cc -+++ b/src/tokenpool_test.cc -@@ -43,10 +43,10 @@ const double kLoadAverageDefault = -1.23456789; - - struct TokenPoolTest : public testing::Test { - double load_avg_; -- TokenPool *tokens_; -+ TokenPool* tokens_; - char buf_[1024]; - #ifdef _WIN32 -- const char *semaphore_name_; -+ const char* semaphore_name_; - HANDLE semaphore_; - #else - int fds_[2]; -@@ -65,7 +65,7 @@ struct TokenPoolTest : public testing::Test { - ASSERT_TRUE(false); - } - -- void CreatePool(const char *format, bool ignore_jobserver = false) { -+ void CreatePool(const char* format, bool ignore_jobserver = false) { - if (format) { - sprintf(buf_, format, - #ifdef _WIN32 -@@ -209,7 +209,7 @@ TEST_F(TokenPoolTest, TwoTokens) { - tokens_->Release(); - EXPECT_TRUE(tokens_->Acquire()); - -- // release implict token - must return 2nd token back to jobserver -+ // release implicit token - must return 2nd token back to jobserver - tokens_->Release(); - EXPECT_TRUE(tokens_->Acquire()); +-const char* kNinjaVersion = "1.11.1"; ++const char* kNinjaVersion = "1.11.1.git.kitware.jobserver-1"; + void ParseVersion(const string& version, int* major, int* minor) { + size_t end = version.find('.'); diff --git a/tools/patch/Makefile b/tools/patch/Makefile index bac7d5692..957fe6e30 100644 --- a/tools/patch/Makefile +++ b/tools/patch/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=patch PKG_VERSION:=2.7.6 -PKG_RELEASE:=6 +PKG_RELEASE:=7 PKG_CPE_ID:=cpe:/a:gnu:patch PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz diff --git a/tools/patch/patches/070-don-t-fail-hard-on-EACCES-when-copying-xattrs.patch b/tools/patch/patches/070-don-t-fail-hard-on-EACCES-when-copying-xattrs.patch new file mode 100644 index 000000000..e19a9c084 --- /dev/null +++ b/tools/patch/patches/070-don-t-fail-hard-on-EACCES-when-copying-xattrs.patch @@ -0,0 +1,33 @@ +From f42cbe1a91a3a6f79d1eec594ce7c72aec79179b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= +Date: Wed, 9 Nov 2022 05:08:22 +0100 +Subject: [PATCH] don't fail hard on EACCES when copying xattrs + +On btrfs the xattr "btrfs.compressed" requires privileges to set, +otherwise EACCES is returned. +When patch tries to do copy this attribute it receives the error and +aborts. +--- + src/util.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/src/util.c ++++ b/src/util.c +@@ -182,7 +182,7 @@ copy_attr_error (struct error_context *c + int err = errno; + va_list ap; + +- if (err != ENOSYS && err != ENOTSUP && err != EPERM) ++ if (err != ENOSYS && err != ENOTSUP && err != EPERM && err != EACCES) + { + /* use verror module to print error message */ + va_start (ap, fmt); +@@ -284,7 +284,7 @@ set_file_attributes (char const *to, enu + } + if (attr & FA_XATTRS) + if (copy_attr (from, to) != 0 +- && errno != ENOSYS && errno != ENOTSUP && errno != EPERM) ++ && errno != ENOSYS && errno != ENOTSUP && errno != EPERM && errno != EACCES) + fatal_exit (0); + if (attr & FA_MODE) + { diff --git a/tools/patchelf/Makefile b/tools/patchelf/Makefile index 4cf039c40..1271a393c 100644 --- a/tools/patchelf/Makefile +++ b/tools/patchelf/Makefile @@ -7,12 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=patchelf +PKG_VERSION:=0.17.0 -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/NixOS/patchelf.git -PKG_SOURCE_VERSION:=f34751b88bd07d7f44f5cd3200fb4122bf916c7e -PKG_SOURCE_DATE:=2020-12-07 -PKG_MIRROR_HASH:=ac746930b919b97da40f259cfc9ab7bbd48a0c9cbf2eebd8cee5ae19a94356fd +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=https://github.com/NixOS/patchelf/releases/download/$(PKG_VERSION) +PKG_HASH:=45d76f4a31688a523718ec512f31650b1f35d1affec3eafeb3feeb5448d341e1 HOST_BUILD_PARALLEL:=1 HOST_FIXUP:=autoreconf diff --git a/tools/sed/Makefile b/tools/sed/Makefile index 4218ac2d5..5cc15a339 100644 --- a/tools/sed/Makefile +++ b/tools/sed/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sed -PKG_VERSION:=4.8 +PKG_VERSION:=4.9 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_HASH:=f79b0cfea71b37a8eeec8490db6c5f7ae7719c35587f21edb0617f370eeff633 +PKG_HASH:=6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181 export SED:= HOST_BUILD_PARALLEL:=1 diff --git a/tools/sed/patches/001-sed-fix-handling-of-symlinks-pointing-to-path-with-1.patch b/tools/sed/patches/001-sed-fix-handling-of-symlinks-pointing-to-path-with-1.patch new file mode 100644 index 000000000..96ae5bdbb --- /dev/null +++ b/tools/sed/patches/001-sed-fix-handling-of-symlinks-pointing-to-path-with-1.patch @@ -0,0 +1,47 @@ +From 8f600f2df293d539e9e9137f6f82faa1633b97c1 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sat, 17 Dec 2022 20:56:29 -0800 +Subject: [PATCH] sed: fix symlink bufsize readlink check + +Problem reported by Hauke Mehrtens. +* sed/utils.c (follow_symlink): Fix typo when checking size of +second and later symlink, when that symlink is so large that it +does not fit into the buffer. Although the bug is not a buffer +overflow, it does cause sed to mishandle the symlink. +* testsuite/follow-symlinks.sh: Test for the bug. +--- + sed/utils.c | 2 +- + testsuite/follow-symlinks.sh | 13 +++++++++++++ + 3 files changed, 18 insertions(+), 1 deletion(-) + +--- a/sed/utils.c ++++ b/sed/utils.c +@@ -345,7 +345,7 @@ follow_symlink (const char *fname) + while ((linklen = (buf_used < buf_size + ? readlink (fn, buf + buf_used, buf_size - buf_used) + : 0)) +- == buf_size) ++ == buf_size - buf_used) + { + buf = xpalloc (buf, &buf_size, 1, SSIZE_IDX_MAX, 1); + if (num_links) +--- a/testsuite/follow-symlinks.sh ++++ b/testsuite/follow-symlinks.sh +@@ -73,4 +73,17 @@ compare_ exp-la-abs out-la-abs || fail=1 + ln -s la-loop la-loop || framework_failure_ + sed --follow-symlinks -i s/a/b/ la-loop && fail=1 + ++# symlink of length 128 ++long=d/ ++for i in 2 3 4 5 6 7; do ++ long=$long$long ++done ++dir=${long%/d/} ++file=$dir/xx ++mkdir -p $dir && ++echo x >$file && ++ln -s $file yy && ++ln -s yy xx || framework_failure_ ++sed -i --follow-symlinks s/x/y/ xx || fail=1 ++ + Exit $fail diff --git a/tools/ucl/Makefile b/tools/ucl/Makefile deleted file mode 100644 index b98fe13ca..000000000 --- a/tools/ucl/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2021 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# -include $(TOPDIR)/rules.mk - -PKG_NAME:=ucl -PKG_VERSION:=1.03 - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://www.oberhumer.com/opensource/ucl/download/$(PKG_SOURCE) -PKG_HASH:=b865299ffd45d73412293369c9754b07637680e5c826915f097577cd27350348 - -HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION) - -include $(INCLUDE_DIR)/host-build.mk - -HOST_CFLAGS +=-std=gnu89 -std=c90 -fPIC -Wno-error=implicit-function-declaration -HOST_CFLAGS +=-std=gnu89 - -define Host/Prepare - $(Host/Prepare/Default) - mkdir -p $(STAGING_DIR_HOST)/include/ucl -endef - -define Host/Configure - (cd $(HOST_BUILD_DIR); \ - CC="$(HOSTCC)" \ - CFLAGS="$(HOST_CFLAGS)" \ - ./configure --prefix=$(STAGING_DIR_HOST) \ - ); - $(call Host/Configure/Default) -endef - -define Host/Compile - $(MAKE) -C $(HOST_BUILD_DIR) -endef - -define Host/Install - $(MAKE) -C $(HOST_BUILD_DIR) install -endef - -define Host/Clean - rm -rf $(STAGING_DIR_HOST)/include/ucl -endef - -$(eval $(call HostBuild)) diff --git a/tools/ucl/patches/100-fix-apple-m1-support.patch b/tools/ucl/patches/100-fix-apple-m1-support.patch deleted file mode 100644 index a130237d2..000000000 --- a/tools/ucl/patches/100-fix-apple-m1-support.patch +++ /dev/null @@ -1,2419 +0,0 @@ ---- a/acconfig/config.guess -+++ b/acconfig/config.guess -@@ -1,13 +1,12 @@ - #! /bin/sh - # Attempt to guess a canonical system name. --# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, --# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. -+# Copyright 1992-2021 Free Software Foundation, Inc. - --timestamp='2004-06-24' -+timestamp='2021-05-24' - - # This file 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; either version 2 of the License, or -+# the Free Software Foundation; either version 3 of the License, or - # (at your option) any later version. - # - # This program is distributed in the hope that it will be useful, but -@@ -16,33 +15,31 @@ - # General Public License for more details. - # - # You should have received a copy of the GNU General Public License --# along with this program; if not, write to the Free Software --# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+# along with this program; if not, see . - # - # As a special exception to the GNU General Public License, if you - # distribute this file as part of a program that contains a - # configuration script generated by Autoconf, you may include it under --# the same distribution terms that you use for the rest of that program. -- --# Originally written by Per Bothner . --# Please send patches to . Submit a context --# diff and a properly formatted ChangeLog entry. -+# the same distribution terms that you use for the rest of that -+# program. This Exception is an additional permission under section 7 -+# of the GNU General Public License, version 3 ("GPLv3"). -+# -+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. - # --# This script attempts to guess a canonical system name similar to --# config.sub. If it succeeds, it prints the system name on stdout, and --# exits with 0. Otherwise, it exits with 1. -+# You can get the latest version of this script from: -+# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess - # --# The plan is that this can be called by configure scripts if you --# don't specify an explicit build system type. -+# Please send patches to . -+ - --me=`echo "$0" | sed -e 's,.*/,,'` -+me=$(echo "$0" | sed -e 's,.*/,,') - - usage="\ - Usage: $0 [OPTION] - - Output the configuration name of the system \`$me' is run on. - --Operation modes: -+Options: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit -@@ -53,8 +50,7 @@ - GNU config.guess ($timestamp) - - Originally written by Per Bothner. --Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 --Free Software Foundation, Inc. -+Copyright 1992-2021 Free Software Foundation, Inc. - - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." -@@ -66,11 +62,11 @@ - while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) -- echo "$timestamp" ; exit 0 ;; -+ echo "$timestamp" ; exit ;; - --version | -v ) -- echo "$version" ; exit 0 ;; -+ echo "$version" ; exit ;; - --help | --h* | -h ) -- echo "$usage"; exit 0 ;; -+ echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. -@@ -88,8 +84,6 @@ - exit 1 - fi - --trap 'exit 1' 1 2 15 -- - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a - # compiler to aid in system detection is discouraged as it requires - # temporary files to be created and, as you can see below, it is a -@@ -100,48 +94,92 @@ - - # Portable tmp directory creation inspired by the Autoconf team. - --set_cc_for_build=' --trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; --trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; --: ${TMPDIR=/tmp} ; -- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || -- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || -- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || -- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; --dummy=$tmp/dummy ; --tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; --case $CC_FOR_BUILD,$HOST_CC,$CC in -- ,,) echo "int x;" > $dummy.c ; -- for c in cc gcc c89 c99 ; do -- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then -- CC_FOR_BUILD="$c"; break ; -- fi ; -- done ; -- if test x"$CC_FOR_BUILD" = x ; then -- CC_FOR_BUILD=no_compiler_found ; -- fi -- ;; -- ,,*) CC_FOR_BUILD=$CC ;; -- ,*,*) CC_FOR_BUILD=$HOST_CC ;; --esac ;' -+tmp= -+# shellcheck disable=SC2172 -+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 -+ -+set_cc_for_build() { -+ # prevent multiple calls if $tmp is already set -+ test "$tmp" && return 0 -+ : "${TMPDIR=/tmp}" -+ # shellcheck disable=SC2039 -+ { tmp=$( (umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null) && test -n "$tmp" && test -d "$tmp" ; } || -+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || -+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || -+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } -+ dummy=$tmp/dummy -+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in -+ ,,) echo "int x;" > "$dummy.c" -+ for driver in cc gcc c89 c99 ; do -+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then -+ CC_FOR_BUILD="$driver" -+ break -+ fi -+ done -+ if test x"$CC_FOR_BUILD" = x ; then -+ CC_FOR_BUILD=no_compiler_found -+ fi -+ ;; -+ ,,*) CC_FOR_BUILD=$CC ;; -+ ,*,*) CC_FOR_BUILD=$HOST_CC ;; -+ esac -+} - - # This is needed to find uname on a Pyramid OSx when run in the BSD universe. - # (ghazi@noc.rutgers.edu 1994-08-24) --if (test -f /.attbin/uname) >/dev/null 2>&1 ; then -+if test -f /.attbin/uname ; then - PATH=$PATH:/.attbin ; export PATH - fi - --UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown --UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown --UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown --UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -+UNAME_MACHINE=$( (uname -m) 2>/dev/null) || UNAME_MACHINE=unknown -+UNAME_RELEASE=$( (uname -r) 2>/dev/null) || UNAME_RELEASE=unknown -+UNAME_SYSTEM=$( (uname -s) 2>/dev/null) || UNAME_SYSTEM=unknown -+UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown -+ -+case $UNAME_SYSTEM in -+Linux|GNU|GNU/*) -+ LIBC=unknown -+ -+ set_cc_for_build -+ cat <<-EOF > "$dummy.c" -+ #include -+ #if defined(__UCLIBC__) -+ LIBC=uclibc -+ #elif defined(__dietlibc__) -+ LIBC=dietlibc -+ #elif defined(__GLIBC__) -+ LIBC=gnu -+ #else -+ #include -+ /* First heuristic to detect musl libc. */ -+ #ifdef __DEFINED_va_list -+ LIBC=musl -+ #endif -+ #endif -+ EOF -+ eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')" -+ -+ # Second heuristic to detect musl libc. -+ if [ "$LIBC" = unknown ] && -+ command -v ldd >/dev/null && -+ ldd --version 2>&1 | grep -q ^musl; then -+ LIBC=musl -+ fi -+ -+ # If the system lacks a compiler, then just pick glibc. -+ # We could probably try harder. -+ if [ "$LIBC" = unknown ]; then -+ LIBC=gnu -+ fi -+ ;; -+esac - - # Note: order is significant - the case branches are not exclusive. - --case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in -+case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or -- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, -+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward -@@ -150,23 +188,34 @@ - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". -- sysctl="sysctl -n hw.machine_arch" -- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ -- /usr/sbin/$sysctl 2>/dev/null || echo unknown)` -- case "${UNAME_MACHINE_ARCH}" in -+ UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \ -+ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ -+ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ -+ echo unknown)) -+ case $UNAME_MACHINE_ARCH in -+ aarch64eb) machine=aarch64_be-unknown ;; - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; -- *) machine=${UNAME_MACHINE_ARCH}-unknown ;; -+ sh5el) machine=sh5le-unknown ;; -+ earmv*) -+ arch=$(echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,') -+ endian=$(echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p') -+ machine="${arch}${endian}"-unknown -+ ;; -+ *) machine="$UNAME_MACHINE_ARCH"-unknown ;; - esac - # The Operating System including object format, if it has switched -- # to ELF recently, or will in the future. -- case "${UNAME_MACHINE_ARCH}" in -+ # to ELF recently (or will in the future) and ABI. -+ case $UNAME_MACHINE_ARCH in -+ earm*) -+ os=netbsdelf -+ ;; - arm*|i386|m68k|ns32k|sh3*|sparc|vax) -- eval $set_cc_for_build -+ set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ -- | grep __ELF__ >/dev/null -+ | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? -@@ -176,7 +225,14 @@ - fi - ;; - *) -- os=netbsd -+ os=netbsd -+ ;; -+ esac -+ # Determine ABI tags. -+ case $UNAME_MACHINE_ARCH in -+ earm*) -+ expr='s/^earmv[0-9]/-eabi/;s/eb$//' -+ abi=$(echo "$UNAME_MACHINE_ARCH" | sed -e "$expr") - ;; - esac - # The OS release -@@ -184,219 +240,226 @@ - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. -- case "${UNAME_VERSION}" in -+ case $UNAME_VERSION in - Debian*) - release='-gnu' - ;; - *) -- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` -+ release=$(echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2) - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. -- echo "${machine}-${os}${release}" -- exit 0 ;; -- amd64:OpenBSD:*:*) -- echo x86_64-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- amiga:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- arc:OpenBSD:*:*) -- echo mipsel-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- cats:OpenBSD:*:*) -- echo arm-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- hp300:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- luna88k:OpenBSD:*:*) -- echo m88k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- mac68k:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- macppc:OpenBSD:*:*) -- echo powerpc-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- mvme68k:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- mvme88k:OpenBSD:*:*) -- echo m88k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- mvmeppc:OpenBSD:*:*) -- echo powerpc-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- pmax:OpenBSD:*:*) -- echo mipsel-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- sgi:OpenBSD:*:*) -- echo mipseb-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- sun3:OpenBSD:*:*) -- echo m68k-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -- wgrisc:OpenBSD:*:*) -- echo mipsel-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -+ echo "$machine-${os}${release}${abi-}" -+ exit ;; -+ *:Bitrig:*:*) -+ UNAME_MACHINE_ARCH=$(arch | sed 's/Bitrig.//') -+ echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" -+ exit ;; - *:OpenBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} -- exit 0 ;; -+ UNAME_MACHINE_ARCH=$(arch | sed 's/OpenBSD.//') -+ echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" -+ exit ;; -+ *:SecBSD:*:*) -+ UNAME_MACHINE_ARCH=$(arch | sed 's/SecBSD.//') -+ echo "$UNAME_MACHINE_ARCH"-unknown-secbsd"$UNAME_RELEASE" -+ exit ;; -+ *:LibertyBSD:*:*) -+ UNAME_MACHINE_ARCH=$(arch | sed 's/^.*BSD\.//') -+ echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" -+ exit ;; -+ *:MidnightBSD:*:*) -+ echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" -+ exit ;; - *:ekkoBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" -+ exit ;; -+ *:SolidBSD:*:*) -+ echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" -+ exit ;; -+ *:OS108:*:*) -+ echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" -+ exit ;; - macppc:MirBSD:*:*) -- echo powerppc-unknown-mirbsd${UNAME_RELEASE} -- exit 0 ;; -+ echo powerpc-unknown-mirbsd"$UNAME_RELEASE" -+ exit ;; - *:MirBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" -+ exit ;; -+ *:Sortix:*:*) -+ echo "$UNAME_MACHINE"-unknown-sortix -+ exit ;; -+ *:Twizzler:*:*) -+ echo "$UNAME_MACHINE"-unknown-twizzler -+ exit ;; -+ *:Redox:*:*) -+ echo "$UNAME_MACHINE"-unknown-redox -+ exit ;; -+ mips:OSF1:*.*) -+ echo mips-dec-osf1 -+ exit ;; - alpha:OSF1:*:*) -+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code. -+ trap '' 0 - case $UNAME_RELEASE in - *4.0) -- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` -+ UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $3}') - ;; - *5.*) -- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` -+ UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $4}') - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. -- ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` -- case "$ALPHA_CPU_TYPE" in -+ ALPHA_CPU_TYPE=$(/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1) -+ case $ALPHA_CPU_TYPE in - "EV4 (21064)") -- UNAME_MACHINE="alpha" ;; -+ UNAME_MACHINE=alpha ;; - "EV4.5 (21064)") -- UNAME_MACHINE="alpha" ;; -+ UNAME_MACHINE=alpha ;; - "LCA4 (21066/21068)") -- UNAME_MACHINE="alpha" ;; -+ UNAME_MACHINE=alpha ;; - "EV5 (21164)") -- UNAME_MACHINE="alphaev5" ;; -+ UNAME_MACHINE=alphaev5 ;; - "EV5.6 (21164A)") -- UNAME_MACHINE="alphaev56" ;; -+ UNAME_MACHINE=alphaev56 ;; - "EV5.6 (21164PC)") -- UNAME_MACHINE="alphapca56" ;; -+ UNAME_MACHINE=alphapca56 ;; - "EV5.7 (21164PC)") -- UNAME_MACHINE="alphapca57" ;; -+ UNAME_MACHINE=alphapca57 ;; - "EV6 (21264)") -- UNAME_MACHINE="alphaev6" ;; -+ UNAME_MACHINE=alphaev6 ;; - "EV6.7 (21264A)") -- UNAME_MACHINE="alphaev67" ;; -+ UNAME_MACHINE=alphaev67 ;; - "EV6.8CB (21264C)") -- UNAME_MACHINE="alphaev68" ;; -+ UNAME_MACHINE=alphaev68 ;; - "EV6.8AL (21264B)") -- UNAME_MACHINE="alphaev68" ;; -+ UNAME_MACHINE=alphaev68 ;; - "EV6.8CX (21264D)") -- UNAME_MACHINE="alphaev68" ;; -+ UNAME_MACHINE=alphaev68 ;; - "EV6.9A (21264/EV69A)") -- UNAME_MACHINE="alphaev69" ;; -+ UNAME_MACHINE=alphaev69 ;; - "EV7 (21364)") -- UNAME_MACHINE="alphaev7" ;; -+ UNAME_MACHINE=alphaev7 ;; - "EV7.9 (21364A)") -- UNAME_MACHINE="alphaev79" ;; -+ UNAME_MACHINE=alphaev79 ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. -- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -- exit 0 ;; -- Alpha\ *:Windows_NT*:*) -- # How do we know it's Interix rather than the generic POSIX subsystem? -- # Should we change UNAME_MACHINE based on the output of uname instead -- # of the specific Alpha model? -- echo alpha-pc-interix -- exit 0 ;; -- 21064:Windows_NT:50:3) -- echo alpha-dec-winnt3.5 -- exit 0 ;; -+ echo "$UNAME_MACHINE"-dec-osf"$(echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)" -+ exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 -- exit 0;; -+ exit ;; - *:[Aa]miga[Oo][Ss]:*:*) -- echo ${UNAME_MACHINE}-unknown-amigaos -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-amigaos -+ exit ;; - *:[Mm]orph[Oo][Ss]:*:*) -- echo ${UNAME_MACHINE}-unknown-morphos -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-morphos -+ exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition -- exit 0 ;; -+ exit ;; -+ *:z/VM:*:*) -+ echo s390-ibm-zvmoe -+ exit ;; - *:OS400:*:*) -- echo powerpc-ibm-os400 -- exit 0 ;; -+ echo powerpc-ibm-os400 -+ exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) -- echo arm-acorn-riscix${UNAME_RELEASE} -- exit 0;; -+ echo arm-acorn-riscix"$UNAME_RELEASE" -+ exit ;; -+ arm*:riscos:*:*|arm*:RISCOS:*:*) -+ echo arm-unknown-riscos -+ exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp -- exit 0;; -+ exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. -- if test "`(/bin/universe) 2>/dev/null`" = att ; then -+ if test "$( (/bin/universe) 2>/dev/null)" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi -- exit 0 ;; -+ exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 -- exit 0 ;; -+ exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 -- exit 0 ;; -- DRS?6000:UNIX_SV:4.2*:7*) -- case `/usr/bin/uname -p` in -- sparc) echo sparc-icl-nx7 && exit 0 ;; -+ exit ;; -+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) -+ case $(/usr/bin/uname -p) in -+ sparc) echo sparc-icl-nx7; exit ;; - esac ;; -+ s390x:SunOS:*:*) -+ echo "$UNAME_MACHINE"-ibm-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" -+ exit ;; - sun4H:SunOS:5.*:*) -- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ echo sparc-hal-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" -+ exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) -- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -- i86pc:SunOS:5.*:*) -- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ echo sparc-sun-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" -+ exit ;; -+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) -+ echo i386-pc-auroraux"$UNAME_RELEASE" -+ exit ;; -+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) -+ set_cc_for_build -+ SUN_ARCH=i386 -+ # If there is a compiler, see if it is configured for 64-bit objects. -+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. -+ # This test works for both compilers. -+ if test "$CC_FOR_BUILD" != no_compiler_found; then -+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ -+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ -+ grep IS_64BIT_ARCH >/dev/null -+ then -+ SUN_ARCH=x86_64 -+ fi -+ fi -+ echo "$SUN_ARCH"-pc-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" -+ exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. -- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ echo sparc-sun-solaris3"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" -+ exit ;; - sun4*:SunOS:*:*) -- case "`/usr/bin/arch -k`" in -+ case $(/usr/bin/arch -k) in - Series*|S4*) -- UNAME_RELEASE=`uname -v` -+ UNAME_RELEASE=$(uname -v) - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. -- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` -- exit 0 ;; -+ echo sparc-sun-sunos"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/')" -+ exit ;; - sun3*:SunOS:*:*) -- echo m68k-sun-sunos${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-sun-sunos"$UNAME_RELEASE" -+ exit ;; - sun*:*:4.2BSD:*) -- UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` -- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 -- case "`/bin/arch`" in -+ UNAME_RELEASE=$( (sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null) -+ test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 -+ case $(/bin/arch) in - sun3) -- echo m68k-sun-sunos${UNAME_RELEASE} -+ echo m68k-sun-sunos"$UNAME_RELEASE" - ;; - sun4) -- echo sparc-sun-sunos${UNAME_RELEASE} -+ echo sparc-sun-sunos"$UNAME_RELEASE" - ;; - esac -- exit 0 ;; -+ exit ;; - aushp:SunOS:*:*) -- echo sparc-auspex-sunos${UNAME_RELEASE} -- exit 0 ;; -+ echo sparc-auspex-sunos"$UNAME_RELEASE" -+ exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor -@@ -406,44 +469,44 @@ - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) -- echo m68k-atari-mint${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-atari-mint"$UNAME_RELEASE" -+ exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) -- echo m68k-atari-mint${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-atari-mint"$UNAME_RELEASE" -+ exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) -- echo m68k-atari-mint${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-atari-mint"$UNAME_RELEASE" -+ exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) -- echo m68k-milan-mint${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-milan-mint"$UNAME_RELEASE" -+ exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) -- echo m68k-hades-mint${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-hades-mint"$UNAME_RELEASE" -+ exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) -- echo m68k-unknown-mint${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-unknown-mint"$UNAME_RELEASE" -+ exit ;; - m68k:machten:*:*) -- echo m68k-apple-machten${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-apple-machten"$UNAME_RELEASE" -+ exit ;; - powerpc:machten:*:*) -- echo powerpc-apple-machten${UNAME_RELEASE} -- exit 0 ;; -+ echo powerpc-apple-machten"$UNAME_RELEASE" -+ exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 -- exit 0 ;; -+ exit ;; - RISC*:ULTRIX:*:*) -- echo mips-dec-ultrix${UNAME_RELEASE} -- exit 0 ;; -+ echo mips-dec-ultrix"$UNAME_RELEASE" -+ exit ;; - VAX*:ULTRIX*:*:*) -- echo vax-dec-ultrix${UNAME_RELEASE} -- exit 0 ;; -+ echo vax-dec-ultrix"$UNAME_RELEASE" -+ exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) -- echo clipper-intergraph-clix${UNAME_RELEASE} -- exit 0 ;; -+ echo clipper-intergraph-clix"$UNAME_RELEASE" -+ exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - #ifdef __cplusplus - #include /* for printf() prototype */ - int main (int argc, char *argv[]) { -@@ -452,94 +515,95 @@ - #endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) -- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); -+ printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) -- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); -+ printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) -- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); -+ printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } - EOF -- $CC_FOR_BUILD -o $dummy $dummy.c \ -- && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ -- && exit 0 -- echo mips-mips-riscos${UNAME_RELEASE} -- exit 0 ;; -+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && -+ dummyarg=$(echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p') && -+ SYSTEM_NAME=$("$dummy" "$dummyarg") && -+ { echo "$SYSTEM_NAME"; exit; } -+ echo mips-mips-riscos"$UNAME_RELEASE" -+ exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax -- exit 0 ;; -+ exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax -- exit 0 ;; -+ exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax -- exit 0 ;; -+ exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix -- exit 0 ;; -+ exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 -- exit 0 ;; -+ exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 -- exit 0 ;; -+ exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 -- exit 0 ;; -+ exit ;; - AViiON:dgux:*:*) -- # DG/UX returns AViiON for all architectures -- UNAME_PROCESSOR=`/usr/bin/uname -p` -- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] -+ # DG/UX returns AViiON for all architectures -+ UNAME_PROCESSOR=$(/usr/bin/uname -p) -+ if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 - then -- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ -- [ ${TARGET_BINARY_INTERFACE}x = x ] -+ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ -+ test "$TARGET_BINARY_INTERFACE"x = x - then -- echo m88k-dg-dgux${UNAME_RELEASE} -+ echo m88k-dg-dgux"$UNAME_RELEASE" - else -- echo m88k-dg-dguxbcs${UNAME_RELEASE} -+ echo m88k-dg-dguxbcs"$UNAME_RELEASE" - fi - else -- echo i586-dg-dgux${UNAME_RELEASE} -+ echo i586-dg-dgux"$UNAME_RELEASE" - fi -- exit 0 ;; -+ exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 -- exit 0 ;; -+ exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 -- exit 0 ;; -+ exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 -- exit 0 ;; -+ exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd -- exit 0 ;; -+ exit ;; - *:IRIX*:*:*) -- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` -- exit 0 ;; -+ echo mips-sgi-irix"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/g')" -+ exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. -- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id -- exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' -+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id -+ exit ;; # Note that: echo "'$(uname -s)'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix -- exit 0 ;; -+ exit ;; - ia64:AIX:*:*) -- if [ -x /usr/bin/oslevel ] ; then -- IBM_REV=`/usr/bin/oslevel` -+ if test -x /usr/bin/oslevel ; then -+ IBM_REV=$(/usr/bin/oslevel) - else -- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} -+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" - fi -- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" -+ exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - #include - - main() -@@ -550,128 +614,143 @@ - exit(0); - } - EOF -- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 -- echo rs6000-ibm-aix3.2.5 -+ if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") -+ then -+ echo "$SYSTEM_NAME" -+ else -+ echo rs6000-ibm-aix3.2.5 -+ fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi -- exit 0 ;; -- *:AIX:*:[45]) -- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` -- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then -+ exit ;; -+ *:AIX:*:[4567]) -+ IBM_CPU_ID=$(/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }') -+ if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi -- if [ -x /usr/bin/oslevel ] ; then -- IBM_REV=`/usr/bin/oslevel` -+ if test -x /usr/bin/lslpp ; then -+ IBM_REV=$(/usr/bin/lslpp -Lqc bos.rte.libc | -+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/) - else -- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} -+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" - fi -- echo ${IBM_ARCH}-ibm-aix${IBM_REV} -- exit 0 ;; -+ echo "$IBM_ARCH"-ibm-aix"$IBM_REV" -+ exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix -- exit 0 ;; -- ibmrt:4.4BSD:*|romp-ibm:BSD:*) -+ exit ;; -+ ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) - echo romp-ibm-bsd4.4 -- exit 0 ;; -+ exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and -- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to -- exit 0 ;; # report: romp-ibm BSD 4.3 -+ echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to -+ exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx -- exit 0 ;; -+ exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 -- exit 0 ;; -+ exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd -- exit 0 ;; -+ exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 -- exit 0 ;; -+ exit ;; - 9000/[34678]??:HP-UX:*:*) -- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` -- case "${UNAME_MACHINE}" in -- 9000/31? ) HP_ARCH=m68000 ;; -- 9000/[34]?? ) HP_ARCH=m68k ;; -+ HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') -+ case $UNAME_MACHINE in -+ 9000/31?) HP_ARCH=m68000 ;; -+ 9000/[34]??) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) -- if [ -x /usr/bin/getconf ]; then -- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` -- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` -- case "${sc_cpu_version}" in -- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 -- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 -- 532) # CPU_PA_RISC2_0 -- case "${sc_kernel_bits}" in -- 32) HP_ARCH="hppa2.0n" ;; -- 64) HP_ARCH="hppa2.0w" ;; -- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 -- esac ;; -- esac -+ if test -x /usr/bin/getconf; then -+ sc_cpu_version=$(/usr/bin/getconf SC_CPU_VERSION 2>/dev/null) -+ sc_kernel_bits=$(/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null) -+ case $sc_cpu_version in -+ 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 -+ 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 -+ 532) # CPU_PA_RISC2_0 -+ case $sc_kernel_bits in -+ 32) HP_ARCH=hppa2.0n ;; -+ 64) HP_ARCH=hppa2.0w ;; -+ '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 -+ esac ;; -+ esac - fi -- if [ "${HP_ARCH}" = "" ]; then -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -- -- #define _HPUX_SOURCE -- #include -- #include -- -- int main () -- { -- #if defined(_SC_KERNEL_BITS) -- long bits = sysconf(_SC_KERNEL_BITS); -- #endif -- long cpu = sysconf (_SC_CPU_VERSION); -- -- switch (cpu) -- { -- case CPU_PA_RISC1_0: puts ("hppa1.0"); break; -- case CPU_PA_RISC1_1: puts ("hppa1.1"); break; -- case CPU_PA_RISC2_0: -- #if defined(_SC_KERNEL_BITS) -- switch (bits) -- { -- case 64: puts ("hppa2.0w"); break; -- case 32: puts ("hppa2.0n"); break; -- default: puts ("hppa2.0"); break; -- } break; -- #else /* !defined(_SC_KERNEL_BITS) */ -- puts ("hppa2.0"); break; -- #endif -- default: puts ("hppa1.0"); break; -- } -- exit (0); -- } -+ if test "$HP_ARCH" = ""; then -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" -+ -+ #define _HPUX_SOURCE -+ #include -+ #include -+ -+ int main () -+ { -+ #if defined(_SC_KERNEL_BITS) -+ long bits = sysconf(_SC_KERNEL_BITS); -+ #endif -+ long cpu = sysconf (_SC_CPU_VERSION); -+ -+ switch (cpu) -+ { -+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break; -+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break; -+ case CPU_PA_RISC2_0: -+ #if defined(_SC_KERNEL_BITS) -+ switch (bits) -+ { -+ case 64: puts ("hppa2.0w"); break; -+ case 32: puts ("hppa2.0n"); break; -+ default: puts ("hppa2.0"); break; -+ } break; -+ #else /* !defined(_SC_KERNEL_BITS) */ -+ puts ("hppa2.0"); break; -+ #endif -+ default: puts ("hppa1.0"); break; -+ } -+ exit (0); -+ } - EOF -- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` -+ (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=$("$dummy") - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac -- if [ ${HP_ARCH} = "hppa2.0w" ] -+ if test "$HP_ARCH" = hppa2.0w - then -- # avoid double evaluation of $set_cc_for_build -- test -n "$CC_FOR_BUILD" || eval $set_cc_for_build -- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null -+ set_cc_for_build -+ -+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating -+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler -+ # generating 64-bit code. GNU and HP use different nomenclature: -+ # -+ # $ CC_FOR_BUILD=cc ./config.guess -+ # => hppa2.0w-hp-hpux11.23 -+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess -+ # => hppa64-hp-hpux11.23 -+ -+ if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | -+ grep -q __LP64__ - then -- HP_ARCH="hppa2.0w" -+ HP_ARCH=hppa2.0w - else -- HP_ARCH="hppa64" -+ HP_ARCH=hppa64 - fi - fi -- echo ${HP_ARCH}-hp-hpux${HPUX_REV} -- exit 0 ;; -+ echo "$HP_ARCH"-hp-hpux"$HPUX_REV" -+ exit ;; - ia64:HP-UX:*:*) -- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` -- echo ia64-hp-hpux${HPUX_REV} -- exit 0 ;; -+ HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') -+ echo ia64-hp-hpux"$HPUX_REV" -+ exit ;; - 3050*:HI-UX:*:*) -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - #include - int - main () -@@ -696,348 +775,414 @@ - exit (0); - } - EOF -- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 -+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") && -+ { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 -- exit 0 ;; -- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) -+ exit ;; -+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) - echo hppa1.1-hp-bsd -- exit 0 ;; -+ exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd -- exit 0 ;; -+ exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix -- exit 0 ;; -- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) -+ exit ;; -+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) - echo hppa1.1-hp-osf -- exit 0 ;; -+ exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf -- exit 0 ;; -+ exit ;; - i*86:OSF1:*:*) -- if [ -x /usr/sbin/sysversion ] ; then -- echo ${UNAME_MACHINE}-unknown-osf1mk -+ if test -x /usr/sbin/sysversion ; then -+ echo "$UNAME_MACHINE"-unknown-osf1mk - else -- echo ${UNAME_MACHINE}-unknown-osf1 -+ echo "$UNAME_MACHINE"-unknown-osf1 - fi -- exit 0 ;; -+ exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites -- exit 0 ;; -+ exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd -- exit 0 ;; -+ exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi -- exit 0 ;; -+ exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd -- exit 0 ;; -+ exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd -- exit 0 ;; -+ exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd -- exit 0 ;; -+ exit ;; - CRAY*Y-MP:*:*:*) -- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' -+ exit ;; - CRAY*[A-Z]90:*:*:*) -- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ -+ echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ exit ;; - CRAY*TS:*:*:*) -- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' -+ exit ;; - CRAY*T3E:*:*:*) -- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' -+ exit ;; - CRAY*SV1:*:*:*) -- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' -+ exit ;; - *:UNICOS/mp:*:*) -- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -- exit 0 ;; -+ echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' -+ exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) -- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` -- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` -- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -- exit 0 ;; -+ FUJITSU_PROC=$(uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) -+ FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') -+ FUJITSU_REL=$(echo "$UNAME_RELEASE" | sed -e 's/ /_/') -+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -+ exit ;; - 5000:UNIX_System_V:4.*:*) -- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` -- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` -- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -- exit 0 ;; -+ FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') -+ FUJITSU_REL=$(echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/') -+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -+ exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) -- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" -+ exit ;; - sparc*:BSD/OS:*:*) -- echo sparc-unknown-bsdi${UNAME_RELEASE} -- exit 0 ;; -+ echo sparc-unknown-bsdi"$UNAME_RELEASE" -+ exit ;; - *:BSD/OS:*:*) -- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" -+ exit ;; -+ arm:FreeBSD:*:*) -+ UNAME_PROCESSOR=$(uname -p) -+ set_cc_for_build -+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ -+ | grep -q __ARM_PCS_VFP -+ then -+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabi -+ else -+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabihf -+ fi -+ exit ;; - *:FreeBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` -- exit 0 ;; -+ UNAME_PROCESSOR=$(/usr/bin/uname -p) -+ case $UNAME_PROCESSOR in -+ amd64) -+ UNAME_PROCESSOR=x86_64 ;; -+ i386) -+ UNAME_PROCESSOR=i586 ;; -+ esac -+ echo "$UNAME_PROCESSOR"-unknown-freebsd"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" -+ exit ;; - i*:CYGWIN*:*) -- echo ${UNAME_MACHINE}-pc-cygwin -- exit 0 ;; -- i*:MINGW*:*) -- echo ${UNAME_MACHINE}-pc-mingw32 -- exit 0 ;; -+ echo "$UNAME_MACHINE"-pc-cygwin -+ exit ;; -+ *:MINGW64*:*) -+ echo "$UNAME_MACHINE"-pc-mingw64 -+ exit ;; -+ *:MINGW*:*) -+ echo "$UNAME_MACHINE"-pc-mingw32 -+ exit ;; -+ *:MSYS*:*) -+ echo "$UNAME_MACHINE"-pc-msys -+ exit ;; - i*:PW*:*) -- echo ${UNAME_MACHINE}-pc-pw32 -- exit 0 ;; -- x86:Interix*:[34]*) -- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' -- exit 0 ;; -- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) -- echo i${UNAME_MACHINE}-pc-mks -- exit 0 ;; -- i*:Windows_NT*:* | Pentium*:Windows_NT*:*) -- # How do we know it's Interix rather than the generic POSIX subsystem? -- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we -- # UNAME_MACHINE based on the output of uname instead of i386? -- echo i586-pc-interix -- exit 0 ;; -+ echo "$UNAME_MACHINE"-pc-pw32 -+ exit ;; -+ *:Interix*:*) -+ case $UNAME_MACHINE in -+ x86) -+ echo i586-pc-interix"$UNAME_RELEASE" -+ exit ;; -+ authenticamd | genuineintel | EM64T) -+ echo x86_64-unknown-interix"$UNAME_RELEASE" -+ exit ;; -+ IA64) -+ echo ia64-unknown-interix"$UNAME_RELEASE" -+ exit ;; -+ esac ;; - i*:UWIN*:*) -- echo ${UNAME_MACHINE}-pc-uwin -- exit 0 ;; -- p*:CYGWIN*:*) -- echo powerpcle-unknown-cygwin -- exit 0 ;; -+ echo "$UNAME_MACHINE"-pc-uwin -+ exit ;; -+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) -+ echo x86_64-pc-cygwin -+ exit ;; - prep*:SunOS:5.*:*) -- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -- exit 0 ;; -+ echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" -+ exit ;; - *:GNU:*:*) - # the GNU system -- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` -- exit 0 ;; -+ echo "$(echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,')-unknown-$LIBC$(echo "$UNAME_RELEASE"|sed -e 's,/.*$,,')" -+ exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland -- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu -- exit 0 ;; -- i*86:Minix:*:*) -- echo ${UNAME_MACHINE}-pc-minix -- exit 0 ;; -+ echo "$UNAME_MACHINE-unknown-$(echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]")$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')-$LIBC" -+ exit ;; -+ *:Minix:*:*) -+ echo "$UNAME_MACHINE"-unknown-minix -+ exit ;; -+ aarch64:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ aarch64_be:Linux:*:*) -+ UNAME_MACHINE=aarch64_be -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ alpha:Linux:*:*) -+ case $(sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null) in -+ EV5) UNAME_MACHINE=alphaev5 ;; -+ EV56) UNAME_MACHINE=alphaev56 ;; -+ PCA56) UNAME_MACHINE=alphapca56 ;; -+ PCA57) UNAME_MACHINE=alphapca56 ;; -+ EV6) UNAME_MACHINE=alphaev6 ;; -+ EV67) UNAME_MACHINE=alphaev67 ;; -+ EV68*) UNAME_MACHINE=alphaev68 ;; -+ esac -+ objdump --private-headers /bin/sh | grep -q ld.so.1 -+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ arc:Linux:*:* | arceb:Linux:*:* | arc64:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - arm*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ set_cc_for_build -+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ -+ | grep -q __ARM_EABI__ -+ then -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ else -+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ -+ | grep -q __ARM_PCS_VFP -+ then -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi -+ else -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf -+ fi -+ fi -+ exit ;; -+ avr32*:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - cris:Linux:*:*) -- echo cris-axis-linux-gnu -- exit 0 ;; -+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC" -+ exit ;; -+ crisv32:Linux:*:*) -+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC" -+ exit ;; -+ e2k:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ frv:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ hexagon:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ i*86:Linux:*:*) -+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC" -+ exit ;; - ia64:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ k1om:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - m32r*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - m68*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -- mips:Linux:*:*) -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ mips:Linux:*:* | mips64:Linux:*:*) -+ set_cc_for_build -+ IS_GLIBC=0 -+ test x"${LIBC}" = xgnu && IS_GLIBC=1 -+ sed 's/^ //' << EOF > "$dummy.c" - #undef CPU - #undef mips - #undef mipsel -- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) -- CPU=mipsel -+ #undef mips64 -+ #undef mips64el -+ #if ${IS_GLIBC} && defined(_ABI64) -+ LIBCABI=gnuabi64 - #else -- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) -- CPU=mips -+ #if ${IS_GLIBC} && defined(_ABIN32) -+ LIBCABI=gnuabin32 - #else -- CPU= -+ LIBCABI=${LIBC} - #endif - #endif --EOF -- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` -- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 -- ;; -- mips64:Linux:*:*) -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -- #undef CPU -- #undef mips64 -- #undef mips64el -+ -+ #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 -+ CPU=mipsisa64r6 -+ #else -+ #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 -+ CPU=mipsisa32r6 -+ #else -+ #if defined(__mips64) -+ CPU=mips64 -+ #else -+ CPU=mips -+ #endif -+ #endif -+ #endif -+ - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) -- CPU=mips64el -+ MIPS_ENDIAN=el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) -- CPU=mips64 -+ MIPS_ENDIAN= - #else -- CPU= -+ MIPS_ENDIAN= - #endif - #endif - EOF -- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` -- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 -+ eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI')" -+ test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } - ;; -- ppc:Linux:*:*) -- echo powerpc-unknown-linux-gnu -- exit 0 ;; -- ppc64:Linux:*:*) -- echo powerpc64-unknown-linux-gnu -- exit 0 ;; -- alpha:Linux:*:*) -- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in -- EV5) UNAME_MACHINE=alphaev5 ;; -- EV56) UNAME_MACHINE=alphaev56 ;; -- PCA56) UNAME_MACHINE=alphapca56 ;; -- PCA57) UNAME_MACHINE=alphapca56 ;; -- EV6) UNAME_MACHINE=alphaev6 ;; -- EV67) UNAME_MACHINE=alphaev67 ;; -- EV68*) UNAME_MACHINE=alphaev68 ;; -- esac -- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null -- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi -- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} -- exit 0 ;; -+ mips64el:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ openrisc*:Linux:*:*) -+ echo or1k-unknown-linux-"$LIBC" -+ exit ;; -+ or32:Linux:*:* | or1k*:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ padre:Linux:*:*) -+ echo sparc-unknown-linux-"$LIBC" -+ exit ;; -+ parisc64:Linux:*:* | hppa64:Linux:*:*) -+ echo hppa64-unknown-linux-"$LIBC" -+ exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level -- case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in -- PA7*) echo hppa1.1-unknown-linux-gnu ;; -- PA8*) echo hppa2.0-unknown-linux-gnu ;; -- *) echo hppa-unknown-linux-gnu ;; -+ case $(grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2) in -+ PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; -+ PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; -+ *) echo hppa-unknown-linux-"$LIBC" ;; - esac -- exit 0 ;; -- parisc64:Linux:*:* | hppa64:Linux:*:*) -- echo hppa64-unknown-linux-gnu -- exit 0 ;; -+ exit ;; -+ ppc64:Linux:*:*) -+ echo powerpc64-unknown-linux-"$LIBC" -+ exit ;; -+ ppc:Linux:*:*) -+ echo powerpc-unknown-linux-"$LIBC" -+ exit ;; -+ ppc64le:Linux:*:*) -+ echo powerpc64le-unknown-linux-"$LIBC" -+ exit ;; -+ ppcle:Linux:*:*) -+ echo powerpcle-unknown-linux-"$LIBC" -+ exit ;; -+ riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - s390:Linux:*:* | s390x:Linux:*:*) -- echo ${UNAME_MACHINE}-ibm-linux -- exit 0 ;; -+ echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" -+ exit ;; - sh64*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - sh*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-gnu -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ tile*:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ vax:Linux:*:*) -+ echo "$UNAME_MACHINE"-dec-linux-"$LIBC" -+ exit ;; - x86_64:Linux:*:*) -- echo x86_64-unknown-linux-gnu -- exit 0 ;; -- i*86:Linux:*:*) -- # The BFD linker knows what the default object file format is, so -- # first see if it will tell us. cd to the root directory to prevent -- # problems with other programs or directories called `ld' in the path. -- # Set LC_ALL=C to ensure ld outputs messages in English. -- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ -- | sed -ne '/supported targets:/!d -- s/[ ][ ]*/ /g -- s/.*supported targets: *// -- s/ .*// -- p'` -- case "$ld_supported_targets" in -- elf32-i386) -- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" -- ;; -- a.out-i386-linux) -- echo "${UNAME_MACHINE}-pc-linux-gnuaout" -- exit 0 ;; -- coff-i386) -- echo "${UNAME_MACHINE}-pc-linux-gnucoff" -- exit 0 ;; -- "") -- # Either a pre-BFD a.out linker (linux-gnuoldld) or -- # one that does not give us useful --help. -- echo "${UNAME_MACHINE}-pc-linux-gnuoldld" -- exit 0 ;; -- esac -- # Determine whether the default compiler is a.out or elf -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -- #include -- #ifdef __ELF__ -- # ifdef __GLIBC__ -- # if __GLIBC__ >= 2 -- LIBC=gnu -- # else -- LIBC=gnulibc1 -- # endif -- # else -- LIBC=gnulibc1 -- # endif -- #else -- #ifdef __INTEL_COMPILER -- LIBC=gnu -- #else -- LIBC=gnuaout -- #endif -- #endif -- #ifdef __dietlibc__ -- LIBC=dietlibc -- #endif --EOF -- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` -- test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 -- test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 -- ;; -+ set_cc_for_build -+ LIBCABI=$LIBC -+ if test "$CC_FOR_BUILD" != no_compiler_found; then -+ if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ -+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ -+ grep IS_X32 >/dev/null -+ then -+ LIBCABI="$LIBC"x32 -+ fi -+ fi -+ echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" -+ exit ;; -+ xtensa*:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 -- exit 0 ;; -+ exit ;; - i*86:UNIX_SV:4.2MP:2.*) -- # Unixware is an offshoot of SVR4, but it has its own version -- # number series starting with 2... -- # I am not positive that other SVR4 systems won't match this, -+ # Unixware is an offshoot of SVR4, but it has its own version -+ # number series starting with 2... -+ # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. -- # Use sysv4.2uw... so that sysv4* matches it. -- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} -- exit 0 ;; -+ # Use sysv4.2uw... so that sysv4* matches it. -+ echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" -+ exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. -- echo ${UNAME_MACHINE}-pc-os2-emx -- exit 0 ;; -+ echo "$UNAME_MACHINE"-pc-os2-emx -+ exit ;; - i*86:XTS-300:*:STOP) -- echo ${UNAME_MACHINE}-unknown-stop -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-stop -+ exit ;; - i*86:atheos:*:*) -- echo ${UNAME_MACHINE}-unknown-atheos -- exit 0 ;; -- i*86:syllable:*:*) -- echo ${UNAME_MACHINE}-pc-syllable -- exit 0 ;; -- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) -- echo i386-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-atheos -+ exit ;; -+ i*86:syllable:*:*) -+ echo "$UNAME_MACHINE"-pc-syllable -+ exit ;; -+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) -+ echo i386-unknown-lynxos"$UNAME_RELEASE" -+ exit ;; - i*86:*DOS:*:*) -- echo ${UNAME_MACHINE}-pc-msdosdjgpp -- exit 0 ;; -- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) -- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` -+ echo "$UNAME_MACHINE"-pc-msdosdjgpp -+ exit ;; -+ i*86:*:4.*:*) -+ UNAME_REL=$(echo "$UNAME_RELEASE" | sed 's/\/MP$//') - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then -- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} -+ echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" - else -- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} -+ echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" - fi -- exit 0 ;; -- i*86:*:5:[78]*) -- case `/bin/uname -X | grep "^Machine"` in -+ exit ;; -+ i*86:*:5:[678]*) -+ # UnixWare 7.x, OpenUNIX and OpenServer 6. -+ case $(/bin/uname -X | grep "^Machine") in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac -- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} -- exit 0 ;; -+ echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" -+ exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then -- UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then -- UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` -+ UNAME_REL=$( (/bin/uname -X|grep Release|sed -e 's/.*= //')) - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 -@@ -1045,221 +1190,328 @@ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 -- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL -+ echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" - else -- echo ${UNAME_MACHINE}-pc-sysv32 -+ echo "$UNAME_MACHINE"-pc-sysv32 - fi -- exit 0 ;; -+ exit ;; - pc:*:*:*) - # Left here for compatibility: -- # uname -m prints for DJGPP always 'pc', but it prints nothing about -- # the processor, so we play safe by assuming i386. -- echo i386-pc-msdosdjgpp -- exit 0 ;; -+ # uname -m prints for DJGPP always 'pc', but it prints nothing about -+ # the processor, so we play safe by assuming i586. -+ # Note: whatever this is, it MUST be the same as what config.sub -+ # prints for the "djgpp" host, or else GDB configure will decide that -+ # this is a cross-build. -+ echo i586-pc-msdosdjgpp -+ exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 -- exit 0 ;; -+ exit ;; - paragon:*:*:*) - echo i860-intel-osf1 -- exit 0 ;; -+ exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then -- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 -+ echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. -- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 -+ echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 - fi -- exit 0 ;; -+ exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv -- exit 0 ;; -+ exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv -- exit 0 ;; -+ exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix -- exit 0 ;; -+ exit ;; - M68*:*:R3V[5678]*:*) -- test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; -- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) -+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; -+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ -- && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` -+ && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -- && echo i486-ncr-sysv4.3${OS_REL} && exit 0 -+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ -- && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; -+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) -- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -- && echo i486-ncr-sysv4 && exit 0 ;; -+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -+ && { echo i486-ncr-sysv4; exit; } ;; -+ NCR*:*:4.2:* | MPRAS*:*:4.2:*) -+ OS_REL='.3' -+ test -r /etc/.relid \ -+ && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) -+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } -+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ -+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } -+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ -+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) -- echo m68k-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-unknown-lynxos"$UNAME_RELEASE" -+ exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 -- exit 0 ;; -+ exit ;; - TSUNAMI:LynxOS:2.*:*) -- echo sparc-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ echo sparc-unknown-lynxos"$UNAME_RELEASE" -+ exit ;; - rs6000:LynxOS:2.*:*) -- echo rs6000-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) -- echo powerpc-unknown-lynxos${UNAME_RELEASE} -- exit 0 ;; -+ echo rs6000-unknown-lynxos"$UNAME_RELEASE" -+ exit ;; -+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) -+ echo powerpc-unknown-lynxos"$UNAME_RELEASE" -+ exit ;; - SM[BE]S:UNIX_SV:*:*) -- echo mips-dde-sysv${UNAME_RELEASE} -- exit 0 ;; -+ echo mips-dde-sysv"$UNAME_RELEASE" -+ exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 -- exit 0 ;; -+ exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 -- exit 0 ;; -+ exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then -- UNAME_MACHINE=`(uname -p) 2>/dev/null` -- echo ${UNAME_MACHINE}-sni-sysv4 -+ UNAME_MACHINE=$( (uname -p) 2>/dev/null) -+ echo "$UNAME_MACHINE"-sni-sysv4 - else - echo ns32k-sni-sysv - fi -- exit 0 ;; -- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort -- # says -- echo i586-unisys-sysv4 -- exit 0 ;; -+ exit ;; -+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort -+ # says -+ echo i586-unisys-sysv4 -+ exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 -- exit 0 ;; -+ exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 -- exit 0 ;; -+ exit ;; -+ i*86:VOS:*:*) -+ # From Paul.Green@stratus.com. -+ echo "$UNAME_MACHINE"-stratus-vos -+ exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos -- exit 0 ;; -+ exit ;; - mc68*:A/UX:*:*) -- echo m68k-apple-aux${UNAME_RELEASE} -- exit 0 ;; -+ echo m68k-apple-aux"$UNAME_RELEASE" -+ exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 -- exit 0 ;; -+ exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) -- if [ -d /usr/nec ]; then -- echo mips-nec-sysv${UNAME_RELEASE} -+ if test -d /usr/nec; then -+ echo mips-nec-sysv"$UNAME_RELEASE" - else -- echo mips-unknown-sysv${UNAME_RELEASE} -+ echo mips-unknown-sysv"$UNAME_RELEASE" - fi -- exit 0 ;; -+ exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos -- exit 0 ;; -+ exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos -- exit 0 ;; -+ exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos -- exit 0 ;; -+ exit ;; -+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible. -+ echo i586-pc-haiku -+ exit ;; -+ x86_64:Haiku:*:*) -+ echo x86_64-unknown-haiku -+ exit ;; - SX-4:SUPER-UX:*:*) -- echo sx4-nec-superux${UNAME_RELEASE} -- exit 0 ;; -+ echo sx4-nec-superux"$UNAME_RELEASE" -+ exit ;; - SX-5:SUPER-UX:*:*) -- echo sx5-nec-superux${UNAME_RELEASE} -- exit 0 ;; -+ echo sx5-nec-superux"$UNAME_RELEASE" -+ exit ;; - SX-6:SUPER-UX:*:*) -- echo sx6-nec-superux${UNAME_RELEASE} -- exit 0 ;; -+ echo sx6-nec-superux"$UNAME_RELEASE" -+ exit ;; -+ SX-7:SUPER-UX:*:*) -+ echo sx7-nec-superux"$UNAME_RELEASE" -+ exit ;; -+ SX-8:SUPER-UX:*:*) -+ echo sx8-nec-superux"$UNAME_RELEASE" -+ exit ;; -+ SX-8R:SUPER-UX:*:*) -+ echo sx8r-nec-superux"$UNAME_RELEASE" -+ exit ;; -+ SX-ACE:SUPER-UX:*:*) -+ echo sxace-nec-superux"$UNAME_RELEASE" -+ exit ;; - Power*:Rhapsody:*:*) -- echo powerpc-apple-rhapsody${UNAME_RELEASE} -- exit 0 ;; -+ echo powerpc-apple-rhapsody"$UNAME_RELEASE" -+ exit ;; - *:Rhapsody:*:*) -- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" -+ exit ;; -+ arm64:Darwin:*:*) -+ echo aarch64-apple-darwin"$UNAME_RELEASE" -+ exit ;; - *:Darwin:*:*) -- case `uname -p` in -- *86) UNAME_PROCESSOR=i686 ;; -- powerpc) UNAME_PROCESSOR=powerpc ;; -+ UNAME_PROCESSOR=$(uname -p) -+ case $UNAME_PROCESSOR in -+ unknown) UNAME_PROCESSOR=powerpc ;; - esac -- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} -- exit 0 ;; -+ if command -v xcode-select > /dev/null 2> /dev/null && \ -+ ! xcode-select --print-path > /dev/null 2> /dev/null ; then -+ # Avoid executing cc if there is no toolchain installed as -+ # cc will be a stub that puts up a graphical alert -+ # prompting the user to install developer tools. -+ CC_FOR_BUILD=no_compiler_found -+ else -+ set_cc_for_build -+ fi -+ if test "$CC_FOR_BUILD" != no_compiler_found; then -+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ -+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ -+ grep IS_64BIT_ARCH >/dev/null -+ then -+ case $UNAME_PROCESSOR in -+ i386) UNAME_PROCESSOR=x86_64 ;; -+ powerpc) UNAME_PROCESSOR=powerpc64 ;; -+ esac -+ fi -+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc -+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ -+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ -+ grep IS_PPC >/dev/null -+ then -+ UNAME_PROCESSOR=powerpc -+ fi -+ elif test "$UNAME_PROCESSOR" = i386 ; then -+ # uname -m returns i386 or x86_64 -+ UNAME_PROCESSOR=$UNAME_MACHINE -+ fi -+ echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" -+ exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) -- UNAME_PROCESSOR=`uname -p` -- if test "$UNAME_PROCESSOR" = "x86"; then -+ UNAME_PROCESSOR=$(uname -p) -+ if test "$UNAME_PROCESSOR" = x86; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi -- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" -+ exit ;; - *:QNX:*:4*) - echo i386-pc-qnx -- exit 0 ;; -- NSR-?:NONSTOP_KERNEL:*:*) -- echo nsr-tandem-nsk${UNAME_RELEASE} -- exit 0 ;; -+ exit ;; -+ NEO-*:NONSTOP_KERNEL:*:*) -+ echo neo-tandem-nsk"$UNAME_RELEASE" -+ exit ;; -+ NSE-*:NONSTOP_KERNEL:*:*) -+ echo nse-tandem-nsk"$UNAME_RELEASE" -+ exit ;; -+ NSR-*:NONSTOP_KERNEL:*:*) -+ echo nsr-tandem-nsk"$UNAME_RELEASE" -+ exit ;; -+ NSV-*:NONSTOP_KERNEL:*:*) -+ echo nsv-tandem-nsk"$UNAME_RELEASE" -+ exit ;; -+ NSX-*:NONSTOP_KERNEL:*:*) -+ echo nsx-tandem-nsk"$UNAME_RELEASE" -+ exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux -- exit 0 ;; -+ exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv -- exit 0 ;; -+ exit ;; - DS/*:UNIX_System_V:*:*) -- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} -- exit 0 ;; -+ echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" -+ exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. -- if test "$cputype" = "386"; then -+ if test "${cputype-}" = 386; then - UNAME_MACHINE=i386 -- else -+ elif test "x${cputype-}" != x; then - UNAME_MACHINE="$cputype" - fi -- echo ${UNAME_MACHINE}-unknown-plan9 -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-plan9 -+ exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 -- exit 0 ;; -+ exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex -- exit 0 ;; -+ exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 -- exit 0 ;; -+ exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 -- exit 0 ;; -+ exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 -- exit 0 ;; -+ exit ;; - *:ITS:*:*) - echo pdp10-unknown-its -- exit 0 ;; -+ exit ;; - SEI:*:*:SEIUX) -- echo mips-sei-seiux${UNAME_RELEASE} -- exit 0 ;; -+ echo mips-sei-seiux"$UNAME_RELEASE" -+ exit ;; - *:DragonFly:*:*) -- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` -- exit 0 ;; -+ echo "$UNAME_MACHINE"-unknown-dragonfly"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" -+ exit ;; - *:*VMS:*:*) -- UNAME_MACHINE=`(uname -p) 2>/dev/null` -- case "${UNAME_MACHINE}" in -- A*) echo alpha-dec-vms && exit 0 ;; -- I*) echo ia64-dec-vms && exit 0 ;; -- V*) echo vax-dec-vms && exit 0 ;; -- esac -+ UNAME_MACHINE=$( (uname -p) 2>/dev/null) -+ case $UNAME_MACHINE in -+ A*) echo alpha-dec-vms ; exit ;; -+ I*) echo ia64-dec-vms ; exit ;; -+ V*) echo vax-dec-vms ; exit ;; -+ esac ;; -+ *:XENIX:*:SysV) -+ echo i386-pc-xenix -+ exit ;; -+ i*86:skyos:*:*) -+ echo "$UNAME_MACHINE"-pc-skyos"$(echo "$UNAME_RELEASE" | sed -e 's/ .*$//')" -+ exit ;; -+ i*86:rdos:*:*) -+ echo "$UNAME_MACHINE"-pc-rdos -+ exit ;; -+ *:AROS:*:*) -+ echo "$UNAME_MACHINE"-unknown-aros -+ exit ;; -+ x86_64:VMkernel:*:*) -+ echo "$UNAME_MACHINE"-unknown-esx -+ exit ;; -+ amd64:Isilon\ OneFS:*:*) -+ echo x86_64-unknown-onefs -+ exit ;; -+ *:Unleashed:*:*) -+ echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" -+ exit ;; - esac - --#echo '(No uname command or uname output not recognized.)' 1>&2 --#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 -- --eval $set_cc_for_build --cat >$dummy.c < "$dummy.c" < --# include -+#include -+#include -+#endif -+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) -+#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) -+#include -+#if defined(_SIZE_T_) || defined(SIGLOST) -+#include -+#endif -+#endif - #endif - main () - { -@@ -1272,28 +1524,20 @@ - #include - printf ("m68k-sony-newsos%s\n", - #ifdef NEWSOS4 -- "4" -+ "4" - #else -- "" -+ "" - #endif -- ); exit (0); -+ ); exit (0); - #endif - #endif - --#if defined (__arm) && defined (__acorn) && defined (__unix) -- printf ("arm-acorn-riscix"); exit (0); --#endif -- --#if defined (hp300) && !defined (hpux) -- printf ("m68k-hp-bsd\n"); exit (0); --#endif -- - #if defined (NeXT) - #if !defined (__ARCHITECTURE__) - #define __ARCHITECTURE__ "m68k" - #endif - int version; -- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; -+ version=$( (hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null); - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else -@@ -1327,39 +1571,54 @@ - #endif - - #if defined (_SEQUENT_) -- struct utsname un; -- -- uname(&un); -- -- if (strncmp(un.version, "V2", 2) == 0) { -- printf ("i386-sequent-ptx2\n"); exit (0); -- } -- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ -- printf ("i386-sequent-ptx1\n"); exit (0); -- } -- printf ("i386-sequent-ptx\n"); exit (0); -+ struct utsname un; - -+ uname(&un); -+ if (strncmp(un.version, "V2", 2) == 0) { -+ printf ("i386-sequent-ptx2\n"); exit (0); -+ } -+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ -+ printf ("i386-sequent-ptx1\n"); exit (0); -+ } -+ printf ("i386-sequent-ptx\n"); exit (0); - #endif - - #if defined (vax) --# if !defined (ultrix) --# include --# if defined (BSD) --# if BSD == 43 -- printf ("vax-dec-bsd4.3\n"); exit (0); --# else --# if BSD == 199006 -- printf ("vax-dec-bsd4.3reno\n"); exit (0); --# else -- printf ("vax-dec-bsd\n"); exit (0); --# endif --# endif --# else -- printf ("vax-dec-bsd\n"); exit (0); --# endif --# else -- printf ("vax-dec-ultrix\n"); exit (0); --# endif -+#if !defined (ultrix) -+#include -+#if defined (BSD) -+#if BSD == 43 -+ printf ("vax-dec-bsd4.3\n"); exit (0); -+#else -+#if BSD == 199006 -+ printf ("vax-dec-bsd4.3reno\n"); exit (0); -+#else -+ printf ("vax-dec-bsd\n"); exit (0); -+#endif -+#endif -+#else -+ printf ("vax-dec-bsd\n"); exit (0); -+#endif -+#else -+#if defined(_SIZE_T_) || defined(SIGLOST) -+ struct utsname un; -+ uname (&un); -+ printf ("vax-dec-ultrix%s\n", un.release); exit (0); -+#else -+ printf ("vax-dec-ultrix\n"); exit (0); -+#endif -+#endif -+#endif -+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) -+#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) -+#if defined(_SIZE_T_) || defined(SIGLOST) -+ struct utsname *un; -+ uname (&un); -+ printf ("mips-dec-ultrix%s\n", un.release); exit (0); -+#else -+ printf ("mips-dec-ultrix\n"); exit (0); -+#endif -+#endif - #endif - - #if defined (alliant) && defined (i860) -@@ -1370,80 +1629,74 @@ - } - EOF - --$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 -+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=$($dummy) && -+ { echo "$SYSTEM_NAME"; exit; } - - # Apollos put the system type in the environment. -+test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } - --test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } -+echo "$0: unable to guess system type" >&2 - --# Convex versions that predate uname can use getsysinfo(1) -+case $UNAME_MACHINE:$UNAME_SYSTEM in -+ mips:Linux | mips64:Linux) -+ # If we got here on MIPS GNU/Linux, output extra information. -+ cat >&2 <&2 < in order to provide the needed --information to handle your system. -+This script (version $timestamp), has failed to recognize the -+operating system you are using. If your script is old, overwrite *all* -+copies of config.guess and config.sub with the latest versions from: -+ -+ https://git.savannah.gnu.org/cgit/config.git/plain/config.guess -+and -+ https://git.savannah.gnu.org/cgit/config.git/plain/config.sub -+EOF -+ -+year=$(echo $timestamp | sed 's,-.*,,') -+# shellcheck disable=SC2003 -+if test "$(expr "$(date +%Y)" - "$year")" -lt 3 ; then -+ cat >&2 </dev/null || echo unknown` --uname -r = `(uname -r) 2>/dev/null || echo unknown` --uname -s = `(uname -s) 2>/dev/null || echo unknown` --uname -v = `(uname -v) 2>/dev/null || echo unknown` -- --/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` --/bin/uname -X = `(/bin/uname -X) 2>/dev/null` -- --hostinfo = `(hostinfo) 2>/dev/null` --/bin/universe = `(/bin/universe) 2>/dev/null` --/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` --/bin/arch = `(/bin/arch) 2>/dev/null` --/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` --/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -- --UNAME_MACHINE = ${UNAME_MACHINE} --UNAME_RELEASE = ${UNAME_RELEASE} --UNAME_SYSTEM = ${UNAME_SYSTEM} --UNAME_VERSION = ${UNAME_VERSION} -+uname -m = $( (uname -m) 2>/dev/null || echo unknown) -+uname -r = $( (uname -r) 2>/dev/null || echo unknown) -+uname -s = $( (uname -s) 2>/dev/null || echo unknown) -+uname -v = $( (uname -v) 2>/dev/null || echo unknown) -+ -+/usr/bin/uname -p = $( (/usr/bin/uname -p) 2>/dev/null) -+/bin/uname -X = $( (/bin/uname -X) 2>/dev/null) -+ -+hostinfo = $( (hostinfo) 2>/dev/null) -+/bin/universe = $( (/bin/universe) 2>/dev/null) -+/usr/bin/arch -k = $( (/usr/bin/arch -k) 2>/dev/null) -+/bin/arch = $( (/bin/arch) 2>/dev/null) -+/usr/bin/oslevel = $( (/usr/bin/oslevel) 2>/dev/null) -+/usr/convex/getsysinfo = $( (/usr/convex/getsysinfo) 2>/dev/null) -+ -+UNAME_MACHINE = "$UNAME_MACHINE" -+UNAME_RELEASE = "$UNAME_RELEASE" -+UNAME_SYSTEM = "$UNAME_SYSTEM" -+UNAME_VERSION = "$UNAME_VERSION" - EOF -+fi - - exit 1 - - # Local variables: --# eval: (add-hook 'write-file-hooks 'time-stamp) -+# eval: (add-hook 'before-save-hook 'time-stamp) - # time-stamp-start: "timestamp='" - # time-stamp-format: "%:y-%02m-%02d" - # time-stamp-end: "'" --# End: -+# End: -\ No newline at end of file diff --git a/tools/ucl/patches/200-ucl-apple-m1-configsub-fix.patch b/tools/ucl/patches/200-ucl-apple-m1-configsub-fix.patch deleted file mode 100644 index d9e546972..000000000 --- a/tools/ucl/patches/200-ucl-apple-m1-configsub-fix.patch +++ /dev/null @@ -1,2923 +0,0 @@ ---- a/acconfig/config.sub 2004-07-20 07:01:47.000000000 +0800 -+++ b/acconfig/config.sub 2021-08-13 14:32:23.000000000 +0800 -@@ -1,42 +1,40 @@ - #! /bin/sh - # Configuration validation subroutine script. --# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, --# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. -+# Copyright 1992-2021 Free Software Foundation, Inc. - --timestamp='2004-06-24' -+timestamp='2021-04-30' - --# This file is (in principle) common to ALL GNU software. --# The presence of a machine in this file suggests that SOME GNU software --# can handle that machine. It does not imply ALL GNU software can. --# --# This file 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; either version 2 of the License, or -+# This file 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; either version 3 of the License, or - # (at your option) any later version. - # --# This program is distributed in the hope that it will be useful, --# but WITHOUT ANY WARRANTY; without even the implied warranty of --# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --# GNU General Public License for more details. -+# This program is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# General Public License for more details. - # - # You should have received a copy of the GNU General Public License --# along with this program; if not, write to the Free Software --# Foundation, Inc., 59 Temple Place - Suite 330, --# Boston, MA 02111-1307, USA. -- -+# along with this program; if not, see . -+# - # As a special exception to the GNU General Public License, if you - # distribute this file as part of a program that contains a - # configuration script generated by Autoconf, you may include it under --# the same distribution terms that you use for the rest of that program. -+# the same distribution terms that you use for the rest of that -+# program. This Exception is an additional permission under section 7 -+# of the GNU General Public License, version 3 ("GPLv3"). -+ - --# Please send patches to . Submit a context --# diff and a properly formatted ChangeLog entry. -+# Please send patches to . - # - # Configuration subroutine to validate and canonicalize a configuration type. - # Supply the specified configuration type as an argument. - # If it is invalid, we print an error message on stderr and exit with code 1. - # Otherwise, we print the canonical config type on stdout and succeed. - -+# You can get the latest version of this script from: -+# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub -+ - # This file is supposed to be the same for all GNU packages - # and recognize all the CPU types, system types and aliases - # that are meaningful with *any* GNU software. -@@ -52,15 +50,14 @@ timestamp='2004-06-24' - # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM - # It is wrong to echo any other type of specification. - --me=`echo "$0" | sed -e 's,.*/,,'` -+me=$(echo "$0" | sed -e 's,.*/,,') - - usage="\ --Usage: $0 [OPTION] CPU-MFR-OPSYS -- $0 [OPTION] ALIAS -+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS - - Canonicalize a configuration name. - --Operation modes: -+Options: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit -@@ -70,8 +67,7 @@ Report bugs and patches to &2 - exit 1 ;; - - *local*) - # First pass through any local machine types. -- echo $1 -- exit 0;; -+ echo "$1" -+ exit ;; - - * ) - break ;; -@@ -114,1007 +110,1173 @@ case $# in - exit 1;; - esac - --# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). --# Here we must recognize all the valid KERNEL-OS combinations. --maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` --case $maybe_os in -- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ -- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) -- os=-$maybe_os -- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` -- ;; -- *) -- basic_machine=`echo $1 | sed 's/-[^-]*$//'` -- if [ $basic_machine != $1 ] -- then os=`echo $1 | sed 's/.*-/-/'` -- else os=; fi -- ;; --esac -- --### Let's recognize common machines as not being operating systems so --### that things like config.sub decstation-3100 work. We also --### recognize some manufacturers as not being operating systems, so we --### can provide default operating systems below. --case $os in -- -sun*os*) -- # Prevent following clause from handling this invalid input. -- ;; -- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -- -apple | -axis | -knuth | -cray) -- os= -- basic_machine=$1 -- ;; -- -sim | -cisco | -oki | -wec | -winbond) -- os= -- basic_machine=$1 -- ;; -- -scout) -- ;; -- -wrs) -- os=-vxworks -- basic_machine=$1 -- ;; -- -chorusos*) -- os=-chorusos -- basic_machine=$1 -- ;; -- -chorusrdb) -- os=-chorusrdb -- basic_machine=$1 -- ;; -- -hiux*) -- os=-hiuxwe2 -- ;; -- -sco5) -- os=-sco3.2v5 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco4) -- os=-sco3.2v4 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco3.2.[4-9]*) -- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco3.2v[4-9]*) -- # Don't forget version if it is 3.2v4 or newer. -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco*) -- os=-sco3.2v2 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -+# Split fields of configuration type -+# shellcheck disable=SC2162 -+IFS="-" read field1 field2 field3 field4 <&2 -+ exit 1 - ;; -- -udk*) -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -+ *-*-*-*) -+ basic_machine=$field1-$field2 -+ basic_os=$field3-$field4 - ;; -- -isc) -- os=-isc2.2 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -+ *-*-*) -+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two -+ # parts -+ maybe_os=$field2-$field3 -+ case $maybe_os in -+ nto-qnx* | linux-* | uclinux-uclibc* \ -+ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ -+ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ -+ | storm-chaos* | os2-emx* | rtmk-nova*) -+ basic_machine=$field1 -+ basic_os=$maybe_os -+ ;; -+ android-linux) -+ basic_machine=$field1-unknown -+ basic_os=linux-android -+ ;; -+ *) -+ basic_machine=$field1-$field2 -+ basic_os=$field3 -+ ;; -+ esac - ;; -- -clix*) -- basic_machine=clipper-intergraph -+ *-*) -+ # A lone config we happen to match not fitting any pattern -+ case $field1-$field2 in -+ decstation-3100) -+ basic_machine=mips-dec -+ basic_os= -+ ;; -+ *-*) -+ # Second component is usually, but not always the OS -+ case $field2 in -+ # Prevent following clause from handling this valid os -+ sun*os*) -+ basic_machine=$field1 -+ basic_os=$field2 -+ ;; -+ # Manufacturers -+ dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ -+ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ -+ | unicom* | ibm* | next | hp | isi* | apollo | altos* \ -+ | convergent* | ncr* | news | 32* | 3600* | 3100* \ -+ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ -+ | ultra | tti* | harris | dolphin | highlevel | gould \ -+ | cbm | ns | masscomp | apple | axis | knuth | cray \ -+ | microblaze* | sim | cisco \ -+ | oki | wec | wrs | winbond) -+ basic_machine=$field1-$field2 -+ basic_os= -+ ;; -+ *) -+ basic_machine=$field1 -+ basic_os=$field2 -+ ;; -+ esac -+ ;; -+ esac - ;; -- -isc*) -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -+ *) -+ # Convert single-component short-hands not valid as part of -+ # multi-component configurations. -+ case $field1 in -+ 386bsd) -+ basic_machine=i386-pc -+ basic_os=bsd -+ ;; -+ a29khif) -+ basic_machine=a29k-amd -+ basic_os=udi -+ ;; -+ adobe68k) -+ basic_machine=m68010-adobe -+ basic_os=scout -+ ;; -+ alliant) -+ basic_machine=fx80-alliant -+ basic_os= -+ ;; -+ altos | altos3068) -+ basic_machine=m68k-altos -+ basic_os= -+ ;; -+ am29k) -+ basic_machine=a29k-none -+ basic_os=bsd -+ ;; -+ amdahl) -+ basic_machine=580-amdahl -+ basic_os=sysv -+ ;; -+ amiga) -+ basic_machine=m68k-unknown -+ basic_os= -+ ;; -+ amigaos | amigados) -+ basic_machine=m68k-unknown -+ basic_os=amigaos -+ ;; -+ amigaunix | amix) -+ basic_machine=m68k-unknown -+ basic_os=sysv4 -+ ;; -+ apollo68) -+ basic_machine=m68k-apollo -+ basic_os=sysv -+ ;; -+ apollo68bsd) -+ basic_machine=m68k-apollo -+ basic_os=bsd -+ ;; -+ aros) -+ basic_machine=i386-pc -+ basic_os=aros -+ ;; -+ aux) -+ basic_machine=m68k-apple -+ basic_os=aux -+ ;; -+ balance) -+ basic_machine=ns32k-sequent -+ basic_os=dynix -+ ;; -+ blackfin) -+ basic_machine=bfin-unknown -+ basic_os=linux -+ ;; -+ cegcc) -+ basic_machine=arm-unknown -+ basic_os=cegcc -+ ;; -+ convex-c1) -+ basic_machine=c1-convex -+ basic_os=bsd -+ ;; -+ convex-c2) -+ basic_machine=c2-convex -+ basic_os=bsd -+ ;; -+ convex-c32) -+ basic_machine=c32-convex -+ basic_os=bsd -+ ;; -+ convex-c34) -+ basic_machine=c34-convex -+ basic_os=bsd -+ ;; -+ convex-c38) -+ basic_machine=c38-convex -+ basic_os=bsd -+ ;; -+ cray) -+ basic_machine=j90-cray -+ basic_os=unicos -+ ;; -+ crds | unos) -+ basic_machine=m68k-crds -+ basic_os= -+ ;; -+ da30) -+ basic_machine=m68k-da30 -+ basic_os= -+ ;; -+ decstation | pmax | pmin | dec3100 | decstatn) -+ basic_machine=mips-dec -+ basic_os= -+ ;; -+ delta88) -+ basic_machine=m88k-motorola -+ basic_os=sysv3 -+ ;; -+ dicos) -+ basic_machine=i686-pc -+ basic_os=dicos -+ ;; -+ djgpp) -+ basic_machine=i586-pc -+ basic_os=msdosdjgpp -+ ;; -+ ebmon29k) -+ basic_machine=a29k-amd -+ basic_os=ebmon -+ ;; -+ es1800 | OSE68k | ose68k | ose | OSE) -+ basic_machine=m68k-ericsson -+ basic_os=ose -+ ;; -+ gmicro) -+ basic_machine=tron-gmicro -+ basic_os=sysv -+ ;; -+ go32) -+ basic_machine=i386-pc -+ basic_os=go32 -+ ;; -+ h8300hms) -+ basic_machine=h8300-hitachi -+ basic_os=hms -+ ;; -+ h8300xray) -+ basic_machine=h8300-hitachi -+ basic_os=xray -+ ;; -+ h8500hms) -+ basic_machine=h8500-hitachi -+ basic_os=hms -+ ;; -+ harris) -+ basic_machine=m88k-harris -+ basic_os=sysv3 -+ ;; -+ hp300 | hp300hpux) -+ basic_machine=m68k-hp -+ basic_os=hpux -+ ;; -+ hp300bsd) -+ basic_machine=m68k-hp -+ basic_os=bsd -+ ;; -+ hppaosf) -+ basic_machine=hppa1.1-hp -+ basic_os=osf -+ ;; -+ hppro) -+ basic_machine=hppa1.1-hp -+ basic_os=proelf -+ ;; -+ i386mach) -+ basic_machine=i386-mach -+ basic_os=mach -+ ;; -+ isi68 | isi) -+ basic_machine=m68k-isi -+ basic_os=sysv -+ ;; -+ m68knommu) -+ basic_machine=m68k-unknown -+ basic_os=linux -+ ;; -+ magnum | m3230) -+ basic_machine=mips-mips -+ basic_os=sysv -+ ;; -+ merlin) -+ basic_machine=ns32k-utek -+ basic_os=sysv -+ ;; -+ mingw64) -+ basic_machine=x86_64-pc -+ basic_os=mingw64 -+ ;; -+ mingw32) -+ basic_machine=i686-pc -+ basic_os=mingw32 -+ ;; -+ mingw32ce) -+ basic_machine=arm-unknown -+ basic_os=mingw32ce -+ ;; -+ monitor) -+ basic_machine=m68k-rom68k -+ basic_os=coff -+ ;; -+ morphos) -+ basic_machine=powerpc-unknown -+ basic_os=morphos -+ ;; -+ moxiebox) -+ basic_machine=moxie-unknown -+ basic_os=moxiebox -+ ;; -+ msdos) -+ basic_machine=i386-pc -+ basic_os=msdos -+ ;; -+ msys) -+ basic_machine=i686-pc -+ basic_os=msys -+ ;; -+ mvs) -+ basic_machine=i370-ibm -+ basic_os=mvs -+ ;; -+ nacl) -+ basic_machine=le32-unknown -+ basic_os=nacl -+ ;; -+ ncr3000) -+ basic_machine=i486-ncr -+ basic_os=sysv4 -+ ;; -+ netbsd386) -+ basic_machine=i386-pc -+ basic_os=netbsd -+ ;; -+ netwinder) -+ basic_machine=armv4l-rebel -+ basic_os=linux -+ ;; -+ news | news700 | news800 | news900) -+ basic_machine=m68k-sony -+ basic_os=newsos -+ ;; -+ news1000) -+ basic_machine=m68030-sony -+ basic_os=newsos -+ ;; -+ necv70) -+ basic_machine=v70-nec -+ basic_os=sysv -+ ;; -+ nh3000) -+ basic_machine=m68k-harris -+ basic_os=cxux -+ ;; -+ nh[45]000) -+ basic_machine=m88k-harris -+ basic_os=cxux -+ ;; -+ nindy960) -+ basic_machine=i960-intel -+ basic_os=nindy -+ ;; -+ mon960) -+ basic_machine=i960-intel -+ basic_os=mon960 -+ ;; -+ nonstopux) -+ basic_machine=mips-compaq -+ basic_os=nonstopux -+ ;; -+ os400) -+ basic_machine=powerpc-ibm -+ basic_os=os400 -+ ;; -+ OSE68000 | ose68000) -+ basic_machine=m68000-ericsson -+ basic_os=ose -+ ;; -+ os68k) -+ basic_machine=m68k-none -+ basic_os=os68k -+ ;; -+ paragon) -+ basic_machine=i860-intel -+ basic_os=osf -+ ;; -+ parisc) -+ basic_machine=hppa-unknown -+ basic_os=linux -+ ;; -+ psp) -+ basic_machine=mipsallegrexel-sony -+ basic_os=psp -+ ;; -+ pw32) -+ basic_machine=i586-unknown -+ basic_os=pw32 -+ ;; -+ rdos | rdos64) -+ basic_machine=x86_64-pc -+ basic_os=rdos -+ ;; -+ rdos32) -+ basic_machine=i386-pc -+ basic_os=rdos -+ ;; -+ rom68k) -+ basic_machine=m68k-rom68k -+ basic_os=coff -+ ;; -+ sa29200) -+ basic_machine=a29k-amd -+ basic_os=udi -+ ;; -+ sei) -+ basic_machine=mips-sei -+ basic_os=seiux -+ ;; -+ sequent) -+ basic_machine=i386-sequent -+ basic_os= -+ ;; -+ sps7) -+ basic_machine=m68k-bull -+ basic_os=sysv2 -+ ;; -+ st2000) -+ basic_machine=m68k-tandem -+ basic_os= -+ ;; -+ stratus) -+ basic_machine=i860-stratus -+ basic_os=sysv4 -+ ;; -+ sun2) -+ basic_machine=m68000-sun -+ basic_os= -+ ;; -+ sun2os3) -+ basic_machine=m68000-sun -+ basic_os=sunos3 -+ ;; -+ sun2os4) -+ basic_machine=m68000-sun -+ basic_os=sunos4 -+ ;; -+ sun3) -+ basic_machine=m68k-sun -+ basic_os= -+ ;; -+ sun3os3) -+ basic_machine=m68k-sun -+ basic_os=sunos3 -+ ;; -+ sun3os4) -+ basic_machine=m68k-sun -+ basic_os=sunos4 -+ ;; -+ sun4) -+ basic_machine=sparc-sun -+ basic_os= -+ ;; -+ sun4os3) -+ basic_machine=sparc-sun -+ basic_os=sunos3 -+ ;; -+ sun4os4) -+ basic_machine=sparc-sun -+ basic_os=sunos4 -+ ;; -+ sun4sol2) -+ basic_machine=sparc-sun -+ basic_os=solaris2 -+ ;; -+ sun386 | sun386i | roadrunner) -+ basic_machine=i386-sun -+ basic_os= -+ ;; -+ sv1) -+ basic_machine=sv1-cray -+ basic_os=unicos -+ ;; -+ symmetry) -+ basic_machine=i386-sequent -+ basic_os=dynix -+ ;; -+ t3e) -+ basic_machine=alphaev5-cray -+ basic_os=unicos -+ ;; -+ t90) -+ basic_machine=t90-cray -+ basic_os=unicos -+ ;; -+ toad1) -+ basic_machine=pdp10-xkl -+ basic_os=tops20 -+ ;; -+ tpf) -+ basic_machine=s390x-ibm -+ basic_os=tpf -+ ;; -+ udi29k) -+ basic_machine=a29k-amd -+ basic_os=udi -+ ;; -+ ultra3) -+ basic_machine=a29k-nyu -+ basic_os=sym1 -+ ;; -+ v810 | necv810) -+ basic_machine=v810-nec -+ basic_os=none -+ ;; -+ vaxv) -+ basic_machine=vax-dec -+ basic_os=sysv -+ ;; -+ vms) -+ basic_machine=vax-dec -+ basic_os=vms -+ ;; -+ vsta) -+ basic_machine=i386-pc -+ basic_os=vsta -+ ;; -+ vxworks960) -+ basic_machine=i960-wrs -+ basic_os=vxworks -+ ;; -+ vxworks68) -+ basic_machine=m68k-wrs -+ basic_os=vxworks -+ ;; -+ vxworks29k) -+ basic_machine=a29k-wrs -+ basic_os=vxworks -+ ;; -+ xbox) -+ basic_machine=i686-pc -+ basic_os=mingw32 -+ ;; -+ ymp) -+ basic_machine=ymp-cray -+ basic_os=unicos -+ ;; -+ *) -+ basic_machine=$1 -+ basic_os= -+ ;; -+ esac - ;; -- -lynx*) -- os=-lynxos -+esac -+ -+# Decode 1-component or ad-hoc basic machines -+case $basic_machine in -+ # Here we handle the default manufacturer of certain CPU types. It is in -+ # some cases the only manufacturer, in others, it is the most popular. -+ w89k) -+ cpu=hppa1.1 -+ vendor=winbond - ;; -- -ptx*) -- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` -+ op50n) -+ cpu=hppa1.1 -+ vendor=oki - ;; -- -windowsnt*) -- os=`echo $os | sed -e 's/windowsnt/winnt/'` -+ op60c) -+ cpu=hppa1.1 -+ vendor=oki - ;; -- -psos*) -- os=-psos -+ ibm*) -+ cpu=i370 -+ vendor=ibm - ;; -- -mint | -mint[0-9]*) -- basic_machine=m68k-atari -- os=-mint -+ orion105) -+ cpu=clipper -+ vendor=highlevel - ;; --esac -- --# Decode aliases for certain CPU-COMPANY combinations. --case $basic_machine in -- # Recognize the basic CPU types without company name. -- # Some are omitted here because they have special meanings below. -- 1750a | 580 \ -- | a29k \ -- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ -- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ -- | am33_2.0 \ -- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ -- | c4x | clipper \ -- | d10v | d30v | dlx | dsp16xx \ -- | fr30 | frv \ -- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ -- | i370 | i860 | i960 | ia64 \ -- | ip2k | iq2000 \ -- | m32r | m32rle | m68000 | m68k | m88k | mcore \ -- | mips | mipsbe | mipseb | mipsel | mipsle \ -- | mips16 \ -- | mips64 | mips64el \ -- | mips64vr | mips64vrel \ -- | mips64orion | mips64orionel \ -- | mips64vr4100 | mips64vr4100el \ -- | mips64vr4300 | mips64vr4300el \ -- | mips64vr5000 | mips64vr5000el \ -- | mipsisa32 | mipsisa32el \ -- | mipsisa32r2 | mipsisa32r2el \ -- | mipsisa64 | mipsisa64el \ -- | mipsisa64r2 | mipsisa64r2el \ -- | mipsisa64sb1 | mipsisa64sb1el \ -- | mipsisa64sr71k | mipsisa64sr71kel \ -- | mipstx39 | mipstx39el \ -- | mn10200 | mn10300 \ -- | msp430 \ -- | ns16k | ns32k \ -- | openrisc | or32 \ -- | pdp10 | pdp11 | pj | pjl \ -- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ -- | pyramid \ -- | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ -- | sh64 | sh64le \ -- | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ -- | strongarm \ -- | tahoe | thumb | tic4x | tic80 | tron \ -- | v850 | v850e \ -- | we32k \ -- | x86 | xscale | xstormy16 | xtensa \ -- | z8k) -- basic_machine=$basic_machine-unknown -- ;; -- m6811 | m68hc11 | m6812 | m68hc12) -- # Motorola 68HC11/12. -- basic_machine=$basic_machine-unknown -- os=-none -+ mac | mpw | mac-mpw) -+ cpu=m68k -+ vendor=apple - ;; -- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) -+ pmac | pmac-mpw) -+ cpu=powerpc -+ vendor=apple - ;; - -- # We use `pc' rather than `unknown' -- # because (1) that's what they normally are, and -- # (2) the word "unknown" tends to confuse beginning users. -- i*86 | x86_64) -- basic_machine=$basic_machine-pc -- ;; -- # Object if more than one company name word. -- *-*-*) -- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 -- exit 1 -- ;; -- # Recognize the basic CPU types with company name. -- 580-* \ -- | a29k-* \ -- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ -- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ -- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ -- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ -- | avr-* \ -- | bs2000-* \ -- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ -- | clipper-* | craynv-* | cydra-* \ -- | d10v-* | d30v-* | dlx-* \ -- | elxsi-* \ -- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ -- | h8300-* | h8500-* \ -- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ -- | i*86-* | i860-* | i960-* | ia64-* \ -- | ip2k-* | iq2000-* \ -- | m32r-* | m32rle-* \ -- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ -- | m88110-* | m88k-* | mcore-* \ -- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ -- | mips16-* \ -- | mips64-* | mips64el-* \ -- | mips64vr-* | mips64vrel-* \ -- | mips64orion-* | mips64orionel-* \ -- | mips64vr4100-* | mips64vr4100el-* \ -- | mips64vr4300-* | mips64vr4300el-* \ -- | mips64vr5000-* | mips64vr5000el-* \ -- | mipsisa32-* | mipsisa32el-* \ -- | mipsisa32r2-* | mipsisa32r2el-* \ -- | mipsisa64-* | mipsisa64el-* \ -- | mipsisa64r2-* | mipsisa64r2el-* \ -- | mipsisa64sb1-* | mipsisa64sb1el-* \ -- | mipsisa64sr71k-* | mipsisa64sr71kel-* \ -- | mipstx39-* | mipstx39el-* \ -- | mmix-* \ -- | msp430-* \ -- | none-* | np1-* | ns16k-* | ns32k-* \ -- | orion-* \ -- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ -- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ -- | pyramid-* \ -- | romp-* | rs6000-* \ -- | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ -- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ -- | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ -- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ -- | tahoe-* | thumb-* \ -- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ -- | tron-* \ -- | v850-* | v850e-* | vax-* \ -- | we32k-* \ -- | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ -- | xtensa-* \ -- | ymp-* \ -- | z8k-*) -- ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. -- 386bsd) -- basic_machine=i386-unknown -- os=-bsd -- ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) -- basic_machine=m68000-att -+ cpu=m68000 -+ vendor=att - ;; - 3b*) -- basic_machine=we32k-att -- ;; -- a29khif) -- basic_machine=a29k-amd -- os=-udi -- ;; -- abacus) -- basic_machine=abacus-unknown -- ;; -- adobe68k) -- basic_machine=m68010-adobe -- os=-scout -- ;; -- alliant | fx80) -- basic_machine=fx80-alliant -- ;; -- altos | altos3068) -- basic_machine=m68k-altos -- ;; -- am29k) -- basic_machine=a29k-none -- os=-bsd -- ;; -- amd64) -- basic_machine=x86_64-pc -- ;; -- amd64-*) -- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- amdahl) -- basic_machine=580-amdahl -- os=-sysv -- ;; -- amiga | amiga-*) -- basic_machine=m68k-unknown -- ;; -- amigaos | amigados) -- basic_machine=m68k-unknown -- os=-amigaos -- ;; -- amigaunix | amix) -- basic_machine=m68k-unknown -- os=-sysv4 -- ;; -- apollo68) -- basic_machine=m68k-apollo -- os=-sysv -- ;; -- apollo68bsd) -- basic_machine=m68k-apollo -- os=-bsd -+ cpu=we32k -+ vendor=att - ;; -- aux) -- basic_machine=m68k-apple -- os=-aux -- ;; -- balance) -- basic_machine=ns32k-sequent -- os=-dynix -- ;; -- c90) -- basic_machine=c90-cray -- os=-unicos -- ;; -- convex-c1) -- basic_machine=c1-convex -- os=-bsd -- ;; -- convex-c2) -- basic_machine=c2-convex -- os=-bsd -- ;; -- convex-c32) -- basic_machine=c32-convex -- os=-bsd -- ;; -- convex-c34) -- basic_machine=c34-convex -- os=-bsd -- ;; -- convex-c38) -- basic_machine=c38-convex -- os=-bsd -- ;; -- cray | j90) -- basic_machine=j90-cray -- os=-unicos -- ;; -- craynv) -- basic_machine=craynv-cray -- os=-unicosmp -- ;; -- cr16c) -- basic_machine=cr16c-unknown -- os=-elf -- ;; -- crds | unos) -- basic_machine=m68k-crds -- ;; -- cris | cris-* | etrax*) -- basic_machine=cris-axis -- ;; -- crx) -- basic_machine=crx-unknown -- os=-elf -- ;; -- da30 | da30-*) -- basic_machine=m68k-da30 -- ;; -- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) -- basic_machine=mips-dec -+ bluegene*) -+ cpu=powerpc -+ vendor=ibm -+ basic_os=cnk - ;; - decsystem10* | dec10*) -- basic_machine=pdp10-dec -- os=-tops10 -+ cpu=pdp10 -+ vendor=dec -+ basic_os=tops10 - ;; - decsystem20* | dec20*) -- basic_machine=pdp10-dec -- os=-tops20 -+ cpu=pdp10 -+ vendor=dec -+ basic_os=tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) -- basic_machine=m68k-motorola -+ cpu=m68k -+ vendor=motorola - ;; -- delta88) -- basic_machine=m88k-motorola -- os=-sysv3 -- ;; -- dpx20 | dpx20-*) -- basic_machine=rs6000-bull -- os=-bosx -- ;; -- dpx2* | dpx2*-bull) -- basic_machine=m68k-bull -- os=-sysv3 -- ;; -- ebmon29k) -- basic_machine=a29k-amd -- os=-ebmon -- ;; -- elxsi) -- basic_machine=elxsi-elxsi -- os=-bsd -+ dpx2*) -+ cpu=m68k -+ vendor=bull -+ basic_os=sysv3 - ;; - encore | umax | mmax) -- basic_machine=ns32k-encore -+ cpu=ns32k -+ vendor=encore - ;; -- es1800 | OSE68k | ose68k | ose | OSE) -- basic_machine=m68k-ericsson -- os=-ose -+ elxsi) -+ cpu=elxsi -+ vendor=elxsi -+ basic_os=${basic_os:-bsd} - ;; - fx2800) -- basic_machine=i860-alliant -+ cpu=i860 -+ vendor=alliant - ;; - genix) -- basic_machine=ns32k-ns -- ;; -- gmicro) -- basic_machine=tron-gmicro -- os=-sysv -- ;; -- go32) -- basic_machine=i386-pc -- os=-go32 -+ cpu=ns32k -+ vendor=ns - ;; - h3050r* | hiux*) -- basic_machine=hppa1.1-hitachi -- os=-hiuxwe2 -- ;; -- h8300hms) -- basic_machine=h8300-hitachi -- os=-hms -- ;; -- h8300xray) -- basic_machine=h8300-hitachi -- os=-xray -- ;; -- h8500hms) -- basic_machine=h8500-hitachi -- os=-hms -- ;; -- harris) -- basic_machine=m88k-harris -- os=-sysv3 -- ;; -- hp300-*) -- basic_machine=m68k-hp -- ;; -- hp300bsd) -- basic_machine=m68k-hp -- os=-bsd -- ;; -- hp300hpux) -- basic_machine=m68k-hp -- os=-hpux -+ cpu=hppa1.1 -+ vendor=hitachi -+ basic_os=hiuxwe2 - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) -- basic_machine=hppa1.0-hp -+ cpu=hppa1.0 -+ vendor=hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) -- basic_machine=m68000-hp -+ cpu=m68000 -+ vendor=hp - ;; - hp9k3[2-9][0-9]) -- basic_machine=m68k-hp -+ cpu=m68k -+ vendor=hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) -- basic_machine=hppa1.0-hp -+ cpu=hppa1.0 -+ vendor=hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) -- basic_machine=hppa1.0-hp -- ;; -- hppa-next) -- os=-nextstep3 -- ;; -- hppaosf) -- basic_machine=hppa1.1-hp -- os=-osf -+ cpu=hppa1.0 -+ vendor=hp - ;; -- hppro) -- basic_machine=hppa1.1-hp -- os=-proelf -- ;; -- i370-ibm* | ibm*) -- basic_machine=i370-ibm -- ;; --# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv32 -+ cpu=$(echo "$1" | sed -e 's/86.*/86/') -+ vendor=pc -+ basic_os=sysv32 - ;; - i*86v4*) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv4 -+ cpu=$(echo "$1" | sed -e 's/86.*/86/') -+ vendor=pc -+ basic_os=sysv4 - ;; - i*86v) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv -+ cpu=$(echo "$1" | sed -e 's/86.*/86/') -+ vendor=pc -+ basic_os=sysv - ;; - i*86sol2) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-solaris2 -- ;; -- i386mach) -- basic_machine=i386-mach -- os=-mach -- ;; -- i386-vsta | vsta) -- basic_machine=i386-unknown -- os=-vsta -+ cpu=$(echo "$1" | sed -e 's/86.*/86/') -+ vendor=pc -+ basic_os=solaris2 -+ ;; -+ j90 | j90-cray) -+ cpu=j90 -+ vendor=cray -+ basic_os=${basic_os:-unicos} - ;; - iris | iris4d) -- basic_machine=mips-sgi -- case $os in -- -irix*) -+ cpu=mips -+ vendor=sgi -+ case $basic_os in -+ irix*) - ;; - *) -- os=-irix4 -+ basic_os=irix4 - ;; - esac - ;; -- isi68 | isi) -- basic_machine=m68k-isi -- os=-sysv -- ;; -- m88k-omron*) -- basic_machine=m88k-omron -- ;; -- magnum | m3230) -- basic_machine=mips-mips -- os=-sysv -- ;; -- merlin) -- basic_machine=ns32k-utek -- os=-sysv -- ;; -- mingw32) -- basic_machine=i386-pc -- os=-mingw32 -- ;; - miniframe) -- basic_machine=m68000-convergent -+ cpu=m68000 -+ vendor=convergent - ;; -- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) -- basic_machine=m68k-atari -- os=-mint -- ;; -- mips3*-*) -- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` -- ;; -- mips3*) -- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown -- ;; -- monitor) -- basic_machine=m68k-rom68k -- os=-coff -- ;; -- morphos) -- basic_machine=powerpc-unknown -- os=-morphos -- ;; -- msdos) -- basic_machine=i386-pc -- os=-msdos -- ;; -- mvs) -- basic_machine=i370-ibm -- os=-mvs -- ;; -- ncr3000) -- basic_machine=i486-ncr -- os=-sysv4 -- ;; -- netbsd386) -- basic_machine=i386-unknown -- os=-netbsd -- ;; -- netwinder) -- basic_machine=armv4l-rebel -- os=-linux -- ;; -- news | news700 | news800 | news900) -- basic_machine=m68k-sony -- os=-newsos -- ;; -- news1000) -- basic_machine=m68030-sony -- os=-newsos -+ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) -+ cpu=m68k -+ vendor=atari -+ basic_os=mint - ;; - news-3600 | risc-news) -- basic_machine=mips-sony -- os=-newsos -- ;; -- necv70) -- basic_machine=v70-nec -- os=-sysv -- ;; -- next | m*-next ) -- basic_machine=m68k-next -- case $os in -- -nextstep* ) -+ cpu=mips -+ vendor=sony -+ basic_os=newsos -+ ;; -+ next | m*-next) -+ cpu=m68k -+ vendor=next -+ case $basic_os in -+ openstep*) -+ ;; -+ nextstep*) - ;; -- -ns2*) -- os=-nextstep2 -+ ns2*) -+ basic_os=nextstep2 - ;; - *) -- os=-nextstep3 -+ basic_os=nextstep3 - ;; - esac - ;; -- nh3000) -- basic_machine=m68k-harris -- os=-cxux -- ;; -- nh[45]000) -- basic_machine=m88k-harris -- os=-cxux -- ;; -- nindy960) -- basic_machine=i960-intel -- os=-nindy -- ;; -- mon960) -- basic_machine=i960-intel -- os=-mon960 -- ;; -- nonstopux) -- basic_machine=mips-compaq -- os=-nonstopux -- ;; - np1) -- basic_machine=np1-gould -- ;; -- nsr-tandem) -- basic_machine=nsr-tandem -+ cpu=np1 -+ vendor=gould - ;; - op50n-* | op60c-*) -- basic_machine=hppa1.1-oki -- os=-proelf -- ;; -- or32 | or32-*) -- basic_machine=or32-unknown -- os=-coff -- ;; -- os400) -- basic_machine=powerpc-ibm -- os=-os400 -- ;; -- OSE68000 | ose68000) -- basic_machine=m68000-ericsson -- os=-ose -- ;; -- os68k) -- basic_machine=m68k-none -- os=-os68k -+ cpu=hppa1.1 -+ vendor=oki -+ basic_os=proelf - ;; - pa-hitachi) -- basic_machine=hppa1.1-hitachi -- os=-hiuxwe2 -- ;; -- paragon) -- basic_machine=i860-intel -- os=-osf -+ cpu=hppa1.1 -+ vendor=hitachi -+ basic_os=hiuxwe2 - ;; - pbd) -- basic_machine=sparc-tti -+ cpu=sparc -+ vendor=tti - ;; - pbb) -- basic_machine=m68k-tti -- ;; -- pc532 | pc532-*) -- basic_machine=ns32k-pc532 -- ;; -- pentium | p5 | k5 | k6 | nexgen | viac3) -- basic_machine=i586-pc -+ cpu=m68k -+ vendor=tti - ;; -- pentiumpro | p6 | 6x86 | athlon | athlon_*) -- basic_machine=i686-pc -- ;; -- pentiumii | pentium2 | pentiumiii | pentium3) -- basic_machine=i686-pc -- ;; -- pentium4) -- basic_machine=i786-pc -- ;; -- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) -- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentiumpro-* | p6-* | 6x86-* | athlon-*) -- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) -- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentium4-*) -- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` -+ pc532) -+ cpu=ns32k -+ vendor=pc532 - ;; - pn) -- basic_machine=pn-gould -- ;; -- power) basic_machine=power-ibm -- ;; -- ppc) basic_machine=powerpc-unknown -- ;; -- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppcle | powerpclittle | ppc-le | powerpc-little) -- basic_machine=powerpcle-unknown -- ;; -- ppcle-* | powerpclittle-*) -- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppc64) basic_machine=powerpc64-unknown -- ;; -- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` -+ cpu=pn -+ vendor=gould - ;; -- ppc64le | powerpc64little | ppc64-le | powerpc64-little) -- basic_machine=powerpc64le-unknown -- ;; -- ppc64le-* | powerpc64little-*) -- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` -+ power) -+ cpu=power -+ vendor=ibm - ;; - ps2) -- basic_machine=i386-ibm -- ;; -- pw32) -- basic_machine=i586-unknown -- os=-pw32 -- ;; -- rom68k) -- basic_machine=m68k-rom68k -- os=-coff -+ cpu=i386 -+ vendor=ibm - ;; - rm[46]00) -- basic_machine=mips-siemens -+ cpu=mips -+ vendor=siemens - ;; - rtpc | rtpc-*) -- basic_machine=romp-ibm -+ cpu=romp -+ vendor=ibm - ;; -- s390 | s390-*) -- basic_machine=s390-ibm -+ sde) -+ cpu=mipsisa32 -+ vendor=sde -+ basic_os=${basic_os:-elf} -+ ;; -+ simso-wrs) -+ cpu=sparclite -+ vendor=wrs -+ basic_os=vxworks - ;; -- s390x | s390x-*) -- basic_machine=s390x-ibm -+ tower | tower-32) -+ cpu=m68k -+ vendor=ncr - ;; -- sa29200) -- basic_machine=a29k-amd -- os=-udi -+ vpp*|vx|vx-*) -+ cpu=f301 -+ vendor=fujitsu - ;; -- sb1) -- basic_machine=mipsisa64sb1-unknown -+ w65) -+ cpu=w65 -+ vendor=wdc - ;; -- sb1el) -- basic_machine=mipsisa64sb1el-unknown -+ w89k-*) -+ cpu=hppa1.1 -+ vendor=winbond -+ basic_os=proelf - ;; -- sei) -- basic_machine=mips-sei -- os=-seiux -+ none) -+ cpu=none -+ vendor=none - ;; -- sequent) -- basic_machine=i386-sequent -+ leon|leon[3-9]) -+ cpu=sparc -+ vendor=$basic_machine -+ ;; -+ leon-*|leon[3-9]-*) -+ cpu=sparc -+ vendor=$(echo "$basic_machine" | sed 's/-.*//') -+ ;; -+ -+ *-*) -+ # shellcheck disable=SC2162 -+ IFS="-" read cpu vendor <&2 -- exit 1 -+ # Recognize the canonical CPU types that are allowed with any -+ # company name. -+ case $cpu in -+ 1750a | 580 \ -+ | a29k \ -+ | aarch64 | aarch64_be \ -+ | abacus \ -+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ -+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ -+ | alphapca5[67] | alpha64pca5[67] \ -+ | am33_2.0 \ -+ | amdgcn \ -+ | arc | arceb | arc64 \ -+ | arm | arm[lb]e | arme[lb] | armv* \ -+ | avr | avr32 \ -+ | asmjs \ -+ | ba \ -+ | be32 | be64 \ -+ | bfin | bpf | bs2000 \ -+ | c[123]* | c30 | [cjt]90 | c4x \ -+ | c8051 | clipper | craynv | csky | cydra \ -+ | d10v | d30v | dlx | dsp16xx \ -+ | e2k | elxsi | epiphany \ -+ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ -+ | h8300 | h8500 \ -+ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ -+ | hexagon \ -+ | i370 | i*86 | i860 | i960 | ia16 | ia64 \ -+ | ip2k | iq2000 \ -+ | k1om \ -+ | le32 | le64 \ -+ | lm32 \ -+ | loongarch32 | loongarch64 | loongarchx32 \ -+ | m32c | m32r | m32rle \ -+ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ -+ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ -+ | m88110 | m88k | maxq | mb | mcore | mep | metag \ -+ | microblaze | microblazeel \ -+ | mips | mipsbe | mipseb | mipsel | mipsle \ -+ | mips16 \ -+ | mips64 | mips64eb | mips64el \ -+ | mips64octeon | mips64octeonel \ -+ | mips64orion | mips64orionel \ -+ | mips64r5900 | mips64r5900el \ -+ | mips64vr | mips64vrel \ -+ | mips64vr4100 | mips64vr4100el \ -+ | mips64vr4300 | mips64vr4300el \ -+ | mips64vr5000 | mips64vr5000el \ -+ | mips64vr5900 | mips64vr5900el \ -+ | mipsisa32 | mipsisa32el \ -+ | mipsisa32r2 | mipsisa32r2el \ -+ | mipsisa32r3 | mipsisa32r3el \ -+ | mipsisa32r5 | mipsisa32r5el \ -+ | mipsisa32r6 | mipsisa32r6el \ -+ | mipsisa64 | mipsisa64el \ -+ | mipsisa64r2 | mipsisa64r2el \ -+ | mipsisa64r3 | mipsisa64r3el \ -+ | mipsisa64r5 | mipsisa64r5el \ -+ | mipsisa64r6 | mipsisa64r6el \ -+ | mipsisa64sb1 | mipsisa64sb1el \ -+ | mipsisa64sr71k | mipsisa64sr71kel \ -+ | mipsr5900 | mipsr5900el \ -+ | mipstx39 | mipstx39el \ -+ | mmix \ -+ | mn10200 | mn10300 \ -+ | moxie \ -+ | mt \ -+ | msp430 \ -+ | nds32 | nds32le | nds32be \ -+ | nfp \ -+ | nios | nios2 | nios2eb | nios2el \ -+ | none | np1 | ns16k | ns32k | nvptx \ -+ | open8 \ -+ | or1k* \ -+ | or32 \ -+ | orion \ -+ | picochip \ -+ | pdp10 | pdp11 | pj | pjl | pn | power \ -+ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ -+ | pru \ -+ | pyramid \ -+ | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ -+ | rl78 | romp | rs6000 | rx \ -+ | s390 | s390x \ -+ | score \ -+ | sh | shl \ -+ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ -+ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ -+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ -+ | sparclite \ -+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ -+ | spu \ -+ | tahoe \ -+ | thumbv7* \ -+ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ -+ | tron \ -+ | ubicom32 \ -+ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ -+ | vax \ -+ | visium \ -+ | w65 \ -+ | wasm32 | wasm64 \ -+ | we32k \ -+ | x86 | x86_64 | xc16x | xgate | xps100 \ -+ | xstormy16 | xtensa* \ -+ | ymp \ -+ | z8k | z80) -+ ;; -+ -+ *) -+ echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 -+ exit 1 -+ ;; -+ esac - ;; - esac - - # Here we canonicalize certain aliases for manufacturers. --case $basic_machine in -- *-digital*) -- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` -+case $vendor in -+ digital*) -+ vendor=dec - ;; -- *-commodore*) -- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` -+ commodore*) -+ vendor=cbm - ;; - *) - ;; -@@ -1122,187 +1284,213 @@ esac - - # Decode manufacturer-specific aliases for certain operating systems. - --if [ x"$os" != x"" ] -+if test x$basic_os != x - then -+ -+# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just -+# set os. -+case $basic_os in -+ gnu/linux*) -+ kernel=linux -+ os=$(echo $basic_os | sed -e 's|gnu/linux|gnu|') -+ ;; -+ os2-emx) -+ kernel=os2 -+ os=$(echo $basic_os | sed -e 's|os2-emx|emx|') -+ ;; -+ nto-qnx*) -+ kernel=nto -+ os=$(echo $basic_os | sed -e 's|nto-qnx|qnx|') -+ ;; -+ *-*) -+ # shellcheck disable=SC2162 -+ IFS="-" read kernel os <&2 -- exit 1 -+ # No normalization, but not necessarily accepted, that comes below. - ;; - esac -+ - else - - # Here we handle the default operating systems that come with various machines. -@@ -1315,237 +1503,361 @@ else - # will signal an error saying that MANUFACTURER isn't an operating - # system, and we'll never get to this point. - --case $basic_machine in -+kernel= -+case $cpu-$vendor in -+ score-*) -+ os=elf -+ ;; -+ spu-*) -+ os=elf -+ ;; - *-acorn) -- os=-riscix1.2 -+ os=riscix1.2 - ;; - arm*-rebel) -- os=-linux -+ kernel=linux -+ os=gnu - ;; - arm*-semi) -- os=-aout -+ os=aout -+ ;; -+ c4x-* | tic4x-*) -+ os=coff -+ ;; -+ c8051-*) -+ os=elf -+ ;; -+ clipper-intergraph) -+ os=clix -+ ;; -+ hexagon-*) -+ os=elf -+ ;; -+ tic54x-*) -+ os=coff -+ ;; -+ tic55x-*) -+ os=coff -+ ;; -+ tic6x-*) -+ os=coff - ;; -- c4x-* | tic4x-*) -- os=-coff -- ;; - # This must come before the *-dec entry. - pdp10-*) -- os=-tops20 -+ os=tops20 - ;; - pdp11-*) -- os=-none -+ os=none - ;; - *-dec | vax-*) -- os=-ultrix4.2 -+ os=ultrix4.2 - ;; - m68*-apollo) -- os=-domain -+ os=domain - ;; - i386-sun) -- os=-sunos4.0.2 -+ os=sunos4.0.2 - ;; - m68000-sun) -- os=-sunos3 -- # This also exists in the configure program, but was not the -- # default. -- # os=-sunos4 -+ os=sunos3 - ;; - m68*-cisco) -- os=-aout -+ os=aout -+ ;; -+ mep-*) -+ os=elf - ;; - mips*-cisco) -- os=-elf -+ os=elf - ;; - mips*-*) -- os=-elf -+ os=elf - ;; - or32-*) -- os=-coff -+ os=coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. -- os=-sysv3 -+ os=sysv3 - ;; - sparc-* | *-sun) -- os=-sunos4.1.1 -+ os=sunos4.1.1 -+ ;; -+ pru-*) -+ os=elf - ;; - *-be) -- os=-beos -+ os=beos - ;; - *-ibm) -- os=-aix -+ os=aix - ;; -- *-knuth) -- os=-mmixware -+ *-knuth) -+ os=mmixware - ;; - *-wec) -- os=-proelf -+ os=proelf - ;; - *-winbond) -- os=-proelf -+ os=proelf - ;; - *-oki) -- os=-proelf -+ os=proelf - ;; - *-hp) -- os=-hpux -+ os=hpux - ;; - *-hitachi) -- os=-hiux -+ os=hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) -- os=-sysv -+ os=sysv - ;; - *-cbm) -- os=-amigaos -+ os=amigaos - ;; - *-dg) -- os=-dgux -+ os=dgux - ;; - *-dolphin) -- os=-sysv3 -+ os=sysv3 - ;; - m68k-ccur) -- os=-rtu -+ os=rtu - ;; - m88k-omron*) -- os=-luna -+ os=luna - ;; -- *-next ) -- os=-nextstep -+ *-next) -+ os=nextstep - ;; - *-sequent) -- os=-ptx -+ os=ptx - ;; - *-crds) -- os=-unos -+ os=unos - ;; - *-ns) -- os=-genix -+ os=genix - ;; - i370-*) -- os=-mvs -- ;; -- *-next) -- os=-nextstep3 -+ os=mvs - ;; - *-gould) -- os=-sysv -+ os=sysv - ;; - *-highlevel) -- os=-bsd -+ os=bsd - ;; - *-encore) -- os=-bsd -+ os=bsd - ;; - *-sgi) -- os=-irix -+ os=irix - ;; - *-siemens) -- os=-sysv4 -+ os=sysv4 - ;; - *-masscomp) -- os=-rtu -+ os=rtu - ;; - f30[01]-fujitsu | f700-fujitsu) -- os=-uxpv -+ os=uxpv - ;; - *-rom68k) -- os=-coff -+ os=coff - ;; - *-*bug) -- os=-coff -+ os=coff - ;; - *-apple) -- os=-macos -+ os=macos - ;; - *-atari*) -- os=-mint -+ os=mint -+ ;; -+ *-wrs) -+ os=vxworks - ;; - *) -- os=-none -+ os=none - ;; - esac -+ - fi - -+# Now, validate our (potentially fixed-up) OS. -+case $os in -+ # Sometimes we do "kernel-libc", so those need to count as OSes. -+ musl* | newlib* | uclibc*) -+ ;; -+ # Likewise for "kernel-abi" -+ eabi* | gnueabi*) -+ ;; -+ # VxWorks passes extra cpu info in the 4th filed. -+ simlinux | simwindows | spe) -+ ;; -+ # Now accept the basic system types. -+ # The portable systems comes first. -+ # Each alternative MUST end in a * to match a version number. -+ gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ -+ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ -+ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ -+ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ -+ | hiux* | abug | nacl* | netware* | windows* \ -+ | os9* | macos* | osx* | ios* \ -+ | mpw* | magic* | mmixware* | mon960* | lnews* \ -+ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ -+ | aos* | aros* | cloudabi* | sortix* | twizzler* \ -+ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ -+ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ -+ | mirbsd* | netbsd* | dicos* | openedition* | ose* \ -+ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ -+ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ -+ | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ -+ | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ -+ | udi* | lites* | ieee* | go32* | aux* | hcos* \ -+ | chorusrdb* | cegcc* | glidix* | serenity* \ -+ | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ -+ | midipix* | mingw32* | mingw64* | mint* \ -+ | uxpv* | beos* | mpeix* | udk* | moxiebox* \ -+ | interix* | uwin* | mks* | rhapsody* | darwin* \ -+ | openstep* | oskit* | conix* | pw32* | nonstopux* \ -+ | storm-chaos* | tops10* | tenex* | tops20* | its* \ -+ | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ -+ | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ -+ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ -+ | skyos* | haiku* | rdos* | toppers* | drops* | es* \ -+ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ -+ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ -+ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*) -+ ;; -+ # This one is extra strict with allowed versions -+ sco3.2v2 | sco3.2v[4-9]* | sco5v6*) -+ # Don't forget version if it is 3.2v4 or newer. -+ ;; -+ none) -+ ;; -+ *) -+ echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 -+ exit 1 -+ ;; -+esac -+ -+# As a final step for OS-related things, validate the OS-kernel combination -+# (given a valid OS), if there is a kernel. -+case $kernel-$os in -+ linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) -+ ;; -+ uclinux-uclibc* ) -+ ;; -+ -dietlibc* | -newlib* | -musl* | -uclibc* ) -+ # These are just libc implementations, not actual OSes, and thus -+ # require a kernel. -+ echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 -+ exit 1 -+ ;; -+ kfreebsd*-gnu* | kopensolaris*-gnu*) -+ ;; -+ vxworks-simlinux | vxworks-simwindows | vxworks-spe) -+ ;; -+ nto-qnx*) -+ ;; -+ os2-emx) -+ ;; -+ *-eabi* | *-gnueabi*) -+ ;; -+ -*) -+ # Blank kernel with real OS is always fine. -+ ;; -+ *-*) -+ echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 -+ exit 1 -+ ;; -+esac -+ - # Here we handle the case where we know the os, and the CPU type, but not the - # manufacturer. We pick the logical manufacturer. --vendor=unknown --case $basic_machine in -- *-unknown) -- case $os in -- -riscix*) -+case $vendor in -+ unknown) -+ case $cpu-$os in -+ *-riscix*) - vendor=acorn - ;; -- -sunos*) -+ *-sunos*) - vendor=sun - ;; -- -aix*) -+ *-cnk* | *-aix*) - vendor=ibm - ;; -- -beos*) -+ *-beos*) - vendor=be - ;; -- -hpux*) -+ *-hpux*) - vendor=hp - ;; -- -mpeix*) -+ *-mpeix*) - vendor=hp - ;; -- -hiux*) -+ *-hiux*) - vendor=hitachi - ;; -- -unos*) -+ *-unos*) - vendor=crds - ;; -- -dgux*) -+ *-dgux*) - vendor=dg - ;; -- -luna*) -+ *-luna*) - vendor=omron - ;; -- -genix*) -+ *-genix*) - vendor=ns - ;; -- -mvs* | -opened*) -+ *-clix*) -+ vendor=intergraph -+ ;; -+ *-mvs* | *-opened*) -+ vendor=ibm -+ ;; -+ *-os400*) - vendor=ibm - ;; -- -os400*) -+ s390-* | s390x-*) - vendor=ibm - ;; -- -ptx*) -+ *-ptx*) - vendor=sequent - ;; -- -tpf*) -+ *-tpf*) - vendor=ibm - ;; -- -vxsim* | -vxworks* | -windiss*) -+ *-vxsim* | *-vxworks* | *-windiss*) - vendor=wrs - ;; -- -aux*) -+ *-aux*) - vendor=apple - ;; -- -hms*) -+ *-hms*) - vendor=hitachi - ;; -- -mpw* | -macos*) -+ *-mpw* | *-macos*) - vendor=apple - ;; -- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -+ *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) - vendor=atari - ;; -- -vos*) -+ *-vos*) - vendor=stratus - ;; - esac -- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; - esac - --echo $basic_machine$os --exit 0 -+echo "$cpu-$vendor-${kernel:+$kernel-}$os" -+exit - - # Local variables: --# eval: (add-hook 'write-file-hooks 'time-stamp) -+# eval: (add-hook 'before-save-hook 'time-stamp) - # time-stamp-start: "timestamp='" - # time-stamp-format: "%:y-%02m-%02d" - # time-stamp-end: "'" \ No newline at end of file diff --git a/tools/upx/Makefile b/tools/upx/Makefile deleted file mode 100644 index fbf1dfbd2..000000000 --- a/tools/upx/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2011-2020 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# -include $(TOPDIR)/rules.mk - -PKG_NAME:=upx -PKG_VERSION:=3.95 - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-src.tar.xz -PKG_SOURCE_URL:=https://github.com/upx/upx/releases/download/v$(PKG_VERSION) -PKG_HASH:=3b0f55468d285c760fcf5ea865a070b27696393002712054c69ff40d8f7f5592 - -HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION)-src - -include $(INCLUDE_DIR)/host-build.mk - -define Host/Compile - UPX_UCLDIR=$(STAGING_DIR_HOST) \ - $(MAKE) -C $(HOST_BUILD_DIR)/src \ - CXXFLAGS_WERROR="" LDFLAGS="$(HOST_LDFLAGS)" \ - CXX="$(HOSTCXX)" -endef - -define Host/Install - $(CP) $(HOST_BUILD_DIR)/src/upx.out $(STAGING_DIR_HOST)/bin/upx -endef - -define Host/Clean - rm -f $(STAGING_DIR_HOST)/bin/upx -endef - -$(eval $(call HostBuild)) diff --git a/tools/xz/Makefile b/tools/xz/Makefile index 845fefe9a..6e287a61b 100644 --- a/tools/xz/Makefile +++ b/tools/xz/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=xz -PKG_VERSION:=5.2.7 +PKG_VERSION:=5.2.10 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@SF/lzmautils \ http://tukaani.org/xz -PKG_HASH:=b65f1d0c2708e57716f4dd2216989a73847ac6fdb4168ffceb155767e22b834b +PKG_HASH:=01b71df61521d9da698ce3c33148bff06a131628ff037398c09482f3a26e5408 PKG_CPE_ID:=cpe:/a:tukaani:xz HOST_BUILD_PARALLEL:=1