From ce21efa858132c4ed82a1e097a4cc300aaeb727d Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Jan 17 2018 17:43:35 +0000 Subject: Change TSC calibration driver preference (prefer pmtimer over PIT) - Pull in fixes for TSC calibration driver preference (prefer pmtimer over PIT) to boot on Apollo Lake systems with no PIT - Fix pmtimer calibration to not take forever to fail on kvm. Signed-off-by: Peter Jones --- diff --git a/0001-IBM-client-architecture-CAS-reboot-support.patch b/0001-IBM-client-architecture-CAS-reboot-support.patch deleted file mode 100644 index 22c682d..0000000 --- a/0001-IBM-client-architecture-CAS-reboot-support.patch +++ /dev/null @@ -1,174 +0,0 @@ -From e32c57d2abd034cbdea24a8f51de8dbef453bd96 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Thu, 20 Sep 2012 18:07:39 -0300 -Subject: [PATCH 01/90] IBM client architecture (CAS) reboot support - -This is an implementation of IBM client architecture (CAS) reboot for GRUB. - -There are cases where the POWER firmware must reboot in order to support -specific features requested by a kernel. The kernel calls -ibm,client-architecture-support and it may either return or reboot with the new -feature set. eg: - -Calling ibm,client-architecture-support.../ -Elapsed time since release of system processors: 70959 mins 50 secs -Welcome to GRUB! - -Instead of return to the GRUB menu, it will check if the flag for CAS reboot is -set. If so, grub will automatically boot the last booted kernel using the same -parameters ---- - grub-core/kern/ieee1275/openfw.c | 62 ++++++++++++++++++++++++++++++++++++++++ - grub-core/normal/main.c | 19 ++++++++++++ - grub-core/script/execute.c | 7 +++++ - include/grub/ieee1275/ieee1275.h | 2 ++ - 4 files changed, 90 insertions(+) - -diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index ddb7783..6db8b98 100644 ---- a/grub-core/kern/ieee1275/openfw.c -+++ b/grub-core/kern/ieee1275/openfw.c -@@ -561,3 +561,65 @@ grub_ieee1275_canonicalise_devname (const char *path) - return NULL; - } - -+/* Check if it's a CAS reboot. If so, set the script to be executed. */ -+int -+grub_ieee1275_cas_reboot (char *script) -+{ -+ grub_uint32_t ibm_ca_support_reboot; -+ grub_uint32_t ibm_fw_nbr_reboots; -+ char property_value[10]; -+ grub_ssize_t actual; -+ grub_ieee1275_ihandle_t options; -+ -+ if (grub_ieee1275_finddevice ("/options", &options) < 0) -+ return -1; -+ -+ /* Check two properties, one is enough to get cas reboot value */ -+ ibm_ca_support_reboot = 0; -+ if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, -+ "ibm,client-architecture-support-reboot", -+ &ibm_ca_support_reboot, -+ sizeof (ibm_ca_support_reboot), -+ &actual) >= 0) -+ grub_dprintf("ieee1275", "ibm,client-architecture-support-reboot: %u\n", -+ ibm_ca_support_reboot); -+ -+ ibm_fw_nbr_reboots = 0; -+ if (grub_ieee1275_get_property (options, "ibm,fw-nbr-reboots", -+ property_value, sizeof (property_value), -+ &actual) >= 0) -+ { -+ property_value[sizeof (property_value) - 1] = 0; -+ ibm_fw_nbr_reboots = (grub_uint8_t) grub_strtoul (property_value, 0, 10); -+ grub_dprintf("ieee1275", "ibm,fw-nbr-reboots: %u\n", ibm_fw_nbr_reboots); -+ } -+ -+ if (ibm_ca_support_reboot || ibm_fw_nbr_reboots) -+ { -+ if (! grub_ieee1275_get_property_length (options, "boot-last-label", &actual)) -+ { -+ if (actual > 1024) -+ script = grub_realloc (script, actual + 1); -+ grub_ieee1275_get_property (options, "boot-last-label", script, actual, -+ &actual); -+ return 0; -+ } -+ } -+ -+ grub_ieee1275_set_boot_last_label (""); -+ -+ return -1; -+} -+ -+int grub_ieee1275_set_boot_last_label (const char *text) -+{ -+ grub_ieee1275_ihandle_t options; -+ grub_ssize_t actual; -+ -+ grub_dprintf("ieee1275", "set boot_last_label (size: %u)\n", grub_strlen(text)); -+ if (! grub_ieee1275_finddevice ("/options", &options) && -+ options != (grub_ieee1275_ihandle_t) -1) -+ grub_ieee1275_set_property (options, "boot-last-label", text, -+ grub_strlen (text), &actual); -+ return 0; -+} -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 78a70a8..249e19b 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -33,6 +33,9 @@ - #include - #include - #include -+#ifdef GRUB_MACHINE_IEEE1275 -+#include -+#endif - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -275,6 +278,22 @@ grub_normal_execute (const char *config, int nested, int batch) - { - menu = read_config_file (config); - -+#ifdef GRUB_MACHINE_IEEE1275 -+ int boot; -+ boot = 0; -+ char *script; -+ script = grub_malloc (1024); -+ if (! grub_ieee1275_cas_reboot (script)) -+ { -+ char *dummy[1] = { NULL }; -+ if (! grub_script_execute_sourcecode (script)) -+ boot = 1; -+ } -+ grub_free (script); -+ if (boot) -+ grub_command_execute ("boot", 0, 0); -+#endif -+ - /* Ignore any error. */ - grub_errno = GRUB_ERR_NONE; - } -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index a8502d9..ab78ca8 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -27,6 +27,9 @@ - #include - #include - #include -+#ifdef GRUB_MACHINE_IEEE1275 -+#include -+#endif - - /* Max digits for a char is 3 (0xFF is 255), similarly for an int it - is sizeof (int) * 3, and one extra for a possible -ve sign. */ -@@ -877,6 +880,10 @@ grub_script_execute_sourcecode (const char *source) - grub_err_t ret = 0; - struct grub_script *parsed_script; - -+#ifdef GRUB_MACHINE_IEEE1275 -+ grub_ieee1275_set_boot_last_label (source); -+#endif -+ - while (source) - { - char *line; -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 8e42513..9f26c69 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -234,6 +234,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *ali - void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias); - void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, - struct grub_ieee1275_devalias *alias); -+int EXPORT_FUNC(grub_ieee1275_cas_reboot) (char *script); -+int EXPORT_FUNC(grub_ieee1275_set_boot_last_label) (const char *text); - - #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) - --- -2.9.3 - diff --git a/0001-NEWS-update.patch b/0001-NEWS-update.patch new file mode 100644 index 0000000..bdc0718 --- /dev/null +++ b/0001-NEWS-update.patch @@ -0,0 +1,62 @@ +From d017ea8ede3f76aaf6b6c9dabe3e96af0eebd395 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Sun, 28 Feb 2016 21:52:08 +0300 +Subject: [PATCH 001/123] NEWS update + +--- + NEWS | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/NEWS b/NEWS +index c9a975219..572eadb3e 100644 +--- a/NEWS ++++ b/NEWS +@@ -18,6 +18,7 @@ New in 2.02: + * ZFS features support. + * ZFS LZ4 support. + * XFS V5 format support. ++ * LVM RAID1 support. + + * New/improved terminal and video support: + * Monochrome text (matching `hercules' in GRUB Legacy). +@@ -49,6 +50,7 @@ New in 2.02: + * Improve TFTP robustness. + * Parse `nd' disk names in GRUB Legacy configuration files. + * Issue separate DNS queries for IPv4 and IPv6. ++ * Support IPv6 Router Advertisement to configure default router. + + * Coreboot improvements: + * CBFS support both in on-disk images (loopback) and flash. +@@ -96,6 +98,8 @@ New in 2.02: + EFI Stall. If everything fails, use hardcoded frequency 800MHz. + * Support Hyper-V Gen2 platforms which lack PIT for TSC calibration. + * Map UEFI Persistent Memory to E820 persistent memory. ++ * New Xen loader on ARM64. ++ * Respect alignment requirement for block device IO buffers on EFI. + + * Security: + * Add optional facility to enforce that all files read by the core image +@@ -134,6 +138,11 @@ New in 2.02: + menu entry immediately. + * New `file' command and grub-file utility to check file types. + * New syslinux configuration file parser. ++ * Set menu entry class to primary OS name returned by os-prober to display ++ OS specific icon. ++ * On Linux x86 detect EFI word size in grub-install and automatically select ++ correct platform (x86_64-efi or i386-efi) to install. Requires Linux kernel ++ 4.0 or higher. + + * Build system: + * Remove all uses of nested functions; GRUB no longer requires an +@@ -160,6 +169,8 @@ New in 2.02: + * emu libusb support removed (was broken and unmaintained). + * powerpc64le compile support. + * Use fixed timestamp when generating GRUB image for reproducible builds. ++ * Verify at build time that modules contain only supported relocations and their ++ structure matches what boot-time module loader expects. + + * Revision control moved to git. + +-- +2.14.3 + diff --git a/0002-10_linux-Fix-grouping-of-tests-for-GRUB_DEVICE.patch b/0002-10_linux-Fix-grouping-of-tests-for-GRUB_DEVICE.patch new file mode 100644 index 0000000..fe32a59 --- /dev/null +++ b/0002-10_linux-Fix-grouping-of-tests-for-GRUB_DEVICE.patch @@ -0,0 +1,27 @@ +From 082bc9f77b200eb48a5f1147163dea9c9d02d44c Mon Sep 17 00:00:00 2001 +From: Mike Gilbert +Date: Sat, 5 Mar 2016 17:30:48 -0500 +Subject: [PATCH 002/123] 10_linux: Fix grouping of tests for GRUB_DEVICE + +Commit 7290bb562 causes GRUB_DISABLE_LINUX_UUID to be ignored due to +mixing of || and && operators. Add some parens to help with that. +--- + util/grub.d/10_linux.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 5a78513ae..de9044c7f 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -47,7 +47,7 @@ esac + # and mounting btrfs requires user space scanning, so force UUID in this case. + if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ +- || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then ++ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then + LINUX_ROOT_DEVICE=${GRUB_DEVICE} + else + LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} +-- +2.14.3 + diff --git a/0002-for-ppc-reset-console-display-attr-when-clear-screen.patch b/0002-for-ppc-reset-console-display-attr-when-clear-screen.patch deleted file mode 100644 index 3582760..0000000 --- a/0002-for-ppc-reset-console-display-attr-when-clear-screen.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 4f82466e3b1fcf3370d82432e406f51906e1fa46 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Wed, 24 Apr 2013 10:51:48 -0300 -Subject: [PATCH 02/90] for ppc, reset console display attr when clear screen - -v2: Also use \x0c instead of a literal ^L to make future patches less -awkward. - -This should fix this bugzilla: -https://bugzilla.redhat.com/show_bug.cgi?id=908519 - -Signed-off-by: Peter Jones ---- - grub-core/term/terminfo.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c -index f0d3e3d..9bb75c1 100644 ---- a/grub-core/term/terminfo.c -+++ b/grub-core/term/terminfo.c -@@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term, - /* Clear the screen. Using serial console, screen(1) only recognizes the - * ANSI escape sequence. Using video console, Apple Open Firmware - * (version 3.1.1) only recognizes the literal ^L. So use both. */ -- data->cls = grub_strdup (" \e[2J"); -+ data->cls = grub_strdup ("\x0c\e[2J\e[m"); - data->reverse_video_on = grub_strdup ("\e[7m"); - data->reverse_video_off = grub_strdup ("\e[m"); - if (grub_strcmp ("ieee1275", str) == 0) --- -2.9.3 - diff --git a/0003-20_linux_xen-fix-test-for-GRUB_DEVICE.patch b/0003-20_linux_xen-fix-test-for-GRUB_DEVICE.patch new file mode 100644 index 0000000..1c07624 --- /dev/null +++ b/0003-20_linux_xen-fix-test-for-GRUB_DEVICE.patch @@ -0,0 +1,26 @@ +From 9545a8fd04ca33bcecc1907fec4d2354b02992ba Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Sun, 6 Mar 2016 08:54:19 +0300 +Subject: [PATCH 003/123] 20_linux_xen: fix test for GRUB_DEVICE + +Same fix as in 082bc9f. +--- + util/grub.d/20_linux_xen.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in +index 46045db1a..c48af948d 100644 +--- a/util/grub.d/20_linux_xen.in ++++ b/util/grub.d/20_linux_xen.in +@@ -47,7 +47,7 @@ esac + # and mounting btrfs requires user space scanning, so force UUID in this case. + if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ +- || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then ++ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then + LINUX_ROOT_DEVICE=${GRUB_DEVICE} + else + LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} +-- +2.14.3 + diff --git a/0003-Disable-GRUB-video-support-for-IBM-power-machines.patch b/0003-Disable-GRUB-video-support-for-IBM-power-machines.patch deleted file mode 100644 index 335100a..0000000 --- a/0003-Disable-GRUB-video-support-for-IBM-power-machines.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 9cff6efa3a7e15a6968fed29a29f38713da864fd Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Tue, 11 Jun 2013 15:14:05 -0300 -Subject: [PATCH 03/90] Disable GRUB video support for IBM power machines - -Should fix the problem in bugzilla: -https://bugzilla.redhat.com/show_bug.cgi?id=973205 ---- - grub-core/kern/ieee1275/cmain.c | 5 ++++- - grub-core/video/ieee1275.c | 9 ++++++--- - include/grub/ieee1275/ieee1275.h | 2 ++ - 3 files changed, 12 insertions(+), 4 deletions(-) - -diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c -index 3e12e6b..3e14f53 100644 ---- a/grub-core/kern/ieee1275/cmain.c -+++ b/grub-core/kern/ieee1275/cmain.c -@@ -90,7 +90,10 @@ grub_ieee1275_find_options (void) - } - - if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0) -- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS); -+ { -+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS); -+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT); -+ } - - /* Old Macs have no key repeat, newer ones have fully working one. - The ones inbetween when repeated key generates an escaoe sequence -diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c -index 0b150ec..813ab38 100644 ---- a/grub-core/video/ieee1275.c -+++ b/grub-core/video/ieee1275.c -@@ -351,9 +351,12 @@ static struct grub_video_adapter grub_video_ieee1275_adapter = - - GRUB_MOD_INIT(ieee1275_fb) - { -- find_display (); -- if (display) -- grub_video_register (&grub_video_ieee1275_adapter); -+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT)) -+ { -+ find_display (); -+ if (display) -+ grub_video_register (&grub_video_ieee1275_adapter); -+ } - } - - GRUB_MOD_FINI(ieee1275_fb) -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 9f26c69..ab4f284 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -146,6 +146,8 @@ enum grub_ieee1275_flag - GRUB_IEEE1275_FLAG_BROKEN_REPEAT, - - GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN, -+ -+ GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT - }; - - extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); --- -2.9.3 - diff --git a/0004-Fix-bzr-s-ignore-artificats-in-.gitignore.patch b/0004-Fix-bzr-s-ignore-artificats-in-.gitignore.patch deleted file mode 100644 index 7705c8e..0000000 --- a/0004-Fix-bzr-s-ignore-artificats-in-.gitignore.patch +++ /dev/null @@ -1,371 +0,0 @@ -From 512fe6865738286c94f87da64ca6b475bc3e2f38 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 7 Jul 2015 10:13:14 -0400 -Subject: [PATCH 04/90] Fix bzr's ignore artificats in .gitignore - -We lost a man page because of incompatibilities between bzr's ignore -system and .gitignore, so solve that slightly better. - -Signed-off-by: Peter Jones ---- - .gitignore | 265 ++++++++++++++++++++++++++++--------------------------------- - 1 file changed, 120 insertions(+), 145 deletions(-) - -diff --git a/.gitignore b/.gitignore -index 18ab8e8..06c9f3a 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -1,93 +1,154 @@ --00_header --10_* --20_linux_xen --30_os-prober --40_custom --41_custom --*.1 --*.8 -+!util/*.[[:digit:]] -+!util/grub.d/[[:digit:]][[:digit:]]_*.in -+*.[[:digit:]] -+*.a -+*.exe -+*.exec -+*.image -+*.img -+*.log -+*.lst -+*.marker -+*.mod -+*.o -+*.pf2 -+*.pp -+*.trs -+.deps -+.deps-core -+.deps-util -+.dirstamp -+DISTLIST -+GPATH -+GRTAGS -+GSYMS -+GTAGS -+Makefile -+Makefile.in -+Makefile.util.am -+Makefile.utilgcry.def -+[[:digit:]][[:digit:]]_* - aclocal.m4 - ahci_test - ascii.bitmaps - ascii.h - autom4te.cache -+build-aux/test-driver - build-grub-gen-asciih - build-grub-gen-widthspec - build-grub-mkfont - cdboot_test - cmp_test -+compile -+config-util.h -+config-util.h.in - config.cache - config.guess - config.h --config-util.h --config-util.h.in - config.log - config.status - config.sub - configure -+contrib - core_compress_test --DISTLIST -+depcomp - docs/*.info -+docs/stamp-1 - docs/stamp-vti -+docs/version-dev.texi - docs/version.texi - ehci_test - example_grub_script_test - example_scripted_test - example_unit_test --*.exec --*.exec.exe - fddboot_test -+garbage-gen - genkernsyms.sh - gensymlist.sh - gentrigtables --gentrigtables.exe - gettext_strings_test - grub-bin2h --/grub-bios-setup --/grub-bios-setup.exe -+grub-bios-setup -+grub-core/*.module -+grub-core/*.pp -+grub-core/Makefile.core.am -+grub-core/Makefile.gcry.def -+grub-core/bootinfo.txt -+grub-core/contrib -+grub-core/gdb_grub -+grub-core/genmod.sh -+grub-core/gensyminfo.sh -+grub-core/gmodule.pl -+grub-core/gnulib/alloca.h -+grub-core/gnulib/arg-nonnull.h -+grub-core/gnulib/c++defs.h -+grub-core/gnulib/charset.alias -+grub-core/gnulib/configmake.h -+grub-core/gnulib/float.h -+grub-core/gnulib/getopt.h -+grub-core/gnulib/langinfo.h -+grub-core/gnulib/locale.h -+grub-core/gnulib/ref-add.sed -+grub-core/gnulib/ref-del.sed -+grub-core/gnulib/stdio.h -+grub-core/gnulib/stdlib.h -+grub-core/gnulib/string.h -+grub-core/gnulib/strings.h -+grub-core/gnulib/sys -+grub-core/gnulib/unistd.h -+grub-core/gnulib/unitypes.h -+grub-core/gnulib/uniwidth.h -+grub-core/gnulib/warn-on-use.h -+grub-core/gnulib/wchar.h -+grub-core/gnulib/wctype.h -+grub-core/grub.chrp -+grub-core/kernel.img.bin -+grub-core/lib/libgcrypt-grub -+grub-core/modinfo.sh -+grub-core/rs_decoder.h -+grub-editenv -+grub-emu -+grub-emu-lite -+grub-file -+grub-fs-tester -+grub-fstest -+grub-glue-efi -+grub-install -+grub-kbdcomp -+grub-macbless -+grub-macho2img -+grub-menulst2cfg -+grub-mk* -+grub-mount -+grub-ofpathname -+grub-probe -+grub-reboot -+grub-render-label -+grub-script-check -+grub-set-default -+grub-shell -+grub-shell-tester -+grub-sparc64-setup -+grub-syslinux2cfg - grub_cmd_date - grub_cmd_echo - grub_cmd_regexp - grub_cmd_set_date - grub_cmd_sleep --/grub-editenv --/grub-editenv.exe --grub-emu --grub-emu-lite --grub-emu.exe --grub-emu-lite.exe - grub_emu_init.c - grub_emu_init.h --/grub-file --/grub-file.exe --grub-fstest --grub-fstest.exe - grub_fstest_init.c - grub_fstest_init.h - grub_func_test --grub-install --grub-install.exe --grub-kbdcomp --/grub-macbless --/grub-macbless.exe --grub-macho2img --/grub-menulst2cfg --/grub-menulst2cfg.exe --/grub-mk* --grub-mount --/grub-ofpathname --/grub-ofpathname.exe --grub-core/build-grub-pe2elf.exe --/grub-probe --/grub-probe.exe - grub_probe_init.c - grub_probe_init.h --/grub-reboot -+grub_script.tab.c -+grub_script.tab.h -+grub_script.yy.c -+grub_script.yy.h - grub_script_blanklines - grub_script_blockarg - grub_script_break --grub-script-check --grub-script-check.exe - grub_script_check_init.c - grub_script_check_init.h - grub_script_comments -@@ -113,136 +174,50 @@ grub_script_strcmp - grub_script_test - grub_script_vars1 - grub_script_while1 --grub_script.tab.c --grub_script.tab.h --grub_script.yy.c --grub_script.yy.h --grub-set-default - grub_setup_init.c - grub_setup_init.h --grub-shell --grub-shell-tester --grub-sparc64-setup --grub-sparc64-setup.exe --/grub-syslinux2cfg --/grub-syslinux2cfg.exe - gzcompress_test - hddboot_test - help_test --*.img --*.image --*.image.exe - include/grub/cpu -+include/grub/gcrypt/g10lib.h -+include/grub/gcrypt/gcrypt.h - include/grub/machine - install-sh - lib/libgcrypt-grub - libgrub_a_init.c --*.log --*.lst - lzocompress_test --*.marker --Makefile --*.mod --mod-*.c -+mdate-sh - missing -+mod-*.c - netboot_test --*.o --*.a - ohci_test - partmap_test - pata_test --*.pf2 --*.pp -+po/*.gmo - po/*.mo --po/grub.pot -+po/*.po -+po/LINGUAS - po/POTFILES -+po/POTFILES-shell.in -+po/POTFILES.in -+po/grub.pot -+po/remove-potcdate.sed - po/stamp-po - printf_test - priority_queue_unit_test - pseries_test - stamp-h --stamp-h1 - stamp-h.in -+stamp-h1 - symlist.c - symlist.h -+texinfo.tex - trigtables.c --*.trs - uhci_test --update-grub_lib - unidata.c --xzcompress_test --Makefile.in --GPATH --GRTAGS --GSYMS --GTAGS --compile --depcomp --mdate-sh --texinfo.tex --grub-core/lib/libgcrypt-grub --.deps --.deps-util --.deps-core --.dirstamp --Makefile.util.am --contrib --grub-core/bootinfo.txt --grub-core/Makefile.core.am --grub-core/Makefile.gcry.def --grub-core/contrib --grub-core/gdb_grub --grub-core/genmod.sh --grub-core/gensyminfo.sh --grub-core/gmodule.pl --grub-core/grub.chrp --grub-core/modinfo.sh --grub-core/*.module --grub-core/*.module.exe --grub-core/*.pp --grub-core/kernel.img.bin -+update-grub_lib - util/bash-completion.d/grub --grub-core/gnulib/alloca.h --grub-core/gnulib/arg-nonnull.h --grub-core/gnulib/c++defs.h --grub-core/gnulib/charset.alias --grub-core/gnulib/configmake.h --grub-core/gnulib/float.h --grub-core/gnulib/getopt.h --grub-core/gnulib/langinfo.h --grub-core/gnulib/ref-add.sed --grub-core/gnulib/ref-del.sed --grub-core/gnulib/stdio.h --grub-core/gnulib/stdlib.h --grub-core/gnulib/string.h --grub-core/gnulib/strings.h --grub-core/gnulib/sys --grub-core/gnulib/unistd.h --grub-core/gnulib/warn-on-use.h --grub-core/gnulib/wchar.h --grub-core/gnulib/wctype.h --grub-core/rs_decoder.h - widthspec.bin - widthspec.h --docs/stamp-1 --docs/version-dev.texi --Makefile.utilgcry.def --po/*.po --po/*.gmo --po/LINGUAS --po/remove-potcdate.sed --include/grub/gcrypt/gcrypt.h --include/grub/gcrypt/g10lib.h --po/POTFILES.in --po/POTFILES-shell.in --/grub-glue-efi --/grub-render-label --/grub-glue-efi.exe --/grub-render-label.exe --grub-core/gnulib/locale.h --grub-core/gnulib/unitypes.h --grub-core/gnulib/uniwidth.h --build-aux/test-driver --/garbage-gen --/garbage-gen.exe --/grub-fs-tester -+xzcompress_test --- -2.9.3 - diff --git a/0004-multiboot2-Remove-useless-GRUB_PACKED.patch b/0004-multiboot2-Remove-useless-GRUB_PACKED.patch new file mode 100644 index 0000000..86da872 --- /dev/null +++ b/0004-multiboot2-Remove-useless-GRUB_PACKED.patch @@ -0,0 +1,26 @@ +From 7f2a856faec951b7ab816880bd26e1e10b17a596 Mon Sep 17 00:00:00 2001 +From: Vladimir Serbinenko +Date: Thu, 10 Mar 2016 21:16:10 +0100 +Subject: [PATCH 004/123] multiboot2: Remove useless GRUB_PACKED + +Reported by: Daniel Kiper +--- + include/multiboot2.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/multiboot2.h b/include/multiboot2.h +index 9d4862759..8b8c1568a 100644 +--- a/include/multiboot2.h ++++ b/include/multiboot2.h +@@ -176,7 +176,7 @@ struct multiboot_mmap_entry + #define MULTIBOOT_MEMORY_BADRAM 5 + multiboot_uint32_t type; + multiboot_uint32_t zero; +-} GRUB_PACKED; ++}; + typedef struct multiboot_mmap_entry multiboot_memory_map_t; + + struct multiboot_tag +-- +2.14.3 + diff --git a/0005-Honor-a-symlink-when-generating-configuration-by-gru.patch b/0005-Honor-a-symlink-when-generating-configuration-by-gru.patch deleted file mode 100644 index 5977a22..0000000 --- a/0005-Honor-a-symlink-when-generating-configuration-by-gru.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 7f1ea377390345b8ef7609ad0fa2952708b17e19 Mon Sep 17 00:00:00 2001 -From: Marcel Kolaja -Date: Tue, 21 Jan 2014 10:57:08 -0500 -Subject: [PATCH 05/90] Honor a symlink when generating configuration by - grub2-mkconfig - -Honor a symlink when generating configuration by grub2-mkconfig, so that -the -o option follows it rather than overwriting it with a regular file. ---- - util/grub-mkconfig.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index f8496d2..3b070fd 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -276,7 +276,8 @@ and /etc/grub.d/* files or please file a bug report with - exit 1 - else - # none of the children aborted with error, install the new grub.cfg -- mv -f ${grub_cfg}.new ${grub_cfg} -+ cat ${grub_cfg}.new > ${grub_cfg} -+ rm -f ${grub_cfg}.new - fi - fi - --- -2.9.3 - diff --git a/0005-xen_file-Fix-invalid-payload-size.patch b/0005-xen_file-Fix-invalid-payload-size.patch new file mode 100644 index 0000000..a1e5c57 --- /dev/null +++ b/0005-xen_file-Fix-invalid-payload-size.patch @@ -0,0 +1,30 @@ +From 15aee573d2312ebf4aab53d07d3d30eccf1484f9 Mon Sep 17 00:00:00 2001 +From: Michael Chang +Date: Fri, 11 Mar 2016 10:26:51 +0100 +Subject: [PATCH 005/123] xen_file: Fix invalid payload size + +--- + grub-core/loader/i386/xen_file.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c +index 583621890..37f9ad8ac 100644 +--- a/grub-core/loader/i386/xen_file.c ++++ b/grub-core/loader/i386/xen_file.c +@@ -55,11 +55,11 @@ grub_xen_file (grub_file_t file) + grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n", + (unsigned long long) (lh.setup_sects + 1) * 512 + + lh.payload_offset, +- (unsigned long long) lh.payload_length - 4); ++ (unsigned long long) lh.payload_length); + + off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512 + + lh.payload_offset, +- lh.payload_length - 4); ++ lh.payload_length); + if (!off_file) + goto fail; + +-- +2.14.3 + diff --git a/0006-Failed-config-now-returns-exit-code-1252311.patch b/0006-Failed-config-now-returns-exit-code-1252311.patch new file mode 100644 index 0000000..57834f2 --- /dev/null +++ b/0006-Failed-config-now-returns-exit-code-1252311.patch @@ -0,0 +1,28 @@ +From 3c3e96d0443e8de64ff29a6563fb69c8a37dd15a Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Fri, 29 Jan 2016 14:49:24 -0500 +Subject: [PATCH 006/123] Failed config now returns exit code (#1252311) + +Grub would notify the user if the new config was invalid, however, it +did not exit properly with exit code 1. Added the proper exit code. + +Resolves: rhbz#1252311 +--- + util/grub-mkconfig.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 203b07696..f8496d28b 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -273,6 +273,7 @@ Ensure that there are no errors in /etc/default/grub + and /etc/grub.d/* files or please file a bug report with + %s file attached." "${grub_cfg}.new" >&2 + echo >&2 ++ exit 1 + else + # none of the children aborted with error, install the new grub.cfg + mv -f ${grub_cfg}.new ${grub_cfg} +-- +2.14.3 + diff --git a/0006-Move-bash-completion-script-922997.patch b/0006-Move-bash-completion-script-922997.patch deleted file mode 100644 index 4f60fb0..0000000 --- a/0006-Move-bash-completion-script-922997.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 5b77e510eb6e4b649c53ab0790cdc9fdf0c85be9 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 3 Apr 2013 14:35:34 -0400 -Subject: [PATCH 06/90] Move bash completion script (#922997) - -Apparently these go in a new place now. ---- - configure.ac | 11 +++++++++++ - util/bash-completion.d/Makefile.am | 1 - - 2 files changed, 11 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 9ddfc53..ab9134c 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -287,6 +287,14 @@ AC_SUBST(grubdirname) - AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", - [Default grub directory name]) - -+PKG_PROG_PKG_CONFIG -+AS_IF([$($PKG_CONFIG --exists bash-completion)], [ -+ bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion) -+] , [ -+ bashcompletiondir=${datadir}/bash-completion/completions -+]) -+AC_SUBST(bashcompletiondir) -+ - # - # Checks for build programs. - # -@@ -476,6 +484,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" - # Check for target programs. - # - -+# This makes sure pkg.m4 is available. -+m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config]) -+ - # Find tools for the target. - if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then - tmp_ac_tool_prefix="$ac_tool_prefix" -diff --git a/util/bash-completion.d/Makefile.am b/util/bash-completion.d/Makefile.am -index 136287c..61108f0 100644 ---- a/util/bash-completion.d/Makefile.am -+++ b/util/bash-completion.d/Makefile.am -@@ -6,7 +6,6 @@ EXTRA_DIST = $(bash_completion_source) - - CLEANFILES = $(bash_completion_script) config.log - --bashcompletiondir = $(sysconfdir)/bash_completion.d - bashcompletion_DATA = $(bash_completion_script) - - $(bash_completion_script): $(bash_completion_source) $(top_builddir)/config.status --- -2.9.3 - diff --git a/0007-Makefile.util.def-add-LIBINTL-to-grub-macbless-flags.patch b/0007-Makefile.util.def-add-LIBINTL-to-grub-macbless-flags.patch new file mode 100644 index 0000000..652a1de --- /dev/null +++ b/0007-Makefile.util.def-add-LIBINTL-to-grub-macbless-flags.patch @@ -0,0 +1,29 @@ +From ee83919e938e7987c2753b3003a2074e92edf671 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Sun, 13 Mar 2016 08:11:58 +0300 +Subject: [PATCH 007/123] Makefile.util.def: add $LIBINTL to grub-macbless + flags + +Fixes compilation on OpenBSD 5.9. + +Reported by Jiri B +--- + Makefile.util.def | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.util.def b/Makefile.util.def +index ed9b4c697..f9caccb97 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -416,7 +416,7 @@ program = { + ldadd = libgrubgcry.a; + ldadd = libgrubkern.a; + ldadd = grub-core/gnulib/libgnu.a; +- ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; ++ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + }; + + data = { +-- +2.14.3 + diff --git a/0007-Update-to-minilzo-2.08.patch b/0007-Update-to-minilzo-2.08.patch deleted file mode 100644 index cb8e4a6..0000000 --- a/0007-Update-to-minilzo-2.08.patch +++ /dev/null @@ -1,8790 +0,0 @@ -From 579ecb682efc5221b4a13b8009af1731f5349912 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 4 Dec 2014 15:36:09 -0500 -Subject: [PATCH 07/90] Update to minilzo-2.08 - -This fixes CVE-2014-4607 - lzo: lzo1x_decompress_safe() integer overflow - -Signed-off-by: Peter Jones ---- - grub-core/lib/minilzo/lzoconf.h | 216 ++- - grub-core/lib/minilzo/lzodefs.h | 2450 +++++++++++++++++------- - grub-core/lib/minilzo/minilzo.c | 3953 +++++++++++++++++++++++++++------------ - grub-core/lib/minilzo/minilzo.h | 21 +- - 4 files changed, 4630 insertions(+), 2010 deletions(-) - -diff --git a/grub-core/lib/minilzo/lzoconf.h b/grub-core/lib/minilzo/lzoconf.h -index 1d0fe14..61be29c 100644 ---- a/grub-core/lib/minilzo/lzoconf.h -+++ b/grub-core/lib/minilzo/lzoconf.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -44,9 +29,9 @@ - #ifndef __LZOCONF_H_INCLUDED - #define __LZOCONF_H_INCLUDED 1 - --#define LZO_VERSION 0x2050 --#define LZO_VERSION_STRING "2.05" --#define LZO_VERSION_DATE "Apr 23 2011" -+#define LZO_VERSION 0x2080 -+#define LZO_VERSION_STRING "2.08" -+#define LZO_VERSION_DATE "Jun 29 2014" - - /* internal Autoconf configuration file - only used when building LZO */ - #if defined(LZO_HAVE_CONFIG_H) -@@ -63,7 +48,7 @@ - #if !defined(CHAR_BIT) || (CHAR_BIT != 8) - # error "invalid CHAR_BIT" - #endif --#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) -+#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) - # error "check your compiler installation" - #endif - #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) -@@ -85,14 +70,6 @@ extern "C" { - // some core defines - ************************************************************************/ - --#if !defined(LZO_UINT32_C) --# if (UINT_MAX < LZO_0xffffffffL) --# define LZO_UINT32_C(c) c ## UL --# else --# define LZO_UINT32_C(c) ((c) + 0U) --# endif --#endif -- - /* memory checkers */ - #if !defined(__LZO_CHECKER) - # if defined(__BOUNDS_CHECKING_ON) -@@ -111,28 +88,31 @@ extern "C" { - // integral and pointer types - ************************************************************************/ - --/* lzo_uint should match size_t */ -+/* lzo_uint must match size_t */ - #if !defined(LZO_UINT_MAX) --# if defined(LZO_ABI_LLP64) /* WIN64 */ --# if defined(LZO_OS_WIN64) -+# if (LZO_ABI_LLP64) -+# if (LZO_OS_WIN64) - typedef unsigned __int64 lzo_uint; - typedef __int64 lzo_int; - # else -- typedef unsigned long long lzo_uint; -- typedef long long lzo_int; -+ typedef lzo_ullong_t lzo_uint; -+ typedef lzo_llong_t lzo_int; - # endif -+# define LZO_SIZEOF_LZO_UINT 8 - # define LZO_UINT_MAX 0xffffffffffffffffull - # define LZO_INT_MAX 9223372036854775807LL - # define LZO_INT_MIN (-1LL - LZO_INT_MAX) --# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ -+# elif (LZO_ABI_IP32L64) /* MIPS R5900 */ - typedef unsigned int lzo_uint; - typedef int lzo_int; -+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT - # define LZO_UINT_MAX UINT_MAX - # define LZO_INT_MAX INT_MAX - # define LZO_INT_MIN INT_MIN - # elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint; - typedef long lzo_int; -+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG - # define LZO_UINT_MAX ULONG_MAX - # define LZO_INT_MAX LONG_MAX - # define LZO_INT_MIN LONG_MIN -@@ -141,63 +121,22 @@ extern "C" { - # endif - #endif - --/* Integral types with 32 bits or more. */ --#if !defined(LZO_UINT32_MAX) --# if (UINT_MAX >= LZO_0xffffffffL) -- typedef unsigned int lzo_uint32; -- typedef int lzo_int32; --# define LZO_UINT32_MAX UINT_MAX --# define LZO_INT32_MAX INT_MAX --# define LZO_INT32_MIN INT_MIN --# elif (ULONG_MAX >= LZO_0xffffffffL) -- typedef unsigned long lzo_uint32; -- typedef long lzo_int32; --# define LZO_UINT32_MAX ULONG_MAX --# define LZO_INT32_MAX LONG_MAX --# define LZO_INT32_MIN LONG_MIN --# else --# error "lzo_uint32" --# endif --#endif -- --/* Integral types with exactly 64 bits. */ --#if !defined(LZO_UINT64_MAX) --# if (LZO_UINT_MAX >= LZO_0xffffffffL) --# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) --# define lzo_uint64 lzo_uint --# define lzo_int64 lzo_int --# define LZO_UINT64_MAX LZO_UINT_MAX --# define LZO_INT64_MAX LZO_INT_MAX --# define LZO_INT64_MIN LZO_INT_MIN --# endif --# elif (ULONG_MAX >= LZO_0xffffffffL) --# if ((((ULONG_MAX) >> 31) >> 31) == 3) -- typedef unsigned long lzo_uint64; -- typedef long lzo_int64; --# define LZO_UINT64_MAX ULONG_MAX --# define LZO_INT64_MAX LONG_MAX --# define LZO_INT64_MIN LONG_MIN --# endif --# endif --#endif -- --/* The larger type of lzo_uint and lzo_uint32. */ --#if (LZO_UINT_MAX >= LZO_UINT32_MAX) -+/* The larger type of lzo_uint and lzo_uint32_t. */ -+#if (LZO_SIZEOF_LZO_UINT >= 4) - # define lzo_xint lzo_uint - #else --# define lzo_xint lzo_uint32 -+# define lzo_xint lzo_uint32_t - #endif - --/* Memory model that allows to access memory at offsets of lzo_uint. */ --#if !defined(__LZO_MMODEL) --# if (LZO_UINT_MAX <= UINT_MAX) --# define __LZO_MMODEL /*empty*/ --# elif defined(LZO_HAVE_MM_HUGE_PTR) --# define __LZO_MMODEL_HUGE 1 --# define __LZO_MMODEL __huge --# else --# define __LZO_MMODEL /*empty*/ --# endif -+typedef int lzo_bool; -+ -+/* sanity checks */ -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) -+ -+#ifndef __LZO_MMODEL -+#define __LZO_MMODEL /*empty*/ - #endif - - /* no typedef here because of const-pointer issues */ -@@ -206,21 +145,52 @@ extern "C" { - #define lzo_voidp void __LZO_MMODEL * - #define lzo_shortp short __LZO_MMODEL * - #define lzo_ushortp unsigned short __LZO_MMODEL * --#define lzo_uint32p lzo_uint32 __LZO_MMODEL * --#define lzo_int32p lzo_int32 __LZO_MMODEL * --#if defined(LZO_UINT64_MAX) --#define lzo_uint64p lzo_uint64 __LZO_MMODEL * --#define lzo_int64p lzo_int64 __LZO_MMODEL * --#endif --#define lzo_uintp lzo_uint __LZO_MMODEL * - #define lzo_intp lzo_int __LZO_MMODEL * -+#define lzo_uintp lzo_uint __LZO_MMODEL * - #define lzo_xintp lzo_xint __LZO_MMODEL * - #define lzo_voidpp lzo_voidp __LZO_MMODEL * - #define lzo_bytepp lzo_bytep __LZO_MMODEL * --/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ --#define lzo_byte unsigned char __LZO_MMODEL - --typedef int lzo_bool; -+#define lzo_int8_tp lzo_int8_t __LZO_MMODEL * -+#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * -+#define lzo_int16_tp lzo_int16_t __LZO_MMODEL * -+#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * -+#define lzo_int32_tp lzo_int32_t __LZO_MMODEL * -+#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * -+#if defined(lzo_int64_t) -+#define lzo_int64_tp lzo_int64_t __LZO_MMODEL * -+#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * -+#endif -+ -+/* Older LZO versions used to support ancient systems and memory models -+ * like 16-bit MSDOS with __huge pointers and Cray PVP, but these -+ * obsolete configurations are not supported any longer. -+ */ -+#if defined(__LZO_MMODEL_HUGE) -+#error "__LZO_MMODEL_HUGE is unsupported" -+#endif -+#if (LZO_MM_PVP) -+#error "LZO_MM_PVP is unsupported" -+#endif -+#if (LZO_SIZEOF_INT < 4) -+#error "LZO_SIZEOF_INT < 4 is unsupported" -+#endif -+#if (__LZO_UINTPTR_T_IS_POINTER) -+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) -+/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should -+ * work but have not received much testing lately, so be strict here. -+ */ -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) - - - /*********************************************************************** -@@ -315,7 +285,7 @@ struct lzo_callback_t - /* a progress indicator callback function (set to 0 to disable) */ - lzo_progress_func_t nprogress; - -- /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress -+ /* INFO: the first parameter "self" of the nalloc/nfree/nprogress - * callbacks points back to this struct, so you are free to store - * some extra info in the following variables. */ - lzo_voidp user1; -@@ -343,6 +313,9 @@ struct lzo_callback_t - #define LZO_E_INPUT_NOT_CONSUMED (-8) - #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ - #define LZO_E_INVALID_ARGUMENT (-10) -+#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ -+#define LZO_E_OUTPUT_NOT_CONSUMED (-12) -+#define LZO_E_INTERNAL_ERROR (-99) - - - #ifndef lzo_sizeof_dict_t -@@ -356,7 +329,7 @@ struct lzo_callback_t - * compiler's view of various types are consistent. - */ - #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ -- (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ -+ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_callback_t)) - LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); -@@ -379,18 +352,22 @@ LZO_EXTERN(lzo_voidp) - lzo_memset(lzo_voidp buf, int c, lzo_uint len); - - /* checksum functions */ --LZO_EXTERN(lzo_uint32) -- lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); --LZO_EXTERN(lzo_uint32) -- lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); --LZO_EXTERN(const lzo_uint32p) -+LZO_EXTERN(lzo_uint32_t) -+ lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); -+LZO_EXTERN(lzo_uint32_t) -+ lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); -+LZO_EXTERN(const lzo_uint32_tp) - lzo_get_crc32_table(void); - - /* misc. */ - LZO_EXTERN(int) _lzo_config_check(void); --typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; --typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; --typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; -+typedef union { -+ lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; -+ void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; -+#if defined(lzo_int64_t) -+ lzo_uint64_t a10; -+#endif -+} lzo_align_t; - - /* align a char pointer on a boundary that is a multiple of 'size' */ - LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); -@@ -399,9 +376,30 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); - - - /*********************************************************************** --// deprecated macros - only for backward compatibility with LZO v1.xx -+// deprecated macros - only for backward compatibility - ************************************************************************/ - -+/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ -+#define lzo_byte unsigned char -+/* deprecated type names */ -+#define lzo_int32 lzo_int32_t -+#define lzo_uint32 lzo_uint32_t -+#define lzo_int32p lzo_int32_t __LZO_MMODEL * -+#define lzo_uint32p lzo_uint32_t __LZO_MMODEL * -+#define LZO_INT32_MAX LZO_INT32_C(2147483647) -+#define LZO_UINT32_MAX LZO_UINT32_C(4294967295) -+#if defined(lzo_int64_t) -+#define lzo_int64 lzo_int64_t -+#define lzo_uint64 lzo_uint64_t -+#define lzo_int64p lzo_int64_t __LZO_MMODEL * -+#define lzo_uint64p lzo_uint64_t __LZO_MMODEL * -+#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) -+#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) -+#endif -+/* deprecated types */ -+typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; -+typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; -+ - #if defined(LZO_CFG_COMPAT) - - #define __LZOCONF_H 1 -@@ -443,4 +441,4 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); - #endif /* already included */ - - --/* vim:set ts=4 et: */ -+/* vim:set ts=4 sw=4 et: */ -diff --git a/grub-core/lib/minilzo/lzodefs.h b/grub-core/lib/minilzo/lzodefs.h -index 0e40e33..f4ae948 100644 ---- a/grub-core/lib/minilzo/lzodefs.h -+++ b/grub-core/lib/minilzo/lzodefs.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -47,12 +32,6 @@ - #if defined(__CYGWIN32__) && !defined(__CYGWIN__) - # define __CYGWIN__ __CYGWIN32__ - #endif --#if defined(__IBMCPP__) && !defined(__IBMC__) --# define __IBMC__ __IBMCPP__ --#endif --#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) --# define __INTEL_COMPILER __ICL --#endif - #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) - # define _ALL_SOURCE 1 - #endif -@@ -61,19 +40,30 @@ - # define __LONG_MAX__ 9223372036854775807L - # endif - #endif --#if defined(__INTEL_COMPILER) && defined(__linux__) -+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) -+#if defined(__ARMCC_VERSION) -+# pragma diag_suppress 193 -+#elif defined(__clang__) && defined(__clang_minor__) -+# pragma clang diagnostic ignored "-Wundef" -+#elif defined(__INTEL_COMPILER) - # pragma warning(disable: 193) --#endif --#if defined(__KEIL__) && defined(__C166__) --# pragma warning disable = 322 --#elif 0 && defined(__C251__) -+#elif defined(__KEIL__) && defined(__C166__) - # pragma warning disable = 322 --#endif --#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) --# if (_MSC_VER >= 1300) -+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) -+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) -+# pragma GCC diagnostic ignored "-Wundef" -+# endif -+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -+# if ((_MSC_VER-0) >= 1300) - # pragma warning(disable: 4668) - # endif - #endif -+#endif -+#if 0 && defined(__POCC__) && defined(_WIN32) -+# if (__POCC__ >= 400) -+# pragma warn(disable: 2216) -+# endif -+#endif - #if 0 && defined(__WATCOMC__) - # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) - # pragma warning 203 9 -@@ -82,13 +72,29 @@ - #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) - # pragma option -h - #endif -+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) -+#ifndef _CRT_NONSTDC_NO_DEPRECATE -+#define _CRT_NONSTDC_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_NONSTDC_NO_WARNINGS -+#define _CRT_NONSTDC_NO_WARNINGS 1 -+#endif -+#ifndef _CRT_SECURE_NO_DEPRECATE -+#define _CRT_SECURE_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_SECURE_NO_WARNINGS -+#define _CRT_SECURE_NO_WARNINGS 1 -+#endif -+#endif - #if 0 --#define LZO_0xffffL 0xfffful --#define LZO_0xffffffffL 0xfffffffful -+#define LZO_0xffffUL 0xfffful -+#define LZO_0xffffffffUL 0xfffffffful - #else --#define LZO_0xffffL 65535ul --#define LZO_0xffffffffL 4294967295ul -+#define LZO_0xffffUL 65535ul -+#define LZO_0xffffffffUL 4294967295ul - #endif -+#define LZO_0xffffL LZO_0xffffUL -+#define LZO_0xffffffffL LZO_0xffffffffUL - #if (LZO_0xffffL == LZO_0xffffffffL) - # error "your preprocessor is broken 1" - #endif -@@ -103,6 +109,13 @@ - # error "your preprocessor is broken 4" - #endif - #endif -+#if defined(__COUNTER__) -+# ifndef LZO_CFG_USE_COUNTER -+# define LZO_CFG_USE_COUNTER 1 -+# endif -+#else -+# undef LZO_CFG_USE_COUNTER -+#endif - #if (UINT_MAX == LZO_0xffffL) - #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) - # if !defined(MSDOS) -@@ -233,14 +246,31 @@ - #endif - #define LZO_PP_STRINGIZE(x) #x - #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) -+#define LZO_PP_CONCAT0() /*empty*/ -+#define LZO_PP_CONCAT1(a) a - #define LZO_PP_CONCAT2(a,b) a ## b - #define LZO_PP_CONCAT3(a,b,c) a ## b ## c - #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g -+#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() -+#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) - #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) - #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) - #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) - #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -+#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) -+#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) -+#define LZO_PP_EMPTY /*empty*/ -+#define LZO_PP_EMPTY0() /*empty*/ -+#define LZO_PP_EMPTY1(a) /*empty*/ -+#define LZO_PP_EMPTY2(a,b) /*empty*/ -+#define LZO_PP_EMPTY3(a,b,c) /*empty*/ -+#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ -+#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ -+#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ -+#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ - #if 1 - #define LZO_CPP_STRINGIZE(x) #x - #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -@@ -248,12 +278,16 @@ - #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c - #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g - #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) - #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) - #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) - #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -+#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) -+#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) - #endif --#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -+#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) - #if 1 && defined(__cplusplus) - # if !defined(__STDC_CONSTANT_MACROS) - # define __STDC_CONSTANT_MACROS 1 -@@ -263,9 +297,13 @@ - # endif - #endif - #if defined(__cplusplus) --# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C_BEGIN extern "C" { -+# define LZO_EXTERN_C_END } - #else --# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C_BEGIN /*empty*/ -+# define LZO_EXTERN_C_END /*empty*/ - #endif - #if !defined(__LZO_OS_OVERRIDE) - #if (LZO_OS_FREESTANDING) -@@ -366,12 +404,12 @@ - #elif defined(__VMS) - # define LZO_OS_VMS 1 - # define LZO_INFO_OS "vms" --#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PS2 1 - # define LZO_INFO_OS "console" - # define LZO_INFO_OS_CONSOLE "ps2" --#elif (defined(__mips__) && defined(__psp__)) -+#elif defined(__mips__) && defined(__psp__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PSP 1 - # define LZO_INFO_OS "console" -@@ -399,9 +437,18 @@ - # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) - # define LZO_OS_POSIX_LINUX 1 - # define LZO_INFO_OS_POSIX "linux" --# elif defined(__APPLE__) || defined(__MACOS__) --# define LZO_OS_POSIX_MACOSX 1 --# define LZO_INFO_OS_POSIX "macosx" -+# elif defined(__APPLE__) && defined(__MACH__) -+# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) -+# define LZO_OS_POSIX_DARWIN 1040 -+# define LZO_INFO_OS_POSIX "darwin_iphone" -+# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) -+# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -+# define LZO_INFO_OS_POSIX "darwin" -+# else -+# define LZO_OS_POSIX_DARWIN 1 -+# define LZO_INFO_OS_POSIX "darwin" -+# endif -+# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN - # elif defined(__minix__) || defined(__minix) - # define LZO_OS_POSIX_MINIX 1 - # define LZO_INFO_OS_POSIX "minix" -@@ -436,18 +483,18 @@ - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (UINT_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -@@ -463,59 +510,65 @@ - # define LZO_INFO_CC "sdcc" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) - #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) --# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) -+# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) - # define LZO_INFO_CC "Pathscale C" - # define LZO_INFO_CCVER __PATHSCALE__ --#elif defined(__INTEL_COMPILER) --# define LZO_CC_INTELC 1 -+# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif -+#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) -+# define LZO_CC_INTELC __INTEL_COMPILER - # define LZO_INFO_CC "Intel C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) --# if defined(_WIN32) || defined(_WIN64) --# define LZO_CC_SYNTAX_MSC 1 --# else --# define LZO_CC_SYNTAX_GNUC 1 -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_INTELC_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif - #elif defined(__POCC__) && defined(_WIN32) - # define LZO_CC_PELLESC 1 - # define LZO_INFO_CC "Pelles C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) --#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) - # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) --# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) -+# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) - # else --# define LZO_CC_CLANG_CLANG 0x010000L -+# define LZO_CC_CLANG 0x010000L -+# endif -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_CLANG_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif --# define LZO_CC_CLANG LZO_CC_CLANG_GNUC - # define LZO_INFO_CC "clang" - # define LZO_INFO_CCVER __VERSION__ - #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif - # define LZO_CC_LLVM LZO_CC_LLVM_GNUC - # define LZO_INFO_CC "llvm-gcc" - # define LZO_INFO_CCVER __VERSION__ --#elif defined(__GNUC__) && defined(__VERSION__) --# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) --# elif defined(__GNUC_MINOR__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) --# else --# define LZO_CC_GNUC (__GNUC__ * 0x10000L) --# endif --# define LZO_INFO_CC "gcc" --# define LZO_INFO_CCVER __VERSION__ - #elif defined(__ACK__) && defined(_ACK) - # define LZO_CC_ACK 1 - # define LZO_INFO_CC "Amsterdam Compiler Kit C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) - #elif defined(__AZTEC_C__) - # define LZO_CC_AZTECC 1 - # define LZO_INFO_CC "Aztec C" -@@ -540,10 +593,23 @@ - # define LZO_CC_DECC 1 - # define LZO_INFO_CC "DEC C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) -+#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) -+# define LZO_CC_GHS 1 -+# define LZO_INFO_CC "Green Hills C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_GHS_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif - #elif defined(__HIGHC__) - # define LZO_CC_HIGHC 1 - # define LZO_INFO_CC "MetaWare High C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) -+# define LZO_CC_HPACC __HP_aCC -+# define LZO_INFO_CC "HP aCC" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) - #elif defined(__IAR_SYSTEMS_ICC__) - # define LZO_CC_IARC 1 - # define LZO_INFO_CC "IAR C" -@@ -552,10 +618,14 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(__IBMC__) --# define LZO_CC_IBMC 1 -+#elif defined(__IBMC__) && ((__IBMC__-0) > 0) -+# define LZO_CC_IBMC __IBMC__ - # define LZO_INFO_CC "IBM C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) -+#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) -+# define LZO_CC_IBMC __IBMCPP__ -+# define LZO_INFO_CC "IBM C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) - #elif defined(__KEIL__) && defined(__C166__) - # define LZO_CC_KEILC 1 - # define LZO_INFO_CC "Keil C" -@@ -572,16 +642,8 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(_MSC_VER) --# define LZO_CC_MSC 1 --# define LZO_INFO_CC "Microsoft C" --# if defined(_MSC_FULL_VER) --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) --# else --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) --# endif --#elif defined(__MWERKS__) --# define LZO_CC_MWERKS 1 -+#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) -+# define LZO_CC_MWERKS __MWERKS__ - # define LZO_INFO_CC "Metrowerks C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) - #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -@@ -592,6 +654,15 @@ - # define LZO_CC_PACIFICC 1 - # define LZO_INFO_CC "Pacific C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) -+#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) -+# if defined(__PGIC_PATCHLEVEL__) -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) -+# else -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" -+# endif -+# define LZO_INFO_CC "Portland Group PGI C" - #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) - # define LZO_CC_PGI 1 - # define LZO_INFO_CC "Portland Group PGI C" -@@ -606,7 +677,7 @@ - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) - #elif defined(__SUNPRO_C) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_C)+0 > 0) -+# if ((__SUNPRO_C-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_C - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) - # else -@@ -615,7 +686,7 @@ - # endif - #elif defined(__SUNPRO_CC) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_CC)+0 > 0) -+# if ((__SUNPRO_CC-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_CC - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) - # else -@@ -641,16 +712,46 @@ - #elif defined(__ZTC__) - # define LZO_CC_ZORTECHC 1 - # define LZO_INFO_CC "Zortech C" --# if (__ZTC__ == 0x310) -+# if ((__ZTC__-0) == 0x310) - # define LZO_INFO_CCVER "0x310" - # else - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) - # endif -+#elif defined(__GNUC__) && defined(__VERSION__) -+# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# elif defined(__GNUC_MINOR__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) -+# else -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -+# endif -+# define LZO_INFO_CC "gcc" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_MSC _MSC_VER -+# define LZO_INFO_CC "Microsoft C" -+# if defined(_MSC_FULL_VER) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -+# else -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -+# endif - #else - # define LZO_CC_UNKNOWN 1 - # define LZO_INFO_CC "unknown" - # define LZO_INFO_CCVER "unknown" - #endif -+#if (LZO_CC_GNUC) && defined(__OPEN64__) -+# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) -+# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) -+# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC -+# endif -+#endif -+#if (LZO_CC_GNUC) && defined(__PCC__) -+# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) -+# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) -+# define LZO_CC_PCC_GNUC LZO_CC_GNUC -+# endif -+#endif - #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) - # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" - #endif -@@ -668,8 +769,10 @@ - # define LZO_INFO_ARCH "generic" - #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086 1 --# define LZO_ARCH_IA16 1 - # define LZO_INFO_ARCH "i086" -+#elif defined(__aarch64__) -+# define LZO_ARCH_ARM64 1 -+# define LZO_INFO_ARCH "arm64" - #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) - # define LZO_ARCH_ALPHA 1 - # define LZO_INFO_ARCH "alpha" -@@ -685,10 +788,10 @@ - # define LZO_INFO_ARCH "arm_thumb" - #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) - # define LZO_ARCH_ARM 1 --# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) -+# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) - # define LZO_ARCH_ARM_THUMB 1 - # define LZO_INFO_ARCH "arm_thumb" --# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) -+# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) - # define LZO_INFO_ARCH "arm" - # else - # define LZO_INFO_ARCH "arm" -@@ -806,53 +909,147 @@ - # error "FIXME - missing define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) --# error "FIXME - missing WIN32 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) --# error "FIXME - missing WIN64 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" - #endif - #if (LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #endif --#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) --# error "this should not happen" -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) -+# define LZO_ARCH_X64 1 -+#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_AMD64 1 -+#endif -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) -+# define LZO_ARCH_AARCH64 1 -+#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_ARM64 1 -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) -+# define LZO_ARCH_X86 1 -+#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_I386 1 -+#endif -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" - #endif --#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) --# error "this should not happen" -+#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ARCH_I086) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_ARCH_I386) - # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" -+# endif -+#endif -+#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# if !defined(LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSE2__) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSSE3) -+# if (LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSSE3__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# elif defined(_MSC_VER) && defined(__AVX__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSE4_2) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__SSE4_2__) -+# define LZO_TARGET_FEATURE_SSE4_2 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__AVX__) -+# define LZO_TARGET_FEATURE_AVX 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX2) -+# if (LZO_TARGET_FEATURE_AVX) -+# if defined(__AVX2__) -+# define LZO_TARGET_FEATURE_AVX2 1 -+# endif -+# endif -+# endif -+#endif -+#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if defined(__ARM_NEON__) -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if 1 -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif - # endif - #endif --#if !defined(__LZO_MM_OVERRIDE) -+#if 0 -+#elif !defined(__LZO_MM_OVERRIDE) - #if (LZO_ARCH_I086) - #if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) - # define LZO_MM_TINY 1 -@@ -879,7 +1076,7 @@ - #elif (LZO_CC_ZORTECHC && defined(__VCM__)) - # define LZO_MM_LARGE 1 - #else --# error "unknown memory model" -+# error "unknown LZO_ARCH_I086 memory model" - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - #define LZO_HAVE_MM_HUGE_PTR 1 -@@ -902,10 +1099,10 @@ - #endif - #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) - # if (LZO_OS_DOS16) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # elif (LZO_CC_ZORTECHC) - # else --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #ifdef __cplusplus -@@ -937,7 +1134,7 @@ extern "C" { - #endif - #elif (LZO_ARCH_C166) - #if !defined(__MODEL__) --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 1) -@@ -951,11 +1148,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #endif - #elif (LZO_ARCH_MCS251) - #if !defined(__MODEL__) --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -967,11 +1164,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #endif - #elif (LZO_ARCH_MCS51) - #if !defined(__MODEL__) --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #elif ((__MODEL__) == 1) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -983,7 +1180,7 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #endif - #elif (LZO_ARCH_CRAY_PVP) - # define LZO_MM_PVP 1 -@@ -1010,462 +1207,270 @@ extern "C" { - # error "unknown memory model" - #endif - #endif --#if defined(SIZEOF_SHORT) --# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -+#if !defined(__lzo_gnuc_extension__) -+#if (LZO_CC_GNUC >= 0x020800ul) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_gnuc_extension__ __extension__ -+#else - #endif --#if defined(SIZEOF_INT) --# define LZO_SIZEOF_INT (SIZEOF_INT) - #endif --#if defined(SIZEOF_LONG) --# define LZO_SIZEOF_LONG (SIZEOF_LONG) -+#if !defined(__lzo_gnuc_extension__) -+# define __lzo_gnuc_extension__ /*empty*/ - #endif --#if defined(SIZEOF_LONG_LONG) --# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 -+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# else -+# define LZO_CFG_USE_NEW_STYLE_CASTS 1 -+# endif - #endif --#if defined(SIZEOF___INT16) --# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 - #endif --#if defined(SIZEOF___INT32) --# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -+#if !defined(__cplusplus) -+# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# undef LZO_CFG_USE_NEW_STYLE_CASTS -+# endif -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 - #endif --#if defined(SIZEOF___INT64) --# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -+#if !defined(LZO_REINTERPRET_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) -+# endif - #endif --#if defined(SIZEOF_VOID_P) --# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -+#if !defined(LZO_REINTERPRET_CAST) -+# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) - #endif --#if defined(SIZEOF_SIZE_T) --# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -+#if !defined(LZO_STATIC_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_STATIC_CAST(t,e) (static_cast (e)) -+# endif - #endif --#if defined(SIZEOF_PTRDIFF_T) --# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -+#if !defined(LZO_STATIC_CAST) -+# define LZO_STATIC_CAST(t,e) ((t) (e)) - #endif --#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) --#if !defined(LZO_SIZEOF_SHORT) --# if (LZO_ARCH_CRAY_PVP) --# define LZO_SIZEOF_SHORT 8 --# elif (USHRT_MAX == LZO_0xffffL) --# define LZO_SIZEOF_SHORT 2 --# elif (__LZO_LSR(USHRT_MAX,7) == 1) --# define LZO_SIZEOF_SHORT 1 --# elif (__LZO_LSR(USHRT_MAX,15) == 1) --# define LZO_SIZEOF_SHORT 2 --# elif (__LZO_LSR(USHRT_MAX,31) == 1) --# define LZO_SIZEOF_SHORT 4 --# elif (__LZO_LSR(USHRT_MAX,63) == 1) --# define LZO_SIZEOF_SHORT 8 --# elif (__LZO_LSR(USHRT_MAX,127) == 1) --# define LZO_SIZEOF_SHORT 16 --# else --# error "LZO_SIZEOF_SHORT" --# endif -+#if !defined(LZO_STATIC_CAST2) -+# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) - #endif --#if !defined(LZO_SIZEOF_INT) --# if (LZO_ARCH_CRAY_PVP) --# define LZO_SIZEOF_INT 8 --# elif (UINT_MAX == LZO_0xffffL) --# define LZO_SIZEOF_INT 2 --# elif (UINT_MAX == LZO_0xffffffffL) --# define LZO_SIZEOF_INT 4 --# elif (__LZO_LSR(UINT_MAX,7) == 1) --# define LZO_SIZEOF_INT 1 --# elif (__LZO_LSR(UINT_MAX,15) == 1) --# define LZO_SIZEOF_INT 2 --# elif (__LZO_LSR(UINT_MAX,31) == 1) --# define LZO_SIZEOF_INT 4 --# elif (__LZO_LSR(UINT_MAX,63) == 1) --# define LZO_SIZEOF_INT 8 --# elif (__LZO_LSR(UINT_MAX,127) == 1) --# define LZO_SIZEOF_INT 16 --# else --# error "LZO_SIZEOF_INT" -+#if !defined(LZO_UNCONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) - # endif - #endif --#if !defined(LZO_SIZEOF_LONG) --# if (ULONG_MAX == LZO_0xffffffffL) --# define LZO_SIZEOF_LONG 4 --# elif (__LZO_LSR(ULONG_MAX,7) == 1) --# define LZO_SIZEOF_LONG 1 --# elif (__LZO_LSR(ULONG_MAX,15) == 1) --# define LZO_SIZEOF_LONG 2 --# elif (__LZO_LSR(ULONG_MAX,31) == 1) --# define LZO_SIZEOF_LONG 4 --# elif (__LZO_LSR(ULONG_MAX,63) == 1) --# define LZO_SIZEOF_LONG 8 --# elif (__LZO_LSR(ULONG_MAX,127) == 1) --# define LZO_SIZEOF_LONG 16 --# else --# error "LZO_SIZEOF_LONG" -+#if !defined(LZO_UNCONST_CAST) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) -+#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) - # endif - #endif --#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) --#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) --# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) --# if (LZO_CC_GNUC >= 0x030300ul) --# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) --# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG --# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) --# define LZO_SIZEOF_LONG_LONG 4 --# endif --# endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) -+#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) - # endif - #endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) - #endif --#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) --#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) --#if (LZO_ARCH_I086 && LZO_CC_DMC) --#elif (LZO_CC_CILLY) && defined(__GNUC__) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_SIZEOF_LONG_LONG 8 --#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_OS_WIN64 || defined(_WIN64)) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) --# define LZO_SIZEOF___INT64 8 --#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) --#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define LZO_SIZEOF_LONG_LONG 8 -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif - #endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) - #endif -+#if !defined(LZO_PCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_PCAST(t,e) ((t) (e)) -+# endif - #endif --#if defined(__cplusplus) && (LZO_CC_GNUC) --# if (LZO_CC_GNUC < 0x020800ul) --# undef LZO_SIZEOF_LONG_LONG -+#if !defined(LZO_PCAST) -+# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) -+#endif -+#if !defined(LZO_CCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_CCAST(t,e) ((t) (e)) - # endif - #endif --#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) --# undef LZO_SIZEOF_LONG_LONG -+#if !defined(LZO_CCAST) -+# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) - #endif --#if !defined(LZO_SIZEOF_VOID_P) --#if (LZO_ARCH_I086) --# define __LZO_WORDSIZE 2 --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) --# define LZO_SIZEOF_VOID_P 2 --# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) --# define LZO_SIZEOF_VOID_P 4 --# else --# error "LZO_MM" -+#if !defined(LZO_ICONV) -+# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ICAST) -+# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ITRUNC) -+# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(__lzo_cte) -+# if (LZO_CC_MSC || LZO_CC_WATCOMC) -+# define __lzo_cte(e) ((void)0,(e)) -+# elif 1 -+# define __lzo_cte(e) ((void)0,(e)) - # endif --#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) --# define __LZO_WORDSIZE 1 --# define LZO_SIZEOF_VOID_P 2 --#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) --# define LZO_SIZEOF_VOID_P 2 --#elif (LZO_ARCH_H8300) --# if defined(__NORMAL_MODE__) --# define __LZO_WORDSIZE 4 --# define LZO_SIZEOF_VOID_P 2 --# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) --# define __LZO_WORDSIZE 4 --# define LZO_SIZEOF_VOID_P 4 --# else --# define __LZO_WORDSIZE 2 --# define LZO_SIZEOF_VOID_P 2 --# endif --# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT --# endif --#elif (LZO_ARCH_M16C) --# define __LZO_WORDSIZE 2 --# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) --# define LZO_SIZEOF_VOID_P 4 --# else --# define LZO_SIZEOF_VOID_P 2 --# endif --#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 4 --#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_OS_OS400 || defined(__OS400__)) --# define __LZO_WORDSIZE LZO_SIZEOF_LONG --# define LZO_SIZEOF_VOID_P 16 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_VOID_P 8 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_ARCH_SPU) --# if 0 --# define __LZO_WORDSIZE 16 --# endif --# define LZO_SIZEOF_VOID_P 4 --#else --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG - #endif -+#if !defined(__lzo_cte) -+# define __lzo_cte(e) (e) - #endif --#if !defined(LZO_WORDSIZE) --# if defined(__LZO_WORDSIZE) --# define LZO_WORDSIZE __LZO_WORDSIZE -+#if !defined(LZO_BLOCK_BEGIN) -+# define LZO_BLOCK_BEGIN do { -+# define LZO_BLOCK_END } while __lzo_cte(0) -+#endif -+#if !defined(LZO_UNUSED) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNUSED(var) ((void) var) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_KEILC) -+# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} -+# elif (LZO_CC_PACIFICC) -+# define LZO_UNUSED(var) ((void) sizeof(var)) -+# elif (LZO_CC_WATCOMC) && defined(__cplusplus) -+# define LZO_UNUSED(var) ((void) var) - # else --# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -+# define LZO_UNUSED(var) ((void) &var) - # endif - #endif --#if !defined(LZO_SIZEOF_SIZE_T) --#if (LZO_ARCH_I086 || LZO_ARCH_M16C) --# define LZO_SIZEOF_SIZE_T 2 --#else --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P --#endif --#endif --#if !defined(LZO_SIZEOF_PTRDIFF_T) --#if (LZO_ARCH_I086) --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P --# elif (LZO_MM_COMPACT || LZO_MM_LARGE) --# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) --# define LZO_SIZEOF_PTRDIFF_T 4 --# else --# define LZO_SIZEOF_PTRDIFF_T 2 --# endif -+#if !defined(LZO_UNUSED_FUNC) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED_FUNC(func) ((void) func) -+# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_CLANG || LZO_CC_LLVM) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_MSC) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_KEILC || LZO_CC_PELLESC) -+# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} - # else --# error "LZO_MM" -+# define LZO_UNUSED_FUNC(func) ((void) func) - # endif --#else --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T --#endif - #endif --#if (LZO_ABI_NEUTRAL_ENDIAN) --# undef LZO_ABI_BIG_ENDIAN --# undef LZO_ABI_LITTLE_ENDIAN --#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) --#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) --# define LZO_ABI_BIG_ENDIAN 1 --#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) --# if (__LITTLE_ENDIAN__ == 1) --# define LZO_ABI_LITTLE_ENDIAN 1 -+#if !defined(LZO_UNUSED_LABEL) -+# if (LZO_CC_CLANG >= 0x020800ul) -+# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) -+# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -+# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l - # else --# define LZO_ABI_BIG_ENDIAN 1 -+# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l - # endif --#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) --# define LZO_ABI_LITTLE_ENDIAN 1 --#endif --#endif --#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) --# error "this should not happen" --#endif --#if (LZO_ABI_BIG_ENDIAN) --# define LZO_INFO_ABI_ENDIAN "be" --#elif (LZO_ABI_LITTLE_ENDIAN) --# define LZO_INFO_ABI_ENDIAN "le" --#elif (LZO_ABI_NEUTRAL_ENDIAN) --# define LZO_INFO_ABI_ENDIAN "neutral" --#endif --#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) --# define LZO_ABI_I8LP16 1 --# define LZO_INFO_ABI_PM "i8lp16" --#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) --# define LZO_ABI_ILP16 1 --# define LZO_INFO_ABI_PM "ilp16" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) --# define LZO_ABI_ILP32 1 --# define LZO_INFO_ABI_PM "ilp32" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) --# define LZO_ABI_LLP64 1 --# define LZO_INFO_ABI_PM "llp64" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) --# define LZO_ABI_LP64 1 --# define LZO_INFO_ABI_PM "lp64" --#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) --# define LZO_ABI_ILP64 1 --# define LZO_INFO_ABI_PM "ilp64" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) --# define LZO_ABI_IP32L64 1 --# define LZO_INFO_ABI_PM "ip32l64" - #endif --#if !defined(__LZO_LIBC_OVERRIDE) --#if (LZO_LIBC_NAKED) --# define LZO_INFO_LIBC "naked" --#elif (LZO_LIBC_FREESTANDING) --# define LZO_INFO_LIBC "freestanding" --#elif (LZO_LIBC_MOSTLY_FREESTANDING) --# define LZO_INFO_LIBC "mfreestanding" --#elif (LZO_LIBC_ISOC90) --# define LZO_INFO_LIBC "isoc90" --#elif (LZO_LIBC_ISOC99) --# define LZO_INFO_LIBC "isoc99" --#elif defined(__dietlibc__) --# define LZO_LIBC_DIETLIBC 1 --# define LZO_INFO_LIBC "dietlibc" --#elif defined(_NEWLIB_VERSION) --# define LZO_LIBC_NEWLIB 1 --# define LZO_INFO_LIBC "newlib" --#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) --# if defined(__UCLIBC_SUBLEVEL__) --# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -+#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -+# if 0 -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -+# elif 0 && (LZO_CC_GNUC) -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var - # else --# define LZO_LIBC_UCLIBC 0x00090bL -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init - # endif --# define LZO_INFO_LIBC "uclibc" --#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) --# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) --# define LZO_INFO_LIBC "glibc" --#elif (LZO_CC_MWERKS) && defined(__MSL__) --# define LZO_LIBC_MSL __MSL__ --# define LZO_INFO_LIBC "msl" --#elif 1 && defined(__IAR_SYSTEMS_ICC__) --# define LZO_LIBC_ISOC90 1 --# define LZO_INFO_LIBC "isoc90" --#else --# define LZO_LIBC_DEFAULT 1 --# define LZO_INFO_LIBC "default" --#endif --#endif --#if !defined(__lzo_gnuc_extension__) --#if (LZO_CC_GNUC >= 0x020800ul) --# define __lzo_gnuc_extension__ __extension__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_gnuc_extension__ __extension__ --#else --# define __lzo_gnuc_extension__ /*empty*/ --#endif --#endif --#if !defined(__lzo_ua_volatile) --# define __lzo_ua_volatile volatile --#endif --#if !defined(__lzo_alignof) --#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_alignof(e) __alignof(e) --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_alignof(e) __alignof__(e) --#endif --#endif --#if defined(__lzo_alignof) --# define __lzo_HAVE_alignof 1 --#endif --#if !defined(__lzo_constructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_constructor __attribute__((__constructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_constructor __attribute__((__constructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_constructor __attribute__((__constructor__)) --#endif --#endif --#if defined(__lzo_constructor) --# define __lzo_HAVE_constructor 1 --#endif --#if !defined(__lzo_destructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_destructor __attribute__((__destructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_destructor __attribute__((__destructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_destructor __attribute__((__destructor__)) --#endif --#endif --#if defined(__lzo_destructor) --# define __lzo_HAVE_destructor 1 --#endif --#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) --# error "this should not happen" - #endif - #if !defined(__lzo_inline) - #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) - #elif defined(__cplusplus) - # define __lzo_inline inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_inline inline - #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) - # define __lzo_inline __inline --#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) - # define __lzo_inline __inline__ - #elif (LZO_CC_DMC) - # define __lzo_inline __inline -+#elif (LZO_CC_GHS) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_inline __inline__ - #elif (LZO_CC_INTELC) - # define __lzo_inline __inline - #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) - # define __lzo_inline __inline - #elif (LZO_CC_MSC && (_MSC_VER >= 900)) - # define __lzo_inline __inline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -+#elif (LZO_CC_SUNPROC >= 0x5100) - # define __lzo_inline __inline__ --#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define __lzo_inline inline - #endif - #endif - #if defined(__lzo_inline) -+# ifndef __lzo_HAVE_inline - # define __lzo_HAVE_inline 1 -+# endif - #else - # define __lzo_inline /*empty*/ - #endif - #if !defined(__lzo_forceinline) - #if (LZO_CC_GNUC >= 0x030200ul) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) - # define __lzo_forceinline __forceinline --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) - #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) - # define __lzo_forceinline __forceinline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) - #endif - #endif - #if defined(__lzo_forceinline) -+# ifndef __lzo_HAVE_forceinline - # define __lzo_HAVE_forceinline 1 -+# endif - #else --# define __lzo_forceinline /*empty*/ -+# define __lzo_forceinline __lzo_inline - #endif - #if !defined(__lzo_noinline) - #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) - # define __lzo_noinline __attribute__((__noinline__,__used__)) - #elif (LZO_CC_GNUC >= 0x030200ul) - # define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) - # define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) - # define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define __lzo_noinline __attribute__((__noinline__)) - #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) - # define __lzo_noinline __declspec(noinline) -@@ -1474,179 +1479,409 @@ extern "C" { - # else - # define __lzo_noinline __declspec(noinline) - # endif --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) - # define __lzo_noinline __attribute__((__noinline__)) - #endif - #endif - #if defined(__lzo_noinline) -+# ifndef __lzo_HAVE_noinline - # define __lzo_HAVE_noinline 1 -+# endif - #else - # define __lzo_noinline /*empty*/ - #endif - #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif --#if !defined(__lzo_noreturn) --#if (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_noreturn __declspec(noreturn) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_noreturn __declspec(noreturn) -+#if !defined(__lzo_static_inline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline - #endif - #endif --#if defined(__lzo_noreturn) --# define __lzo_HAVE_noreturn 1 --#else --# define __lzo_noreturn /*empty*/ -+#if !defined(__lzo_static_inline) -+# define __lzo_static_inline static __lzo_inline - #endif --#if !defined(__lzo_nothrow) --#if (LZO_CC_GNUC >= 0x030300ul) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -+#if !defined(__lzo_static_forceinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline -+#endif -+#endif -+#if !defined(__lzo_static_forceinline) -+# define __lzo_static_forceinline static __lzo_forceinline -+#endif -+#if !defined(__lzo_static_noinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline -+#endif -+#endif -+#if !defined(__lzo_static_noinline) -+# define __lzo_static_noinline static __lzo_noinline -+#endif -+#if !defined(__lzo_c99_extern_inline) -+#if defined(__GNUC_GNU_INLINE__) -+# define __lzo_c99_extern_inline __lzo_inline -+#elif defined(__GNUC_STDC_INLINE__) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#endif -+#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) -+# define __lzo_c99_extern_inline __lzo_inline -+#endif -+#endif -+#if defined(__lzo_c99_extern_inline) -+# ifndef __lzo_HAVE_c99_extern_inline -+# define __lzo_HAVE_c99_extern_inline 1 -+# endif -+#else -+# define __lzo_c99_extern_inline /*empty*/ -+#endif -+#if !defined(__lzo_may_alias) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_CLANG >= 0x020900ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#endif -+#endif -+#if defined(__lzo_may_alias) -+# ifndef __lzo_HAVE_may_alias -+# define __lzo_HAVE_may_alias 1 -+# endif -+#else -+# define __lzo_may_alias /*empty*/ -+#endif -+#if !defined(__lzo_noreturn) -+#if (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#endif -+#endif -+#if defined(__lzo_noreturn) -+# ifndef __lzo_HAVE_noreturn -+# define __lzo_HAVE_noreturn 1 -+# endif -+#else -+# define __lzo_noreturn /*empty*/ -+#endif -+#if !defined(__lzo_nothrow) -+#if (LZO_CC_GNUC >= 0x030300ul) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) - # define __lzo_nothrow __declspec(nothrow) - #endif - #endif - #if defined(__lzo_nothrow) -+# ifndef __lzo_HAVE_nothrow - # define __lzo_HAVE_nothrow 1 -+# endif - #else - # define __lzo_nothrow /*empty*/ - #endif - #if !defined(__lzo_restrict) - #if (LZO_CC_GNUC >= 0x030400ul) - # define __lzo_restrict __restrict__ --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -+#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) - # define __lzo_restrict __restrict__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM) -+#elif (LZO_CC_IBMC >= 1210) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) - # define __lzo_restrict __restrict__ - #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) - # define __lzo_restrict __restrict -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_restrict __restrict__ - #endif - #endif - #if defined(__lzo_restrict) -+# ifndef __lzo_HAVE_restrict - # define __lzo_HAVE_restrict 1 -+# endif - #else - # define __lzo_restrict /*empty*/ - #endif -+#if !defined(__lzo_alignof) -+#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_GHS) && !defined(__cplusplus) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_alignof(e) __alignof(e) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_alignof(e) __alignof__(e) -+#endif -+#endif -+#if defined(__lzo_alignof) -+# ifndef __lzo_HAVE_alignof -+# define __lzo_HAVE_alignof 1 -+# endif -+#endif -+#if !defined(__lzo_struct_packed) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { -+# define __lzo_struct_packed_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_struct_packed(s) _Packed struct s { -+# define __lzo_struct_packed_end() }; -+#endif -+#endif -+#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) -+# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) -+#endif -+#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) -+# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() -+#endif -+#if !defined(__lzo_byte_struct) -+#if defined(__lzo_struct_packed) -+# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() -+# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() -+#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); -+# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); -+#endif -+#endif -+#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) -+# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) -+#endif -+#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) -+#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) -+#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_CILLY || LZO_CC_PCC) -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_align16(s) struct __declspec(align(16)) s { -+# define __lzo_struct_align16_end() }; -+# define __lzo_struct_align32(s) struct __declspec(align(32)) s { -+# define __lzo_struct_align32_end() }; -+# define __lzo_struct_align64(s) struct __declspec(align(64)) s { -+# define __lzo_struct_align64_end() }; -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_struct_align16(s) struct s { -+# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); -+# define __lzo_struct_align32(s) struct s { -+# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); -+# define __lzo_struct_align64(s) struct s { -+# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); -+#endif -+#endif -+#if !defined(__lzo_union_um) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_union_um(s) __pragma(pack(push,1)) union s { -+# define __lzo_union_um_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_union_um(s) _Packed union s { -+# define __lzo_union_um_end() }; -+#endif -+#endif -+#if !defined(__lzo_union_am) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() }; -+#endif -+#if !defined(__lzo_constructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_constructor __attribute__((__constructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_constructor __attribute__((__constructor__)) -+#endif -+#endif -+#if defined(__lzo_constructor) -+# ifndef __lzo_HAVE_constructor -+# define __lzo_HAVE_constructor 1 -+# endif -+#endif -+#if !defined(__lzo_destructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_destructor __attribute__((__destructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_destructor __attribute__((__destructor__)) -+#endif -+#endif -+#if defined(__lzo_destructor) -+# ifndef __lzo_HAVE_destructor -+# define __lzo_HAVE_destructor 1 -+# endif -+#endif -+#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -+# error "unexpected configuration - check your compiler defines" -+#endif - #if !defined(__lzo_likely) && !defined(__lzo_unlikely) - #if (LZO_CC_GNUC >= 0x030200ul) - # define __lzo_likely(e) (__builtin_expect(!!(e),1)) - # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_IBMC >= 1010) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) - #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) - # define __lzo_likely(e) (__builtin_expect(!!(e),1)) - # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define __lzo_likely(e) (__builtin_expect(!!(e),1)) - # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) - #endif - #endif - #if defined(__lzo_likely) -+# ifndef __lzo_HAVE_likely - # define __lzo_HAVE_likely 1 -+# endif - #else - # define __lzo_likely(e) (e) - #endif - #if defined(__lzo_unlikely) -+# ifndef __lzo_HAVE_unlikely - # define __lzo_HAVE_unlikely 1 -+# endif - #else - # define __lzo_unlikely(e) (e) - #endif --#if !defined(LZO_UNUSED) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED(var) ((void) &var) --# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNUSED(var) ((void) var) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_KEILC) --# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} --# elif (LZO_CC_PACIFICC) --# define LZO_UNUSED(var) ((void) sizeof(var)) --# elif (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED(var) ((void) var) -+#if !defined(__lzo_static_unused_void_func) -+# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) - # else --# define LZO_UNUSED(var) ((void) &var) -+# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) - # endif - #endif --#if !defined(LZO_UNUSED_FUNC) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED_FUNC(func) ((void) func) --# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_MSC) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_KEILC || LZO_CC_PELLESC) --# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} -+#if !defined(__lzo_loop_forever) -+# if (LZO_CC_IBMC) -+# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END - # else --# define LZO_UNUSED_FUNC(func) ((void) func) -+# define __lzo_loop_forever() do { ; } while __lzo_cte(1) - # endif - #endif --#if !defined(LZO_UNUSED_LABEL) --# if (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) --# define LZO_UNUSED_LABEL(l) if (0) goto l --# else --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# endif -+#if !defined(__lzo_unreachable) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_GNUC >= 0x040500ul) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 -+# define __lzo_unreachable() __builtin_unreachable(); - #endif --#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -+#endif -+#if defined(__lzo_unreachable) -+# ifndef __lzo_HAVE_unreachable -+# define __lzo_HAVE_unreachable 1 -+# endif -+#else - # if 0 --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var --# elif 0 && (LZO_CC_GNUC) --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -+# define __lzo_unreachable() ((void)0); - # else --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -+# define __lzo_unreachable() __lzo_loop_forever(); - # endif - #endif --#if !defined(LZO_UNCONST_CAST) --# if 0 && defined(__cplusplus) --# define LZO_UNCONST_CAST(t,e) (const_cast (e)) --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) --# else --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) --# endif -+#ifndef __LZO_CTA_NAME -+#if (LZO_CFG_USE_COUNTER) -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) -+#else -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) -+#endif - #endif - #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) - # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END - # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END - # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END - # else --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END - # endif - #endif - #if !defined(LZO_COMPILE_TIME_ASSERT) - # if (LZO_CC_AZTECC) --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} - # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) - # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} -+# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} -+# elif (LZO_CC_GNUC >= 0x040700ul) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} - # elif (LZO_CC_MSC && (_MSC_VER < 900)) - # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; - # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) - # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; - # else --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) -+#if defined(__cplusplus) -+extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) - #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) - # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -@@ -1681,99 +1916,654 @@ extern "C" { - # elif defined(_MT) - # define __lzo_cdecl_sighandler _far _cdecl - # else --# define __lzo_cdecl_sighandler _cdecl -+# define __lzo_cdecl_sighandler _cdecl -+# endif -+# else -+# define __lzo_cdecl_sighandler __cdecl -+# endif -+#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) -+# define __lzo_cdecl cdecl -+#endif -+#if !defined(__lzo_cdecl) -+# define __lzo_cdecl /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_atexit) -+# define __lzo_cdecl_atexit /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_main) -+# define __lzo_cdecl_main /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_qsort) -+# define __lzo_cdecl_qsort /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_sighandler) -+# define __lzo_cdecl_sighandler /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_va) -+# define __lzo_cdecl_va __lzo_cdecl -+#endif -+#if !(LZO_CFG_NO_WINDOWS_H) -+#if !defined(LZO_HAVE_WINDOWS_H) -+#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) -+# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) -+# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) -+# else -+# define LZO_HAVE_WINDOWS_H 1 -+# endif -+#endif -+#endif -+#endif -+#ifndef LZO_SIZEOF_SHORT -+#if defined(SIZEOF_SHORT) -+# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -+#elif defined(__SIZEOF_SHORT__) -+# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_INT -+#if defined(SIZEOF_INT) -+# define LZO_SIZEOF_INT (SIZEOF_INT) -+#elif defined(__SIZEOF_INT__) -+# define LZO_SIZEOF_INT (__SIZEOF_INT__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_LONG -+#if defined(SIZEOF_LONG) -+# define LZO_SIZEOF_LONG (SIZEOF_LONG) -+#elif defined(__SIZEOF_LONG__) -+# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_LONG_LONG -+#if defined(SIZEOF_LONG_LONG) -+# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -+#elif defined(__SIZEOF_LONG_LONG__) -+# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) -+#endif -+#endif -+#ifndef LZO_SIZEOF___INT16 -+#if defined(SIZEOF___INT16) -+# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -+#endif -+#endif -+#ifndef LZO_SIZEOF___INT32 -+#if defined(SIZEOF___INT32) -+# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -+#endif -+#endif -+#ifndef LZO_SIZEOF___INT64 -+#if defined(SIZEOF___INT64) -+# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -+#endif -+#endif -+#ifndef LZO_SIZEOF_VOID_P -+#if defined(SIZEOF_VOID_P) -+# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -+#elif defined(__SIZEOF_POINTER__) -+# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_SIZE_T -+#if defined(SIZEOF_SIZE_T) -+# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -+#elif defined(__SIZEOF_SIZE_T__) -+# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_PTRDIFF_T -+#if defined(SIZEOF_PTRDIFF_T) -+# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -+#elif defined(__SIZEOF_PTRDIFF_T__) -+# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) -+#endif -+#endif -+#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) -+#if !defined(LZO_SIZEOF_SHORT) -+# if (LZO_ARCH_CRAY_PVP) -+# define LZO_SIZEOF_SHORT 8 -+# elif (USHRT_MAX == LZO_0xffffL) -+# define LZO_SIZEOF_SHORT 2 -+# elif (__LZO_LSR(USHRT_MAX,7) == 1) -+# define LZO_SIZEOF_SHORT 1 -+# elif (__LZO_LSR(USHRT_MAX,15) == 1) -+# define LZO_SIZEOF_SHORT 2 -+# elif (__LZO_LSR(USHRT_MAX,31) == 1) -+# define LZO_SIZEOF_SHORT 4 -+# elif (__LZO_LSR(USHRT_MAX,63) == 1) -+# define LZO_SIZEOF_SHORT 8 -+# elif (__LZO_LSR(USHRT_MAX,127) == 1) -+# define LZO_SIZEOF_SHORT 16 -+# else -+# error "LZO_SIZEOF_SHORT" -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) -+#if !defined(LZO_SIZEOF_INT) -+# if (LZO_ARCH_CRAY_PVP) -+# define LZO_SIZEOF_INT 8 -+# elif (UINT_MAX == LZO_0xffffL) -+# define LZO_SIZEOF_INT 2 -+# elif (UINT_MAX == LZO_0xffffffffL) -+# define LZO_SIZEOF_INT 4 -+# elif (__LZO_LSR(UINT_MAX,7) == 1) -+# define LZO_SIZEOF_INT 1 -+# elif (__LZO_LSR(UINT_MAX,15) == 1) -+# define LZO_SIZEOF_INT 2 -+# elif (__LZO_LSR(UINT_MAX,31) == 1) -+# define LZO_SIZEOF_INT 4 -+# elif (__LZO_LSR(UINT_MAX,63) == 1) -+# define LZO_SIZEOF_INT 8 -+# elif (__LZO_LSR(UINT_MAX,127) == 1) -+# define LZO_SIZEOF_INT 16 -+# else -+# error "LZO_SIZEOF_INT" -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) -+#if !defined(LZO_SIZEOF_LONG) -+# if (ULONG_MAX == LZO_0xffffffffL) -+# define LZO_SIZEOF_LONG 4 -+# elif (__LZO_LSR(ULONG_MAX,7) == 1) -+# define LZO_SIZEOF_LONG 1 -+# elif (__LZO_LSR(ULONG_MAX,15) == 1) -+# define LZO_SIZEOF_LONG 2 -+# elif (__LZO_LSR(ULONG_MAX,31) == 1) -+# define LZO_SIZEOF_LONG 4 -+# elif (__LZO_LSR(ULONG_MAX,39) == 1) -+# define LZO_SIZEOF_LONG 5 -+# elif (__LZO_LSR(ULONG_MAX,63) == 1) -+# define LZO_SIZEOF_LONG 8 -+# elif (__LZO_LSR(ULONG_MAX,127) == 1) -+# define LZO_SIZEOF_LONG 16 -+# else -+# error "LZO_SIZEOF_LONG" -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) -+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -+# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) -+# if (LZO_CC_GNUC >= 0x030300ul) -+# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) -+# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG -+# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) -+# define LZO_SIZEOF_LONG_LONG 4 -+# endif -+# endif -+# endif -+#endif -+#endif -+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -+#if (LZO_ARCH_I086 && LZO_CC_DMC) -+#elif (LZO_CC_CILLY) && defined(__GNUC__) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_OS_WIN64 || defined(_WIN64)) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) -+# define LZO_SIZEOF___INT64 8 -+#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) -+#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -+# define LZO_SIZEOF_LONG_LONG 8 -+#endif -+#endif -+#endif -+#if defined(__cplusplus) && (LZO_CC_GNUC) -+# if (LZO_CC_GNUC < 0x020800ul) -+# undef LZO_SIZEOF_LONG_LONG -+# endif -+#endif -+#if (LZO_CFG_NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(__NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(_NO_LONGLONG) -+# undef LZO_SIZEOF_LONG_LONG -+#endif -+#if !defined(LZO_WORDSIZE) -+#if (LZO_ARCH_ALPHA) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AMD64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AVR) -+# define LZO_WORDSIZE 1 -+#elif (LZO_ARCH_H8300) -+# if defined(__NORMAL_MODE__) -+# define LZO_WORDSIZE 4 -+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -+# define LZO_WORDSIZE 4 -+# else -+# define LZO_WORDSIZE 2 -+# endif -+#elif (LZO_ARCH_I086) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_IA64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_M16C) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_SPU) -+# define LZO_WORDSIZE 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_WORDSIZE 1 -+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+# define LZO_WORDSIZE 8 -+#elif (LZO_OS_OS400 || defined(__OS400__)) -+# define LZO_WORDSIZE 8 -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_WORDSIZE 8 -+#endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 4 -+#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif (LZO_ARCH_AVR) -+# define LZO_SIZEOF_VOID_P 2 -+#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) -+# define LZO_SIZEOF_VOID_P 2 -+#elif (LZO_ARCH_H8300) -+# if defined(__NORMAL_MODE__) -+# define LZO_SIZEOF_VOID_P 2 -+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# define LZO_SIZEOF_VOID_P 2 -+# endif -+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT -+# endif -+#elif (LZO_ARCH_I086) -+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -+# define LZO_SIZEOF_VOID_P 2 -+# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# error "invalid LZO_ARCH_I086 memory model" -+# endif -+#elif (LZO_ARCH_M16C) -+# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# define LZO_SIZEOF_VOID_P 2 -+# endif -+#elif (LZO_ARCH_SPU) -+# define LZO_SIZEOF_VOID_P 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_SIZEOF_VOID_P 2 -+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+# define LZO_SIZEOF_VOID_P 4 -+#elif (LZO_OS_OS400 || defined(__OS400__)) -+# if defined(__LLP64_IFC__) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -+# else -+# define LZO_SIZEOF_VOID_P 16 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -+# endif -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -+#endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) -+#if !defined(LZO_SIZEOF_SIZE_T) -+#if (LZO_ARCH_I086 || LZO_ARCH_M16C) -+# define LZO_SIZEOF_SIZE_T 2 -+#endif -+#endif -+#if !defined(LZO_SIZEOF_SIZE_T) -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P -+#endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) -+#endif -+#if !defined(LZO_SIZEOF_PTRDIFF_T) -+#if (LZO_ARCH_I086) -+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P -+# elif (LZO_MM_COMPACT || LZO_MM_LARGE) -+# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) -+# define LZO_SIZEOF_PTRDIFF_T 4 -+# else -+# define LZO_SIZEOF_PTRDIFF_T 2 - # endif - # else --# define __lzo_cdecl_sighandler __cdecl -+# error "invalid LZO_ARCH_I086 memory model" - # endif --#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) --# define __lzo_cdecl cdecl - #endif --#if !defined(__lzo_cdecl) --# define __lzo_cdecl /*empty*/ - #endif --#if !defined(__lzo_cdecl_atexit) --# define __lzo_cdecl_atexit /*empty*/ -+#if !defined(LZO_SIZEOF_PTRDIFF_T) -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T - #endif --#if !defined(__lzo_cdecl_main) --# define __lzo_cdecl_main /*empty*/ -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) - #endif --#if !defined(__lzo_cdecl_qsort) --# define __lzo_cdecl_qsort /*empty*/ -+#if !defined(LZO_WORDSIZE) -+# define LZO_WORDSIZE LZO_SIZEOF_VOID_P - #endif --#if !defined(__lzo_cdecl_sighandler) --# define __lzo_cdecl_sighandler /*empty*/ -+#if (LZO_ABI_NEUTRAL_ENDIAN) -+# undef LZO_ABI_BIG_ENDIAN -+# undef LZO_ABI_LITTLE_ENDIAN -+#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) -+#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) -+# if (__LITTLE_ENDIAN__ == 1) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+# else -+# define LZO_ABI_BIG_ENDIAN 1 -+# endif -+#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) -+# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) -+# error "unexpected configuration - check your compiler defines" -+# elif defined(__BIG_ENDIAN) -+# define LZO_ABI_BIG_ENDIAN 1 -+# else -+# define LZO_ABI_LITTLE_ENDIAN 1 -+# endif -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 - #endif --#if !defined(__lzo_cdecl_va) --# define __lzo_cdecl_va __lzo_cdecl - #endif --#if !(LZO_CFG_NO_WINDOWS_H) --#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) --# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) --# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) -+#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ABI_BIG_ENDIAN) -+# define LZO_INFO_ABI_ENDIAN "be" -+#elif (LZO_ABI_LITTLE_ENDIAN) -+# define LZO_INFO_ABI_ENDIAN "le" -+#elif (LZO_ABI_NEUTRAL_ENDIAN) -+# define LZO_INFO_ABI_ENDIAN "neutral" -+#endif -+#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -+# define LZO_ABI_I8LP16 1 -+# define LZO_INFO_ABI_PM "i8lp16" -+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -+# define LZO_ABI_ILP16 1 -+# define LZO_INFO_ABI_PM "ilp16" -+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_LP32 1 -+# define LZO_INFO_ABI_PM "lp32" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_ILP32 1 -+# define LZO_INFO_ABI_PM "ilp32" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) -+# define LZO_ABI_LLP64 1 -+# define LZO_INFO_ABI_PM "llp64" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -+# define LZO_ABI_LP64 1 -+# define LZO_INFO_ABI_PM "lp64" -+#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -+# define LZO_ABI_ILP64 1 -+# define LZO_INFO_ABI_PM "ilp64" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_IP32L64 1 -+# define LZO_INFO_ABI_PM "ip32l64" -+#endif -+#if 0 -+#elif !defined(__LZO_LIBC_OVERRIDE) -+#if (LZO_LIBC_NAKED) -+# define LZO_INFO_LIBC "naked" -+#elif (LZO_LIBC_FREESTANDING) -+# define LZO_INFO_LIBC "freestanding" -+#elif (LZO_LIBC_MOSTLY_FREESTANDING) -+# define LZO_INFO_LIBC "mfreestanding" -+#elif (LZO_LIBC_ISOC90) -+# define LZO_INFO_LIBC "isoc90" -+#elif (LZO_LIBC_ISOC99) -+# define LZO_INFO_LIBC "isoc99" -+#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) -+# define LZO_LIBC_ISOC90 1 -+# define LZO_INFO_LIBC "isoc90" -+#elif defined(__dietlibc__) -+# define LZO_LIBC_DIETLIBC 1 -+# define LZO_INFO_LIBC "dietlibc" -+#elif defined(_NEWLIB_VERSION) -+# define LZO_LIBC_NEWLIB 1 -+# define LZO_INFO_LIBC "newlib" -+#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) -+# if defined(__UCLIBC_SUBLEVEL__) -+# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) - # else --# define LZO_HAVE_WINDOWS_H 1 -+# define LZO_LIBC_UCLIBC 0x00090bL - # endif -+# define LZO_INFO_LIBC "uc" "libc" -+#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) -+# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) -+# define LZO_INFO_LIBC "glibc" -+#elif (LZO_CC_MWERKS) && defined(__MSL__) -+# define LZO_LIBC_MSL __MSL__ -+# define LZO_INFO_LIBC "msl" -+#elif 1 && defined(__IAR_SYSTEMS_ICC__) -+# define LZO_LIBC_ISOC90 1 -+# define LZO_INFO_LIBC "isoc90" -+#else -+# define LZO_LIBC_DEFAULT 1 -+# define LZO_INFO_LIBC "default" -+#endif -+#endif -+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+# define LZO_ASM_SYNTAX_MSC 1 -+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_CC_GNUC) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#endif -+#if (LZO_ASM_SYNTAX_GNUC) -+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -+# define __LZO_ASM_CLOBBER "ax" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) -+# define __LZO_ASM_CLOBBER "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#else -+# define __LZO_ASM_CLOBBER "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC : "cc" -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ - #endif - #endif - #if (LZO_ARCH_ALPHA) --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_AMD64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# define LZO_OPT_UNALIGNED64 1 --#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_ARM) --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# if defined(__ARM_FEATURE_UNALIGNED) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_CRIS) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_I386) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_IA64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_PREFER_POSTINC 1 - #elif (LZO_ARCH_M68K) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if defined(__mc68020__) && !defined(__mcoldfire__) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - # endif - #elif (LZO_ARCH_MIPS) --# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_POWERPC) --# define LZO_OPT_PREFER_PREINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_PREINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if (LZO_ABI_BIG_ENDIAN) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif -+# endif - # endif - #elif (LZO_ARCH_S390) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# if (LZO_SIZEOF_SIZE_T == 8) --# define LZO_OPT_UNALIGNED64 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - # endif - #elif (LZO_ARCH_SH) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - #endif - #ifndef LZO_CFG_NO_INLINE_ASM --#if (LZO_CC_LLVM) -+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -+# define LZO_CFG_NO_INLINE_ASM 1 -+#elif (LZO_CC_LLVM) - # define LZO_CFG_NO_INLINE_ASM 1 - #endif - #endif -+#if (LZO_CFG_NO_INLINE_ASM) -+# undef LZO_ASM_SYNTAX_MSC -+# undef LZO_ASM_SYNTAX_GNUC -+# undef __LZO_ASM_CLOBBER -+# undef __LZO_ASM_CLOBBER_LIST_CC -+# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY -+# undef __LZO_ASM_CLOBBER_LIST_EMPTY -+#endif - #ifndef LZO_CFG_NO_UNALIGNED - #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) - # define LZO_CFG_NO_UNALIGNED 1 -@@ -1784,25 +2574,6 @@ extern "C" { - # undef LZO_OPT_UNALIGNED32 - # undef LZO_OPT_UNALIGNED64 - #endif --#if (LZO_CFG_NO_INLINE_ASM) --#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --# define LZO_ASM_SYNTAX_MSC 1 --#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) --#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#endif --#if (LZO_ASM_SYNTAX_GNUC) --#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) --# define __LZO_ASM_CLOBBER "ax" --#elif (LZO_CC_INTELC) --# define __LZO_ASM_CLOBBER "memory" --#else --# define __LZO_ASM_CLOBBER "cc", "memory" --#endif --#endif - #if defined(__LZO_INFOSTR_MM) - #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) - # define __LZO_INFOSTR_MM "" -@@ -1846,7 +2617,382 @@ extern "C" { - #define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ - " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER -+#if !(LZO_CFG_SKIP_LZO_TYPES) -+#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if !defined(lzo_llong_t) -+#if (LZO_SIZEOF_LONG_LONG+0 > 0) -+__lzo_gnuc_extension__ typedef long long lzo_llong_t__; -+__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; -+# define lzo_llong_t lzo_llong_t__ -+# define lzo_ullong_t lzo_ullong_t__ -+#endif -+#endif -+#if !defined(lzo_int16e_t) -+#if (LZO_SIZEOF_LONG == 2) -+# define lzo_int16e_t long -+# define lzo_uint16e_t unsigned long -+#elif (LZO_SIZEOF_INT == 2) -+# define lzo_int16e_t int -+# define lzo_uint16e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 2) -+# define lzo_int16e_t short int -+# define lzo_uint16e_t unsigned short int -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) -+ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); -+ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); -+# define lzo_int16e_t lzo_int16e_hi_t__ -+# define lzo_uint16e_t lzo_uint16e_hi_t__ -+#elif (LZO_SIZEOF___INT16 == 2) -+# define lzo_int16e_t __int16 -+# define lzo_uint16e_t unsigned __int16 -+#else -+#endif -+#endif -+#if defined(lzo_int16e_t) -+# define LZO_SIZEOF_LZO_INT16E_T 2 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) -+#endif -+#if !defined(lzo_int32e_t) -+#if (LZO_SIZEOF_LONG == 4) -+# define lzo_int32e_t long int -+# define lzo_uint32e_t unsigned long int -+#elif (LZO_SIZEOF_INT == 4) -+# define lzo_int32e_t int -+# define lzo_uint32e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 4) -+# define lzo_int32e_t short int -+# define lzo_uint32e_t unsigned short int -+#elif (LZO_SIZEOF_LONG_LONG == 4) -+# define lzo_int32e_t lzo_llong_t -+# define lzo_uint32e_t lzo_ullong_t -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+#elif (LZO_SIZEOF___INT32 == 4) -+# define lzo_int32e_t __int32 -+# define lzo_uint32e_t unsigned __int32 -+#else -+#endif -+#endif -+#if defined(lzo_int32e_t) -+# define LZO_SIZEOF_LZO_INT32E_T 4 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) -+#endif -+#if !defined(lzo_int64e_t) -+#if (LZO_SIZEOF___INT64 == 8) -+# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define LZO_CFG_TYPE_PREFER___INT64 1 -+# endif -+#endif -+#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int64e_t int -+# define lzo_uint64e_t unsigned int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG == 8) -+# define lzo_int64e_t long int -+# define lzo_uint64e_t unsigned long int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define lzo_int64e_t lzo_llong_t -+# define lzo_uint64e_t lzo_ullong_t -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0ll) -+# define LZO_UINT64_C(c) ((c) + 0ull) -+# elif 0 -+# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) -+# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) -+# else -+# define LZO_INT64_C(c) (c##LL) -+# define LZO_UINT64_C(c) (c##ULL) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG -+#elif (LZO_SIZEOF___INT64 == 8) -+# define lzo_int64e_t __int64 -+# define lzo_uint64e_t unsigned __int64 -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0i64) -+# define LZO_UINT64_C(c) ((c) + 0ui64) -+# else -+# define LZO_INT64_C(c) (c##i64) -+# define LZO_UINT64_C(c) (c##ui64) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 -+#else -+#endif -+#endif -+#if defined(lzo_int64e_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) -+#endif -+#if !defined(lzo_int32l_t) -+#if defined(lzo_int32e_t) -+# define lzo_int32l_t lzo_int32e_t -+# define lzo_uint32l_t lzo_uint32e_t -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T -+#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int32l_t int -+# define lzo_uint32l_t unsigned int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= 4) -+# define lzo_int32l_t long int -+# define lzo_uint32l_t unsigned long int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG -+#else -+# error "lzo_int32l_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) -+#endif -+#if !defined(lzo_int64l_t) -+#if defined(lzo_int64e_t) -+# define lzo_int64l_t lzo_int64e_t -+# define lzo_uint64l_t lzo_uint64e_t -+# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T -+#else -+#endif -+#endif -+#if defined(lzo_int64l_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) -+#endif -+#if !defined(lzo_int32f_t) -+#if (LZO_SIZEOF_SIZE_T >= 8) -+# define lzo_int32f_t lzo_int64l_t -+# define lzo_uint32f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# define lzo_int32f_t lzo_int32l_t -+# define lzo_uint32f_t lzo_uint32l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) -+#endif -+#if !defined(lzo_int64f_t) -+#if defined(lzo_int64l_t) -+# define lzo_int64f_t lzo_int64l_t -+# define lzo_uint64f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+#endif -+#endif -+#if defined(lzo_int64f_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) -+#endif -+#if !defined(lzo_intptr_t) -+#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) -+# define __LZO_INTPTR_T_IS_POINTER 1 -+ typedef char* lzo_intptr_t; -+ typedef char* lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) -+ typedef __w64 int lzo_intptr_t; -+ typedef __w64 unsigned int lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t short -+# define lzo_uintptr_t unsigned short -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT -+#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_intptr_t int -+# define lzo_uintptr_t unsigned int -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t long -+# define lzo_uintptr_t unsigned long -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t lzo_int64l_t -+# define lzo_uintptr_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# error "lzo_intptr_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) -+#endif -+#if !defined(lzo_word_t) -+#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) -+#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) -+# define lzo_word_t lzo_uintptr_t -+# define lzo_sword_t lzo_intptr_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) -+# define lzo_word_t unsigned long -+# define lzo_sword_t long -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG -+#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) -+# define lzo_word_t unsigned int -+# define lzo_sword_t int -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT -+#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) -+# define lzo_word_t unsigned short -+# define lzo_sword_t short -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT -+#elif (LZO_WORDSIZE == 1) -+# define lzo_word_t unsigned char -+# define lzo_sword_t signed char -+# define LZO_SIZEOF_LZO_WORD_T 1 -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) -+# define lzo_word_t lzo_uint64l_t -+# define lzo_sword_t lzo_int64l_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T -+#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) -+#if 0 -+ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); -+ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); -+# define lzo_word_t lzo_word_t -+# define lzo_sword_t lzo_sword_t -+# define LZO_SIZEOF_LZO_WORD_T 16 -+#endif -+#else -+# error "lzo_word_t" -+#endif -+#endif -+#endif -+#if 1 && defined(lzo_word_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) -+#endif -+#if 1 -+#define lzo_int8_t signed char -+#define lzo_uint8_t unsigned char -+#define LZO_SIZEOF_LZO_INT8_T 1 -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) -+#endif -+#if defined(lzo_int16e_t) -+#define lzo_int16_t lzo_int16e_t -+#define lzo_uint16_t lzo_uint16e_t -+#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) -+#endif -+#if defined(lzo_int32e_t) -+#define lzo_int32_t lzo_int32e_t -+#define lzo_uint32_t lzo_uint32e_t -+#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) -+#endif -+#if defined(lzo_int64e_t) -+#define lzo_int64_t lzo_int64e_t -+#define lzo_uint64_t lzo_uint64e_t -+#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) -+#endif -+#if 1 -+#define lzo_int_least32_t lzo_int32l_t -+#define lzo_uint_least32_t lzo_uint32l_t -+#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) -+#endif -+#if defined(lzo_int64l_t) -+#define lzo_int_least64_t lzo_int64l_t -+#define lzo_uint_least64_t lzo_uint64l_t -+#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) -+#endif -+#if 1 -+#define lzo_int_fast32_t lzo_int32f_t -+#define lzo_uint_fast32_t lzo_uint32f_t -+#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) -+#endif -+#if defined(lzo_int64f_t) -+#define lzo_int_fast64_t lzo_int64f_t -+#define lzo_uint_fast64_t lzo_uint64f_t -+#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) -+#endif -+#if !defined(LZO_INT16_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) ((c) + 0) -+# define LZO_UINT16_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) ((c) + 0L) -+# define LZO_UINT16_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) (c) -+# define LZO_UINT16_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) (c##L) -+# define LZO_UINT16_C(c) (c##UL) -+# else -+# error "LZO_INT16_C" -+# endif -+#endif -+#if !defined(LZO_INT32_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) ((c) + 0) -+# define LZO_UINT32_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) ((c) + 0L) -+# define LZO_UINT32_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) (c) -+# define LZO_UINT32_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) (c##L) -+# define LZO_UINT32_C(c) (c##UL) -+# elif (LZO_SIZEOF_LONG_LONG >= 4) -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+# else -+# error "LZO_INT32_C" -+# endif -+#endif -+#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) ((c) + 0) -+# define LZO_UINT64_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) ((c) + 0L) -+# define LZO_UINT64_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) (c) -+# define LZO_UINT64_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) (c##L) -+# define LZO_UINT64_C(c) (c##UL) -+# else -+# error "LZO_INT64_C" -+# endif -+#endif -+#endif - - #endif /* already included */ - --/* vim:set ts=4 et: */ -+/* vim:set ts=4 sw=4 et: */ -diff --git a/grub-core/lib/minilzo/minilzo.c b/grub-core/lib/minilzo/minilzo.c -index 25a1f68..ab2be5f 100644 ---- a/grub-core/lib/minilzo/minilzo.c -+++ b/grub-core/lib/minilzo/minilzo.c -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -67,12 +52,6 @@ - #if defined(__CYGWIN32__) && !defined(__CYGWIN__) - # define __CYGWIN__ __CYGWIN32__ - #endif --#if defined(__IBMCPP__) && !defined(__IBMC__) --# define __IBMC__ __IBMCPP__ --#endif --#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) --# define __INTEL_COMPILER __ICL --#endif - #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) - # define _ALL_SOURCE 1 - #endif -@@ -81,19 +60,30 @@ - # define __LONG_MAX__ 9223372036854775807L - # endif - #endif --#if defined(__INTEL_COMPILER) && defined(__linux__) -+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) -+#if defined(__ARMCC_VERSION) -+# pragma diag_suppress 193 -+#elif defined(__clang__) && defined(__clang_minor__) -+# pragma clang diagnostic ignored "-Wundef" -+#elif defined(__INTEL_COMPILER) - # pragma warning(disable: 193) --#endif --#if defined(__KEIL__) && defined(__C166__) --# pragma warning disable = 322 --#elif 0 && defined(__C251__) -+#elif defined(__KEIL__) && defined(__C166__) - # pragma warning disable = 322 --#endif --#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) --# if (_MSC_VER >= 1300) -+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) -+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) -+# pragma GCC diagnostic ignored "-Wundef" -+# endif -+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -+# if ((_MSC_VER-0) >= 1300) - # pragma warning(disable: 4668) - # endif - #endif -+#endif -+#if 0 && defined(__POCC__) && defined(_WIN32) -+# if (__POCC__ >= 400) -+# pragma warn(disable: 2216) -+# endif -+#endif - #if 0 && defined(__WATCOMC__) - # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) - # pragma warning 203 9 -@@ -102,13 +92,29 @@ - #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) - # pragma option -h - #endif -+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) -+#ifndef _CRT_NONSTDC_NO_DEPRECATE -+#define _CRT_NONSTDC_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_NONSTDC_NO_WARNINGS -+#define _CRT_NONSTDC_NO_WARNINGS 1 -+#endif -+#ifndef _CRT_SECURE_NO_DEPRECATE -+#define _CRT_SECURE_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_SECURE_NO_WARNINGS -+#define _CRT_SECURE_NO_WARNINGS 1 -+#endif -+#endif - #if 0 --#define LZO_0xffffL 0xfffful --#define LZO_0xffffffffL 0xfffffffful -+#define LZO_0xffffUL 0xfffful -+#define LZO_0xffffffffUL 0xfffffffful - #else --#define LZO_0xffffL 65535ul --#define LZO_0xffffffffL 4294967295ul -+#define LZO_0xffffUL 65535ul -+#define LZO_0xffffffffUL 4294967295ul - #endif -+#define LZO_0xffffL LZO_0xffffUL -+#define LZO_0xffffffffL LZO_0xffffffffUL - #if (LZO_0xffffL == LZO_0xffffffffL) - # error "your preprocessor is broken 1" - #endif -@@ -123,6 +129,13 @@ - # error "your preprocessor is broken 4" - #endif - #endif -+#if defined(__COUNTER__) -+# ifndef LZO_CFG_USE_COUNTER -+# define LZO_CFG_USE_COUNTER 1 -+# endif -+#else -+# undef LZO_CFG_USE_COUNTER -+#endif - #if (UINT_MAX == LZO_0xffffL) - #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) - # if !defined(MSDOS) -@@ -253,14 +266,31 @@ - #endif - #define LZO_PP_STRINGIZE(x) #x - #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) -+#define LZO_PP_CONCAT0() /*empty*/ -+#define LZO_PP_CONCAT1(a) a - #define LZO_PP_CONCAT2(a,b) a ## b - #define LZO_PP_CONCAT3(a,b,c) a ## b ## c - #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g -+#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() -+#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) - #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) - #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) - #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) - #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -+#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) -+#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) -+#define LZO_PP_EMPTY /*empty*/ -+#define LZO_PP_EMPTY0() /*empty*/ -+#define LZO_PP_EMPTY1(a) /*empty*/ -+#define LZO_PP_EMPTY2(a,b) /*empty*/ -+#define LZO_PP_EMPTY3(a,b,c) /*empty*/ -+#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ -+#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ -+#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ -+#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ - #if 1 - #define LZO_CPP_STRINGIZE(x) #x - #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -@@ -268,12 +298,16 @@ - #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c - #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g - #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) - #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) - #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) - #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -+#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) -+#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) - #endif --#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -+#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) - #if 1 && defined(__cplusplus) - # if !defined(__STDC_CONSTANT_MACROS) - # define __STDC_CONSTANT_MACROS 1 -@@ -283,9 +317,13 @@ - # endif - #endif - #if defined(__cplusplus) --# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C_BEGIN extern "C" { -+# define LZO_EXTERN_C_END } - #else --# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C_BEGIN /*empty*/ -+# define LZO_EXTERN_C_END /*empty*/ - #endif - #if !defined(__LZO_OS_OVERRIDE) - #if (LZO_OS_FREESTANDING) -@@ -386,12 +424,12 @@ - #elif defined(__VMS) - # define LZO_OS_VMS 1 - # define LZO_INFO_OS "vms" --#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PS2 1 - # define LZO_INFO_OS "console" - # define LZO_INFO_OS_CONSOLE "ps2" --#elif (defined(__mips__) && defined(__psp__)) -+#elif defined(__mips__) && defined(__psp__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PSP 1 - # define LZO_INFO_OS "console" -@@ -419,9 +457,18 @@ - # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) - # define LZO_OS_POSIX_LINUX 1 - # define LZO_INFO_OS_POSIX "linux" --# elif defined(__APPLE__) || defined(__MACOS__) --# define LZO_OS_POSIX_MACOSX 1 --# define LZO_INFO_OS_POSIX "macosx" -+# elif defined(__APPLE__) && defined(__MACH__) -+# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) -+# define LZO_OS_POSIX_DARWIN 1040 -+# define LZO_INFO_OS_POSIX "darwin_iphone" -+# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) -+# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -+# define LZO_INFO_OS_POSIX "darwin" -+# else -+# define LZO_OS_POSIX_DARWIN 1 -+# define LZO_INFO_OS_POSIX "darwin" -+# endif -+# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN - # elif defined(__minix__) || defined(__minix) - # define LZO_OS_POSIX_MINIX 1 - # define LZO_INFO_OS_POSIX "minix" -@@ -456,18 +503,18 @@ - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (UINT_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -@@ -483,59 +530,65 @@ - # define LZO_INFO_CC "sdcc" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) - #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) --# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) -+# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) - # define LZO_INFO_CC "Pathscale C" - # define LZO_INFO_CCVER __PATHSCALE__ --#elif defined(__INTEL_COMPILER) --# define LZO_CC_INTELC 1 -+# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif -+#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) -+# define LZO_CC_INTELC __INTEL_COMPILER - # define LZO_INFO_CC "Intel C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) --# if defined(_WIN32) || defined(_WIN64) --# define LZO_CC_SYNTAX_MSC 1 --# else --# define LZO_CC_SYNTAX_GNUC 1 -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_INTELC_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif - #elif defined(__POCC__) && defined(_WIN32) - # define LZO_CC_PELLESC 1 - # define LZO_INFO_CC "Pelles C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) --#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) - # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) --# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) -+# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) - # else --# define LZO_CC_CLANG_CLANG 0x010000L -+# define LZO_CC_CLANG 0x010000L -+# endif -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_CLANG_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif --# define LZO_CC_CLANG LZO_CC_CLANG_GNUC - # define LZO_INFO_CC "clang" - # define LZO_INFO_CCVER __VERSION__ - #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif - # define LZO_CC_LLVM LZO_CC_LLVM_GNUC - # define LZO_INFO_CC "llvm-gcc" - # define LZO_INFO_CCVER __VERSION__ --#elif defined(__GNUC__) && defined(__VERSION__) --# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) --# elif defined(__GNUC_MINOR__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) --# else --# define LZO_CC_GNUC (__GNUC__ * 0x10000L) --# endif --# define LZO_INFO_CC "gcc" --# define LZO_INFO_CCVER __VERSION__ - #elif defined(__ACK__) && defined(_ACK) - # define LZO_CC_ACK 1 - # define LZO_INFO_CC "Amsterdam Compiler Kit C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) - #elif defined(__AZTEC_C__) - # define LZO_CC_AZTECC 1 - # define LZO_INFO_CC "Aztec C" -@@ -560,10 +613,23 @@ - # define LZO_CC_DECC 1 - # define LZO_INFO_CC "DEC C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) -+#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) -+# define LZO_CC_GHS 1 -+# define LZO_INFO_CC "Green Hills C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_GHS_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif - #elif defined(__HIGHC__) - # define LZO_CC_HIGHC 1 - # define LZO_INFO_CC "MetaWare High C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) -+# define LZO_CC_HPACC __HP_aCC -+# define LZO_INFO_CC "HP aCC" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) - #elif defined(__IAR_SYSTEMS_ICC__) - # define LZO_CC_IARC 1 - # define LZO_INFO_CC "IAR C" -@@ -572,10 +638,14 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(__IBMC__) --# define LZO_CC_IBMC 1 -+#elif defined(__IBMC__) && ((__IBMC__-0) > 0) -+# define LZO_CC_IBMC __IBMC__ - # define LZO_INFO_CC "IBM C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) -+#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) -+# define LZO_CC_IBMC __IBMCPP__ -+# define LZO_INFO_CC "IBM C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) - #elif defined(__KEIL__) && defined(__C166__) - # define LZO_CC_KEILC 1 - # define LZO_INFO_CC "Keil C" -@@ -592,16 +662,8 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(_MSC_VER) --# define LZO_CC_MSC 1 --# define LZO_INFO_CC "Microsoft C" --# if defined(_MSC_FULL_VER) --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) --# else --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) --# endif --#elif defined(__MWERKS__) --# define LZO_CC_MWERKS 1 -+#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) -+# define LZO_CC_MWERKS __MWERKS__ - # define LZO_INFO_CC "Metrowerks C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) - #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -@@ -612,6 +674,15 @@ - # define LZO_CC_PACIFICC 1 - # define LZO_INFO_CC "Pacific C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) -+#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) -+# if defined(__PGIC_PATCHLEVEL__) -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) -+# else -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" -+# endif -+# define LZO_INFO_CC "Portland Group PGI C" - #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) - # define LZO_CC_PGI 1 - # define LZO_INFO_CC "Portland Group PGI C" -@@ -626,7 +697,7 @@ - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) - #elif defined(__SUNPRO_C) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_C)+0 > 0) -+# if ((__SUNPRO_C-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_C - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) - # else -@@ -635,7 +706,7 @@ - # endif - #elif defined(__SUNPRO_CC) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_CC)+0 > 0) -+# if ((__SUNPRO_CC-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_CC - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) - # else -@@ -661,16 +732,46 @@ - #elif defined(__ZTC__) - # define LZO_CC_ZORTECHC 1 - # define LZO_INFO_CC "Zortech C" --# if (__ZTC__ == 0x310) -+# if ((__ZTC__-0) == 0x310) - # define LZO_INFO_CCVER "0x310" - # else - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) - # endif -+#elif defined(__GNUC__) && defined(__VERSION__) -+# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# elif defined(__GNUC_MINOR__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) -+# else -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -+# endif -+# define LZO_INFO_CC "gcc" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_MSC _MSC_VER -+# define LZO_INFO_CC "Microsoft C" -+# if defined(_MSC_FULL_VER) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -+# else -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -+# endif - #else - # define LZO_CC_UNKNOWN 1 - # define LZO_INFO_CC "unknown" - # define LZO_INFO_CCVER "unknown" - #endif -+#if (LZO_CC_GNUC) && defined(__OPEN64__) -+# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) -+# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) -+# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC -+# endif -+#endif -+#if (LZO_CC_GNUC) && defined(__PCC__) -+# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) -+# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) -+# define LZO_CC_PCC_GNUC LZO_CC_GNUC -+# endif -+#endif - #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) - # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" - #endif -@@ -688,8 +789,10 @@ - # define LZO_INFO_ARCH "generic" - #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086 1 --# define LZO_ARCH_IA16 1 - # define LZO_INFO_ARCH "i086" -+#elif defined(__aarch64__) -+# define LZO_ARCH_ARM64 1 -+# define LZO_INFO_ARCH "arm64" - #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) - # define LZO_ARCH_ALPHA 1 - # define LZO_INFO_ARCH "alpha" -@@ -705,10 +808,10 @@ - # define LZO_INFO_ARCH "arm_thumb" - #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) - # define LZO_ARCH_ARM 1 --# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) -+# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) - # define LZO_ARCH_ARM_THUMB 1 - # define LZO_INFO_ARCH "arm_thumb" --# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) -+# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) - # define LZO_INFO_ARCH "arm" - # else - # define LZO_INFO_ARCH "arm" -@@ -826,53 +929,147 @@ - # error "FIXME - missing define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) --# error "FIXME - missing WIN32 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) --# error "FIXME - missing WIN64 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" - #endif - #if (LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #endif --#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) --# error "this should not happen" -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) -+# define LZO_ARCH_X64 1 -+#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_AMD64 1 -+#endif -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) -+# define LZO_ARCH_AARCH64 1 -+#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_ARM64 1 -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) -+# define LZO_ARCH_X86 1 -+#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_I386 1 -+#endif -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" - #endif --#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) --# error "this should not happen" -+#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ARCH_I086) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_ARCH_I386) - # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" -+# endif -+#endif -+#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# if !defined(LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSE2__) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSSE3) -+# if (LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSSE3__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# elif defined(_MSC_VER) && defined(__AVX__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSE4_2) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__SSE4_2__) -+# define LZO_TARGET_FEATURE_SSE4_2 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__AVX__) -+# define LZO_TARGET_FEATURE_AVX 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX2) -+# if (LZO_TARGET_FEATURE_AVX) -+# if defined(__AVX2__) -+# define LZO_TARGET_FEATURE_AVX2 1 -+# endif -+# endif -+# endif -+#endif -+#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if defined(__ARM_NEON__) -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if 1 -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif - # endif - #endif --#if !defined(__LZO_MM_OVERRIDE) -+#if 0 -+#elif !defined(__LZO_MM_OVERRIDE) - #if (LZO_ARCH_I086) - #if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) - # define LZO_MM_TINY 1 -@@ -899,7 +1096,7 @@ - #elif (LZO_CC_ZORTECHC && defined(__VCM__)) - # define LZO_MM_LARGE 1 - #else --# error "unknown memory model" -+# error "unknown LZO_ARCH_I086 memory model" - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - #define LZO_HAVE_MM_HUGE_PTR 1 -@@ -922,10 +1119,10 @@ - #endif - #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) - # if (LZO_OS_DOS16) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # elif (LZO_CC_ZORTECHC) - # else --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #ifdef __cplusplus -@@ -957,7 +1154,7 @@ extern "C" { - #endif - #elif (LZO_ARCH_C166) - #if !defined(__MODEL__) --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 1) -@@ -971,11 +1168,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #endif - #elif (LZO_ARCH_MCS251) - #if !defined(__MODEL__) --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -987,11 +1184,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #endif - #elif (LZO_ARCH_MCS51) - #if !defined(__MODEL__) --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #elif ((__MODEL__) == 1) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -1003,7 +1200,7 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #endif - #elif (LZO_ARCH_CRAY_PVP) - # define LZO_MM_PVP 1 -@@ -1030,462 +1227,270 @@ extern "C" { - # error "unknown memory model" - #endif - #endif --#if defined(SIZEOF_SHORT) --# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -+#if !defined(__lzo_gnuc_extension__) -+#if (LZO_CC_GNUC >= 0x020800ul) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_gnuc_extension__ __extension__ -+#else - #endif --#if defined(SIZEOF_INT) --# define LZO_SIZEOF_INT (SIZEOF_INT) - #endif --#if defined(SIZEOF_LONG) --# define LZO_SIZEOF_LONG (SIZEOF_LONG) -+#if !defined(__lzo_gnuc_extension__) -+# define __lzo_gnuc_extension__ /*empty*/ - #endif --#if defined(SIZEOF_LONG_LONG) --# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 -+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# else -+# define LZO_CFG_USE_NEW_STYLE_CASTS 1 -+# endif - #endif --#if defined(SIZEOF___INT16) --# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 - #endif --#if defined(SIZEOF___INT32) --# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -+#if !defined(__cplusplus) -+# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# undef LZO_CFG_USE_NEW_STYLE_CASTS -+# endif -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 - #endif --#if defined(SIZEOF___INT64) --# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -+#if !defined(LZO_REINTERPRET_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) -+# endif - #endif --#if defined(SIZEOF_VOID_P) --# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -+#if !defined(LZO_REINTERPRET_CAST) -+# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) - #endif --#if defined(SIZEOF_SIZE_T) --# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -+#if !defined(LZO_STATIC_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_STATIC_CAST(t,e) (static_cast (e)) -+# endif - #endif --#if defined(SIZEOF_PTRDIFF_T) --# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -+#if !defined(LZO_STATIC_CAST) -+# define LZO_STATIC_CAST(t,e) ((t) (e)) - #endif --#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) --#if !defined(LZO_SIZEOF_SHORT) --# if (LZO_ARCH_CRAY_PVP) --# define LZO_SIZEOF_SHORT 8 --# elif (USHRT_MAX == LZO_0xffffL) --# define LZO_SIZEOF_SHORT 2 --# elif (__LZO_LSR(USHRT_MAX,7) == 1) --# define LZO_SIZEOF_SHORT 1 --# elif (__LZO_LSR(USHRT_MAX,15) == 1) --# define LZO_SIZEOF_SHORT 2 --# elif (__LZO_LSR(USHRT_MAX,31) == 1) --# define LZO_SIZEOF_SHORT 4 --# elif (__LZO_LSR(USHRT_MAX,63) == 1) --# define LZO_SIZEOF_SHORT 8 --# elif (__LZO_LSR(USHRT_MAX,127) == 1) --# define LZO_SIZEOF_SHORT 16 --# else --# error "LZO_SIZEOF_SHORT" --# endif -+#if !defined(LZO_STATIC_CAST2) -+# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) - #endif --#if !defined(LZO_SIZEOF_INT) --# if (LZO_ARCH_CRAY_PVP) --# define LZO_SIZEOF_INT 8 --# elif (UINT_MAX == LZO_0xffffL) --# define LZO_SIZEOF_INT 2 --# elif (UINT_MAX == LZO_0xffffffffL) --# define LZO_SIZEOF_INT 4 --# elif (__LZO_LSR(UINT_MAX,7) == 1) --# define LZO_SIZEOF_INT 1 --# elif (__LZO_LSR(UINT_MAX,15) == 1) --# define LZO_SIZEOF_INT 2 --# elif (__LZO_LSR(UINT_MAX,31) == 1) --# define LZO_SIZEOF_INT 4 --# elif (__LZO_LSR(UINT_MAX,63) == 1) --# define LZO_SIZEOF_INT 8 --# elif (__LZO_LSR(UINT_MAX,127) == 1) --# define LZO_SIZEOF_INT 16 --# else --# error "LZO_SIZEOF_INT" -+#if !defined(LZO_UNCONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) - # endif - #endif --#if !defined(LZO_SIZEOF_LONG) --# if (ULONG_MAX == LZO_0xffffffffL) --# define LZO_SIZEOF_LONG 4 --# elif (__LZO_LSR(ULONG_MAX,7) == 1) --# define LZO_SIZEOF_LONG 1 --# elif (__LZO_LSR(ULONG_MAX,15) == 1) --# define LZO_SIZEOF_LONG 2 --# elif (__LZO_LSR(ULONG_MAX,31) == 1) --# define LZO_SIZEOF_LONG 4 --# elif (__LZO_LSR(ULONG_MAX,63) == 1) --# define LZO_SIZEOF_LONG 8 --# elif (__LZO_LSR(ULONG_MAX,127) == 1) --# define LZO_SIZEOF_LONG 16 --# else --# error "LZO_SIZEOF_LONG" -+#if !defined(LZO_UNCONST_CAST) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) -+#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) - # endif - #endif --#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) --#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) --# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) --# if (LZO_CC_GNUC >= 0x030300ul) --# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) --# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG --# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) --# define LZO_SIZEOF_LONG_LONG 4 --# endif --# endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) -+#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) - # endif - #endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) - #endif --#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) --#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) --#if (LZO_ARCH_I086 && LZO_CC_DMC) --#elif (LZO_CC_CILLY) && defined(__GNUC__) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_SIZEOF_LONG_LONG 8 --#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_OS_WIN64 || defined(_WIN64)) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) --# define LZO_SIZEOF___INT64 8 --#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) --# define LZO_SIZEOF___INT64 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) --#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define LZO_SIZEOF_LONG_LONG 8 -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif - #endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) - #endif -+#if !defined(LZO_PCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_PCAST(t,e) ((t) (e)) -+# endif - #endif --#if defined(__cplusplus) && (LZO_CC_GNUC) --# if (LZO_CC_GNUC < 0x020800ul) --# undef LZO_SIZEOF_LONG_LONG -+#if !defined(LZO_PCAST) -+# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) -+#endif -+#if !defined(LZO_CCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_CCAST(t,e) ((t) (e)) - # endif - #endif --#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) --# undef LZO_SIZEOF_LONG_LONG -+#if !defined(LZO_CCAST) -+# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) - #endif --#if !defined(LZO_SIZEOF_VOID_P) --#if (LZO_ARCH_I086) --# define __LZO_WORDSIZE 2 --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) --# define LZO_SIZEOF_VOID_P 2 --# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) --# define LZO_SIZEOF_VOID_P 4 --# else --# error "LZO_MM" -+#if !defined(LZO_ICONV) -+# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ICAST) -+# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ITRUNC) -+# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(__lzo_cte) -+# if (LZO_CC_MSC || LZO_CC_WATCOMC) -+# define __lzo_cte(e) ((void)0,(e)) -+# elif 1 -+# define __lzo_cte(e) ((void)0,(e)) - # endif --#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) --# define __LZO_WORDSIZE 1 --# define LZO_SIZEOF_VOID_P 2 --#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) --# define LZO_SIZEOF_VOID_P 2 --#elif (LZO_ARCH_H8300) --# if defined(__NORMAL_MODE__) --# define __LZO_WORDSIZE 4 --# define LZO_SIZEOF_VOID_P 2 --# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) --# define __LZO_WORDSIZE 4 --# define LZO_SIZEOF_VOID_P 4 --# else --# define __LZO_WORDSIZE 2 --# define LZO_SIZEOF_VOID_P 2 --# endif --# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT --# endif --#elif (LZO_ARCH_M16C) --# define __LZO_WORDSIZE 2 --# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) --# define LZO_SIZEOF_VOID_P 4 --# else --# define LZO_SIZEOF_VOID_P 2 --# endif --#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 4 --#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_OS_OS400 || defined(__OS400__)) --# define __LZO_WORDSIZE LZO_SIZEOF_LONG --# define LZO_SIZEOF_VOID_P 16 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_VOID_P 8 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_ARCH_SPU) --# if 0 --# define __LZO_WORDSIZE 16 --# endif --# define LZO_SIZEOF_VOID_P 4 --#else --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG - #endif -+#if !defined(__lzo_cte) -+# define __lzo_cte(e) (e) - #endif --#if !defined(LZO_WORDSIZE) --# if defined(__LZO_WORDSIZE) --# define LZO_WORDSIZE __LZO_WORDSIZE -+#if !defined(LZO_BLOCK_BEGIN) -+# define LZO_BLOCK_BEGIN do { -+# define LZO_BLOCK_END } while __lzo_cte(0) -+#endif -+#if !defined(LZO_UNUSED) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNUSED(var) ((void) var) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_KEILC) -+# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} -+# elif (LZO_CC_PACIFICC) -+# define LZO_UNUSED(var) ((void) sizeof(var)) -+# elif (LZO_CC_WATCOMC) && defined(__cplusplus) -+# define LZO_UNUSED(var) ((void) var) - # else --# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -+# define LZO_UNUSED(var) ((void) &var) - # endif - #endif --#if !defined(LZO_SIZEOF_SIZE_T) --#if (LZO_ARCH_I086 || LZO_ARCH_M16C) --# define LZO_SIZEOF_SIZE_T 2 --#else --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P --#endif --#endif --#if !defined(LZO_SIZEOF_PTRDIFF_T) --#if (LZO_ARCH_I086) --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P --# elif (LZO_MM_COMPACT || LZO_MM_LARGE) --# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) --# define LZO_SIZEOF_PTRDIFF_T 4 --# else --# define LZO_SIZEOF_PTRDIFF_T 2 --# endif -+#if !defined(LZO_UNUSED_FUNC) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED_FUNC(func) ((void) func) -+# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_CLANG || LZO_CC_LLVM) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_MSC) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_KEILC || LZO_CC_PELLESC) -+# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} - # else --# error "LZO_MM" -+# define LZO_UNUSED_FUNC(func) ((void) func) - # endif --#else --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T --#endif - #endif --#if (LZO_ABI_NEUTRAL_ENDIAN) --# undef LZO_ABI_BIG_ENDIAN --# undef LZO_ABI_LITTLE_ENDIAN --#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) --#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) --# define LZO_ABI_BIG_ENDIAN 1 --#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) --# if (__LITTLE_ENDIAN__ == 1) --# define LZO_ABI_LITTLE_ENDIAN 1 -+#if !defined(LZO_UNUSED_LABEL) -+# if (LZO_CC_CLANG >= 0x020800ul) -+# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) -+# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -+# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l - # else --# define LZO_ABI_BIG_ENDIAN 1 -+# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l - # endif --#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) --# define LZO_ABI_LITTLE_ENDIAN 1 --#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) --# define LZO_ABI_BIG_ENDIAN 1 --#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) --# define LZO_ABI_LITTLE_ENDIAN 1 --#endif --#endif --#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) --# error "this should not happen" --#endif --#if (LZO_ABI_BIG_ENDIAN) --# define LZO_INFO_ABI_ENDIAN "be" --#elif (LZO_ABI_LITTLE_ENDIAN) --# define LZO_INFO_ABI_ENDIAN "le" --#elif (LZO_ABI_NEUTRAL_ENDIAN) --# define LZO_INFO_ABI_ENDIAN "neutral" --#endif --#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) --# define LZO_ABI_I8LP16 1 --# define LZO_INFO_ABI_PM "i8lp16" --#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) --# define LZO_ABI_ILP16 1 --# define LZO_INFO_ABI_PM "ilp16" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) --# define LZO_ABI_ILP32 1 --# define LZO_INFO_ABI_PM "ilp32" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) --# define LZO_ABI_LLP64 1 --# define LZO_INFO_ABI_PM "llp64" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) --# define LZO_ABI_LP64 1 --# define LZO_INFO_ABI_PM "lp64" --#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) --# define LZO_ABI_ILP64 1 --# define LZO_INFO_ABI_PM "ilp64" --#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) --# define LZO_ABI_IP32L64 1 --# define LZO_INFO_ABI_PM "ip32l64" - #endif --#if !defined(__LZO_LIBC_OVERRIDE) --#if (LZO_LIBC_NAKED) --# define LZO_INFO_LIBC "naked" --#elif (LZO_LIBC_FREESTANDING) --# define LZO_INFO_LIBC "freestanding" --#elif (LZO_LIBC_MOSTLY_FREESTANDING) --# define LZO_INFO_LIBC "mfreestanding" --#elif (LZO_LIBC_ISOC90) --# define LZO_INFO_LIBC "isoc90" --#elif (LZO_LIBC_ISOC99) --# define LZO_INFO_LIBC "isoc99" --#elif defined(__dietlibc__) --# define LZO_LIBC_DIETLIBC 1 --# define LZO_INFO_LIBC "dietlibc" --#elif defined(_NEWLIB_VERSION) --# define LZO_LIBC_NEWLIB 1 --# define LZO_INFO_LIBC "newlib" --#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) --# if defined(__UCLIBC_SUBLEVEL__) --# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -+#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -+# if 0 -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -+# elif 0 && (LZO_CC_GNUC) -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var - # else --# define LZO_LIBC_UCLIBC 0x00090bL -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init - # endif --# define LZO_INFO_LIBC "uclibc" --#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) --# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) --# define LZO_INFO_LIBC "glibc" --#elif (LZO_CC_MWERKS) && defined(__MSL__) --# define LZO_LIBC_MSL __MSL__ --# define LZO_INFO_LIBC "msl" --#elif 1 && defined(__IAR_SYSTEMS_ICC__) --# define LZO_LIBC_ISOC90 1 --# define LZO_INFO_LIBC "isoc90" --#else --# define LZO_LIBC_DEFAULT 1 --# define LZO_INFO_LIBC "default" --#endif --#endif --#if !defined(__lzo_gnuc_extension__) --#if (LZO_CC_GNUC >= 0x020800ul) --# define __lzo_gnuc_extension__ __extension__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_gnuc_extension__ __extension__ --#else --# define __lzo_gnuc_extension__ /*empty*/ --#endif --#endif --#if !defined(__lzo_ua_volatile) --# define __lzo_ua_volatile volatile --#endif --#if !defined(__lzo_alignof) --#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_alignof(e) __alignof(e) --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_alignof(e) __alignof__(e) --#endif --#endif --#if defined(__lzo_alignof) --# define __lzo_HAVE_alignof 1 --#endif --#if !defined(__lzo_constructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_constructor __attribute__((__constructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_constructor __attribute__((__constructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_constructor __attribute__((__constructor__)) --#endif --#endif --#if defined(__lzo_constructor) --# define __lzo_HAVE_constructor 1 --#endif --#if !defined(__lzo_destructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_destructor __attribute__((__destructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_destructor __attribute__((__destructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_destructor __attribute__((__destructor__)) --#endif --#endif --#if defined(__lzo_destructor) --# define __lzo_HAVE_destructor 1 --#endif --#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) --# error "this should not happen" - #endif - #if !defined(__lzo_inline) - #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) - #elif defined(__cplusplus) - # define __lzo_inline inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_inline inline - #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) - # define __lzo_inline __inline --#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) - # define __lzo_inline __inline__ - #elif (LZO_CC_DMC) - # define __lzo_inline __inline -+#elif (LZO_CC_GHS) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_inline __inline__ - #elif (LZO_CC_INTELC) - # define __lzo_inline __inline - #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) - # define __lzo_inline __inline - #elif (LZO_CC_MSC && (_MSC_VER >= 900)) - # define __lzo_inline __inline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -+#elif (LZO_CC_SUNPROC >= 0x5100) - # define __lzo_inline __inline__ --#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define __lzo_inline inline - #endif - #endif - #if defined(__lzo_inline) -+# ifndef __lzo_HAVE_inline - # define __lzo_HAVE_inline 1 -+# endif - #else - # define __lzo_inline /*empty*/ - #endif - #if !defined(__lzo_forceinline) - #if (LZO_CC_GNUC >= 0x030200ul) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) - # define __lzo_forceinline __forceinline --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) - #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) - # define __lzo_forceinline __forceinline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) - # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) - #endif - #endif - #if defined(__lzo_forceinline) -+# ifndef __lzo_HAVE_forceinline - # define __lzo_HAVE_forceinline 1 -+# endif - #else --# define __lzo_forceinline /*empty*/ -+# define __lzo_forceinline __lzo_inline - #endif - #if !defined(__lzo_noinline) - #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) - # define __lzo_noinline __attribute__((__noinline__,__used__)) - #elif (LZO_CC_GNUC >= 0x030200ul) - # define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) - # define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) - # define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define __lzo_noinline __attribute__((__noinline__)) - #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) - # define __lzo_noinline __declspec(noinline) -@@ -1494,179 +1499,409 @@ extern "C" { - # else - # define __lzo_noinline __declspec(noinline) - # endif --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) - # define __lzo_noinline __attribute__((__noinline__)) - #endif - #endif - #if defined(__lzo_noinline) -+# ifndef __lzo_HAVE_noinline - # define __lzo_HAVE_noinline 1 -+# endif - #else - # define __lzo_noinline /*empty*/ - #endif - #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif --#if !defined(__lzo_noreturn) --#if (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_noreturn __declspec(noreturn) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_noreturn __declspec(noreturn) -+#if !defined(__lzo_static_inline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline - #endif - #endif --#if defined(__lzo_noreturn) --# define __lzo_HAVE_noreturn 1 --#else --# define __lzo_noreturn /*empty*/ -+#if !defined(__lzo_static_inline) -+# define __lzo_static_inline static __lzo_inline - #endif --#if !defined(__lzo_nothrow) --#if (LZO_CC_GNUC >= 0x030300ul) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#if !defined(__lzo_static_forceinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline -+#endif -+#endif -+#if !defined(__lzo_static_forceinline) -+# define __lzo_static_forceinline static __lzo_forceinline -+#endif -+#if !defined(__lzo_static_noinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline -+#endif -+#endif -+#if !defined(__lzo_static_noinline) -+# define __lzo_static_noinline static __lzo_noinline -+#endif -+#if !defined(__lzo_c99_extern_inline) -+#if defined(__GNUC_GNU_INLINE__) -+# define __lzo_c99_extern_inline __lzo_inline -+#elif defined(__GNUC_STDC_INLINE__) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#endif -+#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) -+# define __lzo_c99_extern_inline __lzo_inline -+#endif -+#endif -+#if defined(__lzo_c99_extern_inline) -+# ifndef __lzo_HAVE_c99_extern_inline -+# define __lzo_HAVE_c99_extern_inline 1 -+# endif -+#else -+# define __lzo_c99_extern_inline /*empty*/ -+#endif -+#if !defined(__lzo_may_alias) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_CLANG >= 0x020900ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#endif -+#endif -+#if defined(__lzo_may_alias) -+# ifndef __lzo_HAVE_may_alias -+# define __lzo_HAVE_may_alias 1 -+# endif -+#else -+# define __lzo_may_alias /*empty*/ -+#endif -+#if !defined(__lzo_noreturn) -+#if (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#endif -+#endif -+#if defined(__lzo_noreturn) -+# ifndef __lzo_HAVE_noreturn -+# define __lzo_HAVE_noreturn 1 -+# endif -+#else -+# define __lzo_noreturn /*empty*/ -+#endif -+#if !defined(__lzo_nothrow) -+#if (LZO_CC_GNUC >= 0x030300ul) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define __lzo_nothrow __attribute__((__nothrow__)) - #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) - # define __lzo_nothrow __declspec(nothrow) - #endif - #endif - #if defined(__lzo_nothrow) -+# ifndef __lzo_HAVE_nothrow - # define __lzo_HAVE_nothrow 1 -+# endif - #else - # define __lzo_nothrow /*empty*/ - #endif - #if !defined(__lzo_restrict) - #if (LZO_CC_GNUC >= 0x030400ul) - # define __lzo_restrict __restrict__ --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -+#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) - # define __lzo_restrict __restrict__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM) -+#elif (LZO_CC_IBMC >= 1210) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) - # define __lzo_restrict __restrict__ - #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) - # define __lzo_restrict __restrict -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_restrict __restrict__ - #endif - #endif - #if defined(__lzo_restrict) -+# ifndef __lzo_HAVE_restrict - # define __lzo_HAVE_restrict 1 -+# endif - #else - # define __lzo_restrict /*empty*/ - #endif -+#if !defined(__lzo_alignof) -+#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_GHS) && !defined(__cplusplus) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_alignof(e) __alignof(e) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_alignof(e) __alignof__(e) -+#endif -+#endif -+#if defined(__lzo_alignof) -+# ifndef __lzo_HAVE_alignof -+# define __lzo_HAVE_alignof 1 -+# endif -+#endif -+#if !defined(__lzo_struct_packed) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { -+# define __lzo_struct_packed_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_struct_packed(s) _Packed struct s { -+# define __lzo_struct_packed_end() }; -+#endif -+#endif -+#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) -+# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) -+#endif -+#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) -+# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() -+#endif -+#if !defined(__lzo_byte_struct) -+#if defined(__lzo_struct_packed) -+# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() -+# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() -+#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); -+# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); -+#endif -+#endif -+#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) -+# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) -+#endif -+#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) -+#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) -+#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_CILLY || LZO_CC_PCC) -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_align16(s) struct __declspec(align(16)) s { -+# define __lzo_struct_align16_end() }; -+# define __lzo_struct_align32(s) struct __declspec(align(32)) s { -+# define __lzo_struct_align32_end() }; -+# define __lzo_struct_align64(s) struct __declspec(align(64)) s { -+# define __lzo_struct_align64_end() }; -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_struct_align16(s) struct s { -+# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); -+# define __lzo_struct_align32(s) struct s { -+# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); -+# define __lzo_struct_align64(s) struct s { -+# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); -+#endif -+#endif -+#if !defined(__lzo_union_um) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_union_um(s) __pragma(pack(push,1)) union s { -+# define __lzo_union_um_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_union_um(s) _Packed union s { -+# define __lzo_union_um_end() }; -+#endif -+#endif -+#if !defined(__lzo_union_am) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() }; -+#endif -+#if !defined(__lzo_constructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_constructor __attribute__((__constructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_constructor __attribute__((__constructor__)) -+#endif -+#endif -+#if defined(__lzo_constructor) -+# ifndef __lzo_HAVE_constructor -+# define __lzo_HAVE_constructor 1 -+# endif -+#endif -+#if !defined(__lzo_destructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_destructor __attribute__((__destructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_destructor __attribute__((__destructor__)) -+#endif -+#endif -+#if defined(__lzo_destructor) -+# ifndef __lzo_HAVE_destructor -+# define __lzo_HAVE_destructor 1 -+# endif -+#endif -+#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -+# error "unexpected configuration - check your compiler defines" -+#endif - #if !defined(__lzo_likely) && !defined(__lzo_unlikely) - #if (LZO_CC_GNUC >= 0x030200ul) - # define __lzo_likely(e) (__builtin_expect(!!(e),1)) - # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_IBMC >= 1010) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) - #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) - # define __lzo_likely(e) (__builtin_expect(!!(e),1)) - # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define __lzo_likely(e) (__builtin_expect(!!(e),1)) - # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) - #endif - #endif - #if defined(__lzo_likely) -+# ifndef __lzo_HAVE_likely - # define __lzo_HAVE_likely 1 -+# endif - #else - # define __lzo_likely(e) (e) - #endif - #if defined(__lzo_unlikely) -+# ifndef __lzo_HAVE_unlikely - # define __lzo_HAVE_unlikely 1 -+# endif - #else - # define __lzo_unlikely(e) (e) - #endif --#if !defined(LZO_UNUSED) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED(var) ((void) &var) --# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNUSED(var) ((void) var) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_KEILC) --# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} --# elif (LZO_CC_PACIFICC) --# define LZO_UNUSED(var) ((void) sizeof(var)) --# elif (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED(var) ((void) var) -+#if !defined(__lzo_static_unused_void_func) -+# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) - # else --# define LZO_UNUSED(var) ((void) &var) -+# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) - # endif - #endif --#if !defined(LZO_UNUSED_FUNC) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED_FUNC(func) ((void) func) --# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_MSC) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_KEILC || LZO_CC_PELLESC) --# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} -+#if !defined(__lzo_loop_forever) -+# if (LZO_CC_IBMC) -+# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END - # else --# define LZO_UNUSED_FUNC(func) ((void) func) -+# define __lzo_loop_forever() do { ; } while __lzo_cte(1) - # endif - #endif --#if !defined(LZO_UNUSED_LABEL) --# if (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) --# define LZO_UNUSED_LABEL(l) if (0) goto l --# else --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# endif -+#if !defined(__lzo_unreachable) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_GNUC >= 0x040500ul) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 -+# define __lzo_unreachable() __builtin_unreachable(); - #endif --#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -+#endif -+#if defined(__lzo_unreachable) -+# ifndef __lzo_HAVE_unreachable -+# define __lzo_HAVE_unreachable 1 -+# endif -+#else - # if 0 --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var --# elif 0 && (LZO_CC_GNUC) --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -+# define __lzo_unreachable() ((void)0); - # else --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -+# define __lzo_unreachable() __lzo_loop_forever(); - # endif - #endif --#if !defined(LZO_UNCONST_CAST) --# if 0 && defined(__cplusplus) --# define LZO_UNCONST_CAST(t,e) (const_cast (e)) --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) --# else --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) --# endif -+#ifndef __LZO_CTA_NAME -+#if (LZO_CFG_USE_COUNTER) -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) -+#else -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) -+#endif - #endif - #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) - # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END - # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END - # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END - # else --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END - # endif - #endif - #if !defined(LZO_COMPILE_TIME_ASSERT) - # if (LZO_CC_AZTECC) --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} - # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) - # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} -+# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} -+# elif (LZO_CC_GNUC >= 0x040700ul) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} - # elif (LZO_CC_MSC && (_MSC_VER < 900)) - # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; - # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) - # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; - # else --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) -+#if defined(__cplusplus) -+extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) - #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) - # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -@@ -1730,6 +1965,7 @@ extern "C" { - # define __lzo_cdecl_va __lzo_cdecl - #endif - #if !(LZO_CFG_NO_WINDOWS_H) -+#if !defined(LZO_HAVE_WINDOWS_H) - #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) - # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) -@@ -1739,60 +1975,614 @@ extern "C" { - # endif - #endif - #endif -+#endif -+#ifndef LZO_SIZEOF_SHORT -+#if defined(SIZEOF_SHORT) -+# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -+#elif defined(__SIZEOF_SHORT__) -+# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_INT -+#if defined(SIZEOF_INT) -+# define LZO_SIZEOF_INT (SIZEOF_INT) -+#elif defined(__SIZEOF_INT__) -+# define LZO_SIZEOF_INT (__SIZEOF_INT__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_LONG -+#if defined(SIZEOF_LONG) -+# define LZO_SIZEOF_LONG (SIZEOF_LONG) -+#elif defined(__SIZEOF_LONG__) -+# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_LONG_LONG -+#if defined(SIZEOF_LONG_LONG) -+# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -+#elif defined(__SIZEOF_LONG_LONG__) -+# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) -+#endif -+#endif -+#ifndef LZO_SIZEOF___INT16 -+#if defined(SIZEOF___INT16) -+# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -+#endif -+#endif -+#ifndef LZO_SIZEOF___INT32 -+#if defined(SIZEOF___INT32) -+# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -+#endif -+#endif -+#ifndef LZO_SIZEOF___INT64 -+#if defined(SIZEOF___INT64) -+# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -+#endif -+#endif -+#ifndef LZO_SIZEOF_VOID_P -+#if defined(SIZEOF_VOID_P) -+# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -+#elif defined(__SIZEOF_POINTER__) -+# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_SIZE_T -+#if defined(SIZEOF_SIZE_T) -+# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -+#elif defined(__SIZEOF_SIZE_T__) -+# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) -+#endif -+#endif -+#ifndef LZO_SIZEOF_PTRDIFF_T -+#if defined(SIZEOF_PTRDIFF_T) -+# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -+#elif defined(__SIZEOF_PTRDIFF_T__) -+# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) -+#endif -+#endif -+#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) -+#if !defined(LZO_SIZEOF_SHORT) -+# if (LZO_ARCH_CRAY_PVP) -+# define LZO_SIZEOF_SHORT 8 -+# elif (USHRT_MAX == LZO_0xffffL) -+# define LZO_SIZEOF_SHORT 2 -+# elif (__LZO_LSR(USHRT_MAX,7) == 1) -+# define LZO_SIZEOF_SHORT 1 -+# elif (__LZO_LSR(USHRT_MAX,15) == 1) -+# define LZO_SIZEOF_SHORT 2 -+# elif (__LZO_LSR(USHRT_MAX,31) == 1) -+# define LZO_SIZEOF_SHORT 4 -+# elif (__LZO_LSR(USHRT_MAX,63) == 1) -+# define LZO_SIZEOF_SHORT 8 -+# elif (__LZO_LSR(USHRT_MAX,127) == 1) -+# define LZO_SIZEOF_SHORT 16 -+# else -+# error "LZO_SIZEOF_SHORT" -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) -+#if !defined(LZO_SIZEOF_INT) -+# if (LZO_ARCH_CRAY_PVP) -+# define LZO_SIZEOF_INT 8 -+# elif (UINT_MAX == LZO_0xffffL) -+# define LZO_SIZEOF_INT 2 -+# elif (UINT_MAX == LZO_0xffffffffL) -+# define LZO_SIZEOF_INT 4 -+# elif (__LZO_LSR(UINT_MAX,7) == 1) -+# define LZO_SIZEOF_INT 1 -+# elif (__LZO_LSR(UINT_MAX,15) == 1) -+# define LZO_SIZEOF_INT 2 -+# elif (__LZO_LSR(UINT_MAX,31) == 1) -+# define LZO_SIZEOF_INT 4 -+# elif (__LZO_LSR(UINT_MAX,63) == 1) -+# define LZO_SIZEOF_INT 8 -+# elif (__LZO_LSR(UINT_MAX,127) == 1) -+# define LZO_SIZEOF_INT 16 -+# else -+# error "LZO_SIZEOF_INT" -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) -+#if !defined(LZO_SIZEOF_LONG) -+# if (ULONG_MAX == LZO_0xffffffffL) -+# define LZO_SIZEOF_LONG 4 -+# elif (__LZO_LSR(ULONG_MAX,7) == 1) -+# define LZO_SIZEOF_LONG 1 -+# elif (__LZO_LSR(ULONG_MAX,15) == 1) -+# define LZO_SIZEOF_LONG 2 -+# elif (__LZO_LSR(ULONG_MAX,31) == 1) -+# define LZO_SIZEOF_LONG 4 -+# elif (__LZO_LSR(ULONG_MAX,39) == 1) -+# define LZO_SIZEOF_LONG 5 -+# elif (__LZO_LSR(ULONG_MAX,63) == 1) -+# define LZO_SIZEOF_LONG 8 -+# elif (__LZO_LSR(ULONG_MAX,127) == 1) -+# define LZO_SIZEOF_LONG 16 -+# else -+# error "LZO_SIZEOF_LONG" -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) -+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -+# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) -+# if (LZO_CC_GNUC >= 0x030300ul) -+# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) -+# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG -+# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) -+# define LZO_SIZEOF_LONG_LONG 4 -+# endif -+# endif -+# endif -+#endif -+#endif -+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -+#if (LZO_ARCH_I086 && LZO_CC_DMC) -+#elif (LZO_CC_CILLY) && defined(__GNUC__) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_OS_WIN64 || defined(_WIN64)) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) -+# define LZO_SIZEOF___INT64 8 -+#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) -+# define LZO_SIZEOF___INT64 8 -+#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) -+#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -+# define LZO_SIZEOF_LONG_LONG 8 -+#endif -+#endif -+#endif -+#if defined(__cplusplus) && (LZO_CC_GNUC) -+# if (LZO_CC_GNUC < 0x020800ul) -+# undef LZO_SIZEOF_LONG_LONG -+# endif -+#endif -+#if (LZO_CFG_NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(__NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(_NO_LONGLONG) -+# undef LZO_SIZEOF_LONG_LONG -+#endif -+#if !defined(LZO_WORDSIZE) -+#if (LZO_ARCH_ALPHA) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AMD64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AVR) -+# define LZO_WORDSIZE 1 -+#elif (LZO_ARCH_H8300) -+# if defined(__NORMAL_MODE__) -+# define LZO_WORDSIZE 4 -+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -+# define LZO_WORDSIZE 4 -+# else -+# define LZO_WORDSIZE 2 -+# endif -+#elif (LZO_ARCH_I086) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_IA64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_M16C) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_SPU) -+# define LZO_WORDSIZE 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_WORDSIZE 1 -+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+# define LZO_WORDSIZE 8 -+#elif (LZO_OS_OS400 || defined(__OS400__)) -+# define LZO_WORDSIZE 8 -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_WORDSIZE 8 -+#endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 4 -+#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif (LZO_ARCH_AVR) -+# define LZO_SIZEOF_VOID_P 2 -+#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) -+# define LZO_SIZEOF_VOID_P 2 -+#elif (LZO_ARCH_H8300) -+# if defined(__NORMAL_MODE__) -+# define LZO_SIZEOF_VOID_P 2 -+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# define LZO_SIZEOF_VOID_P 2 -+# endif -+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT -+# endif -+#elif (LZO_ARCH_I086) -+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -+# define LZO_SIZEOF_VOID_P 2 -+# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# error "invalid LZO_ARCH_I086 memory model" -+# endif -+#elif (LZO_ARCH_M16C) -+# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# define LZO_SIZEOF_VOID_P 2 -+# endif -+#elif (LZO_ARCH_SPU) -+# define LZO_SIZEOF_VOID_P 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_SIZEOF_VOID_P 2 -+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+# define LZO_SIZEOF_VOID_P 4 -+#elif (LZO_OS_OS400 || defined(__OS400__)) -+# if defined(__LLP64_IFC__) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -+# else -+# define LZO_SIZEOF_VOID_P 16 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -+# endif -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -+#endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) -+#if !defined(LZO_SIZEOF_SIZE_T) -+#if (LZO_ARCH_I086 || LZO_ARCH_M16C) -+# define LZO_SIZEOF_SIZE_T 2 -+#endif -+#endif -+#if !defined(LZO_SIZEOF_SIZE_T) -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P -+#endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) -+#endif -+#if !defined(LZO_SIZEOF_PTRDIFF_T) -+#if (LZO_ARCH_I086) -+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P -+# elif (LZO_MM_COMPACT || LZO_MM_LARGE) -+# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) -+# define LZO_SIZEOF_PTRDIFF_T 4 -+# else -+# define LZO_SIZEOF_PTRDIFF_T 2 -+# endif -+# else -+# error "invalid LZO_ARCH_I086 memory model" -+# endif -+#endif -+#endif -+#if !defined(LZO_SIZEOF_PTRDIFF_T) -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T -+#endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) -+#endif -+#if !defined(LZO_WORDSIZE) -+# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -+#endif -+#if (LZO_ABI_NEUTRAL_ENDIAN) -+# undef LZO_ABI_BIG_ENDIAN -+# undef LZO_ABI_LITTLE_ENDIAN -+#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) -+#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) -+# if (__LITTLE_ENDIAN__ == 1) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+# else -+# define LZO_ABI_BIG_ENDIAN 1 -+# endif -+#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) -+# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) -+# error "unexpected configuration - check your compiler defines" -+# elif defined(__BIG_ENDIAN) -+# define LZO_ABI_BIG_ENDIAN 1 -+# else -+# define LZO_ABI_LITTLE_ENDIAN 1 -+# endif -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#endif -+#endif -+#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ABI_BIG_ENDIAN) -+# define LZO_INFO_ABI_ENDIAN "be" -+#elif (LZO_ABI_LITTLE_ENDIAN) -+# define LZO_INFO_ABI_ENDIAN "le" -+#elif (LZO_ABI_NEUTRAL_ENDIAN) -+# define LZO_INFO_ABI_ENDIAN "neutral" -+#endif -+#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -+# define LZO_ABI_I8LP16 1 -+# define LZO_INFO_ABI_PM "i8lp16" -+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -+# define LZO_ABI_ILP16 1 -+# define LZO_INFO_ABI_PM "ilp16" -+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_LP32 1 -+# define LZO_INFO_ABI_PM "lp32" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_ILP32 1 -+# define LZO_INFO_ABI_PM "ilp32" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) -+# define LZO_ABI_LLP64 1 -+# define LZO_INFO_ABI_PM "llp64" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -+# define LZO_ABI_LP64 1 -+# define LZO_INFO_ABI_PM "lp64" -+#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -+# define LZO_ABI_ILP64 1 -+# define LZO_INFO_ABI_PM "ilp64" -+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_IP32L64 1 -+# define LZO_INFO_ABI_PM "ip32l64" -+#endif -+#if 0 -+#elif !defined(__LZO_LIBC_OVERRIDE) -+#if (LZO_LIBC_NAKED) -+# define LZO_INFO_LIBC "naked" -+#elif (LZO_LIBC_FREESTANDING) -+# define LZO_INFO_LIBC "freestanding" -+#elif (LZO_LIBC_MOSTLY_FREESTANDING) -+# define LZO_INFO_LIBC "mfreestanding" -+#elif (LZO_LIBC_ISOC90) -+# define LZO_INFO_LIBC "isoc90" -+#elif (LZO_LIBC_ISOC99) -+# define LZO_INFO_LIBC "isoc99" -+#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) -+# define LZO_LIBC_ISOC90 1 -+# define LZO_INFO_LIBC "isoc90" -+#elif defined(__dietlibc__) -+# define LZO_LIBC_DIETLIBC 1 -+# define LZO_INFO_LIBC "dietlibc" -+#elif defined(_NEWLIB_VERSION) -+# define LZO_LIBC_NEWLIB 1 -+# define LZO_INFO_LIBC "newlib" -+#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) -+# if defined(__UCLIBC_SUBLEVEL__) -+# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) -+# else -+# define LZO_LIBC_UCLIBC 0x00090bL -+# endif -+# define LZO_INFO_LIBC "uc" "libc" -+#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) -+# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) -+# define LZO_INFO_LIBC "glibc" -+#elif (LZO_CC_MWERKS) && defined(__MSL__) -+# define LZO_LIBC_MSL __MSL__ -+# define LZO_INFO_LIBC "msl" -+#elif 1 && defined(__IAR_SYSTEMS_ICC__) -+# define LZO_LIBC_ISOC90 1 -+# define LZO_INFO_LIBC "isoc90" -+#else -+# define LZO_LIBC_DEFAULT 1 -+# define LZO_INFO_LIBC "default" -+#endif -+#endif -+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+# define LZO_ASM_SYNTAX_MSC 1 -+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_CC_GNUC) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#endif -+#if (LZO_ASM_SYNTAX_GNUC) -+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -+# define __LZO_ASM_CLOBBER "ax" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) -+# define __LZO_ASM_CLOBBER "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#else -+# define __LZO_ASM_CLOBBER "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC : "cc" -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#endif -+#endif - #if (LZO_ARCH_ALPHA) --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_AMD64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# define LZO_OPT_UNALIGNED64 1 --#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_ARM) --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# if defined(__ARM_FEATURE_UNALIGNED) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_CRIS) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_I386) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_IA64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_PREFER_POSTINC 1 - #elif (LZO_ARCH_M68K) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if defined(__mc68020__) && !defined(__mcoldfire__) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - # endif - #elif (LZO_ARCH_MIPS) --# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_POWERPC) --# define LZO_OPT_PREFER_PREINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_PREINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if (LZO_ABI_BIG_ENDIAN) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif -+# endif - # endif - #elif (LZO_ARCH_S390) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# if (LZO_SIZEOF_SIZE_T == 8) --# define LZO_OPT_UNALIGNED64 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - # endif - #elif (LZO_ARCH_SH) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - #endif - #ifndef LZO_CFG_NO_INLINE_ASM --#if (LZO_CC_LLVM) -+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) - # define LZO_CFG_NO_INLINE_ASM 1 -+#elif (LZO_CC_LLVM) -+# define LZO_CFG_NO_INLINE_ASM 1 -+#endif - #endif -+#if (LZO_CFG_NO_INLINE_ASM) -+# undef LZO_ASM_SYNTAX_MSC -+# undef LZO_ASM_SYNTAX_GNUC -+# undef __LZO_ASM_CLOBBER -+# undef __LZO_ASM_CLOBBER_LIST_CC -+# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY -+# undef __LZO_ASM_CLOBBER_LIST_EMPTY - #endif - #ifndef LZO_CFG_NO_UNALIGNED - #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -@@ -1804,25 +2594,6 @@ extern "C" { - # undef LZO_OPT_UNALIGNED32 - # undef LZO_OPT_UNALIGNED64 - #endif --#if (LZO_CFG_NO_INLINE_ASM) --#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --# define LZO_ASM_SYNTAX_MSC 1 --#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) --#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#endif --#if (LZO_ASM_SYNTAX_GNUC) --#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) --# define __LZO_ASM_CLOBBER "ax" --#elif (LZO_CC_INTELC) --# define __LZO_ASM_CLOBBER "memory" --#else --# define __LZO_ASM_CLOBBER "cc", "memory" --#endif --#endif - #if defined(__LZO_INFOSTR_MM) - #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) - # define __LZO_INFOSTR_MM "" -@@ -1866,6 +2637,381 @@ extern "C" { - #define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ - " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER -+#if !(LZO_CFG_SKIP_LZO_TYPES) -+#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if !defined(lzo_llong_t) -+#if (LZO_SIZEOF_LONG_LONG+0 > 0) -+__lzo_gnuc_extension__ typedef long long lzo_llong_t__; -+__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; -+# define lzo_llong_t lzo_llong_t__ -+# define lzo_ullong_t lzo_ullong_t__ -+#endif -+#endif -+#if !defined(lzo_int16e_t) -+#if (LZO_SIZEOF_LONG == 2) -+# define lzo_int16e_t long -+# define lzo_uint16e_t unsigned long -+#elif (LZO_SIZEOF_INT == 2) -+# define lzo_int16e_t int -+# define lzo_uint16e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 2) -+# define lzo_int16e_t short int -+# define lzo_uint16e_t unsigned short int -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) -+ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); -+ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); -+# define lzo_int16e_t lzo_int16e_hi_t__ -+# define lzo_uint16e_t lzo_uint16e_hi_t__ -+#elif (LZO_SIZEOF___INT16 == 2) -+# define lzo_int16e_t __int16 -+# define lzo_uint16e_t unsigned __int16 -+#else -+#endif -+#endif -+#if defined(lzo_int16e_t) -+# define LZO_SIZEOF_LZO_INT16E_T 2 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) -+#endif -+#if !defined(lzo_int32e_t) -+#if (LZO_SIZEOF_LONG == 4) -+# define lzo_int32e_t long int -+# define lzo_uint32e_t unsigned long int -+#elif (LZO_SIZEOF_INT == 4) -+# define lzo_int32e_t int -+# define lzo_uint32e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 4) -+# define lzo_int32e_t short int -+# define lzo_uint32e_t unsigned short int -+#elif (LZO_SIZEOF_LONG_LONG == 4) -+# define lzo_int32e_t lzo_llong_t -+# define lzo_uint32e_t lzo_ullong_t -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+#elif (LZO_SIZEOF___INT32 == 4) -+# define lzo_int32e_t __int32 -+# define lzo_uint32e_t unsigned __int32 -+#else -+#endif -+#endif -+#if defined(lzo_int32e_t) -+# define LZO_SIZEOF_LZO_INT32E_T 4 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) -+#endif -+#if !defined(lzo_int64e_t) -+#if (LZO_SIZEOF___INT64 == 8) -+# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define LZO_CFG_TYPE_PREFER___INT64 1 -+# endif -+#endif -+#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int64e_t int -+# define lzo_uint64e_t unsigned int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG == 8) -+# define lzo_int64e_t long int -+# define lzo_uint64e_t unsigned long int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define lzo_int64e_t lzo_llong_t -+# define lzo_uint64e_t lzo_ullong_t -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0ll) -+# define LZO_UINT64_C(c) ((c) + 0ull) -+# elif 0 -+# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) -+# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) -+# else -+# define LZO_INT64_C(c) (c##LL) -+# define LZO_UINT64_C(c) (c##ULL) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG -+#elif (LZO_SIZEOF___INT64 == 8) -+# define lzo_int64e_t __int64 -+# define lzo_uint64e_t unsigned __int64 -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0i64) -+# define LZO_UINT64_C(c) ((c) + 0ui64) -+# else -+# define LZO_INT64_C(c) (c##i64) -+# define LZO_UINT64_C(c) (c##ui64) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 -+#else -+#endif -+#endif -+#if defined(lzo_int64e_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) -+#endif -+#if !defined(lzo_int32l_t) -+#if defined(lzo_int32e_t) -+# define lzo_int32l_t lzo_int32e_t -+# define lzo_uint32l_t lzo_uint32e_t -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T -+#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int32l_t int -+# define lzo_uint32l_t unsigned int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= 4) -+# define lzo_int32l_t long int -+# define lzo_uint32l_t unsigned long int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG -+#else -+# error "lzo_int32l_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) -+#endif -+#if !defined(lzo_int64l_t) -+#if defined(lzo_int64e_t) -+# define lzo_int64l_t lzo_int64e_t -+# define lzo_uint64l_t lzo_uint64e_t -+# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T -+#else -+#endif -+#endif -+#if defined(lzo_int64l_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) -+#endif -+#if !defined(lzo_int32f_t) -+#if (LZO_SIZEOF_SIZE_T >= 8) -+# define lzo_int32f_t lzo_int64l_t -+# define lzo_uint32f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# define lzo_int32f_t lzo_int32l_t -+# define lzo_uint32f_t lzo_uint32l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) -+#endif -+#if !defined(lzo_int64f_t) -+#if defined(lzo_int64l_t) -+# define lzo_int64f_t lzo_int64l_t -+# define lzo_uint64f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+#endif -+#endif -+#if defined(lzo_int64f_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) -+#endif -+#if !defined(lzo_intptr_t) -+#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) -+# define __LZO_INTPTR_T_IS_POINTER 1 -+ typedef char* lzo_intptr_t; -+ typedef char* lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) -+ typedef __w64 int lzo_intptr_t; -+ typedef __w64 unsigned int lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t short -+# define lzo_uintptr_t unsigned short -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT -+#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_intptr_t int -+# define lzo_uintptr_t unsigned int -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t long -+# define lzo_uintptr_t unsigned long -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t lzo_int64l_t -+# define lzo_uintptr_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# error "lzo_intptr_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) -+#endif -+#if !defined(lzo_word_t) -+#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) -+#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) -+# define lzo_word_t lzo_uintptr_t -+# define lzo_sword_t lzo_intptr_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) -+# define lzo_word_t unsigned long -+# define lzo_sword_t long -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG -+#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) -+# define lzo_word_t unsigned int -+# define lzo_sword_t int -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT -+#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) -+# define lzo_word_t unsigned short -+# define lzo_sword_t short -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT -+#elif (LZO_WORDSIZE == 1) -+# define lzo_word_t unsigned char -+# define lzo_sword_t signed char -+# define LZO_SIZEOF_LZO_WORD_T 1 -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) -+# define lzo_word_t lzo_uint64l_t -+# define lzo_sword_t lzo_int64l_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T -+#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) -+#if 0 -+ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); -+ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); -+# define lzo_word_t lzo_word_t -+# define lzo_sword_t lzo_sword_t -+# define LZO_SIZEOF_LZO_WORD_T 16 -+#endif -+#else -+# error "lzo_word_t" -+#endif -+#endif -+#endif -+#if 1 && defined(lzo_word_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) -+#endif -+#if 1 -+#define lzo_int8_t signed char -+#define lzo_uint8_t unsigned char -+#define LZO_SIZEOF_LZO_INT8_T 1 -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) -+#endif -+#if defined(lzo_int16e_t) -+#define lzo_int16_t lzo_int16e_t -+#define lzo_uint16_t lzo_uint16e_t -+#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) -+#endif -+#if defined(lzo_int32e_t) -+#define lzo_int32_t lzo_int32e_t -+#define lzo_uint32_t lzo_uint32e_t -+#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) -+#endif -+#if defined(lzo_int64e_t) -+#define lzo_int64_t lzo_int64e_t -+#define lzo_uint64_t lzo_uint64e_t -+#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) -+#endif -+#if 1 -+#define lzo_int_least32_t lzo_int32l_t -+#define lzo_uint_least32_t lzo_uint32l_t -+#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) -+#endif -+#if defined(lzo_int64l_t) -+#define lzo_int_least64_t lzo_int64l_t -+#define lzo_uint_least64_t lzo_uint64l_t -+#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) -+#endif -+#if 1 -+#define lzo_int_fast32_t lzo_int32f_t -+#define lzo_uint_fast32_t lzo_uint32f_t -+#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) -+#endif -+#if defined(lzo_int64f_t) -+#define lzo_int_fast64_t lzo_int64f_t -+#define lzo_uint_fast64_t lzo_uint64f_t -+#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) -+#endif -+#if !defined(LZO_INT16_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) ((c) + 0) -+# define LZO_UINT16_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) ((c) + 0L) -+# define LZO_UINT16_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) (c) -+# define LZO_UINT16_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) (c##L) -+# define LZO_UINT16_C(c) (c##UL) -+# else -+# error "LZO_INT16_C" -+# endif -+#endif -+#if !defined(LZO_INT32_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) ((c) + 0) -+# define LZO_UINT32_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) ((c) + 0L) -+# define LZO_UINT32_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) (c) -+# define LZO_UINT32_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) (c##L) -+# define LZO_UINT32_C(c) (c##UL) -+# elif (LZO_SIZEOF_LONG_LONG >= 4) -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+# else -+# error "LZO_INT32_C" -+# endif -+#endif -+#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) ((c) + 0) -+# define LZO_UINT64_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) ((c) + 0L) -+# define LZO_UINT64_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) (c) -+# define LZO_UINT64_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) (c##L) -+# define LZO_UINT64_C(c) (c##UL) -+# else -+# error "LZO_INT64_C" -+# endif -+#endif -+#endif - - #endif - -@@ -1874,7 +3020,7 @@ extern "C" { - #undef LZO_HAVE_CONFIG_H - #include "minilzo.h" - --#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050) -+#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2080) - # error "version mismatch in miniLZO source files" - #endif - -@@ -1886,23 +3032,9 @@ extern "C" { - #define __LZO_CONF_H 1 - - #if !defined(__LZO_IN_MINILZO) --#if (LZO_CFG_FREESTANDING) -+#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) - # define LZO_LIBC_FREESTANDING 1 - # define LZO_OS_FREESTANDING 1 --# define ACC_LIBC_FREESTANDING 1 --# define ACC_OS_FREESTANDING 1 --#endif --#if (LZO_CFG_NO_UNALIGNED) --# define ACC_CFG_NO_UNALIGNED 1 --#endif --#if (LZO_ARCH_GENERIC) --# define ACC_ARCH_GENERIC 1 --#endif --#if (LZO_ABI_NEUTRAL_ENDIAN) --# define ACC_ABI_NEUTRAL_ENDIAN 1 --#endif --#if (LZO_HAVE_CONFIG_H) --# define ACC_CONFIG_NO_HEADER 1 - #endif - #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) - # include LZO_CFG_EXTRA_CONFIG_HEADER -@@ -1911,22 +3043,27 @@ extern "C" { - # error "include this file first" - #endif - #include "lzo/lzoconf.h" -+#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) -+# include LZO_CFG_EXTRA_CONFIG_HEADER2 -+#endif - #endif - --#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) -+#if (LZO_VERSION < 0x2080) || !defined(__LZOCONF_H_INCLUDED) - # error "version mismatch" - #endif - --#if (LZO_CC_BORLANDC && LZO_ARCH_I086) --# pragma option -h -+#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) -+# pragma warning(disable: 4702) - #endif -- - #if (LZO_CC_MSC && (_MSC_VER >= 1000)) - # pragma warning(disable: 4127 4701) -+# pragma warning(disable: 4514 4710 4711) - #endif - #if (LZO_CC_MSC && (_MSC_VER >= 1300)) - # pragma warning(disable: 4820) --# pragma warning(disable: 4514 4710 4711) -+#endif -+#if (LZO_CC_MSC && (_MSC_VER >= 1800)) -+# pragma warning(disable: 4746) - #endif - - #if (LZO_CC_SUNPROC) -@@ -1937,48 +3074,15 @@ extern "C" { - #endif - #endif - --#if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR) --# error "this should not happen - check defines for __huge" --#endif -- --#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) --#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) --# define ACC_WANT_ACC_INCD_H 1 --# define ACC_WANT_ACC_INCE_H 1 --# define ACC_WANT_ACC_INCI_H 1 -+#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) - #elif 1 - # include - #else --# define ACC_WANT_ACC_INCD_H 1 -+# define LZO_WANT_ACC_INCD_H 1 - #endif -- --#if (LZO_ARCH_I086) --# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT --# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) --# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) --# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) --#endif -- --#if !defined(lzo_uintptr_t) --# if defined(__LZO_MMODEL_HUGE) --# define lzo_uintptr_t unsigned long --# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) --# define __LZO_UINTPTR_T_IS_POINTER 1 -- typedef char* lzo_uintptr_t; --# define lzo_uintptr_t lzo_uintptr_t --# elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t size_t --# elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned long --# elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned int --# elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned long long --# else --# define lzo_uintptr_t size_t --# endif -+#if defined(LZO_HAVE_CONFIG_H) -+# define LZO_CFG_NO_CONFIG_HEADER 1 - #endif --LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - - #if 1 && !defined(LZO_CFG_FREESTANDING) - #if 1 && !defined(HAVE_STRING_H) -@@ -2002,6 +3106,23 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #include - #endif - -+#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) -+#endif -+#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) -+#endif -+#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) -+#endif -+#if defined(lzo_int64_t) || defined(lzo_uint64_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) -+#endif -+ - #if (LZO_CFG_FREESTANDING) - # undef HAVE_MEMCMP - # undef HAVE_MEMCPY -@@ -2012,169 +3133,635 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #if !(HAVE_MEMCMP) - # undef memcmp - # define memcmp(a,b,c) lzo_memcmp(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memcmp - # define lzo_memcmp(a,b,c) memcmp(a,b,c) - #endif - #if !(HAVE_MEMCPY) - # undef memcpy - # define memcpy(a,b,c) lzo_memcpy(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memcpy - # define lzo_memcpy(a,b,c) memcpy(a,b,c) - #endif - #if !(HAVE_MEMMOVE) - # undef memmove - # define memmove(a,b,c) lzo_memmove(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memmove - # define lzo_memmove(a,b,c) memmove(a,b,c) - #endif - #if !(HAVE_MEMSET) - # undef memset - # define memset(a,b,c) lzo_memset(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memset - # define lzo_memset(a,b,c) memset(a,b,c) - #endif - --#undef NDEBUG --#if (LZO_CFG_FREESTANDING) --# undef LZO_DEBUG --# define NDEBUG 1 --# undef assert --# define assert(e) ((void)0) -+#undef NDEBUG -+#if (LZO_CFG_FREESTANDING) -+# undef LZO_DEBUG -+# define NDEBUG 1 -+# undef assert -+# define assert(e) ((void)0) -+#else -+# if !defined(LZO_DEBUG) -+# define NDEBUG 1 -+# endif -+# include -+#endif -+ -+#if 0 && defined(__BOUNDS_CHECKING_ON) -+# include -+#else -+# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt -+# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) -+#endif -+ -+#if (LZO_CFG_PGO) -+# undef __lzo_likely -+# undef __lzo_unlikely -+# define __lzo_likely(e) (e) -+# define __lzo_unlikely(e) (e) -+#endif -+ -+#undef _ -+#undef __ -+#undef ___ -+#undef ____ -+#undef _p0 -+#undef _p1 -+#undef _p2 -+#undef _p3 -+#undef _p4 -+#undef _s0 -+#undef _s1 -+#undef _s2 -+#undef _s3 -+#undef _s4 -+#undef _ww -+ -+#if 1 -+# define LZO_BYTE(x) ((unsigned char) (x)) -+#else -+# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) -+#endif -+ -+#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) -+#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) -+#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) -+#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) -+ -+#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) -+ -+#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) -+ -+#define LZO_SIZE(bits) (1u << (bits)) -+#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) -+ -+#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) -+#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) -+ -+#if !defined(DMUL) -+#if 0 -+ -+# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) -+#else -+# define DMUL(a,b) ((lzo_xint) ((a) * (b))) -+#endif -+#endif -+ -+#ifndef __LZO_FUNC_H -+#define __LZO_FUNC_H 1 -+ -+#if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN) -+#if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC) -+#define LZO_BITOPS_USE_ASM_BITSCAN 1 -+#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul)))) -+#define LZO_BITOPS_USE_GNUC_BITSCAN 1 -+#elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) -+#define LZO_BITOPS_USE_MSC_BITSCAN 1 -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+#include -+#endif -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+#pragma intrinsic(_BitScanReverse) -+#pragma intrinsic(_BitScanForward) -+#endif -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64) -+#pragma intrinsic(_BitScanReverse64) -+#pragma intrinsic(_BitScanForward64) -+#endif -+#endif -+#endif -+ -+__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+ unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; -+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint32_t r; -+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r ^ 31; -+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) -+ unsigned r; r = (unsigned) __builtin_clz(v); return r; -+#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+ -+#if defined(lzo_uint64_t) -+__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) -+ unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; -+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint64_t r; -+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r ^ 63; -+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_clzl(v); return r; -+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_clzll(v); return r; -+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+#endif -+ -+__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+ unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; -+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint32_t r; -+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r; -+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) -+ unsigned r; r = (unsigned) __builtin_ctz(v); return r; -+#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+ -+#if defined(lzo_uint64_t) -+__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) -+ unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; -+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint64_t r; -+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r; -+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_ctzl(v); return r; -+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_ctzll(v); return r; -+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+#endif -+ -+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+static void __attribute__((__unused__)) -+#else -+__lzo_static_forceinline void -+#endif -+lzo_bitops_unused_funcs(void) -+{ -+ LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func); -+ LZO_UNUSED_FUNC(lzo_bitops_cttz32_func); -+#if defined(lzo_uint64_t) -+ LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func); -+ LZO_UNUSED_FUNC(lzo_bitops_cttz64_func); -+#endif -+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); -+} -+ -+#if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED) -+#ifndef __lzo_memops_tcheck -+#define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b)) -+#endif -+#endif -+#ifndef lzo_memops_TU0p -+#define lzo_memops_TU0p void __LZO_MMODEL * -+#endif -+#ifndef lzo_memops_TU1p -+#define lzo_memops_TU1p unsigned char __LZO_MMODEL * -+#endif -+#ifndef lzo_memops_TU2p -+#if (LZO_OPT_UNALIGNED16) -+typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; -+#define lzo_memops_TU2p volatile lzo_memops_TU2 * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU2_struct,2) -+typedef struct lzo_memops_TU2_struct lzo_memops_TU2; -+#else -+struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; -+typedef struct lzo_memops_TU2_struct lzo_memops_TU2; -+#endif -+#ifndef lzo_memops_TU2p -+#define lzo_memops_TU2p lzo_memops_TU2 * -+#endif -+#endif -+#ifndef lzo_memops_TU4p -+#if (LZO_OPT_UNALIGNED32) -+typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; -+#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU4_struct,4) -+typedef struct lzo_memops_TU4_struct lzo_memops_TU4; -+#else -+struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; -+typedef struct lzo_memops_TU4_struct lzo_memops_TU4; -+#endif -+#ifndef lzo_memops_TU4p -+#define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL * -+#endif -+#endif -+#ifndef lzo_memops_TU8p -+#if (LZO_OPT_UNALIGNED64) -+typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; -+#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU8_struct,8) -+typedef struct lzo_memops_TU8_struct lzo_memops_TU8; -+#else -+struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; -+typedef struct lzo_memops_TU8_struct lzo_memops_TU8; -+#endif -+#ifndef lzo_memops_TU8p -+#define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL * -+#endif -+#endif -+#ifndef lzo_memops_set_TU1p -+#define lzo_memops_set_TU1p volatile lzo_memops_TU1p -+#endif -+#ifndef lzo_memops_move_TU1p -+#define lzo_memops_move_TU1p lzo_memops_TU1p -+#endif -+#define LZO_MEMOPS_SET1(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__1[0] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET2(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET3(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET4(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE1(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__1[0] = s__1[0]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE2(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__2[0] = s__2[0]; d__2[1] = s__2[1]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE3(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE4(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE8(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ -+ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ -+ LZO_BLOCK_END -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) -+#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) -+#if (LZO_OPT_UNALIGNED16) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) -+#define LZO_MEMOPS_COPY2(dd,ss) \ -+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY2(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \ -+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) -+#endif -+#if (LZO_OPT_UNALIGNED32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) -+#define LZO_MEMOPS_COPY4(dd,ss) \ -+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY4(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \ -+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss) -+#endif -+#if (LZO_WORDSIZE != 8) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END -+#else -+#if (LZO_OPT_UNALIGNED64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#elif (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \ -+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss) -+#endif -+#endif -+#define LZO_MEMOPS_COPYN(dd,ss,nn) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \ -+ lzo_uint n__n = (nn); \ -+ while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \ -+ if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \ -+ if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ -+ LZO_BLOCK_END -+ -+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) -+{ -+ lzo_uint16_t v; -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY2(&v, ss); -+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; -+ unsigned long vv; -+ __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); -+ v = (lzo_uint16_t) vv; - #else --# if !defined(LZO_DEBUG) --# define NDEBUG 1 --# endif --# include -+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; -+ v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); - #endif -- --#if 0 && defined(__BOUNDS_CHECKING_ON) --# include -+ return v; -+} -+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) - #else --# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt --# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) -+#define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss) - #endif - --#if !defined(__lzo_inline) --# define __lzo_inline /*empty*/ --#endif --#if !defined(__lzo_forceinline) --# define __lzo_forceinline /*empty*/ -+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss) -+{ -+ lzo_uint32_t v; -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY4(&v, ss); -+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; -+ unsigned long vv; -+ __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); -+ v = (lzo_uint32_t) vv; -+#else -+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; -+ v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24)); - #endif --#if !defined(__lzo_noinline) --# define __lzo_noinline /*empty*/ -+ return v; -+} -+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss) - #endif - --#if (LZO_CFG_PGO) --# undef __acc_likely --# undef __acc_unlikely --# undef __lzo_likely --# undef __lzo_unlikely --# define __acc_likely(e) (e) --# define __acc_unlikely(e) (e) --# define __lzo_likely(e) (e) --# define __lzo_unlikely(e) (e) -+#if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) - #endif - --#if 1 --# define LZO_BYTE(x) ((unsigned char) (x)) -+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss) -+{ -+ lzo_uint16_t v; -+ LZO_MEMOPS_COPY2(&v, ss); -+ return v; -+} -+#if (LZO_OPT_UNALIGNED16) -+#define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) - #else --# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) -+#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) - #endif - --#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) --#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) --#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) --#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) -- --#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) -+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss) -+{ -+ lzo_uint32_t v; -+ LZO_MEMOPS_COPY4(&v, ss); -+ return v; -+} -+#if (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) -+#endif - --#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) -+#if (LZO_OPT_UNALIGNED64) -+#define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#endif - --#define LZO_SIZE(bits) (1u << (bits)) --#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) -+__lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv) -+{ -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY2(dd, &vv); -+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_memops_TU2p d = (lzo_memops_TU2p) dd; -+ unsigned long v = vv; -+ __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); -+#else -+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; -+ d[0] = LZO_BYTE((vv ) & 0xff); -+ d[1] = LZO_BYTE((vv >> 8) & 0xff); -+#endif -+} -+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv) -+#endif - --#define LZO_LSIZE(bits) (1ul << (bits)) --#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) -+__lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv) -+{ -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY4(dd, &vv); -+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_memops_TU4p d = (lzo_memops_TU4p) dd; -+ unsigned long v = vv; -+ __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); -+#else -+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; -+ d[0] = LZO_BYTE((vv ) & 0xff); -+ d[1] = LZO_BYTE((vv >> 8) & 0xff); -+ d[2] = LZO_BYTE((vv >> 16) & 0xff); -+ d[3] = LZO_BYTE((vv >> 24) & 0xff); -+#endif -+} -+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv) -+#endif - --#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) --#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) -+__lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv) -+{ -+ LZO_MEMOPS_COPY2(dd, &vv); -+} -+#if (LZO_OPT_UNALIGNED16) -+#define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv) -+#endif - --#if !defined(DMUL) --#if 0 -+__lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv) -+{ -+ LZO_MEMOPS_COPY4(dd, &vv); -+} -+#if (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv) -+#endif - --# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) -+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+static void __attribute__((__unused__)) - #else --# define DMUL(a,b) ((lzo_xint) ((a) * (b))) -+__lzo_static_forceinline void - #endif -+lzo_memops_unused_funcs(void) -+{ -+ LZO_UNUSED_FUNC(lzo_memops_get_le16); -+ LZO_UNUSED_FUNC(lzo_memops_get_le32); -+ LZO_UNUSED_FUNC(lzo_memops_get_ne16); -+ LZO_UNUSED_FUNC(lzo_memops_get_ne32); -+ LZO_UNUSED_FUNC(lzo_memops_put_le16); -+ LZO_UNUSED_FUNC(lzo_memops_put_le32); -+ LZO_UNUSED_FUNC(lzo_memops_put_ne16); -+ LZO_UNUSED_FUNC(lzo_memops_put_ne32); -+ LZO_UNUSED_FUNC(lzo_memops_unused_funcs); -+} -+ - #endif - --#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC) --# if (LZO_SIZEOF_SHORT == 2) --# define LZO_UNALIGNED_OK_2 1 --# endif --# if (LZO_SIZEOF_INT == 4) --# define LZO_UNALIGNED_OK_4 1 --# endif -+#ifndef UA_SET1 -+#define UA_SET1 LZO_MEMOPS_SET1 - #endif --#if 1 && (LZO_ARCH_AMD64) --# if defined(LZO_UINT64_MAX) --# define LZO_UNALIGNED_OK_8 1 --# endif -+#ifndef UA_SET2 -+#define UA_SET2 LZO_MEMOPS_SET2 - #endif --#if (LZO_CFG_NO_UNALIGNED) --# undef LZO_UNALIGNED_OK_2 --# undef LZO_UNALIGNED_OK_4 --# undef LZO_UNALIGNED_OK_8 --#endif -- --#undef UA_GET16 --#undef UA_SET16 --#undef UA_COPY16 --#undef UA_GET32 --#undef UA_SET32 --#undef UA_COPY32 --#undef UA_GET64 --#undef UA_SET64 --#undef UA_COPY64 --#if defined(LZO_UNALIGNED_OK_2) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2) --# if 1 && defined(ACC_UA_COPY16) --# define UA_GET16 ACC_UA_GET16 --# define UA_SET16 ACC_UA_SET16 --# define UA_COPY16 ACC_UA_COPY16 --# else --# define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v)) --# define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s)) --# endif -+#ifndef UA_SET3 -+#define UA_SET3 LZO_MEMOPS_SET3 - #endif --#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) --# if 1 && defined(ACC_UA_COPY32) --# define UA_GET32 ACC_UA_GET32 --# define UA_SET32 ACC_UA_SET32 --# define UA_COPY32 ACC_UA_COPY32 --# else --# define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v)) --# define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s)) --# endif -+#ifndef UA_SET4 -+#define UA_SET4 LZO_MEMOPS_SET4 - #endif --#if defined(LZO_UNALIGNED_OK_8) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8) --# if 1 && defined(ACC_UA_COPY64) --# define UA_GET64 ACC_UA_GET64 --# define UA_SET64 ACC_UA_SET64 --# define UA_COPY64 ACC_UA_COPY64 --# else --# define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v)) --# define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s)) --# endif -+#ifndef UA_MOVE1 -+#define UA_MOVE1 LZO_MEMOPS_MOVE1 -+#endif -+#ifndef UA_MOVE2 -+#define UA_MOVE2 LZO_MEMOPS_MOVE2 -+#endif -+#ifndef UA_MOVE3 -+#define UA_MOVE3 LZO_MEMOPS_MOVE3 -+#endif -+#ifndef UA_MOVE4 -+#define UA_MOVE4 LZO_MEMOPS_MOVE4 -+#endif -+#ifndef UA_MOVE8 -+#define UA_MOVE8 LZO_MEMOPS_MOVE8 -+#endif -+#ifndef UA_COPY1 -+#define UA_COPY1 LZO_MEMOPS_COPY1 -+#endif -+#ifndef UA_COPY2 -+#define UA_COPY2 LZO_MEMOPS_COPY2 -+#endif -+#ifndef UA_COPY3 -+#define UA_COPY3 LZO_MEMOPS_COPY3 -+#endif -+#ifndef UA_COPY4 -+#define UA_COPY4 LZO_MEMOPS_COPY4 -+#endif -+#ifndef UA_COPY8 -+#define UA_COPY8 LZO_MEMOPS_COPY8 -+#endif -+#ifndef UA_COPYN -+#define UA_COPYN LZO_MEMOPS_COPYN -+#endif -+#ifndef UA_COPYN_X -+#define UA_COPYN_X LZO_MEMOPS_COPYN -+#endif -+#ifndef UA_GET_LE16 -+#define UA_GET_LE16 LZO_MEMOPS_GET_LE16 -+#endif -+#ifndef UA_GET_LE32 -+#define UA_GET_LE32 LZO_MEMOPS_GET_LE32 -+#endif -+#ifdef LZO_MEMOPS_GET_LE64 -+#ifndef UA_GET_LE64 -+#define UA_GET_LE64 LZO_MEMOPS_GET_LE64 -+#endif -+#endif -+#ifndef UA_GET_NE16 -+#define UA_GET_NE16 LZO_MEMOPS_GET_NE16 -+#endif -+#ifndef UA_GET_NE32 -+#define UA_GET_NE32 LZO_MEMOPS_GET_NE32 -+#endif -+#ifdef LZO_MEMOPS_GET_NE64 -+#ifndef UA_GET_NE64 -+#define UA_GET_NE64 LZO_MEMOPS_GET_NE64 -+#endif -+#endif -+#ifndef UA_PUT_LE16 -+#define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 -+#endif -+#ifndef UA_PUT_LE32 -+#define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 -+#endif -+#ifndef UA_PUT_NE16 -+#define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 -+#endif -+#ifndef UA_PUT_NE32 -+#define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 - #endif - - #define MEMCPY8_DS(dest,src,len) \ -@@ -2195,25 +3782,10 @@ LZO_EXTERN(const lzo_bytep) lzo_copyright(void); - extern "C" { - #endif - --#if !defined(lzo_uintptr_t) --# if (__LZO_MMODEL_HUGE) --# define lzo_uintptr_t unsigned long --# else --# define lzo_uintptr_t acc_uintptr_t --# ifdef __ACC_INTPTR_T_IS_POINTER --# define __LZO_UINTPTR_T_IS_POINTER 1 --# endif --# endif --#endif -- - #if (LZO_ARCH_I086) --#define PTR(a) ((lzo_bytep) (a)) --#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) --#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) -+#error "LZO_ARCH_I086 is unsupported" - #elif (LZO_MM_PVP) --#define PTR(a) ((lzo_bytep) (a)) --#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) --#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) -+#error "LZO_MM_PVP is unsupported" - #else - #define PTR(a) ((lzo_uintptr_t) (a)) - #define PTR_LINEAR(a) PTR(a) -@@ -2243,24 +3815,28 @@ typedef union - unsigned long a_ulong; - lzo_int a_lzo_int; - lzo_uint a_lzo_uint; -- lzo_int32 a_lzo_int32; -- lzo_uint32 a_lzo_uint32; --#if defined(LZO_UINT64_MAX) -- lzo_int64 a_lzo_int64; -- lzo_uint64 a_lzo_uint64; --#endif -+ lzo_xint a_lzo_xint; -+ lzo_int16_t a_lzo_int16_t; -+ lzo_uint16_t a_lzo_uint16_t; -+ lzo_int32_t a_lzo_int32_t; -+ lzo_uint32_t a_lzo_uint32_t; -+#if defined(lzo_uint64_t) -+ lzo_int64_t a_lzo_int64_t; -+ lzo_uint64_t a_lzo_uint64_t; -+#endif -+ size_t a_size_t; - ptrdiff_t a_ptrdiff_t; - lzo_uintptr_t a_lzo_uintptr_t; -- lzo_voidp a_lzo_voidp; - void * a_void_p; -- lzo_bytep a_lzo_bytep; -- lzo_bytepp a_lzo_bytepp; -- lzo_uintp a_lzo_uintp; -- lzo_uint * a_lzo_uint_p; -- lzo_uint32p a_lzo_uint32p; -- lzo_uint32 * a_lzo_uint32_p; -- unsigned char * a_uchar_p; - char * a_char_p; -+ unsigned char * a_uchar_p; -+ const void * a_c_void_p; -+ const char * a_c_char_p; -+ const unsigned char * a_c_uchar_p; -+ lzo_voidp a_lzo_voidp; -+ lzo_bytep a_lzo_bytep; -+ const lzo_voidp a_c_lzo_voidp; -+ const lzo_bytep a_c_lzo_bytep; - } - lzo_full_align_t; - -@@ -2276,18 +3852,14 @@ lzo_full_align_t; - - #ifndef LZO_DICT_USE_PTR - #define LZO_DICT_USE_PTR 1 --#if 0 && (LZO_ARCH_I086) --# undef LZO_DICT_USE_PTR --# define LZO_DICT_USE_PTR 0 --#endif - #endif - - #if (LZO_DICT_USE_PTR) - # define lzo_dict_t const lzo_bytep --# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -+# define lzo_dict_p lzo_dict_t * - #else - # define lzo_dict_t lzo_uint --# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -+# define lzo_dict_p lzo_dict_t * - #endif - - #endif -@@ -2300,10 +3872,9 @@ __lzo_ptr_linear(const lzo_voidp ptr) - lzo_uintptr_t p; - - #if (LZO_ARCH_I086) -- p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); -+#error "LZO_ARCH_I086 is unsupported" - #elif (LZO_MM_PVP) -- p = (lzo_uintptr_t) (ptr); -- p = (p << 3) | (p >> 61); -+#error "LZO_MM_PVP is unsupported" - #else - p = (lzo_uintptr_t) PTR_LINEAR(ptr); - #endif -@@ -2314,9 +3885,8 @@ __lzo_ptr_linear(const lzo_voidp ptr) - LZO_PUBLIC(unsigned) - __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) - { --#if defined(__LZO_UINTPTR_T_IS_POINTER) -- size_t n = (size_t) ptr; -- n = (((n + size - 1) / size) * size) - n; -+#if (__LZO_UINTPTR_T_IS_POINTER) -+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" - #else - lzo_uintptr_t p, n; - p = __lzo_ptr_linear(ptr); -@@ -2342,7 +3912,7 @@ static const char __lzo_copyright[] = - #else - "\r\n\n" - "LZO data compression library.\n" -- "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n" -+ "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n" - "\n" - "http://www.oberhumer.com $\n\n" - "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" -@@ -2352,11 +3922,7 @@ static const char __lzo_copyright[] = - LZO_PUBLIC(const lzo_bytep) - lzo_copyright(void) - { --#if (LZO_OS_DOS16 && LZO_CC_TURBOC) -- return (lzo_voidp) __lzo_copyright; --#else - return (const lzo_bytep) __lzo_copyright; --#endif - } - - LZO_PUBLIC(unsigned) -@@ -2393,16 +3959,16 @@ _lzo_version_date(void) - #define LZO_NMAX 5552 - - #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 --#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); --#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); --#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); --#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); -+#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1) -+#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2) -+#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4) -+#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8) - --LZO_PUBLIC(lzo_uint32) --lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) -+LZO_PUBLIC(lzo_uint32_t) -+lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len) - { -- lzo_uint32 s1 = adler & 0xffff; -- lzo_uint32 s2 = (adler >> 16) & 0xffff; -+ lzo_uint32_t s1 = adler & 0xffff; -+ lzo_uint32_t s2 = (adler >> 16) & 0xffff; - unsigned k; - - if (buf == NULL) -@@ -2459,8 +4025,8 @@ lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) - LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) -- const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; -+ const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2); - if __lzo_likely(len > 0) do - { - int d = *p1 - *p2; -@@ -2476,8 +4042,8 @@ LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo - LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) -- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; -+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); - if (!(len > 0) || p1 == p2) - return dest; - do -@@ -2491,8 +4057,8 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src - LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) -- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; -+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); - if (!(len > 0) || p1 == p2) - return dest; - if (p1 < p2) -@@ -2514,16 +4080,17 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p sr - return memmove(dest, src, len); - #endif - } --LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) -+LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) -- lzo_hbyte_p p = (lzo_hbyte_p) s; -+ lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s); -+ unsigned char c = LZO_ITRUNC(unsigned char, cc); - if __lzo_likely(len > 0) do -- *p++ = (unsigned char) c; -+ *p++ = c; - while __lzo_likely(--len > 0); - return s; - #else -- return memset(s, c, len); -+ return memset(s, cc, len); - #endif - } - #undef LZOLIB_PUBLIC -@@ -2532,105 +4099,28 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) - - #if !defined(__LZO_IN_MINILZO) - --#define ACC_WANT_ACC_CHK_CH 1 --#undef ACCCHK_ASSERT -- -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) -- -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) -- ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) -- ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) --#if defined(LZO_UINT64_MAX) -- ACCCHK_ASSERT(sizeof(lzo_uint64) == 8) -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64) --#endif -- --#if !defined(__LZO_UINTPTR_T_IS_POINTER) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) --#endif -- ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -- -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) -- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) -- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) -- ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) -+#define LZO_WANT_ACC_CHK_CH 1 -+#undef LZOCHK_ASSERT - -+ LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) -+ LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) -+#if !(__LZO_UINTPTR_T_IS_POINTER) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) - #endif --#undef ACCCHK_ASSERT -+ LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) - --#if 0 --#define WANT_lzo_bitops_clz32 1 --#define WANT_lzo_bitops_clz64 1 --#endif --#define WANT_lzo_bitops_ctz32 1 --#define WANT_lzo_bitops_ctz64 1 -- --#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) --#include --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 --#pragma intrinsic(_BitScanReverse) --static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanReverse(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz32 lzo_bitops_clz32 --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 --#pragma intrinsic(_BitScanReverse64) --static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanReverse64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz64 lzo_bitops_clz64 --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#pragma intrinsic(_BitScanForward) --static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanForward(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz32 lzo_bitops_ctz32 --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#pragma intrinsic(_BitScanForward64) --static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanForward64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz64 lzo_bitops_ctz64 - #endif -+#undef LZOCHK_ASSERT - --#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) --#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) --#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) --#endif -+union lzo_config_check_union { -+ lzo_uint a[2]; -+ unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; -+#if defined(lzo_uint64_t) -+ lzo_uint64_t c[2]; - #endif -+}; - - #if 0 - #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off))) -@@ -2644,73 +4134,101 @@ static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) - LZO_PUBLIC(int) - _lzo_config_check(void) - { -- lzo_bool r = 1; -- union { -- lzo_xint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_xint))]; --#if defined(LZO_UNALIGNED_OK_8) -- lzo_uint64 c[2]; --#endif -- unsigned short x[2]; lzo_uint32 y[2]; lzo_uint z[2]; -- } u; -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul)) -+# if 0 -+ volatile -+# endif -+#endif -+ union lzo_config_check_union u; - lzo_voidp p; -+ unsigned r = 1; - - u.a[0] = u.a[1] = 0; - p = u2p(&u, 0); - r &= ((* (lzo_bytep) p) == 0); --#if !defined(LZO_CFG_NO_CONFIG_CHECK) --#if defined(LZO_ABI_BIG_ENDIAN) -+#if !(LZO_CFG_NO_CONFIG_CHECK) -+#if (LZO_ABI_BIG_ENDIAN) - u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; - p = u2p(&u, 0); - r &= ((* (lzo_uintp) p) == 128); - #endif --#if defined(LZO_ABI_LITTLE_ENDIAN) -+#if (LZO_ABI_LITTLE_ENDIAN) - u.a[0] = u.a[1] = 0; u.b[0] = 128; - p = u2p(&u, 0); - r &= ((* (lzo_uintp) p) == 128); - #endif --#if defined(LZO_UNALIGNED_OK_2) - u.a[0] = u.a[1] = 0; -- u.b[0] = 1; u.b[sizeof(unsigned short) + 1] = 2; -+ u.b[0] = 1; u.b[3] = 2; - p = u2p(&u, 1); -- r &= ((* (lzo_ushortp) p) == 0); -+ r &= UA_GET_NE16(p) == 0; -+ r &= UA_GET_LE16(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE16(p) == 128; -+ u.b[2] = 129; -+ r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180); -+#if (LZO_ABI_BIG_ENDIAN) -+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081); -+#endif -+#if (LZO_ABI_LITTLE_ENDIAN) -+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180); - #endif --#if defined(LZO_UNALIGNED_OK_4) - u.a[0] = u.a[1] = 0; -- u.b[0] = 3; u.b[sizeof(lzo_uint32) + 1] = 4; -+ u.b[0] = 3; u.b[5] = 4; - p = u2p(&u, 1); -- r &= ((* (lzo_uint32p) p) == 0); -+ r &= UA_GET_NE32(p) == 0; -+ r &= UA_GET_LE32(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE32(p) == 128; -+ u.b[2] = 129; u.b[3] = 130; u.b[4] = 131; -+ r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180); -+#if (LZO_ABI_BIG_ENDIAN) -+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283); - #endif --#if defined(LZO_UNALIGNED_OK_8) -+#if (LZO_ABI_LITTLE_ENDIAN) -+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180); -+#endif -+#if defined(UA_GET_NE64) - u.c[0] = u.c[1] = 0; -- u.b[0] = 5; u.b[sizeof(lzo_uint64) + 1] = 6; -+ u.b[0] = 5; u.b[9] = 6; - p = u2p(&u, 1); -- r &= ((* (lzo_uint64p) p) == 0); --#endif --#if defined(lzo_bitops_clz32) -- { unsigned i; lzo_uint32 v = 1; -- for (i = 0; i < 31; i++, v <<= 1) -- r &= lzo_bitops_clz32(v) == 31 - i; -- } --#endif --#if defined(lzo_bitops_clz64) -- { unsigned i; lzo_uint64 v = 1; -- for (i = 0; i < 63; i++, v <<= 1) -- r &= lzo_bitops_clz64(v) == 63 - i; -- } --#endif --#if defined(lzo_bitops_ctz32) -- { unsigned i; lzo_uint32 v = 1; -- for (i = 0; i < 31; i++, v <<= 1) -- r &= lzo_bitops_ctz32(v) == i; -- } --#endif --#if defined(lzo_bitops_ctz64) -- { unsigned i; lzo_uint64 v = 1; -- for (i = 0; i < 63; i++, v <<= 1) -- r &= lzo_bitops_ctz64(v) == i; -- } --#endif --#endif -+ u.c[0] = u.c[1] = 0; -+ r &= UA_GET_NE64(p) == 0; -+#if defined(UA_GET_LE64) -+ r &= UA_GET_LE64(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE64(p) == 128; -+#endif -+#endif -+#if defined(lzo_bitops_ctlz32) -+ { unsigned i = 0; lzo_uint32_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_ctlz32(v) == 31 - i; -+ r &= lzo_bitops_ctlz32_func(v) == 31 - i; -+ }} -+#endif -+#if defined(lzo_bitops_ctlz64) -+ { unsigned i = 0; lzo_uint64_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_ctlz64(v) == 63 - i; -+ r &= lzo_bitops_ctlz64_func(v) == 63 - i; -+ }} -+#endif -+#if defined(lzo_bitops_cttz32) -+ { unsigned i = 0; lzo_uint32_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_cttz32(v) == i; -+ r &= lzo_bitops_cttz32_func(v) == i; -+ }} -+#endif -+#if defined(lzo_bitops_cttz64) -+ { unsigned i = 0; lzo_uint64_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_cttz64(v) == i; -+ r &= lzo_bitops_cttz64_func(v) == i; -+ }} -+#endif -+#endif -+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); - - return r == 1 ? LZO_E_OK : LZO_E_ERROR; - } -@@ -2724,11 +4242,11 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, - #if defined(__LZO_IN_MINILZO) - #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) - #else --#define ACC_WANT_ACC_CHK_CH 1 --#undef ACCCHK_ASSERT --#define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) -+#define LZO_WANT_ACC_CHK_CH 1 -+#undef LZOCHK_ASSERT -+#define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) - #endif --#undef ACCCHK_ASSERT -+#undef LZOCHK_ASSERT - - if (v == 0) - return LZO_E_ERROR; -@@ -2736,7 +4254,7 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, - r = (s1 == -1 || s1 == (int) sizeof(short)) && - (s2 == -1 || s2 == (int) sizeof(int)) && - (s3 == -1 || s3 == (int) sizeof(long)) && -- (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && -+ (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && - (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && - (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && - (s7 == -1 || s7 == (int) sizeof(char *)) && -@@ -2779,11 +4297,11 @@ int __far __pascal LibMain ( int a, short b, short c, long d ) - - #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) - --#if 1 && defined(UA_GET32) -+#if 1 && defined(UA_GET_LE32) - #undef LZO_DICT_USE_PTR - #define LZO_DICT_USE_PTR 0 - #undef lzo_dict_t --#define lzo_dict_t unsigned short -+#define lzo_dict_t lzo_uint16_t - #endif - - #define LZO_NEED_DICT_H 1 -@@ -3088,77 +4606,7 @@ DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) - #endif - - #if 1 && defined(DO_COMPRESS) && !defined(do_compress) --# define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core) --#endif -- --#if defined(UA_GET64) --# define WANT_lzo_bitops_ctz64 1 --#elif defined(UA_GET32) --# define WANT_lzo_bitops_ctz32 1 --#endif -- --#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) --#include --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 --#pragma intrinsic(_BitScanReverse) --static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanReverse(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz32 lzo_bitops_clz32 --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 --#pragma intrinsic(_BitScanReverse64) --static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanReverse64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz64 lzo_bitops_clz64 --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#pragma intrinsic(_BitScanForward) --static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanForward(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz32 lzo_bitops_ctz32 --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#pragma intrinsic(_BitScanForward64) --static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanForward64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz64 lzo_bitops_ctz64 --#endif -- --#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) --#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) --#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) --#endif -+# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) - #endif - - static __lzo_noinline lzo_uint -@@ -3166,7 +4614,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, - lzo_bytep out, lzo_uintp out_len, - lzo_uint ti, lzo_voidp wrkmem) - { -- register const lzo_bytep ip; -+ const lzo_bytep ip; - lzo_bytep op; - const lzo_bytep const in_end = in + in_len; - const lzo_bytep const ip_end = in + in_len - 20; -@@ -3175,7 +4623,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, - - op = out; - ip = in; -- ii = ip - ti; -+ ii = ip; - - ip += ti < 4 ? 4 - ti : 0; - for (;;) -@@ -3205,8 +4653,8 @@ next: - goto literal; - - try_match: --#if defined(UA_GET32) -- if (UA_GET32(m_pos) != UA_GET32(ip)) -+#if (LZO_OPT_UNALIGNED32) -+ if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) - #else - if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) - #endif -@@ -3221,49 +4669,43 @@ literal: - lzo_uint m_off; - lzo_uint m_len; - { -- lzo_uint32 dv; -+ lzo_uint32_t dv; - lzo_uint dindex; - literal: - ip += 1 + ((ip - ii) >> 5); - next: - if __lzo_unlikely(ip >= ip_end) - break; -- dv = UA_GET32(ip); -+ dv = UA_GET_LE32(ip); - dindex = DINDEX(dv,ip); - GINDEX(m_off,m_pos,in+dict,dindex,in); - UPDATE_I(dict,0,dindex,ip,in); -- if __lzo_unlikely(dv != UA_GET32(m_pos)) -+ if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) - goto literal; - } - #endif - -+ ii -= ti; ti = 0; - { -- register lzo_uint t = pd(ip,ii); -+ lzo_uint t = pd(ip,ii); - if (t != 0) - { - if (t <= 3) - { -- op[-2] |= LZO_BYTE(t); --#if defined(UA_COPY32) -- UA_COPY32(op, ii); -+ op[-2] = LZO_BYTE(op[-2] | t); -+#if (LZO_OPT_UNALIGNED32) -+ UA_COPY4(op, ii); - op += t; - #else - { do *op++ = *ii++; while (--t > 0); } - #endif - } --#if defined(UA_COPY32) || defined(UA_COPY64) -+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) - else if (t <= 16) - { - *op++ = LZO_BYTE(t - 3); --#if defined(UA_COPY64) -- UA_COPY64(op, ii); -- UA_COPY64(op+8, ii+8); --#else -- UA_COPY32(op, ii); -- UA_COPY32(op+4, ii+4); -- UA_COPY32(op+8, ii+8); -- UA_COPY32(op+12, ii+12); --#endif -+ UA_COPY8(op, ii); -+ UA_COPY8(op+8, ii+8); - op += t; - } - #endif -@@ -3273,31 +4715,21 @@ next: - *op++ = LZO_BYTE(t - 3); - else - { -- register lzo_uint tt = t - 18; -+ lzo_uint tt = t - 18; - *op++ = 0; - while __lzo_unlikely(tt > 255) - { - tt -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } --#if defined(UA_COPY32) || defined(UA_COPY64) -+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) - do { --#if defined(UA_COPY64) -- UA_COPY64(op, ii); -- UA_COPY64(op+8, ii+8); --#else -- UA_COPY32(op, ii); -- UA_COPY32(op+4, ii+4); -- UA_COPY32(op+8, ii+8); -- UA_COPY32(op+12, ii+12); --#endif -+ UA_COPY8(op, ii); -+ UA_COPY8(op+8, ii+8); - op += 16; ii += 16; t -= 16; - } while (t >= 16); if (t > 0) - #endif -@@ -3307,19 +4739,26 @@ next: - } - m_len = 4; - { --#if defined(UA_GET64) -- lzo_uint64 v; -- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); -+#if (LZO_OPT_UNALIGNED64) -+ lzo_uint64_t v; -+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); - if __lzo_unlikely(v == 0) { - do { - m_len += 8; -- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); -+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (v == 0); - } --#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64) -- m_len += lzo_bitops_ctz64(v) / CHAR_BIT; -+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) -+ m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; -+#elif (LZO_ABI_BIG_ENDIAN) -+ if ((v >> (64 - CHAR_BIT)) == 0) do { -+ v <<= CHAR_BIT; -+ m_len += 1; -+ } while ((v >> (64 - CHAR_BIT)) == 0); -+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) -+ m_len += lzo_bitops_cttz64(v) / CHAR_BIT; - #elif (LZO_ABI_LITTLE_ENDIAN) - if ((v & UCHAR_MAX) == 0) do { - v >>= CHAR_BIT; -@@ -3330,19 +4769,30 @@ next: - m_len += 1; - } while (ip[m_len] == m_pos[m_len]); - #endif --#elif defined(UA_GET32) -- lzo_uint32 v; -- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); -+#elif (LZO_OPT_UNALIGNED32) -+ lzo_uint32_t v; -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); - if __lzo_unlikely(v == 0) { - do { - m_len += 4; -- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); -+ if (v != 0) -+ break; -+ m_len += 4; -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (v == 0); - } --#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32) -- m_len += lzo_bitops_ctz32(v) / CHAR_BIT; -+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) -+ m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; -+#elif (LZO_ABI_BIG_ENDIAN) -+ if ((v >> (32 - CHAR_BIT)) == 0) do { -+ v <<= CHAR_BIT; -+ m_len += 1; -+ } while ((v >> (32 - CHAR_BIT)) == 0); -+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) -+ m_len += lzo_bitops_cttz32(v) / CHAR_BIT; - #elif (LZO_ABI_LITTLE_ENDIAN) - if ((v & UCHAR_MAX) == 0) do { - v >>= CHAR_BIT; -@@ -3357,6 +4807,27 @@ next: - if __lzo_unlikely(ip[m_len] == m_pos[m_len]) { - do { - m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (ip[m_len] == m_pos[m_len]); -@@ -3390,11 +4861,8 @@ m_len_done: - while __lzo_unlikely(m_len > 255) - { - m_len -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - *op++ = LZO_BYTE(m_len); - } -@@ -3413,11 +4881,8 @@ m_len_done: - while __lzo_unlikely(m_len > 255) - { - m_len -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - *op++ = LZO_BYTE(m_len); - } -@@ -3428,7 +4893,7 @@ m_len_done: - } - - *out_len = pd(op, out); -- return pd(in_end,ii); -+ return pd(in_end,ii-ti); - } - - LZO_PUBLIC(int) -@@ -3468,7 +4933,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - if (op == out && t <= 238) - *op++ = LZO_BYTE(17 + t); - else if (t <= 3) -- op[-2] |= LZO_BYTE(t); -+ op[-2] = LZO_BYTE(op[-2] | t); - else if (t <= 18) - *op++ = LZO_BYTE(t - 3); - else -@@ -3479,17 +4944,14 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - while (tt > 255) - { - tt -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } -- do *op++ = *ii++; while (--t > 0); -+ UA_COPYN(op, ii, t); -+ op += t; - } - - *op++ = M4_MARKER | 1; -@@ -3526,10 +4988,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - - #undef TEST_IP - #undef TEST_OP -+#undef TEST_IP_AND_TEST_OP - #undef TEST_LB - #undef TEST_LBO - #undef NEED_IP - #undef NEED_OP -+#undef TEST_IV -+#undef TEST_OV - #undef HAVE_TEST_IP - #undef HAVE_TEST_OP - #undef HAVE_NEED_IP -@@ -3544,6 +5009,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # if (LZO_TEST_OVERRUN_INPUT >= 2) - # define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun - # endif - #endif - -@@ -3555,12 +5021,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # undef TEST_OP - # define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun - # endif - #endif - - #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) --# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun --# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun -+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun -+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun - #else - # define TEST_LB(m_pos) ((void) 0) - # define TEST_LBO(m_pos,o) ((void) 0) -@@ -3581,15 +5048,27 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # define TEST_OP 1 - #endif - -+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) -+#elif defined(HAVE_TEST_IP) -+# define TEST_IP_AND_TEST_OP TEST_IP -+#elif defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP TEST_OP -+#else -+# define TEST_IP_AND_TEST_OP 1 -+#endif -+ - #if defined(NEED_IP) - # define HAVE_NEED_IP 1 - #else - # define NEED_IP(x) ((void) 0) -+# define TEST_IV(x) ((void) 0) - #endif - #if defined(NEED_OP) - # define HAVE_NEED_OP 1 - #else - # define NEED_OP(x) ((void) 0) -+# define TEST_OV(x) ((void) 0) - #endif - - #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -@@ -3606,14 +5085,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - lzo_voidp wrkmem ) - #endif - { -- register lzo_bytep op; -- register const lzo_bytep ip; -- register lzo_uint t; -+ lzo_bytep op; -+ const lzo_bytep ip; -+ lzo_uint t; - #if defined(COPY_DICT) - lzo_uint m_off; - const lzo_bytep dict_end; - #else -- register const lzo_bytep m_pos; -+ const lzo_bytep m_pos; - #endif - - const lzo_bytep const ip_end = in + in_len; -@@ -3648,43 +5127,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - op = out; - ip = in; - -+ NEED_IP(1); - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; -- assert(t > 0); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); NEED_OP(t); NEED_IP(t+3); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - -- while (TEST_IP && TEST_OP) -+ for (;;) - { -+ NEED_IP(3); - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_IV(t); - NEED_IP(1); - } - t += 15 + *ip++; - } -- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - t += 3; - if (t >= 8) do - { -- UA_COPY64(op,ip); -+ UA_COPY8(op,ip); - op += 8; ip += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } - if (t > 0) -@@ -3692,19 +5173,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - *op++ = *ip++; - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - } --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (PTR_ALIGNED2_4(op,ip)) - { - #endif -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); -@@ -3712,12 +5193,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - else - do *op++ = *ip++; while (--t > 0); - } --#if !defined(LZO_UNALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - } - else - #endif - #endif --#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) -+#if !(LZO_OPT_UNALIGNED32) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); -@@ -3753,7 +5234,7 @@ first_literal_run: - #endif - goto match_done; - -- do { -+ for (;;) { - match: - if (t >= 64) - { -@@ -3813,14 +5294,15 @@ match: - t &= 31; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 31 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -3836,9 +5318,9 @@ match: - m_pos = op - off; - last_m_off = off; - } --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) - m_pos = op - 1; -- m_pos -= UA_GET16(ip) >> 2; -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -@@ -3857,14 +5339,15 @@ match: - t &= 7; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 7 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -3882,8 +5365,8 @@ match: - #else - #if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -- m_pos -= UA_GET16(ip) >> 2; -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); - #endif -@@ -3931,18 +5414,18 @@ match: - #else - - TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - if (op - m_pos >= 8) - { - t += (3 - 1); - if (t >= 8) do - { -- UA_COPY64(op,m_pos); -+ UA_COPY8(op,m_pos); - op += 8; m_pos += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } - if (t > 0) -@@ -3952,8 +5435,8 @@ match: - } - } - else --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -@@ -3961,10 +5444,10 @@ match: - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { - #endif -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); -@@ -3989,7 +5472,7 @@ match_done: - break; - - match_next: -- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); - #if 0 - do *op++ = *ip++; while (--t > 0); - #else -@@ -3997,16 +5480,10 @@ match_next: - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - #endif - t = *ip++; -- } while (TEST_IP && TEST_OP); -+ } - } - --#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) -- *out_len = pd(op, out); -- return LZO_E_EOF_NOT_FOUND; --#endif -- - eof_found: -- assert(t == 1); - *out_len = pd(op, out); - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -@@ -4052,10 +5529,13 @@ lookbehind_overrun: - - #undef TEST_IP - #undef TEST_OP -+#undef TEST_IP_AND_TEST_OP - #undef TEST_LB - #undef TEST_LBO - #undef NEED_IP - #undef NEED_OP -+#undef TEST_IV -+#undef TEST_OV - #undef HAVE_TEST_IP - #undef HAVE_TEST_OP - #undef HAVE_NEED_IP -@@ -4070,6 +5550,7 @@ lookbehind_overrun: - # if (LZO_TEST_OVERRUN_INPUT >= 2) - # define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun - # endif - #endif - -@@ -4081,12 +5562,13 @@ lookbehind_overrun: - # undef TEST_OP - # define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun - # endif - #endif - - #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) --# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun --# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun -+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun -+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun - #else - # define TEST_LB(m_pos) ((void) 0) - # define TEST_LBO(m_pos,o) ((void) 0) -@@ -4107,15 +5589,27 @@ lookbehind_overrun: - # define TEST_OP 1 - #endif - -+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) -+#elif defined(HAVE_TEST_IP) -+# define TEST_IP_AND_TEST_OP TEST_IP -+#elif defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP TEST_OP -+#else -+# define TEST_IP_AND_TEST_OP 1 -+#endif -+ - #if defined(NEED_IP) - # define HAVE_NEED_IP 1 - #else - # define NEED_IP(x) ((void) 0) -+# define TEST_IV(x) ((void) 0) - #endif - #if defined(NEED_OP) - # define HAVE_NEED_OP 1 - #else - # define NEED_OP(x) ((void) 0) -+# define TEST_OV(x) ((void) 0) - #endif - - #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -@@ -4132,14 +5626,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - lzo_voidp wrkmem ) - #endif - { -- register lzo_bytep op; -- register const lzo_bytep ip; -- register lzo_uint t; -+ lzo_bytep op; -+ const lzo_bytep ip; -+ lzo_uint t; - #if defined(COPY_DICT) - lzo_uint m_off; - const lzo_bytep dict_end; - #else -- register const lzo_bytep m_pos; -+ const lzo_bytep m_pos; - #endif - - const lzo_bytep const ip_end = in + in_len; -@@ -4174,43 +5668,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - op = out; - ip = in; - -+ NEED_IP(1); - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; -- assert(t > 0); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); NEED_OP(t); NEED_IP(t+3); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - -- while (TEST_IP && TEST_OP) -+ for (;;) - { -+ NEED_IP(3); - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_IV(t); - NEED_IP(1); - } - t += 15 + *ip++; - } -- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - t += 3; - if (t >= 8) do - { -- UA_COPY64(op,ip); -+ UA_COPY8(op,ip); - op += 8; ip += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } - if (t > 0) -@@ -4218,19 +5714,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - *op++ = *ip++; - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - } --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (PTR_ALIGNED2_4(op,ip)) - { - #endif -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); -@@ -4238,12 +5734,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - else - do *op++ = *ip++; while (--t > 0); - } --#if !defined(LZO_UNALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - } - else - #endif - #endif --#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) -+#if !(LZO_OPT_UNALIGNED32) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); -@@ -4279,7 +5775,7 @@ first_literal_run: - #endif - goto match_done; - -- do { -+ for (;;) { - match: - if (t >= 64) - { -@@ -4339,14 +5835,15 @@ match: - t &= 31; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 31 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -4362,9 +5859,9 @@ match: - m_pos = op - off; - last_m_off = off; - } --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) - m_pos = op - 1; -- m_pos -= UA_GET16(ip) >> 2; -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -@@ -4383,14 +5880,15 @@ match: - t &= 7; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 7 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -4408,8 +5906,8 @@ match: - #else - #if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -- m_pos -= UA_GET16(ip) >> 2; -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); - #endif -@@ -4457,18 +5955,18 @@ match: - #else - - TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - if (op - m_pos >= 8) - { - t += (3 - 1); - if (t >= 8) do - { -- UA_COPY64(op,m_pos); -+ UA_COPY8(op,m_pos); - op += 8; m_pos += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } - if (t > 0) -@@ -4478,8 +5976,8 @@ match: - } - } - else --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -@@ -4487,10 +5985,10 @@ match: - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { - #endif -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); -@@ -4515,7 +6013,7 @@ match_done: - break; - - match_next: -- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); - #if 0 - do *op++ = *ip++; while (--t > 0); - #else -@@ -4523,16 +6021,10 @@ match_next: - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - #endif - t = *ip++; -- } while (TEST_IP && TEST_OP); -+ } - } - --#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) -- *out_len = pd(op, out); -- return LZO_E_EOF_NOT_FOUND; --#endif -- - eof_found: -- assert(t == 1); - *out_len = pd(op, out); - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -@@ -4559,4 +6051,3 @@ lookbehind_overrun: - #endif - - /***** End of minilzo.c *****/ -- -diff --git a/grub-core/lib/minilzo/minilzo.h b/grub-core/lib/minilzo/minilzo.h -index 74fefa9..7937454 100644 ---- a/grub-core/lib/minilzo/minilzo.h -+++ b/grub-core/lib/minilzo/minilzo.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -50,7 +35,7 @@ - #ifndef __MINILZO_H - #define __MINILZO_H 1 - --#define MINILZO_VERSION 0x2050 -+#define MINILZO_VERSION 0x2080 - - #ifdef __LZOCONF_H - # error "you cannot use both LZO and miniLZO" -@@ -78,7 +63,7 @@ extern "C" { - */ - - #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS --#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -+#define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) - #define LZO1X_MEM_DECOMPRESS (0) - - --- -2.9.3 - diff --git a/0008-Add-vlan-tag-support-on-IBM-PPC-machines.patch b/0008-Add-vlan-tag-support-on-IBM-PPC-machines.patch deleted file mode 100644 index 05af50c..0000000 --- a/0008-Add-vlan-tag-support-on-IBM-PPC-machines.patch +++ /dev/null @@ -1,186 +0,0 @@ -From de423b22780b0fd225a1ee476166777af29d53d0 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Tue, 30 Oct 2012 15:19:39 -0200 -Subject: [PATCH 08/90] Add vlan-tag support on IBM PPC machines - -This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows -multiple VLANs in a bridged network to share the same physical network link but -maintain isolation: - -http://en.wikipedia.org/wiki/IEEE_802.1Q - -This patch should fix this bugzilla: -https://bugzilla.redhat.com/show_bug.cgi?id=871563 ---- - grub-core/kern/ieee1275/init.c | 1 + - grub-core/kern/ieee1275/openfw.c | 30 ++++++++++++++++++++++++++++ - grub-core/net/ethernet.c | 42 +++++++++++++++++++++++++++++++++++++--- - include/grub/ieee1275/ieee1275.h | 1 + - include/grub/net.h | 2 ++ - 5 files changed, 73 insertions(+), 3 deletions(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 1259022..5fa26e1 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -125,6 +125,7 @@ grub_machine_get_bootlocation (char **device, char **path) - char *dev, *canon; - char *ptr; - dev = grub_ieee1275_get_aliasdevname (bootpath); -+ grub_ieee1275_parse_net_options (bootpath); - canon = grub_ieee1275_canonicalise_devname (dev); - ptr = canon + grub_strlen (canon) - 1; - while (ptr > canon && (*ptr == ',' || *ptr == ':')) -diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index 6db8b98..81276fa 100644 ---- a/grub-core/kern/ieee1275/openfw.c -+++ b/grub-core/kern/ieee1275/openfw.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - enum grub_ieee1275_parse_type - { -@@ -451,6 +452,35 @@ fail: - return ret; - } - -+int -+grub_ieee1275_parse_net_options (const char *path) -+{ -+ char *comma; -+ char *args; -+ char *option = 0; -+ -+ args = grub_ieee1275_get_devargs (path); -+ if (!args) -+ /* There is no option. */ -+ return -1; -+ -+ do -+ { -+ comma = grub_strchr (args, ','); -+ if (! comma) -+ option = grub_strdup (args); -+ else -+ option = grub_strndup (args, (grub_size_t)(comma - args)); -+ args = comma + 1; -+ -+ if (! grub_strncmp(option, "vtag", 4)) -+ grub_env_set ("vlan-tag", option + grub_strlen("vtag=")); -+ -+ } while (comma); -+ -+ return 0; -+} -+ - char * - grub_ieee1275_get_device_type (const char *path) - { -diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c -index c397b1b..faaca67 100644 ---- a/grub-core/net/ethernet.c -+++ b/grub-core/net/ethernet.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -56,10 +57,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, - { - struct etherhdr *eth; - grub_err_t err; -+ grub_uint32_t vlantag = 0; -+ grub_uint8_t etherhdr_size; - -- COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE); -+ etherhdr_size = sizeof (*eth); -+ COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE); - -- err = grub_netbuff_push (nb, sizeof (*eth)); -+ const char *vlantag_text = grub_env_get ("vlan-tag"); -+ if (vlantag_text != 0) { -+ etherhdr_size += 4; -+ vlantag = grub_strtoul (vlantag_text, 0, 16); -+ } -+ -+ err = grub_netbuff_push (nb, etherhdr_size); - if (err) - return err; - eth = (struct etherhdr *) nb->data; -@@ -76,6 +86,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, - return err; - inf->card->opened = 1; - } -+ -+ /* Check if a vlan-tag is needed. */ -+ if (vlantag != 0) -+ { -+ /* Move eth type to the right */ -+ grub_memcpy((char *) nb->data + etherhdr_size - 2, -+ (char *) nb->data + etherhdr_size - 6, 2); -+ -+ /* Add the tag in the middle */ -+ grub_memcpy((char *) nb->data + etherhdr_size - 6, -+ &vlantag, 4); -+ } -+ - return inf->card->driver->send (inf->card, nb); - } - -@@ -90,10 +113,23 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, - grub_net_link_level_address_t hwaddress; - grub_net_link_level_address_t src_hwaddress; - grub_err_t err; -+ grub_uint8_t etherhdr_size = sizeof (*eth); -+ -+ grub_uint16_t vlantag_identifier = 0; -+ grub_memcpy (&vlantag_identifier, nb->data + etherhdr_size - 2, 2); -+ -+ /* Check if a vlan-tag is present. */ -+ if (vlantag_identifier == VLANTAG_IDENTIFIER) -+ { -+ etherhdr_size += 4; -+ /* Move eth type to the original position */ -+ grub_memcpy((char *) nb->data + etherhdr_size - 6, -+ (char *) nb->data + etherhdr_size - 2, 2); -+ } - - eth = (struct etherhdr *) nb->data; - type = grub_be_to_cpu16 (eth->type); -- err = grub_netbuff_pull (nb, sizeof (*eth)); -+ err = grub_netbuff_pull (nb, etherhdr_size); - if (err) - return err; - -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index ab4f284..663935d 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -238,6 +238,7 @@ void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, - struct grub_ieee1275_devalias *alias); - int EXPORT_FUNC(grub_ieee1275_cas_reboot) (char *script); - int EXPORT_FUNC(grub_ieee1275_set_boot_last_label) (const char *text); -+int EXPORT_FUNC(grub_ieee1275_parse_net_options) (const char *path); - - #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) - -diff --git a/include/grub/net.h b/include/grub/net.h -index 2192fa1..6ac9d72 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -561,4 +561,6 @@ extern char *grub_net_default_server; - #define GRUB_NET_INTERVAL 400 - #define GRUB_NET_INTERVAL_ADDITION 20 - -+#define VLANTAG_IDENTIFIER 0x8100 -+ - #endif /* ! GRUB_NET_HEADER */ --- -2.9.3 - diff --git a/0008-Remove-the-variable-oldname-which-is-attempting-to-f.patch b/0008-Remove-the-variable-oldname-which-is-attempting-to-f.patch new file mode 100644 index 0000000..92127af --- /dev/null +++ b/0008-Remove-the-variable-oldname-which-is-attempting-to-f.patch @@ -0,0 +1,45 @@ +From 76eac44af37358fb14f437a7878119e6d34e8d7f Mon Sep 17 00:00:00 2001 +From: Aaron Luft +Date: Mon, 14 Mar 2016 16:48:33 -0400 +Subject: [PATCH 008/123] Remove the variable oldname which is attempting to + free stack space. + +Historically this variable hold previous value of filename that +had to be freed if allocated previously. Currently this branch +is entered only if filename was not allocated previously so it +became redundant. It did not cause real problems because grub_free +was not called, but code is confusing and causes compilation error +in some cases. +--- + grub-core/fs/iso9660.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c +index 67a67cf40..c9c8374bf 100644 +--- a/grub-core/fs/iso9660.c ++++ b/grub-core/fs/iso9660.c +@@ -750,19 +750,15 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, + + if (dir->data->joliet && !ctx.filename) + { +- char *oldname, *semicolon; ++ char *semicolon; + +- oldname = name; + ctx.filename = grub_iso9660_convert_string +- ((grub_uint8_t *) oldname, dirent.namelen >> 1); ++ ((grub_uint8_t *) name, dirent.namelen >> 1); + + semicolon = grub_strrchr (ctx.filename, ';'); + if (semicolon) + *semicolon = '\0'; + +- if (ctx.filename_alloc) +- grub_free (oldname); +- + ctx.filename_alloc = 1; + } + +-- +2.14.3 + diff --git a/0009-Allow-fallback-to-include-entries-by-title-not-just-.patch b/0009-Allow-fallback-to-include-entries-by-title-not-just-.patch deleted file mode 100644 index 37f85f1..0000000 --- a/0009-Allow-fallback-to-include-entries-by-title-not-just-.patch +++ /dev/null @@ -1,144 +0,0 @@ -From 196ae5abd961cd64b60d9ab41bfc02d340e8bb6f Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 5 Sep 2014 10:07:04 -0400 -Subject: [PATCH 09/90] Allow "fallback" to include entries by title, not just - number. - -Resolves: rhbz#1026084 - -Signed-off-by: Peter Jones ---- - grub-core/normal/menu.c | 85 +++++++++++++++++++++++++++++++++---------------- - 1 file changed, 58 insertions(+), 27 deletions(-) - -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 719e2fb..2e8a7bd 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -163,16 +163,41 @@ grub_menu_set_timeout (int timeout) - } - } - -+static int -+menuentry_eq (const char *id, const char *spec) -+{ -+ const char *ptr1, *ptr2; -+ ptr1 = id; -+ ptr2 = spec; -+ while (1) -+ { -+ if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0) -+ return ptr2 - spec; -+ if (*ptr2 == '>' && ptr2[1] != '>') -+ return 0; -+ if (*ptr2 == '>') -+ ptr2++; -+ if (*ptr1 != *ptr2) -+ return 0; -+ if (*ptr1 == 0) -+ return ptr1 - id; -+ ptr1++; -+ ptr2++; -+ } -+ return 0; -+} -+ - /* Get the first entry number from the value of the environment variable NAME, - which is a space-separated list of non-negative integers. The entry number - which is returned is stripped from the value of NAME. If no entry number - can be found, -1 is returned. */ - static int --get_and_remove_first_entry_number (const char *name) -+get_and_remove_first_entry_number (grub_menu_t menu, const char *name) - { - const char *val; - char *tail; - int entry; -+ int sz = 0; - - val = grub_env_get (name); - if (! val) -@@ -182,9 +207,39 @@ get_and_remove_first_entry_number (const char *name) - - entry = (int) grub_strtoul (val, &tail, 0); - -+ if (grub_errno == GRUB_ERR_BAD_NUMBER) -+ { -+ /* See if the variable matches the title of a menu entry. */ -+ grub_menu_entry_t e = menu->entry_list; -+ int i; -+ -+ for (i = 0; e; i++) -+ { -+ sz = menuentry_eq (e->title, val); -+ if (sz < 1) -+ sz = menuentry_eq (e->id, val); -+ -+ if (sz >= 1) -+ { -+ entry = i; -+ break; -+ } -+ e = e->next; -+ } -+ -+ if (sz > 0) -+ grub_errno = GRUB_ERR_NONE; -+ -+ if (! e) -+ entry = -1; -+ } -+ - if (grub_errno == GRUB_ERR_NONE) - { -- /* Skip whitespace to find the next digit. */ -+ if (sz > 0) -+ tail += sz; -+ -+ /* Skip whitespace to find the next entry. */ - while (*tail && grub_isspace (*tail)) - tail++; - grub_env_set (name, tail); -@@ -347,7 +402,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu, - grub_menu_execute_entry (entry, 1); - - /* Deal with fallback entries. */ -- while ((fallback_entry = get_and_remove_first_entry_number ("fallback")) -+ while ((fallback_entry = get_and_remove_first_entry_number (menu, "fallback")) - >= 0) - { - grub_print_error (); -@@ -465,30 +520,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer) - viewers = viewer; - } - --static int --menuentry_eq (const char *id, const char *spec) --{ -- const char *ptr1, *ptr2; -- ptr1 = id; -- ptr2 = spec; -- while (1) -- { -- if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0) -- return 1; -- if (*ptr2 == '>' && ptr2[1] != '>') -- return 0; -- if (*ptr2 == '>') -- ptr2++; -- if (*ptr1 != *ptr2) -- return 0; -- if (*ptr1 == 0) -- return 1; -- ptr1++; -- ptr2++; -- } --} -- -- - /* Get the entry number from the variable NAME. */ - static int - get_entry_number (grub_menu_t menu, const char *name) --- -2.9.3 - diff --git a/0009-bootp-fix-memory-leak-in-grub_cmd_dhcpopt.patch b/0009-bootp-fix-memory-leak-in-grub_cmd_dhcpopt.patch new file mode 100644 index 0000000..101b618 --- /dev/null +++ b/0009-bootp-fix-memory-leak-in-grub_cmd_dhcpopt.patch @@ -0,0 +1,56 @@ +From 5b8ddf6e03bbc780d6902b1d9c1e3aa6361c9cc3 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Sat, 19 Mar 2016 09:39:30 +0300 +Subject: [PATCH 009/123] bootp: fix memory leak in grub_cmd_dhcpopt + +--- + grub-core/net/bootp.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c +index a088244b4..09c6f7606 100644 +--- a/grub-core/net/bootp.c ++++ b/grub-core/net/bootp.c +@@ -368,6 +368,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), + + if (grub_strcmp (args[3], "string") == 0) + { ++ grub_err_t err = GRUB_ERR_NONE; + char *val = grub_malloc (taglength + 1); + if (!val) + return grub_errno; +@@ -376,8 +377,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), + if (args[0][0] == '-' && args[0][1] == 0) + grub_printf ("%s\n", val); + else +- return grub_env_set (args[0], val); +- return GRUB_ERR_NONE; ++ err = grub_env_set (args[0], val); ++ grub_free (val); ++ return err; + } + + if (grub_strcmp (args[3], "number") == 0) +@@ -399,6 +401,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), + + if (grub_strcmp (args[3], "hex") == 0) + { ++ grub_err_t err = GRUB_ERR_NONE; + char *val = grub_malloc (2 * taglength + 1); + int i; + if (!val) +@@ -412,8 +415,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), + if (args[0][0] == '-' && args[0][1] == 0) + grub_printf ("%s\n", val); + else +- return grub_env_set (args[0], val); +- return GRUB_ERR_NONE; ++ err = grub_env_set (args[0], val); ++ grub_free (val); ++ return err; + } + + return grub_error (GRUB_ERR_BAD_ARGUMENT, +-- +2.14.3 + diff --git a/0010-Add-GRUB_DISABLE_UUID.patch b/0010-Add-GRUB_DISABLE_UUID.patch deleted file mode 100644 index 6bd4ca7..0000000 --- a/0010-Add-GRUB_DISABLE_UUID.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 8f405e93871ad51cd9ab4dfdea844042a33fa7f0 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 4 Sep 2014 16:49:25 -0400 -Subject: [PATCH 10/90] Add GRUB_DISABLE_UUID. - -This will cause "search --fs-uuid --set=root ..." not to be generated by -grub2-mkconfig, and instead simply attempt to use the grub device name -as it understands it. - -Signed-off-by: Peter Jones ---- - docs/grub.texi | 7 +++++++ - util/grub-mkconfig.in | 12 ++++++++++-- - util/grub-mkconfig_lib.in | 4 ++-- - 3 files changed, 19 insertions(+), 4 deletions(-) - -diff --git a/docs/grub.texi b/docs/grub.texi -index 82f6fa4..98d4d0d 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -1409,6 +1409,13 @@ disable the use of UUIDs, set this option to @samp{true}. - If this option is set to @samp{true}, disable the generation of recovery - mode menu entries. - -+@item GRUB_DISABLE_UUID -+Normally, @command{grub-mkconfig} will generate menu entries that use -+universally-unique identifiers (UUIDs) to identify various filesystems to -+search for files. This is usually more reliable, but in some cases it may -+not be appropriate. To disable this use of UUIDs, set this option to -+@samp{true}. -+ - @item GRUB_VIDEO_BACKEND - If graphical video support is required, either because the @samp{gfxterm} - graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set, -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 3b070fd..c088b70 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -133,11 +133,11 @@ fi - - # Device containing our userland. Typically used for root= parameter. - GRUB_DEVICE="`${grub_probe} --target=device /`" --GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true -+GRUB_DEVICE_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true - - # Device containing our /boot partition. Usually the same as GRUB_DEVICE. - GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" --GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true -+GRUB_DEVICE_BOOT_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true - - # Filesystem for the device containing our userland. Used for stuff like - # choosing Hurd filesystem module. -@@ -151,6 +151,13 @@ if test -f ${sysconfdir}/default/grub ; then - . ${sysconfdir}/default/grub - fi - -+if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_UUID" ]; then -+ GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" -+fi -+if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_BOOT_UUID" ]; then -+ GRUB_DEVICE_BOOT_UUID="$GRUB_DEVICE_BOOT_UUID_GENERATED" -+fi -+ - # XXX: should this be deprecated at some point? - if [ "x${GRUB_TERMINAL}" != "x" ] ; then - GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}" -@@ -216,6 +223,7 @@ export GRUB_DEFAULT \ - GRUB_SERIAL_COMMAND \ - GRUB_DISABLE_LINUX_UUID \ - GRUB_DISABLE_RECOVERY \ -+ GRUB_DISABLE_UUID \ - GRUB_VIDEO_BACKEND \ - GRUB_GFXMODE \ - GRUB_BACKGROUND \ -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 60b31ca..cf35e41 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -156,7 +156,7 @@ prepare_grub_to_access_device () - if [ "x$fs_hint" != x ]; then - echo "set root='$fs_hint'" - fi -- if fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then -+ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then - hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= - echo "if [ x\$feature_platform_search_hint = xy ]; then" - echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" -@@ -173,7 +173,7 @@ grub_get_device_id () - IFS=' - ' - device="$1" -- if fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then -+ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then - echo "$fs_uuid"; - else - echo $device |sed 's, ,_,g' --- -2.9.3 - diff --git a/0010-bootp-check-that-interface-is-not-NULL-in-configure_.patch b/0010-bootp-check-that-interface-is-not-NULL-in-configure_.patch new file mode 100644 index 0000000..a674872 --- /dev/null +++ b/0010-bootp-check-that-interface-is-not-NULL-in-configure_.patch @@ -0,0 +1,29 @@ +From 6714d7ecffe58021760e4d1ebfa9cc3473f7fb24 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Sun, 20 Mar 2016 10:32:33 +0300 +Subject: [PATCH 010/123] bootp: check that interface is not NULL in + configure_by_dhcp_ack + +grub_net_add_addr may fail with OOM and we use returned interface +later without any checks. +--- + grub-core/net/bootp.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c +index 09c6f7606..189551a48 100644 +--- a/grub-core/net/bootp.c ++++ b/grub-core/net/bootp.c +@@ -157,6 +157,9 @@ grub_net_configure_by_dhcp_ack (const char *name, + hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + + inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags); ++ if (!inter) ++ return 0; ++ + #if 0 + /* This is likely based on misunderstanding. gateway_ip refers to + address of BOOTP relay and should not be used after BOOTP transaction +-- +2.14.3 + diff --git a/0011-Make-exit-take-a-return-code.patch b/0011-Make-exit-take-a-return-code.patch deleted file mode 100644 index 1bae1cd..0000000 --- a/0011-Make-exit-take-a-return-code.patch +++ /dev/null @@ -1,259 +0,0 @@ -From 6879936079d17ace35cebcab787f7fb9f8cd205e Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 26 Feb 2014 21:49:12 -0500 -Subject: [PATCH 11/90] Make "exit" take a return code. - -This adds "exit" with a return code. With this patch, any "exit" -command /may/ include a return code, and on platforms that support -returning with an exit status, we will do so. By default we return the -same exit status we did before this patch. - -Signed-off-by: Peter Jones ---- - grub-core/commands/minicmd.c | 20 ++++++++++++++++---- - grub-core/kern/efi/efi.c | 9 +++++++-- - grub-core/kern/emu/main.c | 2 +- - grub-core/kern/emu/misc.c | 5 +++-- - grub-core/kern/i386/coreboot/init.c | 2 +- - grub-core/kern/i386/qemu/init.c | 2 +- - grub-core/kern/ieee1275/init.c | 2 +- - grub-core/kern/mips/arc/init.c | 2 +- - grub-core/kern/mips/loongson/init.c | 2 +- - grub-core/kern/mips/qemu_mips/init.c | 2 +- - grub-core/kern/misc.c | 2 +- - grub-core/kern/uboot/init.c | 6 +++--- - grub-core/kern/xen/init.c | 2 +- - include/grub/misc.h | 2 +- - 14 files changed, 39 insertions(+), 21 deletions(-) - -diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c -index a3a1182..b25ca4b 100644 ---- a/grub-core/commands/minicmd.c -+++ b/grub-core/commands/minicmd.c -@@ -176,12 +176,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), - } - - /* exit */ --static grub_err_t __attribute__ ((noreturn)) -+static grub_err_t - grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)), -- int argc __attribute__ ((unused)), -- char *argv[] __attribute__ ((unused))) -+ int argc, char *argv[]) - { -- grub_exit (); -+ int retval = -1; -+ unsigned long n; -+ -+ if (argc < 0 || argc > 1) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); -+ -+ if (argc == 1) -+ { -+ n = grub_strtoul (argv[0], 0, 10); -+ if (n != ~0UL) -+ retval = n; -+ } -+ -+ grub_exit (retval); - /* Not reached. */ - } - -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index caf9bcc..101307f 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -155,11 +155,16 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) - } - - void --grub_exit (void) -+grub_exit (int retval) - { -+ int rc = GRUB_EFI_LOAD_ERROR; -+ -+ if (retval == 0) -+ rc = GRUB_EFI_SUCCESS; -+ - grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); - efi_call_4 (grub_efi_system_table->boot_services->exit, -- grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0); -+ grub_efi_image_handle, rc, 0, 0); - for (;;) ; - } - -diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index f91280f..34634d3 100644 ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -66,7 +66,7 @@ grub_reboot (void) - } - - void --grub_exit (void) -+grub_exit (int retval __attribute__((unused))) - { - grub_reboot (); - } -diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index d361feb..331fa62 100644 ---- a/grub-core/kern/emu/misc.c -+++ b/grub-core/kern/emu/misc.c -@@ -136,9 +136,10 @@ xasprintf (const char *fmt, ...) - - #if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) - void --grub_exit (void) -+__attribute__ ((noreturn)) -+grub_exit (int rc) - { -- exit (1); -+ exit (rc < 0 ? 1 : rc); - } - #endif - -diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c -index 3314f02..36f9134 100644 ---- a/grub-core/kern/i386/coreboot/init.c -+++ b/grub-core/kern/i386/coreboot/init.c -@@ -41,7 +41,7 @@ extern grub_uint8_t _end[]; - extern grub_uint8_t _edata[]; - - void __attribute__ ((noreturn)) --grub_exit (void) -+grub_exit (int rc __attribute__((unused))) - { - /* We can't use grub_fatal() in this function. This would create an infinite - loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ -diff --git a/grub-core/kern/i386/qemu/init.c b/grub-core/kern/i386/qemu/init.c -index 271b6fb..9fafe98 100644 ---- a/grub-core/kern/i386/qemu/init.c -+++ b/grub-core/kern/i386/qemu/init.c -@@ -42,7 +42,7 @@ extern grub_uint8_t _end[]; - extern grub_uint8_t _edata[]; - - void __attribute__ ((noreturn)) --grub_exit (void) -+grub_exit (int rc __attribute__((unused))) - { - /* We can't use grub_fatal() in this function. This would create an infinite - loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 5fa26e1..8a3ecd5 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -68,7 +68,7 @@ grub_addr_t grub_ieee1275_original_stack; - #endif - - void --grub_exit (void) -+grub_exit (int rc __attribute__((unused))) - { - grub_ieee1275_exit (); - } -diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c -index 3834a14..86b3a25 100644 ---- a/grub-core/kern/mips/arc/init.c -+++ b/grub-core/kern/mips/arc/init.c -@@ -276,7 +276,7 @@ grub_halt (void) - } - - void --grub_exit (void) -+grub_exit (int rc __attribute__((unused))) - { - GRUB_ARC_FIRMWARE_VECTOR->exit (); - -diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c -index 7b96531..dff598c 100644 ---- a/grub-core/kern/mips/loongson/init.c -+++ b/grub-core/kern/mips/loongson/init.c -@@ -304,7 +304,7 @@ grub_halt (void) - } - - void --grub_exit (void) -+grub_exit (int rc __attribute__((unused))) - { - grub_halt (); - } -diff --git a/grub-core/kern/mips/qemu_mips/init.c b/grub-core/kern/mips/qemu_mips/init.c -index be88b77..8b6c55f 100644 ---- a/grub-core/kern/mips/qemu_mips/init.c -+++ b/grub-core/kern/mips/qemu_mips/init.c -@@ -75,7 +75,7 @@ grub_machine_fini (int flags __attribute__ ((unused))) - } - - void --grub_exit (void) -+grub_exit (int rc __attribute__((unused))) - { - grub_halt (); - } -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index d1a54df..6bb0351 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -1094,7 +1094,7 @@ grub_abort (void) - grub_getkey (); - } - -- grub_exit (); -+ grub_exit (1); - } - - void -diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c -index 5dcc106..430c62b 100644 ---- a/grub-core/kern/uboot/init.c -+++ b/grub-core/kern/uboot/init.c -@@ -43,9 +43,9 @@ extern grub_uint32_t grub_uboot_machine_type; - extern grub_addr_t grub_uboot_boot_data; - - void --grub_exit (void) -+grub_exit (int rc) - { -- grub_uboot_return (0); -+ grub_uboot_return (rc < 0 ? 1 : rc); - } - - grub_uint32_t -@@ -94,7 +94,7 @@ grub_machine_init (void) - if (!ver) - { - /* Don't even have a console to log errors to... */ -- grub_exit (); -+ grub_exit (-1); - } - else if (ver > API_SIG_VERSION) - { -diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c -index 0559c03..fce526d 100644 ---- a/grub-core/kern/xen/init.c -+++ b/grub-core/kern/xen/init.c -@@ -549,7 +549,7 @@ grub_machine_init (void) - } - - void --grub_exit (void) -+grub_exit (int rc __attribute__((unused))) - { - struct sched_shutdown arg; - -diff --git a/include/grub/misc.h b/include/grub/misc.h -index 2a9f87c..0620814 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -334,7 +334,7 @@ int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt, - char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) - __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT; - char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT; --void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); -+void EXPORT_FUNC(grub_exit) (int rc) __attribute__ ((noreturn)); - grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, - grub_uint64_t d, - grub_uint64_t *r); --- -2.9.3 - diff --git a/0011-configure-set-fno-pie-together-with-fno-PIE.patch b/0011-configure-set-fno-pie-together-with-fno-PIE.patch new file mode 100644 index 0000000..1d3ab98 --- /dev/null +++ b/0011-configure-set-fno-pie-together-with-fno-PIE.patch @@ -0,0 +1,39 @@ +From f4d35d49e32c29183b3492da18ea480d91716efe Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Tue, 22 Mar 2016 20:12:22 +0300 +Subject: [PATCH 011/123] configure: set -fno-pie together with -fno-PIE + +OpenBSD 5.9 apparently defaults to -fpie. We use -fno-PIE when appropriate +already, but that is not enough - it does not turn off -fpie. + +Actually check for -fPIE is not precise enough. __PIE__ is set for both +-fpie and -fPIE but with different values. As far as I can tell, both +options were introduced at the same time, so both should always be supported. + +This fixes compilation on OpenBSD 5.9 which otherwise created insanely big +lzma_decompress.img. + +Reported, suggested and tested by: Jiri B +--- + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index a85b134ec..57e17138e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1185,9 +1185,9 @@ CFLAGS="$TARGET_CFLAGS" + # Position independent executable. + grub_CHECK_PIE + [# Need that, because some distributions ship compilers that include +-# `-fPIE' in the default specs. ++# `-fPIE' or '-fpie' in the default specs. + if [ x"$pie_possible" = xyes ]; then +- TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" ++ TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie" + fi] + + CFLAGS="$TARGET_CFLAGS" +-- +2.14.3 + diff --git a/0012-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch b/0012-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch deleted file mode 100644 index e947704..0000000 --- a/0012-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch +++ /dev/null @@ -1,22 +0,0 @@ -From ef756db92dd4f47ed4bb4aede86d33326b0b9188 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 22 Jul 2015 11:21:01 -0400 -Subject: [PATCH 12/90] Mark po/exclude.pot as binary so git won't try to diff - nonprintables. - -Signed-off-by: Peter Jones ---- - .gitattributes | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 .gitattributes - -diff --git a/.gitattributes b/.gitattributes -new file mode 100644 -index 0000000..33ffaa4 ---- /dev/null -+++ b/.gitattributes -@@ -0,0 +1 @@ -+po/exclude.pot binary --- -2.9.3 - diff --git a/0012-http-fix-superfluous-null-line-in-range-request-head.patch b/0012-http-fix-superfluous-null-line-in-range-request-head.patch new file mode 100644 index 0000000..6648981 --- /dev/null +++ b/0012-http-fix-superfluous-null-line-in-range-request-head.patch @@ -0,0 +1,31 @@ +From abf9beb7d667d3604774753cf698c439c6fbc736 Mon Sep 17 00:00:00 2001 +From: Michael Chang +Date: Wed, 6 Apr 2016 18:19:14 +0800 +Subject: [PATCH 012/123] http: fix superfluous null line in range request + header + +At least the apache sever is very unhappy with that extra null line and will +take more than ten seconds in responding to each range request, which slows +down a lot the entire http file transfer process or even time out. +--- + grub-core/net/http.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/grub-core/net/http.c b/grub-core/net/http.c +index 4684f8b33..a7c5101a1 100644 +--- a/grub-core/net/http.c ++++ b/grub-core/net/http.c +@@ -381,9 +381,8 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) + ptr = nb->tail; + grub_snprintf ((char *) ptr, + sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX-" +- "\r\n" + "\r\n"), +- "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n\r\n", ++ "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n", + offset); + grub_netbuff_put (nb, grub_strlen ((char *) ptr)); + } +-- +2.14.3 + diff --git a/0013-Make-efi-machines-load-an-env-block-from-a-variable.patch b/0013-Make-efi-machines-load-an-env-block-from-a-variable.patch deleted file mode 100644 index cf4e42d..0000000 --- a/0013-Make-efi-machines-load-an-env-block-from-a-variable.patch +++ /dev/null @@ -1,84 +0,0 @@ -From e14c5369fea76d1e067ca9f7e5e55bfe615cb639 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 7 Dec 2015 14:20:49 -0500 -Subject: [PATCH 13/90] Make efi machines load an env block from a variable - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 1 + - grub-core/kern/efi/init.c | 34 +++++++++++++++++++++++++++++++++- - 2 files changed, 34 insertions(+), 1 deletion(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 58b4208..f8d4634 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -173,6 +173,7 @@ kernel = { - efi = term/efi/console.c; - efi = kern/acpi.c; - efi = kern/efi/acpi.c; -+ efi = lib/envblk.c; - i386_coreboot = kern/i386/pc/acpi.c; - i386_multiboot = kern/i386/pc/acpi.c; - i386_coreboot = kern/acpi.c; -diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index e9c85de..a5b6c1d 100644 ---- a/grub-core/kern/efi/init.c -+++ b/grub-core/kern/efi/init.c -@@ -25,9 +25,40 @@ - #include - #include - #include -+#include - - grub_addr_t grub_modbase; - -+#define GRUB_EFI_GRUB_VARIABLE_GUID \ -+ { 0x91376aff, 0xcba6, 0x42be, \ -+ { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \ -+ } -+ -+/* Helper for grub_efi_env_init */ -+static int -+set_var (const char *name, const char *value, -+ void *whitelist __attribute__((__unused__))) -+{ -+ grub_env_set (name, value); -+ return 0; -+} -+ -+static void -+grub_efi_env_init (void) -+{ -+ grub_efi_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID; -+ struct grub_envblk envblk_s = { NULL, 0 }; -+ grub_envblk_t envblk = &envblk_s; -+ -+ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid, -+ &envblk_s.size); -+ if (!envblk_s.buf || envblk_s.size < 1) -+ return; -+ -+ grub_envblk_iterate (envblk, NULL, set_var); -+ grub_free (envblk_s.buf); -+} -+ - void - grub_efi_init (void) - { -@@ -42,10 +73,11 @@ grub_efi_init (void) - efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer, - 0, 0, 0, NULL); - -+ grub_efi_env_init (); - grub_efidisk_init (); - } - --void (*grub_efi_net_config) (grub_efi_handle_t hnd, -+void (*grub_efi_net_config) (grub_efi_handle_t hnd, - char **device, - char **path); - --- -2.9.3 - diff --git a/0013-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch b/0013-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch new file mode 100644 index 0000000..283e7b0 --- /dev/null +++ b/0013-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch @@ -0,0 +1,107 @@ +From 7a5b301e3adb8e054288518a325135a1883c1c6c Mon Sep 17 00:00:00 2001 +From: Mike Gilbert +Date: Tue, 19 Apr 2016 14:27:22 -0400 +Subject: [PATCH 013/123] build: Use AC_HEADER_MAJOR to find device macros + +Depending on the OS/libc, device macros are defined in different +headers. This change ensures we include the right one. + +sys/types.h - BSD +sys/mkdev.h - Sun +sys/sysmacros.h - glibc (Linux) + +glibc currently pulls sys/sysmacros.h into sys/types.h, but this may +change in a future release. + +https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html +--- + configure.ac | 3 ++- + grub-core/osdep/devmapper/getroot.c | 6 ++++++ + grub-core/osdep/devmapper/hostdisk.c | 5 +++++ + grub-core/osdep/linux/getroot.c | 6 ++++++ + grub-core/osdep/unix/getroot.c | 4 +++- + 5 files changed, 22 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 57e17138e..9ddfc5323 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -388,7 +388,8 @@ fi + + # Check for functions and headers. + AC_CHECK_FUNCS(posix_memalign memalign getextmntent) +-AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h) ++AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) ++AC_HEADER_MAJOR + + AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default + #include +diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c +index 05eda500a..72e558275 100644 +--- a/grub-core/osdep/devmapper/getroot.c ++++ b/grub-core/osdep/devmapper/getroot.c +@@ -40,6 +40,12 @@ + #include + #endif + ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#endif ++ + #include + + #include +diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c +index 19c1101fd..a697bcb4d 100644 +--- a/grub-core/osdep/devmapper/hostdisk.c ++++ b/grub-core/osdep/devmapper/hostdisk.c +@@ -24,6 +24,11 @@ + #include + #include + ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#endif + + #ifdef HAVE_DEVICE_MAPPER + # include +diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c +index 10480b646..09e7e6e6d 100644 +--- a/grub-core/osdep/linux/getroot.c ++++ b/grub-core/osdep/linux/getroot.c +@@ -35,6 +35,12 @@ + #include + #endif + ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#endif ++ + #include + #include /* ioctl */ + #include +diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c +index 1079a919d..4bf37b027 100644 +--- a/grub-core/osdep/unix/getroot.c ++++ b/grub-core/osdep/unix/getroot.c +@@ -51,8 +51,10 @@ + #endif + + #include +-#if defined(HAVE_SYS_MKDEV_H) ++#if defined(MAJOR_IN_MKDEV) + #include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include + #endif + + #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) +-- +2.14.3 + diff --git a/0014-DHCP-client-ID-and-UUID-options-added.patch b/0014-DHCP-client-ID-and-UUID-options-added.patch deleted file mode 100644 index aefc4af..0000000 --- a/0014-DHCP-client-ID-and-UUID-options-added.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 12fb24b4d8a8f0fd7f79bc224157c290ebab31f4 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Tue, 27 Nov 2012 17:18:53 -0200 -Subject: [PATCH 14/90] DHCP client ID and UUID options added. - ---- - grub-core/net/bootp.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++----- - include/grub/net.h | 2 ++ - 2 files changed, 81 insertions(+), 8 deletions(-) - -diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 189551a..a9c8f47 100644 ---- a/grub-core/net/bootp.c -+++ b/grub-core/net/bootp.c -@@ -25,6 +25,49 @@ - #include - #include - -+static char * -+grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), -+ const char *val __attribute__ ((unused))) -+{ -+ return NULL; -+} -+ -+static void -+set_env_limn_ro (const char *intername, const char *suffix, -+ const char *value, grub_size_t len) -+{ -+ char *varname, *varvalue; -+ char *ptr; -+ varname = grub_xasprintf ("net_%s_%s", intername, suffix); -+ if (!varname) -+ return; -+ for (ptr = varname; *ptr; ptr++) -+ if (*ptr == ':') -+ *ptr = '_'; -+ varvalue = grub_malloc (len + 1); -+ if (!varvalue) -+ { -+ grub_free (varname); -+ return; -+ } -+ -+ grub_memcpy (varvalue, value, len); -+ varvalue[len] = 0; -+ grub_env_set (varname, varvalue); -+ grub_register_variable_hook (varname, 0, grub_env_write_readonly); -+ grub_env_export (varname); -+ grub_free (varname); -+ grub_free (varvalue); -+} -+ -+static char -+hexdigit (grub_uint8_t val) -+{ -+ if (val < 10) -+ return val + '0'; -+ return val + 'a' - 10; -+} -+ - static void - parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) - { -@@ -55,6 +98,9 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) - - taglength = *ptr++; - -+ grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n", -+ tagtype, tagtype, taglength); -+ - switch (tagtype) - { - case GRUB_NET_BOOTP_NETMASK: -@@ -120,6 +166,39 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) - taglength); - break; - -+ case GRUB_NET_BOOTP_CLIENT_ID: -+ set_env_limn_ro (name, "clientid", (char *) ptr, taglength); -+ break; -+ -+ case GRUB_NET_BOOTP_CLIENT_UUID: -+ { -+ if (taglength != 17) -+ break; -+ -+ /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */ -+ -+ ptr += 1; -+ taglength -= 1; -+ -+ char *val = grub_malloc (2 * taglength + 4 + 1); -+ int i = 0; -+ int j = 0; -+ for (i = 0; i < taglength; i++) -+ { -+ val[2 * i + j] = hexdigit (ptr[i] >> 4); -+ val[2 * i + 1 + j] = hexdigit (ptr[i] & 0xf); -+ -+ if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) -+ { -+ j++; -+ val[2 * i + 1+ j] = '-'; -+ } -+ } -+ -+ set_env_limn_ro (name, "clientuuid", (char *) val, 2 * taglength + 4); -+ } -+ break; -+ - /* If you need any other options please contact GRUB - development team. */ - } -@@ -298,14 +377,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb, - } - } - --static char --hexdigit (grub_uint8_t val) --{ -- if (val < 10) -- return val + '0'; -- return val + 'a' - 10; --} -- - static grub_err_t - grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), - int argc, char **args) -diff --git a/include/grub/net.h b/include/grub/net.h -index 6ac9d72..96aa9fa 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -456,6 +456,8 @@ enum - GRUB_NET_BOOTP_DOMAIN = 0x0f, - GRUB_NET_BOOTP_ROOT_PATH = 0x11, - GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, -+ GRUB_NET_BOOTP_CLIENT_ID = 0x3d, -+ GRUB_NET_BOOTP_CLIENT_UUID = 0x61, - GRUB_NET_BOOTP_END = 0xff - }; - --- -2.9.3 - diff --git a/0014-http-reset-EOF-indication-in-http_seek.patch b/0014-http-reset-EOF-indication-in-http_seek.patch new file mode 100644 index 0000000..8cec1fe --- /dev/null +++ b/0014-http-reset-EOF-indication-in-http_seek.patch @@ -0,0 +1,26 @@ +From 13f7ead3a17a5c2681b95c4bb4f40d8eb8648880 Mon Sep 17 00:00:00 2001 +From: Stefan Fritsch +Date: Sat, 30 Apr 2016 09:10:12 +0300 +Subject: [PATCH 014/123] http: reset EOF indication in http_seek + +Otherwise next read will stop polling too early due to stale EOF +indicator, returning incomplete data to caller. +--- + grub-core/net/http.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/grub-core/net/http.c b/grub-core/net/http.c +index a7c5101a1..5aa4ad3be 100644 +--- a/grub-core/net/http.c ++++ b/grub-core/net/http.c +@@ -449,6 +449,7 @@ http_seek (struct grub_file *file, grub_off_t off) + } + + file->device->net->stall = 0; ++ file->device->net->eof = 0; + file->device->net->offset = off; + + data = grub_zalloc (sizeof (*data)); +-- +2.14.3 + diff --git a/0015-net-reset-net-stall-in-grub_net_seek_real.patch b/0015-net-reset-net-stall-in-grub_net_seek_real.patch new file mode 100644 index 0000000..56e1b8c --- /dev/null +++ b/0015-net-reset-net-stall-in-grub_net_seek_real.patch @@ -0,0 +1,27 @@ +From e045af148a580203e47e47276e387fc3958391a5 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Sat, 30 Apr 2016 09:15:36 +0300 +Subject: [PATCH 015/123] net: reset net->stall in grub_net_seek_real + +If we open new connection, we need to reset stall indication, otherwise +nothing will ever be polled (low level code rely on this field being +zero when establishing connection). +--- + grub-core/net/net.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/grub-core/net/net.c b/grub-core/net/net.c +index 942459527..26a1fc3fc 100644 +--- a/grub-core/net/net.c ++++ b/grub-core/net/net.c +@@ -1672,6 +1672,7 @@ grub_net_seek_real (struct grub_file *file, grub_off_t offset) + file->device->net->packs.last = NULL; + file->device->net->offset = 0; + file->device->net->eof = 0; ++ file->device->net->stall = 0; + err = file->device->net->protocol->open (file, file->device->net->name); + if (err) + return err; +-- +2.14.3 + diff --git a/0015-trim-arp-packets-with-abnormal-size.patch b/0015-trim-arp-packets-with-abnormal-size.patch deleted file mode 100644 index fed31b4..0000000 --- a/0015-trim-arp-packets-with-abnormal-size.patch +++ /dev/null @@ -1,31 +0,0 @@ -From a6f4624278357f853e3e8888e538eb0ef3654556 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Wed, 5 Feb 2014 09:42:42 -0200 -Subject: [PATCH 15/90] trim arp packets with abnormal size - -GRUB uses arp request to create the arp response. If the incoming packet -is foobared, GRUB needs to trim the arp response packet before sending it. ---- - grub-core/net/arp.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c -index 4b68c41..f7c59d3 100644 ---- a/grub-core/net/arp.c -+++ b/grub-core/net/arp.c -@@ -142,6 +142,12 @@ grub_net_arp_receive (struct grub_net_buff *nb, - if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) - { -+ if ((nb->tail - nb->data) > 50) -+ { -+ grub_dprintf ("net", "arp packet with abnormal size (%ld bytes).\n", -+ nb->tail - nb->data); -+ nb->tail = nb->data + 50; -+ } - grub_net_link_level_address_t target; - struct grub_net_buff nb_reply; - struct arppkt *arp_reply; --- -2.9.3 - diff --git a/0016-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch b/0016-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch deleted file mode 100644 index 011204e..0000000 --- a/0016-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch +++ /dev/null @@ -1,41 +0,0 @@ -From c22139b340f1a306ad718646a4cd4bc1d4039d7b Mon Sep 17 00:00:00 2001 -From: Prarit Bhargava -Date: Wed, 12 Mar 2014 10:58:16 -0400 -Subject: [PATCH 16/90] Fix bad test on GRUB_DISABLE_SUBMENU. - -The file /etc/grub.d/10_linux does - -if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then - -when it should do - -if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then - -which results in submenus in /boot/grub2/grub.cfg when -GRUB_DISABLE_SUBMENU="yes". - -Resolves: rhbz#1063414 ---- - util/grub.d/10_linux.in | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index de9044c..cf6331f 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -224,7 +224,11 @@ while [ "x$list" != "x" ] ; do - linux_root_device_thisversion=${GRUB_DEVICE} - fi - -- if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then -+ if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then -+ GRUB_DISABLE_SUBMENU="true" -+ fi -+ -+ if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then - linux_entry "${OS}" "${version}" simple \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - --- -2.9.3 - diff --git a/0016-net-translate-pxe-prefix-to-tftp-when-checking-for-s.patch b/0016-net-translate-pxe-prefix-to-tftp-when-checking-for-s.patch new file mode 100644 index 0000000..cd287eb --- /dev/null +++ b/0016-net-translate-pxe-prefix-to-tftp-when-checking-for-s.patch @@ -0,0 +1,35 @@ +From b524fa27f56381bb0efa4944e36f50265113aee5 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Tue, 3 May 2016 19:23:31 +0300 +Subject: [PATCH 016/123] net: translate pxe prefix to tftp when checking for + self-load + +Commit ba218c1 missed legacy pxe and pxe: prefixes which are +translated to tftp, so comparison failed. +--- + grub-core/net/net.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/grub-core/net/net.c b/grub-core/net/net.c +index 26a1fc3fc..10773fc34 100644 +--- a/grub-core/net/net.c ++++ b/grub-core/net/net.c +@@ -1346,6 +1346,15 @@ grub_net_open_real (const char *name) + continue; + } + ++ if (grub_strncmp (prefdev, "pxe", sizeof ("pxe") - 1) == 0 && ++ (!prefdev[sizeof ("pxe") - 1] || (prefdev[sizeof("pxe") - 1] == ':'))) ++ { ++ grub_free (prefdev); ++ prefdev = grub_strdup ("tftp"); ++ if (!prefdev) ++ continue; ++ } ++ + comma = grub_strchr (prefdev, ','); + if (comma) + *comma = '\0'; +-- +2.14.3 + diff --git a/0017-Add-support-for-UEFI-operating-systems-returned-by-o.patch b/0017-Add-support-for-UEFI-operating-systems-returned-by-o.patch deleted file mode 100644 index fb49bb7..0000000 --- a/0017-Add-support-for-UEFI-operating-systems-returned-by-o.patch +++ /dev/null @@ -1,50 +0,0 @@ -From f0daa044a90c508f8f60d23e5ef39597ec80c2cc Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Wed, 12 Jun 2013 11:51:49 -0400 -Subject: [PATCH 17/90] Add support for UEFI operating systems returned by - os-prober - -os-prober returns UEFI operating systems in the form: - -path:long-name:name - -where path is the path under the EFI directory on the ESP. This is in -contrast to legacy OSes, where path is the device string. Handle this case. ---- - util/grub.d/30_os-prober.in | 21 ++++++++++++++++++--- - 1 file changed, 18 insertions(+), 3 deletions(-) - -diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 515a68c..9b8f596 100644 ---- a/util/grub.d/30_os-prober.in -+++ b/util/grub.d/30_os-prober.in -@@ -328,8 +328,23 @@ EOF - EOF - ;; - *) -- # TRANSLATORS: %s is replaced by OS name. -- gettext_printf "%s is not yet supported by grub-mkconfig.\n" " ${LONGNAME}" >&2 -- ;; -+ case ${DEVICE} in -+ *.efi) -+ cat << EOF -+menuentry '$(echo "${LONGNAME}" | grub_quote)' { -+EOF -+ save_default_entry | grub_add_tab -+ cat << EOF -+ chainloader /EFI/${DEVICE} -+ boot -+} -+EOF -+ ;; -+ *) -+ echo -n " " -+ # TRANSLATORS: %s is replaced by OS name. -+ gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2 -+ ;; -+ esac - esac - done --- -2.9.3 - diff --git a/0017-IBM-client-architecture-CAS-reboot-support.patch b/0017-IBM-client-architecture-CAS-reboot-support.patch new file mode 100644 index 0000000..7e5d4f3 --- /dev/null +++ b/0017-IBM-client-architecture-CAS-reboot-support.patch @@ -0,0 +1,174 @@ +From e32c57d2abd034cbdea24a8f51de8dbef453bd96 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Thu, 20 Sep 2012 18:07:39 -0300 +Subject: [PATCH 017/123] IBM client architecture (CAS) reboot support + +This is an implementation of IBM client architecture (CAS) reboot for GRUB. + +There are cases where the POWER firmware must reboot in order to support +specific features requested by a kernel. The kernel calls +ibm,client-architecture-support and it may either return or reboot with the new +feature set. eg: + +Calling ibm,client-architecture-support.../ +Elapsed time since release of system processors: 70959 mins 50 secs +Welcome to GRUB! + +Instead of return to the GRUB menu, it will check if the flag for CAS reboot is +set. If so, grub will automatically boot the last booted kernel using the same +parameters +--- + grub-core/kern/ieee1275/openfw.c | 62 ++++++++++++++++++++++++++++++++++++++++ + grub-core/normal/main.c | 19 ++++++++++++ + grub-core/script/execute.c | 7 +++++ + include/grub/ieee1275/ieee1275.h | 2 ++ + 4 files changed, 90 insertions(+) + +diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c +index ddb778340..6db8b9865 100644 +--- a/grub-core/kern/ieee1275/openfw.c ++++ b/grub-core/kern/ieee1275/openfw.c +@@ -561,3 +561,65 @@ grub_ieee1275_canonicalise_devname (const char *path) + return NULL; + } + ++/* Check if it's a CAS reboot. If so, set the script to be executed. */ ++int ++grub_ieee1275_cas_reboot (char *script) ++{ ++ grub_uint32_t ibm_ca_support_reboot; ++ grub_uint32_t ibm_fw_nbr_reboots; ++ char property_value[10]; ++ grub_ssize_t actual; ++ grub_ieee1275_ihandle_t options; ++ ++ if (grub_ieee1275_finddevice ("/options", &options) < 0) ++ return -1; ++ ++ /* Check two properties, one is enough to get cas reboot value */ ++ ibm_ca_support_reboot = 0; ++ if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, ++ "ibm,client-architecture-support-reboot", ++ &ibm_ca_support_reboot, ++ sizeof (ibm_ca_support_reboot), ++ &actual) >= 0) ++ grub_dprintf("ieee1275", "ibm,client-architecture-support-reboot: %u\n", ++ ibm_ca_support_reboot); ++ ++ ibm_fw_nbr_reboots = 0; ++ if (grub_ieee1275_get_property (options, "ibm,fw-nbr-reboots", ++ property_value, sizeof (property_value), ++ &actual) >= 0) ++ { ++ property_value[sizeof (property_value) - 1] = 0; ++ ibm_fw_nbr_reboots = (grub_uint8_t) grub_strtoul (property_value, 0, 10); ++ grub_dprintf("ieee1275", "ibm,fw-nbr-reboots: %u\n", ibm_fw_nbr_reboots); ++ } ++ ++ if (ibm_ca_support_reboot || ibm_fw_nbr_reboots) ++ { ++ if (! grub_ieee1275_get_property_length (options, "boot-last-label", &actual)) ++ { ++ if (actual > 1024) ++ script = grub_realloc (script, actual + 1); ++ grub_ieee1275_get_property (options, "boot-last-label", script, actual, ++ &actual); ++ return 0; ++ } ++ } ++ ++ grub_ieee1275_set_boot_last_label (""); ++ ++ return -1; ++} ++ ++int grub_ieee1275_set_boot_last_label (const char *text) ++{ ++ grub_ieee1275_ihandle_t options; ++ grub_ssize_t actual; ++ ++ grub_dprintf("ieee1275", "set boot_last_label (size: %u)\n", grub_strlen(text)); ++ if (! grub_ieee1275_finddevice ("/options", &options) && ++ options != (grub_ieee1275_ihandle_t) -1) ++ grub_ieee1275_set_property (options, "boot-last-label", text, ++ grub_strlen (text), &actual); ++ return 0; ++} +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index 78a70a8bf..249e19bc7 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -33,6 +33,9 @@ + #include + #include + #include ++#ifdef GRUB_MACHINE_IEEE1275 ++#include ++#endif + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -275,6 +278,22 @@ grub_normal_execute (const char *config, int nested, int batch) + { + menu = read_config_file (config); + ++#ifdef GRUB_MACHINE_IEEE1275 ++ int boot; ++ boot = 0; ++ char *script; ++ script = grub_malloc (1024); ++ if (! grub_ieee1275_cas_reboot (script)) ++ { ++ char *dummy[1] = { NULL }; ++ if (! grub_script_execute_sourcecode (script)) ++ boot = 1; ++ } ++ grub_free (script); ++ if (boot) ++ grub_command_execute ("boot", 0, 0); ++#endif ++ + /* Ignore any error. */ + grub_errno = GRUB_ERR_NONE; + } +diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c +index a8502d907..ab78ca87f 100644 +--- a/grub-core/script/execute.c ++++ b/grub-core/script/execute.c +@@ -27,6 +27,9 @@ + #include + #include + #include ++#ifdef GRUB_MACHINE_IEEE1275 ++#include ++#endif + + /* Max digits for a char is 3 (0xFF is 255), similarly for an int it + is sizeof (int) * 3, and one extra for a possible -ve sign. */ +@@ -877,6 +880,10 @@ grub_script_execute_sourcecode (const char *source) + grub_err_t ret = 0; + struct grub_script *parsed_script; + ++#ifdef GRUB_MACHINE_IEEE1275 ++ grub_ieee1275_set_boot_last_label (source); ++#endif ++ + while (source) + { + char *line; +diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h +index 8e4251303..9f26c69a2 100644 +--- a/include/grub/ieee1275/ieee1275.h ++++ b/include/grub/ieee1275/ieee1275.h +@@ -234,6 +234,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *ali + void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias); + void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, + struct grub_ieee1275_devalias *alias); ++int EXPORT_FUNC(grub_ieee1275_cas_reboot) (char *script); ++int EXPORT_FUNC(grub_ieee1275_set_boot_last_label) (const char *text); + + #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) + +-- +2.14.3 + diff --git a/0018-Migrate-PPC-from-Yaboot-to-Grub2.patch b/0018-Migrate-PPC-from-Yaboot-to-Grub2.patch deleted file mode 100644 index f605f68..0000000 --- a/0018-Migrate-PPC-from-Yaboot-to-Grub2.patch +++ /dev/null @@ -1,154 +0,0 @@ -From 0e433858169473aa7a042c28dd6f0d4e1adab8d7 Mon Sep 17 00:00:00 2001 -From: Mark Hamzy -Date: Wed, 28 Mar 2012 14:46:41 -0500 -Subject: [PATCH 18/90] Migrate PPC from Yaboot to Grub2 - -Add configuration support for serial terminal consoles. This will set the -maximum screen size so that text is not overwritten. ---- - Makefile.util.def | 7 +++ - util/grub.d/20_ppc_terminfo.in | 114 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 121 insertions(+) - create mode 100644 util/grub.d/20_ppc_terminfo.in - -diff --git a/Makefile.util.def b/Makefile.util.def -index f9caccb..6d452da 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -487,6 +487,13 @@ script = { - }; - - script = { -+ name = '20_ppc_terminfo'; -+ common = util/grub.d/20_ppc_terminfo.in; -+ installdir = grubconf; -+ condition = COND_HOST_LINUX; -+}; -+ -+script = { - name = '30_os-prober'; - common = util/grub.d/30_os-prober.in; - installdir = grubconf; -diff --git a/util/grub.d/20_ppc_terminfo.in b/util/grub.d/20_ppc_terminfo.in -new file mode 100644 -index 0000000..10d6658 ---- /dev/null -+++ b/util/grub.d/20_ppc_terminfo.in -@@ -0,0 +1,114 @@ -+#! /bin/sh -+set -e -+ -+# grub-mkconfig helper script. -+# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. -+# -+# GRUB 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. -+# -+# GRUB 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 GRUB. If not, see . -+ -+prefix=@prefix@ -+exec_prefix=@exec_prefix@ -+bindir=@bindir@ -+libdir=@libdir@ -+. "@datadir@/@PACKAGE@/grub-mkconfig_lib" -+ -+export TEXTDOMAIN=@PACKAGE@ -+export TEXTDOMAINDIR=@localedir@ -+ -+X=80 -+Y=24 -+TERMINAL=ofconsole -+ -+argument () { -+ opt=$1 -+ shift -+ -+ if test $# -eq 0; then -+ echo "$0: option requires an argument -- '$opt'" 1>&2 -+ exit 1 -+ fi -+ echo $1 -+} -+ -+check_terminfo () { -+ -+ while test $# -gt 0 -+ do -+ option=$1 -+ shift -+ -+ case "$option" in -+ terminfo | TERMINFO) -+ ;; -+ -+ -g) -+ NEWXY=`argument $option "$@"` -+ NEWX=`echo $NEWXY | cut -d x -f 1` -+ NEWY=`echo $NEWXY | cut -d x -f 2` -+ -+ if [ ${NEWX} -ge 80 ] ; then -+ X=${NEWX} -+ else -+ echo "Warning: ${NEWX} is less than the minimum size of 80" -+ fi -+ -+ if [ ${NEWY} -ge 24 ] ; then -+ Y=${NEWY} -+ else -+ echo "Warning: ${NEWY} is less than the minimum size of 24" -+ fi -+ -+ shift -+ ;; -+ -+ *) -+# # accept console or ofconsole -+# if [ "$option" != "console" -a "$option" != "ofconsole" ] ; then -+# echo "Error: GRUB_TERMINFO unknown console: $option" -+# exit 1 -+# fi -+# # perfer console -+# TERMINAL=console -+ # accept ofconsole -+ if [ "$option" != "ofconsole" ] ; then -+ echo "Error: GRUB_TERMINFO unknown console: $option" -+ exit 1 -+ fi -+ # perfer console -+ TERMINAL=ofconsole -+ ;; -+ esac -+ -+ done -+ -+} -+ -+if ! uname -m | grep -q ppc ; then -+ exit 0 -+fi -+ -+if [ "x${GRUB_TERMINFO}" != "x" ] ; then -+ F1=`echo ${GRUB_TERMINFO} | cut -d " " -f 1` -+ -+ if [ "${F1}" != "terminfo" ] ; then -+ echo "Error: GRUB_TERMINFO is set to \"${GRUB_TERMINFO}\" The first word should be terminfo." -+ exit 1 -+ fi -+ -+ check_terminfo ${GRUB_TERMINFO} -+fi -+ -+cat << EOF -+ terminfo -g ${X}x${Y} ${TERMINAL} -+EOF --- -2.9.3 - diff --git a/0018-for-ppc-reset-console-display-attr-when-clear-screen.patch b/0018-for-ppc-reset-console-display-attr-when-clear-screen.patch new file mode 100644 index 0000000..d213501 --- /dev/null +++ b/0018-for-ppc-reset-console-display-attr-when-clear-screen.patch @@ -0,0 +1,32 @@ +From 4f82466e3b1fcf3370d82432e406f51906e1fa46 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Wed, 24 Apr 2013 10:51:48 -0300 +Subject: [PATCH 018/123] for ppc, reset console display attr when clear screen + +v2: Also use \x0c instead of a literal ^L to make future patches less +awkward. + +This should fix this bugzilla: +https://bugzilla.redhat.com/show_bug.cgi?id=908519 + +Signed-off-by: Peter Jones +--- + grub-core/term/terminfo.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c +index f0d3e3deb..9bb75c173 100644 +--- a/grub-core/term/terminfo.c ++++ b/grub-core/term/terminfo.c +@@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term, + /* Clear the screen. Using serial console, screen(1) only recognizes the + * ANSI escape sequence. Using video console, Apple Open Firmware + * (version 3.1.1) only recognizes the literal ^L. So use both. */ +- data->cls = grub_strdup (" \e[2J"); ++ data->cls = grub_strdup ("\x0c\e[2J\e[m"); + data->reverse_video_on = grub_strdup ("\e[7m"); + data->reverse_video_off = grub_strdup ("\e[m"); + if (grub_strcmp ("ieee1275", str) == 0) +-- +2.14.3 + diff --git a/0019-Add-fw_path-variable-revised.patch b/0019-Add-fw_path-variable-revised.patch deleted file mode 100644 index 8724bf3..0000000 --- a/0019-Add-fw_path-variable-revised.patch +++ /dev/null @@ -1,81 +0,0 @@ -From fdc52554d998170f56ed45856082f4a3bfeb3e2a Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Wed, 19 Sep 2012 21:22:55 -0300 -Subject: [PATCH 19/90] Add fw_path variable (revised) - -This patch makes grub look for its config file on efi where the app was -found. It was originally written by Matthew Garrett, and adapted to fix the -"No modules are loaded on grub2 network boot" issue: - -https://bugzilla.redhat.com/show_bug.cgi?id=857936 ---- - grub-core/kern/main.c | 13 ++++++------- - grub-core/normal/main.c | 25 ++++++++++++++++++++++++- - 2 files changed, 30 insertions(+), 8 deletions(-) - -diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 9cad0c4..8ab7794 100644 ---- a/grub-core/kern/main.c -+++ b/grub-core/kern/main.c -@@ -127,16 +127,15 @@ grub_set_prefix_and_root (void) - - grub_machine_get_bootlocation (&fwdevice, &fwpath); - -- if (fwdevice) -+ if (fwdevice && fwpath) - { -- char *cmdpath; -+ char *fw_path; - -- cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : ""); -- if (cmdpath) -+ fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath); -+ if (fw_path) - { -- grub_env_set ("cmdpath", cmdpath); -- grub_env_export ("cmdpath"); -- grub_free (cmdpath); -+ grub_env_set ("fw_path", fw_path); -+ grub_free (fw_path); - } - } - -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 249e19b..759c475 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -338,7 +338,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), - /* Guess the config filename. It is necessary to make CONFIG static, - so that it won't get broken by longjmp. */ - char *config; -- const char *prefix; -+ const char *prefix, *fw_path; -+ -+ fw_path = grub_env_get ("fw_path"); -+ if (fw_path) -+ { -+ config = grub_xasprintf ("%s/grub.cfg", fw_path); -+ if (config) -+ { -+ grub_file_t file; -+ -+ file = grub_file_open (config); -+ if (file) -+ { -+ grub_file_close (file); -+ grub_enter_normal_mode (config); -+ } -+ else -+ { -+ /* Ignore all errors. */ -+ grub_errno = 0; -+ } -+ grub_free (config); -+ } -+ } - - prefix = grub_env_get ("prefix"); - if (prefix) --- -2.9.3 - diff --git a/0019-Disable-GRUB-video-support-for-IBM-power-machines.patch b/0019-Disable-GRUB-video-support-for-IBM-power-machines.patch new file mode 100644 index 0000000..38e53fa --- /dev/null +++ b/0019-Disable-GRUB-video-support-for-IBM-power-machines.patch @@ -0,0 +1,65 @@ +From 9cff6efa3a7e15a6968fed29a29f38713da864fd Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Tue, 11 Jun 2013 15:14:05 -0300 +Subject: [PATCH 019/123] Disable GRUB video support for IBM power machines + +Should fix the problem in bugzilla: +https://bugzilla.redhat.com/show_bug.cgi?id=973205 +--- + grub-core/kern/ieee1275/cmain.c | 5 ++++- + grub-core/video/ieee1275.c | 9 ++++++--- + include/grub/ieee1275/ieee1275.h | 2 ++ + 3 files changed, 12 insertions(+), 4 deletions(-) + +diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c +index 3e12e6b24..3e14f5393 100644 +--- a/grub-core/kern/ieee1275/cmain.c ++++ b/grub-core/kern/ieee1275/cmain.c +@@ -90,7 +90,10 @@ grub_ieee1275_find_options (void) + } + + if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0) +- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS); ++ { ++ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS); ++ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT); ++ } + + /* Old Macs have no key repeat, newer ones have fully working one. + The ones inbetween when repeated key generates an escaoe sequence +diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c +index 0b150ec24..813ab38e1 100644 +--- a/grub-core/video/ieee1275.c ++++ b/grub-core/video/ieee1275.c +@@ -351,9 +351,12 @@ static struct grub_video_adapter grub_video_ieee1275_adapter = + + GRUB_MOD_INIT(ieee1275_fb) + { +- find_display (); +- if (display) +- grub_video_register (&grub_video_ieee1275_adapter); ++ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT)) ++ { ++ find_display (); ++ if (display) ++ grub_video_register (&grub_video_ieee1275_adapter); ++ } + } + + GRUB_MOD_FINI(ieee1275_fb) +diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h +index 9f26c69a2..ab4f284c3 100644 +--- a/include/grub/ieee1275/ieee1275.h ++++ b/include/grub/ieee1275/ieee1275.h +@@ -146,6 +146,8 @@ enum grub_ieee1275_flag + GRUB_IEEE1275_FLAG_BROKEN_REPEAT, + + GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN, ++ ++ GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT + }; + + extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); +-- +2.14.3 + diff --git a/0020-Add-support-for-linuxefi.patch b/0020-Add-support-for-linuxefi.patch deleted file mode 100644 index 19940a6..0000000 --- a/0020-Add-support-for-linuxefi.patch +++ /dev/null @@ -1,482 +0,0 @@ -From a64179016df64b72cc956fd6085ca3ed1a41baac Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Tue, 10 Jul 2012 11:58:52 -0400 -Subject: [PATCH 20/90] Add support for linuxefi - ---- - grub-core/Makefile.core.def | 8 + - grub-core/kern/efi/mm.c | 32 ++++ - grub-core/loader/i386/efi/linux.c | 371 ++++++++++++++++++++++++++++++++++++++ - include/grub/efi/efi.h | 3 + - include/grub/i386/linux.h | 1 + - 5 files changed, 415 insertions(+) - create mode 100644 grub-core/loader/i386/efi/linux.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index f8d4634..de8c9df 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1732,6 +1732,14 @@ module = { - }; - - module = { -+ name = linuxefi; -+ efi = loader/i386/efi/linux.c; -+ efi = lib/cmdline.c; -+ enable = i386_efi; -+ enable = x86_64_efi; -+}; -+ -+module = { - name = chain; - efi = loader/efi/chainloader.c; - i386_pc = loader/i386/pc/chainloader.c; -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 20a47aa..efb15cc 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -49,6 +49,38 @@ static grub_efi_uintn_t finish_desc_size; - static grub_efi_uint32_t finish_desc_version; - int grub_efi_is_finished = 0; - -+/* Allocate pages below a specified address */ -+void * -+grub_efi_allocate_pages_max (grub_efi_physical_address_t max, -+ grub_efi_uintn_t pages) -+{ -+ grub_efi_status_t status; -+ grub_efi_boot_services_t *b; -+ grub_efi_physical_address_t address = max; -+ -+ if (max > 0xffffffff) -+ return 0; -+ -+ b = grub_efi_system_table->boot_services; -+ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); -+ -+ if (status != GRUB_EFI_SUCCESS) -+ return 0; -+ -+ if (address == 0) -+ { -+ /* Uggh, the address 0 was allocated... This is too annoying, -+ so reallocate another one. */ -+ address = max; -+ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); -+ grub_efi_free_pages (0, pages); -+ if (status != GRUB_EFI_SUCCESS) -+ return 0; -+ } -+ -+ return (void *) ((grub_addr_t) address); -+} -+ - /* Allocate pages. Return the pointer to the first of allocated pages. */ - void * - grub_efi_allocate_pages (grub_efi_physical_address_t address, -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -new file mode 100644 -index 0000000..b79e632 ---- /dev/null -+++ b/grub-core/loader/i386/efi/linux.c -@@ -0,0 +1,371 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2012 Free Software Foundation, Inc. -+ * -+ * GRUB 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. -+ * -+ * GRUB 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 GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+GRUB_MOD_LICENSE ("GPLv3+"); -+ -+static grub_dl_t my_mod; -+static int loaded; -+static void *kernel_mem; -+static grub_uint64_t kernel_size; -+static grub_uint8_t *initrd_mem; -+static grub_uint32_t handover_offset; -+struct linux_kernel_params *params; -+static char *linux_cmdline; -+ -+#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) -+ -+#define SHIM_LOCK_GUID \ -+ { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } -+ -+struct grub_efi_shim_lock -+{ -+ grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size); -+}; -+typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; -+ -+static grub_efi_boolean_t -+grub_linuxefi_secure_validate (void *data, grub_uint32_t size) -+{ -+ grub_efi_guid_t guid = SHIM_LOCK_GUID; -+ grub_efi_shim_lock_t *shim_lock; -+ -+ shim_lock = grub_efi_locate_protocol(&guid, NULL); -+ -+ if (!shim_lock) -+ return 1; -+ -+ if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) -+ return 1; -+ -+ return 0; -+} -+ -+typedef void(*handover_func)(void *, grub_efi_system_table_t *, struct linux_kernel_params *); -+ -+static grub_err_t -+grub_linuxefi_boot (void) -+{ -+ handover_func hf; -+ int offset = 0; -+ -+#ifdef __x86_64__ -+ offset = 512; -+#endif -+ -+ hf = (handover_func)((char *)kernel_mem + handover_offset + offset); -+ -+ asm volatile ("cli"); -+ -+ hf (grub_efi_image_handle, grub_efi_system_table, params); -+ -+ /* Not reached */ -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_linuxefi_unload (void) -+{ -+ grub_dl_unref (my_mod); -+ loaded = 0; -+ if (initrd_mem) -+ grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size)); -+ if (linux_cmdline) -+ grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1)); -+ if (kernel_mem) -+ grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); -+ if (params) -+ grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), -+ int argc, char *argv[]) -+{ -+ grub_file_t *files = 0; -+ int i, nfiles = 0; -+ grub_size_t size = 0; -+ grub_uint8_t *ptr; -+ -+ if (argc == 0) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -+ goto fail; -+ } -+ -+ if (!loaded) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("you need to load the kernel first")); -+ goto fail; -+ } -+ -+ files = grub_zalloc (argc * sizeof (files[0])); -+ if (!files) -+ goto fail; -+ -+ for (i = 0; i < argc; i++) -+ { -+ grub_file_filter_disable_compression (); -+ files[i] = grub_file_open (argv[i]); -+ if (! files[i]) -+ goto fail; -+ nfiles++; -+ size += ALIGN_UP (grub_file_size (files[i]), 4); -+ } -+ -+ initrd_mem = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(size)); -+ -+ if (!initrd_mem) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd")); -+ goto fail; -+ } -+ -+ params->ramdisk_size = size; -+ params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem; -+ -+ ptr = initrd_mem; -+ -+ for (i = 0; i < nfiles; i++) -+ { -+ grub_ssize_t cursize = grub_file_size (files[i]); -+ if (grub_file_read (files[i], ptr, cursize) != cursize) -+ { -+ if (!grub_errno) -+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), -+ argv[i]); -+ goto fail; -+ } -+ ptr += cursize; -+ grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); -+ ptr += ALIGN_UP_OVERHEAD (cursize, 4); -+ } -+ -+ params->ramdisk_size = size; -+ -+ fail: -+ for (i = 0; i < nfiles; i++) -+ grub_file_close (files[i]); -+ grub_free (files); -+ -+ if (initrd_mem && grub_errno) -+ grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(size)); -+ -+ return grub_errno; -+} -+ -+static grub_err_t -+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), -+ int argc, char *argv[]) -+{ -+ grub_file_t file = 0; -+ struct linux_kernel_header lh; -+ grub_ssize_t len, start, filelen; -+ void *kernel; -+ -+ grub_dl_ref (my_mod); -+ -+ if (argc == 0) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -+ goto fail; -+ } -+ -+ file = grub_file_open (argv[0]); -+ if (! file) -+ goto fail; -+ -+ filelen = grub_file_size (file); -+ -+ kernel = grub_malloc(filelen); -+ -+ if (!kernel) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer")); -+ goto fail; -+ } -+ -+ if (grub_file_read (file, kernel, filelen) != filelen) -+ { -+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), argv[0]); -+ goto fail; -+ } -+ -+ if (! grub_linuxefi_secure_validate (kernel, filelen)) -+ { -+ grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); -+ grub_free (kernel); -+ goto fail; -+ } -+ -+ grub_file_seek (file, 0); -+ -+ grub_free(kernel); -+ -+ params = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(16384)); -+ -+ if (! params) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); -+ goto fail; -+ } -+ -+ memset (params, 0, 16384); -+ -+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) -+ { -+ if (!grub_errno) -+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -+ argv[0]); -+ goto fail; -+ } -+ -+ if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) -+ { -+ grub_error (GRUB_ERR_BAD_OS, N_("invalid magic number")); -+ goto fail; -+ } -+ -+ if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS) -+ { -+ grub_error (GRUB_ERR_BAD_OS, N_("too many setup sectors")); -+ goto fail; -+ } -+ -+ if (lh.version < grub_cpu_to_le16 (0x020b)) -+ { -+ grub_error (GRUB_ERR_BAD_OS, N_("kernel too old")); -+ goto fail; -+ } -+ -+ if (!lh.handover_offset) -+ { -+ grub_error (GRUB_ERR_BAD_OS, N_("kernel doesn't support EFI handover")); -+ goto fail; -+ } -+ -+ linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, -+ BYTES_TO_PAGES(lh.cmdline_size + 1)); -+ -+ if (!linux_cmdline) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline")); -+ goto fail; -+ } -+ -+ grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); -+ grub_create_loader_cmdline (argc, argv, -+ linux_cmdline + sizeof (LINUX_IMAGE) - 1, -+ lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); -+ -+ lh.cmd_line_ptr = (grub_uint32_t)(grub_uint64_t)linux_cmdline; -+ -+ handover_offset = lh.handover_offset; -+ -+ start = (lh.setup_sects + 1) * 512; -+ len = grub_file_size(file) - start; -+ -+ kernel_mem = grub_efi_allocate_pages(lh.pref_address, -+ BYTES_TO_PAGES(lh.init_size)); -+ -+ if (!kernel_mem) -+ kernel_mem = grub_efi_allocate_pages_max(0x3fffffff, -+ BYTES_TO_PAGES(lh.init_size)); -+ -+ if (!kernel_mem) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel")); -+ goto fail; -+ } -+ -+ if (grub_file_seek (file, start) == (grub_off_t) -1) -+ { -+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -+ argv[0]); -+ goto fail; -+ } -+ -+ if (grub_file_read (file, kernel_mem, len) != len && !grub_errno) -+ { -+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -+ argv[0]); -+ } -+ -+ if (grub_errno == GRUB_ERR_NONE) -+ { -+ grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); -+ loaded = 1; -+ lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; -+ } -+ -+ memcpy(params, &lh, 2 * 512); -+ -+ params->type_of_loader = 0x21; -+ -+ fail: -+ -+ if (file) -+ grub_file_close (file); -+ -+ if (grub_errno != GRUB_ERR_NONE) -+ { -+ grub_dl_unref (my_mod); -+ loaded = 0; -+ } -+ -+ if (linux_cmdline && !loaded) -+ grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1)); -+ -+ if (kernel_mem && !loaded) -+ grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); -+ -+ if (params && !loaded) -+ grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); -+ -+ return grub_errno; -+} -+ -+static grub_command_t cmd_linux, cmd_initrd; -+ -+GRUB_MOD_INIT(linuxefi) -+{ -+ cmd_linux = -+ grub_register_command ("linuxefi", grub_cmd_linux, -+ 0, N_("Load Linux.")); -+ cmd_initrd = -+ grub_register_command ("initrdefi", grub_cmd_initrd, -+ 0, N_("Load initrd.")); -+ my_mod = mod; -+} -+ -+GRUB_MOD_FINI(linuxefi) -+{ -+ grub_unregister_command (cmd_linux); -+ grub_unregister_command (cmd_initrd); -+} -diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 0e6fd86..9a2da0e 100644 ---- a/include/grub/efi/efi.h -+++ b/include/grub/efi/efi.h -@@ -40,6 +40,9 @@ void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds); - void * - EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, - grub_efi_uintn_t pages); -+void * -+EXPORT_FUNC(grub_efi_allocate_pages_max) (grub_efi_physical_address_t max, -+ grub_efi_uintn_t pages); - void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, - grub_efi_uintn_t pages); - int -diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index da0ca3b..fc36bda 100644 ---- a/include/grub/i386/linux.h -+++ b/include/grub/i386/linux.h -@@ -139,6 +139,7 @@ struct linux_kernel_header - grub_uint64_t setup_data; - grub_uint64_t pref_address; - grub_uint32_t init_size; -+ grub_uint32_t handover_offset; - } GRUB_PACKED; - - /* Boot parameters for Linux based on 2.6.12. This is used by the setup --- -2.9.3 - diff --git a/0020-Fix-bzr-s-ignore-artificats-in-.gitignore.patch b/0020-Fix-bzr-s-ignore-artificats-in-.gitignore.patch new file mode 100644 index 0000000..d7eb2a5 --- /dev/null +++ b/0020-Fix-bzr-s-ignore-artificats-in-.gitignore.patch @@ -0,0 +1,371 @@ +From 512fe6865738286c94f87da64ca6b475bc3e2f38 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 7 Jul 2015 10:13:14 -0400 +Subject: [PATCH 020/123] Fix bzr's ignore artificats in .gitignore + +We lost a man page because of incompatibilities between bzr's ignore +system and .gitignore, so solve that slightly better. + +Signed-off-by: Peter Jones +--- + .gitignore | 265 ++++++++++++++++++++++++++++--------------------------------- + 1 file changed, 120 insertions(+), 145 deletions(-) + +diff --git a/.gitignore b/.gitignore +index 18ab8e812..06c9f3ab7 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -1,93 +1,154 @@ +-00_header +-10_* +-20_linux_xen +-30_os-prober +-40_custom +-41_custom +-*.1 +-*.8 ++!util/*.[[:digit:]] ++!util/grub.d/[[:digit:]][[:digit:]]_*.in ++*.[[:digit:]] ++*.a ++*.exe ++*.exec ++*.image ++*.img ++*.log ++*.lst ++*.marker ++*.mod ++*.o ++*.pf2 ++*.pp ++*.trs ++.deps ++.deps-core ++.deps-util ++.dirstamp ++DISTLIST ++GPATH ++GRTAGS ++GSYMS ++GTAGS ++Makefile ++Makefile.in ++Makefile.util.am ++Makefile.utilgcry.def ++[[:digit:]][[:digit:]]_* + aclocal.m4 + ahci_test + ascii.bitmaps + ascii.h + autom4te.cache ++build-aux/test-driver + build-grub-gen-asciih + build-grub-gen-widthspec + build-grub-mkfont + cdboot_test + cmp_test ++compile ++config-util.h ++config-util.h.in + config.cache + config.guess + config.h +-config-util.h +-config-util.h.in + config.log + config.status + config.sub + configure ++contrib + core_compress_test +-DISTLIST ++depcomp + docs/*.info ++docs/stamp-1 + docs/stamp-vti ++docs/version-dev.texi + docs/version.texi + ehci_test + example_grub_script_test + example_scripted_test + example_unit_test +-*.exec +-*.exec.exe + fddboot_test ++garbage-gen + genkernsyms.sh + gensymlist.sh + gentrigtables +-gentrigtables.exe + gettext_strings_test + grub-bin2h +-/grub-bios-setup +-/grub-bios-setup.exe ++grub-bios-setup ++grub-core/*.module ++grub-core/*.pp ++grub-core/Makefile.core.am ++grub-core/Makefile.gcry.def ++grub-core/bootinfo.txt ++grub-core/contrib ++grub-core/gdb_grub ++grub-core/genmod.sh ++grub-core/gensyminfo.sh ++grub-core/gmodule.pl ++grub-core/gnulib/alloca.h ++grub-core/gnulib/arg-nonnull.h ++grub-core/gnulib/c++defs.h ++grub-core/gnulib/charset.alias ++grub-core/gnulib/configmake.h ++grub-core/gnulib/float.h ++grub-core/gnulib/getopt.h ++grub-core/gnulib/langinfo.h ++grub-core/gnulib/locale.h ++grub-core/gnulib/ref-add.sed ++grub-core/gnulib/ref-del.sed ++grub-core/gnulib/stdio.h ++grub-core/gnulib/stdlib.h ++grub-core/gnulib/string.h ++grub-core/gnulib/strings.h ++grub-core/gnulib/sys ++grub-core/gnulib/unistd.h ++grub-core/gnulib/unitypes.h ++grub-core/gnulib/uniwidth.h ++grub-core/gnulib/warn-on-use.h ++grub-core/gnulib/wchar.h ++grub-core/gnulib/wctype.h ++grub-core/grub.chrp ++grub-core/kernel.img.bin ++grub-core/lib/libgcrypt-grub ++grub-core/modinfo.sh ++grub-core/rs_decoder.h ++grub-editenv ++grub-emu ++grub-emu-lite ++grub-file ++grub-fs-tester ++grub-fstest ++grub-glue-efi ++grub-install ++grub-kbdcomp ++grub-macbless ++grub-macho2img ++grub-menulst2cfg ++grub-mk* ++grub-mount ++grub-ofpathname ++grub-probe ++grub-reboot ++grub-render-label ++grub-script-check ++grub-set-default ++grub-shell ++grub-shell-tester ++grub-sparc64-setup ++grub-syslinux2cfg + grub_cmd_date + grub_cmd_echo + grub_cmd_regexp + grub_cmd_set_date + grub_cmd_sleep +-/grub-editenv +-/grub-editenv.exe +-grub-emu +-grub-emu-lite +-grub-emu.exe +-grub-emu-lite.exe + grub_emu_init.c + grub_emu_init.h +-/grub-file +-/grub-file.exe +-grub-fstest +-grub-fstest.exe + grub_fstest_init.c + grub_fstest_init.h + grub_func_test +-grub-install +-grub-install.exe +-grub-kbdcomp +-/grub-macbless +-/grub-macbless.exe +-grub-macho2img +-/grub-menulst2cfg +-/grub-menulst2cfg.exe +-/grub-mk* +-grub-mount +-/grub-ofpathname +-/grub-ofpathname.exe +-grub-core/build-grub-pe2elf.exe +-/grub-probe +-/grub-probe.exe + grub_probe_init.c + grub_probe_init.h +-/grub-reboot ++grub_script.tab.c ++grub_script.tab.h ++grub_script.yy.c ++grub_script.yy.h + grub_script_blanklines + grub_script_blockarg + grub_script_break +-grub-script-check +-grub-script-check.exe + grub_script_check_init.c + grub_script_check_init.h + grub_script_comments +@@ -113,136 +174,50 @@ grub_script_strcmp + grub_script_test + grub_script_vars1 + grub_script_while1 +-grub_script.tab.c +-grub_script.tab.h +-grub_script.yy.c +-grub_script.yy.h +-grub-set-default + grub_setup_init.c + grub_setup_init.h +-grub-shell +-grub-shell-tester +-grub-sparc64-setup +-grub-sparc64-setup.exe +-/grub-syslinux2cfg +-/grub-syslinux2cfg.exe + gzcompress_test + hddboot_test + help_test +-*.img +-*.image +-*.image.exe + include/grub/cpu ++include/grub/gcrypt/g10lib.h ++include/grub/gcrypt/gcrypt.h + include/grub/machine + install-sh + lib/libgcrypt-grub + libgrub_a_init.c +-*.log +-*.lst + lzocompress_test +-*.marker +-Makefile +-*.mod +-mod-*.c ++mdate-sh + missing ++mod-*.c + netboot_test +-*.o +-*.a + ohci_test + partmap_test + pata_test +-*.pf2 +-*.pp ++po/*.gmo + po/*.mo +-po/grub.pot ++po/*.po ++po/LINGUAS + po/POTFILES ++po/POTFILES-shell.in ++po/POTFILES.in ++po/grub.pot ++po/remove-potcdate.sed + po/stamp-po + printf_test + priority_queue_unit_test + pseries_test + stamp-h +-stamp-h1 + stamp-h.in ++stamp-h1 + symlist.c + symlist.h ++texinfo.tex + trigtables.c +-*.trs + uhci_test +-update-grub_lib + unidata.c +-xzcompress_test +-Makefile.in +-GPATH +-GRTAGS +-GSYMS +-GTAGS +-compile +-depcomp +-mdate-sh +-texinfo.tex +-grub-core/lib/libgcrypt-grub +-.deps +-.deps-util +-.deps-core +-.dirstamp +-Makefile.util.am +-contrib +-grub-core/bootinfo.txt +-grub-core/Makefile.core.am +-grub-core/Makefile.gcry.def +-grub-core/contrib +-grub-core/gdb_grub +-grub-core/genmod.sh +-grub-core/gensyminfo.sh +-grub-core/gmodule.pl +-grub-core/grub.chrp +-grub-core/modinfo.sh +-grub-core/*.module +-grub-core/*.module.exe +-grub-core/*.pp +-grub-core/kernel.img.bin ++update-grub_lib + util/bash-completion.d/grub +-grub-core/gnulib/alloca.h +-grub-core/gnulib/arg-nonnull.h +-grub-core/gnulib/c++defs.h +-grub-core/gnulib/charset.alias +-grub-core/gnulib/configmake.h +-grub-core/gnulib/float.h +-grub-core/gnulib/getopt.h +-grub-core/gnulib/langinfo.h +-grub-core/gnulib/ref-add.sed +-grub-core/gnulib/ref-del.sed +-grub-core/gnulib/stdio.h +-grub-core/gnulib/stdlib.h +-grub-core/gnulib/string.h +-grub-core/gnulib/strings.h +-grub-core/gnulib/sys +-grub-core/gnulib/unistd.h +-grub-core/gnulib/warn-on-use.h +-grub-core/gnulib/wchar.h +-grub-core/gnulib/wctype.h +-grub-core/rs_decoder.h + widthspec.bin + widthspec.h +-docs/stamp-1 +-docs/version-dev.texi +-Makefile.utilgcry.def +-po/*.po +-po/*.gmo +-po/LINGUAS +-po/remove-potcdate.sed +-include/grub/gcrypt/gcrypt.h +-include/grub/gcrypt/g10lib.h +-po/POTFILES.in +-po/POTFILES-shell.in +-/grub-glue-efi +-/grub-render-label +-/grub-glue-efi.exe +-/grub-render-label.exe +-grub-core/gnulib/locale.h +-grub-core/gnulib/unitypes.h +-grub-core/gnulib/uniwidth.h +-build-aux/test-driver +-/garbage-gen +-/garbage-gen.exe +-/grub-fs-tester ++xzcompress_test +-- +2.14.3 + diff --git a/0021-Honor-a-symlink-when-generating-configuration-by-gru.patch b/0021-Honor-a-symlink-when-generating-configuration-by-gru.patch new file mode 100644 index 0000000..e5c1138 --- /dev/null +++ b/0021-Honor-a-symlink-when-generating-configuration-by-gru.patch @@ -0,0 +1,29 @@ +From 7f1ea377390345b8ef7609ad0fa2952708b17e19 Mon Sep 17 00:00:00 2001 +From: Marcel Kolaja +Date: Tue, 21 Jan 2014 10:57:08 -0500 +Subject: [PATCH 021/123] Honor a symlink when generating configuration by + grub2-mkconfig + +Honor a symlink when generating configuration by grub2-mkconfig, so that +the -o option follows it rather than overwriting it with a regular file. +--- + util/grub-mkconfig.in | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index f8496d28b..3b070fd76 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -276,7 +276,8 @@ and /etc/grub.d/* files or please file a bug report with + exit 1 + else + # none of the children aborted with error, install the new grub.cfg +- mv -f ${grub_cfg}.new ${grub_cfg} ++ cat ${grub_cfg}.new > ${grub_cfg} ++ rm -f ${grub_cfg}.new + fi + fi + +-- +2.14.3 + diff --git a/0021-Use-linuxefi-and-initrdefi-where-appropriate.patch b/0021-Use-linuxefi-and-initrdefi-where-appropriate.patch deleted file mode 100644 index 1af6eb2..0000000 --- a/0021-Use-linuxefi-and-initrdefi-where-appropriate.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 5894e3bfaf055554c786b4c1a9452d4e3bb9f568 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 16 Jul 2012 18:57:11 -0400 -Subject: [PATCH 21/90] Use "linuxefi" and "initrdefi" where appropriate. - ---- - util/grub.d/10_linux.in | 18 ++++++++++++++++-- - 1 file changed, 16 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index cf6331f..8ccf012 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -129,17 +129,31 @@ linux_entry () - printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" - fi - message="$(gettext_printf "Loading Linux %s ..." ${version})" -- sed "s/^/$submenu_indentation/" << EOF -+ if [ -d /sys/firmware/efi ]; then -+ sed "s/^/$submenu_indentation/" << EOF -+ echo '$(echo "$message" | grub_quote)' -+ linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} -+EOF -+ else -+ sed "s/^/$submenu_indentation/" << EOF - echo '$(echo "$message" | grub_quote)' - linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} - EOF -+ fi - if test -n "${initrd}" ; then - # TRANSLATORS: ramdisk isn't identifier. Should be translated. - message="$(gettext_printf "Loading initial ramdisk ...")" -- sed "s/^/$submenu_indentation/" << EOF -+ if [ -d /sys/firmware/efi ]; then -+ sed "s/^/$submenu_indentation/" << EOF - echo '$(echo "$message" | grub_quote)' -+ initrdefi ${rel_dirname}/${initrd} -+EOF -+ else -+ sed "s/^/$submenu_indentation/" << EOF -+ echo '$message' - initrd ${rel_dirname}/${initrd} - EOF -+ fi - fi - sed "s/^/$submenu_indentation/" << EOF - } --- -2.9.3 - diff --git a/0022-Don-t-allow-insmod-when-secure-boot-is-enabled.patch b/0022-Don-t-allow-insmod-when-secure-boot-is-enabled.patch deleted file mode 100644 index 4ff26a8..0000000 --- a/0022-Don-t-allow-insmod-when-secure-boot-is-enabled.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 9d70f7f9a356d965ed48963e2ead12af8de97615 Mon Sep 17 00:00:00 2001 -From: Colin Watson -Date: Tue, 23 Oct 2012 10:40:49 -0400 -Subject: [PATCH 22/90] Don't allow insmod when secure boot is enabled. - -Hi, - -Fedora's patch to forbid insmod in UEFI Secure Boot environments is fine -as far as it goes. However, the insmod command is not the only way that -modules can be loaded. In particular, the 'normal' command, which -implements the usual GRUB menu and the fully-featured command prompt, -will implicitly load commands not currently loaded into memory. This -permits trivial Secure Boot violations by writing commands implementing -whatever you want to do and pointing $prefix at the malicious code. - -I'm currently test-building this patch (replacing your current -grub-2.00-no-insmod-on-sb.patch), but this should be more correct. It -moves the check into grub_dl_load_file. ---- - grub-core/kern/dl.c | 22 ++++++++++++++++++++++ - grub-core/kern/efi/efi.c | 28 ++++++++++++++++++++++++++++ - include/grub/efi/efi.h | 1 + - 3 files changed, 51 insertions(+) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index e394cd9..6210709 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -32,12 +32,21 @@ - #include - #include - #include -+#include - - /* Platforms where modules are in a readonly area of memory. */ - #if defined(GRUB_MACHINE_QEMU) - #define GRUB_MODULES_MACHINE_READONLY - #endif - -+#ifdef GRUB_MACHINE_EMU -+#include -+#endif -+ -+#ifdef GRUB_MACHINE_EFI -+#include -+#endif -+ - - - #pragma GCC diagnostic ignored "-Wcast-align" -@@ -686,6 +695,19 @@ grub_dl_load_file (const char *filename) - void *core = 0; - grub_dl_t mod = 0; - -+#ifdef GRUB_MACHINE_EFI -+ if (grub_efi_secure_boot ()) -+ { -+#if 0 -+ /* This is an error, but grub2-mkconfig still generates a pile of -+ * insmod commands, so emitting it would be mostly just obnoxious. */ -+ grub_error (GRUB_ERR_ACCESS_DENIED, -+ "Secure Boot forbids loading module from %s", filename); -+#endif -+ return 0; -+ } -+#endif -+ - grub_boot_time ("Loading module %s", filename); - - file = grub_file_open (filename); -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 101307f..0859910 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -269,6 +269,34 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - return NULL; - } - -+grub_efi_boolean_t -+grub_efi_secure_boot (void) -+{ -+ grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; -+ grub_size_t datasize; -+ char *secure_boot = NULL; -+ char *setup_mode = NULL; -+ grub_efi_boolean_t ret = 0; -+ -+ secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -+ -+ if (datasize != 1 || !secure_boot) -+ goto out; -+ -+ setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -+ -+ if (datasize != 1 || !setup_mode) -+ goto out; -+ -+ if (*secure_boot && !*setup_mode) -+ ret = 1; -+ -+ out: -+ grub_free (secure_boot); -+ grub_free (setup_mode); -+ return ret; -+} -+ - #pragma GCC diagnostic ignored "-Wcast-align" - - /* Search the mods section from the PE32/PE32+ image. This code uses -diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 9a2da0e..2245632 100644 ---- a/include/grub/efi/efi.h -+++ b/include/grub/efi/efi.h -@@ -76,6 +76,7 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, - const grub_efi_guid_t *guid, - void *data, - grub_size_t datasize); -+grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void); - int - EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, - const grub_efi_device_path_t *dp2); --- -2.9.3 - diff --git a/0022-Move-bash-completion-script-922997.patch b/0022-Move-bash-completion-script-922997.patch new file mode 100644 index 0000000..1103001 --- /dev/null +++ b/0022-Move-bash-completion-script-922997.patch @@ -0,0 +1,55 @@ +From 5b77e510eb6e4b649c53ab0790cdc9fdf0c85be9 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 3 Apr 2013 14:35:34 -0400 +Subject: [PATCH 022/123] Move bash completion script (#922997) + +Apparently these go in a new place now. +--- + configure.ac | 11 +++++++++++ + util/bash-completion.d/Makefile.am | 1 - + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 9ddfc5323..ab9134c86 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -287,6 +287,14 @@ AC_SUBST(grubdirname) + AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", + [Default grub directory name]) + ++PKG_PROG_PKG_CONFIG ++AS_IF([$($PKG_CONFIG --exists bash-completion)], [ ++ bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion) ++] , [ ++ bashcompletiondir=${datadir}/bash-completion/completions ++]) ++AC_SUBST(bashcompletiondir) ++ + # + # Checks for build programs. + # +@@ -476,6 +484,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" + # Check for target programs. + # + ++# This makes sure pkg.m4 is available. ++m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config]) ++ + # Find tools for the target. + if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then + tmp_ac_tool_prefix="$ac_tool_prefix" +diff --git a/util/bash-completion.d/Makefile.am b/util/bash-completion.d/Makefile.am +index 136287cf1..61108f054 100644 +--- a/util/bash-completion.d/Makefile.am ++++ b/util/bash-completion.d/Makefile.am +@@ -6,7 +6,6 @@ EXTRA_DIST = $(bash_completion_source) + + CLEANFILES = $(bash_completion_script) config.log + +-bashcompletiondir = $(sysconfdir)/bash_completion.d + bashcompletion_DATA = $(bash_completion_script) + + $(bash_completion_script): $(bash_completion_source) $(top_builddir)/config.status +-- +2.14.3 + diff --git a/0023-Pass-x-hex-hex-straight-through-unmolested.patch b/0023-Pass-x-hex-hex-straight-through-unmolested.patch deleted file mode 100644 index ac6cd8b..0000000 --- a/0023-Pass-x-hex-hex-straight-through-unmolested.patch +++ /dev/null @@ -1,183 +0,0 @@ -From c2a19ee447623af8765254b87ff83cbb5b8253bc Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 1 Oct 2012 13:24:37 -0400 -Subject: [PATCH 23/90] Pass "\x[[:hex:]][[:hex:]]" straight through - unmolested. - ---- - grub-core/commands/wildcard.c | 16 +++++++++++++++- - grub-core/lib/cmdline.c | 34 ++++++++++++++++++++++++++++++++-- - grub-core/script/execute.c | 43 +++++++++++++++++++++++++++++++++++++------ - 3 files changed, 84 insertions(+), 9 deletions(-) - -diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c -index 9b4e727..02c46f9 100644 ---- a/grub-core/commands/wildcard.c -+++ b/grub-core/commands/wildcard.c -@@ -462,6 +462,12 @@ check_file (const char *dir, const char *basename) - return ctx.found; - } - -+static int -+is_hex(char c) -+{ -+ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); -+} -+ - static void - unescape (char *out, const char *in, const char *end) - { -@@ -470,7 +476,15 @@ unescape (char *out, const char *in, const char *end) - - for (optr = out, iptr = in; iptr < end;) - { -- if (*iptr == '\\' && iptr + 1 < end) -+ if (*iptr == '\\' && iptr + 3 < end && iptr[1] == 'x' && is_hex(iptr[2]) && is_hex(iptr[3])) -+ { -+ *optr++ = *iptr++; -+ *optr++ = *iptr++; -+ *optr++ = *iptr++; -+ *optr++ = *iptr++; -+ continue; -+ } -+ else if (*iptr == '\\' && iptr + 1 < end) - { - *optr++ = iptr[1]; - iptr += 2; -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index d5e10ee..0a5b2af 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -20,6 +20,12 @@ - #include - #include - -+static int -+is_hex(char c) -+{ -+ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); -+} -+ - static unsigned int check_arg (char *c, int *has_space) - { - int space = 0; -@@ -27,7 +33,13 @@ static unsigned int check_arg (char *c, int *has_space) - - while (*c) - { -- if (*c == '\\' || *c == '\'' || *c == '"') -+ if (*c == '\\' && *(c+1) == 'x' && is_hex(*(c+2)) && is_hex(*(c+3))) -+ { -+ size += 4; -+ c += 4; -+ continue; -+ } -+ else if (*c == '\\' || *c == '\'' || *c == '"') - size++; - else if (*c == ' ') - space = 1; -@@ -85,7 +97,25 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - while (*c) - { -- if (*c == '\\' || *c == '\'' || *c == '"') -+ if (*c == ' ') -+ { -+ *buf++ = '\\'; -+ *buf++ = 'x'; -+ *buf++ = '2'; -+ *buf++ = '0'; -+ c++; -+ continue; -+ } -+ else if (*c == '\\' && *(c+1) == 'x' && -+ is_hex(*(c+2)) && is_hex(*(c+3))) -+ { -+ *buf++ = *c++; -+ *buf++ = *c++; -+ *buf++ = *c++; -+ *buf++ = *c++; -+ continue; -+ } -+ else if (*c == '\\' || *c == '\'' || *c == '"') - *buf++ = '\\'; - - *buf++ = *c; -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index ab78ca8..cf6cd66 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -55,6 +55,12 @@ static struct grub_script_scope *scope = 0; - /* Wildcard translator for GRUB script. */ - struct grub_script_wildcard_translator *grub_wildcard_translator; - -+static int -+is_hex(char c) -+{ -+ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); -+} -+ - static char* - wildcard_escape (const char *s) - { -@@ -71,7 +77,15 @@ wildcard_escape (const char *s) - i = 0; - while ((ch = *s++)) - { -- if (ch == '*' || ch == '\\' || ch == '?') -+ if (ch == '\\' && s[0] == 'x' && is_hex(s[1]) && is_hex(s[2])) -+ { -+ p[i++] = ch; -+ p[i++] = *s++; -+ p[i++] = *s++; -+ p[i++] = *s++; -+ continue; -+ } -+ else if (ch == '*' || ch == '\\' || ch == '?') - p[i++] = '\\'; - p[i++] = ch; - } -@@ -95,7 +109,14 @@ wildcard_unescape (const char *s) - i = 0; - while ((ch = *s++)) - { -- if (ch == '\\') -+ if (ch == '\\' && s[0] == 'x' && is_hex(s[1]) && is_hex(s[2])) -+ { -+ p[i++] = '\\'; -+ p[i++] = *s++; -+ p[i++] = *s++; -+ p[i++] = *s++; -+ } -+ else if (ch == '\\') - p[i++] = *s++; - else - p[i++] = ch; -@@ -397,10 +418,20 @@ parse_string (const char *str, - switch (*ptr) - { - case '\\': -- escaped = !escaped; -- if (!escaped && put) -- *(put++) = '\\'; -- ptr++; -+ if (!escaped && put && *(ptr+1) == 'x' && is_hex(*(ptr+2)) && is_hex(*(ptr+3))) -+ { -+ *(put++) = *ptr++; -+ *(put++) = *ptr++; -+ *(put++) = *ptr++; -+ *(put++) = *ptr++; -+ } -+ else -+ { -+ escaped = !escaped; -+ if (!escaped && put) -+ *(put++) = '\\'; -+ ptr++; -+ } - break; - case '$': - if (escaped) --- -2.9.3 - diff --git a/0023-Update-to-minilzo-2.08.patch b/0023-Update-to-minilzo-2.08.patch new file mode 100644 index 0000000..23a9aba --- /dev/null +++ b/0023-Update-to-minilzo-2.08.patch @@ -0,0 +1,8790 @@ +From 579ecb682efc5221b4a13b8009af1731f5349912 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 4 Dec 2014 15:36:09 -0500 +Subject: [PATCH 023/123] Update to minilzo-2.08 + +This fixes CVE-2014-4607 - lzo: lzo1x_decompress_safe() integer overflow + +Signed-off-by: Peter Jones +--- + grub-core/lib/minilzo/lzoconf.h | 216 ++- + grub-core/lib/minilzo/lzodefs.h | 2450 +++++++++++++++++------- + grub-core/lib/minilzo/minilzo.c | 3953 +++++++++++++++++++++++++++------------ + grub-core/lib/minilzo/minilzo.h | 21 +- + 4 files changed, 4630 insertions(+), 2010 deletions(-) + +diff --git a/grub-core/lib/minilzo/lzoconf.h b/grub-core/lib/minilzo/lzoconf.h +index 1d0fe14fc..61be29c5d 100644 +--- a/grub-core/lib/minilzo/lzoconf.h ++++ b/grub-core/lib/minilzo/lzoconf.h +@@ -2,22 +2,7 @@ + + This file is part of the LZO real-time data compression library. + +- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ++ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or +@@ -44,9 +29,9 @@ + #ifndef __LZOCONF_H_INCLUDED + #define __LZOCONF_H_INCLUDED 1 + +-#define LZO_VERSION 0x2050 +-#define LZO_VERSION_STRING "2.05" +-#define LZO_VERSION_DATE "Apr 23 2011" ++#define LZO_VERSION 0x2080 ++#define LZO_VERSION_STRING "2.08" ++#define LZO_VERSION_DATE "Jun 29 2014" + + /* internal Autoconf configuration file - only used when building LZO */ + #if defined(LZO_HAVE_CONFIG_H) +@@ -63,7 +48,7 @@ + #if !defined(CHAR_BIT) || (CHAR_BIT != 8) + # error "invalid CHAR_BIT" + #endif +-#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) ++#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) + # error "check your compiler installation" + #endif + #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) +@@ -85,14 +70,6 @@ extern "C" { + // some core defines + ************************************************************************/ + +-#if !defined(LZO_UINT32_C) +-# if (UINT_MAX < LZO_0xffffffffL) +-# define LZO_UINT32_C(c) c ## UL +-# else +-# define LZO_UINT32_C(c) ((c) + 0U) +-# endif +-#endif +- + /* memory checkers */ + #if !defined(__LZO_CHECKER) + # if defined(__BOUNDS_CHECKING_ON) +@@ -111,28 +88,31 @@ extern "C" { + // integral and pointer types + ************************************************************************/ + +-/* lzo_uint should match size_t */ ++/* lzo_uint must match size_t */ + #if !defined(LZO_UINT_MAX) +-# if defined(LZO_ABI_LLP64) /* WIN64 */ +-# if defined(LZO_OS_WIN64) ++# if (LZO_ABI_LLP64) ++# if (LZO_OS_WIN64) + typedef unsigned __int64 lzo_uint; + typedef __int64 lzo_int; + # else +- typedef unsigned long long lzo_uint; +- typedef long long lzo_int; ++ typedef lzo_ullong_t lzo_uint; ++ typedef lzo_llong_t lzo_int; + # endif ++# define LZO_SIZEOF_LZO_UINT 8 + # define LZO_UINT_MAX 0xffffffffffffffffull + # define LZO_INT_MAX 9223372036854775807LL + # define LZO_INT_MIN (-1LL - LZO_INT_MAX) +-# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ ++# elif (LZO_ABI_IP32L64) /* MIPS R5900 */ + typedef unsigned int lzo_uint; + typedef int lzo_int; ++# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT + # define LZO_UINT_MAX UINT_MAX + # define LZO_INT_MAX INT_MAX + # define LZO_INT_MIN INT_MIN + # elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint; + typedef long lzo_int; ++# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG + # define LZO_UINT_MAX ULONG_MAX + # define LZO_INT_MAX LONG_MAX + # define LZO_INT_MIN LONG_MIN +@@ -141,63 +121,22 @@ extern "C" { + # endif + #endif + +-/* Integral types with 32 bits or more. */ +-#if !defined(LZO_UINT32_MAX) +-# if (UINT_MAX >= LZO_0xffffffffL) +- typedef unsigned int lzo_uint32; +- typedef int lzo_int32; +-# define LZO_UINT32_MAX UINT_MAX +-# define LZO_INT32_MAX INT_MAX +-# define LZO_INT32_MIN INT_MIN +-# elif (ULONG_MAX >= LZO_0xffffffffL) +- typedef unsigned long lzo_uint32; +- typedef long lzo_int32; +-# define LZO_UINT32_MAX ULONG_MAX +-# define LZO_INT32_MAX LONG_MAX +-# define LZO_INT32_MIN LONG_MIN +-# else +-# error "lzo_uint32" +-# endif +-#endif +- +-/* Integral types with exactly 64 bits. */ +-#if !defined(LZO_UINT64_MAX) +-# if (LZO_UINT_MAX >= LZO_0xffffffffL) +-# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) +-# define lzo_uint64 lzo_uint +-# define lzo_int64 lzo_int +-# define LZO_UINT64_MAX LZO_UINT_MAX +-# define LZO_INT64_MAX LZO_INT_MAX +-# define LZO_INT64_MIN LZO_INT_MIN +-# endif +-# elif (ULONG_MAX >= LZO_0xffffffffL) +-# if ((((ULONG_MAX) >> 31) >> 31) == 3) +- typedef unsigned long lzo_uint64; +- typedef long lzo_int64; +-# define LZO_UINT64_MAX ULONG_MAX +-# define LZO_INT64_MAX LONG_MAX +-# define LZO_INT64_MIN LONG_MIN +-# endif +-# endif +-#endif +- +-/* The larger type of lzo_uint and lzo_uint32. */ +-#if (LZO_UINT_MAX >= LZO_UINT32_MAX) ++/* The larger type of lzo_uint and lzo_uint32_t. */ ++#if (LZO_SIZEOF_LZO_UINT >= 4) + # define lzo_xint lzo_uint + #else +-# define lzo_xint lzo_uint32 ++# define lzo_xint lzo_uint32_t + #endif + +-/* Memory model that allows to access memory at offsets of lzo_uint. */ +-#if !defined(__LZO_MMODEL) +-# if (LZO_UINT_MAX <= UINT_MAX) +-# define __LZO_MMODEL /*empty*/ +-# elif defined(LZO_HAVE_MM_HUGE_PTR) +-# define __LZO_MMODEL_HUGE 1 +-# define __LZO_MMODEL __huge +-# else +-# define __LZO_MMODEL /*empty*/ +-# endif ++typedef int lzo_bool; ++ ++/* sanity checks */ ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) ++ ++#ifndef __LZO_MMODEL ++#define __LZO_MMODEL /*empty*/ + #endif + + /* no typedef here because of const-pointer issues */ +@@ -206,21 +145,52 @@ extern "C" { + #define lzo_voidp void __LZO_MMODEL * + #define lzo_shortp short __LZO_MMODEL * + #define lzo_ushortp unsigned short __LZO_MMODEL * +-#define lzo_uint32p lzo_uint32 __LZO_MMODEL * +-#define lzo_int32p lzo_int32 __LZO_MMODEL * +-#if defined(LZO_UINT64_MAX) +-#define lzo_uint64p lzo_uint64 __LZO_MMODEL * +-#define lzo_int64p lzo_int64 __LZO_MMODEL * +-#endif +-#define lzo_uintp lzo_uint __LZO_MMODEL * + #define lzo_intp lzo_int __LZO_MMODEL * ++#define lzo_uintp lzo_uint __LZO_MMODEL * + #define lzo_xintp lzo_xint __LZO_MMODEL * + #define lzo_voidpp lzo_voidp __LZO_MMODEL * + #define lzo_bytepp lzo_bytep __LZO_MMODEL * +-/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ +-#define lzo_byte unsigned char __LZO_MMODEL + +-typedef int lzo_bool; ++#define lzo_int8_tp lzo_int8_t __LZO_MMODEL * ++#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * ++#define lzo_int16_tp lzo_int16_t __LZO_MMODEL * ++#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * ++#define lzo_int32_tp lzo_int32_t __LZO_MMODEL * ++#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * ++#if defined(lzo_int64_t) ++#define lzo_int64_tp lzo_int64_t __LZO_MMODEL * ++#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * ++#endif ++ ++/* Older LZO versions used to support ancient systems and memory models ++ * like 16-bit MSDOS with __huge pointers and Cray PVP, but these ++ * obsolete configurations are not supported any longer. ++ */ ++#if defined(__LZO_MMODEL_HUGE) ++#error "__LZO_MMODEL_HUGE is unsupported" ++#endif ++#if (LZO_MM_PVP) ++#error "LZO_MM_PVP is unsupported" ++#endif ++#if (LZO_SIZEOF_INT < 4) ++#error "LZO_SIZEOF_INT < 4 is unsupported" ++#endif ++#if (__LZO_UINTPTR_T_IS_POINTER) ++#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) ++/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should ++ * work but have not received much testing lately, so be strict here. ++ */ ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) + + + /*********************************************************************** +@@ -315,7 +285,7 @@ struct lzo_callback_t + /* a progress indicator callback function (set to 0 to disable) */ + lzo_progress_func_t nprogress; + +- /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress ++ /* INFO: the first parameter "self" of the nalloc/nfree/nprogress + * callbacks points back to this struct, so you are free to store + * some extra info in the following variables. */ + lzo_voidp user1; +@@ -343,6 +313,9 @@ struct lzo_callback_t + #define LZO_E_INPUT_NOT_CONSUMED (-8) + #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ + #define LZO_E_INVALID_ARGUMENT (-10) ++#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ ++#define LZO_E_OUTPUT_NOT_CONSUMED (-12) ++#define LZO_E_INTERNAL_ERROR (-99) + + + #ifndef lzo_sizeof_dict_t +@@ -356,7 +329,7 @@ struct lzo_callback_t + * compiler's view of various types are consistent. + */ + #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ +- (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ ++ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ + (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ + (int)sizeof(lzo_callback_t)) + LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); +@@ -379,18 +352,22 @@ LZO_EXTERN(lzo_voidp) + lzo_memset(lzo_voidp buf, int c, lzo_uint len); + + /* checksum functions */ +-LZO_EXTERN(lzo_uint32) +- lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); +-LZO_EXTERN(lzo_uint32) +- lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); +-LZO_EXTERN(const lzo_uint32p) ++LZO_EXTERN(lzo_uint32_t) ++ lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); ++LZO_EXTERN(lzo_uint32_t) ++ lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); ++LZO_EXTERN(const lzo_uint32_tp) + lzo_get_crc32_table(void); + + /* misc. */ + LZO_EXTERN(int) _lzo_config_check(void); +-typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; +-typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; +-typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; ++typedef union { ++ lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; ++ void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; ++#if defined(lzo_int64_t) ++ lzo_uint64_t a10; ++#endif ++} lzo_align_t; + + /* align a char pointer on a boundary that is a multiple of 'size' */ + LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); +@@ -399,9 +376,30 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); + + + /*********************************************************************** +-// deprecated macros - only for backward compatibility with LZO v1.xx ++// deprecated macros - only for backward compatibility + ************************************************************************/ + ++/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ ++#define lzo_byte unsigned char ++/* deprecated type names */ ++#define lzo_int32 lzo_int32_t ++#define lzo_uint32 lzo_uint32_t ++#define lzo_int32p lzo_int32_t __LZO_MMODEL * ++#define lzo_uint32p lzo_uint32_t __LZO_MMODEL * ++#define LZO_INT32_MAX LZO_INT32_C(2147483647) ++#define LZO_UINT32_MAX LZO_UINT32_C(4294967295) ++#if defined(lzo_int64_t) ++#define lzo_int64 lzo_int64_t ++#define lzo_uint64 lzo_uint64_t ++#define lzo_int64p lzo_int64_t __LZO_MMODEL * ++#define lzo_uint64p lzo_uint64_t __LZO_MMODEL * ++#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) ++#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) ++#endif ++/* deprecated types */ ++typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; ++typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; ++ + #if defined(LZO_CFG_COMPAT) + + #define __LZOCONF_H 1 +@@ -443,4 +441,4 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); + #endif /* already included */ + + +-/* vim:set ts=4 et: */ ++/* vim:set ts=4 sw=4 et: */ +diff --git a/grub-core/lib/minilzo/lzodefs.h b/grub-core/lib/minilzo/lzodefs.h +index 0e40e332a..f4ae9487e 100644 +--- a/grub-core/lib/minilzo/lzodefs.h ++++ b/grub-core/lib/minilzo/lzodefs.h +@@ -2,22 +2,7 @@ + + This file is part of the LZO real-time data compression library. + +- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ++ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or +@@ -47,12 +32,6 @@ + #if defined(__CYGWIN32__) && !defined(__CYGWIN__) + # define __CYGWIN__ __CYGWIN32__ + #endif +-#if defined(__IBMCPP__) && !defined(__IBMC__) +-# define __IBMC__ __IBMCPP__ +-#endif +-#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) +-# define __INTEL_COMPILER __ICL +-#endif + #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) + # define _ALL_SOURCE 1 + #endif +@@ -61,19 +40,30 @@ + # define __LONG_MAX__ 9223372036854775807L + # endif + #endif +-#if defined(__INTEL_COMPILER) && defined(__linux__) ++#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) ++#if defined(__ARMCC_VERSION) ++# pragma diag_suppress 193 ++#elif defined(__clang__) && defined(__clang_minor__) ++# pragma clang diagnostic ignored "-Wundef" ++#elif defined(__INTEL_COMPILER) + # pragma warning(disable: 193) +-#endif +-#if defined(__KEIL__) && defined(__C166__) +-# pragma warning disable = 322 +-#elif 0 && defined(__C251__) ++#elif defined(__KEIL__) && defined(__C166__) + # pragma warning disable = 322 +-#endif +-#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +-# if (_MSC_VER >= 1300) ++#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) ++# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) ++# pragma GCC diagnostic ignored "-Wundef" ++# endif ++#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) ++# if ((_MSC_VER-0) >= 1300) + # pragma warning(disable: 4668) + # endif + #endif ++#endif ++#if 0 && defined(__POCC__) && defined(_WIN32) ++# if (__POCC__ >= 400) ++# pragma warn(disable: 2216) ++# endif ++#endif + #if 0 && defined(__WATCOMC__) + # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) + # pragma warning 203 9 +@@ -82,13 +72,29 @@ + #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) + # pragma option -h + #endif ++#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) ++#ifndef _CRT_NONSTDC_NO_DEPRECATE ++#define _CRT_NONSTDC_NO_DEPRECATE 1 ++#endif ++#ifndef _CRT_NONSTDC_NO_WARNINGS ++#define _CRT_NONSTDC_NO_WARNINGS 1 ++#endif ++#ifndef _CRT_SECURE_NO_DEPRECATE ++#define _CRT_SECURE_NO_DEPRECATE 1 ++#endif ++#ifndef _CRT_SECURE_NO_WARNINGS ++#define _CRT_SECURE_NO_WARNINGS 1 ++#endif ++#endif + #if 0 +-#define LZO_0xffffL 0xfffful +-#define LZO_0xffffffffL 0xfffffffful ++#define LZO_0xffffUL 0xfffful ++#define LZO_0xffffffffUL 0xfffffffful + #else +-#define LZO_0xffffL 65535ul +-#define LZO_0xffffffffL 4294967295ul ++#define LZO_0xffffUL 65535ul ++#define LZO_0xffffffffUL 4294967295ul + #endif ++#define LZO_0xffffL LZO_0xffffUL ++#define LZO_0xffffffffL LZO_0xffffffffUL + #if (LZO_0xffffL == LZO_0xffffffffL) + # error "your preprocessor is broken 1" + #endif +@@ -103,6 +109,13 @@ + # error "your preprocessor is broken 4" + #endif + #endif ++#if defined(__COUNTER__) ++# ifndef LZO_CFG_USE_COUNTER ++# define LZO_CFG_USE_COUNTER 1 ++# endif ++#else ++# undef LZO_CFG_USE_COUNTER ++#endif + #if (UINT_MAX == LZO_0xffffL) + #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) + # if !defined(MSDOS) +@@ -233,14 +246,31 @@ + #endif + #define LZO_PP_STRINGIZE(x) #x + #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) ++#define LZO_PP_CONCAT0() /*empty*/ ++#define LZO_PP_CONCAT1(a) a + #define LZO_PP_CONCAT2(a,b) a ## b + #define LZO_PP_CONCAT3(a,b,c) a ## b ## c + #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d + #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e ++#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f ++#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g ++#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() ++#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) + #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) + #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) + #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) + #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) ++#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) ++#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) ++#define LZO_PP_EMPTY /*empty*/ ++#define LZO_PP_EMPTY0() /*empty*/ ++#define LZO_PP_EMPTY1(a) /*empty*/ ++#define LZO_PP_EMPTY2(a,b) /*empty*/ ++#define LZO_PP_EMPTY3(a,b,c) /*empty*/ ++#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ ++#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ ++#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ ++#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ + #if 1 + #define LZO_CPP_STRINGIZE(x) #x + #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) +@@ -248,12 +278,16 @@ + #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c + #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d + #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e ++#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f ++#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g + #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) + #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) + #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) + #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) ++#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) ++#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) + #endif +-#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) ++#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) + #if 1 && defined(__cplusplus) + # if !defined(__STDC_CONSTANT_MACROS) + # define __STDC_CONSTANT_MACROS 1 +@@ -263,9 +297,13 @@ + # endif + #endif + #if defined(__cplusplus) +-# define LZO_EXTERN_C extern "C" ++# define LZO_EXTERN_C extern "C" ++# define LZO_EXTERN_C_BEGIN extern "C" { ++# define LZO_EXTERN_C_END } + #else +-# define LZO_EXTERN_C extern ++# define LZO_EXTERN_C extern ++# define LZO_EXTERN_C_BEGIN /*empty*/ ++# define LZO_EXTERN_C_END /*empty*/ + #endif + #if !defined(__LZO_OS_OVERRIDE) + #if (LZO_OS_FREESTANDING) +@@ -366,12 +404,12 @@ + #elif defined(__VMS) + # define LZO_OS_VMS 1 + # define LZO_INFO_OS "vms" +-#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) + # define LZO_OS_CONSOLE 1 + # define LZO_OS_CONSOLE_PS2 1 + # define LZO_INFO_OS "console" + # define LZO_INFO_OS_CONSOLE "ps2" +-#elif (defined(__mips__) && defined(__psp__)) ++#elif defined(__mips__) && defined(__psp__) + # define LZO_OS_CONSOLE 1 + # define LZO_OS_CONSOLE_PSP 1 + # define LZO_INFO_OS "console" +@@ -399,9 +437,18 @@ + # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) + # define LZO_OS_POSIX_LINUX 1 + # define LZO_INFO_OS_POSIX "linux" +-# elif defined(__APPLE__) || defined(__MACOS__) +-# define LZO_OS_POSIX_MACOSX 1 +-# define LZO_INFO_OS_POSIX "macosx" ++# elif defined(__APPLE__) && defined(__MACH__) ++# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) ++# define LZO_OS_POSIX_DARWIN 1040 ++# define LZO_INFO_OS_POSIX "darwin_iphone" ++# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) ++# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ ++# define LZO_INFO_OS_POSIX "darwin" ++# else ++# define LZO_OS_POSIX_DARWIN 1 ++# define LZO_INFO_OS_POSIX "darwin" ++# endif ++# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN + # elif defined(__minix__) || defined(__minix) + # define LZO_OS_POSIX_MINIX 1 + # define LZO_INFO_OS_POSIX "minix" +@@ -436,18 +483,18 @@ + #endif + #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + # if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (UINT_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) +@@ -463,59 +510,65 @@ + # define LZO_INFO_CC "sdcc" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) + #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) +-# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) ++# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) + # define LZO_INFO_CC "Pathscale C" + # define LZO_INFO_CCVER __PATHSCALE__ +-#elif defined(__INTEL_COMPILER) +-# define LZO_CC_INTELC 1 ++# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# endif ++#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) ++# define LZO_CC_INTELC __INTEL_COMPILER + # define LZO_INFO_CC "Intel C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) +-# if defined(_WIN32) || defined(_WIN64) +-# define LZO_CC_SYNTAX_MSC 1 +-# else +-# define LZO_CC_SYNTAX_GNUC 1 ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_INTELC_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # endif + #elif defined(__POCC__) && defined(_WIN32) + # define LZO_CC_PELLESC 1 + # define LZO_INFO_CC "Pelles C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) +-#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) + # if defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) ++# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # else +-# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) ++# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) + # endif ++# define LZO_CC_ARMCC __ARMCC_VERSION ++# define LZO_INFO_CC "ARM C Compiler" ++# define LZO_INFO_CCVER __VERSION__ ++#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) + # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) +-# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) ++# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) + # else +-# define LZO_CC_CLANG_CLANG 0x010000L ++# define LZO_CC_CLANG 0x010000L ++# endif ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_CLANG_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # endif +-# define LZO_CC_CLANG LZO_CC_CLANG_GNUC + # define LZO_INFO_CC "clang" + # define LZO_INFO_CCVER __VERSION__ + #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) + # if defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) ++# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # else +-# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) ++# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) + # endif + # define LZO_CC_LLVM LZO_CC_LLVM_GNUC + # define LZO_INFO_CC "llvm-gcc" + # define LZO_INFO_CCVER __VERSION__ +-#elif defined(__GNUC__) && defined(__VERSION__) +-# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +-# elif defined(__GNUC_MINOR__) +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +-# else +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L) +-# endif +-# define LZO_INFO_CC "gcc" +-# define LZO_INFO_CCVER __VERSION__ + #elif defined(__ACK__) && defined(_ACK) + # define LZO_CC_ACK 1 + # define LZO_INFO_CC "Amsterdam Compiler Kit C" + # define LZO_INFO_CCVER "unknown" ++#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) ++# define LZO_CC_ARMCC __ARMCC_VERSION ++# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION ++# define LZO_INFO_CC "ARM C Compiler" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) + #elif defined(__AZTEC_C__) + # define LZO_CC_AZTECC 1 + # define LZO_INFO_CC "Aztec C" +@@ -540,10 +593,23 @@ + # define LZO_CC_DECC 1 + # define LZO_INFO_CC "DEC C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) ++#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) ++# define LZO_CC_GHS 1 ++# define LZO_INFO_CC "Green Hills C" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_GHS_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# endif + #elif defined(__HIGHC__) + # define LZO_CC_HIGHC 1 + # define LZO_INFO_CC "MetaWare High C" + # define LZO_INFO_CCVER "unknown" ++#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) ++# define LZO_CC_HPACC __HP_aCC ++# define LZO_INFO_CC "HP aCC" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) + #elif defined(__IAR_SYSTEMS_ICC__) + # define LZO_CC_IARC 1 + # define LZO_INFO_CC "IAR C" +@@ -552,10 +618,14 @@ + # else + # define LZO_INFO_CCVER "unknown" + # endif +-#elif defined(__IBMC__) +-# define LZO_CC_IBMC 1 ++#elif defined(__IBMC__) && ((__IBMC__-0) > 0) ++# define LZO_CC_IBMC __IBMC__ + # define LZO_INFO_CC "IBM C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) ++#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) ++# define LZO_CC_IBMC __IBMCPP__ ++# define LZO_INFO_CC "IBM C" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) + #elif defined(__KEIL__) && defined(__C166__) + # define LZO_CC_KEILC 1 + # define LZO_INFO_CC "Keil C" +@@ -572,16 +642,8 @@ + # else + # define LZO_INFO_CCVER "unknown" + # endif +-#elif defined(_MSC_VER) +-# define LZO_CC_MSC 1 +-# define LZO_INFO_CC "Microsoft C" +-# if defined(_MSC_FULL_VER) +-# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) +-# else +-# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) +-# endif +-#elif defined(__MWERKS__) +-# define LZO_CC_MWERKS 1 ++#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) ++# define LZO_CC_MWERKS __MWERKS__ + # define LZO_INFO_CC "Metrowerks C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) + #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) +@@ -592,6 +654,15 @@ + # define LZO_CC_PACIFICC 1 + # define LZO_INFO_CC "Pacific C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) ++#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) ++# if defined(__PGIC_PATCHLEVEL__) ++# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) ++# else ++# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" ++# endif ++# define LZO_INFO_CC "Portland Group PGI C" + #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) + # define LZO_CC_PGI 1 + # define LZO_INFO_CC "Portland Group PGI C" +@@ -606,7 +677,7 @@ + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) + #elif defined(__SUNPRO_C) + # define LZO_INFO_CC "SunPro C" +-# if ((__SUNPRO_C)+0 > 0) ++# if ((__SUNPRO_C-0) > 0) + # define LZO_CC_SUNPROC __SUNPRO_C + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) + # else +@@ -615,7 +686,7 @@ + # endif + #elif defined(__SUNPRO_CC) + # define LZO_INFO_CC "SunPro C" +-# if ((__SUNPRO_CC)+0 > 0) ++# if ((__SUNPRO_CC-0) > 0) + # define LZO_CC_SUNPROC __SUNPRO_CC + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) + # else +@@ -641,16 +712,46 @@ + #elif defined(__ZTC__) + # define LZO_CC_ZORTECHC 1 + # define LZO_INFO_CC "Zortech C" +-# if (__ZTC__ == 0x310) ++# if ((__ZTC__-0) == 0x310) + # define LZO_INFO_CCVER "0x310" + # else + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) + # endif ++#elif defined(__GNUC__) && defined(__VERSION__) ++# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# elif defined(__GNUC_MINOR__) ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) ++# else ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L) ++# endif ++# define LZO_INFO_CC "gcc" ++# define LZO_INFO_CCVER __VERSION__ ++#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_MSC _MSC_VER ++# define LZO_INFO_CC "Microsoft C" ++# if defined(_MSC_FULL_VER) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) ++# else ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) ++# endif + #else + # define LZO_CC_UNKNOWN 1 + # define LZO_INFO_CC "unknown" + # define LZO_INFO_CCVER "unknown" + #endif ++#if (LZO_CC_GNUC) && defined(__OPEN64__) ++# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) ++# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) ++# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC ++# endif ++#endif ++#if (LZO_CC_GNUC) && defined(__PCC__) ++# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) ++# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) ++# define LZO_CC_PCC_GNUC LZO_CC_GNUC ++# endif ++#endif + #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) + # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" + #endif +@@ -668,8 +769,10 @@ + # define LZO_INFO_ARCH "generic" + #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + # define LZO_ARCH_I086 1 +-# define LZO_ARCH_IA16 1 + # define LZO_INFO_ARCH "i086" ++#elif defined(__aarch64__) ++# define LZO_ARCH_ARM64 1 ++# define LZO_INFO_ARCH "arm64" + #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) + # define LZO_ARCH_ALPHA 1 + # define LZO_INFO_ARCH "alpha" +@@ -685,10 +788,10 @@ + # define LZO_INFO_ARCH "arm_thumb" + #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) + # define LZO_ARCH_ARM 1 +-# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) ++# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) + # define LZO_ARCH_ARM_THUMB 1 + # define LZO_INFO_ARCH "arm_thumb" +-# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) ++# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) + # define LZO_INFO_ARCH "arm" + # else + # define LZO_INFO_ARCH "arm" +@@ -806,53 +909,147 @@ + # error "FIXME - missing define for CPU architecture" + #endif + #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) +-# error "FIXME - missing WIN32 define for CPU architecture" ++# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" + #endif + #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) +-# error "FIXME - missing WIN64 define for CPU architecture" ++# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" + #endif + #if (LZO_OS_OS216 || LZO_OS_WIN16) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #endif +-#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) +-# error "this should not happen" ++#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) ++# define LZO_ARCH_X64 1 ++#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_AMD64 1 ++#endif ++#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) ++# define LZO_ARCH_AARCH64 1 ++#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_ARM64 1 ++#endif ++#if (LZO_ARCH_I386 && !LZO_ARCH_X86) ++# define LZO_ARCH_X86 1 ++#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_I386 1 ++#endif ++#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) ++# error "unexpected configuration - check your compiler defines" + #endif +-#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) +-# error "this should not happen" ++#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) ++# error "unexpected configuration - check your compiler defines" + #endif + #if (LZO_ARCH_I086) + # if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if (LZO_ARCH_I386) + # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" ++# endif ++#endif ++#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++# if !defined(LZO_TARGET_FEATURE_SSE2) ++# if defined(__SSE2__) ++# define LZO_TARGET_FEATURE_SSE2 1 ++# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) ++# define LZO_TARGET_FEATURE_SSE2 1 ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_SSSE3) ++# if (LZO_TARGET_FEATURE_SSE2) ++# if defined(__SSSE3__) ++# define LZO_TARGET_FEATURE_SSSE3 1 ++# elif defined(_MSC_VER) && defined(__AVX__) ++# define LZO_TARGET_FEATURE_SSSE3 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_SSE4_2) ++# if (LZO_TARGET_FEATURE_SSSE3) ++# if defined(__SSE4_2__) ++# define LZO_TARGET_FEATURE_SSE4_2 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_AVX) ++# if (LZO_TARGET_FEATURE_SSSE3) ++# if defined(__AVX__) ++# define LZO_TARGET_FEATURE_AVX 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_AVX2) ++# if (LZO_TARGET_FEATURE_AVX) ++# if defined(__AVX2__) ++# define LZO_TARGET_FEATURE_AVX2 1 ++# endif ++# endif ++# endif ++#endif ++#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM) ++# if !defined(LZO_TARGET_FEATURE_NEON) ++# if defined(__ARM_NEON__) ++# define LZO_TARGET_FEATURE_NEON 1 ++# endif ++# endif ++#elif (LZO_ARCH_ARM64) ++# if !defined(LZO_TARGET_FEATURE_NEON) ++# if 1 ++# define LZO_TARGET_FEATURE_NEON 1 ++# endif + # endif + #endif +-#if !defined(__LZO_MM_OVERRIDE) ++#if 0 ++#elif !defined(__LZO_MM_OVERRIDE) + #if (LZO_ARCH_I086) + #if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + #endif + #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) + # define LZO_MM_TINY 1 +@@ -879,7 +1076,7 @@ + #elif (LZO_CC_ZORTECHC && defined(__VCM__)) + # define LZO_MM_LARGE 1 + #else +-# error "unknown memory model" ++# error "unknown LZO_ARCH_I086 memory model" + #endif + #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + #define LZO_HAVE_MM_HUGE_PTR 1 +@@ -902,10 +1099,10 @@ + #endif + #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) + # if (LZO_OS_DOS16) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # elif (LZO_CC_ZORTECHC) + # else +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #ifdef __cplusplus +@@ -937,7 +1134,7 @@ extern "C" { + #endif + #elif (LZO_ARCH_C166) + #if !defined(__MODEL__) +-# error "FIXME - C166 __MODEL__" ++# error "FIXME - LZO_ARCH_C166 __MODEL__" + #elif ((__MODEL__) == 0) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 1) +@@ -951,11 +1148,11 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - C166 __MODEL__" ++# error "FIXME - LZO_ARCH_C166 __MODEL__" + #endif + #elif (LZO_ARCH_MCS251) + #if !defined(__MODEL__) +-# error "FIXME - MCS251 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS251 __MODEL__" + #elif ((__MODEL__) == 0) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 2) +@@ -967,11 +1164,11 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - MCS251 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS251 __MODEL__" + #endif + #elif (LZO_ARCH_MCS51) + #if !defined(__MODEL__) +-# error "FIXME - MCS51 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS51 __MODEL__" + #elif ((__MODEL__) == 1) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 2) +@@ -983,7 +1180,7 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - MCS51 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS51 __MODEL__" + #endif + #elif (LZO_ARCH_CRAY_PVP) + # define LZO_MM_PVP 1 +@@ -1010,462 +1207,270 @@ extern "C" { + # error "unknown memory model" + #endif + #endif +-#if defined(SIZEOF_SHORT) +-# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) ++#if !defined(__lzo_gnuc_extension__) ++#if (LZO_CC_GNUC >= 0x020800ul) ++# define __lzo_gnuc_extension__ __extension__ ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_gnuc_extension__ __extension__ ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_gnuc_extension__ __extension__ ++#else + #endif +-#if defined(SIZEOF_INT) +-# define LZO_SIZEOF_INT (SIZEOF_INT) + #endif +-#if defined(SIZEOF_LONG) +-# define LZO_SIZEOF_LONG (SIZEOF_LONG) ++#if !defined(__lzo_gnuc_extension__) ++# define __lzo_gnuc_extension__ /*empty*/ + #endif +-#if defined(SIZEOF_LONG_LONG) +-# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) ++#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 ++# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++# else ++# define LZO_CFG_USE_NEW_STYLE_CASTS 1 ++# endif + #endif +-#if defined(SIZEOF___INT16) +-# define LZO_SIZEOF___INT16 (SIZEOF___INT16) ++#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 + #endif +-#if defined(SIZEOF___INT32) +-# define LZO_SIZEOF___INT32 (SIZEOF___INT32) ++#if !defined(__cplusplus) ++# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) ++# undef LZO_CFG_USE_NEW_STYLE_CASTS ++# endif ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 + #endif +-#if defined(SIZEOF___INT64) +-# define LZO_SIZEOF___INT64 (SIZEOF___INT64) ++#if !defined(LZO_REINTERPRET_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) ++# endif + #endif +-#if defined(SIZEOF_VOID_P) +-# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) ++#if !defined(LZO_REINTERPRET_CAST) ++# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) + #endif +-#if defined(SIZEOF_SIZE_T) +-# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) ++#if !defined(LZO_STATIC_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_STATIC_CAST(t,e) (static_cast (e)) ++# endif + #endif +-#if defined(SIZEOF_PTRDIFF_T) +-# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) ++#if !defined(LZO_STATIC_CAST) ++# define LZO_STATIC_CAST(t,e) ((t) (e)) + #endif +-#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) +-#if !defined(LZO_SIZEOF_SHORT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_SHORT 8 +-# elif (USHRT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,7) == 1) +-# define LZO_SIZEOF_SHORT 1 +-# elif (__LZO_LSR(USHRT_MAX,15) == 1) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,31) == 1) +-# define LZO_SIZEOF_SHORT 4 +-# elif (__LZO_LSR(USHRT_MAX,63) == 1) +-# define LZO_SIZEOF_SHORT 8 +-# elif (__LZO_LSR(USHRT_MAX,127) == 1) +-# define LZO_SIZEOF_SHORT 16 +-# else +-# error "LZO_SIZEOF_SHORT" +-# endif ++#if !defined(LZO_STATIC_CAST2) ++# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) + #endif +-#if !defined(LZO_SIZEOF_INT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_INT 8 +-# elif (UINT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_INT 2 +-# elif (UINT_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,7) == 1) +-# define LZO_SIZEOF_INT 1 +-# elif (__LZO_LSR(UINT_MAX,15) == 1) +-# define LZO_SIZEOF_INT 2 +-# elif (__LZO_LSR(UINT_MAX,31) == 1) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,63) == 1) +-# define LZO_SIZEOF_INT 8 +-# elif (__LZO_LSR(UINT_MAX,127) == 1) +-# define LZO_SIZEOF_INT 16 +-# else +-# error "LZO_SIZEOF_INT" ++#if !defined(LZO_UNCONST_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNCONST_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNCONST_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG) +-# if (ULONG_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,7) == 1) +-# define LZO_SIZEOF_LONG 1 +-# elif (__LZO_LSR(ULONG_MAX,15) == 1) +-# define LZO_SIZEOF_LONG 2 +-# elif (__LZO_LSR(ULONG_MAX,31) == 1) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,63) == 1) +-# define LZO_SIZEOF_LONG 8 +-# elif (__LZO_LSR(ULONG_MAX,127) == 1) +-# define LZO_SIZEOF_LONG 16 +-# else +-# error "LZO_SIZEOF_LONG" ++#if !defined(LZO_UNCONST_CAST) ++# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) ++#endif ++#if !defined(LZO_UNCONST_VOLATILE_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) +-# if (LZO_CC_GNUC >= 0x030300ul) +-# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) +-# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG +-# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) +-# define LZO_SIZEOF_LONG_LONG 4 +-# endif +-# endif ++#if !defined(LZO_UNCONST_VOLATILE_CAST) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) ++#endif ++#if !defined(LZO_UNVOLATILE_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) + # endif + #endif ++#if !defined(LZO_UNVOLATILE_CAST) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-#if (LZO_ARCH_I086 && LZO_CC_DMC) +-#elif (LZO_CC_CILLY) && defined(__GNUC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_OS_WIN64 || defined(_WIN64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) +-#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define LZO_SIZEOF_LONG_LONG 8 ++#if !defined(LZO_UNVOLATILE_CONST_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) ++# endif + #endif ++#if !defined(LZO_UNVOLATILE_CONST_CAST) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) + #endif ++#if !defined(LZO_PCAST) ++# if (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_PCAST(t,e) ((t) (e)) ++# endif + #endif +-#if defined(__cplusplus) && (LZO_CC_GNUC) +-# if (LZO_CC_GNUC < 0x020800ul) +-# undef LZO_SIZEOF_LONG_LONG ++#if !defined(LZO_PCAST) ++# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) ++#endif ++#if !defined(LZO_CCAST) ++# if (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_CCAST(t,e) ((t) (e)) + # endif + #endif +-#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) +-# undef LZO_SIZEOF_LONG_LONG ++#if !defined(LZO_CCAST) ++# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) + #endif +-#if !defined(LZO_SIZEOF_VOID_P) +-#if (LZO_ARCH_I086) +-# define __LZO_WORDSIZE 2 +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) +-# define LZO_SIZEOF_VOID_P 2 +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# error "LZO_MM" ++#if !defined(LZO_ICONV) ++# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) ++#endif ++#if !defined(LZO_ICAST) ++# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) ++#endif ++#if !defined(LZO_ITRUNC) ++# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) ++#endif ++#if !defined(__lzo_cte) ++# if (LZO_CC_MSC || LZO_CC_WATCOMC) ++# define __lzo_cte(e) ((void)0,(e)) ++# elif 1 ++# define __lzo_cte(e) ((void)0,(e)) + # endif +-#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) +-# define __LZO_WORDSIZE 1 +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_H8300) +-# if defined(__NORMAL_MODE__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 2 +-# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define __LZO_WORDSIZE 2 +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT +-# endif +-#elif (LZO_ARCH_M16C) +-# define __LZO_WORDSIZE 2 +-# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 4 +-#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_OS_OS400 || defined(__OS400__)) +-# define __LZO_WORDSIZE LZO_SIZEOF_LONG +-# define LZO_SIZEOF_VOID_P 16 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_VOID_P 8 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_ARCH_SPU) +-# if 0 +-# define __LZO_WORDSIZE 16 +-# endif +-# define LZO_SIZEOF_VOID_P 4 +-#else +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG + #endif ++#if !defined(__lzo_cte) ++# define __lzo_cte(e) (e) + #endif +-#if !defined(LZO_WORDSIZE) +-# if defined(__LZO_WORDSIZE) +-# define LZO_WORDSIZE __LZO_WORDSIZE ++#if !defined(LZO_BLOCK_BEGIN) ++# define LZO_BLOCK_BEGIN do { ++# define LZO_BLOCK_END } while __lzo_cte(0) ++#endif ++#if !defined(LZO_UNUSED) ++# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) ++# define LZO_UNUSED(var) ((void) &var) ++# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) ++# define LZO_UNUSED(var) if (&var) ; else ++# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) ++# define LZO_UNUSED(var) ((void) &var) ++# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNUSED(var) ((void) var) ++# elif (LZO_CC_MSC && (_MSC_VER < 900)) ++# define LZO_UNUSED(var) if (&var) ; else ++# elif (LZO_CC_KEILC) ++# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} ++# elif (LZO_CC_PACIFICC) ++# define LZO_UNUSED(var) ((void) sizeof(var)) ++# elif (LZO_CC_WATCOMC) && defined(__cplusplus) ++# define LZO_UNUSED(var) ((void) var) + # else +-# define LZO_WORDSIZE LZO_SIZEOF_VOID_P ++# define LZO_UNUSED(var) ((void) &var) + # endif + #endif +-#if !defined(LZO_SIZEOF_SIZE_T) +-#if (LZO_ARCH_I086 || LZO_ARCH_M16C) +-# define LZO_SIZEOF_SIZE_T 2 +-#else +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P +-#endif +-#endif +-#if !defined(LZO_SIZEOF_PTRDIFF_T) +-#if (LZO_ARCH_I086) +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE) +-# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) +-# define LZO_SIZEOF_PTRDIFF_T 4 +-# else +-# define LZO_SIZEOF_PTRDIFF_T 2 +-# endif ++#if !defined(LZO_UNUSED_FUNC) ++# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) ++# define LZO_UNUSED_FUNC(func) ((void) func) ++# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) ++# define LZO_UNUSED_FUNC(func) if (func) ; else ++# elif (LZO_CC_CLANG || LZO_CC_LLVM) ++# define LZO_UNUSED_FUNC(func) ((void) &func) ++# elif (LZO_CC_MSC && (_MSC_VER < 900)) ++# define LZO_UNUSED_FUNC(func) if (func) ; else ++# elif (LZO_CC_MSC) ++# define LZO_UNUSED_FUNC(func) ((void) &func) ++# elif (LZO_CC_KEILC || LZO_CC_PELLESC) ++# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} + # else +-# error "LZO_MM" ++# define LZO_UNUSED_FUNC(func) ((void) func) + # endif +-#else +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T +-#endif + #endif +-#if (LZO_ABI_NEUTRAL_ENDIAN) +-# undef LZO_ABI_BIG_ENDIAN +-# undef LZO_ABI_LITTLE_ENDIAN +-#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) +-#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +-# if (__LITTLE_ENDIAN__ == 1) +-# define LZO_ABI_LITTLE_ENDIAN 1 ++#if !defined(LZO_UNUSED_LABEL) ++# if (LZO_CC_CLANG >= 0x020800ul) ++# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) ++# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) ++# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l + # else +-# define LZO_ABI_BIG_ENDIAN 1 ++# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l + # endif +-#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#endif +-#endif +-#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +-# error "this should not happen" +-#endif +-#if (LZO_ABI_BIG_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "be" +-#elif (LZO_ABI_LITTLE_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "le" +-#elif (LZO_ABI_NEUTRAL_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "neutral" +-#endif +-#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_I8LP16 1 +-# define LZO_INFO_ABI_PM "i8lp16" +-#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_ILP16 1 +-# define LZO_INFO_ABI_PM "ilp16" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_ILP32 1 +-# define LZO_INFO_ABI_PM "ilp32" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) +-# define LZO_ABI_LLP64 1 +-# define LZO_INFO_ABI_PM "llp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_LP64 1 +-# define LZO_INFO_ABI_PM "lp64" +-#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_ILP64 1 +-# define LZO_INFO_ABI_PM "ilp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_IP32L64 1 +-# define LZO_INFO_ABI_PM "ip32l64" + #endif +-#if !defined(__LZO_LIBC_OVERRIDE) +-#if (LZO_LIBC_NAKED) +-# define LZO_INFO_LIBC "naked" +-#elif (LZO_LIBC_FREESTANDING) +-# define LZO_INFO_LIBC "freestanding" +-#elif (LZO_LIBC_MOSTLY_FREESTANDING) +-# define LZO_INFO_LIBC "mfreestanding" +-#elif (LZO_LIBC_ISOC90) +-# define LZO_INFO_LIBC "isoc90" +-#elif (LZO_LIBC_ISOC99) +-# define LZO_INFO_LIBC "isoc99" +-#elif defined(__dietlibc__) +-# define LZO_LIBC_DIETLIBC 1 +-# define LZO_INFO_LIBC "dietlibc" +-#elif defined(_NEWLIB_VERSION) +-# define LZO_LIBC_NEWLIB 1 +-# define LZO_INFO_LIBC "newlib" +-#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) +-# if defined(__UCLIBC_SUBLEVEL__) +-# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) ++#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) ++# if 0 ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var ++# elif 0 && (LZO_CC_GNUC) ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var + # else +-# define LZO_LIBC_UCLIBC 0x00090bL ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init + # endif +-# define LZO_INFO_LIBC "uclibc" +-#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +-# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) +-# define LZO_INFO_LIBC "glibc" +-#elif (LZO_CC_MWERKS) && defined(__MSL__) +-# define LZO_LIBC_MSL __MSL__ +-# define LZO_INFO_LIBC "msl" +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) +-# define LZO_LIBC_ISOC90 1 +-# define LZO_INFO_LIBC "isoc90" +-#else +-# define LZO_LIBC_DEFAULT 1 +-# define LZO_INFO_LIBC "default" +-#endif +-#endif +-#if !defined(__lzo_gnuc_extension__) +-#if (LZO_CC_GNUC >= 0x020800ul) +-# define __lzo_gnuc_extension__ __extension__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_gnuc_extension__ __extension__ +-#else +-# define __lzo_gnuc_extension__ /*empty*/ +-#endif +-#endif +-#if !defined(__lzo_ua_volatile) +-# define __lzo_ua_volatile volatile +-#endif +-#if !defined(__lzo_alignof) +-#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +-# define __lzo_alignof(e) __alignof(e) +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) +-# define __lzo_alignof(e) __alignof__(e) +-#endif +-#endif +-#if defined(__lzo_alignof) +-# define __lzo_HAVE_alignof 1 +-#endif +-#if !defined(__lzo_constructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_constructor __attribute__((__constructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_constructor __attribute__((__constructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_constructor __attribute__((__constructor__)) +-#endif +-#endif +-#if defined(__lzo_constructor) +-# define __lzo_HAVE_constructor 1 +-#endif +-#if !defined(__lzo_destructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_destructor __attribute__((__destructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_destructor __attribute__((__destructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_destructor __attribute__((__destructor__)) +-#endif +-#endif +-#if defined(__lzo_destructor) +-# define __lzo_HAVE_destructor 1 +-#endif +-#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) +-# error "this should not happen" + #endif + #if !defined(__lzo_inline) + #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) + #elif defined(__cplusplus) + # define __lzo_inline inline ++#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) ++# define __lzo_inline inline + #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) + # define __lzo_inline __inline +-#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) + # define __lzo_inline __inline__ + #elif (LZO_CC_DMC) + # define __lzo_inline __inline ++#elif (LZO_CC_GHS) ++# define __lzo_inline __inline__ ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_inline __inline__ + #elif (LZO_CC_INTELC) + # define __lzo_inline __inline + #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) + # define __lzo_inline __inline + #elif (LZO_CC_MSC && (_MSC_VER >= 900)) + # define __lzo_inline __inline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_inline __inline__ +-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define __lzo_inline inline + #endif + #endif + #if defined(__lzo_inline) ++# ifndef __lzo_HAVE_inline + # define __lzo_HAVE_inline 1 ++# endif + #else + # define __lzo_inline /*empty*/ + #endif + #if !defined(__lzo_forceinline) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #endif + #endif + #if defined(__lzo_forceinline) ++# ifndef __lzo_HAVE_forceinline + # define __lzo_HAVE_forceinline 1 ++# endif + #else +-# define __lzo_forceinline /*empty*/ ++# define __lzo_forceinline __lzo_inline + #endif + #if !defined(__lzo_noinline) + #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) + # define __lzo_noinline __attribute__((__noinline__,__used__)) + #elif (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_noinline __attribute__((__noinline__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) + # define __lzo_noinline __declspec(noinline) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_noinline __attribute__((__noinline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) + # define __lzo_noinline __declspec(noinline) +@@ -1474,179 +1479,409 @@ extern "C" { + # else + # define __lzo_noinline __declspec(noinline) + # endif +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_noinline __attribute__((__noinline__)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_noinline __attribute__((__noinline__)) + #endif + #endif + #if defined(__lzo_noinline) ++# ifndef __lzo_HAVE_noinline + # define __lzo_HAVE_noinline 1 ++# endif + #else + # define __lzo_noinline /*empty*/ + #endif + #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + #endif +-#if !defined(__lzo_noreturn) +-#if (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) +-# define __lzo_noreturn __declspec(noreturn) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +-# define __lzo_noreturn __declspec(noreturn) ++#if !defined(__lzo_static_inline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline + #endif + #endif +-#if defined(__lzo_noreturn) +-# define __lzo_HAVE_noreturn 1 +-#else +-# define __lzo_noreturn /*empty*/ ++#if !defined(__lzo_static_inline) ++# define __lzo_static_inline static __lzo_inline + #endif +-#if !defined(__lzo_nothrow) +-#if (LZO_CC_GNUC >= 0x030300ul) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) +-# define __lzo_nothrow __declspec(nothrow) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) ++#if !defined(__lzo_static_forceinline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline ++#endif ++#endif ++#if !defined(__lzo_static_forceinline) ++# define __lzo_static_forceinline static __lzo_forceinline ++#endif ++#if !defined(__lzo_static_noinline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline ++#endif ++#endif ++#if !defined(__lzo_static_noinline) ++# define __lzo_static_noinline static __lzo_noinline ++#endif ++#if !defined(__lzo_c99_extern_inline) ++#if defined(__GNUC_GNU_INLINE__) ++# define __lzo_c99_extern_inline __lzo_inline ++#elif defined(__GNUC_STDC_INLINE__) ++# define __lzo_c99_extern_inline extern __lzo_inline ++#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) ++# define __lzo_c99_extern_inline extern __lzo_inline ++#endif ++#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) ++# define __lzo_c99_extern_inline __lzo_inline ++#endif ++#endif ++#if defined(__lzo_c99_extern_inline) ++# ifndef __lzo_HAVE_c99_extern_inline ++# define __lzo_HAVE_c99_extern_inline 1 ++# endif ++#else ++# define __lzo_c99_extern_inline /*empty*/ ++#endif ++#if !defined(__lzo_may_alias) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_CLANG >= 0x020900ul) ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#endif ++#endif ++#if defined(__lzo_may_alias) ++# ifndef __lzo_HAVE_may_alias ++# define __lzo_HAVE_may_alias 1 ++# endif ++#else ++# define __lzo_may_alias /*empty*/ ++#endif ++#if !defined(__lzo_noreturn) ++#if (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) ++# define __lzo_noreturn __declspec(noreturn) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) ++# define __lzo_noreturn __declspec(noreturn) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#endif ++#endif ++#if defined(__lzo_noreturn) ++# ifndef __lzo_HAVE_noreturn ++# define __lzo_HAVE_noreturn 1 ++# endif ++#else ++# define __lzo_noreturn /*empty*/ ++#endif ++#if !defined(__lzo_nothrow) ++#if (LZO_CC_GNUC >= 0x030300ul) ++# define __lzo_nothrow __attribute__((__nothrow__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) ++# define __lzo_nothrow __declspec(nothrow) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) ++# define __lzo_nothrow __attribute__((__nothrow__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_nothrow __attribute__((__nothrow__)) ++#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) + # define __lzo_nothrow __declspec(nothrow) + #endif + #endif + #if defined(__lzo_nothrow) ++# ifndef __lzo_HAVE_nothrow + # define __lzo_HAVE_nothrow 1 ++# endif + #else + # define __lzo_nothrow /*empty*/ + #endif + #if !defined(__lzo_restrict) + #if (LZO_CC_GNUC >= 0x030400ul) + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM) ++#elif (LZO_CC_IBMC >= 1210) ++# define __lzo_restrict __restrict__ ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) ++# define __lzo_restrict __restrict__ ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) + # define __lzo_restrict __restrict__ + #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) + # define __lzo_restrict __restrict ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_restrict __restrict__ + #endif + #endif + #if defined(__lzo_restrict) ++# ifndef __lzo_HAVE_restrict + # define __lzo_HAVE_restrict 1 ++# endif + #else + # define __lzo_restrict /*empty*/ + #endif ++#if !defined(__lzo_alignof) ++#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_GHS) && !defined(__cplusplus) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) ++#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_alignof(e) __alignof(e) ++#elif (LZO_CC_SUNPROC >= 0x5100) ++# define __lzo_alignof(e) __alignof__(e) ++#endif ++#endif ++#if defined(__lzo_alignof) ++# ifndef __lzo_HAVE_alignof ++# define __lzo_HAVE_alignof 1 ++# endif ++#endif ++#if !defined(__lzo_struct_packed) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) ++#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) ++#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++# define __lzo_struct_packed(s) struct s { ++# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_struct_packed(s) struct s { ++# define __lzo_struct_packed_end() } __attribute__((__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { ++# define __lzo_struct_packed_end() } __attribute__((__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { ++# define __lzo_struct_packed_end() } __pragma(pack(pop)); ++#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) ++# define __lzo_struct_packed(s) _Packed struct s { ++# define __lzo_struct_packed_end() }; ++#endif ++#endif ++#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) ++# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) ++#endif ++#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) ++# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() ++#endif ++#if !defined(__lzo_byte_struct) ++#if defined(__lzo_struct_packed) ++# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() ++# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() ++#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); ++# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); ++#endif ++#endif ++#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) ++# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) ++#endif ++#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) ++#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) ++#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_CILLY || LZO_CC_PCC) ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_struct_align16(s) struct __declspec(align(16)) s { ++# define __lzo_struct_align16_end() }; ++# define __lzo_struct_align32(s) struct __declspec(align(32)) s { ++# define __lzo_struct_align32_end() }; ++# define __lzo_struct_align64(s) struct __declspec(align(64)) s { ++# define __lzo_struct_align64_end() }; ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_struct_align16(s) struct s { ++# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); ++# define __lzo_struct_align32(s) struct s { ++# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); ++# define __lzo_struct_align64(s) struct s { ++# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); ++#endif ++#endif ++#if !defined(__lzo_union_um) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) ++#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) ++#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_union_am(s) union s { ++# define __lzo_union_am_end() } __lzo_may_alias; ++# define __lzo_union_um(s) union s { ++# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { ++# define __lzo_union_am_end() } __lzo_may_alias; ++# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { ++# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_union_um(s) __pragma(pack(push,1)) union s { ++# define __lzo_union_um_end() } __pragma(pack(pop)); ++#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) ++# define __lzo_union_um(s) _Packed union s { ++# define __lzo_union_um_end() }; ++#endif ++#endif ++#if !defined(__lzo_union_am) ++# define __lzo_union_am(s) union s { ++# define __lzo_union_am_end() }; ++#endif ++#if !defined(__lzo_constructor) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_constructor __attribute__((__constructor__,__used__)) ++#elif (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_constructor __attribute__((__constructor__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) ++# define __lzo_constructor __attribute__((__constructor__,__used__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_constructor __attribute__((__constructor__)) ++#endif ++#endif ++#if defined(__lzo_constructor) ++# ifndef __lzo_HAVE_constructor ++# define __lzo_HAVE_constructor 1 ++# endif ++#endif ++#if !defined(__lzo_destructor) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_destructor __attribute__((__destructor__,__used__)) ++#elif (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_destructor __attribute__((__destructor__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) ++# define __lzo_destructor __attribute__((__destructor__,__used__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_destructor __attribute__((__destructor__)) ++#endif ++#endif ++#if defined(__lzo_destructor) ++# ifndef __lzo_HAVE_destructor ++# define __lzo_HAVE_destructor 1 ++# endif ++#endif ++#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) ++# error "unexpected configuration - check your compiler defines" ++#endif + #if !defined(__lzo_likely) && !defined(__lzo_unlikely) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) ++#elif (LZO_CC_IBMC >= 1010) ++# define __lzo_likely(e) (__builtin_expect(!!(e),1)) ++# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #endif + #endif + #if defined(__lzo_likely) ++# ifndef __lzo_HAVE_likely + # define __lzo_HAVE_likely 1 ++# endif + #else + # define __lzo_likely(e) (e) + #endif + #if defined(__lzo_unlikely) ++# ifndef __lzo_HAVE_unlikely + # define __lzo_HAVE_unlikely 1 ++# endif + #else + # define __lzo_unlikely(e) (e) + #endif +-#if !defined(LZO_UNUSED) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED(var) ((void) &var) +-# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNUSED(var) ((void) var) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_KEILC) +-# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} +-# elif (LZO_CC_PACIFICC) +-# define LZO_UNUSED(var) ((void) sizeof(var)) +-# elif (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED(var) ((void) var) ++#if !defined(__lzo_static_unused_void_func) ++# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) + # else +-# define LZO_UNUSED(var) ((void) &var) ++# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) + # endif + #endif +-#if !defined(LZO_UNUSED_FUNC) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED_FUNC(func) ((void) func) +-# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_CLANG || LZO_CC_LLVM) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_MSC) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_KEILC || LZO_CC_PELLESC) +-# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} ++#if !defined(__lzo_loop_forever) ++# if (LZO_CC_IBMC) ++# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END + # else +-# define LZO_UNUSED_FUNC(func) ((void) func) ++# define __lzo_loop_forever() do { ; } while __lzo_cte(1) + # endif + #endif +-#if !defined(LZO_UNUSED_LABEL) +-# if (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) +-# define LZO_UNUSED_LABEL(l) if (0) goto l +-# else +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# endif ++#if !defined(__lzo_unreachable) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) ++# define __lzo_unreachable() __builtin_unreachable(); ++#elif (LZO_CC_GNUC >= 0x040500ul) ++# define __lzo_unreachable() __builtin_unreachable(); ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 ++# define __lzo_unreachable() __builtin_unreachable(); + #endif +-#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) ++#endif ++#if defined(__lzo_unreachable) ++# ifndef __lzo_HAVE_unreachable ++# define __lzo_HAVE_unreachable 1 ++# endif ++#else + # if 0 +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var +-# elif 0 && (LZO_CC_GNUC) +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var ++# define __lzo_unreachable() ((void)0); + # else +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init ++# define __lzo_unreachable() __lzo_loop_forever(); + # endif + #endif +-#if !defined(LZO_UNCONST_CAST) +-# if 0 && defined(__cplusplus) +-# define LZO_UNCONST_CAST(t,e) (const_cast (e)) +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) +-# else +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) +-# endif ++#ifndef __LZO_CTA_NAME ++#if (LZO_CFG_USE_COUNTER) ++# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) ++#else ++# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) ++#endif + #endif + #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) + # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END ++# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END ++# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END + # else +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END + # endif + #endif + #if !defined(LZO_COMPILE_TIME_ASSERT) + # if (LZO_CC_AZTECC) +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} + # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; ++# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) ++# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} ++# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) ++# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} ++# elif (LZO_CC_GNUC >= 0x040700ul) ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} + # elif (LZO_CC_MSC && (_MSC_VER < 900)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # else +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} + # endif + #endif ++LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) ++#if defined(__cplusplus) ++extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) + #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) +@@ -1681,99 +1916,654 @@ extern "C" { + # elif defined(_MT) + # define __lzo_cdecl_sighandler _far _cdecl + # else +-# define __lzo_cdecl_sighandler _cdecl ++# define __lzo_cdecl_sighandler _cdecl ++# endif ++# else ++# define __lzo_cdecl_sighandler __cdecl ++# endif ++#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) ++# define __lzo_cdecl __cdecl ++#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) ++# define __lzo_cdecl cdecl ++#endif ++#if !defined(__lzo_cdecl) ++# define __lzo_cdecl /*empty*/ ++#endif ++#if !defined(__lzo_cdecl_atexit) ++# define __lzo_cdecl_atexit /*empty*/ ++#endif ++#if !defined(__lzo_cdecl_main) ++# define __lzo_cdecl_main /*empty*/ ++#endif ++#if !defined(__lzo_cdecl_qsort) ++# define __lzo_cdecl_qsort /*empty*/ ++#endif ++#if !defined(__lzo_cdecl_sighandler) ++# define __lzo_cdecl_sighandler /*empty*/ ++#endif ++#if !defined(__lzo_cdecl_va) ++# define __lzo_cdecl_va __lzo_cdecl ++#endif ++#if !(LZO_CFG_NO_WINDOWS_H) ++#if !defined(LZO_HAVE_WINDOWS_H) ++#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) ++# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) ++# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) ++# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) ++# else ++# define LZO_HAVE_WINDOWS_H 1 ++# endif ++#endif ++#endif ++#endif ++#ifndef LZO_SIZEOF_SHORT ++#if defined(SIZEOF_SHORT) ++# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) ++#elif defined(__SIZEOF_SHORT__) ++# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_INT ++#if defined(SIZEOF_INT) ++# define LZO_SIZEOF_INT (SIZEOF_INT) ++#elif defined(__SIZEOF_INT__) ++# define LZO_SIZEOF_INT (__SIZEOF_INT__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_LONG ++#if defined(SIZEOF_LONG) ++# define LZO_SIZEOF_LONG (SIZEOF_LONG) ++#elif defined(__SIZEOF_LONG__) ++# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_LONG_LONG ++#if defined(SIZEOF_LONG_LONG) ++# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) ++#elif defined(__SIZEOF_LONG_LONG__) ++# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT16 ++#if defined(SIZEOF___INT16) ++# define LZO_SIZEOF___INT16 (SIZEOF___INT16) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT32 ++#if defined(SIZEOF___INT32) ++# define LZO_SIZEOF___INT32 (SIZEOF___INT32) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT64 ++#if defined(SIZEOF___INT64) ++# define LZO_SIZEOF___INT64 (SIZEOF___INT64) ++#endif ++#endif ++#ifndef LZO_SIZEOF_VOID_P ++#if defined(SIZEOF_VOID_P) ++# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) ++#elif defined(__SIZEOF_POINTER__) ++# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_SIZE_T ++#if defined(SIZEOF_SIZE_T) ++# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) ++#elif defined(__SIZEOF_SIZE_T__) ++# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_PTRDIFF_T ++#if defined(SIZEOF_PTRDIFF_T) ++# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) ++#elif defined(__SIZEOF_PTRDIFF_T__) ++# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) ++#endif ++#endif ++#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) ++#if !defined(LZO_SIZEOF_SHORT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_SHORT 8 ++# elif (USHRT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,7) == 1) ++# define LZO_SIZEOF_SHORT 1 ++# elif (__LZO_LSR(USHRT_MAX,15) == 1) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,31) == 1) ++# define LZO_SIZEOF_SHORT 4 ++# elif (__LZO_LSR(USHRT_MAX,63) == 1) ++# define LZO_SIZEOF_SHORT 8 ++# elif (__LZO_LSR(USHRT_MAX,127) == 1) ++# define LZO_SIZEOF_SHORT 16 ++# else ++# error "LZO_SIZEOF_SHORT" ++# endif ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) ++#if !defined(LZO_SIZEOF_INT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_INT 8 ++# elif (UINT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_INT 2 ++# elif (UINT_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,7) == 1) ++# define LZO_SIZEOF_INT 1 ++# elif (__LZO_LSR(UINT_MAX,15) == 1) ++# define LZO_SIZEOF_INT 2 ++# elif (__LZO_LSR(UINT_MAX,31) == 1) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,63) == 1) ++# define LZO_SIZEOF_INT 8 ++# elif (__LZO_LSR(UINT_MAX,127) == 1) ++# define LZO_SIZEOF_INT 16 ++# else ++# error "LZO_SIZEOF_INT" ++# endif ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) ++#if !defined(LZO_SIZEOF_LONG) ++# if (ULONG_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_LONG 4 ++# elif (__LZO_LSR(ULONG_MAX,7) == 1) ++# define LZO_SIZEOF_LONG 1 ++# elif (__LZO_LSR(ULONG_MAX,15) == 1) ++# define LZO_SIZEOF_LONG 2 ++# elif (__LZO_LSR(ULONG_MAX,31) == 1) ++# define LZO_SIZEOF_LONG 4 ++# elif (__LZO_LSR(ULONG_MAX,39) == 1) ++# define LZO_SIZEOF_LONG 5 ++# elif (__LZO_LSR(ULONG_MAX,63) == 1) ++# define LZO_SIZEOF_LONG 8 ++# elif (__LZO_LSR(ULONG_MAX,127) == 1) ++# define LZO_SIZEOF_LONG 16 ++# else ++# error "LZO_SIZEOF_LONG" ++# endif ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) ++# if (LZO_CC_GNUC >= 0x030300ul) ++# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) ++# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG ++# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) ++# define LZO_SIZEOF_LONG_LONG 4 ++# endif ++# endif ++# endif ++#endif ++#endif ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++#if (LZO_ARCH_I086 && LZO_CC_DMC) ++#elif (LZO_CC_CILLY) && defined(__GNUC__) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_OS_WIN64 || defined(_WIN64)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) ++#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ++# define LZO_SIZEOF_LONG_LONG 8 ++#endif ++#endif ++#endif ++#if defined(__cplusplus) && (LZO_CC_GNUC) ++# if (LZO_CC_GNUC < 0x020800ul) ++# undef LZO_SIZEOF_LONG_LONG ++# endif ++#endif ++#if (LZO_CFG_NO_LONG_LONG) ++# undef LZO_SIZEOF_LONG_LONG ++#elif defined(__NO_LONG_LONG) ++# undef LZO_SIZEOF_LONG_LONG ++#elif defined(_NO_LONGLONG) ++# undef LZO_SIZEOF_LONG_LONG ++#endif ++#if !defined(LZO_WORDSIZE) ++#if (LZO_ARCH_ALPHA) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_AMD64) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_AVR) ++# define LZO_WORDSIZE 1 ++#elif (LZO_ARCH_H8300) ++# if defined(__NORMAL_MODE__) ++# define LZO_WORDSIZE 4 ++# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) ++# define LZO_WORDSIZE 4 ++# else ++# define LZO_WORDSIZE 2 ++# endif ++#elif (LZO_ARCH_I086) ++# define LZO_WORDSIZE 2 ++#elif (LZO_ARCH_IA64) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_M16C) ++# define LZO_WORDSIZE 2 ++#elif (LZO_ARCH_SPU) ++# define LZO_WORDSIZE 4 ++#elif (LZO_ARCH_Z80) ++# define LZO_WORDSIZE 1 ++#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++# define LZO_WORDSIZE 8 ++#elif (LZO_OS_OS400 || defined(__OS400__)) ++# define LZO_WORDSIZE 8 ++#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) ++# define LZO_WORDSIZE 8 ++#endif ++#endif ++#if !defined(LZO_SIZEOF_VOID_P) ++#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) ++# define LZO_SIZEOF_VOID_P 4 ++#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) ++# define LZO_SIZEOF_VOID_P 8 ++#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) ++# define LZO_SIZEOF_VOID_P 8 ++#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) ++# define LZO_SIZEOF_VOID_P 8 ++#elif (LZO_ARCH_AVR) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_H8300) ++# if defined(__NORMAL_MODE__) ++# define LZO_SIZEOF_VOID_P 2 ++# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# define LZO_SIZEOF_VOID_P 2 ++# endif ++# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT ++# endif ++#elif (LZO_ARCH_I086) ++# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) ++# define LZO_SIZEOF_VOID_P 2 ++# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# error "invalid LZO_ARCH_I086 memory model" ++# endif ++#elif (LZO_ARCH_M16C) ++# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# define LZO_SIZEOF_VOID_P 2 ++# endif ++#elif (LZO_ARCH_SPU) ++# define LZO_SIZEOF_VOID_P 4 ++#elif (LZO_ARCH_Z80) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++# define LZO_SIZEOF_VOID_P 4 ++#elif (LZO_OS_OS400 || defined(__OS400__)) ++# if defined(__LLP64_IFC__) ++# define LZO_SIZEOF_VOID_P 8 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG ++# else ++# define LZO_SIZEOF_VOID_P 16 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG ++# endif ++#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) ++# define LZO_SIZEOF_VOID_P 8 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG ++#endif ++#endif ++#if !defined(LZO_SIZEOF_VOID_P) ++# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) ++#if !defined(LZO_SIZEOF_SIZE_T) ++#if (LZO_ARCH_I086 || LZO_ARCH_M16C) ++# define LZO_SIZEOF_SIZE_T 2 ++#endif ++#endif ++#if !defined(LZO_SIZEOF_SIZE_T) ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P ++#endif ++#if defined(offsetof) ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) ++#endif ++#if !defined(LZO_SIZEOF_PTRDIFF_T) ++#if (LZO_ARCH_I086) ++# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P ++# elif (LZO_MM_COMPACT || LZO_MM_LARGE) ++# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) ++# define LZO_SIZEOF_PTRDIFF_T 4 ++# else ++# define LZO_SIZEOF_PTRDIFF_T 2 + # endif + # else +-# define __lzo_cdecl_sighandler __cdecl ++# error "invalid LZO_ARCH_I086 memory model" + # endif +-#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) +-# define __lzo_cdecl __cdecl +-#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) +-# define __lzo_cdecl cdecl + #endif +-#if !defined(__lzo_cdecl) +-# define __lzo_cdecl /*empty*/ + #endif +-#if !defined(__lzo_cdecl_atexit) +-# define __lzo_cdecl_atexit /*empty*/ ++#if !defined(LZO_SIZEOF_PTRDIFF_T) ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T + #endif +-#if !defined(__lzo_cdecl_main) +-# define __lzo_cdecl_main /*empty*/ ++#if defined(offsetof) ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) + #endif +-#if !defined(__lzo_cdecl_qsort) +-# define __lzo_cdecl_qsort /*empty*/ ++#if !defined(LZO_WORDSIZE) ++# define LZO_WORDSIZE LZO_SIZEOF_VOID_P + #endif +-#if !defined(__lzo_cdecl_sighandler) +-# define __lzo_cdecl_sighandler /*empty*/ ++#if (LZO_ABI_NEUTRAL_ENDIAN) ++# undef LZO_ABI_BIG_ENDIAN ++# undef LZO_ABI_LITTLE_ENDIAN ++#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) ++#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) ++# if (__LITTLE_ENDIAN__ == 1) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++# else ++# define LZO_ABI_BIG_ENDIAN 1 ++# endif ++#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) ++# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) ++# error "unexpected configuration - check your compiler defines" ++# elif defined(__BIG_ENDIAN) ++# define LZO_ABI_BIG_ENDIAN 1 ++# else ++# define LZO_ABI_LITTLE_ENDIAN 1 ++# endif ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 + #endif +-#if !defined(__lzo_cdecl_va) +-# define __lzo_cdecl_va __lzo_cdecl + #endif +-#if !(LZO_CFG_NO_WINDOWS_H) +-#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) +-# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) +-# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) +-# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) ++#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ABI_BIG_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "be" ++#elif (LZO_ABI_LITTLE_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "le" ++#elif (LZO_ABI_NEUTRAL_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "neutral" ++#endif ++#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_I8LP16 1 ++# define LZO_INFO_ABI_PM "i8lp16" ++#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_ILP16 1 ++# define LZO_INFO_ABI_PM "ilp16" ++#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_LP32 1 ++# define LZO_INFO_ABI_PM "lp32" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_ILP32 1 ++# define LZO_INFO_ABI_PM "ilp32" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) ++# define LZO_ABI_LLP64 1 ++# define LZO_INFO_ABI_PM "llp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_LP64 1 ++# define LZO_INFO_ABI_PM "lp64" ++#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_ILP64 1 ++# define LZO_INFO_ABI_PM "ilp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_IP32L64 1 ++# define LZO_INFO_ABI_PM "ip32l64" ++#endif ++#if 0 ++#elif !defined(__LZO_LIBC_OVERRIDE) ++#if (LZO_LIBC_NAKED) ++# define LZO_INFO_LIBC "naked" ++#elif (LZO_LIBC_FREESTANDING) ++# define LZO_INFO_LIBC "freestanding" ++#elif (LZO_LIBC_MOSTLY_FREESTANDING) ++# define LZO_INFO_LIBC "mfreestanding" ++#elif (LZO_LIBC_ISOC90) ++# define LZO_INFO_LIBC "isoc90" ++#elif (LZO_LIBC_ISOC99) ++# define LZO_INFO_LIBC "isoc99" ++#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) ++# define LZO_LIBC_ISOC90 1 ++# define LZO_INFO_LIBC "isoc90" ++#elif defined(__dietlibc__) ++# define LZO_LIBC_DIETLIBC 1 ++# define LZO_INFO_LIBC "dietlibc" ++#elif defined(_NEWLIB_VERSION) ++# define LZO_LIBC_NEWLIB 1 ++# define LZO_INFO_LIBC "newlib" ++#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) ++# if defined(__UCLIBC_SUBLEVEL__) ++# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) + # else +-# define LZO_HAVE_WINDOWS_H 1 ++# define LZO_LIBC_UCLIBC 0x00090bL + # endif ++# define LZO_INFO_LIBC "uc" "libc" ++#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) ++# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) ++# define LZO_INFO_LIBC "glibc" ++#elif (LZO_CC_MWERKS) && defined(__MSL__) ++# define LZO_LIBC_MSL __MSL__ ++# define LZO_INFO_LIBC "msl" ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) ++# define LZO_LIBC_ISOC90 1 ++# define LZO_INFO_LIBC "isoc90" ++#else ++# define LZO_LIBC_DEFAULT 1 ++# define LZO_INFO_LIBC "default" ++#endif ++#endif ++#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++# define LZO_ASM_SYNTAX_MSC 1 ++#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) ++#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_CC_GNUC) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#endif ++#if (LZO_ASM_SYNTAX_GNUC) ++#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) ++# define __LZO_ASM_CLOBBER "ax" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) ++# define __LZO_ASM_CLOBBER "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#else ++# define __LZO_ASM_CLOBBER "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC : "cc" ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ + #endif + #endif + #if (LZO_ARCH_ALPHA) +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_AVOID_SHORT 1 +-# define LZO_OPT_AVOID_USHORT 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 + #elif (LZO_ARCH_AMD64) +-# define LZO_OPT_AVOID_INT_INDEX 1 +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 +-# define LZO_OPT_UNALIGNED64 1 +-#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) ++# define LZO_OPT_AVOID_INT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + #elif (LZO_ARCH_ARM) +-# define LZO_OPT_AVOID_SHORT 1 +-# define LZO_OPT_AVOID_USHORT 1 ++# if defined(__ARM_FEATURE_UNALIGNED) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# endif ++#elif (LZO_ARCH_ARM64) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + #elif (LZO_ARCH_CRIS) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + #elif (LZO_ARCH_I386) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + #elif (LZO_ARCH_IA64) +-# define LZO_OPT_AVOID_INT_INDEX 1 +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_AVOID_INT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 ++# define LZO_OPT_PREFER_POSTINC 1 + #elif (LZO_ARCH_M68K) +-# define LZO_OPT_PREFER_POSTINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + # if defined(__mc68020__) && !defined(__mcoldfire__) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + # endif + #elif (LZO_ARCH_MIPS) +-# define LZO_OPT_AVOID_UINT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 + #elif (LZO_ARCH_POWERPC) +-# define LZO_OPT_PREFER_PREINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_PREINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + # if (LZO_ABI_BIG_ENDIAN) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# if (LZO_WORDSIZE == 8) ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif ++# endif + # endif + #elif (LZO_ARCH_S390) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 +-# if (LZO_SIZEOF_SIZE_T == 8) +-# define LZO_OPT_UNALIGNED64 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# if (LZO_WORDSIZE == 8) ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + # endif + #elif (LZO_ARCH_SH) +-# define LZO_OPT_PREFER_POSTINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + #endif + #ifndef LZO_CFG_NO_INLINE_ASM +-#if (LZO_CC_LLVM) ++#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) ++# define LZO_CFG_NO_INLINE_ASM 1 ++#elif (LZO_CC_LLVM) + # define LZO_CFG_NO_INLINE_ASM 1 + #endif + #endif ++#if (LZO_CFG_NO_INLINE_ASM) ++# undef LZO_ASM_SYNTAX_MSC ++# undef LZO_ASM_SYNTAX_GNUC ++# undef __LZO_ASM_CLOBBER ++# undef __LZO_ASM_CLOBBER_LIST_CC ++# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY ++# undef __LZO_ASM_CLOBBER_LIST_EMPTY ++#endif + #ifndef LZO_CFG_NO_UNALIGNED + #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) + # define LZO_CFG_NO_UNALIGNED 1 +@@ -1784,25 +2574,6 @@ extern "C" { + # undef LZO_OPT_UNALIGNED32 + # undef LZO_OPT_UNALIGNED64 + #endif +-#if (LZO_CFG_NO_INLINE_ASM) +-#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +-# define LZO_ASM_SYNTAX_MSC 1 +-#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +-#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) +-#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +-# define LZO_ASM_SYNTAX_GNUC 1 +-#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +-# define LZO_ASM_SYNTAX_GNUC 1 +-#endif +-#if (LZO_ASM_SYNTAX_GNUC) +-#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) +-# define __LZO_ASM_CLOBBER "ax" +-#elif (LZO_CC_INTELC) +-# define __LZO_ASM_CLOBBER "memory" +-#else +-# define __LZO_ASM_CLOBBER "cc", "memory" +-#endif +-#endif + #if defined(__LZO_INFOSTR_MM) + #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) + # define __LZO_INFOSTR_MM "" +@@ -1846,7 +2617,382 @@ extern "C" { + #define LZO_INFO_STRING \ + LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ + " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER ++#if !(LZO_CFG_SKIP_LZO_TYPES) ++#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) ++# error "missing defines for sizes" ++#endif ++#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) ++# error "missing defines for sizes" ++#endif ++#if !defined(lzo_llong_t) ++#if (LZO_SIZEOF_LONG_LONG+0 > 0) ++__lzo_gnuc_extension__ typedef long long lzo_llong_t__; ++__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; ++# define lzo_llong_t lzo_llong_t__ ++# define lzo_ullong_t lzo_ullong_t__ ++#endif ++#endif ++#if !defined(lzo_int16e_t) ++#if (LZO_SIZEOF_LONG == 2) ++# define lzo_int16e_t long ++# define lzo_uint16e_t unsigned long ++#elif (LZO_SIZEOF_INT == 2) ++# define lzo_int16e_t int ++# define lzo_uint16e_t unsigned int ++#elif (LZO_SIZEOF_SHORT == 2) ++# define lzo_int16e_t short int ++# define lzo_uint16e_t unsigned short int ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) ++ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); ++ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); ++# define lzo_int16e_t lzo_int16e_hi_t__ ++# define lzo_uint16e_t lzo_uint16e_hi_t__ ++#elif (LZO_SIZEOF___INT16 == 2) ++# define lzo_int16e_t __int16 ++# define lzo_uint16e_t unsigned __int16 ++#else ++#endif ++#endif ++#if defined(lzo_int16e_t) ++# define LZO_SIZEOF_LZO_INT16E_T 2 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) ++#endif ++#if !defined(lzo_int32e_t) ++#if (LZO_SIZEOF_LONG == 4) ++# define lzo_int32e_t long int ++# define lzo_uint32e_t unsigned long int ++#elif (LZO_SIZEOF_INT == 4) ++# define lzo_int32e_t int ++# define lzo_uint32e_t unsigned int ++#elif (LZO_SIZEOF_SHORT == 4) ++# define lzo_int32e_t short int ++# define lzo_uint32e_t unsigned short int ++#elif (LZO_SIZEOF_LONG_LONG == 4) ++# define lzo_int32e_t lzo_llong_t ++# define lzo_uint32e_t lzo_ullong_t ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) ++ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); ++ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); ++# define lzo_int32e_t lzo_int32e_si_t__ ++# define lzo_uint32e_t lzo_uint32e_si_t__ ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) ++ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); ++ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); ++# define lzo_int32e_t lzo_int32e_si_t__ ++# define lzo_uint32e_t lzo_uint32e_si_t__ ++# define LZO_INT32_C(c) (c##LL) ++# define LZO_UINT32_C(c) (c##ULL) ++#elif (LZO_SIZEOF___INT32 == 4) ++# define lzo_int32e_t __int32 ++# define lzo_uint32e_t unsigned __int32 ++#else ++#endif ++#endif ++#if defined(lzo_int32e_t) ++# define LZO_SIZEOF_LZO_INT32E_T 4 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) ++#endif ++#if !defined(lzo_int64e_t) ++#if (LZO_SIZEOF___INT64 == 8) ++# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) ++# define LZO_CFG_TYPE_PREFER___INT64 1 ++# endif ++#endif ++#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_int64e_t int ++# define lzo_uint64e_t unsigned int ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG == 8) ++# define lzo_int64e_t long int ++# define lzo_uint64e_t unsigned long int ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG ++#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) ++# define lzo_int64e_t lzo_llong_t ++# define lzo_uint64e_t lzo_ullong_t ++# if (LZO_CC_BORLANDC) ++# define LZO_INT64_C(c) ((c) + 0ll) ++# define LZO_UINT64_C(c) ((c) + 0ull) ++# elif 0 ++# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) ++# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) ++# else ++# define LZO_INT64_C(c) (c##LL) ++# define LZO_UINT64_C(c) (c##ULL) ++# endif ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG ++#elif (LZO_SIZEOF___INT64 == 8) ++# define lzo_int64e_t __int64 ++# define lzo_uint64e_t unsigned __int64 ++# if (LZO_CC_BORLANDC) ++# define LZO_INT64_C(c) ((c) + 0i64) ++# define LZO_UINT64_C(c) ((c) + 0ui64) ++# else ++# define LZO_INT64_C(c) (c##i64) ++# define LZO_UINT64_C(c) (c##ui64) ++# endif ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 ++#else ++#endif ++#endif ++#if defined(lzo_int64e_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) ++#endif ++#if !defined(lzo_int32l_t) ++#if defined(lzo_int32e_t) ++# define lzo_int32l_t lzo_int32e_t ++# define lzo_uint32l_t lzo_uint32e_t ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T ++#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_int32l_t int ++# define lzo_uint32l_t unsigned int ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG >= 4) ++# define lzo_int32l_t long int ++# define lzo_uint32l_t unsigned long int ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG ++#else ++# error "lzo_int32l_t" ++#endif ++#endif ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) ++#endif ++#if !defined(lzo_int64l_t) ++#if defined(lzo_int64e_t) ++# define lzo_int64l_t lzo_int64e_t ++# define lzo_uint64l_t lzo_uint64e_t ++# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T ++#else ++#endif ++#endif ++#if defined(lzo_int64l_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) ++#endif ++#if !defined(lzo_int32f_t) ++#if (LZO_SIZEOF_SIZE_T >= 8) ++# define lzo_int32f_t lzo_int64l_t ++# define lzo_uint32f_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T ++#else ++# define lzo_int32f_t lzo_int32l_t ++# define lzo_uint32f_t lzo_uint32l_t ++# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T ++#endif ++#endif ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) ++#endif ++#if !defined(lzo_int64f_t) ++#if defined(lzo_int64l_t) ++# define lzo_int64f_t lzo_int64l_t ++# define lzo_uint64f_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T ++#else ++#endif ++#endif ++#if defined(lzo_int64f_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) ++#endif ++#if !defined(lzo_intptr_t) ++#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) ++# define __LZO_INTPTR_T_IS_POINTER 1 ++ typedef char* lzo_intptr_t; ++ typedef char* lzo_uintptr_t; ++# define lzo_intptr_t lzo_intptr_t ++# define lzo_uintptr_t lzo_uintptr_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P ++#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) ++ typedef __w64 int lzo_intptr_t; ++ typedef __w64 unsigned int lzo_uintptr_t; ++# define lzo_intptr_t lzo_intptr_t ++# define lzo_uintptr_t lzo_uintptr_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t short ++# define lzo_uintptr_t unsigned short ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT ++#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_intptr_t int ++# define lzo_uintptr_t unsigned int ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t long ++# define lzo_uintptr_t unsigned long ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG ++#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t lzo_int64l_t ++# define lzo_uintptr_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T ++#else ++# error "lzo_intptr_t" ++#endif ++#endif ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) ++#endif ++#if !defined(lzo_word_t) ++#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) ++#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) ++# define lzo_word_t lzo_uintptr_t ++# define lzo_sword_t lzo_intptr_t ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T ++#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) ++# define lzo_word_t unsigned long ++# define lzo_sword_t long ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG ++#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) ++# define lzo_word_t unsigned int ++# define lzo_sword_t int ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT ++#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) ++# define lzo_word_t unsigned short ++# define lzo_sword_t short ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT ++#elif (LZO_WORDSIZE == 1) ++# define lzo_word_t unsigned char ++# define lzo_sword_t signed char ++# define LZO_SIZEOF_LZO_WORD_T 1 ++#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) ++# define lzo_word_t lzo_uint64l_t ++# define lzo_sword_t lzo_int64l_t ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T ++#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) ++#if 0 ++ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); ++ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); ++# define lzo_word_t lzo_word_t ++# define lzo_sword_t lzo_sword_t ++# define LZO_SIZEOF_LZO_WORD_T 16 ++#endif ++#else ++# error "lzo_word_t" ++#endif ++#endif ++#endif ++#if 1 && defined(lzo_word_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) ++#endif ++#if 1 ++#define lzo_int8_t signed char ++#define lzo_uint8_t unsigned char ++#define LZO_SIZEOF_LZO_INT8_T 1 ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) ++#endif ++#if defined(lzo_int16e_t) ++#define lzo_int16_t lzo_int16e_t ++#define lzo_uint16_t lzo_uint16e_t ++#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) ++#endif ++#if defined(lzo_int32e_t) ++#define lzo_int32_t lzo_int32e_t ++#define lzo_uint32_t lzo_uint32e_t ++#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) ++#endif ++#if defined(lzo_int64e_t) ++#define lzo_int64_t lzo_int64e_t ++#define lzo_uint64_t lzo_uint64e_t ++#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) ++#endif ++#if 1 ++#define lzo_int_least32_t lzo_int32l_t ++#define lzo_uint_least32_t lzo_uint32l_t ++#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) ++#endif ++#if defined(lzo_int64l_t) ++#define lzo_int_least64_t lzo_int64l_t ++#define lzo_uint_least64_t lzo_uint64l_t ++#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) ++#endif ++#if 1 ++#define lzo_int_fast32_t lzo_int32f_t ++#define lzo_uint_fast32_t lzo_uint32f_t ++#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) ++#endif ++#if defined(lzo_int64f_t) ++#define lzo_int_fast64_t lzo_int64f_t ++#define lzo_uint_fast64_t lzo_uint64f_t ++#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) ++#endif ++#if !defined(LZO_INT16_C) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) ++# define LZO_INT16_C(c) ((c) + 0) ++# define LZO_UINT16_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) ++# define LZO_INT16_C(c) ((c) + 0L) ++# define LZO_UINT16_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 2) ++# define LZO_INT16_C(c) (c) ++# define LZO_UINT16_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 2) ++# define LZO_INT16_C(c) (c##L) ++# define LZO_UINT16_C(c) (c##UL) ++# else ++# error "LZO_INT16_C" ++# endif ++#endif ++#if !defined(LZO_INT32_C) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) ++# define LZO_INT32_C(c) ((c) + 0) ++# define LZO_UINT32_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) ++# define LZO_INT32_C(c) ((c) + 0L) ++# define LZO_UINT32_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 4) ++# define LZO_INT32_C(c) (c) ++# define LZO_UINT32_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 4) ++# define LZO_INT32_C(c) (c##L) ++# define LZO_UINT32_C(c) (c##UL) ++# elif (LZO_SIZEOF_LONG_LONG >= 4) ++# define LZO_INT32_C(c) (c##LL) ++# define LZO_UINT32_C(c) (c##ULL) ++# else ++# error "LZO_INT32_C" ++# endif ++#endif ++#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) ++# define LZO_INT64_C(c) ((c) + 0) ++# define LZO_UINT64_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) ++# define LZO_INT64_C(c) ((c) + 0L) ++# define LZO_UINT64_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 8) ++# define LZO_INT64_C(c) (c) ++# define LZO_UINT64_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 8) ++# define LZO_INT64_C(c) (c##L) ++# define LZO_UINT64_C(c) (c##UL) ++# else ++# error "LZO_INT64_C" ++# endif ++#endif ++#endif + + #endif /* already included */ + +-/* vim:set ts=4 et: */ ++/* vim:set ts=4 sw=4 et: */ +diff --git a/grub-core/lib/minilzo/minilzo.c b/grub-core/lib/minilzo/minilzo.c +index 25a1f68b3..ab2be5f4f 100644 +--- a/grub-core/lib/minilzo/minilzo.c ++++ b/grub-core/lib/minilzo/minilzo.c +@@ -2,22 +2,7 @@ + + This file is part of the LZO real-time data compression library. + +- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ++ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or +@@ -67,12 +52,6 @@ + #if defined(__CYGWIN32__) && !defined(__CYGWIN__) + # define __CYGWIN__ __CYGWIN32__ + #endif +-#if defined(__IBMCPP__) && !defined(__IBMC__) +-# define __IBMC__ __IBMCPP__ +-#endif +-#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) +-# define __INTEL_COMPILER __ICL +-#endif + #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) + # define _ALL_SOURCE 1 + #endif +@@ -81,19 +60,30 @@ + # define __LONG_MAX__ 9223372036854775807L + # endif + #endif +-#if defined(__INTEL_COMPILER) && defined(__linux__) ++#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) ++#if defined(__ARMCC_VERSION) ++# pragma diag_suppress 193 ++#elif defined(__clang__) && defined(__clang_minor__) ++# pragma clang diagnostic ignored "-Wundef" ++#elif defined(__INTEL_COMPILER) + # pragma warning(disable: 193) +-#endif +-#if defined(__KEIL__) && defined(__C166__) +-# pragma warning disable = 322 +-#elif 0 && defined(__C251__) ++#elif defined(__KEIL__) && defined(__C166__) + # pragma warning disable = 322 +-#endif +-#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +-# if (_MSC_VER >= 1300) ++#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) ++# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) ++# pragma GCC diagnostic ignored "-Wundef" ++# endif ++#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) ++# if ((_MSC_VER-0) >= 1300) + # pragma warning(disable: 4668) + # endif + #endif ++#endif ++#if 0 && defined(__POCC__) && defined(_WIN32) ++# if (__POCC__ >= 400) ++# pragma warn(disable: 2216) ++# endif ++#endif + #if 0 && defined(__WATCOMC__) + # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) + # pragma warning 203 9 +@@ -102,13 +92,29 @@ + #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) + # pragma option -h + #endif ++#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) ++#ifndef _CRT_NONSTDC_NO_DEPRECATE ++#define _CRT_NONSTDC_NO_DEPRECATE 1 ++#endif ++#ifndef _CRT_NONSTDC_NO_WARNINGS ++#define _CRT_NONSTDC_NO_WARNINGS 1 ++#endif ++#ifndef _CRT_SECURE_NO_DEPRECATE ++#define _CRT_SECURE_NO_DEPRECATE 1 ++#endif ++#ifndef _CRT_SECURE_NO_WARNINGS ++#define _CRT_SECURE_NO_WARNINGS 1 ++#endif ++#endif + #if 0 +-#define LZO_0xffffL 0xfffful +-#define LZO_0xffffffffL 0xfffffffful ++#define LZO_0xffffUL 0xfffful ++#define LZO_0xffffffffUL 0xfffffffful + #else +-#define LZO_0xffffL 65535ul +-#define LZO_0xffffffffL 4294967295ul ++#define LZO_0xffffUL 65535ul ++#define LZO_0xffffffffUL 4294967295ul + #endif ++#define LZO_0xffffL LZO_0xffffUL ++#define LZO_0xffffffffL LZO_0xffffffffUL + #if (LZO_0xffffL == LZO_0xffffffffL) + # error "your preprocessor is broken 1" + #endif +@@ -123,6 +129,13 @@ + # error "your preprocessor is broken 4" + #endif + #endif ++#if defined(__COUNTER__) ++# ifndef LZO_CFG_USE_COUNTER ++# define LZO_CFG_USE_COUNTER 1 ++# endif ++#else ++# undef LZO_CFG_USE_COUNTER ++#endif + #if (UINT_MAX == LZO_0xffffL) + #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) + # if !defined(MSDOS) +@@ -253,14 +266,31 @@ + #endif + #define LZO_PP_STRINGIZE(x) #x + #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) ++#define LZO_PP_CONCAT0() /*empty*/ ++#define LZO_PP_CONCAT1(a) a + #define LZO_PP_CONCAT2(a,b) a ## b + #define LZO_PP_CONCAT3(a,b,c) a ## b ## c + #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d + #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e ++#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f ++#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g ++#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() ++#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) + #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) + #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) + #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) + #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) ++#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) ++#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) ++#define LZO_PP_EMPTY /*empty*/ ++#define LZO_PP_EMPTY0() /*empty*/ ++#define LZO_PP_EMPTY1(a) /*empty*/ ++#define LZO_PP_EMPTY2(a,b) /*empty*/ ++#define LZO_PP_EMPTY3(a,b,c) /*empty*/ ++#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ ++#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ ++#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ ++#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ + #if 1 + #define LZO_CPP_STRINGIZE(x) #x + #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) +@@ -268,12 +298,16 @@ + #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c + #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d + #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e ++#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f ++#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g + #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) + #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) + #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) + #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) ++#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) ++#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) + #endif +-#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) ++#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) + #if 1 && defined(__cplusplus) + # if !defined(__STDC_CONSTANT_MACROS) + # define __STDC_CONSTANT_MACROS 1 +@@ -283,9 +317,13 @@ + # endif + #endif + #if defined(__cplusplus) +-# define LZO_EXTERN_C extern "C" ++# define LZO_EXTERN_C extern "C" ++# define LZO_EXTERN_C_BEGIN extern "C" { ++# define LZO_EXTERN_C_END } + #else +-# define LZO_EXTERN_C extern ++# define LZO_EXTERN_C extern ++# define LZO_EXTERN_C_BEGIN /*empty*/ ++# define LZO_EXTERN_C_END /*empty*/ + #endif + #if !defined(__LZO_OS_OVERRIDE) + #if (LZO_OS_FREESTANDING) +@@ -386,12 +424,12 @@ + #elif defined(__VMS) + # define LZO_OS_VMS 1 + # define LZO_INFO_OS "vms" +-#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) + # define LZO_OS_CONSOLE 1 + # define LZO_OS_CONSOLE_PS2 1 + # define LZO_INFO_OS "console" + # define LZO_INFO_OS_CONSOLE "ps2" +-#elif (defined(__mips__) && defined(__psp__)) ++#elif defined(__mips__) && defined(__psp__) + # define LZO_OS_CONSOLE 1 + # define LZO_OS_CONSOLE_PSP 1 + # define LZO_INFO_OS "console" +@@ -419,9 +457,18 @@ + # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) + # define LZO_OS_POSIX_LINUX 1 + # define LZO_INFO_OS_POSIX "linux" +-# elif defined(__APPLE__) || defined(__MACOS__) +-# define LZO_OS_POSIX_MACOSX 1 +-# define LZO_INFO_OS_POSIX "macosx" ++# elif defined(__APPLE__) && defined(__MACH__) ++# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) ++# define LZO_OS_POSIX_DARWIN 1040 ++# define LZO_INFO_OS_POSIX "darwin_iphone" ++# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) ++# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ ++# define LZO_INFO_OS_POSIX "darwin" ++# else ++# define LZO_OS_POSIX_DARWIN 1 ++# define LZO_INFO_OS_POSIX "darwin" ++# endif ++# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN + # elif defined(__minix__) || defined(__minix) + # define LZO_OS_POSIX_MINIX 1 + # define LZO_INFO_OS_POSIX "minix" +@@ -456,18 +503,18 @@ + #endif + #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + # if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (UINT_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) +@@ -483,59 +530,65 @@ + # define LZO_INFO_CC "sdcc" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) + #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) +-# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) ++# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) + # define LZO_INFO_CC "Pathscale C" + # define LZO_INFO_CCVER __PATHSCALE__ +-#elif defined(__INTEL_COMPILER) +-# define LZO_CC_INTELC 1 ++# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# endif ++#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) ++# define LZO_CC_INTELC __INTEL_COMPILER + # define LZO_INFO_CC "Intel C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) +-# if defined(_WIN32) || defined(_WIN64) +-# define LZO_CC_SYNTAX_MSC 1 +-# else +-# define LZO_CC_SYNTAX_GNUC 1 ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_INTELC_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # endif + #elif defined(__POCC__) && defined(_WIN32) + # define LZO_CC_PELLESC 1 + # define LZO_INFO_CC "Pelles C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) +-#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) + # if defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) ++# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # else +-# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) ++# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) + # endif ++# define LZO_CC_ARMCC __ARMCC_VERSION ++# define LZO_INFO_CC "ARM C Compiler" ++# define LZO_INFO_CCVER __VERSION__ ++#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) + # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) +-# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) ++# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) + # else +-# define LZO_CC_CLANG_CLANG 0x010000L ++# define LZO_CC_CLANG 0x010000L ++# endif ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_CLANG_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # endif +-# define LZO_CC_CLANG LZO_CC_CLANG_GNUC + # define LZO_INFO_CC "clang" + # define LZO_INFO_CCVER __VERSION__ + #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) + # if defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) ++# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # else +-# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) ++# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) + # endif + # define LZO_CC_LLVM LZO_CC_LLVM_GNUC + # define LZO_INFO_CC "llvm-gcc" + # define LZO_INFO_CCVER __VERSION__ +-#elif defined(__GNUC__) && defined(__VERSION__) +-# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +-# elif defined(__GNUC_MINOR__) +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +-# else +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L) +-# endif +-# define LZO_INFO_CC "gcc" +-# define LZO_INFO_CCVER __VERSION__ + #elif defined(__ACK__) && defined(_ACK) + # define LZO_CC_ACK 1 + # define LZO_INFO_CC "Amsterdam Compiler Kit C" + # define LZO_INFO_CCVER "unknown" ++#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) ++# define LZO_CC_ARMCC __ARMCC_VERSION ++# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION ++# define LZO_INFO_CC "ARM C Compiler" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) + #elif defined(__AZTEC_C__) + # define LZO_CC_AZTECC 1 + # define LZO_INFO_CC "Aztec C" +@@ -560,10 +613,23 @@ + # define LZO_CC_DECC 1 + # define LZO_INFO_CC "DEC C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) ++#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) ++# define LZO_CC_GHS 1 ++# define LZO_INFO_CC "Green Hills C" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_GHS_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# endif + #elif defined(__HIGHC__) + # define LZO_CC_HIGHC 1 + # define LZO_INFO_CC "MetaWare High C" + # define LZO_INFO_CCVER "unknown" ++#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) ++# define LZO_CC_HPACC __HP_aCC ++# define LZO_INFO_CC "HP aCC" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) + #elif defined(__IAR_SYSTEMS_ICC__) + # define LZO_CC_IARC 1 + # define LZO_INFO_CC "IAR C" +@@ -572,10 +638,14 @@ + # else + # define LZO_INFO_CCVER "unknown" + # endif +-#elif defined(__IBMC__) +-# define LZO_CC_IBMC 1 ++#elif defined(__IBMC__) && ((__IBMC__-0) > 0) ++# define LZO_CC_IBMC __IBMC__ + # define LZO_INFO_CC "IBM C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) ++#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) ++# define LZO_CC_IBMC __IBMCPP__ ++# define LZO_INFO_CC "IBM C" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) + #elif defined(__KEIL__) && defined(__C166__) + # define LZO_CC_KEILC 1 + # define LZO_INFO_CC "Keil C" +@@ -592,16 +662,8 @@ + # else + # define LZO_INFO_CCVER "unknown" + # endif +-#elif defined(_MSC_VER) +-# define LZO_CC_MSC 1 +-# define LZO_INFO_CC "Microsoft C" +-# if defined(_MSC_FULL_VER) +-# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) +-# else +-# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) +-# endif +-#elif defined(__MWERKS__) +-# define LZO_CC_MWERKS 1 ++#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) ++# define LZO_CC_MWERKS __MWERKS__ + # define LZO_INFO_CC "Metrowerks C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) + #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) +@@ -612,6 +674,15 @@ + # define LZO_CC_PACIFICC 1 + # define LZO_INFO_CC "Pacific C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) ++#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) ++# if defined(__PGIC_PATCHLEVEL__) ++# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) ++# else ++# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" ++# endif ++# define LZO_INFO_CC "Portland Group PGI C" + #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) + # define LZO_CC_PGI 1 + # define LZO_INFO_CC "Portland Group PGI C" +@@ -626,7 +697,7 @@ + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) + #elif defined(__SUNPRO_C) + # define LZO_INFO_CC "SunPro C" +-# if ((__SUNPRO_C)+0 > 0) ++# if ((__SUNPRO_C-0) > 0) + # define LZO_CC_SUNPROC __SUNPRO_C + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) + # else +@@ -635,7 +706,7 @@ + # endif + #elif defined(__SUNPRO_CC) + # define LZO_INFO_CC "SunPro C" +-# if ((__SUNPRO_CC)+0 > 0) ++# if ((__SUNPRO_CC-0) > 0) + # define LZO_CC_SUNPROC __SUNPRO_CC + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) + # else +@@ -661,16 +732,46 @@ + #elif defined(__ZTC__) + # define LZO_CC_ZORTECHC 1 + # define LZO_INFO_CC "Zortech C" +-# if (__ZTC__ == 0x310) ++# if ((__ZTC__-0) == 0x310) + # define LZO_INFO_CCVER "0x310" + # else + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) + # endif ++#elif defined(__GNUC__) && defined(__VERSION__) ++# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# elif defined(__GNUC_MINOR__) ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) ++# else ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L) ++# endif ++# define LZO_INFO_CC "gcc" ++# define LZO_INFO_CCVER __VERSION__ ++#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_MSC _MSC_VER ++# define LZO_INFO_CC "Microsoft C" ++# if defined(_MSC_FULL_VER) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) ++# else ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) ++# endif + #else + # define LZO_CC_UNKNOWN 1 + # define LZO_INFO_CC "unknown" + # define LZO_INFO_CCVER "unknown" + #endif ++#if (LZO_CC_GNUC) && defined(__OPEN64__) ++# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) ++# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) ++# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC ++# endif ++#endif ++#if (LZO_CC_GNUC) && defined(__PCC__) ++# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) ++# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) ++# define LZO_CC_PCC_GNUC LZO_CC_GNUC ++# endif ++#endif + #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) + # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" + #endif +@@ -688,8 +789,10 @@ + # define LZO_INFO_ARCH "generic" + #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + # define LZO_ARCH_I086 1 +-# define LZO_ARCH_IA16 1 + # define LZO_INFO_ARCH "i086" ++#elif defined(__aarch64__) ++# define LZO_ARCH_ARM64 1 ++# define LZO_INFO_ARCH "arm64" + #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) + # define LZO_ARCH_ALPHA 1 + # define LZO_INFO_ARCH "alpha" +@@ -705,10 +808,10 @@ + # define LZO_INFO_ARCH "arm_thumb" + #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) + # define LZO_ARCH_ARM 1 +-# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) ++# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) + # define LZO_ARCH_ARM_THUMB 1 + # define LZO_INFO_ARCH "arm_thumb" +-# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) ++# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) + # define LZO_INFO_ARCH "arm" + # else + # define LZO_INFO_ARCH "arm" +@@ -826,53 +929,147 @@ + # error "FIXME - missing define for CPU architecture" + #endif + #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) +-# error "FIXME - missing WIN32 define for CPU architecture" ++# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" + #endif + #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) +-# error "FIXME - missing WIN64 define for CPU architecture" ++# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" + #endif + #if (LZO_OS_OS216 || LZO_OS_WIN16) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #endif +-#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) +-# error "this should not happen" ++#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) ++# define LZO_ARCH_X64 1 ++#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_AMD64 1 ++#endif ++#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) ++# define LZO_ARCH_AARCH64 1 ++#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_ARM64 1 ++#endif ++#if (LZO_ARCH_I386 && !LZO_ARCH_X86) ++# define LZO_ARCH_X86 1 ++#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_I386 1 ++#endif ++#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) ++# error "unexpected configuration - check your compiler defines" + #endif +-#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) +-# error "this should not happen" ++#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) ++# error "unexpected configuration - check your compiler defines" + #endif + #if (LZO_ARCH_I086) + # if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if (LZO_ARCH_I386) + # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" ++# endif ++#endif ++#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++# if !defined(LZO_TARGET_FEATURE_SSE2) ++# if defined(__SSE2__) ++# define LZO_TARGET_FEATURE_SSE2 1 ++# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) ++# define LZO_TARGET_FEATURE_SSE2 1 ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_SSSE3) ++# if (LZO_TARGET_FEATURE_SSE2) ++# if defined(__SSSE3__) ++# define LZO_TARGET_FEATURE_SSSE3 1 ++# elif defined(_MSC_VER) && defined(__AVX__) ++# define LZO_TARGET_FEATURE_SSSE3 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_SSE4_2) ++# if (LZO_TARGET_FEATURE_SSSE3) ++# if defined(__SSE4_2__) ++# define LZO_TARGET_FEATURE_SSE4_2 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_AVX) ++# if (LZO_TARGET_FEATURE_SSSE3) ++# if defined(__AVX__) ++# define LZO_TARGET_FEATURE_AVX 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_AVX2) ++# if (LZO_TARGET_FEATURE_AVX) ++# if defined(__AVX2__) ++# define LZO_TARGET_FEATURE_AVX2 1 ++# endif ++# endif ++# endif ++#endif ++#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ARCH_ARM) ++# if !defined(LZO_TARGET_FEATURE_NEON) ++# if defined(__ARM_NEON__) ++# define LZO_TARGET_FEATURE_NEON 1 ++# endif ++# endif ++#elif (LZO_ARCH_ARM64) ++# if !defined(LZO_TARGET_FEATURE_NEON) ++# if 1 ++# define LZO_TARGET_FEATURE_NEON 1 ++# endif + # endif + #endif +-#if !defined(__LZO_MM_OVERRIDE) ++#if 0 ++#elif !defined(__LZO_MM_OVERRIDE) + #if (LZO_ARCH_I086) + #if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + #endif + #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) + # define LZO_MM_TINY 1 +@@ -899,7 +1096,7 @@ + #elif (LZO_CC_ZORTECHC && defined(__VCM__)) + # define LZO_MM_LARGE 1 + #else +-# error "unknown memory model" ++# error "unknown LZO_ARCH_I086 memory model" + #endif + #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + #define LZO_HAVE_MM_HUGE_PTR 1 +@@ -922,10 +1119,10 @@ + #endif + #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) + # if (LZO_OS_DOS16) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # elif (LZO_CC_ZORTECHC) + # else +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #ifdef __cplusplus +@@ -957,7 +1154,7 @@ extern "C" { + #endif + #elif (LZO_ARCH_C166) + #if !defined(__MODEL__) +-# error "FIXME - C166 __MODEL__" ++# error "FIXME - LZO_ARCH_C166 __MODEL__" + #elif ((__MODEL__) == 0) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 1) +@@ -971,11 +1168,11 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - C166 __MODEL__" ++# error "FIXME - LZO_ARCH_C166 __MODEL__" + #endif + #elif (LZO_ARCH_MCS251) + #if !defined(__MODEL__) +-# error "FIXME - MCS251 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS251 __MODEL__" + #elif ((__MODEL__) == 0) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 2) +@@ -987,11 +1184,11 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - MCS251 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS251 __MODEL__" + #endif + #elif (LZO_ARCH_MCS51) + #if !defined(__MODEL__) +-# error "FIXME - MCS51 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS51 __MODEL__" + #elif ((__MODEL__) == 1) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 2) +@@ -1003,7 +1200,7 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - MCS51 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS51 __MODEL__" + #endif + #elif (LZO_ARCH_CRAY_PVP) + # define LZO_MM_PVP 1 +@@ -1030,462 +1227,270 @@ extern "C" { + # error "unknown memory model" + #endif + #endif +-#if defined(SIZEOF_SHORT) +-# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) ++#if !defined(__lzo_gnuc_extension__) ++#if (LZO_CC_GNUC >= 0x020800ul) ++# define __lzo_gnuc_extension__ __extension__ ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_gnuc_extension__ __extension__ ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_gnuc_extension__ __extension__ ++#else + #endif +-#if defined(SIZEOF_INT) +-# define LZO_SIZEOF_INT (SIZEOF_INT) + #endif +-#if defined(SIZEOF_LONG) +-# define LZO_SIZEOF_LONG (SIZEOF_LONG) ++#if !defined(__lzo_gnuc_extension__) ++# define __lzo_gnuc_extension__ /*empty*/ + #endif +-#if defined(SIZEOF_LONG_LONG) +-# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) ++#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 ++# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++# else ++# define LZO_CFG_USE_NEW_STYLE_CASTS 1 ++# endif + #endif +-#if defined(SIZEOF___INT16) +-# define LZO_SIZEOF___INT16 (SIZEOF___INT16) ++#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 + #endif +-#if defined(SIZEOF___INT32) +-# define LZO_SIZEOF___INT32 (SIZEOF___INT32) ++#if !defined(__cplusplus) ++# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) ++# undef LZO_CFG_USE_NEW_STYLE_CASTS ++# endif ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 + #endif +-#if defined(SIZEOF___INT64) +-# define LZO_SIZEOF___INT64 (SIZEOF___INT64) ++#if !defined(LZO_REINTERPRET_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) ++# endif + #endif +-#if defined(SIZEOF_VOID_P) +-# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) ++#if !defined(LZO_REINTERPRET_CAST) ++# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) + #endif +-#if defined(SIZEOF_SIZE_T) +-# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) ++#if !defined(LZO_STATIC_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_STATIC_CAST(t,e) (static_cast (e)) ++# endif + #endif +-#if defined(SIZEOF_PTRDIFF_T) +-# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) ++#if !defined(LZO_STATIC_CAST) ++# define LZO_STATIC_CAST(t,e) ((t) (e)) + #endif +-#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) +-#if !defined(LZO_SIZEOF_SHORT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_SHORT 8 +-# elif (USHRT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,7) == 1) +-# define LZO_SIZEOF_SHORT 1 +-# elif (__LZO_LSR(USHRT_MAX,15) == 1) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,31) == 1) +-# define LZO_SIZEOF_SHORT 4 +-# elif (__LZO_LSR(USHRT_MAX,63) == 1) +-# define LZO_SIZEOF_SHORT 8 +-# elif (__LZO_LSR(USHRT_MAX,127) == 1) +-# define LZO_SIZEOF_SHORT 16 +-# else +-# error "LZO_SIZEOF_SHORT" +-# endif ++#if !defined(LZO_STATIC_CAST2) ++# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) + #endif +-#if !defined(LZO_SIZEOF_INT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_INT 8 +-# elif (UINT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_INT 2 +-# elif (UINT_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,7) == 1) +-# define LZO_SIZEOF_INT 1 +-# elif (__LZO_LSR(UINT_MAX,15) == 1) +-# define LZO_SIZEOF_INT 2 +-# elif (__LZO_LSR(UINT_MAX,31) == 1) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,63) == 1) +-# define LZO_SIZEOF_INT 8 +-# elif (__LZO_LSR(UINT_MAX,127) == 1) +-# define LZO_SIZEOF_INT 16 +-# else +-# error "LZO_SIZEOF_INT" ++#if !defined(LZO_UNCONST_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNCONST_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNCONST_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG) +-# if (ULONG_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,7) == 1) +-# define LZO_SIZEOF_LONG 1 +-# elif (__LZO_LSR(ULONG_MAX,15) == 1) +-# define LZO_SIZEOF_LONG 2 +-# elif (__LZO_LSR(ULONG_MAX,31) == 1) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,63) == 1) +-# define LZO_SIZEOF_LONG 8 +-# elif (__LZO_LSR(ULONG_MAX,127) == 1) +-# define LZO_SIZEOF_LONG 16 +-# else +-# error "LZO_SIZEOF_LONG" ++#if !defined(LZO_UNCONST_CAST) ++# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) ++#endif ++#if !defined(LZO_UNCONST_VOLATILE_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) +-# if (LZO_CC_GNUC >= 0x030300ul) +-# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) +-# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG +-# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) +-# define LZO_SIZEOF_LONG_LONG 4 +-# endif +-# endif ++#if !defined(LZO_UNCONST_VOLATILE_CAST) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) ++#endif ++#if !defined(LZO_UNVOLATILE_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) + # endif + #endif ++#if !defined(LZO_UNVOLATILE_CAST) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-#if (LZO_ARCH_I086 && LZO_CC_DMC) +-#elif (LZO_CC_CILLY) && defined(__GNUC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_OS_WIN64 || defined(_WIN64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) +-#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define LZO_SIZEOF_LONG_LONG 8 ++#if !defined(LZO_UNVOLATILE_CONST_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) ++# endif + #endif ++#if !defined(LZO_UNVOLATILE_CONST_CAST) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) + #endif ++#if !defined(LZO_PCAST) ++# if (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_PCAST(t,e) ((t) (e)) ++# endif + #endif +-#if defined(__cplusplus) && (LZO_CC_GNUC) +-# if (LZO_CC_GNUC < 0x020800ul) +-# undef LZO_SIZEOF_LONG_LONG ++#if !defined(LZO_PCAST) ++# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) ++#endif ++#if !defined(LZO_CCAST) ++# if (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_CCAST(t,e) ((t) (e)) + # endif + #endif +-#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) +-# undef LZO_SIZEOF_LONG_LONG ++#if !defined(LZO_CCAST) ++# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) + #endif +-#if !defined(LZO_SIZEOF_VOID_P) +-#if (LZO_ARCH_I086) +-# define __LZO_WORDSIZE 2 +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) +-# define LZO_SIZEOF_VOID_P 2 +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# error "LZO_MM" ++#if !defined(LZO_ICONV) ++# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) ++#endif ++#if !defined(LZO_ICAST) ++# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) ++#endif ++#if !defined(LZO_ITRUNC) ++# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) ++#endif ++#if !defined(__lzo_cte) ++# if (LZO_CC_MSC || LZO_CC_WATCOMC) ++# define __lzo_cte(e) ((void)0,(e)) ++# elif 1 ++# define __lzo_cte(e) ((void)0,(e)) + # endif +-#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) +-# define __LZO_WORDSIZE 1 +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_H8300) +-# if defined(__NORMAL_MODE__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 2 +-# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define __LZO_WORDSIZE 2 +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT +-# endif +-#elif (LZO_ARCH_M16C) +-# define __LZO_WORDSIZE 2 +-# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 4 +-#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_OS_OS400 || defined(__OS400__)) +-# define __LZO_WORDSIZE LZO_SIZEOF_LONG +-# define LZO_SIZEOF_VOID_P 16 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_VOID_P 8 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_ARCH_SPU) +-# if 0 +-# define __LZO_WORDSIZE 16 +-# endif +-# define LZO_SIZEOF_VOID_P 4 +-#else +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG + #endif ++#if !defined(__lzo_cte) ++# define __lzo_cte(e) (e) + #endif +-#if !defined(LZO_WORDSIZE) +-# if defined(__LZO_WORDSIZE) +-# define LZO_WORDSIZE __LZO_WORDSIZE ++#if !defined(LZO_BLOCK_BEGIN) ++# define LZO_BLOCK_BEGIN do { ++# define LZO_BLOCK_END } while __lzo_cte(0) ++#endif ++#if !defined(LZO_UNUSED) ++# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) ++# define LZO_UNUSED(var) ((void) &var) ++# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) ++# define LZO_UNUSED(var) if (&var) ; else ++# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) ++# define LZO_UNUSED(var) ((void) &var) ++# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNUSED(var) ((void) var) ++# elif (LZO_CC_MSC && (_MSC_VER < 900)) ++# define LZO_UNUSED(var) if (&var) ; else ++# elif (LZO_CC_KEILC) ++# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} ++# elif (LZO_CC_PACIFICC) ++# define LZO_UNUSED(var) ((void) sizeof(var)) ++# elif (LZO_CC_WATCOMC) && defined(__cplusplus) ++# define LZO_UNUSED(var) ((void) var) + # else +-# define LZO_WORDSIZE LZO_SIZEOF_VOID_P ++# define LZO_UNUSED(var) ((void) &var) + # endif + #endif +-#if !defined(LZO_SIZEOF_SIZE_T) +-#if (LZO_ARCH_I086 || LZO_ARCH_M16C) +-# define LZO_SIZEOF_SIZE_T 2 +-#else +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P +-#endif +-#endif +-#if !defined(LZO_SIZEOF_PTRDIFF_T) +-#if (LZO_ARCH_I086) +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE) +-# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) +-# define LZO_SIZEOF_PTRDIFF_T 4 +-# else +-# define LZO_SIZEOF_PTRDIFF_T 2 +-# endif ++#if !defined(LZO_UNUSED_FUNC) ++# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) ++# define LZO_UNUSED_FUNC(func) ((void) func) ++# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) ++# define LZO_UNUSED_FUNC(func) if (func) ; else ++# elif (LZO_CC_CLANG || LZO_CC_LLVM) ++# define LZO_UNUSED_FUNC(func) ((void) &func) ++# elif (LZO_CC_MSC && (_MSC_VER < 900)) ++# define LZO_UNUSED_FUNC(func) if (func) ; else ++# elif (LZO_CC_MSC) ++# define LZO_UNUSED_FUNC(func) ((void) &func) ++# elif (LZO_CC_KEILC || LZO_CC_PELLESC) ++# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} + # else +-# error "LZO_MM" ++# define LZO_UNUSED_FUNC(func) ((void) func) + # endif +-#else +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T +-#endif + #endif +-#if (LZO_ABI_NEUTRAL_ENDIAN) +-# undef LZO_ABI_BIG_ENDIAN +-# undef LZO_ABI_LITTLE_ENDIAN +-#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) +-#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +-# if (__LITTLE_ENDIAN__ == 1) +-# define LZO_ABI_LITTLE_ENDIAN 1 ++#if !defined(LZO_UNUSED_LABEL) ++# if (LZO_CC_CLANG >= 0x020800ul) ++# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) ++# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) ++# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l + # else +-# define LZO_ABI_BIG_ENDIAN 1 ++# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l + # endif +-#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#endif +-#endif +-#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +-# error "this should not happen" +-#endif +-#if (LZO_ABI_BIG_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "be" +-#elif (LZO_ABI_LITTLE_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "le" +-#elif (LZO_ABI_NEUTRAL_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "neutral" +-#endif +-#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_I8LP16 1 +-# define LZO_INFO_ABI_PM "i8lp16" +-#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_ILP16 1 +-# define LZO_INFO_ABI_PM "ilp16" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_ILP32 1 +-# define LZO_INFO_ABI_PM "ilp32" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) +-# define LZO_ABI_LLP64 1 +-# define LZO_INFO_ABI_PM "llp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_LP64 1 +-# define LZO_INFO_ABI_PM "lp64" +-#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_ILP64 1 +-# define LZO_INFO_ABI_PM "ilp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_IP32L64 1 +-# define LZO_INFO_ABI_PM "ip32l64" + #endif +-#if !defined(__LZO_LIBC_OVERRIDE) +-#if (LZO_LIBC_NAKED) +-# define LZO_INFO_LIBC "naked" +-#elif (LZO_LIBC_FREESTANDING) +-# define LZO_INFO_LIBC "freestanding" +-#elif (LZO_LIBC_MOSTLY_FREESTANDING) +-# define LZO_INFO_LIBC "mfreestanding" +-#elif (LZO_LIBC_ISOC90) +-# define LZO_INFO_LIBC "isoc90" +-#elif (LZO_LIBC_ISOC99) +-# define LZO_INFO_LIBC "isoc99" +-#elif defined(__dietlibc__) +-# define LZO_LIBC_DIETLIBC 1 +-# define LZO_INFO_LIBC "dietlibc" +-#elif defined(_NEWLIB_VERSION) +-# define LZO_LIBC_NEWLIB 1 +-# define LZO_INFO_LIBC "newlib" +-#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) +-# if defined(__UCLIBC_SUBLEVEL__) +-# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) ++#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) ++# if 0 ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var ++# elif 0 && (LZO_CC_GNUC) ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var + # else +-# define LZO_LIBC_UCLIBC 0x00090bL ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init + # endif +-# define LZO_INFO_LIBC "uclibc" +-#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +-# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) +-# define LZO_INFO_LIBC "glibc" +-#elif (LZO_CC_MWERKS) && defined(__MSL__) +-# define LZO_LIBC_MSL __MSL__ +-# define LZO_INFO_LIBC "msl" +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) +-# define LZO_LIBC_ISOC90 1 +-# define LZO_INFO_LIBC "isoc90" +-#else +-# define LZO_LIBC_DEFAULT 1 +-# define LZO_INFO_LIBC "default" +-#endif +-#endif +-#if !defined(__lzo_gnuc_extension__) +-#if (LZO_CC_GNUC >= 0x020800ul) +-# define __lzo_gnuc_extension__ __extension__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_gnuc_extension__ __extension__ +-#else +-# define __lzo_gnuc_extension__ /*empty*/ +-#endif +-#endif +-#if !defined(__lzo_ua_volatile) +-# define __lzo_ua_volatile volatile +-#endif +-#if !defined(__lzo_alignof) +-#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +-# define __lzo_alignof(e) __alignof(e) +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) +-# define __lzo_alignof(e) __alignof__(e) +-#endif +-#endif +-#if defined(__lzo_alignof) +-# define __lzo_HAVE_alignof 1 +-#endif +-#if !defined(__lzo_constructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_constructor __attribute__((__constructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_constructor __attribute__((__constructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_constructor __attribute__((__constructor__)) +-#endif +-#endif +-#if defined(__lzo_constructor) +-# define __lzo_HAVE_constructor 1 +-#endif +-#if !defined(__lzo_destructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_destructor __attribute__((__destructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_destructor __attribute__((__destructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_destructor __attribute__((__destructor__)) +-#endif +-#endif +-#if defined(__lzo_destructor) +-# define __lzo_HAVE_destructor 1 +-#endif +-#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) +-# error "this should not happen" + #endif + #if !defined(__lzo_inline) + #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) + #elif defined(__cplusplus) + # define __lzo_inline inline ++#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) ++# define __lzo_inline inline + #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) + # define __lzo_inline __inline +-#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) + # define __lzo_inline __inline__ + #elif (LZO_CC_DMC) + # define __lzo_inline __inline ++#elif (LZO_CC_GHS) ++# define __lzo_inline __inline__ ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_inline __inline__ + #elif (LZO_CC_INTELC) + # define __lzo_inline __inline + #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) + # define __lzo_inline __inline + #elif (LZO_CC_MSC && (_MSC_VER >= 900)) + # define __lzo_inline __inline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_inline __inline__ +-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define __lzo_inline inline + #endif + #endif + #if defined(__lzo_inline) ++# ifndef __lzo_HAVE_inline + # define __lzo_HAVE_inline 1 ++# endif + #else + # define __lzo_inline /*empty*/ + #endif + #if !defined(__lzo_forceinline) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #endif + #endif + #if defined(__lzo_forceinline) ++# ifndef __lzo_HAVE_forceinline + # define __lzo_HAVE_forceinline 1 ++# endif + #else +-# define __lzo_forceinline /*empty*/ ++# define __lzo_forceinline __lzo_inline + #endif + #if !defined(__lzo_noinline) + #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) + # define __lzo_noinline __attribute__((__noinline__,__used__)) + #elif (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_noinline __attribute__((__noinline__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) + # define __lzo_noinline __declspec(noinline) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_noinline __attribute__((__noinline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) + # define __lzo_noinline __declspec(noinline) +@@ -1494,179 +1499,409 @@ extern "C" { + # else + # define __lzo_noinline __declspec(noinline) + # endif +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_noinline __attribute__((__noinline__)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_noinline __attribute__((__noinline__)) + #endif + #endif + #if defined(__lzo_noinline) ++# ifndef __lzo_HAVE_noinline + # define __lzo_HAVE_noinline 1 ++# endif + #else + # define __lzo_noinline /*empty*/ + #endif + #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + #endif +-#if !defined(__lzo_noreturn) +-#if (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) +-# define __lzo_noreturn __declspec(noreturn) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +-# define __lzo_noreturn __declspec(noreturn) ++#if !defined(__lzo_static_inline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline + #endif + #endif +-#if defined(__lzo_noreturn) +-# define __lzo_HAVE_noreturn 1 +-#else +-# define __lzo_noreturn /*empty*/ ++#if !defined(__lzo_static_inline) ++# define __lzo_static_inline static __lzo_inline + #endif +-#if !defined(__lzo_nothrow) +-#if (LZO_CC_GNUC >= 0x030300ul) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) +-# define __lzo_nothrow __declspec(nothrow) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#if !defined(__lzo_static_forceinline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline ++#endif ++#endif ++#if !defined(__lzo_static_forceinline) ++# define __lzo_static_forceinline static __lzo_forceinline ++#endif ++#if !defined(__lzo_static_noinline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline ++#endif ++#endif ++#if !defined(__lzo_static_noinline) ++# define __lzo_static_noinline static __lzo_noinline ++#endif ++#if !defined(__lzo_c99_extern_inline) ++#if defined(__GNUC_GNU_INLINE__) ++# define __lzo_c99_extern_inline __lzo_inline ++#elif defined(__GNUC_STDC_INLINE__) ++# define __lzo_c99_extern_inline extern __lzo_inline ++#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) ++# define __lzo_c99_extern_inline extern __lzo_inline ++#endif ++#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) ++# define __lzo_c99_extern_inline __lzo_inline ++#endif ++#endif ++#if defined(__lzo_c99_extern_inline) ++# ifndef __lzo_HAVE_c99_extern_inline ++# define __lzo_HAVE_c99_extern_inline 1 ++# endif ++#else ++# define __lzo_c99_extern_inline /*empty*/ ++#endif ++#if !defined(__lzo_may_alias) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_CLANG >= 0x020900ul) ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#endif ++#endif ++#if defined(__lzo_may_alias) ++# ifndef __lzo_HAVE_may_alias ++# define __lzo_HAVE_may_alias 1 ++# endif ++#else ++# define __lzo_may_alias /*empty*/ ++#endif ++#if !defined(__lzo_noreturn) ++#if (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) ++# define __lzo_noreturn __declspec(noreturn) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) ++# define __lzo_noreturn __declspec(noreturn) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#endif ++#endif ++#if defined(__lzo_noreturn) ++# ifndef __lzo_HAVE_noreturn ++# define __lzo_HAVE_noreturn 1 ++# endif ++#else ++# define __lzo_noreturn /*empty*/ ++#endif ++#if !defined(__lzo_nothrow) ++#if (LZO_CC_GNUC >= 0x030300ul) ++# define __lzo_nothrow __attribute__((__nothrow__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) ++# define __lzo_nothrow __declspec(nothrow) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) ++# define __lzo_nothrow __attribute__((__nothrow__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_nothrow __attribute__((__nothrow__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) + # define __lzo_nothrow __declspec(nothrow) + #endif + #endif + #if defined(__lzo_nothrow) ++# ifndef __lzo_HAVE_nothrow + # define __lzo_HAVE_nothrow 1 ++# endif + #else + # define __lzo_nothrow /*empty*/ + #endif + #if !defined(__lzo_restrict) + #if (LZO_CC_GNUC >= 0x030400ul) + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM) ++#elif (LZO_CC_IBMC >= 1210) ++# define __lzo_restrict __restrict__ ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) ++# define __lzo_restrict __restrict__ ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) + # define __lzo_restrict __restrict__ + #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) + # define __lzo_restrict __restrict ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_restrict __restrict__ + #endif + #endif + #if defined(__lzo_restrict) ++# ifndef __lzo_HAVE_restrict + # define __lzo_HAVE_restrict 1 ++# endif + #else + # define __lzo_restrict /*empty*/ + #endif ++#if !defined(__lzo_alignof) ++#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_GHS) && !defined(__cplusplus) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) ++#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_alignof(e) __alignof(e) ++#elif (LZO_CC_SUNPROC >= 0x5100) ++# define __lzo_alignof(e) __alignof__(e) ++#endif ++#endif ++#if defined(__lzo_alignof) ++# ifndef __lzo_HAVE_alignof ++# define __lzo_HAVE_alignof 1 ++# endif ++#endif ++#if !defined(__lzo_struct_packed) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) ++#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) ++#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++# define __lzo_struct_packed(s) struct s { ++# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_struct_packed(s) struct s { ++# define __lzo_struct_packed_end() } __attribute__((__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { ++# define __lzo_struct_packed_end() } __attribute__((__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { ++# define __lzo_struct_packed_end() } __pragma(pack(pop)); ++#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) ++# define __lzo_struct_packed(s) _Packed struct s { ++# define __lzo_struct_packed_end() }; ++#endif ++#endif ++#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) ++# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) ++#endif ++#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) ++# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() ++#endif ++#if !defined(__lzo_byte_struct) ++#if defined(__lzo_struct_packed) ++# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() ++# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() ++#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); ++# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); ++#endif ++#endif ++#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) ++# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) ++#endif ++#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) ++#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) ++#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_CILLY || LZO_CC_PCC) ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_struct_align16(s) struct __declspec(align(16)) s { ++# define __lzo_struct_align16_end() }; ++# define __lzo_struct_align32(s) struct __declspec(align(32)) s { ++# define __lzo_struct_align32_end() }; ++# define __lzo_struct_align64(s) struct __declspec(align(64)) s { ++# define __lzo_struct_align64_end() }; ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_struct_align16(s) struct s { ++# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); ++# define __lzo_struct_align32(s) struct s { ++# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); ++# define __lzo_struct_align64(s) struct s { ++# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); ++#endif ++#endif ++#if !defined(__lzo_union_um) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) ++#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) ++#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_union_am(s) union s { ++# define __lzo_union_am_end() } __lzo_may_alias; ++# define __lzo_union_um(s) union s { ++# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { ++# define __lzo_union_am_end() } __lzo_may_alias; ++# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { ++# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_union_um(s) __pragma(pack(push,1)) union s { ++# define __lzo_union_um_end() } __pragma(pack(pop)); ++#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) ++# define __lzo_union_um(s) _Packed union s { ++# define __lzo_union_um_end() }; ++#endif ++#endif ++#if !defined(__lzo_union_am) ++# define __lzo_union_am(s) union s { ++# define __lzo_union_am_end() }; ++#endif ++#if !defined(__lzo_constructor) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_constructor __attribute__((__constructor__,__used__)) ++#elif (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_constructor __attribute__((__constructor__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) ++# define __lzo_constructor __attribute__((__constructor__,__used__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_constructor __attribute__((__constructor__)) ++#endif ++#endif ++#if defined(__lzo_constructor) ++# ifndef __lzo_HAVE_constructor ++# define __lzo_HAVE_constructor 1 ++# endif ++#endif ++#if !defined(__lzo_destructor) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_destructor __attribute__((__destructor__,__used__)) ++#elif (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_destructor __attribute__((__destructor__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) ++# define __lzo_destructor __attribute__((__destructor__,__used__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_destructor __attribute__((__destructor__)) ++#endif ++#endif ++#if defined(__lzo_destructor) ++# ifndef __lzo_HAVE_destructor ++# define __lzo_HAVE_destructor 1 ++# endif ++#endif ++#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) ++# error "unexpected configuration - check your compiler defines" ++#endif + #if !defined(__lzo_likely) && !defined(__lzo_unlikely) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) ++#elif (LZO_CC_IBMC >= 1010) ++# define __lzo_likely(e) (__builtin_expect(!!(e),1)) ++# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #endif + #endif + #if defined(__lzo_likely) ++# ifndef __lzo_HAVE_likely + # define __lzo_HAVE_likely 1 ++# endif + #else + # define __lzo_likely(e) (e) + #endif + #if defined(__lzo_unlikely) ++# ifndef __lzo_HAVE_unlikely + # define __lzo_HAVE_unlikely 1 ++# endif + #else + # define __lzo_unlikely(e) (e) + #endif +-#if !defined(LZO_UNUSED) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED(var) ((void) &var) +-# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNUSED(var) ((void) var) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_KEILC) +-# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} +-# elif (LZO_CC_PACIFICC) +-# define LZO_UNUSED(var) ((void) sizeof(var)) +-# elif (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED(var) ((void) var) ++#if !defined(__lzo_static_unused_void_func) ++# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) + # else +-# define LZO_UNUSED(var) ((void) &var) ++# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) + # endif + #endif +-#if !defined(LZO_UNUSED_FUNC) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED_FUNC(func) ((void) func) +-# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_CLANG || LZO_CC_LLVM) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_MSC) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_KEILC || LZO_CC_PELLESC) +-# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} ++#if !defined(__lzo_loop_forever) ++# if (LZO_CC_IBMC) ++# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END + # else +-# define LZO_UNUSED_FUNC(func) ((void) func) ++# define __lzo_loop_forever() do { ; } while __lzo_cte(1) + # endif + #endif +-#if !defined(LZO_UNUSED_LABEL) +-# if (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) +-# define LZO_UNUSED_LABEL(l) if (0) goto l +-# else +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# endif ++#if !defined(__lzo_unreachable) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) ++# define __lzo_unreachable() __builtin_unreachable(); ++#elif (LZO_CC_GNUC >= 0x040500ul) ++# define __lzo_unreachable() __builtin_unreachable(); ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 ++# define __lzo_unreachable() __builtin_unreachable(); + #endif +-#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) ++#endif ++#if defined(__lzo_unreachable) ++# ifndef __lzo_HAVE_unreachable ++# define __lzo_HAVE_unreachable 1 ++# endif ++#else + # if 0 +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var +-# elif 0 && (LZO_CC_GNUC) +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var ++# define __lzo_unreachable() ((void)0); + # else +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init ++# define __lzo_unreachable() __lzo_loop_forever(); + # endif + #endif +-#if !defined(LZO_UNCONST_CAST) +-# if 0 && defined(__cplusplus) +-# define LZO_UNCONST_CAST(t,e) (const_cast (e)) +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) +-# else +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) +-# endif ++#ifndef __LZO_CTA_NAME ++#if (LZO_CFG_USE_COUNTER) ++# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) ++#else ++# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) ++#endif + #endif + #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) + # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END ++# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END ++# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END + # else +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END + # endif + #endif + #if !defined(LZO_COMPILE_TIME_ASSERT) + # if (LZO_CC_AZTECC) +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} + # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; ++# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) ++# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} ++# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) ++# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} ++# elif (LZO_CC_GNUC >= 0x040700ul) ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} + # elif (LZO_CC_MSC && (_MSC_VER < 900)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # else +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} + # endif + #endif ++LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) ++#if defined(__cplusplus) ++extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) + #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) +@@ -1730,6 +1965,7 @@ extern "C" { + # define __lzo_cdecl_va __lzo_cdecl + #endif + #if !(LZO_CFG_NO_WINDOWS_H) ++#if !defined(LZO_HAVE_WINDOWS_H) + #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) + # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) +@@ -1739,60 +1975,614 @@ extern "C" { + # endif + #endif + #endif ++#endif ++#ifndef LZO_SIZEOF_SHORT ++#if defined(SIZEOF_SHORT) ++# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) ++#elif defined(__SIZEOF_SHORT__) ++# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_INT ++#if defined(SIZEOF_INT) ++# define LZO_SIZEOF_INT (SIZEOF_INT) ++#elif defined(__SIZEOF_INT__) ++# define LZO_SIZEOF_INT (__SIZEOF_INT__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_LONG ++#if defined(SIZEOF_LONG) ++# define LZO_SIZEOF_LONG (SIZEOF_LONG) ++#elif defined(__SIZEOF_LONG__) ++# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_LONG_LONG ++#if defined(SIZEOF_LONG_LONG) ++# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) ++#elif defined(__SIZEOF_LONG_LONG__) ++# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT16 ++#if defined(SIZEOF___INT16) ++# define LZO_SIZEOF___INT16 (SIZEOF___INT16) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT32 ++#if defined(SIZEOF___INT32) ++# define LZO_SIZEOF___INT32 (SIZEOF___INT32) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT64 ++#if defined(SIZEOF___INT64) ++# define LZO_SIZEOF___INT64 (SIZEOF___INT64) ++#endif ++#endif ++#ifndef LZO_SIZEOF_VOID_P ++#if defined(SIZEOF_VOID_P) ++# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) ++#elif defined(__SIZEOF_POINTER__) ++# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_SIZE_T ++#if defined(SIZEOF_SIZE_T) ++# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) ++#elif defined(__SIZEOF_SIZE_T__) ++# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_PTRDIFF_T ++#if defined(SIZEOF_PTRDIFF_T) ++# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) ++#elif defined(__SIZEOF_PTRDIFF_T__) ++# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) ++#endif ++#endif ++#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) ++#if !defined(LZO_SIZEOF_SHORT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_SHORT 8 ++# elif (USHRT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,7) == 1) ++# define LZO_SIZEOF_SHORT 1 ++# elif (__LZO_LSR(USHRT_MAX,15) == 1) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,31) == 1) ++# define LZO_SIZEOF_SHORT 4 ++# elif (__LZO_LSR(USHRT_MAX,63) == 1) ++# define LZO_SIZEOF_SHORT 8 ++# elif (__LZO_LSR(USHRT_MAX,127) == 1) ++# define LZO_SIZEOF_SHORT 16 ++# else ++# error "LZO_SIZEOF_SHORT" ++# endif ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) ++#if !defined(LZO_SIZEOF_INT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_INT 8 ++# elif (UINT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_INT 2 ++# elif (UINT_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,7) == 1) ++# define LZO_SIZEOF_INT 1 ++# elif (__LZO_LSR(UINT_MAX,15) == 1) ++# define LZO_SIZEOF_INT 2 ++# elif (__LZO_LSR(UINT_MAX,31) == 1) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,63) == 1) ++# define LZO_SIZEOF_INT 8 ++# elif (__LZO_LSR(UINT_MAX,127) == 1) ++# define LZO_SIZEOF_INT 16 ++# else ++# error "LZO_SIZEOF_INT" ++# endif ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) ++#if !defined(LZO_SIZEOF_LONG) ++# if (ULONG_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_LONG 4 ++# elif (__LZO_LSR(ULONG_MAX,7) == 1) ++# define LZO_SIZEOF_LONG 1 ++# elif (__LZO_LSR(ULONG_MAX,15) == 1) ++# define LZO_SIZEOF_LONG 2 ++# elif (__LZO_LSR(ULONG_MAX,31) == 1) ++# define LZO_SIZEOF_LONG 4 ++# elif (__LZO_LSR(ULONG_MAX,39) == 1) ++# define LZO_SIZEOF_LONG 5 ++# elif (__LZO_LSR(ULONG_MAX,63) == 1) ++# define LZO_SIZEOF_LONG 8 ++# elif (__LZO_LSR(ULONG_MAX,127) == 1) ++# define LZO_SIZEOF_LONG 16 ++# else ++# error "LZO_SIZEOF_LONG" ++# endif ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) ++# if (LZO_CC_GNUC >= 0x030300ul) ++# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) ++# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG ++# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) ++# define LZO_SIZEOF_LONG_LONG 4 ++# endif ++# endif ++# endif ++#endif ++#endif ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++#if (LZO_ARCH_I086 && LZO_CC_DMC) ++#elif (LZO_CC_CILLY) && defined(__GNUC__) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_OS_WIN64 || defined(_WIN64)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) ++#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ++# define LZO_SIZEOF_LONG_LONG 8 ++#endif ++#endif ++#endif ++#if defined(__cplusplus) && (LZO_CC_GNUC) ++# if (LZO_CC_GNUC < 0x020800ul) ++# undef LZO_SIZEOF_LONG_LONG ++# endif ++#endif ++#if (LZO_CFG_NO_LONG_LONG) ++# undef LZO_SIZEOF_LONG_LONG ++#elif defined(__NO_LONG_LONG) ++# undef LZO_SIZEOF_LONG_LONG ++#elif defined(_NO_LONGLONG) ++# undef LZO_SIZEOF_LONG_LONG ++#endif ++#if !defined(LZO_WORDSIZE) ++#if (LZO_ARCH_ALPHA) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_AMD64) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_AVR) ++# define LZO_WORDSIZE 1 ++#elif (LZO_ARCH_H8300) ++# if defined(__NORMAL_MODE__) ++# define LZO_WORDSIZE 4 ++# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) ++# define LZO_WORDSIZE 4 ++# else ++# define LZO_WORDSIZE 2 ++# endif ++#elif (LZO_ARCH_I086) ++# define LZO_WORDSIZE 2 ++#elif (LZO_ARCH_IA64) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_M16C) ++# define LZO_WORDSIZE 2 ++#elif (LZO_ARCH_SPU) ++# define LZO_WORDSIZE 4 ++#elif (LZO_ARCH_Z80) ++# define LZO_WORDSIZE 1 ++#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++# define LZO_WORDSIZE 8 ++#elif (LZO_OS_OS400 || defined(__OS400__)) ++# define LZO_WORDSIZE 8 ++#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) ++# define LZO_WORDSIZE 8 ++#endif ++#endif ++#if !defined(LZO_SIZEOF_VOID_P) ++#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) ++# define LZO_SIZEOF_VOID_P 4 ++#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) ++# define LZO_SIZEOF_VOID_P 8 ++#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) ++# define LZO_SIZEOF_VOID_P 8 ++#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) ++# define LZO_SIZEOF_VOID_P 8 ++#elif (LZO_ARCH_AVR) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_H8300) ++# if defined(__NORMAL_MODE__) ++# define LZO_SIZEOF_VOID_P 2 ++# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# define LZO_SIZEOF_VOID_P 2 ++# endif ++# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT ++# endif ++#elif (LZO_ARCH_I086) ++# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) ++# define LZO_SIZEOF_VOID_P 2 ++# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# error "invalid LZO_ARCH_I086 memory model" ++# endif ++#elif (LZO_ARCH_M16C) ++# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# define LZO_SIZEOF_VOID_P 2 ++# endif ++#elif (LZO_ARCH_SPU) ++# define LZO_SIZEOF_VOID_P 4 ++#elif (LZO_ARCH_Z80) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++# define LZO_SIZEOF_VOID_P 4 ++#elif (LZO_OS_OS400 || defined(__OS400__)) ++# if defined(__LLP64_IFC__) ++# define LZO_SIZEOF_VOID_P 8 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG ++# else ++# define LZO_SIZEOF_VOID_P 16 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG ++# endif ++#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) ++# define LZO_SIZEOF_VOID_P 8 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG ++#endif ++#endif ++#if !defined(LZO_SIZEOF_VOID_P) ++# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) ++#if !defined(LZO_SIZEOF_SIZE_T) ++#if (LZO_ARCH_I086 || LZO_ARCH_M16C) ++# define LZO_SIZEOF_SIZE_T 2 ++#endif ++#endif ++#if !defined(LZO_SIZEOF_SIZE_T) ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P ++#endif ++#if defined(offsetof) ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) ++#endif ++#if !defined(LZO_SIZEOF_PTRDIFF_T) ++#if (LZO_ARCH_I086) ++# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P ++# elif (LZO_MM_COMPACT || LZO_MM_LARGE) ++# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) ++# define LZO_SIZEOF_PTRDIFF_T 4 ++# else ++# define LZO_SIZEOF_PTRDIFF_T 2 ++# endif ++# else ++# error "invalid LZO_ARCH_I086 memory model" ++# endif ++#endif ++#endif ++#if !defined(LZO_SIZEOF_PTRDIFF_T) ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T ++#endif ++#if defined(offsetof) ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) ++#endif ++#if !defined(LZO_WORDSIZE) ++# define LZO_WORDSIZE LZO_SIZEOF_VOID_P ++#endif ++#if (LZO_ABI_NEUTRAL_ENDIAN) ++# undef LZO_ABI_BIG_ENDIAN ++# undef LZO_ABI_LITTLE_ENDIAN ++#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) ++#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) ++# if (__LITTLE_ENDIAN__ == 1) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++# else ++# define LZO_ABI_BIG_ENDIAN 1 ++# endif ++#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) ++# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) ++# error "unexpected configuration - check your compiler defines" ++# elif defined(__BIG_ENDIAN) ++# define LZO_ABI_BIG_ENDIAN 1 ++# else ++# define LZO_ABI_LITTLE_ENDIAN 1 ++# endif ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#endif ++#endif ++#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) ++# error "unexpected configuration - check your compiler defines" ++#endif ++#if (LZO_ABI_BIG_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "be" ++#elif (LZO_ABI_LITTLE_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "le" ++#elif (LZO_ABI_NEUTRAL_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "neutral" ++#endif ++#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_I8LP16 1 ++# define LZO_INFO_ABI_PM "i8lp16" ++#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_ILP16 1 ++# define LZO_INFO_ABI_PM "ilp16" ++#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_LP32 1 ++# define LZO_INFO_ABI_PM "lp32" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_ILP32 1 ++# define LZO_INFO_ABI_PM "ilp32" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) ++# define LZO_ABI_LLP64 1 ++# define LZO_INFO_ABI_PM "llp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_LP64 1 ++# define LZO_INFO_ABI_PM "lp64" ++#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_ILP64 1 ++# define LZO_INFO_ABI_PM "ilp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_IP32L64 1 ++# define LZO_INFO_ABI_PM "ip32l64" ++#endif ++#if 0 ++#elif !defined(__LZO_LIBC_OVERRIDE) ++#if (LZO_LIBC_NAKED) ++# define LZO_INFO_LIBC "naked" ++#elif (LZO_LIBC_FREESTANDING) ++# define LZO_INFO_LIBC "freestanding" ++#elif (LZO_LIBC_MOSTLY_FREESTANDING) ++# define LZO_INFO_LIBC "mfreestanding" ++#elif (LZO_LIBC_ISOC90) ++# define LZO_INFO_LIBC "isoc90" ++#elif (LZO_LIBC_ISOC99) ++# define LZO_INFO_LIBC "isoc99" ++#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) ++# define LZO_LIBC_ISOC90 1 ++# define LZO_INFO_LIBC "isoc90" ++#elif defined(__dietlibc__) ++# define LZO_LIBC_DIETLIBC 1 ++# define LZO_INFO_LIBC "dietlibc" ++#elif defined(_NEWLIB_VERSION) ++# define LZO_LIBC_NEWLIB 1 ++# define LZO_INFO_LIBC "newlib" ++#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) ++# if defined(__UCLIBC_SUBLEVEL__) ++# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) ++# else ++# define LZO_LIBC_UCLIBC 0x00090bL ++# endif ++# define LZO_INFO_LIBC "uc" "libc" ++#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) ++# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) ++# define LZO_INFO_LIBC "glibc" ++#elif (LZO_CC_MWERKS) && defined(__MSL__) ++# define LZO_LIBC_MSL __MSL__ ++# define LZO_INFO_LIBC "msl" ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) ++# define LZO_LIBC_ISOC90 1 ++# define LZO_INFO_LIBC "isoc90" ++#else ++# define LZO_LIBC_DEFAULT 1 ++# define LZO_INFO_LIBC "default" ++#endif ++#endif ++#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++# define LZO_ASM_SYNTAX_MSC 1 ++#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) ++#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_CC_GNUC) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#endif ++#if (LZO_ASM_SYNTAX_GNUC) ++#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) ++# define __LZO_ASM_CLOBBER "ax" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) ++# define __LZO_ASM_CLOBBER "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#else ++# define __LZO_ASM_CLOBBER "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC : "cc" ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#endif ++#endif + #if (LZO_ARCH_ALPHA) +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_AVOID_SHORT 1 +-# define LZO_OPT_AVOID_USHORT 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 + #elif (LZO_ARCH_AMD64) +-# define LZO_OPT_AVOID_INT_INDEX 1 +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 +-# define LZO_OPT_UNALIGNED64 1 +-#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) ++# define LZO_OPT_AVOID_INT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + #elif (LZO_ARCH_ARM) +-# define LZO_OPT_AVOID_SHORT 1 +-# define LZO_OPT_AVOID_USHORT 1 ++# if defined(__ARM_FEATURE_UNALIGNED) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# endif ++#elif (LZO_ARCH_ARM64) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + #elif (LZO_ARCH_CRIS) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + #elif (LZO_ARCH_I386) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + #elif (LZO_ARCH_IA64) +-# define LZO_OPT_AVOID_INT_INDEX 1 +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_AVOID_INT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 ++# define LZO_OPT_PREFER_POSTINC 1 + #elif (LZO_ARCH_M68K) +-# define LZO_OPT_PREFER_POSTINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + # if defined(__mc68020__) && !defined(__mcoldfire__) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + # endif + #elif (LZO_ARCH_MIPS) +-# define LZO_OPT_AVOID_UINT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 + #elif (LZO_ARCH_POWERPC) +-# define LZO_OPT_PREFER_PREINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_PREINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + # if (LZO_ABI_BIG_ENDIAN) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# if (LZO_WORDSIZE == 8) ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif ++# endif + # endif + #elif (LZO_ARCH_S390) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 +-# if (LZO_SIZEOF_SIZE_T == 8) +-# define LZO_OPT_UNALIGNED64 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# if (LZO_WORDSIZE == 8) ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + # endif + #elif (LZO_ARCH_SH) +-# define LZO_OPT_PREFER_POSTINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + #endif + #ifndef LZO_CFG_NO_INLINE_ASM +-#if (LZO_CC_LLVM) ++#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) + # define LZO_CFG_NO_INLINE_ASM 1 ++#elif (LZO_CC_LLVM) ++# define LZO_CFG_NO_INLINE_ASM 1 ++#endif + #endif ++#if (LZO_CFG_NO_INLINE_ASM) ++# undef LZO_ASM_SYNTAX_MSC ++# undef LZO_ASM_SYNTAX_GNUC ++# undef __LZO_ASM_CLOBBER ++# undef __LZO_ASM_CLOBBER_LIST_CC ++# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY ++# undef __LZO_ASM_CLOBBER_LIST_EMPTY + #endif + #ifndef LZO_CFG_NO_UNALIGNED + #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) +@@ -1804,25 +2594,6 @@ extern "C" { + # undef LZO_OPT_UNALIGNED32 + # undef LZO_OPT_UNALIGNED64 + #endif +-#if (LZO_CFG_NO_INLINE_ASM) +-#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +-# define LZO_ASM_SYNTAX_MSC 1 +-#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +-#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) +-#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +-# define LZO_ASM_SYNTAX_GNUC 1 +-#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +-# define LZO_ASM_SYNTAX_GNUC 1 +-#endif +-#if (LZO_ASM_SYNTAX_GNUC) +-#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) +-# define __LZO_ASM_CLOBBER "ax" +-#elif (LZO_CC_INTELC) +-# define __LZO_ASM_CLOBBER "memory" +-#else +-# define __LZO_ASM_CLOBBER "cc", "memory" +-#endif +-#endif + #if defined(__LZO_INFOSTR_MM) + #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) + # define __LZO_INFOSTR_MM "" +@@ -1866,6 +2637,381 @@ extern "C" { + #define LZO_INFO_STRING \ + LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ + " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER ++#if !(LZO_CFG_SKIP_LZO_TYPES) ++#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) ++# error "missing defines for sizes" ++#endif ++#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) ++# error "missing defines for sizes" ++#endif ++#if !defined(lzo_llong_t) ++#if (LZO_SIZEOF_LONG_LONG+0 > 0) ++__lzo_gnuc_extension__ typedef long long lzo_llong_t__; ++__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; ++# define lzo_llong_t lzo_llong_t__ ++# define lzo_ullong_t lzo_ullong_t__ ++#endif ++#endif ++#if !defined(lzo_int16e_t) ++#if (LZO_SIZEOF_LONG == 2) ++# define lzo_int16e_t long ++# define lzo_uint16e_t unsigned long ++#elif (LZO_SIZEOF_INT == 2) ++# define lzo_int16e_t int ++# define lzo_uint16e_t unsigned int ++#elif (LZO_SIZEOF_SHORT == 2) ++# define lzo_int16e_t short int ++# define lzo_uint16e_t unsigned short int ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) ++ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); ++ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); ++# define lzo_int16e_t lzo_int16e_hi_t__ ++# define lzo_uint16e_t lzo_uint16e_hi_t__ ++#elif (LZO_SIZEOF___INT16 == 2) ++# define lzo_int16e_t __int16 ++# define lzo_uint16e_t unsigned __int16 ++#else ++#endif ++#endif ++#if defined(lzo_int16e_t) ++# define LZO_SIZEOF_LZO_INT16E_T 2 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) ++#endif ++#if !defined(lzo_int32e_t) ++#if (LZO_SIZEOF_LONG == 4) ++# define lzo_int32e_t long int ++# define lzo_uint32e_t unsigned long int ++#elif (LZO_SIZEOF_INT == 4) ++# define lzo_int32e_t int ++# define lzo_uint32e_t unsigned int ++#elif (LZO_SIZEOF_SHORT == 4) ++# define lzo_int32e_t short int ++# define lzo_uint32e_t unsigned short int ++#elif (LZO_SIZEOF_LONG_LONG == 4) ++# define lzo_int32e_t lzo_llong_t ++# define lzo_uint32e_t lzo_ullong_t ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) ++ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); ++ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); ++# define lzo_int32e_t lzo_int32e_si_t__ ++# define lzo_uint32e_t lzo_uint32e_si_t__ ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) ++ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); ++ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); ++# define lzo_int32e_t lzo_int32e_si_t__ ++# define lzo_uint32e_t lzo_uint32e_si_t__ ++# define LZO_INT32_C(c) (c##LL) ++# define LZO_UINT32_C(c) (c##ULL) ++#elif (LZO_SIZEOF___INT32 == 4) ++# define lzo_int32e_t __int32 ++# define lzo_uint32e_t unsigned __int32 ++#else ++#endif ++#endif ++#if defined(lzo_int32e_t) ++# define LZO_SIZEOF_LZO_INT32E_T 4 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) ++#endif ++#if !defined(lzo_int64e_t) ++#if (LZO_SIZEOF___INT64 == 8) ++# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) ++# define LZO_CFG_TYPE_PREFER___INT64 1 ++# endif ++#endif ++#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_int64e_t int ++# define lzo_uint64e_t unsigned int ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG == 8) ++# define lzo_int64e_t long int ++# define lzo_uint64e_t unsigned long int ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG ++#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) ++# define lzo_int64e_t lzo_llong_t ++# define lzo_uint64e_t lzo_ullong_t ++# if (LZO_CC_BORLANDC) ++# define LZO_INT64_C(c) ((c) + 0ll) ++# define LZO_UINT64_C(c) ((c) + 0ull) ++# elif 0 ++# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) ++# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) ++# else ++# define LZO_INT64_C(c) (c##LL) ++# define LZO_UINT64_C(c) (c##ULL) ++# endif ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG ++#elif (LZO_SIZEOF___INT64 == 8) ++# define lzo_int64e_t __int64 ++# define lzo_uint64e_t unsigned __int64 ++# if (LZO_CC_BORLANDC) ++# define LZO_INT64_C(c) ((c) + 0i64) ++# define LZO_UINT64_C(c) ((c) + 0ui64) ++# else ++# define LZO_INT64_C(c) (c##i64) ++# define LZO_UINT64_C(c) (c##ui64) ++# endif ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 ++#else ++#endif ++#endif ++#if defined(lzo_int64e_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) ++#endif ++#if !defined(lzo_int32l_t) ++#if defined(lzo_int32e_t) ++# define lzo_int32l_t lzo_int32e_t ++# define lzo_uint32l_t lzo_uint32e_t ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T ++#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_int32l_t int ++# define lzo_uint32l_t unsigned int ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG >= 4) ++# define lzo_int32l_t long int ++# define lzo_uint32l_t unsigned long int ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG ++#else ++# error "lzo_int32l_t" ++#endif ++#endif ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) ++#endif ++#if !defined(lzo_int64l_t) ++#if defined(lzo_int64e_t) ++# define lzo_int64l_t lzo_int64e_t ++# define lzo_uint64l_t lzo_uint64e_t ++# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T ++#else ++#endif ++#endif ++#if defined(lzo_int64l_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) ++#endif ++#if !defined(lzo_int32f_t) ++#if (LZO_SIZEOF_SIZE_T >= 8) ++# define lzo_int32f_t lzo_int64l_t ++# define lzo_uint32f_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T ++#else ++# define lzo_int32f_t lzo_int32l_t ++# define lzo_uint32f_t lzo_uint32l_t ++# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T ++#endif ++#endif ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) ++#endif ++#if !defined(lzo_int64f_t) ++#if defined(lzo_int64l_t) ++# define lzo_int64f_t lzo_int64l_t ++# define lzo_uint64f_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T ++#else ++#endif ++#endif ++#if defined(lzo_int64f_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) ++#endif ++#if !defined(lzo_intptr_t) ++#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) ++# define __LZO_INTPTR_T_IS_POINTER 1 ++ typedef char* lzo_intptr_t; ++ typedef char* lzo_uintptr_t; ++# define lzo_intptr_t lzo_intptr_t ++# define lzo_uintptr_t lzo_uintptr_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P ++#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) ++ typedef __w64 int lzo_intptr_t; ++ typedef __w64 unsigned int lzo_uintptr_t; ++# define lzo_intptr_t lzo_intptr_t ++# define lzo_uintptr_t lzo_uintptr_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t short ++# define lzo_uintptr_t unsigned short ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT ++#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_intptr_t int ++# define lzo_uintptr_t unsigned int ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t long ++# define lzo_uintptr_t unsigned long ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG ++#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t lzo_int64l_t ++# define lzo_uintptr_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T ++#else ++# error "lzo_intptr_t" ++#endif ++#endif ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) ++#endif ++#if !defined(lzo_word_t) ++#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) ++#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) ++# define lzo_word_t lzo_uintptr_t ++# define lzo_sword_t lzo_intptr_t ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T ++#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) ++# define lzo_word_t unsigned long ++# define lzo_sword_t long ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG ++#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) ++# define lzo_word_t unsigned int ++# define lzo_sword_t int ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT ++#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) ++# define lzo_word_t unsigned short ++# define lzo_sword_t short ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT ++#elif (LZO_WORDSIZE == 1) ++# define lzo_word_t unsigned char ++# define lzo_sword_t signed char ++# define LZO_SIZEOF_LZO_WORD_T 1 ++#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) ++# define lzo_word_t lzo_uint64l_t ++# define lzo_sword_t lzo_int64l_t ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T ++#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) ++#if 0 ++ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); ++ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); ++# define lzo_word_t lzo_word_t ++# define lzo_sword_t lzo_sword_t ++# define LZO_SIZEOF_LZO_WORD_T 16 ++#endif ++#else ++# error "lzo_word_t" ++#endif ++#endif ++#endif ++#if 1 && defined(lzo_word_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) ++#endif ++#if 1 ++#define lzo_int8_t signed char ++#define lzo_uint8_t unsigned char ++#define LZO_SIZEOF_LZO_INT8_T 1 ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) ++#endif ++#if defined(lzo_int16e_t) ++#define lzo_int16_t lzo_int16e_t ++#define lzo_uint16_t lzo_uint16e_t ++#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) ++#endif ++#if defined(lzo_int32e_t) ++#define lzo_int32_t lzo_int32e_t ++#define lzo_uint32_t lzo_uint32e_t ++#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) ++#endif ++#if defined(lzo_int64e_t) ++#define lzo_int64_t lzo_int64e_t ++#define lzo_uint64_t lzo_uint64e_t ++#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) ++#endif ++#if 1 ++#define lzo_int_least32_t lzo_int32l_t ++#define lzo_uint_least32_t lzo_uint32l_t ++#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) ++#endif ++#if defined(lzo_int64l_t) ++#define lzo_int_least64_t lzo_int64l_t ++#define lzo_uint_least64_t lzo_uint64l_t ++#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) ++#endif ++#if 1 ++#define lzo_int_fast32_t lzo_int32f_t ++#define lzo_uint_fast32_t lzo_uint32f_t ++#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) ++#endif ++#if defined(lzo_int64f_t) ++#define lzo_int_fast64_t lzo_int64f_t ++#define lzo_uint_fast64_t lzo_uint64f_t ++#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) ++#endif ++#if !defined(LZO_INT16_C) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) ++# define LZO_INT16_C(c) ((c) + 0) ++# define LZO_UINT16_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) ++# define LZO_INT16_C(c) ((c) + 0L) ++# define LZO_UINT16_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 2) ++# define LZO_INT16_C(c) (c) ++# define LZO_UINT16_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 2) ++# define LZO_INT16_C(c) (c##L) ++# define LZO_UINT16_C(c) (c##UL) ++# else ++# error "LZO_INT16_C" ++# endif ++#endif ++#if !defined(LZO_INT32_C) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) ++# define LZO_INT32_C(c) ((c) + 0) ++# define LZO_UINT32_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) ++# define LZO_INT32_C(c) ((c) + 0L) ++# define LZO_UINT32_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 4) ++# define LZO_INT32_C(c) (c) ++# define LZO_UINT32_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 4) ++# define LZO_INT32_C(c) (c##L) ++# define LZO_UINT32_C(c) (c##UL) ++# elif (LZO_SIZEOF_LONG_LONG >= 4) ++# define LZO_INT32_C(c) (c##LL) ++# define LZO_UINT32_C(c) (c##ULL) ++# else ++# error "LZO_INT32_C" ++# endif ++#endif ++#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) ++# define LZO_INT64_C(c) ((c) + 0) ++# define LZO_UINT64_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) ++# define LZO_INT64_C(c) ((c) + 0L) ++# define LZO_UINT64_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 8) ++# define LZO_INT64_C(c) (c) ++# define LZO_UINT64_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 8) ++# define LZO_INT64_C(c) (c##L) ++# define LZO_UINT64_C(c) (c##UL) ++# else ++# error "LZO_INT64_C" ++# endif ++#endif ++#endif + + #endif + +@@ -1874,7 +3020,7 @@ extern "C" { + #undef LZO_HAVE_CONFIG_H + #include "minilzo.h" + +-#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050) ++#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2080) + # error "version mismatch in miniLZO source files" + #endif + +@@ -1886,23 +3032,9 @@ extern "C" { + #define __LZO_CONF_H 1 + + #if !defined(__LZO_IN_MINILZO) +-#if (LZO_CFG_FREESTANDING) ++#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) + # define LZO_LIBC_FREESTANDING 1 + # define LZO_OS_FREESTANDING 1 +-# define ACC_LIBC_FREESTANDING 1 +-# define ACC_OS_FREESTANDING 1 +-#endif +-#if (LZO_CFG_NO_UNALIGNED) +-# define ACC_CFG_NO_UNALIGNED 1 +-#endif +-#if (LZO_ARCH_GENERIC) +-# define ACC_ARCH_GENERIC 1 +-#endif +-#if (LZO_ABI_NEUTRAL_ENDIAN) +-# define ACC_ABI_NEUTRAL_ENDIAN 1 +-#endif +-#if (LZO_HAVE_CONFIG_H) +-# define ACC_CONFIG_NO_HEADER 1 + #endif + #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) + # include LZO_CFG_EXTRA_CONFIG_HEADER +@@ -1911,22 +3043,27 @@ extern "C" { + # error "include this file first" + #endif + #include "lzo/lzoconf.h" ++#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) ++# include LZO_CFG_EXTRA_CONFIG_HEADER2 ++#endif + #endif + +-#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) ++#if (LZO_VERSION < 0x2080) || !defined(__LZOCONF_H_INCLUDED) + # error "version mismatch" + #endif + +-#if (LZO_CC_BORLANDC && LZO_ARCH_I086) +-# pragma option -h ++#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) ++# pragma warning(disable: 4702) + #endif +- + #if (LZO_CC_MSC && (_MSC_VER >= 1000)) + # pragma warning(disable: 4127 4701) ++# pragma warning(disable: 4514 4710 4711) + #endif + #if (LZO_CC_MSC && (_MSC_VER >= 1300)) + # pragma warning(disable: 4820) +-# pragma warning(disable: 4514 4710 4711) ++#endif ++#if (LZO_CC_MSC && (_MSC_VER >= 1800)) ++# pragma warning(disable: 4746) + #endif + + #if (LZO_CC_SUNPROC) +@@ -1937,48 +3074,15 @@ extern "C" { + #endif + #endif + +-#if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR) +-# error "this should not happen - check defines for __huge" +-#endif +- +-#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) +-#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) +-# define ACC_WANT_ACC_INCD_H 1 +-# define ACC_WANT_ACC_INCE_H 1 +-# define ACC_WANT_ACC_INCI_H 1 ++#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) + #elif 1 + # include + #else +-# define ACC_WANT_ACC_INCD_H 1 ++# define LZO_WANT_ACC_INCD_H 1 + #endif +- +-#if (LZO_ARCH_I086) +-# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT +-# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) +-# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) +-# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) +-#endif +- +-#if !defined(lzo_uintptr_t) +-# if defined(__LZO_MMODEL_HUGE) +-# define lzo_uintptr_t unsigned long +-# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) +-# define __LZO_UINTPTR_T_IS_POINTER 1 +- typedef char* lzo_uintptr_t; +-# define lzo_uintptr_t lzo_uintptr_t +-# elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t size_t +-# elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t unsigned long +-# elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t unsigned int +-# elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t unsigned long long +-# else +-# define lzo_uintptr_t size_t +-# endif ++#if defined(LZO_HAVE_CONFIG_H) ++# define LZO_CFG_NO_CONFIG_HEADER 1 + #endif +-LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) + + #if 1 && !defined(LZO_CFG_FREESTANDING) + #if 1 && !defined(HAVE_STRING_H) +@@ -2002,6 +3106,23 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) + #include + #endif + ++#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) ++#endif ++#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) ++#endif ++#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) ++#endif ++#if defined(lzo_int64_t) || defined(lzo_uint64_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) ++#endif ++ + #if (LZO_CFG_FREESTANDING) + # undef HAVE_MEMCMP + # undef HAVE_MEMCPY +@@ -2012,169 +3133,635 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) + #if !(HAVE_MEMCMP) + # undef memcmp + # define memcmp(a,b,c) lzo_memcmp(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) ++#else + # undef lzo_memcmp + # define lzo_memcmp(a,b,c) memcmp(a,b,c) + #endif + #if !(HAVE_MEMCPY) + # undef memcpy + # define memcpy(a,b,c) lzo_memcpy(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) ++#else + # undef lzo_memcpy + # define lzo_memcpy(a,b,c) memcpy(a,b,c) + #endif + #if !(HAVE_MEMMOVE) + # undef memmove + # define memmove(a,b,c) lzo_memmove(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) ++#else + # undef lzo_memmove + # define lzo_memmove(a,b,c) memmove(a,b,c) + #endif + #if !(HAVE_MEMSET) + # undef memset + # define memset(a,b,c) lzo_memset(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) ++#else + # undef lzo_memset + # define lzo_memset(a,b,c) memset(a,b,c) + #endif + +-#undef NDEBUG +-#if (LZO_CFG_FREESTANDING) +-# undef LZO_DEBUG +-# define NDEBUG 1 +-# undef assert +-# define assert(e) ((void)0) ++#undef NDEBUG ++#if (LZO_CFG_FREESTANDING) ++# undef LZO_DEBUG ++# define NDEBUG 1 ++# undef assert ++# define assert(e) ((void)0) ++#else ++# if !defined(LZO_DEBUG) ++# define NDEBUG 1 ++# endif ++# include ++#endif ++ ++#if 0 && defined(__BOUNDS_CHECKING_ON) ++# include ++#else ++# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt ++# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) ++#endif ++ ++#if (LZO_CFG_PGO) ++# undef __lzo_likely ++# undef __lzo_unlikely ++# define __lzo_likely(e) (e) ++# define __lzo_unlikely(e) (e) ++#endif ++ ++#undef _ ++#undef __ ++#undef ___ ++#undef ____ ++#undef _p0 ++#undef _p1 ++#undef _p2 ++#undef _p3 ++#undef _p4 ++#undef _s0 ++#undef _s1 ++#undef _s2 ++#undef _s3 ++#undef _s4 ++#undef _ww ++ ++#if 1 ++# define LZO_BYTE(x) ((unsigned char) (x)) ++#else ++# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) ++#endif ++ ++#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) ++#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) ++#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) ++#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) ++ ++#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) ++ ++#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) ++ ++#define LZO_SIZE(bits) (1u << (bits)) ++#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) ++ ++#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) ++#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) ++ ++#if !defined(DMUL) ++#if 0 ++ ++# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) ++#else ++# define DMUL(a,b) ((lzo_xint) ((a) * (b))) ++#endif ++#endif ++ ++#ifndef __LZO_FUNC_H ++#define __LZO_FUNC_H 1 ++ ++#if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN) ++#if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC) ++#define LZO_BITOPS_USE_ASM_BITSCAN 1 ++#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul)))) ++#define LZO_BITOPS_USE_GNUC_BITSCAN 1 ++#elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) ++#define LZO_BITOPS_USE_MSC_BITSCAN 1 ++#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++#include ++#endif ++#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++#pragma intrinsic(_BitScanReverse) ++#pragma intrinsic(_BitScanForward) ++#endif ++#if (LZO_CC_MSC) && (LZO_ARCH_AMD64) ++#pragma intrinsic(_BitScanReverse64) ++#pragma intrinsic(_BitScanForward64) ++#endif ++#endif ++#endif ++ ++__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++ unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; ++#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint32_t r; ++ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r ^ 31; ++#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) ++ unsigned r; r = (unsigned) __builtin_clz(v); return r; ++#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) ++#else ++ LZO_UNUSED(v); return 0; ++#endif ++} ++ ++#if defined(lzo_uint64_t) ++__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) ++ unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; ++#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint64_t r; ++ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r ^ 63; ++#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_clzl(v); return r; ++#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_clzll(v); return r; ++#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) ++#else ++ LZO_UNUSED(v); return 0; ++#endif ++} ++#endif ++ ++__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++ unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; ++#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint32_t r; ++ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r; ++#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) ++ unsigned r; r = (unsigned) __builtin_ctz(v); return r; ++#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) ++#else ++ LZO_UNUSED(v); return 0; ++#endif ++} ++ ++#if defined(lzo_uint64_t) ++__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) ++ unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; ++#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint64_t r; ++ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r; ++#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_ctzl(v); return r; ++#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_ctzll(v); return r; ++#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) ++#else ++ LZO_UNUSED(v); return 0; ++#endif ++} ++#endif ++ ++#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++static void __attribute__((__unused__)) ++#else ++__lzo_static_forceinline void ++#endif ++lzo_bitops_unused_funcs(void) ++{ ++ LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func); ++ LZO_UNUSED_FUNC(lzo_bitops_cttz32_func); ++#if defined(lzo_uint64_t) ++ LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func); ++ LZO_UNUSED_FUNC(lzo_bitops_cttz64_func); ++#endif ++ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); ++} ++ ++#if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED) ++#ifndef __lzo_memops_tcheck ++#define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b)) ++#endif ++#endif ++#ifndef lzo_memops_TU0p ++#define lzo_memops_TU0p void __LZO_MMODEL * ++#endif ++#ifndef lzo_memops_TU1p ++#define lzo_memops_TU1p unsigned char __LZO_MMODEL * ++#endif ++#ifndef lzo_memops_TU2p ++#if (LZO_OPT_UNALIGNED16) ++typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; ++#define lzo_memops_TU2p volatile lzo_memops_TU2 * ++#elif defined(__lzo_byte_struct) ++__lzo_byte_struct(lzo_memops_TU2_struct,2) ++typedef struct lzo_memops_TU2_struct lzo_memops_TU2; ++#else ++struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; ++typedef struct lzo_memops_TU2_struct lzo_memops_TU2; ++#endif ++#ifndef lzo_memops_TU2p ++#define lzo_memops_TU2p lzo_memops_TU2 * ++#endif ++#endif ++#ifndef lzo_memops_TU4p ++#if (LZO_OPT_UNALIGNED32) ++typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; ++#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * ++#elif defined(__lzo_byte_struct) ++__lzo_byte_struct(lzo_memops_TU4_struct,4) ++typedef struct lzo_memops_TU4_struct lzo_memops_TU4; ++#else ++struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; ++typedef struct lzo_memops_TU4_struct lzo_memops_TU4; ++#endif ++#ifndef lzo_memops_TU4p ++#define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL * ++#endif ++#endif ++#ifndef lzo_memops_TU8p ++#if (LZO_OPT_UNALIGNED64) ++typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; ++#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * ++#elif defined(__lzo_byte_struct) ++__lzo_byte_struct(lzo_memops_TU8_struct,8) ++typedef struct lzo_memops_TU8_struct lzo_memops_TU8; ++#else ++struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; ++typedef struct lzo_memops_TU8_struct lzo_memops_TU8; ++#endif ++#ifndef lzo_memops_TU8p ++#define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL * ++#endif ++#endif ++#ifndef lzo_memops_set_TU1p ++#define lzo_memops_set_TU1p volatile lzo_memops_TU1p ++#endif ++#ifndef lzo_memops_move_TU1p ++#define lzo_memops_move_TU1p lzo_memops_TU1p ++#endif ++#define LZO_MEMOPS_SET1(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__1[0] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_SET2(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_SET3(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_SET4(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE1(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__1[0] = s__1[0]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE2(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__2[0] = s__2[0]; d__2[1] = s__2[1]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE3(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE4(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE8(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ ++ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ ++ LZO_BLOCK_END ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) ++#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) ++#if (LZO_OPT_UNALIGNED16) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) ++#define LZO_MEMOPS_COPY2(dd,ss) \ ++ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) ++#elif defined(__lzo_memops_tcheck) ++#define LZO_MEMOPS_COPY2(dd,ss) \ ++ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \ ++ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \ ++ } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END ++#else ++#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) ++#endif ++#if (LZO_OPT_UNALIGNED32) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) ++#define LZO_MEMOPS_COPY4(dd,ss) \ ++ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) ++#elif defined(__lzo_memops_tcheck) ++#define LZO_MEMOPS_COPY4(dd,ss) \ ++ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \ ++ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \ ++ } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END ++#else ++#define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss) ++#endif ++#if (LZO_WORDSIZE != 8) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END ++#else ++#if (LZO_OPT_UNALIGNED64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) ++#elif (LZO_OPT_UNALIGNED32) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END ++#elif defined(__lzo_memops_tcheck) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \ ++ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \ ++ } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END ++#else ++#define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss) ++#endif ++#endif ++#define LZO_MEMOPS_COPYN(dd,ss,nn) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \ ++ lzo_uint n__n = (nn); \ ++ while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \ ++ if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \ ++ if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ ++ LZO_BLOCK_END ++ ++__lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) ++{ ++ lzo_uint16_t v; ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY2(&v, ss); ++#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; ++ unsigned long vv; ++ __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); ++ v = (lzo_uint16_t) vv; + #else +-# if !defined(LZO_DEBUG) +-# define NDEBUG 1 +-# endif +-# include ++ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; ++ v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); + #endif +- +-#if 0 && defined(__BOUNDS_CHECKING_ON) +-# include ++ return v; ++} ++#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) + #else +-# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt +-# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) ++#define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss) + #endif + +-#if !defined(__lzo_inline) +-# define __lzo_inline /*empty*/ +-#endif +-#if !defined(__lzo_forceinline) +-# define __lzo_forceinline /*empty*/ ++__lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss) ++{ ++ lzo_uint32_t v; ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY4(&v, ss); ++#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; ++ unsigned long vv; ++ __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); ++ v = (lzo_uint32_t) vv; ++#else ++ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; ++ v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24)); + #endif +-#if !defined(__lzo_noinline) +-# define __lzo_noinline /*empty*/ ++ return v; ++} ++#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) ++#else ++#define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss) + #endif + +-#if (LZO_CFG_PGO) +-# undef __acc_likely +-# undef __acc_unlikely +-# undef __lzo_likely +-# undef __lzo_unlikely +-# define __acc_likely(e) (e) +-# define __acc_unlikely(e) (e) +-# define __lzo_likely(e) (e) +-# define __lzo_unlikely(e) (e) ++#if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) + #endif + +-#if 1 +-# define LZO_BYTE(x) ((unsigned char) (x)) ++__lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss) ++{ ++ lzo_uint16_t v; ++ LZO_MEMOPS_COPY2(&v, ss); ++ return v; ++} ++#if (LZO_OPT_UNALIGNED16) ++#define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) + #else +-# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) ++#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) + #endif + +-#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) +-#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) +-#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) +-#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) +- +-#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) ++__lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss) ++{ ++ lzo_uint32_t v; ++ LZO_MEMOPS_COPY4(&v, ss); ++ return v; ++} ++#if (LZO_OPT_UNALIGNED32) ++#define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) ++#else ++#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) ++#endif + +-#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) ++#if (LZO_OPT_UNALIGNED64) ++#define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) ++#endif + +-#define LZO_SIZE(bits) (1u << (bits)) +-#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) ++__lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv) ++{ ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY2(dd, &vv); ++#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_memops_TU2p d = (lzo_memops_TU2p) dd; ++ unsigned long v = vv; ++ __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); ++#else ++ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; ++ d[0] = LZO_BYTE((vv ) & 0xff); ++ d[1] = LZO_BYTE((vv >> 8) & 0xff); ++#endif ++} ++#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) ++#else ++#define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv) ++#endif + +-#define LZO_LSIZE(bits) (1ul << (bits)) +-#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) ++__lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv) ++{ ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY4(dd, &vv); ++#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_memops_TU4p d = (lzo_memops_TU4p) dd; ++ unsigned long v = vv; ++ __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); ++#else ++ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; ++ d[0] = LZO_BYTE((vv ) & 0xff); ++ d[1] = LZO_BYTE((vv >> 8) & 0xff); ++ d[2] = LZO_BYTE((vv >> 16) & 0xff); ++ d[3] = LZO_BYTE((vv >> 24) & 0xff); ++#endif ++} ++#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) ++#else ++#define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv) ++#endif + +-#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) +-#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) ++__lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv) ++{ ++ LZO_MEMOPS_COPY2(dd, &vv); ++} ++#if (LZO_OPT_UNALIGNED16) ++#define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) ++#else ++#define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv) ++#endif + +-#if !defined(DMUL) +-#if 0 ++__lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv) ++{ ++ LZO_MEMOPS_COPY4(dd, &vv); ++} ++#if (LZO_OPT_UNALIGNED32) ++#define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) ++#else ++#define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv) ++#endif + +-# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) ++#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++static void __attribute__((__unused__)) + #else +-# define DMUL(a,b) ((lzo_xint) ((a) * (b))) ++__lzo_static_forceinline void + #endif ++lzo_memops_unused_funcs(void) ++{ ++ LZO_UNUSED_FUNC(lzo_memops_get_le16); ++ LZO_UNUSED_FUNC(lzo_memops_get_le32); ++ LZO_UNUSED_FUNC(lzo_memops_get_ne16); ++ LZO_UNUSED_FUNC(lzo_memops_get_ne32); ++ LZO_UNUSED_FUNC(lzo_memops_put_le16); ++ LZO_UNUSED_FUNC(lzo_memops_put_le32); ++ LZO_UNUSED_FUNC(lzo_memops_put_ne16); ++ LZO_UNUSED_FUNC(lzo_memops_put_ne32); ++ LZO_UNUSED_FUNC(lzo_memops_unused_funcs); ++} ++ + #endif + +-#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC) +-# if (LZO_SIZEOF_SHORT == 2) +-# define LZO_UNALIGNED_OK_2 1 +-# endif +-# if (LZO_SIZEOF_INT == 4) +-# define LZO_UNALIGNED_OK_4 1 +-# endif ++#ifndef UA_SET1 ++#define UA_SET1 LZO_MEMOPS_SET1 + #endif +-#if 1 && (LZO_ARCH_AMD64) +-# if defined(LZO_UINT64_MAX) +-# define LZO_UNALIGNED_OK_8 1 +-# endif ++#ifndef UA_SET2 ++#define UA_SET2 LZO_MEMOPS_SET2 + #endif +-#if (LZO_CFG_NO_UNALIGNED) +-# undef LZO_UNALIGNED_OK_2 +-# undef LZO_UNALIGNED_OK_4 +-# undef LZO_UNALIGNED_OK_8 +-#endif +- +-#undef UA_GET16 +-#undef UA_SET16 +-#undef UA_COPY16 +-#undef UA_GET32 +-#undef UA_SET32 +-#undef UA_COPY32 +-#undef UA_GET64 +-#undef UA_SET64 +-#undef UA_COPY64 +-#if defined(LZO_UNALIGNED_OK_2) +- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2) +-# if 1 && defined(ACC_UA_COPY16) +-# define UA_GET16 ACC_UA_GET16 +-# define UA_SET16 ACC_UA_SET16 +-# define UA_COPY16 ACC_UA_COPY16 +-# else +-# define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p)) +-# define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v)) +-# define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s)) +-# endif ++#ifndef UA_SET3 ++#define UA_SET3 LZO_MEMOPS_SET3 + #endif +-#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) +-# if 1 && defined(ACC_UA_COPY32) +-# define UA_GET32 ACC_UA_GET32 +-# define UA_SET32 ACC_UA_SET32 +-# define UA_COPY32 ACC_UA_COPY32 +-# else +-# define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p)) +-# define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v)) +-# define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s)) +-# endif ++#ifndef UA_SET4 ++#define UA_SET4 LZO_MEMOPS_SET4 + #endif +-#if defined(LZO_UNALIGNED_OK_8) +- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8) +-# if 1 && defined(ACC_UA_COPY64) +-# define UA_GET64 ACC_UA_GET64 +-# define UA_SET64 ACC_UA_SET64 +-# define UA_COPY64 ACC_UA_COPY64 +-# else +-# define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p)) +-# define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v)) +-# define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s)) +-# endif ++#ifndef UA_MOVE1 ++#define UA_MOVE1 LZO_MEMOPS_MOVE1 ++#endif ++#ifndef UA_MOVE2 ++#define UA_MOVE2 LZO_MEMOPS_MOVE2 ++#endif ++#ifndef UA_MOVE3 ++#define UA_MOVE3 LZO_MEMOPS_MOVE3 ++#endif ++#ifndef UA_MOVE4 ++#define UA_MOVE4 LZO_MEMOPS_MOVE4 ++#endif ++#ifndef UA_MOVE8 ++#define UA_MOVE8 LZO_MEMOPS_MOVE8 ++#endif ++#ifndef UA_COPY1 ++#define UA_COPY1 LZO_MEMOPS_COPY1 ++#endif ++#ifndef UA_COPY2 ++#define UA_COPY2 LZO_MEMOPS_COPY2 ++#endif ++#ifndef UA_COPY3 ++#define UA_COPY3 LZO_MEMOPS_COPY3 ++#endif ++#ifndef UA_COPY4 ++#define UA_COPY4 LZO_MEMOPS_COPY4 ++#endif ++#ifndef UA_COPY8 ++#define UA_COPY8 LZO_MEMOPS_COPY8 ++#endif ++#ifndef UA_COPYN ++#define UA_COPYN LZO_MEMOPS_COPYN ++#endif ++#ifndef UA_COPYN_X ++#define UA_COPYN_X LZO_MEMOPS_COPYN ++#endif ++#ifndef UA_GET_LE16 ++#define UA_GET_LE16 LZO_MEMOPS_GET_LE16 ++#endif ++#ifndef UA_GET_LE32 ++#define UA_GET_LE32 LZO_MEMOPS_GET_LE32 ++#endif ++#ifdef LZO_MEMOPS_GET_LE64 ++#ifndef UA_GET_LE64 ++#define UA_GET_LE64 LZO_MEMOPS_GET_LE64 ++#endif ++#endif ++#ifndef UA_GET_NE16 ++#define UA_GET_NE16 LZO_MEMOPS_GET_NE16 ++#endif ++#ifndef UA_GET_NE32 ++#define UA_GET_NE32 LZO_MEMOPS_GET_NE32 ++#endif ++#ifdef LZO_MEMOPS_GET_NE64 ++#ifndef UA_GET_NE64 ++#define UA_GET_NE64 LZO_MEMOPS_GET_NE64 ++#endif ++#endif ++#ifndef UA_PUT_LE16 ++#define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 ++#endif ++#ifndef UA_PUT_LE32 ++#define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 ++#endif ++#ifndef UA_PUT_NE16 ++#define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 ++#endif ++#ifndef UA_PUT_NE32 ++#define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 + #endif + + #define MEMCPY8_DS(dest,src,len) \ +@@ -2195,25 +3782,10 @@ LZO_EXTERN(const lzo_bytep) lzo_copyright(void); + extern "C" { + #endif + +-#if !defined(lzo_uintptr_t) +-# if (__LZO_MMODEL_HUGE) +-# define lzo_uintptr_t unsigned long +-# else +-# define lzo_uintptr_t acc_uintptr_t +-# ifdef __ACC_INTPTR_T_IS_POINTER +-# define __LZO_UINTPTR_T_IS_POINTER 1 +-# endif +-# endif +-#endif +- + #if (LZO_ARCH_I086) +-#define PTR(a) ((lzo_bytep) (a)) +-#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) +-#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) ++#error "LZO_ARCH_I086 is unsupported" + #elif (LZO_MM_PVP) +-#define PTR(a) ((lzo_bytep) (a)) +-#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) +-#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) ++#error "LZO_MM_PVP is unsupported" + #else + #define PTR(a) ((lzo_uintptr_t) (a)) + #define PTR_LINEAR(a) PTR(a) +@@ -2243,24 +3815,28 @@ typedef union + unsigned long a_ulong; + lzo_int a_lzo_int; + lzo_uint a_lzo_uint; +- lzo_int32 a_lzo_int32; +- lzo_uint32 a_lzo_uint32; +-#if defined(LZO_UINT64_MAX) +- lzo_int64 a_lzo_int64; +- lzo_uint64 a_lzo_uint64; +-#endif ++ lzo_xint a_lzo_xint; ++ lzo_int16_t a_lzo_int16_t; ++ lzo_uint16_t a_lzo_uint16_t; ++ lzo_int32_t a_lzo_int32_t; ++ lzo_uint32_t a_lzo_uint32_t; ++#if defined(lzo_uint64_t) ++ lzo_int64_t a_lzo_int64_t; ++ lzo_uint64_t a_lzo_uint64_t; ++#endif ++ size_t a_size_t; + ptrdiff_t a_ptrdiff_t; + lzo_uintptr_t a_lzo_uintptr_t; +- lzo_voidp a_lzo_voidp; + void * a_void_p; +- lzo_bytep a_lzo_bytep; +- lzo_bytepp a_lzo_bytepp; +- lzo_uintp a_lzo_uintp; +- lzo_uint * a_lzo_uint_p; +- lzo_uint32p a_lzo_uint32p; +- lzo_uint32 * a_lzo_uint32_p; +- unsigned char * a_uchar_p; + char * a_char_p; ++ unsigned char * a_uchar_p; ++ const void * a_c_void_p; ++ const char * a_c_char_p; ++ const unsigned char * a_c_uchar_p; ++ lzo_voidp a_lzo_voidp; ++ lzo_bytep a_lzo_bytep; ++ const lzo_voidp a_c_lzo_voidp; ++ const lzo_bytep a_c_lzo_bytep; + } + lzo_full_align_t; + +@@ -2276,18 +3852,14 @@ lzo_full_align_t; + + #ifndef LZO_DICT_USE_PTR + #define LZO_DICT_USE_PTR 1 +-#if 0 && (LZO_ARCH_I086) +-# undef LZO_DICT_USE_PTR +-# define LZO_DICT_USE_PTR 0 +-#endif + #endif + + #if (LZO_DICT_USE_PTR) + # define lzo_dict_t const lzo_bytep +-# define lzo_dict_p lzo_dict_t __LZO_MMODEL * ++# define lzo_dict_p lzo_dict_t * + #else + # define lzo_dict_t lzo_uint +-# define lzo_dict_p lzo_dict_t __LZO_MMODEL * ++# define lzo_dict_p lzo_dict_t * + #endif + + #endif +@@ -2300,10 +3872,9 @@ __lzo_ptr_linear(const lzo_voidp ptr) + lzo_uintptr_t p; + + #if (LZO_ARCH_I086) +- p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); ++#error "LZO_ARCH_I086 is unsupported" + #elif (LZO_MM_PVP) +- p = (lzo_uintptr_t) (ptr); +- p = (p << 3) | (p >> 61); ++#error "LZO_MM_PVP is unsupported" + #else + p = (lzo_uintptr_t) PTR_LINEAR(ptr); + #endif +@@ -2314,9 +3885,8 @@ __lzo_ptr_linear(const lzo_voidp ptr) + LZO_PUBLIC(unsigned) + __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) + { +-#if defined(__LZO_UINTPTR_T_IS_POINTER) +- size_t n = (size_t) ptr; +- n = (((n + size - 1) / size) * size) - n; ++#if (__LZO_UINTPTR_T_IS_POINTER) ++#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" + #else + lzo_uintptr_t p, n; + p = __lzo_ptr_linear(ptr); +@@ -2342,7 +3912,7 @@ static const char __lzo_copyright[] = + #else + "\r\n\n" + "LZO data compression library.\n" +- "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n" ++ "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n" + "\n" + "http://www.oberhumer.com $\n\n" + "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" +@@ -2352,11 +3922,7 @@ static const char __lzo_copyright[] = + LZO_PUBLIC(const lzo_bytep) + lzo_copyright(void) + { +-#if (LZO_OS_DOS16 && LZO_CC_TURBOC) +- return (lzo_voidp) __lzo_copyright; +-#else + return (const lzo_bytep) __lzo_copyright; +-#endif + } + + LZO_PUBLIC(unsigned) +@@ -2393,16 +3959,16 @@ _lzo_version_date(void) + #define LZO_NMAX 5552 + + #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 +-#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); +-#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); +-#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); +-#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); ++#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1) ++#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2) ++#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4) ++#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8) + +-LZO_PUBLIC(lzo_uint32) +-lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) ++LZO_PUBLIC(lzo_uint32_t) ++lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len) + { +- lzo_uint32 s1 = adler & 0xffff; +- lzo_uint32 s2 = (adler >> 16) & 0xffff; ++ lzo_uint32_t s1 = adler & 0xffff; ++ lzo_uint32_t s2 = (adler >> 16) & 0xffff; + unsigned k; + + if (buf == NULL) +@@ -2459,8 +4025,8 @@ lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) + LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) +- const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; +- const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; ++ const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1); ++ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2); + if __lzo_likely(len > 0) do + { + int d = *p1 - *p2; +@@ -2476,8 +4042,8 @@ LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo + LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) +- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; +- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; ++ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); ++ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); + if (!(len > 0) || p1 == p2) + return dest; + do +@@ -2491,8 +4057,8 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src + LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) +- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; +- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; ++ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); ++ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); + if (!(len > 0) || p1 == p2) + return dest; + if (p1 < p2) +@@ -2514,16 +4080,17 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p sr + return memmove(dest, src, len); + #endif + } +-LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) ++LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) +- lzo_hbyte_p p = (lzo_hbyte_p) s; ++ lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s); ++ unsigned char c = LZO_ITRUNC(unsigned char, cc); + if __lzo_likely(len > 0) do +- *p++ = (unsigned char) c; ++ *p++ = c; + while __lzo_likely(--len > 0); + return s; + #else +- return memset(s, c, len); ++ return memset(s, cc, len); + #endif + } + #undef LZOLIB_PUBLIC +@@ -2532,105 +4099,28 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) + + #if !defined(__LZO_IN_MINILZO) + +-#define ACC_WANT_ACC_CHK_CH 1 +-#undef ACCCHK_ASSERT +- +- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) +- +- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) +- ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) +- ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) +-#if defined(LZO_UINT64_MAX) +- ACCCHK_ASSERT(sizeof(lzo_uint64) == 8) +- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64) +-#endif +- +-#if !defined(__LZO_UINTPTR_T_IS_POINTER) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) +-#endif +- ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) +- +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) +- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) +- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) +- ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) ++#define LZO_WANT_ACC_CHK_CH 1 ++#undef LZOCHK_ASSERT + ++ LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) ++ LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) ++ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) ++#if !(__LZO_UINTPTR_T_IS_POINTER) ++ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) + #endif +-#undef ACCCHK_ASSERT ++ LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) ++ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) + +-#if 0 +-#define WANT_lzo_bitops_clz32 1 +-#define WANT_lzo_bitops_clz64 1 +-#endif +-#define WANT_lzo_bitops_ctz32 1 +-#define WANT_lzo_bitops_ctz64 1 +- +-#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) +-#include +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 +-#pragma intrinsic(_BitScanReverse) +-static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanReverse(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz32 lzo_bitops_clz32 +-#endif +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 +-#pragma intrinsic(_BitScanReverse64) +-static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanReverse64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz64 lzo_bitops_clz64 +-#endif +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#pragma intrinsic(_BitScanForward) +-static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanForward(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz32 lzo_bitops_ctz32 +-#endif +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#pragma intrinsic(_BitScanForward64) +-static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanForward64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz64 lzo_bitops_ctz64 + #endif ++#undef LZOCHK_ASSERT + +-#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) +-#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) +-#endif +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) +-#endif +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) +-#endif +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) +-#endif +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) +-#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) +-#endif +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) +-#endif ++union lzo_config_check_union { ++ lzo_uint a[2]; ++ unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; ++#if defined(lzo_uint64_t) ++ lzo_uint64_t c[2]; + #endif ++}; + + #if 0 + #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off))) +@@ -2644,73 +4134,101 @@ static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) + LZO_PUBLIC(int) + _lzo_config_check(void) + { +- lzo_bool r = 1; +- union { +- lzo_xint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_xint))]; +-#if defined(LZO_UNALIGNED_OK_8) +- lzo_uint64 c[2]; +-#endif +- unsigned short x[2]; lzo_uint32 y[2]; lzo_uint z[2]; +- } u; ++#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul)) ++# if 0 ++ volatile ++# endif ++#endif ++ union lzo_config_check_union u; + lzo_voidp p; ++ unsigned r = 1; + + u.a[0] = u.a[1] = 0; + p = u2p(&u, 0); + r &= ((* (lzo_bytep) p) == 0); +-#if !defined(LZO_CFG_NO_CONFIG_CHECK) +-#if defined(LZO_ABI_BIG_ENDIAN) ++#if !(LZO_CFG_NO_CONFIG_CHECK) ++#if (LZO_ABI_BIG_ENDIAN) + u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; + p = u2p(&u, 0); + r &= ((* (lzo_uintp) p) == 128); + #endif +-#if defined(LZO_ABI_LITTLE_ENDIAN) ++#if (LZO_ABI_LITTLE_ENDIAN) + u.a[0] = u.a[1] = 0; u.b[0] = 128; + p = u2p(&u, 0); + r &= ((* (lzo_uintp) p) == 128); + #endif +-#if defined(LZO_UNALIGNED_OK_2) + u.a[0] = u.a[1] = 0; +- u.b[0] = 1; u.b[sizeof(unsigned short) + 1] = 2; ++ u.b[0] = 1; u.b[3] = 2; + p = u2p(&u, 1); +- r &= ((* (lzo_ushortp) p) == 0); ++ r &= UA_GET_NE16(p) == 0; ++ r &= UA_GET_LE16(p) == 0; ++ u.b[1] = 128; ++ r &= UA_GET_LE16(p) == 128; ++ u.b[2] = 129; ++ r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180); ++#if (LZO_ABI_BIG_ENDIAN) ++ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081); ++#endif ++#if (LZO_ABI_LITTLE_ENDIAN) ++ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180); + #endif +-#if defined(LZO_UNALIGNED_OK_4) + u.a[0] = u.a[1] = 0; +- u.b[0] = 3; u.b[sizeof(lzo_uint32) + 1] = 4; ++ u.b[0] = 3; u.b[5] = 4; + p = u2p(&u, 1); +- r &= ((* (lzo_uint32p) p) == 0); ++ r &= UA_GET_NE32(p) == 0; ++ r &= UA_GET_LE32(p) == 0; ++ u.b[1] = 128; ++ r &= UA_GET_LE32(p) == 128; ++ u.b[2] = 129; u.b[3] = 130; u.b[4] = 131; ++ r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180); ++#if (LZO_ABI_BIG_ENDIAN) ++ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283); + #endif +-#if defined(LZO_UNALIGNED_OK_8) ++#if (LZO_ABI_LITTLE_ENDIAN) ++ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180); ++#endif ++#if defined(UA_GET_NE64) + u.c[0] = u.c[1] = 0; +- u.b[0] = 5; u.b[sizeof(lzo_uint64) + 1] = 6; ++ u.b[0] = 5; u.b[9] = 6; + p = u2p(&u, 1); +- r &= ((* (lzo_uint64p) p) == 0); +-#endif +-#if defined(lzo_bitops_clz32) +- { unsigned i; lzo_uint32 v = 1; +- for (i = 0; i < 31; i++, v <<= 1) +- r &= lzo_bitops_clz32(v) == 31 - i; +- } +-#endif +-#if defined(lzo_bitops_clz64) +- { unsigned i; lzo_uint64 v = 1; +- for (i = 0; i < 63; i++, v <<= 1) +- r &= lzo_bitops_clz64(v) == 63 - i; +- } +-#endif +-#if defined(lzo_bitops_ctz32) +- { unsigned i; lzo_uint32 v = 1; +- for (i = 0; i < 31; i++, v <<= 1) +- r &= lzo_bitops_ctz32(v) == i; +- } +-#endif +-#if defined(lzo_bitops_ctz64) +- { unsigned i; lzo_uint64 v = 1; +- for (i = 0; i < 63; i++, v <<= 1) +- r &= lzo_bitops_ctz64(v) == i; +- } +-#endif +-#endif ++ u.c[0] = u.c[1] = 0; ++ r &= UA_GET_NE64(p) == 0; ++#if defined(UA_GET_LE64) ++ r &= UA_GET_LE64(p) == 0; ++ u.b[1] = 128; ++ r &= UA_GET_LE64(p) == 128; ++#endif ++#endif ++#if defined(lzo_bitops_ctlz32) ++ { unsigned i = 0; lzo_uint32_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_ctlz32(v) == 31 - i; ++ r &= lzo_bitops_ctlz32_func(v) == 31 - i; ++ }} ++#endif ++#if defined(lzo_bitops_ctlz64) ++ { unsigned i = 0; lzo_uint64_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_ctlz64(v) == 63 - i; ++ r &= lzo_bitops_ctlz64_func(v) == 63 - i; ++ }} ++#endif ++#if defined(lzo_bitops_cttz32) ++ { unsigned i = 0; lzo_uint32_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_cttz32(v) == i; ++ r &= lzo_bitops_cttz32_func(v) == i; ++ }} ++#endif ++#if defined(lzo_bitops_cttz64) ++ { unsigned i = 0; lzo_uint64_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_cttz64(v) == i; ++ r &= lzo_bitops_cttz64_func(v) == i; ++ }} ++#endif ++#endif ++ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); + + return r == 1 ? LZO_E_OK : LZO_E_ERROR; + } +@@ -2724,11 +4242,11 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, + #if defined(__LZO_IN_MINILZO) + #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) + #else +-#define ACC_WANT_ACC_CHK_CH 1 +-#undef ACCCHK_ASSERT +-#define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) ++#define LZO_WANT_ACC_CHK_CH 1 ++#undef LZOCHK_ASSERT ++#define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) + #endif +-#undef ACCCHK_ASSERT ++#undef LZOCHK_ASSERT + + if (v == 0) + return LZO_E_ERROR; +@@ -2736,7 +4254,7 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, + r = (s1 == -1 || s1 == (int) sizeof(short)) && + (s2 == -1 || s2 == (int) sizeof(int)) && + (s3 == -1 || s3 == (int) sizeof(long)) && +- (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && ++ (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && + (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && + (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && + (s7 == -1 || s7 == (int) sizeof(char *)) && +@@ -2779,11 +4297,11 @@ int __far __pascal LibMain ( int a, short b, short c, long d ) + + #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) + +-#if 1 && defined(UA_GET32) ++#if 1 && defined(UA_GET_LE32) + #undef LZO_DICT_USE_PTR + #define LZO_DICT_USE_PTR 0 + #undef lzo_dict_t +-#define lzo_dict_t unsigned short ++#define lzo_dict_t lzo_uint16_t + #endif + + #define LZO_NEED_DICT_H 1 +@@ -3088,77 +4606,7 @@ DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) + #endif + + #if 1 && defined(DO_COMPRESS) && !defined(do_compress) +-# define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core) +-#endif +- +-#if defined(UA_GET64) +-# define WANT_lzo_bitops_ctz64 1 +-#elif defined(UA_GET32) +-# define WANT_lzo_bitops_ctz32 1 +-#endif +- +-#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) +-#include +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 +-#pragma intrinsic(_BitScanReverse) +-static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanReverse(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz32 lzo_bitops_clz32 +-#endif +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 +-#pragma intrinsic(_BitScanReverse64) +-static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanReverse64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz64 lzo_bitops_clz64 +-#endif +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#pragma intrinsic(_BitScanForward) +-static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanForward(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz32 lzo_bitops_ctz32 +-#endif +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#pragma intrinsic(_BitScanForward64) +-static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanForward64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz64 lzo_bitops_ctz64 +-#endif +- +-#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) +-#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) +-#endif +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) +-#endif +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) +-#endif +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) +-#endif +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) +-#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) +-#endif +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) +-#endif ++# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) + #endif + + static __lzo_noinline lzo_uint +@@ -3166,7 +4614,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, + lzo_bytep out, lzo_uintp out_len, + lzo_uint ti, lzo_voidp wrkmem) + { +- register const lzo_bytep ip; ++ const lzo_bytep ip; + lzo_bytep op; + const lzo_bytep const in_end = in + in_len; + const lzo_bytep const ip_end = in + in_len - 20; +@@ -3175,7 +4623,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, + + op = out; + ip = in; +- ii = ip - ti; ++ ii = ip; + + ip += ti < 4 ? 4 - ti : 0; + for (;;) +@@ -3205,8 +4653,8 @@ next: + goto literal; + + try_match: +-#if defined(UA_GET32) +- if (UA_GET32(m_pos) != UA_GET32(ip)) ++#if (LZO_OPT_UNALIGNED32) ++ if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) + #else + if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) + #endif +@@ -3221,49 +4669,43 @@ literal: + lzo_uint m_off; + lzo_uint m_len; + { +- lzo_uint32 dv; ++ lzo_uint32_t dv; + lzo_uint dindex; + literal: + ip += 1 + ((ip - ii) >> 5); + next: + if __lzo_unlikely(ip >= ip_end) + break; +- dv = UA_GET32(ip); ++ dv = UA_GET_LE32(ip); + dindex = DINDEX(dv,ip); + GINDEX(m_off,m_pos,in+dict,dindex,in); + UPDATE_I(dict,0,dindex,ip,in); +- if __lzo_unlikely(dv != UA_GET32(m_pos)) ++ if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) + goto literal; + } + #endif + ++ ii -= ti; ti = 0; + { +- register lzo_uint t = pd(ip,ii); ++ lzo_uint t = pd(ip,ii); + if (t != 0) + { + if (t <= 3) + { +- op[-2] |= LZO_BYTE(t); +-#if defined(UA_COPY32) +- UA_COPY32(op, ii); ++ op[-2] = LZO_BYTE(op[-2] | t); ++#if (LZO_OPT_UNALIGNED32) ++ UA_COPY4(op, ii); + op += t; + #else + { do *op++ = *ii++; while (--t > 0); } + #endif + } +-#if defined(UA_COPY32) || defined(UA_COPY64) ++#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) + else if (t <= 16) + { + *op++ = LZO_BYTE(t - 3); +-#if defined(UA_COPY64) +- UA_COPY64(op, ii); +- UA_COPY64(op+8, ii+8); +-#else +- UA_COPY32(op, ii); +- UA_COPY32(op+4, ii+4); +- UA_COPY32(op+8, ii+8); +- UA_COPY32(op+12, ii+12); +-#endif ++ UA_COPY8(op, ii); ++ UA_COPY8(op+8, ii+8); + op += t; + } + #endif +@@ -3273,31 +4715,21 @@ next: + *op++ = LZO_BYTE(t - 3); + else + { +- register lzo_uint tt = t - 18; ++ lzo_uint tt = t - 18; + *op++ = 0; + while __lzo_unlikely(tt > 255) + { + tt -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + assert(tt > 0); + *op++ = LZO_BYTE(tt); + } +-#if defined(UA_COPY32) || defined(UA_COPY64) ++#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) + do { +-#if defined(UA_COPY64) +- UA_COPY64(op, ii); +- UA_COPY64(op+8, ii+8); +-#else +- UA_COPY32(op, ii); +- UA_COPY32(op+4, ii+4); +- UA_COPY32(op+8, ii+8); +- UA_COPY32(op+12, ii+12); +-#endif ++ UA_COPY8(op, ii); ++ UA_COPY8(op+8, ii+8); + op += 16; ii += 16; t -= 16; + } while (t >= 16); if (t > 0) + #endif +@@ -3307,19 +4739,26 @@ next: + } + m_len = 4; + { +-#if defined(UA_GET64) +- lzo_uint64 v; +- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); ++#if (LZO_OPT_UNALIGNED64) ++ lzo_uint64_t v; ++ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); + if __lzo_unlikely(v == 0) { + do { + m_len += 8; +- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); ++ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); + if __lzo_unlikely(ip + m_len >= ip_end) + goto m_len_done; + } while (v == 0); + } +-#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64) +- m_len += lzo_bitops_ctz64(v) / CHAR_BIT; ++#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) ++ m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; ++#elif (LZO_ABI_BIG_ENDIAN) ++ if ((v >> (64 - CHAR_BIT)) == 0) do { ++ v <<= CHAR_BIT; ++ m_len += 1; ++ } while ((v >> (64 - CHAR_BIT)) == 0); ++#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) ++ m_len += lzo_bitops_cttz64(v) / CHAR_BIT; + #elif (LZO_ABI_LITTLE_ENDIAN) + if ((v & UCHAR_MAX) == 0) do { + v >>= CHAR_BIT; +@@ -3330,19 +4769,30 @@ next: + m_len += 1; + } while (ip[m_len] == m_pos[m_len]); + #endif +-#elif defined(UA_GET32) +- lzo_uint32 v; +- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); ++#elif (LZO_OPT_UNALIGNED32) ++ lzo_uint32_t v; ++ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); + if __lzo_unlikely(v == 0) { + do { + m_len += 4; +- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); ++ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); ++ if (v != 0) ++ break; ++ m_len += 4; ++ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); + if __lzo_unlikely(ip + m_len >= ip_end) + goto m_len_done; + } while (v == 0); + } +-#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32) +- m_len += lzo_bitops_ctz32(v) / CHAR_BIT; ++#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) ++ m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; ++#elif (LZO_ABI_BIG_ENDIAN) ++ if ((v >> (32 - CHAR_BIT)) == 0) do { ++ v <<= CHAR_BIT; ++ m_len += 1; ++ } while ((v >> (32 - CHAR_BIT)) == 0); ++#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) ++ m_len += lzo_bitops_cttz32(v) / CHAR_BIT; + #elif (LZO_ABI_LITTLE_ENDIAN) + if ((v & UCHAR_MAX) == 0) do { + v >>= CHAR_BIT; +@@ -3357,6 +4807,27 @@ next: + if __lzo_unlikely(ip[m_len] == m_pos[m_len]) { + do { + m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; + if __lzo_unlikely(ip + m_len >= ip_end) + goto m_len_done; + } while (ip[m_len] == m_pos[m_len]); +@@ -3390,11 +4861,8 @@ m_len_done: + while __lzo_unlikely(m_len > 255) + { + m_len -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + *op++ = LZO_BYTE(m_len); + } +@@ -3413,11 +4881,8 @@ m_len_done: + while __lzo_unlikely(m_len > 255) + { + m_len -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + *op++ = LZO_BYTE(m_len); + } +@@ -3428,7 +4893,7 @@ m_len_done: + } + + *out_len = pd(op, out); +- return pd(in_end,ii); ++ return pd(in_end,ii-ti); + } + + LZO_PUBLIC(int) +@@ -3468,7 +4933,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + if (op == out && t <= 238) + *op++ = LZO_BYTE(17 + t); + else if (t <= 3) +- op[-2] |= LZO_BYTE(t); ++ op[-2] = LZO_BYTE(op[-2] | t); + else if (t <= 18) + *op++ = LZO_BYTE(t - 3); + else +@@ -3479,17 +4944,14 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + while (tt > 255) + { + tt -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + assert(tt > 0); + *op++ = LZO_BYTE(tt); + } +- do *op++ = *ii++; while (--t > 0); ++ UA_COPYN(op, ii, t); ++ op += t; + } + + *op++ = M4_MARKER | 1; +@@ -3526,10 +4988,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + + #undef TEST_IP + #undef TEST_OP ++#undef TEST_IP_AND_TEST_OP + #undef TEST_LB + #undef TEST_LBO + #undef NEED_IP + #undef NEED_OP ++#undef TEST_IV ++#undef TEST_OV + #undef HAVE_TEST_IP + #undef HAVE_TEST_OP + #undef HAVE_NEED_IP +@@ -3544,6 +5009,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + # if (LZO_TEST_OVERRUN_INPUT >= 2) + # define NEED_IP(x) \ + if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun ++# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun + # endif + #endif + +@@ -3555,12 +5021,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + # undef TEST_OP + # define NEED_OP(x) \ + if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun ++# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun + # endif + #endif + + #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) +-# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun +-# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun ++# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun ++# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun + #else + # define TEST_LB(m_pos) ((void) 0) + # define TEST_LBO(m_pos,o) ((void) 0) +@@ -3581,15 +5048,27 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + # define TEST_OP 1 + #endif + ++#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) ++#elif defined(HAVE_TEST_IP) ++# define TEST_IP_AND_TEST_OP TEST_IP ++#elif defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP TEST_OP ++#else ++# define TEST_IP_AND_TEST_OP 1 ++#endif ++ + #if defined(NEED_IP) + # define HAVE_NEED_IP 1 + #else + # define NEED_IP(x) ((void) 0) ++# define TEST_IV(x) ((void) 0) + #endif + #if defined(NEED_OP) + # define HAVE_NEED_OP 1 + #else + # define NEED_OP(x) ((void) 0) ++# define TEST_OV(x) ((void) 0) + #endif + + #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) +@@ -3606,14 +5085,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + lzo_voidp wrkmem ) + #endif + { +- register lzo_bytep op; +- register const lzo_bytep ip; +- register lzo_uint t; ++ lzo_bytep op; ++ const lzo_bytep ip; ++ lzo_uint t; + #if defined(COPY_DICT) + lzo_uint m_off; + const lzo_bytep dict_end; + #else +- register const lzo_bytep m_pos; ++ const lzo_bytep m_pos; + #endif + + const lzo_bytep const ip_end = in + in_len; +@@ -3648,43 +5127,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + op = out; + ip = in; + ++ NEED_IP(1); + if (*ip > 17) + { + t = *ip++ - 17; + if (t < 4) + goto match_next; +- assert(t > 0); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); NEED_OP(t); NEED_IP(t+3); + do *op++ = *ip++; while (--t > 0); + goto first_literal_run; + } + +- while (TEST_IP && TEST_OP) ++ for (;;) + { ++ NEED_IP(3); + t = *ip++; + if (t >= 16) + goto match; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_IV(t); + NEED_IP(1); + } + t += 15 + *ip++; + } +- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + t += 3; + if (t >= 8) do + { +- UA_COPY64(op,ip); ++ UA_COPY8(op,ip); + op += 8; ip += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } + if (t > 0) +@@ -3692,19 +5173,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + } +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (PTR_ALIGNED2_4(op,ip)) + { + #endif +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; + if (--t > 0) + { + if (t >= 4) + { + do { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *ip++; while (--t > 0); +@@ -3712,12 +5193,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + else + do *op++ = *ip++; while (--t > 0); + } +-#if !defined(LZO_UNALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + } + else + #endif + #endif +-#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) ++#if !(LZO_OPT_UNALIGNED32) + { + *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; + do *op++ = *ip++; while (--t > 0); +@@ -3753,7 +5234,7 @@ first_literal_run: + #endif + goto match_done; + +- do { ++ for (;;) { + match: + if (t >= 64) + { +@@ -3813,14 +5294,15 @@ match: + t &= 31; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 31 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -3836,9 +5318,9 @@ match: + m_pos = op - off; + last_m_off = off; + } +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) + m_pos = op - 1; +- m_pos -= UA_GET16(ip) >> 2; ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos = op - 1; + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +@@ -3857,14 +5339,15 @@ match: + t &= 7; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 7 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -3882,8 +5365,8 @@ match: + #else + #if defined(LZO1Z) + m_pos -= (ip[0] << 6) + (ip[1] >> 2); +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) +- m_pos -= UA_GET16(ip) >> 2; ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos -= (ip[0] >> 2) + (ip[1] << 6); + #endif +@@ -3931,18 +5414,18 @@ match: + #else + + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + if (op - m_pos >= 8) + { + t += (3 - 1); + if (t >= 8) do + { +- UA_COPY64(op,m_pos); ++ UA_COPY8(op,m_pos); + op += 8; m_pos += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } + if (t > 0) +@@ -3952,8 +5435,8 @@ match: + } + } + else +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + { + assert((op - m_pos) >= 4); +@@ -3961,10 +5444,10 @@ match: + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) + { + #endif +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4 - (3 - 1); + do { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *m_pos++; while (--t > 0); +@@ -3989,7 +5472,7 @@ match_done: + break; + + match_next: +- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); + #if 0 + do *op++ = *ip++; while (--t > 0); + #else +@@ -3997,16 +5480,10 @@ match_next: + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + #endif + t = *ip++; +- } while (TEST_IP && TEST_OP); ++ } + } + +-#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) +- *out_len = pd(op, out); +- return LZO_E_EOF_NOT_FOUND; +-#endif +- + eof_found: +- assert(t == 1); + *out_len = pd(op, out); + return (ip == ip_end ? LZO_E_OK : + (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); +@@ -4052,10 +5529,13 @@ lookbehind_overrun: + + #undef TEST_IP + #undef TEST_OP ++#undef TEST_IP_AND_TEST_OP + #undef TEST_LB + #undef TEST_LBO + #undef NEED_IP + #undef NEED_OP ++#undef TEST_IV ++#undef TEST_OV + #undef HAVE_TEST_IP + #undef HAVE_TEST_OP + #undef HAVE_NEED_IP +@@ -4070,6 +5550,7 @@ lookbehind_overrun: + # if (LZO_TEST_OVERRUN_INPUT >= 2) + # define NEED_IP(x) \ + if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun ++# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun + # endif + #endif + +@@ -4081,12 +5562,13 @@ lookbehind_overrun: + # undef TEST_OP + # define NEED_OP(x) \ + if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun ++# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun + # endif + #endif + + #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) +-# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun +-# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun ++# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun ++# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun + #else + # define TEST_LB(m_pos) ((void) 0) + # define TEST_LBO(m_pos,o) ((void) 0) +@@ -4107,15 +5589,27 @@ lookbehind_overrun: + # define TEST_OP 1 + #endif + ++#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) ++#elif defined(HAVE_TEST_IP) ++# define TEST_IP_AND_TEST_OP TEST_IP ++#elif defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP TEST_OP ++#else ++# define TEST_IP_AND_TEST_OP 1 ++#endif ++ + #if defined(NEED_IP) + # define HAVE_NEED_IP 1 + #else + # define NEED_IP(x) ((void) 0) ++# define TEST_IV(x) ((void) 0) + #endif + #if defined(NEED_OP) + # define HAVE_NEED_OP 1 + #else + # define NEED_OP(x) ((void) 0) ++# define TEST_OV(x) ((void) 0) + #endif + + #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) +@@ -4132,14 +5626,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + lzo_voidp wrkmem ) + #endif + { +- register lzo_bytep op; +- register const lzo_bytep ip; +- register lzo_uint t; ++ lzo_bytep op; ++ const lzo_bytep ip; ++ lzo_uint t; + #if defined(COPY_DICT) + lzo_uint m_off; + const lzo_bytep dict_end; + #else +- register const lzo_bytep m_pos; ++ const lzo_bytep m_pos; + #endif + + const lzo_bytep const ip_end = in + in_len; +@@ -4174,43 +5668,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + op = out; + ip = in; + ++ NEED_IP(1); + if (*ip > 17) + { + t = *ip++ - 17; + if (t < 4) + goto match_next; +- assert(t > 0); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); NEED_OP(t); NEED_IP(t+3); + do *op++ = *ip++; while (--t > 0); + goto first_literal_run; + } + +- while (TEST_IP && TEST_OP) ++ for (;;) + { ++ NEED_IP(3); + t = *ip++; + if (t >= 16) + goto match; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_IV(t); + NEED_IP(1); + } + t += 15 + *ip++; + } +- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + t += 3; + if (t >= 8) do + { +- UA_COPY64(op,ip); ++ UA_COPY8(op,ip); + op += 8; ip += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } + if (t > 0) +@@ -4218,19 +5714,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + } +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (PTR_ALIGNED2_4(op,ip)) + { + #endif +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; + if (--t > 0) + { + if (t >= 4) + { + do { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *ip++; while (--t > 0); +@@ -4238,12 +5734,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + else + do *op++ = *ip++; while (--t > 0); + } +-#if !defined(LZO_UNALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + } + else + #endif + #endif +-#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) ++#if !(LZO_OPT_UNALIGNED32) + { + *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; + do *op++ = *ip++; while (--t > 0); +@@ -4279,7 +5775,7 @@ first_literal_run: + #endif + goto match_done; + +- do { ++ for (;;) { + match: + if (t >= 64) + { +@@ -4339,14 +5835,15 @@ match: + t &= 31; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 31 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -4362,9 +5859,9 @@ match: + m_pos = op - off; + last_m_off = off; + } +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) + m_pos = op - 1; +- m_pos -= UA_GET16(ip) >> 2; ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos = op - 1; + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +@@ -4383,14 +5880,15 @@ match: + t &= 7; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 7 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -4408,8 +5906,8 @@ match: + #else + #if defined(LZO1Z) + m_pos -= (ip[0] << 6) + (ip[1] >> 2); +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) +- m_pos -= UA_GET16(ip) >> 2; ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos -= (ip[0] >> 2) + (ip[1] << 6); + #endif +@@ -4457,18 +5955,18 @@ match: + #else + + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + if (op - m_pos >= 8) + { + t += (3 - 1); + if (t >= 8) do + { +- UA_COPY64(op,m_pos); ++ UA_COPY8(op,m_pos); + op += 8; m_pos += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } + if (t > 0) +@@ -4478,8 +5976,8 @@ match: + } + } + else +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + { + assert((op - m_pos) >= 4); +@@ -4487,10 +5985,10 @@ match: + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) + { + #endif +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4 - (3 - 1); + do { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *m_pos++; while (--t > 0); +@@ -4515,7 +6013,7 @@ match_done: + break; + + match_next: +- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); + #if 0 + do *op++ = *ip++; while (--t > 0); + #else +@@ -4523,16 +6021,10 @@ match_next: + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + #endif + t = *ip++; +- } while (TEST_IP && TEST_OP); ++ } + } + +-#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) +- *out_len = pd(op, out); +- return LZO_E_EOF_NOT_FOUND; +-#endif +- + eof_found: +- assert(t == 1); + *out_len = pd(op, out); + return (ip == ip_end ? LZO_E_OK : + (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); +@@ -4559,4 +6051,3 @@ lookbehind_overrun: + #endif + + /***** End of minilzo.c *****/ +- +diff --git a/grub-core/lib/minilzo/minilzo.h b/grub-core/lib/minilzo/minilzo.h +index 74fefa9fe..793745467 100644 +--- a/grub-core/lib/minilzo/minilzo.h ++++ b/grub-core/lib/minilzo/minilzo.h +@@ -2,22 +2,7 @@ + + This file is part of the LZO real-time data compression library. + +- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ++ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or +@@ -50,7 +35,7 @@ + #ifndef __MINILZO_H + #define __MINILZO_H 1 + +-#define MINILZO_VERSION 0x2050 ++#define MINILZO_VERSION 0x2080 + + #ifdef __LZOCONF_H + # error "you cannot use both LZO and miniLZO" +@@ -78,7 +63,7 @@ extern "C" { + */ + + #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS +-#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) ++#define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) + #define LZO1X_MEM_DECOMPRESS (0) + + +-- +2.14.3 + diff --git a/0024-Add-X-option-to-printf-functions.patch b/0024-Add-X-option-to-printf-functions.patch deleted file mode 100644 index be1dc64..0000000 --- a/0024-Add-X-option-to-printf-functions.patch +++ /dev/null @@ -1,58 +0,0 @@ -From c482ec700b2ba4b1fabccaa5848cccae466d3a12 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Tue, 27 Nov 2012 16:58:39 -0200 -Subject: [PATCH 24/90] Add %X option to printf functions. - ---- - grub-core/kern/misc.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 6bb0351..81be344 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -587,7 +587,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) - static inline char * - grub_lltoa (char *str, int c, unsigned long long n) - { -- unsigned base = (c == 'x') ? 16 : 10; -+ unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10; - char *p; - - if ((long long) n < 0 && c == 'd') -@@ -602,7 +602,7 @@ grub_lltoa (char *str, int c, unsigned long long n) - do - { - unsigned d = (unsigned) (n & 0xf); -- *p++ = (d > 9) ? d + 'a' - 10 : d + '0'; -+ *p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0'; - } - while (n >>= 4); - else -@@ -675,6 +675,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, - { - case 'p': - case 'x': -+ case 'X': - case 'u': - case 'd': - case 'c': -@@ -761,6 +762,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, - switch (c) - { - case 'x': -+ case 'X': - case 'u': - args->ptr[curn].type = UNSIGNED_INT + longfmt; - break; -@@ -899,6 +901,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, - c = 'x'; - /* Fall through. */ - case 'x': -+ case 'X': - case 'u': - case 'd': - { --- -2.9.3 - diff --git a/0024-Add-vlan-tag-support-on-IBM-PPC-machines.patch b/0024-Add-vlan-tag-support-on-IBM-PPC-machines.patch new file mode 100644 index 0000000..154f07f --- /dev/null +++ b/0024-Add-vlan-tag-support-on-IBM-PPC-machines.patch @@ -0,0 +1,186 @@ +From de423b22780b0fd225a1ee476166777af29d53d0 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Tue, 30 Oct 2012 15:19:39 -0200 +Subject: [PATCH 024/123] Add vlan-tag support on IBM PPC machines + +This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows +multiple VLANs in a bridged network to share the same physical network link but +maintain isolation: + +http://en.wikipedia.org/wiki/IEEE_802.1Q + +This patch should fix this bugzilla: +https://bugzilla.redhat.com/show_bug.cgi?id=871563 +--- + grub-core/kern/ieee1275/init.c | 1 + + grub-core/kern/ieee1275/openfw.c | 30 ++++++++++++++++++++++++++++ + grub-core/net/ethernet.c | 42 +++++++++++++++++++++++++++++++++++++--- + include/grub/ieee1275/ieee1275.h | 1 + + include/grub/net.h | 2 ++ + 5 files changed, 73 insertions(+), 3 deletions(-) + +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 12590225e..5fa26e189 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -125,6 +125,7 @@ grub_machine_get_bootlocation (char **device, char **path) + char *dev, *canon; + char *ptr; + dev = grub_ieee1275_get_aliasdevname (bootpath); ++ grub_ieee1275_parse_net_options (bootpath); + canon = grub_ieee1275_canonicalise_devname (dev); + ptr = canon + grub_strlen (canon) - 1; + while (ptr > canon && (*ptr == ',' || *ptr == ':')) +diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c +index 6db8b9865..81276fae7 100644 +--- a/grub-core/kern/ieee1275/openfw.c ++++ b/grub-core/kern/ieee1275/openfw.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + enum grub_ieee1275_parse_type + { +@@ -451,6 +452,35 @@ fail: + return ret; + } + ++int ++grub_ieee1275_parse_net_options (const char *path) ++{ ++ char *comma; ++ char *args; ++ char *option = 0; ++ ++ args = grub_ieee1275_get_devargs (path); ++ if (!args) ++ /* There is no option. */ ++ return -1; ++ ++ do ++ { ++ comma = grub_strchr (args, ','); ++ if (! comma) ++ option = grub_strdup (args); ++ else ++ option = grub_strndup (args, (grub_size_t)(comma - args)); ++ args = comma + 1; ++ ++ if (! grub_strncmp(option, "vtag", 4)) ++ grub_env_set ("vlan-tag", option + grub_strlen("vtag=")); ++ ++ } while (comma); ++ ++ return 0; ++} ++ + char * + grub_ieee1275_get_device_type (const char *path) + { +diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c +index c397b1b34..faaca67c5 100644 +--- a/grub-core/net/ethernet.c ++++ b/grub-core/net/ethernet.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -56,10 +57,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, + { + struct etherhdr *eth; + grub_err_t err; ++ grub_uint32_t vlantag = 0; ++ grub_uint8_t etherhdr_size; + +- COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE); ++ etherhdr_size = sizeof (*eth); ++ COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE); + +- err = grub_netbuff_push (nb, sizeof (*eth)); ++ const char *vlantag_text = grub_env_get ("vlan-tag"); ++ if (vlantag_text != 0) { ++ etherhdr_size += 4; ++ vlantag = grub_strtoul (vlantag_text, 0, 16); ++ } ++ ++ err = grub_netbuff_push (nb, etherhdr_size); + if (err) + return err; + eth = (struct etherhdr *) nb->data; +@@ -76,6 +86,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, + return err; + inf->card->opened = 1; + } ++ ++ /* Check if a vlan-tag is needed. */ ++ if (vlantag != 0) ++ { ++ /* Move eth type to the right */ ++ grub_memcpy((char *) nb->data + etherhdr_size - 2, ++ (char *) nb->data + etherhdr_size - 6, 2); ++ ++ /* Add the tag in the middle */ ++ grub_memcpy((char *) nb->data + etherhdr_size - 6, ++ &vlantag, 4); ++ } ++ + return inf->card->driver->send (inf->card, nb); + } + +@@ -90,10 +113,23 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, + grub_net_link_level_address_t hwaddress; + grub_net_link_level_address_t src_hwaddress; + grub_err_t err; ++ grub_uint8_t etherhdr_size = sizeof (*eth); ++ ++ grub_uint16_t vlantag_identifier = 0; ++ grub_memcpy (&vlantag_identifier, nb->data + etherhdr_size - 2, 2); ++ ++ /* Check if a vlan-tag is present. */ ++ if (vlantag_identifier == VLANTAG_IDENTIFIER) ++ { ++ etherhdr_size += 4; ++ /* Move eth type to the original position */ ++ grub_memcpy((char *) nb->data + etherhdr_size - 6, ++ (char *) nb->data + etherhdr_size - 2, 2); ++ } + + eth = (struct etherhdr *) nb->data; + type = grub_be_to_cpu16 (eth->type); +- err = grub_netbuff_pull (nb, sizeof (*eth)); ++ err = grub_netbuff_pull (nb, etherhdr_size); + if (err) + return err; + +diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h +index ab4f284c3..663935da7 100644 +--- a/include/grub/ieee1275/ieee1275.h ++++ b/include/grub/ieee1275/ieee1275.h +@@ -238,6 +238,7 @@ void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, + struct grub_ieee1275_devalias *alias); + int EXPORT_FUNC(grub_ieee1275_cas_reboot) (char *script); + int EXPORT_FUNC(grub_ieee1275_set_boot_last_label) (const char *text); ++int EXPORT_FUNC(grub_ieee1275_parse_net_options) (const char *path); + + #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) + +diff --git a/include/grub/net.h b/include/grub/net.h +index 2192fa186..6ac9d72bf 100644 +--- a/include/grub/net.h ++++ b/include/grub/net.h +@@ -561,4 +561,6 @@ extern char *grub_net_default_server; + #define GRUB_NET_INTERVAL 400 + #define GRUB_NET_INTERVAL_ADDITION 20 + ++#define VLANTAG_IDENTIFIER 0x8100 ++ + #endif /* ! GRUB_NET_HEADER */ +-- +2.14.3 + diff --git a/0025-Allow-fallback-to-include-entries-by-title-not-just-.patch b/0025-Allow-fallback-to-include-entries-by-title-not-just-.patch new file mode 100644 index 0000000..48ee0ae --- /dev/null +++ b/0025-Allow-fallback-to-include-entries-by-title-not-just-.patch @@ -0,0 +1,144 @@ +From 196ae5abd961cd64b60d9ab41bfc02d340e8bb6f Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 5 Sep 2014 10:07:04 -0400 +Subject: [PATCH 025/123] Allow "fallback" to include entries by title, not + just number. + +Resolves: rhbz#1026084 + +Signed-off-by: Peter Jones +--- + grub-core/normal/menu.c | 85 +++++++++++++++++++++++++++++++++---------------- + 1 file changed, 58 insertions(+), 27 deletions(-) + +diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c +index 719e2fb1c..2e8a7bd89 100644 +--- a/grub-core/normal/menu.c ++++ b/grub-core/normal/menu.c +@@ -163,16 +163,41 @@ grub_menu_set_timeout (int timeout) + } + } + ++static int ++menuentry_eq (const char *id, const char *spec) ++{ ++ const char *ptr1, *ptr2; ++ ptr1 = id; ++ ptr2 = spec; ++ while (1) ++ { ++ if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0) ++ return ptr2 - spec; ++ if (*ptr2 == '>' && ptr2[1] != '>') ++ return 0; ++ if (*ptr2 == '>') ++ ptr2++; ++ if (*ptr1 != *ptr2) ++ return 0; ++ if (*ptr1 == 0) ++ return ptr1 - id; ++ ptr1++; ++ ptr2++; ++ } ++ return 0; ++} ++ + /* Get the first entry number from the value of the environment variable NAME, + which is a space-separated list of non-negative integers. The entry number + which is returned is stripped from the value of NAME. If no entry number + can be found, -1 is returned. */ + static int +-get_and_remove_first_entry_number (const char *name) ++get_and_remove_first_entry_number (grub_menu_t menu, const char *name) + { + const char *val; + char *tail; + int entry; ++ int sz = 0; + + val = grub_env_get (name); + if (! val) +@@ -182,9 +207,39 @@ get_and_remove_first_entry_number (const char *name) + + entry = (int) grub_strtoul (val, &tail, 0); + ++ if (grub_errno == GRUB_ERR_BAD_NUMBER) ++ { ++ /* See if the variable matches the title of a menu entry. */ ++ grub_menu_entry_t e = menu->entry_list; ++ int i; ++ ++ for (i = 0; e; i++) ++ { ++ sz = menuentry_eq (e->title, val); ++ if (sz < 1) ++ sz = menuentry_eq (e->id, val); ++ ++ if (sz >= 1) ++ { ++ entry = i; ++ break; ++ } ++ e = e->next; ++ } ++ ++ if (sz > 0) ++ grub_errno = GRUB_ERR_NONE; ++ ++ if (! e) ++ entry = -1; ++ } ++ + if (grub_errno == GRUB_ERR_NONE) + { +- /* Skip whitespace to find the next digit. */ ++ if (sz > 0) ++ tail += sz; ++ ++ /* Skip whitespace to find the next entry. */ + while (*tail && grub_isspace (*tail)) + tail++; + grub_env_set (name, tail); +@@ -347,7 +402,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu, + grub_menu_execute_entry (entry, 1); + + /* Deal with fallback entries. */ +- while ((fallback_entry = get_and_remove_first_entry_number ("fallback")) ++ while ((fallback_entry = get_and_remove_first_entry_number (menu, "fallback")) + >= 0) + { + grub_print_error (); +@@ -465,30 +520,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer) + viewers = viewer; + } + +-static int +-menuentry_eq (const char *id, const char *spec) +-{ +- const char *ptr1, *ptr2; +- ptr1 = id; +- ptr2 = spec; +- while (1) +- { +- if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0) +- return 1; +- if (*ptr2 == '>' && ptr2[1] != '>') +- return 0; +- if (*ptr2 == '>') +- ptr2++; +- if (*ptr1 != *ptr2) +- return 0; +- if (*ptr1 == 0) +- return 1; +- ptr1++; +- ptr2++; +- } +-} +- +- + /* Get the entry number from the variable NAME. */ + static int + get_entry_number (grub_menu_t menu, const char *name) +-- +2.14.3 + diff --git a/0025-Search-for-specific-config-file-for-netboot.patch b/0025-Search-for-specific-config-file-for-netboot.patch deleted file mode 100644 index 0e6d042..0000000 --- a/0025-Search-for-specific-config-file-for-netboot.patch +++ /dev/null @@ -1,203 +0,0 @@ -From 70a8c5e075d59ec13fdee4c3868b3862a8cd8aa4 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Tue, 27 Nov 2012 17:22:07 -0200 -Subject: [PATCH 25/90] Search for specific config file for netboot - -This patch implements a search for a specific configuration when the config -file is on a remoteserver. It uses the following order: - 1) DHCP client UUID option. - 2) MAC address (in lower case hexadecimal with dash separators); - 3) IP (in upper case hexadecimal) or IPv6; - 4) The original grub.cfg file. - -This procedure is similar to what is used by pxelinux and yaboot: -http://www.syslinux.org/wiki/index.php/PXELINUX#config - -This should close the bugzilla: -https://bugzilla.redhat.com/show_bug.cgi?id=873406 ---- - grub-core/net/net.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ - grub-core/normal/main.c | 18 ++++++-- - include/grub/net.h | 3 ++ - 3 files changed, 135 insertions(+), 4 deletions(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 10773fc..0769bf8 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -1735,6 +1735,124 @@ grub_net_restore_hw (void) - return GRUB_ERR_NONE; - } - -+grub_err_t -+grub_net_search_configfile (char *config) -+{ -+ grub_size_t config_len; -+ char *suffix; -+ -+ auto int search_through (grub_size_t num_tries, grub_size_t slice_size); -+ int search_through (grub_size_t num_tries, grub_size_t slice_size) -+ { -+ while (num_tries-- > 0) -+ { -+ grub_dprintf ("net", "probe %s\n", config); -+ -+ grub_file_t file; -+ file = grub_file_open (config); -+ -+ if (file) -+ { -+ grub_file_close (file); -+ grub_dprintf ("net", "found!\n"); -+ return 0; -+ } -+ else -+ { -+ if (grub_errno == GRUB_ERR_IO) -+ grub_errno = GRUB_ERR_NONE; -+ } -+ -+ if (grub_strlen (suffix) < slice_size) -+ break; -+ -+ config[grub_strlen (config) - slice_size] = '\0'; -+ } -+ -+ return 1; -+ } -+ -+ config_len = grub_strlen (config); -+ config[config_len] = '-'; -+ suffix = config + config_len + 1; -+ -+ struct grub_net_network_level_interface *inf; -+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf) -+ { -+ /* By the Client UUID. */ -+ -+ char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) + -+ sizeof ("_clientuuid") + 1]; -+ grub_snprintf (client_uuid_var, sizeof (client_uuid_var), -+ "net_%s_clientuuid", inf->name); -+ -+ const char *client_uuid; -+ client_uuid = grub_env_get (client_uuid_var); -+ -+ if (client_uuid) -+ { -+ grub_strcpy (suffix, client_uuid); -+ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; -+ } -+ -+ /* By the MAC address. */ -+ -+ /* Add ethernet type */ -+ grub_strcpy (suffix, "01-"); -+ -+ grub_net_hwaddr_to_str (&inf->hwaddress, suffix + 3); -+ -+ char *ptr; -+ for (ptr = suffix; *ptr; ptr++) -+ if (*ptr == ':') -+ *ptr = '-'; -+ -+ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; -+ -+ /* By IP address */ -+ -+ switch ((&inf->address)->type) -+ { -+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4: -+ { -+ grub_uint32_t n = grub_be_to_cpu32 ((&inf->address)->ipv4); -+ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%02X%02X%02X%02X", \ -+ ((n >> 24) & 0xff), ((n >> 16) & 0xff), \ -+ ((n >> 8) & 0xff), ((n >> 0) & 0xff)); -+ -+ if (search_through (8, 1) == 0) return GRUB_ERR_NONE; -+ break; -+ } -+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6: -+ { -+ char buf[GRUB_NET_MAX_STR_ADDR_LEN]; -+ struct grub_net_network_level_address base; -+ base.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; -+ grub_memcpy (&base.ipv6, ((&inf->address)->ipv6), 16); -+ grub_net_addr_to_str (&base, buf); -+ -+ for (ptr = buf; *ptr; ptr++) -+ if (*ptr == ':') -+ *ptr = '-'; -+ -+ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%s", buf); -+ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; -+ break; -+ } -+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV: -+ return grub_error (GRUB_ERR_BUG, "shouldn't reach here"); -+ default: -+ return grub_error (GRUB_ERR_BUG, -+ "unsupported address type %d", (&inf->address)->type); -+ } -+ } -+ -+ /* Remove the remaining minus sign at the end. */ -+ config[config_len] = '\0'; -+ -+ return GRUB_ERR_NONE; -+} -+ - static struct grub_preboot *fini_hnd; - - static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 759c475..b2654ef 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -33,6 +33,7 @@ - #include - #include - #include -+#include - #ifdef GRUB_MACHINE_IEEE1275 - #include - #endif -@@ -365,10 +366,19 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), - - prefix = grub_env_get ("prefix"); - if (prefix) -- { -- config = grub_xasprintf ("%s/grub.cfg", prefix); -- if (! config) -- goto quit; -+ { -+ grub_size_t config_len; -+ config_len = grub_strlen (prefix) + -+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -+ config = grub_malloc (config_len); -+ -+ if (! config) -+ goto quit; -+ -+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -+ -+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -+ grub_net_search_configfile (config); - - grub_enter_normal_mode (config); - grub_free (config); -diff --git a/include/grub/net.h b/include/grub/net.h -index 96aa9fa..e13ae1e 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -565,4 +565,7 @@ extern char *grub_net_default_server; - - #define VLANTAG_IDENTIFIER 0x8100 - -+grub_err_t -+grub_net_search_configfile (char *config); -+ - #endif /* ! GRUB_NET_HEADER */ --- -2.9.3 - diff --git a/0026-Add-GRUB_DISABLE_UUID.patch b/0026-Add-GRUB_DISABLE_UUID.patch new file mode 100644 index 0000000..d70c1aa --- /dev/null +++ b/0026-Add-GRUB_DISABLE_UUID.patch @@ -0,0 +1,99 @@ +From 8f405e93871ad51cd9ab4dfdea844042a33fa7f0 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 4 Sep 2014 16:49:25 -0400 +Subject: [PATCH 026/123] Add GRUB_DISABLE_UUID. + +This will cause "search --fs-uuid --set=root ..." not to be generated by +grub2-mkconfig, and instead simply attempt to use the grub device name +as it understands it. + +Signed-off-by: Peter Jones +--- + docs/grub.texi | 7 +++++++ + util/grub-mkconfig.in | 12 ++++++++++-- + util/grub-mkconfig_lib.in | 4 ++-- + 3 files changed, 19 insertions(+), 4 deletions(-) + +diff --git a/docs/grub.texi b/docs/grub.texi +index 82f6fa459..98d4d0d52 100644 +--- a/docs/grub.texi ++++ b/docs/grub.texi +@@ -1409,6 +1409,13 @@ disable the use of UUIDs, set this option to @samp{true}. + If this option is set to @samp{true}, disable the generation of recovery + mode menu entries. + ++@item GRUB_DISABLE_UUID ++Normally, @command{grub-mkconfig} will generate menu entries that use ++universally-unique identifiers (UUIDs) to identify various filesystems to ++search for files. This is usually more reliable, but in some cases it may ++not be appropriate. To disable this use of UUIDs, set this option to ++@samp{true}. ++ + @item GRUB_VIDEO_BACKEND + If graphical video support is required, either because the @samp{gfxterm} + graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set, +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 3b070fd76..c088b7054 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -133,11 +133,11 @@ fi + + # Device containing our userland. Typically used for root= parameter. + GRUB_DEVICE="`${grub_probe} --target=device /`" +-GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true ++GRUB_DEVICE_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true + + # Device containing our /boot partition. Usually the same as GRUB_DEVICE. + GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" +-GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true ++GRUB_DEVICE_BOOT_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true + + # Filesystem for the device containing our userland. Used for stuff like + # choosing Hurd filesystem module. +@@ -151,6 +151,13 @@ if test -f ${sysconfdir}/default/grub ; then + . ${sysconfdir}/default/grub + fi + ++if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_UUID" ]; then ++ GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" ++fi ++if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_BOOT_UUID" ]; then ++ GRUB_DEVICE_BOOT_UUID="$GRUB_DEVICE_BOOT_UUID_GENERATED" ++fi ++ + # XXX: should this be deprecated at some point? + if [ "x${GRUB_TERMINAL}" != "x" ] ; then + GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}" +@@ -216,6 +223,7 @@ export GRUB_DEFAULT \ + GRUB_SERIAL_COMMAND \ + GRUB_DISABLE_LINUX_UUID \ + GRUB_DISABLE_RECOVERY \ ++ GRUB_DISABLE_UUID \ + GRUB_VIDEO_BACKEND \ + GRUB_GFXMODE \ + GRUB_BACKGROUND \ +diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in +index 60b31cadd..cf35e4174 100644 +--- a/util/grub-mkconfig_lib.in ++++ b/util/grub-mkconfig_lib.in +@@ -156,7 +156,7 @@ prepare_grub_to_access_device () + if [ "x$fs_hint" != x ]; then + echo "set root='$fs_hint'" + fi +- if fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then ++ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then + hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= + echo "if [ x\$feature_platform_search_hint = xy ]; then" + echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" +@@ -173,7 +173,7 @@ grub_get_device_id () + IFS=' + ' + device="$1" +- if fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then ++ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then + echo "$fs_uuid"; + else + echo $device |sed 's, ,_,g' +-- +2.14.3 + diff --git a/0026-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch b/0026-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch deleted file mode 100644 index af5efe3..0000000 --- a/0026-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +++ /dev/null @@ -1,251 +0,0 @@ -From 8992c2812e1e914e803429314b9164a19af4398b Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Tue, 22 Jan 2013 06:31:38 +0100 -Subject: [PATCH 26/90] blscfg: add blscfg module to parse Boot Loader - Specification snippets - -http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec - -Works like this: - - insmod blscfg - bls_import - -Done! You should now have menu items for your snippets in place. - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 8 ++ - grub-core/commands/blscfg.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 209 insertions(+) - create mode 100644 grub-core/commands/blscfg.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index de8c9df..e79bb0c 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -741,6 +741,14 @@ module = { - }; - - module = { -+ name = blscfg; -+ common = commands/blscfg.c; -+ enable = i386_efi; -+ enable = x86_64_efi; -+ enable = i386_pc; -+}; -+ -+module = { - name = boot; - common = commands/boot.c; - i386_pc = lib/i386/pc/biosnum.c; -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -new file mode 100644 -index 0000000..4274aca ---- /dev/null -+++ b/grub-core/commands/blscfg.c -@@ -0,0 +1,201 @@ -+/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/ -+ -+/* bls.c - implementation of the boot loader spec */ -+ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * -+ * GRUB 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. -+ * -+ * GRUB 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 GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+GRUB_MOD_LICENSE ("GPLv3+"); -+ -+#ifdef GRUB_MACHINE_EFI -+#define GRUB_LINUX_CMD "linuxefi" -+#define GRUB_INITRD_CMD "initrdefi" -+#define GRUB_BLS_CONFIG_PATH "/EFI/fedora/loader/entries/" -+#define GRUB_BOOT_DEVICE "($boot)" -+#else -+#define GRUB_LINUX_CMD "linux" -+#define GRUB_INITRD_CMD "initrd" -+#define GRUB_BLS_CONFIG_PATH "/loader/entries/" -+#define GRUB_BOOT_DEVICE "($root)" -+#endif -+ -+static int parse_entry ( -+ const char *filename, -+ const struct grub_dirhook_info *info __attribute__ ((unused)), -+ void *data __attribute__ ((unused))) -+{ -+ grub_size_t n; -+ char *p; -+ grub_file_t f = NULL; -+ grub_off_t sz; -+ char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL; -+ const char *args[2] = { NULL, NULL }; -+ -+ if (filename[0] == '.') -+ return 0; -+ -+ n = grub_strlen (filename); -+ if (n <= 5) -+ return 0; -+ -+ if (grub_strcmp (filename + n - 5, ".conf") != 0) -+ return 0; -+ -+ p = grub_xasprintf (GRUB_BLS_CONFIG_PATH "%s", filename); -+ -+ f = grub_file_open (p); -+ if (!f) -+ goto finish; -+ -+ sz = grub_file_size (f); -+ if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -+ goto finish; -+ -+ for (;;) -+ { -+ char *buf; -+ -+ buf = grub_file_getline (f); -+ if (!buf) -+ break; -+ -+ if (grub_strncmp (buf, "title ", 6) == 0) -+ { -+ grub_free (title); -+ title = grub_strdup (buf + 6); -+ if (!title) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "options ", 8) == 0) -+ { -+ grub_free (options); -+ options = grub_strdup (buf + 8); -+ if (!options) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "linux ", 6) == 0) -+ { -+ grub_free (clinux); -+ clinux = grub_strdup (buf + 6); -+ if (!clinux) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "initrd ", 7) == 0) -+ { -+ grub_free (initrd); -+ initrd = grub_strdup (buf + 7); -+ if (!initrd) -+ goto finish; -+ } -+ -+ grub_free(buf); -+ } -+ -+ if (!linux) -+ { -+ grub_printf ("Skipping file %s with no 'linux' key.", p); -+ goto finish; -+ } -+ -+ args[0] = title ? title : filename; -+ -+ src = grub_xasprintf ("load_video\n" -+ "set gfx_payload=keep\n" -+ "insmod gzio\n" -+ GRUB_LINUX_CMD " %s%s%s%s\n" -+ "%s%s%s%s", -+ GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", -+ initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); -+ -+ grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0); -+ -+finish: -+ grub_free (p); -+ grub_free (title); -+ grub_free (options); -+ grub_free (clinux); -+ grub_free (initrd); -+ grub_free (src); -+ -+ if (f) -+ grub_file_close (f); -+ -+ return 0; -+} -+ -+static grub_err_t -+grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), -+ int argc __attribute__ ((unused)), -+ char **args __attribute__ ((unused))) -+{ -+ grub_fs_t fs; -+ grub_device_t dev; -+ static grub_err_t r; -+ const char *devid; -+ -+ devid = grub_env_get ("root"); -+ if (!devid) -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "root"); -+ -+ dev = grub_device_open (devid); -+ if (!dev) -+ return grub_errno; -+ -+ fs = grub_fs_probe (dev); -+ if (!fs) -+ { -+ r = grub_errno; -+ goto finish; -+ } -+ -+ r = fs->dir (dev, GRUB_BLS_CONFIG_PATH, parse_entry, NULL); -+ -+finish: -+ if (dev) -+ grub_device_close (dev); -+ -+ return r; -+} -+ -+static grub_extcmd_t cmd; -+ -+GRUB_MOD_INIT(bls) -+{ -+ cmd = grub_register_extcmd ("bls_import", -+ grub_cmd_bls_import, -+ 0, -+ NULL, -+ N_("Import Boot Loader Specification snippets."), -+ NULL); -+} -+ -+GRUB_MOD_FINI(bls) -+{ -+ grub_unregister_extcmd (cmd); -+} --- -2.9.3 - diff --git a/0027-Don-t-write-messages-to-the-screen.patch b/0027-Don-t-write-messages-to-the-screen.patch deleted file mode 100644 index 3b889cd..0000000 --- a/0027-Don-t-write-messages-to-the-screen.patch +++ /dev/null @@ -1,181 +0,0 @@ -From 3e83ff704af9a967fa55d60cc3917bc4ccd85f32 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Wed, 15 May 2013 13:30:20 -0400 -Subject: [PATCH 27/90] Don't write messages to the screen - -Writing messages to the screen before the menus or boot splash -happens so quickly it looks like something is wrong and isn't -very appealing. ---- - grub-core/boot/i386/pc/boot.S | 3 --- - grub-core/boot/i386/pc/diskboot.S | 5 ----- - grub-core/gettext/gettext.c | 25 +++++-------------------- - grub-core/kern/main.c | 5 ----- - util/grub.d/10_linux.in | 7 ------- - 5 files changed, 5 insertions(+), 40 deletions(-) - -diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S -index 2bd0b2d..ea167fe 100644 ---- a/grub-core/boot/i386/pc/boot.S -+++ b/grub-core/boot/i386/pc/boot.S -@@ -249,9 +249,6 @@ real_start: - /* save drive reference first thing! */ - pushw %dx - -- /* print a notification message on the screen */ -- MSG(notification_string) -- - /* set %si to the disk address packet */ - movw $disk_address_packet, %si - -diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S -index 1ee4cf5..c8b87ed 100644 ---- a/grub-core/boot/i386/pc/diskboot.S -+++ b/grub-core/boot/i386/pc/diskboot.S -@@ -50,11 +50,6 @@ _start: - /* save drive reference first thing! */ - pushw %dx - -- /* print a notification message on the screen */ -- pushw %si -- MSG(notification_string) -- popw %si -- - /* this sets up for the first run through "bootloop" */ - movw $LOCAL(firstlist), %di - -diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c -index 4880cef..b22e1bc 100644 ---- a/grub-core/gettext/gettext.c -+++ b/grub-core/gettext/gettext.c -@@ -434,16 +434,12 @@ static char * - grub_gettext_env_write_lang (struct grub_env_var *var - __attribute__ ((unused)), const char *val) - { -- grub_err_t err; -+ grub_err_t __attribute__((__unused__)) err; - err = grub_gettext_init_ext (&main_context, val, grub_env_get ("locale_dir"), - grub_env_get ("prefix")); -- if (err) -- grub_print_error (); - - err = grub_gettext_init_ext (&secondary_context, val, - grub_env_get ("secondary_locale_dir"), 0); -- if (err) -- grub_print_error (); - - return grub_strdup (val); - } -@@ -451,23 +447,19 @@ grub_gettext_env_write_lang (struct grub_env_var *var - void - grub_gettext_reread_prefix (const char *val) - { -- grub_err_t err; -+ grub_err_t __attribute__((__unused__)) err; - err = grub_gettext_init_ext (&main_context, grub_env_get ("lang"), - grub_env_get ("locale_dir"), - val); -- if (err) -- grub_print_error (); - } - - static char * - read_main (struct grub_env_var *var - __attribute__ ((unused)), const char *val) - { -- grub_err_t err; -+ grub_err_t __attribute__((__unused__)) err; - err = grub_gettext_init_ext (&main_context, grub_env_get ("lang"), val, - grub_env_get ("prefix")); -- if (err) -- grub_print_error (); - return grub_strdup (val); - } - -@@ -475,12 +467,9 @@ static char * - read_secondary (struct grub_env_var *var - __attribute__ ((unused)), const char *val) - { -- grub_err_t err; -+ grub_err_t __attribute__((__unused__)) err; - err = grub_gettext_init_ext (&secondary_context, grub_env_get ("lang"), val, - 0); -- if (err) -- grub_print_error (); -- - return grub_strdup (val); - } - -@@ -500,18 +489,14 @@ grub_cmd_translate (grub_command_t cmd __attribute__ ((unused)), - GRUB_MOD_INIT (gettext) - { - const char *lang; -- grub_err_t err; -+ grub_err_t __attribute__((__unused__)) err; - - lang = grub_env_get ("lang"); - - err = grub_gettext_init_ext (&main_context, lang, grub_env_get ("locale_dir"), - grub_env_get ("prefix")); -- if (err) -- grub_print_error (); - err = grub_gettext_init_ext (&secondary_context, lang, - grub_env_get ("secondary_locale_dir"), 0); -- if (err) -- grub_print_error (); - - grub_register_variable_hook ("locale_dir", NULL, read_main); - grub_register_variable_hook ("secondary_locale_dir", NULL, read_secondary); -diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 8ab7794..da47b18 100644 ---- a/grub-core/kern/main.c -+++ b/grub-core/kern/main.c -@@ -268,11 +268,6 @@ grub_main (void) - - grub_boot_time ("After machine init."); - -- /* Hello. */ -- grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); -- grub_printf ("Welcome to GRUB!\n\n"); -- grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); -- - grub_load_config (); - - grub_boot_time ("Before loading embedded modules."); -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 8ccf012..a3d9711 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -128,29 +128,22 @@ linux_entry () - fi - printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" - fi -- message="$(gettext_printf "Loading Linux %s ..." ${version})" - if [ -d /sys/firmware/efi ]; then - sed "s/^/$submenu_indentation/" << EOF -- echo '$(echo "$message" | grub_quote)' - linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} - EOF - else - sed "s/^/$submenu_indentation/" << EOF -- echo '$(echo "$message" | grub_quote)' - linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} - EOF - fi - if test -n "${initrd}" ; then -- # TRANSLATORS: ramdisk isn't identifier. Should be translated. -- message="$(gettext_printf "Loading initial ramdisk ...")" - if [ -d /sys/firmware/efi ]; then - sed "s/^/$submenu_indentation/" << EOF -- echo '$(echo "$message" | grub_quote)' - initrdefi ${rel_dirname}/${initrd} - EOF - else - sed "s/^/$submenu_indentation/" << EOF -- echo '$message' - initrd ${rel_dirname}/${initrd} - EOF - fi --- -2.9.3 - diff --git a/0027-Make-exit-take-a-return-code.patch b/0027-Make-exit-take-a-return-code.patch new file mode 100644 index 0000000..3dd14e6 --- /dev/null +++ b/0027-Make-exit-take-a-return-code.patch @@ -0,0 +1,259 @@ +From 6879936079d17ace35cebcab787f7fb9f8cd205e Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 26 Feb 2014 21:49:12 -0500 +Subject: [PATCH 027/123] Make "exit" take a return code. + +This adds "exit" with a return code. With this patch, any "exit" +command /may/ include a return code, and on platforms that support +returning with an exit status, we will do so. By default we return the +same exit status we did before this patch. + +Signed-off-by: Peter Jones +--- + grub-core/commands/minicmd.c | 20 ++++++++++++++++---- + grub-core/kern/efi/efi.c | 9 +++++++-- + grub-core/kern/emu/main.c | 2 +- + grub-core/kern/emu/misc.c | 5 +++-- + grub-core/kern/i386/coreboot/init.c | 2 +- + grub-core/kern/i386/qemu/init.c | 2 +- + grub-core/kern/ieee1275/init.c | 2 +- + grub-core/kern/mips/arc/init.c | 2 +- + grub-core/kern/mips/loongson/init.c | 2 +- + grub-core/kern/mips/qemu_mips/init.c | 2 +- + grub-core/kern/misc.c | 2 +- + grub-core/kern/uboot/init.c | 6 +++--- + grub-core/kern/xen/init.c | 2 +- + include/grub/misc.h | 2 +- + 14 files changed, 39 insertions(+), 21 deletions(-) + +diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c +index a3a118241..b25ca4b9f 100644 +--- a/grub-core/commands/minicmd.c ++++ b/grub-core/commands/minicmd.c +@@ -176,12 +176,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), + } + + /* exit */ +-static grub_err_t __attribute__ ((noreturn)) ++static grub_err_t + grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)), +- int argc __attribute__ ((unused)), +- char *argv[] __attribute__ ((unused))) ++ int argc, char *argv[]) + { +- grub_exit (); ++ int retval = -1; ++ unsigned long n; ++ ++ if (argc < 0 || argc > 1) ++ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); ++ ++ if (argc == 1) ++ { ++ n = grub_strtoul (argv[0], 0, 10); ++ if (n != ~0UL) ++ retval = n; ++ } ++ ++ grub_exit (retval); + /* Not reached. */ + } + +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index caf9bcc41..101307fc7 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -155,11 +155,16 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) + } + + void +-grub_exit (void) ++grub_exit (int retval) + { ++ int rc = GRUB_EFI_LOAD_ERROR; ++ ++ if (retval == 0) ++ rc = GRUB_EFI_SUCCESS; ++ + grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); + efi_call_4 (grub_efi_system_table->boot_services->exit, +- grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0); ++ grub_efi_image_handle, rc, 0, 0); + for (;;) ; + } + +diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c +index f91280f68..34634d3d5 100644 +--- a/grub-core/kern/emu/main.c ++++ b/grub-core/kern/emu/main.c +@@ -66,7 +66,7 @@ grub_reboot (void) + } + + void +-grub_exit (void) ++grub_exit (int retval __attribute__((unused))) + { + grub_reboot (); + } +diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c +index d361feb00..331fa62a4 100644 +--- a/grub-core/kern/emu/misc.c ++++ b/grub-core/kern/emu/misc.c +@@ -136,9 +136,10 @@ xasprintf (const char *fmt, ...) + + #if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) + void +-grub_exit (void) ++__attribute__ ((noreturn)) ++grub_exit (int rc) + { +- exit (1); ++ exit (rc < 0 ? 1 : rc); + } + #endif + +diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c +index 3314f027f..36f9134b7 100644 +--- a/grub-core/kern/i386/coreboot/init.c ++++ b/grub-core/kern/i386/coreboot/init.c +@@ -41,7 +41,7 @@ extern grub_uint8_t _end[]; + extern grub_uint8_t _edata[]; + + void __attribute__ ((noreturn)) +-grub_exit (void) ++grub_exit (int rc __attribute__((unused))) + { + /* We can't use grub_fatal() in this function. This would create an infinite + loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ +diff --git a/grub-core/kern/i386/qemu/init.c b/grub-core/kern/i386/qemu/init.c +index 271b6fbfa..9fafe98f0 100644 +--- a/grub-core/kern/i386/qemu/init.c ++++ b/grub-core/kern/i386/qemu/init.c +@@ -42,7 +42,7 @@ extern grub_uint8_t _end[]; + extern grub_uint8_t _edata[]; + + void __attribute__ ((noreturn)) +-grub_exit (void) ++grub_exit (int rc __attribute__((unused))) + { + /* We can't use grub_fatal() in this function. This would create an infinite + loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 5fa26e189..8a3ecd580 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -68,7 +68,7 @@ grub_addr_t grub_ieee1275_original_stack; + #endif + + void +-grub_exit (void) ++grub_exit (int rc __attribute__((unused))) + { + grub_ieee1275_exit (); + } +diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c +index 3834a1490..86b3a25ec 100644 +--- a/grub-core/kern/mips/arc/init.c ++++ b/grub-core/kern/mips/arc/init.c +@@ -276,7 +276,7 @@ grub_halt (void) + } + + void +-grub_exit (void) ++grub_exit (int rc __attribute__((unused))) + { + GRUB_ARC_FIRMWARE_VECTOR->exit (); + +diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c +index 7b96531b9..dff598ca7 100644 +--- a/grub-core/kern/mips/loongson/init.c ++++ b/grub-core/kern/mips/loongson/init.c +@@ -304,7 +304,7 @@ grub_halt (void) + } + + void +-grub_exit (void) ++grub_exit (int rc __attribute__((unused))) + { + grub_halt (); + } +diff --git a/grub-core/kern/mips/qemu_mips/init.c b/grub-core/kern/mips/qemu_mips/init.c +index be88b77d2..8b6c55ffc 100644 +--- a/grub-core/kern/mips/qemu_mips/init.c ++++ b/grub-core/kern/mips/qemu_mips/init.c +@@ -75,7 +75,7 @@ grub_machine_fini (int flags __attribute__ ((unused))) + } + + void +-grub_exit (void) ++grub_exit (int rc __attribute__((unused))) + { + grub_halt (); + } +diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c +index d1a54df6c..6bb035175 100644 +--- a/grub-core/kern/misc.c ++++ b/grub-core/kern/misc.c +@@ -1094,7 +1094,7 @@ grub_abort (void) + grub_getkey (); + } + +- grub_exit (); ++ grub_exit (1); + } + + void +diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c +index 5dcc106ed..430c62b66 100644 +--- a/grub-core/kern/uboot/init.c ++++ b/grub-core/kern/uboot/init.c +@@ -43,9 +43,9 @@ extern grub_uint32_t grub_uboot_machine_type; + extern grub_addr_t grub_uboot_boot_data; + + void +-grub_exit (void) ++grub_exit (int rc) + { +- grub_uboot_return (0); ++ grub_uboot_return (rc < 0 ? 1 : rc); + } + + grub_uint32_t +@@ -94,7 +94,7 @@ grub_machine_init (void) + if (!ver) + { + /* Don't even have a console to log errors to... */ +- grub_exit (); ++ grub_exit (-1); + } + else if (ver > API_SIG_VERSION) + { +diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c +index 0559c033c..fce526d41 100644 +--- a/grub-core/kern/xen/init.c ++++ b/grub-core/kern/xen/init.c +@@ -549,7 +549,7 @@ grub_machine_init (void) + } + + void +-grub_exit (void) ++grub_exit (int rc __attribute__((unused))) + { + struct sched_shutdown arg; + +diff --git a/include/grub/misc.h b/include/grub/misc.h +index 2a9f87cc2..062081437 100644 +--- a/include/grub/misc.h ++++ b/include/grub/misc.h +@@ -334,7 +334,7 @@ int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt, + char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) + __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT; + char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT; +-void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); ++void EXPORT_FUNC(grub_exit) (int rc) __attribute__ ((noreturn)); + grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, + grub_uint64_t d, + grub_uint64_t *r); +-- +2.14.3 + diff --git a/0028-Don-t-print-GNU-GRUB-header.patch b/0028-Don-t-print-GNU-GRUB-header.patch deleted file mode 100644 index 7c9fbb7..0000000 --- a/0028-Don-t-print-GNU-GRUB-header.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 9bd3d2fb49a6b8e3807ce7275876fd4b416545c9 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Wed, 15 May 2013 13:53:48 -0400 -Subject: [PATCH 28/90] Don't print GNU GRUB header - -No one cares. ---- - grub-core/normal/main.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index b2654ef..f57b750 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -202,15 +202,16 @@ read_config_file (const char *config) - /* Initialize the screen. */ - void - grub_normal_init_page (struct grub_term_output *term, -- int y) -+ int y __attribute__((__unused__))) - { -+ grub_term_cls (term); -+ -+#if 0 - grub_ssize_t msg_len; - int posx; - char *msg_formatted; - grub_uint32_t *unicode_msg; - grub_uint32_t *last_position; -- -- grub_term_cls (term); - - msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION); - if (!msg_formatted) -@@ -235,6 +236,7 @@ grub_normal_init_page (struct grub_term_output *term, - grub_putcode ('\n', term); - grub_putcode ('\n', term); - grub_free (unicode_msg); -+#endif - } - - static void --- -2.9.3 - diff --git a/0028-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch b/0028-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch new file mode 100644 index 0000000..5d255e5 --- /dev/null +++ b/0028-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch @@ -0,0 +1,22 @@ +From ef756db92dd4f47ed4bb4aede86d33326b0b9188 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 22 Jul 2015 11:21:01 -0400 +Subject: [PATCH 028/123] Mark po/exclude.pot as binary so git won't try to + diff nonprintables. + +Signed-off-by: Peter Jones +--- + .gitattributes | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 .gitattributes + +diff --git a/.gitattributes b/.gitattributes +new file mode 100644 +index 000000000..33ffaa404 +--- /dev/null ++++ b/.gitattributes +@@ -0,0 +1 @@ ++po/exclude.pot binary +-- +2.14.3 + diff --git a/0029-Don-t-add-to-highlighted-row.patch b/0029-Don-t-add-to-highlighted-row.patch deleted file mode 100644 index 96218b3..0000000 --- a/0029-Don-t-add-to-highlighted-row.patch +++ /dev/null @@ -1,26 +0,0 @@ -From dd2c80ddd0e5e57b33a9d06894225e629b1b8b5e Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Wed, 15 May 2013 17:49:45 -0400 -Subject: [PATCH 29/90] Don't add '*' to highlighted row - -It is already highlighted. ---- - grub-core/normal/menu_text.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index e22bb91..a3d1f23 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -242,7 +242,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, - unicode_title[i] = ' '; - - if (data->geo.num_entries > 1) -- grub_putcode (highlight ? '*' : ' ', data->term); -+ grub_putcode (' ', data->term); - - grub_print_ucs4_menu (unicode_title, - unicode_title + len, --- -2.9.3 - diff --git a/0029-Make-efi-machines-load-an-env-block-from-a-variable.patch b/0029-Make-efi-machines-load-an-env-block-from-a-variable.patch new file mode 100644 index 0000000..09f6e6c --- /dev/null +++ b/0029-Make-efi-machines-load-an-env-block-from-a-variable.patch @@ -0,0 +1,84 @@ +From e14c5369fea76d1e067ca9f7e5e55bfe615cb639 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 7 Dec 2015 14:20:49 -0500 +Subject: [PATCH 029/123] Make efi machines load an env block from a variable + +Signed-off-by: Peter Jones +--- + grub-core/Makefile.core.def | 1 + + grub-core/kern/efi/init.c | 34 +++++++++++++++++++++++++++++++++- + 2 files changed, 34 insertions(+), 1 deletion(-) + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index 58b4208b0..f8d46342a 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -173,6 +173,7 @@ kernel = { + efi = term/efi/console.c; + efi = kern/acpi.c; + efi = kern/efi/acpi.c; ++ efi = lib/envblk.c; + i386_coreboot = kern/i386/pc/acpi.c; + i386_multiboot = kern/i386/pc/acpi.c; + i386_coreboot = kern/acpi.c; +diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c +index e9c85de12..a5b6c1dfe 100644 +--- a/grub-core/kern/efi/init.c ++++ b/grub-core/kern/efi/init.c +@@ -25,9 +25,40 @@ + #include + #include + #include ++#include + + grub_addr_t grub_modbase; + ++#define GRUB_EFI_GRUB_VARIABLE_GUID \ ++ { 0x91376aff, 0xcba6, 0x42be, \ ++ { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \ ++ } ++ ++/* Helper for grub_efi_env_init */ ++static int ++set_var (const char *name, const char *value, ++ void *whitelist __attribute__((__unused__))) ++{ ++ grub_env_set (name, value); ++ return 0; ++} ++ ++static void ++grub_efi_env_init (void) ++{ ++ grub_efi_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID; ++ struct grub_envblk envblk_s = { NULL, 0 }; ++ grub_envblk_t envblk = &envblk_s; ++ ++ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid, ++ &envblk_s.size); ++ if (!envblk_s.buf || envblk_s.size < 1) ++ return; ++ ++ grub_envblk_iterate (envblk, NULL, set_var); ++ grub_free (envblk_s.buf); ++} ++ + void + grub_efi_init (void) + { +@@ -42,10 +73,11 @@ grub_efi_init (void) + efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer, + 0, 0, 0, NULL); + ++ grub_efi_env_init (); + grub_efidisk_init (); + } + +-void (*grub_efi_net_config) (grub_efi_handle_t hnd, ++void (*grub_efi_net_config) (grub_efi_handle_t hnd, + char **device, + char **path); + +-- +2.14.3 + diff --git a/0030-DHCP-client-ID-and-UUID-options-added.patch b/0030-DHCP-client-ID-and-UUID-options-added.patch new file mode 100644 index 0000000..872555b --- /dev/null +++ b/0030-DHCP-client-ID-and-UUID-options-added.patch @@ -0,0 +1,145 @@ +From 12fb24b4d8a8f0fd7f79bc224157c290ebab31f4 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Tue, 27 Nov 2012 17:18:53 -0200 +Subject: [PATCH 030/123] DHCP client ID and UUID options added. + +--- + grub-core/net/bootp.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++----- + include/grub/net.h | 2 ++ + 2 files changed, 81 insertions(+), 8 deletions(-) + +diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c +index 189551a48..a9c8f470b 100644 +--- a/grub-core/net/bootp.c ++++ b/grub-core/net/bootp.c +@@ -25,6 +25,49 @@ + #include + #include + ++static char * ++grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), ++ const char *val __attribute__ ((unused))) ++{ ++ return NULL; ++} ++ ++static void ++set_env_limn_ro (const char *intername, const char *suffix, ++ const char *value, grub_size_t len) ++{ ++ char *varname, *varvalue; ++ char *ptr; ++ varname = grub_xasprintf ("net_%s_%s", intername, suffix); ++ if (!varname) ++ return; ++ for (ptr = varname; *ptr; ptr++) ++ if (*ptr == ':') ++ *ptr = '_'; ++ varvalue = grub_malloc (len + 1); ++ if (!varvalue) ++ { ++ grub_free (varname); ++ return; ++ } ++ ++ grub_memcpy (varvalue, value, len); ++ varvalue[len] = 0; ++ grub_env_set (varname, varvalue); ++ grub_register_variable_hook (varname, 0, grub_env_write_readonly); ++ grub_env_export (varname); ++ grub_free (varname); ++ grub_free (varvalue); ++} ++ ++static char ++hexdigit (grub_uint8_t val) ++{ ++ if (val < 10) ++ return val + '0'; ++ return val + 'a' - 10; ++} ++ + static void + parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) + { +@@ -55,6 +98,9 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) + + taglength = *ptr++; + ++ grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n", ++ tagtype, tagtype, taglength); ++ + switch (tagtype) + { + case GRUB_NET_BOOTP_NETMASK: +@@ -120,6 +166,39 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) + taglength); + break; + ++ case GRUB_NET_BOOTP_CLIENT_ID: ++ set_env_limn_ro (name, "clientid", (char *) ptr, taglength); ++ break; ++ ++ case GRUB_NET_BOOTP_CLIENT_UUID: ++ { ++ if (taglength != 17) ++ break; ++ ++ /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */ ++ ++ ptr += 1; ++ taglength -= 1; ++ ++ char *val = grub_malloc (2 * taglength + 4 + 1); ++ int i = 0; ++ int j = 0; ++ for (i = 0; i < taglength; i++) ++ { ++ val[2 * i + j] = hexdigit (ptr[i] >> 4); ++ val[2 * i + 1 + j] = hexdigit (ptr[i] & 0xf); ++ ++ if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) ++ { ++ j++; ++ val[2 * i + 1+ j] = '-'; ++ } ++ } ++ ++ set_env_limn_ro (name, "clientuuid", (char *) val, 2 * taglength + 4); ++ } ++ break; ++ + /* If you need any other options please contact GRUB + development team. */ + } +@@ -298,14 +377,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb, + } + } + +-static char +-hexdigit (grub_uint8_t val) +-{ +- if (val < 10) +- return val + '0'; +- return val + 'a' - 10; +-} +- + static grub_err_t + grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), + int argc, char **args) +diff --git a/include/grub/net.h b/include/grub/net.h +index 6ac9d72bf..96aa9fac0 100644 +--- a/include/grub/net.h ++++ b/include/grub/net.h +@@ -456,6 +456,8 @@ enum + GRUB_NET_BOOTP_DOMAIN = 0x0f, + GRUB_NET_BOOTP_ROOT_PATH = 0x11, + GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, ++ GRUB_NET_BOOTP_CLIENT_ID = 0x3d, ++ GRUB_NET_BOOTP_CLIENT_UUID = 0x61, + GRUB_NET_BOOTP_END = 0xff + }; + +-- +2.14.3 + diff --git a/0030-Message-string-cleanups.patch b/0030-Message-string-cleanups.patch deleted file mode 100644 index 51f80fd..0000000 --- a/0030-Message-string-cleanups.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 4cc90ad7d495b896e0b6b2677285ced8ce70cee1 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Fri, 7 Jun 2013 11:09:04 -0400 -Subject: [PATCH 30/90] Message string cleanups - -Make use of terminology consistent. Remove jargon. ---- - grub-core/normal/menu_text.c | 21 +++++++++------------ - 1 file changed, 9 insertions(+), 12 deletions(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index a3d1f23..64a8386 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -157,9 +157,8 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) - - if (edit) - { -- ret += grub_print_message_indented_real (_("Minimum Emacs-like screen editing is \ --supported. TAB lists completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for a \ --command-line or ESC to discard edits and return to the GRUB menu."), -+ ret += grub_print_message_indented_real (_("Press Ctrl-x or F10 to start, Ctrl-c or F2 for a \ -+command prompt or Escape to discard edits and return to the menu. Pressing Tab lists possible completions."), - STANDARD_MARGIN, STANDARD_MARGIN, - term, dry_run); - } -@@ -167,8 +166,8 @@ command-line or ESC to discard edits and return to the GRUB menu."), - { - char *msg_translated; - -- msg_translated = grub_xasprintf (_("Use the %C and %C keys to select which " -- "entry is highlighted."), -+ msg_translated = grub_xasprintf (_("Use the %C and %C keys to change the " -+ "selection."), - GRUB_UNICODE_UPARROW, - GRUB_UNICODE_DOWNARROW); - if (!msg_translated) -@@ -181,17 +180,15 @@ command-line or ESC to discard edits and return to the GRUB menu."), - if (nested) - { - ret += grub_print_message_indented_real -- (_("Press enter to boot the selected OS, " -- "`e' to edit the commands before booting " -- "or `c' for a command-line. ESC to return previous menu."), -+ (_("Press 'e' to edit the selected item, " -+ "or 'c' for a command prompt. Press Escape to return to the previous menu."), - STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); - } - else - { - ret += grub_print_message_indented_real -- (_("Press enter to boot the selected OS, " -- "`e' to edit the commands before booting " -- "or `c' for a command-line."), -+ (_("Press 'e' to edit the selected item, " -+ "or 'c' for a command prompt."), - STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); - } - } -@@ -443,7 +440,7 @@ menu_text_print_timeout (int timeout, void *dataptr) - || data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN) - msg_translated = grub_xasprintf (_("%ds"), timeout); - else -- msg_translated = grub_xasprintf (_("The highlighted entry will be executed automatically in %ds."), timeout); -+ msg_translated = grub_xasprintf (_("The selected entry will be started automatically in %ds."), timeout); - if (!msg_translated) - { - grub_print_error (); --- -2.9.3 - diff --git a/0031-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch b/0031-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch deleted file mode 100644 index 6a7ec27..0000000 --- a/0031-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch +++ /dev/null @@ -1,32 +0,0 @@ -From ee01481e906071d01649b61925eaac0348f9a9a7 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Fri, 7 Jun 2013 14:08:23 -0400 -Subject: [PATCH 31/90] Fix border spacing now that we aren't displaying it - ---- - grub-core/normal/menu_text.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 64a8386..1062d64 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -331,12 +331,12 @@ grub_menu_init_page (int nested, int edit, - int empty_lines = 1; - int version_msg = 1; - -- geo->border = 1; -- geo->first_entry_x = 1 /* margin */ + 1 /* border */; -+ geo->border = 0; -+ geo->first_entry_x = 0 /* margin */ + 0 /* border */; - geo->entry_width = grub_term_width (term) - 5; - - geo->first_entry_y = 2 /* two empty lines*/ -- + 1 /* GNU GRUB version text */ + 1 /* top border */; -+ + 0 /* GNU GRUB version text */ + 1 /* top border */; - - geo->timeout_lines = 2; - --- -2.9.3 - diff --git a/0031-trim-arp-packets-with-abnormal-size.patch b/0031-trim-arp-packets-with-abnormal-size.patch new file mode 100644 index 0000000..e504060 --- /dev/null +++ b/0031-trim-arp-packets-with-abnormal-size.patch @@ -0,0 +1,31 @@ +From a6f4624278357f853e3e8888e538eb0ef3654556 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Wed, 5 Feb 2014 09:42:42 -0200 +Subject: [PATCH 031/123] trim arp packets with abnormal size + +GRUB uses arp request to create the arp response. If the incoming packet +is foobared, GRUB needs to trim the arp response packet before sending it. +--- + grub-core/net/arp.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c +index 4b68c4151..f7c59d371 100644 +--- a/grub-core/net/arp.c ++++ b/grub-core/net/arp.c +@@ -142,6 +142,12 @@ grub_net_arp_receive (struct grub_net_buff *nb, + if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 + && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) + { ++ if ((nb->tail - nb->data) > 50) ++ { ++ grub_dprintf ("net", "arp packet with abnormal size (%ld bytes).\n", ++ nb->tail - nb->data); ++ nb->tail = nb->data + 50; ++ } + grub_net_link_level_address_t target; + struct grub_net_buff nb_reply; + struct arppkt *arp_reply; +-- +2.14.3 + diff --git a/0032-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch b/0032-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch new file mode 100644 index 0000000..5abc3c0 --- /dev/null +++ b/0032-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch @@ -0,0 +1,41 @@ +From c22139b340f1a306ad718646a4cd4bc1d4039d7b Mon Sep 17 00:00:00 2001 +From: Prarit Bhargava +Date: Wed, 12 Mar 2014 10:58:16 -0400 +Subject: [PATCH 032/123] Fix bad test on GRUB_DISABLE_SUBMENU. + +The file /etc/grub.d/10_linux does + +if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + +when it should do + +if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then + +which results in submenus in /boot/grub2/grub.cfg when +GRUB_DISABLE_SUBMENU="yes". + +Resolves: rhbz#1063414 +--- + util/grub.d/10_linux.in | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index de9044c7f..cf6331f2a 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -224,7 +224,11 @@ while [ "x$list" != "x" ] ; do + linux_root_device_thisversion=${GRUB_DEVICE} + fi + +- if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then ++ if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then ++ GRUB_DISABLE_SUBMENU="true" ++ fi ++ ++ if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then + linux_entry "${OS}" "${version}" simple \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + +-- +2.14.3 + diff --git a/0032-Use-the-correct-indentation-for-the-term-help-text.patch b/0032-Use-the-correct-indentation-for-the-term-help-text.patch deleted file mode 100644 index 168471d..0000000 --- a/0032-Use-the-correct-indentation-for-the-term-help-text.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 748c629f47f4191c66011646e010cdf5ab506b90 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Fri, 7 Jun 2013 14:08:49 -0400 -Subject: [PATCH 32/90] Use the correct indentation for the term help text - -That is consistent with the menu help text ---- - grub-core/normal/main.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index f57b750..0ce59fd 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -426,8 +426,8 @@ grub_normal_reader_init (int nested) - grub_normal_init_page (term, 1); - grub_term_setcursor (term, 1); - -- if (grub_term_width (term) > 3 + STANDARD_MARGIN + 20) -- grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term); -+ if (grub_term_width (term) > 2 * STANDARD_MARGIN + 20) -+ grub_print_message_indented (msg_formatted, STANDARD_MARGIN, STANDARD_MARGIN, term); - else - grub_print_message_indented (msg_formatted, 0, 0, term); - grub_putcode ('\n', term); --- -2.9.3 - diff --git a/0033-Add-support-for-UEFI-operating-systems-returned-by-o.patch b/0033-Add-support-for-UEFI-operating-systems-returned-by-o.patch new file mode 100644 index 0000000..94aacf9 --- /dev/null +++ b/0033-Add-support-for-UEFI-operating-systems-returned-by-o.patch @@ -0,0 +1,50 @@ +From f0daa044a90c508f8f60d23e5ef39597ec80c2cc Mon Sep 17 00:00:00 2001 +From: Matthew Garrett +Date: Wed, 12 Jun 2013 11:51:49 -0400 +Subject: [PATCH 033/123] Add support for UEFI operating systems returned by + os-prober + +os-prober returns UEFI operating systems in the form: + +path:long-name:name + +where path is the path under the EFI directory on the ESP. This is in +contrast to legacy OSes, where path is the device string. Handle this case. +--- + util/grub.d/30_os-prober.in | 21 ++++++++++++++++++--- + 1 file changed, 18 insertions(+), 3 deletions(-) + +diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in +index 515a68c7a..9b8f5968e 100644 +--- a/util/grub.d/30_os-prober.in ++++ b/util/grub.d/30_os-prober.in +@@ -328,8 +328,23 @@ EOF + EOF + ;; + *) +- # TRANSLATORS: %s is replaced by OS name. +- gettext_printf "%s is not yet supported by grub-mkconfig.\n" " ${LONGNAME}" >&2 +- ;; ++ case ${DEVICE} in ++ *.efi) ++ cat << EOF ++menuentry '$(echo "${LONGNAME}" | grub_quote)' { ++EOF ++ save_default_entry | grub_add_tab ++ cat << EOF ++ chainloader /EFI/${DEVICE} ++ boot ++} ++EOF ++ ;; ++ *) ++ echo -n " " ++ # TRANSLATORS: %s is replaced by OS name. ++ gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2 ++ ;; ++ esac + esac + done +-- +2.14.3 + diff --git a/0033-Indent-menu-entries.patch b/0033-Indent-menu-entries.patch deleted file mode 100644 index 8af01f6..0000000 --- a/0033-Indent-menu-entries.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 93092c8a33db0cb36392c9684a60c12fbc823554 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Fri, 7 Jun 2013 14:30:55 -0400 -Subject: [PATCH 33/90] Indent menu entries - ---- - grub-core/normal/menu_text.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 1062d64..ecc60f9 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -239,7 +239,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, - unicode_title[i] = ' '; - - if (data->geo.num_entries > 1) -- grub_putcode (' ', data->term); -+ for (i = 0; i < STANDARD_MARGIN; i++) -+ grub_putcode (' ', data->term); - - grub_print_ucs4_menu (unicode_title, - unicode_title + len, --- -2.9.3 - diff --git a/0034-Fix-margins.patch b/0034-Fix-margins.patch deleted file mode 100644 index f9541af..0000000 --- a/0034-Fix-margins.patch +++ /dev/null @@ -1,37 +0,0 @@ -From ee7064d8667cf51d12f2cc5ead9b428446c563ad Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Fri, 7 Jun 2013 14:59:36 -0400 -Subject: [PATCH 34/90] Fix margins - ---- - grub-core/normal/menu_text.c | 8 +++----- - 1 file changed, 3 insertions(+), 5 deletions(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index ecc60f9..0e43f2c 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -333,17 +333,15 @@ grub_menu_init_page (int nested, int edit, - int version_msg = 1; - - geo->border = 0; -- geo->first_entry_x = 0 /* margin */ + 0 /* border */; -- geo->entry_width = grub_term_width (term) - 5; -+ geo->first_entry_x = 0; /* no margin */ -+ geo->entry_width = grub_term_width (term) - 1; - -- geo->first_entry_y = 2 /* two empty lines*/ -- + 0 /* GNU GRUB version text */ + 1 /* top border */; -+ geo->first_entry_y = 3; /* three empty lines*/ - - geo->timeout_lines = 2; - - /* 3 lines for timeout message and bottom margin. 2 lines for the border. */ - geo->num_entries = grub_term_height (term) - geo->first_entry_y -- - 1 /* bottom border */ - - 1 /* empty line before info message*/ - - geo->timeout_lines /* timeout */ - - 1 /* empty final line */; --- -2.9.3 - diff --git a/0034-Migrate-PPC-from-Yaboot-to-Grub2.patch b/0034-Migrate-PPC-from-Yaboot-to-Grub2.patch new file mode 100644 index 0000000..d7d7bf0 --- /dev/null +++ b/0034-Migrate-PPC-from-Yaboot-to-Grub2.patch @@ -0,0 +1,154 @@ +From 0e433858169473aa7a042c28dd6f0d4e1adab8d7 Mon Sep 17 00:00:00 2001 +From: Mark Hamzy +Date: Wed, 28 Mar 2012 14:46:41 -0500 +Subject: [PATCH 034/123] Migrate PPC from Yaboot to Grub2 + +Add configuration support for serial terminal consoles. This will set the +maximum screen size so that text is not overwritten. +--- + Makefile.util.def | 7 +++ + util/grub.d/20_ppc_terminfo.in | 114 +++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 121 insertions(+) + create mode 100644 util/grub.d/20_ppc_terminfo.in + +diff --git a/Makefile.util.def b/Makefile.util.def +index f9caccb97..6d452da02 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -486,6 +486,13 @@ script = { + condition = COND_HOST_LINUX; + }; + ++script = { ++ name = '20_ppc_terminfo'; ++ common = util/grub.d/20_ppc_terminfo.in; ++ installdir = grubconf; ++ condition = COND_HOST_LINUX; ++}; ++ + script = { + name = '30_os-prober'; + common = util/grub.d/30_os-prober.in; +diff --git a/util/grub.d/20_ppc_terminfo.in b/util/grub.d/20_ppc_terminfo.in +new file mode 100644 +index 000000000..10d665868 +--- /dev/null ++++ b/util/grub.d/20_ppc_terminfo.in +@@ -0,0 +1,114 @@ ++#! /bin/sh ++set -e ++ ++# grub-mkconfig helper script. ++# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. ++# ++# GRUB 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. ++# ++# GRUB 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 GRUB. If not, see . ++ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++bindir=@bindir@ ++libdir=@libdir@ ++. "@datadir@/@PACKAGE@/grub-mkconfig_lib" ++ ++export TEXTDOMAIN=@PACKAGE@ ++export TEXTDOMAINDIR=@localedir@ ++ ++X=80 ++Y=24 ++TERMINAL=ofconsole ++ ++argument () { ++ opt=$1 ++ shift ++ ++ if test $# -eq 0; then ++ echo "$0: option requires an argument -- '$opt'" 1>&2 ++ exit 1 ++ fi ++ echo $1 ++} ++ ++check_terminfo () { ++ ++ while test $# -gt 0 ++ do ++ option=$1 ++ shift ++ ++ case "$option" in ++ terminfo | TERMINFO) ++ ;; ++ ++ -g) ++ NEWXY=`argument $option "$@"` ++ NEWX=`echo $NEWXY | cut -d x -f 1` ++ NEWY=`echo $NEWXY | cut -d x -f 2` ++ ++ if [ ${NEWX} -ge 80 ] ; then ++ X=${NEWX} ++ else ++ echo "Warning: ${NEWX} is less than the minimum size of 80" ++ fi ++ ++ if [ ${NEWY} -ge 24 ] ; then ++ Y=${NEWY} ++ else ++ echo "Warning: ${NEWY} is less than the minimum size of 24" ++ fi ++ ++ shift ++ ;; ++ ++ *) ++# # accept console or ofconsole ++# if [ "$option" != "console" -a "$option" != "ofconsole" ] ; then ++# echo "Error: GRUB_TERMINFO unknown console: $option" ++# exit 1 ++# fi ++# # perfer console ++# TERMINAL=console ++ # accept ofconsole ++ if [ "$option" != "ofconsole" ] ; then ++ echo "Error: GRUB_TERMINFO unknown console: $option" ++ exit 1 ++ fi ++ # perfer console ++ TERMINAL=ofconsole ++ ;; ++ esac ++ ++ done ++ ++} ++ ++if ! uname -m | grep -q ppc ; then ++ exit 0 ++fi ++ ++if [ "x${GRUB_TERMINFO}" != "x" ] ; then ++ F1=`echo ${GRUB_TERMINFO} | cut -d " " -f 1` ++ ++ if [ "${F1}" != "terminfo" ] ; then ++ echo "Error: GRUB_TERMINFO is set to \"${GRUB_TERMINFO}\" The first word should be terminfo." ++ exit 1 ++ fi ++ ++ check_terminfo ${GRUB_TERMINFO} ++fi ++ ++cat << EOF ++ terminfo -g ${X}x${Y} ${TERMINAL} ++EOF +-- +2.14.3 + diff --git a/0035-Add-fw_path-variable-revised.patch b/0035-Add-fw_path-variable-revised.patch new file mode 100644 index 0000000..91edbdd --- /dev/null +++ b/0035-Add-fw_path-variable-revised.patch @@ -0,0 +1,81 @@ +From fdc52554d998170f56ed45856082f4a3bfeb3e2a Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Wed, 19 Sep 2012 21:22:55 -0300 +Subject: [PATCH 035/123] Add fw_path variable (revised) + +This patch makes grub look for its config file on efi where the app was +found. It was originally written by Matthew Garrett, and adapted to fix the +"No modules are loaded on grub2 network boot" issue: + +https://bugzilla.redhat.com/show_bug.cgi?id=857936 +--- + grub-core/kern/main.c | 13 ++++++------- + grub-core/normal/main.c | 25 ++++++++++++++++++++++++- + 2 files changed, 30 insertions(+), 8 deletions(-) + +diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c +index 9cad0c448..8ab7794c4 100644 +--- a/grub-core/kern/main.c ++++ b/grub-core/kern/main.c +@@ -127,16 +127,15 @@ grub_set_prefix_and_root (void) + + grub_machine_get_bootlocation (&fwdevice, &fwpath); + +- if (fwdevice) ++ if (fwdevice && fwpath) + { +- char *cmdpath; ++ char *fw_path; + +- cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : ""); +- if (cmdpath) ++ fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath); ++ if (fw_path) + { +- grub_env_set ("cmdpath", cmdpath); +- grub_env_export ("cmdpath"); +- grub_free (cmdpath); ++ grub_env_set ("fw_path", fw_path); ++ grub_free (fw_path); + } + } + +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index 249e19bc7..759c475c4 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -338,7 +338,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), + /* Guess the config filename. It is necessary to make CONFIG static, + so that it won't get broken by longjmp. */ + char *config; +- const char *prefix; ++ const char *prefix, *fw_path; ++ ++ fw_path = grub_env_get ("fw_path"); ++ if (fw_path) ++ { ++ config = grub_xasprintf ("%s/grub.cfg", fw_path); ++ if (config) ++ { ++ grub_file_t file; ++ ++ file = grub_file_open (config); ++ if (file) ++ { ++ grub_file_close (file); ++ grub_enter_normal_mode (config); ++ } ++ else ++ { ++ /* Ignore all errors. */ ++ grub_errno = 0; ++ } ++ grub_free (config); ++ } ++ } + + prefix = grub_env_get ("prefix"); + if (prefix) +-- +2.14.3 + diff --git a/0035-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch b/0035-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch deleted file mode 100644 index 1d9a608..0000000 --- a/0035-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 712f456d542ec913c4a5bc13f86443f79912cbf3 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 21 Jun 2013 14:44:08 -0400 -Subject: [PATCH 35/90] Use -2 instead of -1 for our right-hand margin, so - linewrapping works (#976643). - -Signed-off-by: Peter Jones ---- - grub-core/normal/menu_text.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 0e43f2c..537d4bf 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -334,7 +334,7 @@ grub_menu_init_page (int nested, int edit, - - geo->border = 0; - geo->first_entry_x = 0; /* no margin */ -- geo->entry_width = grub_term_width (term) - 1; -+ geo->entry_width = grub_term_width (term) - 2; - - geo->first_entry_y = 3; /* three empty lines*/ - --- -2.9.3 - diff --git a/0036-Add-support-for-linuxefi.patch b/0036-Add-support-for-linuxefi.patch new file mode 100644 index 0000000..be23fed --- /dev/null +++ b/0036-Add-support-for-linuxefi.patch @@ -0,0 +1,482 @@ +From a64179016df64b72cc956fd6085ca3ed1a41baac Mon Sep 17 00:00:00 2001 +From: Matthew Garrett +Date: Tue, 10 Jul 2012 11:58:52 -0400 +Subject: [PATCH 036/123] Add support for linuxefi + +--- + grub-core/Makefile.core.def | 8 + + grub-core/kern/efi/mm.c | 32 ++++ + grub-core/loader/i386/efi/linux.c | 371 ++++++++++++++++++++++++++++++++++++++ + include/grub/efi/efi.h | 3 + + include/grub/i386/linux.h | 1 + + 5 files changed, 415 insertions(+) + create mode 100644 grub-core/loader/i386/efi/linux.c + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index f8d46342a..de8c9df66 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -1731,6 +1731,14 @@ module = { + enable = x86_64_efi; + }; + ++module = { ++ name = linuxefi; ++ efi = loader/i386/efi/linux.c; ++ efi = lib/cmdline.c; ++ enable = i386_efi; ++ enable = x86_64_efi; ++}; ++ + module = { + name = chain; + efi = loader/efi/chainloader.c; +diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c +index 20a47aaf5..efb15cc1b 100644 +--- a/grub-core/kern/efi/mm.c ++++ b/grub-core/kern/efi/mm.c +@@ -49,6 +49,38 @@ static grub_efi_uintn_t finish_desc_size; + static grub_efi_uint32_t finish_desc_version; + int grub_efi_is_finished = 0; + ++/* Allocate pages below a specified address */ ++void * ++grub_efi_allocate_pages_max (grub_efi_physical_address_t max, ++ grub_efi_uintn_t pages) ++{ ++ grub_efi_status_t status; ++ grub_efi_boot_services_t *b; ++ grub_efi_physical_address_t address = max; ++ ++ if (max > 0xffffffff) ++ return 0; ++ ++ b = grub_efi_system_table->boot_services; ++ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); ++ ++ if (status != GRUB_EFI_SUCCESS) ++ return 0; ++ ++ if (address == 0) ++ { ++ /* Uggh, the address 0 was allocated... This is too annoying, ++ so reallocate another one. */ ++ address = max; ++ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); ++ grub_efi_free_pages (0, pages); ++ if (status != GRUB_EFI_SUCCESS) ++ return 0; ++ } ++ ++ return (void *) ((grub_addr_t) address); ++} ++ + /* Allocate pages. Return the pointer to the first of allocated pages. */ + void * + grub_efi_allocate_pages (grub_efi_physical_address_t address, +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +new file mode 100644 +index 000000000..b79e6320b +--- /dev/null ++++ b/grub-core/loader/i386/efi/linux.c +@@ -0,0 +1,371 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2012 Free Software Foundation, Inc. ++ * ++ * GRUB 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. ++ * ++ * GRUB 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 GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++GRUB_MOD_LICENSE ("GPLv3+"); ++ ++static grub_dl_t my_mod; ++static int loaded; ++static void *kernel_mem; ++static grub_uint64_t kernel_size; ++static grub_uint8_t *initrd_mem; ++static grub_uint32_t handover_offset; ++struct linux_kernel_params *params; ++static char *linux_cmdline; ++ ++#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) ++ ++#define SHIM_LOCK_GUID \ ++ { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } ++ ++struct grub_efi_shim_lock ++{ ++ grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size); ++}; ++typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; ++ ++static grub_efi_boolean_t ++grub_linuxefi_secure_validate (void *data, grub_uint32_t size) ++{ ++ grub_efi_guid_t guid = SHIM_LOCK_GUID; ++ grub_efi_shim_lock_t *shim_lock; ++ ++ shim_lock = grub_efi_locate_protocol(&guid, NULL); ++ ++ if (!shim_lock) ++ return 1; ++ ++ if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) ++ return 1; ++ ++ return 0; ++} ++ ++typedef void(*handover_func)(void *, grub_efi_system_table_t *, struct linux_kernel_params *); ++ ++static grub_err_t ++grub_linuxefi_boot (void) ++{ ++ handover_func hf; ++ int offset = 0; ++ ++#ifdef __x86_64__ ++ offset = 512; ++#endif ++ ++ hf = (handover_func)((char *)kernel_mem + handover_offset + offset); ++ ++ asm volatile ("cli"); ++ ++ hf (grub_efi_image_handle, grub_efi_system_table, params); ++ ++ /* Not reached */ ++ return GRUB_ERR_NONE; ++} ++ ++static grub_err_t ++grub_linuxefi_unload (void) ++{ ++ grub_dl_unref (my_mod); ++ loaded = 0; ++ if (initrd_mem) ++ grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size)); ++ if (linux_cmdline) ++ grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1)); ++ if (kernel_mem) ++ grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); ++ if (params) ++ grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); ++ return GRUB_ERR_NONE; ++} ++ ++static grub_err_t ++grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), ++ int argc, char *argv[]) ++{ ++ grub_file_t *files = 0; ++ int i, nfiles = 0; ++ grub_size_t size = 0; ++ grub_uint8_t *ptr; ++ ++ if (argc == 0) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); ++ goto fail; ++ } ++ ++ if (!loaded) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("you need to load the kernel first")); ++ goto fail; ++ } ++ ++ files = grub_zalloc (argc * sizeof (files[0])); ++ if (!files) ++ goto fail; ++ ++ for (i = 0; i < argc; i++) ++ { ++ grub_file_filter_disable_compression (); ++ files[i] = grub_file_open (argv[i]); ++ if (! files[i]) ++ goto fail; ++ nfiles++; ++ size += ALIGN_UP (grub_file_size (files[i]), 4); ++ } ++ ++ initrd_mem = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(size)); ++ ++ if (!initrd_mem) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd")); ++ goto fail; ++ } ++ ++ params->ramdisk_size = size; ++ params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem; ++ ++ ptr = initrd_mem; ++ ++ for (i = 0; i < nfiles; i++) ++ { ++ grub_ssize_t cursize = grub_file_size (files[i]); ++ if (grub_file_read (files[i], ptr, cursize) != cursize) ++ { ++ if (!grub_errno) ++ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), ++ argv[i]); ++ goto fail; ++ } ++ ptr += cursize; ++ grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); ++ ptr += ALIGN_UP_OVERHEAD (cursize, 4); ++ } ++ ++ params->ramdisk_size = size; ++ ++ fail: ++ for (i = 0; i < nfiles; i++) ++ grub_file_close (files[i]); ++ grub_free (files); ++ ++ if (initrd_mem && grub_errno) ++ grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(size)); ++ ++ return grub_errno; ++} ++ ++static grub_err_t ++grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), ++ int argc, char *argv[]) ++{ ++ grub_file_t file = 0; ++ struct linux_kernel_header lh; ++ grub_ssize_t len, start, filelen; ++ void *kernel; ++ ++ grub_dl_ref (my_mod); ++ ++ if (argc == 0) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); ++ goto fail; ++ } ++ ++ file = grub_file_open (argv[0]); ++ if (! file) ++ goto fail; ++ ++ filelen = grub_file_size (file); ++ ++ kernel = grub_malloc(filelen); ++ ++ if (!kernel) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer")); ++ goto fail; ++ } ++ ++ if (grub_file_read (file, kernel, filelen) != filelen) ++ { ++ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), argv[0]); ++ goto fail; ++ } ++ ++ if (! grub_linuxefi_secure_validate (kernel, filelen)) ++ { ++ grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); ++ grub_free (kernel); ++ goto fail; ++ } ++ ++ grub_file_seek (file, 0); ++ ++ grub_free(kernel); ++ ++ params = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(16384)); ++ ++ if (! params) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); ++ goto fail; ++ } ++ ++ memset (params, 0, 16384); ++ ++ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) ++ { ++ if (!grub_errno) ++ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), ++ argv[0]); ++ goto fail; ++ } ++ ++ if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) ++ { ++ grub_error (GRUB_ERR_BAD_OS, N_("invalid magic number")); ++ goto fail; ++ } ++ ++ if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS) ++ { ++ grub_error (GRUB_ERR_BAD_OS, N_("too many setup sectors")); ++ goto fail; ++ } ++ ++ if (lh.version < grub_cpu_to_le16 (0x020b)) ++ { ++ grub_error (GRUB_ERR_BAD_OS, N_("kernel too old")); ++ goto fail; ++ } ++ ++ if (!lh.handover_offset) ++ { ++ grub_error (GRUB_ERR_BAD_OS, N_("kernel doesn't support EFI handover")); ++ goto fail; ++ } ++ ++ linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, ++ BYTES_TO_PAGES(lh.cmdline_size + 1)); ++ ++ if (!linux_cmdline) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline")); ++ goto fail; ++ } ++ ++ grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); ++ grub_create_loader_cmdline (argc, argv, ++ linux_cmdline + sizeof (LINUX_IMAGE) - 1, ++ lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); ++ ++ lh.cmd_line_ptr = (grub_uint32_t)(grub_uint64_t)linux_cmdline; ++ ++ handover_offset = lh.handover_offset; ++ ++ start = (lh.setup_sects + 1) * 512; ++ len = grub_file_size(file) - start; ++ ++ kernel_mem = grub_efi_allocate_pages(lh.pref_address, ++ BYTES_TO_PAGES(lh.init_size)); ++ ++ if (!kernel_mem) ++ kernel_mem = grub_efi_allocate_pages_max(0x3fffffff, ++ BYTES_TO_PAGES(lh.init_size)); ++ ++ if (!kernel_mem) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel")); ++ goto fail; ++ } ++ ++ if (grub_file_seek (file, start) == (grub_off_t) -1) ++ { ++ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), ++ argv[0]); ++ goto fail; ++ } ++ ++ if (grub_file_read (file, kernel_mem, len) != len && !grub_errno) ++ { ++ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), ++ argv[0]); ++ } ++ ++ if (grub_errno == GRUB_ERR_NONE) ++ { ++ grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); ++ loaded = 1; ++ lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; ++ } ++ ++ memcpy(params, &lh, 2 * 512); ++ ++ params->type_of_loader = 0x21; ++ ++ fail: ++ ++ if (file) ++ grub_file_close (file); ++ ++ if (grub_errno != GRUB_ERR_NONE) ++ { ++ grub_dl_unref (my_mod); ++ loaded = 0; ++ } ++ ++ if (linux_cmdline && !loaded) ++ grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1)); ++ ++ if (kernel_mem && !loaded) ++ grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); ++ ++ if (params && !loaded) ++ grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); ++ ++ return grub_errno; ++} ++ ++static grub_command_t cmd_linux, cmd_initrd; ++ ++GRUB_MOD_INIT(linuxefi) ++{ ++ cmd_linux = ++ grub_register_command ("linuxefi", grub_cmd_linux, ++ 0, N_("Load Linux.")); ++ cmd_initrd = ++ grub_register_command ("initrdefi", grub_cmd_initrd, ++ 0, N_("Load initrd.")); ++ my_mod = mod; ++} ++ ++GRUB_MOD_FINI(linuxefi) ++{ ++ grub_unregister_command (cmd_linux); ++ grub_unregister_command (cmd_initrd); ++} +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index 0e6fd86b0..9a2da0eb3 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -40,6 +40,9 @@ void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds); + void * + EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, + grub_efi_uintn_t pages); ++void * ++EXPORT_FUNC(grub_efi_allocate_pages_max) (grub_efi_physical_address_t max, ++ grub_efi_uintn_t pages); + void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, + grub_efi_uintn_t pages); + int +diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h +index da0ca3b83..fc36bdaf3 100644 +--- a/include/grub/i386/linux.h ++++ b/include/grub/i386/linux.h +@@ -139,6 +139,7 @@ struct linux_kernel_header + grub_uint64_t setup_data; + grub_uint64_t pref_address; + grub_uint32_t init_size; ++ grub_uint32_t handover_offset; + } GRUB_PACKED; + + /* Boot parameters for Linux based on 2.6.12. This is used by the setup +-- +2.14.3 + diff --git a/0036-Use-linux16-when-appropriate-880840.patch b/0036-Use-linux16-when-appropriate-880840.patch deleted file mode 100644 index c895892..0000000 --- a/0036-Use-linux16-when-appropriate-880840.patch +++ /dev/null @@ -1,52 +0,0 @@ -From aedb9655a10717fe3678a9e2fc720b55f5b0ffbc Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 28 Oct 2013 10:05:07 -0400 -Subject: [PATCH 36/90] Use linux16 when appropriate (#880840) - -The kernel group really would prefer that we use the 16 bit entry point -on x86 bios machines. - -Resolves: rhbz#880840 - -Signed-off-by: Peter Jones ---- - util/grub.d/10_linux.in | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index a3d9711..f3bf6ac 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -76,6 +76,11 @@ linux_entry () - type="$3" - args="$4" - -+ sixteenbit="" -+ case "$machine" in -+ i?86|x86_64) sixteenbit="16" ;; -+ esac -+ - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" - fi -@@ -134,7 +139,7 @@ linux_entry () - EOF - else - sed "s/^/$submenu_indentation/" << EOF -- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} -+ linux${sixteenbit} ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} - EOF - fi - if test -n "${initrd}" ; then -@@ -144,7 +149,7 @@ EOF - EOF - else - sed "s/^/$submenu_indentation/" << EOF -- initrd ${rel_dirname}/${initrd} -+ initrd${sixteenbit} ${rel_dirname}/${initrd} - EOF - fi - fi --- -2.9.3 - diff --git a/0037-Enable-pager-by-default.-985860.patch b/0037-Enable-pager-by-default.-985860.patch deleted file mode 100644 index 948b5ea..0000000 --- a/0037-Enable-pager-by-default.-985860.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0b72348759eaec7d1d488e9788e724a2d48ce3f7 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 28 Oct 2013 10:09:27 -0400 -Subject: [PATCH 37/90] Enable pager by default. (#985860) - -Signed-off-by: Peter Jones ---- - util/grub.d/00_header.in | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in -index 93a9023..858b526 100644 ---- a/util/grub.d/00_header.in -+++ b/util/grub.d/00_header.in -@@ -43,6 +43,8 @@ if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_ - if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi - - cat << EOF -+set pager=1 -+ - if [ -s \$prefix/grubenv ]; then - load_env - fi --- -2.9.3 - diff --git a/0037-Use-linuxefi-and-initrdefi-where-appropriate.patch b/0037-Use-linuxefi-and-initrdefi-where-appropriate.patch new file mode 100644 index 0000000..7991b52 --- /dev/null +++ b/0037-Use-linuxefi-and-initrdefi-where-appropriate.patch @@ -0,0 +1,50 @@ +From 5894e3bfaf055554c786b4c1a9452d4e3bb9f568 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 16 Jul 2012 18:57:11 -0400 +Subject: [PATCH 037/123] Use "linuxefi" and "initrdefi" where appropriate. + +--- + util/grub.d/10_linux.in | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index cf6331f2a..8ccf012f7 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -129,17 +129,31 @@ linux_entry () + printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" + fi + message="$(gettext_printf "Loading Linux %s ..." ${version})" +- sed "s/^/$submenu_indentation/" << EOF ++ if [ -d /sys/firmware/efi ]; then ++ sed "s/^/$submenu_indentation/" << EOF ++ echo '$(echo "$message" | grub_quote)' ++ linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} ++EOF ++ else ++ sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$message" | grub_quote)' + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} + EOF ++ fi + if test -n "${initrd}" ; then + # TRANSLATORS: ramdisk isn't identifier. Should be translated. + message="$(gettext_printf "Loading initial ramdisk ...")" +- sed "s/^/$submenu_indentation/" << EOF ++ if [ -d /sys/firmware/efi ]; then ++ sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$message" | grub_quote)' ++ initrdefi ${rel_dirname}/${initrd} ++EOF ++ else ++ sed "s/^/$submenu_indentation/" << EOF ++ echo '$message' + initrd ${rel_dirname}/${initrd} + EOF ++ fi + fi + sed "s/^/$submenu_indentation/" << EOF + } +-- +2.14.3 + diff --git a/0038-Don-t-allow-insmod-when-secure-boot-is-enabled.patch b/0038-Don-t-allow-insmod-when-secure-boot-is-enabled.patch new file mode 100644 index 0000000..4191e67 --- /dev/null +++ b/0038-Don-t-allow-insmod-when-secure-boot-is-enabled.patch @@ -0,0 +1,124 @@ +From 9d70f7f9a356d965ed48963e2ead12af8de97615 Mon Sep 17 00:00:00 2001 +From: Colin Watson +Date: Tue, 23 Oct 2012 10:40:49 -0400 +Subject: [PATCH 038/123] Don't allow insmod when secure boot is enabled. + +Hi, + +Fedora's patch to forbid insmod in UEFI Secure Boot environments is fine +as far as it goes. However, the insmod command is not the only way that +modules can be loaded. In particular, the 'normal' command, which +implements the usual GRUB menu and the fully-featured command prompt, +will implicitly load commands not currently loaded into memory. This +permits trivial Secure Boot violations by writing commands implementing +whatever you want to do and pointing $prefix at the malicious code. + +I'm currently test-building this patch (replacing your current +grub-2.00-no-insmod-on-sb.patch), but this should be more correct. It +moves the check into grub_dl_load_file. +--- + grub-core/kern/dl.c | 22 ++++++++++++++++++++++ + grub-core/kern/efi/efi.c | 28 ++++++++++++++++++++++++++++ + include/grub/efi/efi.h | 1 + + 3 files changed, 51 insertions(+) + +diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c +index e394cd96f..621070918 100644 +--- a/grub-core/kern/dl.c ++++ b/grub-core/kern/dl.c +@@ -32,12 +32,21 @@ + #include + #include + #include ++#include + + /* Platforms where modules are in a readonly area of memory. */ + #if defined(GRUB_MACHINE_QEMU) + #define GRUB_MODULES_MACHINE_READONLY + #endif + ++#ifdef GRUB_MACHINE_EMU ++#include ++#endif ++ ++#ifdef GRUB_MACHINE_EFI ++#include ++#endif ++ + + + #pragma GCC diagnostic ignored "-Wcast-align" +@@ -686,6 +695,19 @@ grub_dl_load_file (const char *filename) + void *core = 0; + grub_dl_t mod = 0; + ++#ifdef GRUB_MACHINE_EFI ++ if (grub_efi_secure_boot ()) ++ { ++#if 0 ++ /* This is an error, but grub2-mkconfig still generates a pile of ++ * insmod commands, so emitting it would be mostly just obnoxious. */ ++ grub_error (GRUB_ERR_ACCESS_DENIED, ++ "Secure Boot forbids loading module from %s", filename); ++#endif ++ return 0; ++ } ++#endif ++ + grub_boot_time ("Loading module %s", filename); + + file = grub_file_open (filename); +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index 101307fc7..08599101a 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -269,6 +269,34 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, + return NULL; + } + ++grub_efi_boolean_t ++grub_efi_secure_boot (void) ++{ ++ grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; ++ grub_size_t datasize; ++ char *secure_boot = NULL; ++ char *setup_mode = NULL; ++ grub_efi_boolean_t ret = 0; ++ ++ secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); ++ ++ if (datasize != 1 || !secure_boot) ++ goto out; ++ ++ setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); ++ ++ if (datasize != 1 || !setup_mode) ++ goto out; ++ ++ if (*secure_boot && !*setup_mode) ++ ret = 1; ++ ++ out: ++ grub_free (secure_boot); ++ grub_free (setup_mode); ++ return ret; ++} ++ + #pragma GCC diagnostic ignored "-Wcast-align" + + /* Search the mods section from the PE32/PE32+ image. This code uses +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index 9a2da0eb3..22456327e 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -76,6 +76,7 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, + const grub_efi_guid_t *guid, + void *data, + grub_size_t datasize); ++grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void); + int + EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, + const grub_efi_device_path_t *dp2); +-- +2.14.3 + diff --git a/0038-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch b/0038-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch deleted file mode 100644 index a3b66dc..0000000 --- a/0038-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 55d0f5f5fdecfab6c8439520491e08a0178bd5dc Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 28 Oct 2013 10:13:27 -0400 -Subject: [PATCH 38/90] F10 doesn't work on serial, so don't tell the user to - hit it (#987443) - -Signed-off-by: Peter Jones ---- - grub-core/normal/menu_text.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 537d4bf..452d55b 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -157,7 +157,7 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) - - if (edit) - { -- ret += grub_print_message_indented_real (_("Press Ctrl-x or F10 to start, Ctrl-c or F2 for a \ -+ ret += grub_print_message_indented_real (_("Press Ctrl-x to start, Ctrl-c for a \ - command prompt or Escape to discard edits and return to the menu. Pressing Tab lists possible completions."), - STANDARD_MARGIN, STANDARD_MARGIN, - term, dry_run); --- -2.9.3 - diff --git a/0039-Don-t-say-GNU-Linux-in-generated-menus.patch b/0039-Don-t-say-GNU-Linux-in-generated-menus.patch deleted file mode 100644 index 59486cc..0000000 --- a/0039-Don-t-say-GNU-Linux-in-generated-menus.patch +++ /dev/null @@ -1,45 +0,0 @@ -From d110064c73c1604b07cdaa3d41751074b2701142 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 14 Mar 2011 14:27:42 -0400 -Subject: [PATCH 39/90] Don't say "GNU/Linux" in generated menus. - ---- - util/grub.d/10_linux.in | 4 ++-- - util/grub.d/20_linux_xen.in | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index f3bf6ac..ef52cf3 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" - CLASS="--class gnu-linux --class gnu --class os" - - if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then -- OS=GNU/Linux -+ OS="$(sed 's, release .*$,,g' /etc/system-release)" - else -- OS="${GRUB_DISTRIBUTOR} GNU/Linux" -+ OS="${GRUB_DISTRIBUTOR}" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" - fi - -diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index c48af94..25e3c41 100644 ---- a/util/grub.d/20_linux_xen.in -+++ b/util/grub.d/20_linux_xen.in -@@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" - CLASS="--class gnu-linux --class gnu --class os --class xen" - - if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then -- OS=GNU/Linux -+ OS="$(sed 's, release .*$,,g' /etc/system-release)" - else -- OS="${GRUB_DISTRIBUTOR} GNU/Linux" -+ OS="${GRUB_DISTRIBUTOR}" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" - fi - --- -2.9.3 - diff --git a/0039-Pass-x-hex-hex-straight-through-unmolested.patch b/0039-Pass-x-hex-hex-straight-through-unmolested.patch new file mode 100644 index 0000000..6f9481f --- /dev/null +++ b/0039-Pass-x-hex-hex-straight-through-unmolested.patch @@ -0,0 +1,183 @@ +From c2a19ee447623af8765254b87ff83cbb5b8253bc Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 1 Oct 2012 13:24:37 -0400 +Subject: [PATCH 039/123] Pass "\x[[:hex:]][[:hex:]]" straight through + unmolested. + +--- + grub-core/commands/wildcard.c | 16 +++++++++++++++- + grub-core/lib/cmdline.c | 34 ++++++++++++++++++++++++++++++++-- + grub-core/script/execute.c | 43 +++++++++++++++++++++++++++++++++++++------ + 3 files changed, 84 insertions(+), 9 deletions(-) + +diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c +index 9b4e72766..02c46f9fd 100644 +--- a/grub-core/commands/wildcard.c ++++ b/grub-core/commands/wildcard.c +@@ -462,6 +462,12 @@ check_file (const char *dir, const char *basename) + return ctx.found; + } + ++static int ++is_hex(char c) ++{ ++ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); ++} ++ + static void + unescape (char *out, const char *in, const char *end) + { +@@ -470,7 +476,15 @@ unescape (char *out, const char *in, const char *end) + + for (optr = out, iptr = in; iptr < end;) + { +- if (*iptr == '\\' && iptr + 1 < end) ++ if (*iptr == '\\' && iptr + 3 < end && iptr[1] == 'x' && is_hex(iptr[2]) && is_hex(iptr[3])) ++ { ++ *optr++ = *iptr++; ++ *optr++ = *iptr++; ++ *optr++ = *iptr++; ++ *optr++ = *iptr++; ++ continue; ++ } ++ else if (*iptr == '\\' && iptr + 1 < end) + { + *optr++ = iptr[1]; + iptr += 2; +diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c +index d5e10ee87..0a5b2afb9 100644 +--- a/grub-core/lib/cmdline.c ++++ b/grub-core/lib/cmdline.c +@@ -20,6 +20,12 @@ + #include + #include + ++static int ++is_hex(char c) ++{ ++ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); ++} ++ + static unsigned int check_arg (char *c, int *has_space) + { + int space = 0; +@@ -27,7 +33,13 @@ static unsigned int check_arg (char *c, int *has_space) + + while (*c) + { +- if (*c == '\\' || *c == '\'' || *c == '"') ++ if (*c == '\\' && *(c+1) == 'x' && is_hex(*(c+2)) && is_hex(*(c+3))) ++ { ++ size += 4; ++ c += 4; ++ continue; ++ } ++ else if (*c == '\\' || *c == '\'' || *c == '"') + size++; + else if (*c == ' ') + space = 1; +@@ -85,7 +97,25 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + + while (*c) + { +- if (*c == '\\' || *c == '\'' || *c == '"') ++ if (*c == ' ') ++ { ++ *buf++ = '\\'; ++ *buf++ = 'x'; ++ *buf++ = '2'; ++ *buf++ = '0'; ++ c++; ++ continue; ++ } ++ else if (*c == '\\' && *(c+1) == 'x' && ++ is_hex(*(c+2)) && is_hex(*(c+3))) ++ { ++ *buf++ = *c++; ++ *buf++ = *c++; ++ *buf++ = *c++; ++ *buf++ = *c++; ++ continue; ++ } ++ else if (*c == '\\' || *c == '\'' || *c == '"') + *buf++ = '\\'; + + *buf++ = *c; +diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c +index ab78ca87f..cf6cd6601 100644 +--- a/grub-core/script/execute.c ++++ b/grub-core/script/execute.c +@@ -55,6 +55,12 @@ static struct grub_script_scope *scope = 0; + /* Wildcard translator for GRUB script. */ + struct grub_script_wildcard_translator *grub_wildcard_translator; + ++static int ++is_hex(char c) ++{ ++ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); ++} ++ + static char* + wildcard_escape (const char *s) + { +@@ -71,7 +77,15 @@ wildcard_escape (const char *s) + i = 0; + while ((ch = *s++)) + { +- if (ch == '*' || ch == '\\' || ch == '?') ++ if (ch == '\\' && s[0] == 'x' && is_hex(s[1]) && is_hex(s[2])) ++ { ++ p[i++] = ch; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ continue; ++ } ++ else if (ch == '*' || ch == '\\' || ch == '?') + p[i++] = '\\'; + p[i++] = ch; + } +@@ -95,7 +109,14 @@ wildcard_unescape (const char *s) + i = 0; + while ((ch = *s++)) + { +- if (ch == '\\') ++ if (ch == '\\' && s[0] == 'x' && is_hex(s[1]) && is_hex(s[2])) ++ { ++ p[i++] = '\\'; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ } ++ else if (ch == '\\') + p[i++] = *s++; + else + p[i++] = ch; +@@ -397,10 +418,20 @@ parse_string (const char *str, + switch (*ptr) + { + case '\\': +- escaped = !escaped; +- if (!escaped && put) +- *(put++) = '\\'; +- ptr++; ++ if (!escaped && put && *(ptr+1) == 'x' && is_hex(*(ptr+2)) && is_hex(*(ptr+3))) ++ { ++ *(put++) = *ptr++; ++ *(put++) = *ptr++; ++ *(put++) = *ptr++; ++ *(put++) = *ptr++; ++ } ++ else ++ { ++ escaped = !escaped; ++ if (!escaped && put) ++ *(put++) = '\\'; ++ ptr++; ++ } + break; + case '$': + if (escaped) +-- +2.14.3 + diff --git a/0040-Add-X-option-to-printf-functions.patch b/0040-Add-X-option-to-printf-functions.patch new file mode 100644 index 0000000..6e8b33d --- /dev/null +++ b/0040-Add-X-option-to-printf-functions.patch @@ -0,0 +1,58 @@ +From c482ec700b2ba4b1fabccaa5848cccae466d3a12 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Tue, 27 Nov 2012 16:58:39 -0200 +Subject: [PATCH 040/123] Add %X option to printf functions. + +--- + grub-core/kern/misc.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c +index 6bb035175..81be34424 100644 +--- a/grub-core/kern/misc.c ++++ b/grub-core/kern/misc.c +@@ -587,7 +587,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) + static inline char * + grub_lltoa (char *str, int c, unsigned long long n) + { +- unsigned base = (c == 'x') ? 16 : 10; ++ unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10; + char *p; + + if ((long long) n < 0 && c == 'd') +@@ -602,7 +602,7 @@ grub_lltoa (char *str, int c, unsigned long long n) + do + { + unsigned d = (unsigned) (n & 0xf); +- *p++ = (d > 9) ? d + 'a' - 10 : d + '0'; ++ *p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0'; + } + while (n >>= 4); + else +@@ -675,6 +675,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, + { + case 'p': + case 'x': ++ case 'X': + case 'u': + case 'd': + case 'c': +@@ -761,6 +762,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, + switch (c) + { + case 'x': ++ case 'X': + case 'u': + args->ptr[curn].type = UNSIGNED_INT + longfmt; + break; +@@ -899,6 +901,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, + c = 'x'; + /* Fall through. */ + case 'x': ++ case 'X': + case 'u': + case 'd': + { +-- +2.14.3 + diff --git a/0040-Don-t-draw-a-border-around-the-menu.patch b/0040-Don-t-draw-a-border-around-the-menu.patch deleted file mode 100644 index 4ae7d29..0000000 --- a/0040-Don-t-draw-a-border-around-the-menu.patch +++ /dev/null @@ -1,74 +0,0 @@ -From fbd9d8969c059d6e5572b1acfa42ba48bc4299e2 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Wed, 15 May 2013 16:47:33 -0400 -Subject: [PATCH 40/90] Don't draw a border around the menu - -It looks cleaner without it. ---- - grub-core/normal/menu_text.c | 43 ------------------------------------------- - 1 file changed, 43 deletions(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 452d55b..1ed2bd9 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -108,47 +108,6 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right, - grub_print_message_indented_real (msg, margin_left, margin_right, term, 0); - } - --static void --draw_border (struct grub_term_output *term, const struct grub_term_screen_geometry *geo) --{ -- int i; -- -- grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); -- -- grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1, -- geo->first_entry_y - 1 }); -- grub_putcode (GRUB_UNICODE_CORNER_UL, term); -- for (i = 0; i < geo->entry_width + 1; i++) -- grub_putcode (GRUB_UNICODE_HLINE, term); -- grub_putcode (GRUB_UNICODE_CORNER_UR, term); -- -- for (i = 0; i < geo->num_entries; i++) -- { -- grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1, -- geo->first_entry_y + i }); -- grub_putcode (GRUB_UNICODE_VLINE, term); -- grub_term_gotoxy (term, -- (struct grub_term_coordinate) { geo->first_entry_x + geo->entry_width + 1, -- geo->first_entry_y + i }); -- grub_putcode (GRUB_UNICODE_VLINE, term); -- } -- -- grub_term_gotoxy (term, -- (struct grub_term_coordinate) { geo->first_entry_x - 1, -- geo->first_entry_y - 1 + geo->num_entries + 1 }); -- grub_putcode (GRUB_UNICODE_CORNER_LL, term); -- for (i = 0; i < geo->entry_width + 1; i++) -- grub_putcode (GRUB_UNICODE_HLINE, term); -- grub_putcode (GRUB_UNICODE_CORNER_LR, term); -- -- grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); -- -- grub_term_gotoxy (term, -- (struct grub_term_coordinate) { geo->first_entry_x - 1, -- (geo->first_entry_y - 1 + geo->num_entries -- + GRUB_TERM_MARGIN + 1) }); --} -- - static int - print_message (int nested, int edit, struct grub_term_output *term, int dry_run) - { -@@ -406,8 +365,6 @@ grub_menu_init_page (int nested, int edit, - - grub_term_normal_color = grub_color_menu_normal; - grub_term_highlight_color = grub_color_menu_highlight; -- if (geo->border) -- draw_border (term, geo); - grub_term_normal_color = old_color_normal; - grub_term_highlight_color = old_color_highlight; - geo->timeout_y = geo->first_entry_y + geo->num_entries --- -2.9.3 - diff --git a/0041-Search-for-specific-config-file-for-netboot.patch b/0041-Search-for-specific-config-file-for-netboot.patch new file mode 100644 index 0000000..5fc302c --- /dev/null +++ b/0041-Search-for-specific-config-file-for-netboot.patch @@ -0,0 +1,203 @@ +From 70a8c5e075d59ec13fdee4c3868b3862a8cd8aa4 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Tue, 27 Nov 2012 17:22:07 -0200 +Subject: [PATCH 041/123] Search for specific config file for netboot + +This patch implements a search for a specific configuration when the config +file is on a remoteserver. It uses the following order: + 1) DHCP client UUID option. + 2) MAC address (in lower case hexadecimal with dash separators); + 3) IP (in upper case hexadecimal) or IPv6; + 4) The original grub.cfg file. + +This procedure is similar to what is used by pxelinux and yaboot: +http://www.syslinux.org/wiki/index.php/PXELINUX#config + +This should close the bugzilla: +https://bugzilla.redhat.com/show_bug.cgi?id=873406 +--- + grub-core/net/net.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ + grub-core/normal/main.c | 18 ++++++-- + include/grub/net.h | 3 ++ + 3 files changed, 135 insertions(+), 4 deletions(-) + +diff --git a/grub-core/net/net.c b/grub-core/net/net.c +index 10773fc34..0769bf850 100644 +--- a/grub-core/net/net.c ++++ b/grub-core/net/net.c +@@ -1735,6 +1735,124 @@ grub_net_restore_hw (void) + return GRUB_ERR_NONE; + } + ++grub_err_t ++grub_net_search_configfile (char *config) ++{ ++ grub_size_t config_len; ++ char *suffix; ++ ++ auto int search_through (grub_size_t num_tries, grub_size_t slice_size); ++ int search_through (grub_size_t num_tries, grub_size_t slice_size) ++ { ++ while (num_tries-- > 0) ++ { ++ grub_dprintf ("net", "probe %s\n", config); ++ ++ grub_file_t file; ++ file = grub_file_open (config); ++ ++ if (file) ++ { ++ grub_file_close (file); ++ grub_dprintf ("net", "found!\n"); ++ return 0; ++ } ++ else ++ { ++ if (grub_errno == GRUB_ERR_IO) ++ grub_errno = GRUB_ERR_NONE; ++ } ++ ++ if (grub_strlen (suffix) < slice_size) ++ break; ++ ++ config[grub_strlen (config) - slice_size] = '\0'; ++ } ++ ++ return 1; ++ } ++ ++ config_len = grub_strlen (config); ++ config[config_len] = '-'; ++ suffix = config + config_len + 1; ++ ++ struct grub_net_network_level_interface *inf; ++ FOR_NET_NETWORK_LEVEL_INTERFACES (inf) ++ { ++ /* By the Client UUID. */ ++ ++ char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) + ++ sizeof ("_clientuuid") + 1]; ++ grub_snprintf (client_uuid_var, sizeof (client_uuid_var), ++ "net_%s_clientuuid", inf->name); ++ ++ const char *client_uuid; ++ client_uuid = grub_env_get (client_uuid_var); ++ ++ if (client_uuid) ++ { ++ grub_strcpy (suffix, client_uuid); ++ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; ++ } ++ ++ /* By the MAC address. */ ++ ++ /* Add ethernet type */ ++ grub_strcpy (suffix, "01-"); ++ ++ grub_net_hwaddr_to_str (&inf->hwaddress, suffix + 3); ++ ++ char *ptr; ++ for (ptr = suffix; *ptr; ptr++) ++ if (*ptr == ':') ++ *ptr = '-'; ++ ++ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; ++ ++ /* By IP address */ ++ ++ switch ((&inf->address)->type) ++ { ++ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4: ++ { ++ grub_uint32_t n = grub_be_to_cpu32 ((&inf->address)->ipv4); ++ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%02X%02X%02X%02X", \ ++ ((n >> 24) & 0xff), ((n >> 16) & 0xff), \ ++ ((n >> 8) & 0xff), ((n >> 0) & 0xff)); ++ ++ if (search_through (8, 1) == 0) return GRUB_ERR_NONE; ++ break; ++ } ++ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6: ++ { ++ char buf[GRUB_NET_MAX_STR_ADDR_LEN]; ++ struct grub_net_network_level_address base; ++ base.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; ++ grub_memcpy (&base.ipv6, ((&inf->address)->ipv6), 16); ++ grub_net_addr_to_str (&base, buf); ++ ++ for (ptr = buf; *ptr; ptr++) ++ if (*ptr == ':') ++ *ptr = '-'; ++ ++ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%s", buf); ++ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; ++ break; ++ } ++ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV: ++ return grub_error (GRUB_ERR_BUG, "shouldn't reach here"); ++ default: ++ return grub_error (GRUB_ERR_BUG, ++ "unsupported address type %d", (&inf->address)->type); ++ } ++ } ++ ++ /* Remove the remaining minus sign at the end. */ ++ config[config_len] = '\0'; ++ ++ return GRUB_ERR_NONE; ++} ++ + static struct grub_preboot *fini_hnd; + + static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index 759c475c4..b2654ef62 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + #ifdef GRUB_MACHINE_IEEE1275 + #include + #endif +@@ -365,10 +366,19 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), + + prefix = grub_env_get ("prefix"); + if (prefix) +- { +- config = grub_xasprintf ("%s/grub.cfg", prefix); +- if (! config) +- goto quit; ++ { ++ grub_size_t config_len; ++ config_len = grub_strlen (prefix) + ++ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); ++ config = grub_malloc (config_len); ++ ++ if (! config) ++ goto quit; ++ ++ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); ++ ++ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) ++ grub_net_search_configfile (config); + + grub_enter_normal_mode (config); + grub_free (config); +diff --git a/include/grub/net.h b/include/grub/net.h +index 96aa9fac0..e13ae1ef5 100644 +--- a/include/grub/net.h ++++ b/include/grub/net.h +@@ -565,4 +565,7 @@ extern char *grub_net_default_server; + + #define VLANTAG_IDENTIFIER 0x8100 + ++grub_err_t ++grub_net_search_configfile (char *config); ++ + #endif /* ! GRUB_NET_HEADER */ +-- +2.14.3 + diff --git a/0041-Use-the-standard-margin-for-the-timeout-string.patch b/0041-Use-the-standard-margin-for-the-timeout-string.patch deleted file mode 100644 index e79707a..0000000 --- a/0041-Use-the-standard-margin-for-the-timeout-string.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 3aeba4760755b9b263ed4ba60dc0431352b63fe7 Mon Sep 17 00:00:00 2001 -From: William Jon McCann -Date: Fri, 7 Jun 2013 10:52:32 -0400 -Subject: [PATCH 41/90] Use the standard margin for the timeout string - -So that it aligns with the other messages ---- - grub-core/normal/menu_text.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 1ed2bd9..7681f7d 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -372,7 +372,7 @@ grub_menu_init_page (int nested, int edit, - if (bottom_message) - { - grub_term_gotoxy (term, -- (struct grub_term_coordinate) { GRUB_TERM_MARGIN, -+ (struct grub_term_coordinate) { STANDARD_MARGIN, - geo->timeout_y }); - - print_message (nested, edit, term, 0); -@@ -407,14 +407,14 @@ menu_text_print_timeout (int timeout, void *dataptr) - if (data->timeout_msg == TIMEOUT_UNKNOWN) - { - data->timeout_msg = grub_print_message_indented_real (msg_translated, -- 3, 1, data->term, 1) -+ STANDARD_MARGIN, 1, data->term, 1) - <= data->geo.timeout_lines ? TIMEOUT_NORMAL : TIMEOUT_TERSE; - if (data->timeout_msg == TIMEOUT_TERSE) - { - grub_free (msg_translated); - msg_translated = grub_xasprintf (_("%ds"), timeout); - if (grub_term_width (data->term) < 10) -- data->timeout_msg = TIMEOUT_TERSE_NO_MARGIN; -+ data->timeout_msg = STANDARD_MARGIN; - } - } - --- -2.9.3 - diff --git a/0042-Add-.eh_frame-to-list-of-relocations-stripped.patch b/0042-Add-.eh_frame-to-list-of-relocations-stripped.patch deleted file mode 100644 index 6946f20..0000000 --- a/0042-Add-.eh_frame-to-list-of-relocations-stripped.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 333159a74035a726841c6c888f43d983a40ed959 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Mon, 13 Jan 2014 21:50:59 -0500 -Subject: [PATCH 42/90] Add .eh_frame to list of relocations stripped - ---- - conf/Makefile.common | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/conf/Makefile.common b/conf/Makefile.common -index 11296b5..a476ab5 100644 ---- a/conf/Makefile.common -+++ b/conf/Makefile.common -@@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding - LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) - CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 - CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) --STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx -+STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx - - CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding - LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d --- -2.9.3 - diff --git a/0042-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch b/0042-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch new file mode 100644 index 0000000..0d219b5 --- /dev/null +++ b/0042-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch @@ -0,0 +1,251 @@ +From 8992c2812e1e914e803429314b9164a19af4398b Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Tue, 22 Jan 2013 06:31:38 +0100 +Subject: [PATCH 042/123] blscfg: add blscfg module to parse Boot Loader + Specification snippets + +http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec + +Works like this: + + insmod blscfg + bls_import + +Done! You should now have menu items for your snippets in place. + +Signed-off-by: Peter Jones +--- + grub-core/Makefile.core.def | 8 ++ + grub-core/commands/blscfg.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 209 insertions(+) + create mode 100644 grub-core/commands/blscfg.c + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index de8c9df66..e79bb0cc5 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -740,6 +740,14 @@ module = { + common = commands/blocklist.c; + }; + ++module = { ++ name = blscfg; ++ common = commands/blscfg.c; ++ enable = i386_efi; ++ enable = x86_64_efi; ++ enable = i386_pc; ++}; ++ + module = { + name = boot; + common = commands/boot.c; +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +new file mode 100644 +index 000000000..4274aca5a +--- /dev/null ++++ b/grub-core/commands/blscfg.c +@@ -0,0 +1,201 @@ ++/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/ ++ ++/* bls.c - implementation of the boot loader spec */ ++ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * ++ * GRUB 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. ++ * ++ * GRUB 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 GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++GRUB_MOD_LICENSE ("GPLv3+"); ++ ++#ifdef GRUB_MACHINE_EFI ++#define GRUB_LINUX_CMD "linuxefi" ++#define GRUB_INITRD_CMD "initrdefi" ++#define GRUB_BLS_CONFIG_PATH "/EFI/fedora/loader/entries/" ++#define GRUB_BOOT_DEVICE "($boot)" ++#else ++#define GRUB_LINUX_CMD "linux" ++#define GRUB_INITRD_CMD "initrd" ++#define GRUB_BLS_CONFIG_PATH "/loader/entries/" ++#define GRUB_BOOT_DEVICE "($root)" ++#endif ++ ++static int parse_entry ( ++ const char *filename, ++ const struct grub_dirhook_info *info __attribute__ ((unused)), ++ void *data __attribute__ ((unused))) ++{ ++ grub_size_t n; ++ char *p; ++ grub_file_t f = NULL; ++ grub_off_t sz; ++ char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL; ++ const char *args[2] = { NULL, NULL }; ++ ++ if (filename[0] == '.') ++ return 0; ++ ++ n = grub_strlen (filename); ++ if (n <= 5) ++ return 0; ++ ++ if (grub_strcmp (filename + n - 5, ".conf") != 0) ++ return 0; ++ ++ p = grub_xasprintf (GRUB_BLS_CONFIG_PATH "%s", filename); ++ ++ f = grub_file_open (p); ++ if (!f) ++ goto finish; ++ ++ sz = grub_file_size (f); ++ if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) ++ goto finish; ++ ++ for (;;) ++ { ++ char *buf; ++ ++ buf = grub_file_getline (f); ++ if (!buf) ++ break; ++ ++ if (grub_strncmp (buf, "title ", 6) == 0) ++ { ++ grub_free (title); ++ title = grub_strdup (buf + 6); ++ if (!title) ++ goto finish; ++ } ++ else if (grub_strncmp (buf, "options ", 8) == 0) ++ { ++ grub_free (options); ++ options = grub_strdup (buf + 8); ++ if (!options) ++ goto finish; ++ } ++ else if (grub_strncmp (buf, "linux ", 6) == 0) ++ { ++ grub_free (clinux); ++ clinux = grub_strdup (buf + 6); ++ if (!clinux) ++ goto finish; ++ } ++ else if (grub_strncmp (buf, "initrd ", 7) == 0) ++ { ++ grub_free (initrd); ++ initrd = grub_strdup (buf + 7); ++ if (!initrd) ++ goto finish; ++ } ++ ++ grub_free(buf); ++ } ++ ++ if (!linux) ++ { ++ grub_printf ("Skipping file %s with no 'linux' key.", p); ++ goto finish; ++ } ++ ++ args[0] = title ? title : filename; ++ ++ src = grub_xasprintf ("load_video\n" ++ "set gfx_payload=keep\n" ++ "insmod gzio\n" ++ GRUB_LINUX_CMD " %s%s%s%s\n" ++ "%s%s%s%s", ++ GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", ++ initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); ++ ++ grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0); ++ ++finish: ++ grub_free (p); ++ grub_free (title); ++ grub_free (options); ++ grub_free (clinux); ++ grub_free (initrd); ++ grub_free (src); ++ ++ if (f) ++ grub_file_close (f); ++ ++ return 0; ++} ++ ++static grub_err_t ++grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), ++ int argc __attribute__ ((unused)), ++ char **args __attribute__ ((unused))) ++{ ++ grub_fs_t fs; ++ grub_device_t dev; ++ static grub_err_t r; ++ const char *devid; ++ ++ devid = grub_env_get ("root"); ++ if (!devid) ++ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "root"); ++ ++ dev = grub_device_open (devid); ++ if (!dev) ++ return grub_errno; ++ ++ fs = grub_fs_probe (dev); ++ if (!fs) ++ { ++ r = grub_errno; ++ goto finish; ++ } ++ ++ r = fs->dir (dev, GRUB_BLS_CONFIG_PATH, parse_entry, NULL); ++ ++finish: ++ if (dev) ++ grub_device_close (dev); ++ ++ return r; ++} ++ ++static grub_extcmd_t cmd; ++ ++GRUB_MOD_INIT(bls) ++{ ++ cmd = grub_register_extcmd ("bls_import", ++ grub_cmd_bls_import, ++ 0, ++ NULL, ++ N_("Import Boot Loader Specification snippets."), ++ NULL); ++} ++ ++GRUB_MOD_FINI(bls) ++{ ++ grub_unregister_extcmd (cmd); ++} +-- +2.14.3 + diff --git a/0043-Don-t-write-messages-to-the-screen.patch b/0043-Don-t-write-messages-to-the-screen.patch new file mode 100644 index 0000000..4e78180 --- /dev/null +++ b/0043-Don-t-write-messages-to-the-screen.patch @@ -0,0 +1,181 @@ +From 3e83ff704af9a967fa55d60cc3917bc4ccd85f32 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Wed, 15 May 2013 13:30:20 -0400 +Subject: [PATCH 043/123] Don't write messages to the screen + +Writing messages to the screen before the menus or boot splash +happens so quickly it looks like something is wrong and isn't +very appealing. +--- + grub-core/boot/i386/pc/boot.S | 3 --- + grub-core/boot/i386/pc/diskboot.S | 5 ----- + grub-core/gettext/gettext.c | 25 +++++-------------------- + grub-core/kern/main.c | 5 ----- + util/grub.d/10_linux.in | 7 ------- + 5 files changed, 5 insertions(+), 40 deletions(-) + +diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S +index 2bd0b2d28..ea167fe12 100644 +--- a/grub-core/boot/i386/pc/boot.S ++++ b/grub-core/boot/i386/pc/boot.S +@@ -249,9 +249,6 @@ real_start: + /* save drive reference first thing! */ + pushw %dx + +- /* print a notification message on the screen */ +- MSG(notification_string) +- + /* set %si to the disk address packet */ + movw $disk_address_packet, %si + +diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S +index 1ee4cf5b2..c8b87ed29 100644 +--- a/grub-core/boot/i386/pc/diskboot.S ++++ b/grub-core/boot/i386/pc/diskboot.S +@@ -50,11 +50,6 @@ _start: + /* save drive reference first thing! */ + pushw %dx + +- /* print a notification message on the screen */ +- pushw %si +- MSG(notification_string) +- popw %si +- + /* this sets up for the first run through "bootloop" */ + movw $LOCAL(firstlist), %di + +diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c +index 4880cefe3..b22e1bcc9 100644 +--- a/grub-core/gettext/gettext.c ++++ b/grub-core/gettext/gettext.c +@@ -434,16 +434,12 @@ static char * + grub_gettext_env_write_lang (struct grub_env_var *var + __attribute__ ((unused)), const char *val) + { +- grub_err_t err; ++ grub_err_t __attribute__((__unused__)) err; + err = grub_gettext_init_ext (&main_context, val, grub_env_get ("locale_dir"), + grub_env_get ("prefix")); +- if (err) +- grub_print_error (); + + err = grub_gettext_init_ext (&secondary_context, val, + grub_env_get ("secondary_locale_dir"), 0); +- if (err) +- grub_print_error (); + + return grub_strdup (val); + } +@@ -451,23 +447,19 @@ grub_gettext_env_write_lang (struct grub_env_var *var + void + grub_gettext_reread_prefix (const char *val) + { +- grub_err_t err; ++ grub_err_t __attribute__((__unused__)) err; + err = grub_gettext_init_ext (&main_context, grub_env_get ("lang"), + grub_env_get ("locale_dir"), + val); +- if (err) +- grub_print_error (); + } + + static char * + read_main (struct grub_env_var *var + __attribute__ ((unused)), const char *val) + { +- grub_err_t err; ++ grub_err_t __attribute__((__unused__)) err; + err = grub_gettext_init_ext (&main_context, grub_env_get ("lang"), val, + grub_env_get ("prefix")); +- if (err) +- grub_print_error (); + return grub_strdup (val); + } + +@@ -475,12 +467,9 @@ static char * + read_secondary (struct grub_env_var *var + __attribute__ ((unused)), const char *val) + { +- grub_err_t err; ++ grub_err_t __attribute__((__unused__)) err; + err = grub_gettext_init_ext (&secondary_context, grub_env_get ("lang"), val, + 0); +- if (err) +- grub_print_error (); +- + return grub_strdup (val); + } + +@@ -500,18 +489,14 @@ grub_cmd_translate (grub_command_t cmd __attribute__ ((unused)), + GRUB_MOD_INIT (gettext) + { + const char *lang; +- grub_err_t err; ++ grub_err_t __attribute__((__unused__)) err; + + lang = grub_env_get ("lang"); + + err = grub_gettext_init_ext (&main_context, lang, grub_env_get ("locale_dir"), + grub_env_get ("prefix")); +- if (err) +- grub_print_error (); + err = grub_gettext_init_ext (&secondary_context, lang, + grub_env_get ("secondary_locale_dir"), 0); +- if (err) +- grub_print_error (); + + grub_register_variable_hook ("locale_dir", NULL, read_main); + grub_register_variable_hook ("secondary_locale_dir", NULL, read_secondary); +diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c +index 8ab7794c4..da47b18b5 100644 +--- a/grub-core/kern/main.c ++++ b/grub-core/kern/main.c +@@ -268,11 +268,6 @@ grub_main (void) + + grub_boot_time ("After machine init."); + +- /* Hello. */ +- grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); +- grub_printf ("Welcome to GRUB!\n\n"); +- grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); +- + grub_load_config (); + + grub_boot_time ("Before loading embedded modules."); +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 8ccf012f7..a3d9711d6 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -128,29 +128,22 @@ linux_entry () + fi + printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" + fi +- message="$(gettext_printf "Loading Linux %s ..." ${version})" + if [ -d /sys/firmware/efi ]; then + sed "s/^/$submenu_indentation/" << EOF +- echo '$(echo "$message" | grub_quote)' + linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} + EOF + else + sed "s/^/$submenu_indentation/" << EOF +- echo '$(echo "$message" | grub_quote)' + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} + EOF + fi + if test -n "${initrd}" ; then +- # TRANSLATORS: ramdisk isn't identifier. Should be translated. +- message="$(gettext_printf "Loading initial ramdisk ...")" + if [ -d /sys/firmware/efi ]; then + sed "s/^/$submenu_indentation/" << EOF +- echo '$(echo "$message" | grub_quote)' + initrdefi ${rel_dirname}/${initrd} + EOF + else + sed "s/^/$submenu_indentation/" << EOF +- echo '$message' + initrd ${rel_dirname}/${initrd} + EOF + fi +-- +2.14.3 + diff --git a/0043-Make-10_linux-work-with-our-changes-for-linux16-and-.patch b/0043-Make-10_linux-work-with-our-changes-for-linux16-and-.patch deleted file mode 100644 index e00cec7..0000000 --- a/0043-Make-10_linux-work-with-our-changes-for-linux16-and-.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 5fa65416bae89efb88015e72cb21c28fe3833fc8 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 14 Jan 2014 13:12:23 -0500 -Subject: [PATCH 43/90] Make 10_linux work with our changes for linux16 and - linuxefi on aarch64 - -Signed-off-by: Peter Jones ---- - util/grub.d/10_linux.in | 31 ++++++++++++++++++++++++++++--- - 1 file changed, 28 insertions(+), 3 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index ef52cf3..191aebe 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -77,8 +77,18 @@ linux_entry () - args="$4" - - sixteenbit="" -+ linuxefi="linux" -+ initrdefi="initrd" - case "$machine" in -- i?86|x86_64) sixteenbit="16" ;; -+ i?86|x86_64) -+ sixteenbit="16" -+ linuxefi="linuxefi" -+ initrdefi="initrdefi" -+ ;; -+ aarch64) -+ linuxefi="linux" -+ initrdefi="initrd" -+ ;; - esac - - if [ -z "$boot_device_id" ]; then -@@ -135,7 +145,7 @@ linux_entry () - fi - if [ -d /sys/firmware/efi ]; then - sed "s/^/$submenu_indentation/" << EOF -- linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} -+ ${linuxefi} ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} - EOF - else - sed "s/^/$submenu_indentation/" << EOF -@@ -145,7 +155,7 @@ EOF - if test -n "${initrd}" ; then - if [ -d /sys/firmware/efi ]; then - sed "s/^/$submenu_indentation/" << EOF -- initrdefi ${rel_dirname}/${initrd} -+ ${initrdefi} ${rel_dirname}/${initrd} - EOF - else - sed "s/^/$submenu_indentation/" << EOF -@@ -153,6 +163,13 @@ EOF - EOF - fi - fi -+ if test -n "${fdt}" ; then -+ message="$(gettext_printf "Loading fdt ...")" -+ sed "s/^/$submenu_indentation/" << EOF -+ echo '$(echo "$message" | grub_quote)' -+ devicetree ${rel_dirname}/${fdt} -+EOF -+ fi - sed "s/^/$submenu_indentation/" << EOF - } - EOF -@@ -215,6 +232,14 @@ while [ "x$list" != "x" ] ; do - fi - done - -+ fdt= -+ for i in "dtb-${version}" "dtb-${alt_version}"; do -+ if test -e "${dirname}/${i}/foundation-v8.dtb" ; then -+ fdt="${i}/foundation-v8.dtb" -+ break -+ fi -+ done -+ - config= - for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do - if test -e "${i}" ; then --- -2.9.3 - diff --git a/0044-Don-t-print-GNU-GRUB-header.patch b/0044-Don-t-print-GNU-GRUB-header.patch new file mode 100644 index 0000000..c3fba80 --- /dev/null +++ b/0044-Don-t-print-GNU-GRUB-header.patch @@ -0,0 +1,45 @@ +From 9bd3d2fb49a6b8e3807ce7275876fd4b416545c9 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Wed, 15 May 2013 13:53:48 -0400 +Subject: [PATCH 044/123] Don't print GNU GRUB header + +No one cares. +--- + grub-core/normal/main.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index b2654ef62..f57b7508a 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -202,15 +202,16 @@ read_config_file (const char *config) + /* Initialize the screen. */ + void + grub_normal_init_page (struct grub_term_output *term, +- int y) ++ int y __attribute__((__unused__))) + { ++ grub_term_cls (term); ++ ++#if 0 + grub_ssize_t msg_len; + int posx; + char *msg_formatted; + grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; +- +- grub_term_cls (term); + + msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION); + if (!msg_formatted) +@@ -235,6 +236,7 @@ grub_normal_init_page (struct grub_term_output *term, + grub_putcode ('\n', term); + grub_putcode ('\n', term); + grub_free (unicode_msg); ++#endif + } + + static void +-- +2.14.3 + diff --git a/0044-Don-t-print-during-fdt-loading-method.patch b/0044-Don-t-print-during-fdt-loading-method.patch deleted file mode 100644 index 273cba8..0000000 --- a/0044-Don-t-print-during-fdt-loading-method.patch +++ /dev/null @@ -1,27 +0,0 @@ -From e89fd78bb3f62064d930c82ad14cd490166d1a2c Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 14 Jan 2014 16:15:46 -0500 -Subject: [PATCH 44/90] Don't print during fdt loading method. - -Signed-off-by: Peter Jones ---- - util/grub.d/10_linux.in | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 191aebe..452a9f6 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -164,9 +164,7 @@ EOF - fi - fi - if test -n "${fdt}" ; then -- message="$(gettext_printf "Loading fdt ...")" - sed "s/^/$submenu_indentation/" << EOF -- echo '$(echo "$message" | grub_quote)' - devicetree ${rel_dirname}/${fdt} - EOF - fi --- -2.9.3 - diff --git a/0045-Don-t-add-to-highlighted-row.patch b/0045-Don-t-add-to-highlighted-row.patch new file mode 100644 index 0000000..be22c98 --- /dev/null +++ b/0045-Don-t-add-to-highlighted-row.patch @@ -0,0 +1,26 @@ +From dd2c80ddd0e5e57b33a9d06894225e629b1b8b5e Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Wed, 15 May 2013 17:49:45 -0400 +Subject: [PATCH 045/123] Don't add '*' to highlighted row + +It is already highlighted. +--- + grub-core/normal/menu_text.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index e22bb91f6..a3d1f23f6 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -242,7 +242,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, + unicode_title[i] = ' '; + + if (data->geo.num_entries > 1) +- grub_putcode (highlight ? '*' : ' ', data->term); ++ grub_putcode (' ', data->term); + + grub_print_ucs4_menu (unicode_title, + unicode_title + len, +-- +2.14.3 + diff --git a/0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch b/0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch deleted file mode 100644 index a8807eb..0000000 --- a/0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 7683e149c587abf2d35de11c39ddb0810572b2e4 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 30 Jun 2014 14:16:46 -0400 -Subject: [PATCH 45/90] Don't munge raw spaces when we're doing our cmdline - escaping (#923374) - -Signed-off-by: Peter Jones ---- - grub-core/lib/cmdline.c | 11 +---------- - 1 file changed, 1 insertion(+), 10 deletions(-) - -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 0a5b2af..970ea86 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -97,16 +97,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - while (*c) - { -- if (*c == ' ') -- { -- *buf++ = '\\'; -- *buf++ = 'x'; -- *buf++ = '2'; -- *buf++ = '0'; -- c++; -- continue; -- } -- else if (*c == '\\' && *(c+1) == 'x' && -+ if (*c == '\\' && *(c+1) == 'x' && - is_hex(*(c+2)) && is_hex(*(c+3))) - { - *buf++ = *c++; --- -2.9.3 - diff --git a/0046-Don-t-require-a-password-to-boot-entries-generated-b.patch b/0046-Don-t-require-a-password-to-boot-entries-generated-b.patch deleted file mode 100644 index b144fbf..0000000 --- a/0046-Don-t-require-a-password-to-boot-entries-generated-b.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 8a11a21d904e7e823ee6f17faedbf45a8e28044a Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 11 Feb 2014 11:14:50 -0500 -Subject: [PATCH 46/90] Don't require a password to boot entries generated by - grub-mkconfig. - -When we set a password, we just want that to mean you can't /edit/ an entry. - -Resolves: rhbz#1030176 - -Signed-off-by: Peter Jones ---- - util/grub.d/10_linux.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 452a9f6..79a747e 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -26,7 +26,7 @@ datarootdir="@datarootdir@" - export TEXTDOMAIN=@PACKAGE@ - export TEXTDOMAINDIR="@localedir@" - --CLASS="--class gnu-linux --class gnu --class os" -+CLASS="--class gnu-linux --class gnu --class os --unrestricted" - - if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then - OS="$(sed 's, release .*$,,g' /etc/system-release)" --- -2.9.3 - diff --git a/0046-Message-string-cleanups.patch b/0046-Message-string-cleanups.patch new file mode 100644 index 0000000..c111347 --- /dev/null +++ b/0046-Message-string-cleanups.patch @@ -0,0 +1,71 @@ +From 4cc90ad7d495b896e0b6b2677285ced8ce70cee1 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Fri, 7 Jun 2013 11:09:04 -0400 +Subject: [PATCH 046/123] Message string cleanups + +Make use of terminology consistent. Remove jargon. +--- + grub-core/normal/menu_text.c | 21 +++++++++------------ + 1 file changed, 9 insertions(+), 12 deletions(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index a3d1f23f6..64a83862f 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -157,9 +157,8 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) + + if (edit) + { +- ret += grub_print_message_indented_real (_("Minimum Emacs-like screen editing is \ +-supported. TAB lists completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for a \ +-command-line or ESC to discard edits and return to the GRUB menu."), ++ ret += grub_print_message_indented_real (_("Press Ctrl-x or F10 to start, Ctrl-c or F2 for a \ ++command prompt or Escape to discard edits and return to the menu. Pressing Tab lists possible completions."), + STANDARD_MARGIN, STANDARD_MARGIN, + term, dry_run); + } +@@ -167,8 +166,8 @@ command-line or ESC to discard edits and return to the GRUB menu."), + { + char *msg_translated; + +- msg_translated = grub_xasprintf (_("Use the %C and %C keys to select which " +- "entry is highlighted."), ++ msg_translated = grub_xasprintf (_("Use the %C and %C keys to change the " ++ "selection."), + GRUB_UNICODE_UPARROW, + GRUB_UNICODE_DOWNARROW); + if (!msg_translated) +@@ -181,17 +180,15 @@ command-line or ESC to discard edits and return to the GRUB menu."), + if (nested) + { + ret += grub_print_message_indented_real +- (_("Press enter to boot the selected OS, " +- "`e' to edit the commands before booting " +- "or `c' for a command-line. ESC to return previous menu."), ++ (_("Press 'e' to edit the selected item, " ++ "or 'c' for a command prompt. Press Escape to return to the previous menu."), + STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); + } + else + { + ret += grub_print_message_indented_real +- (_("Press enter to boot the selected OS, " +- "`e' to edit the commands before booting " +- "or `c' for a command-line."), ++ (_("Press 'e' to edit the selected item, " ++ "or 'c' for a command prompt."), + STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); + } + } +@@ -443,7 +440,7 @@ menu_text_print_timeout (int timeout, void *dataptr) + || data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN) + msg_translated = grub_xasprintf (_("%ds"), timeout); + else +- msg_translated = grub_xasprintf (_("The highlighted entry will be executed automatically in %ds."), timeout); ++ msg_translated = grub_xasprintf (_("The selected entry will be started automatically in %ds."), timeout); + if (!msg_translated) + { + grub_print_error (); +-- +2.14.3 + diff --git a/0047-Don-t-emit-Booting-.-message.patch b/0047-Don-t-emit-Booting-.-message.patch deleted file mode 100644 index d8cbae1..0000000 --- a/0047-Don-t-emit-Booting-.-message.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 5468ac6eef409220e59741ccf1073d92916cdddf Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 18 Feb 2014 09:37:49 -0500 -Subject: [PATCH 47/90] Don't emit "Booting ..." message. - -UI team still hates this stuff, so we're disabling it for RHEL 7. - -Resolves: rhbz#1023142 - -Signed-off-by: Peter Jones ---- - grub-core/normal/menu.c | 4 +++- - grub-core/normal/menu_entry.c | 3 --- - 2 files changed, 3 insertions(+), 4 deletions(-) - -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 2e8a7bd..004711d 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -838,12 +838,14 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) - - /* Callback invoked immediately before a menu entry is executed. */ - static void --notify_booting (grub_menu_entry_t entry, -+notify_booting (grub_menu_entry_t __attribute__((unused)) entry, - void *userdata __attribute__((unused))) - { -+#if 0 - grub_printf (" "); - grub_printf_ (N_("Booting `%s'"), entry->title); - grub_printf ("\n\n"); -+#endif - } - - /* Callback invoked when a default menu entry executed because of a timeout -diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c -index eeeee55..8349049 100644 ---- a/grub-core/normal/menu_entry.c -+++ b/grub-core/normal/menu_entry.c -@@ -1167,9 +1167,6 @@ run (struct screen *screen) - char *dummy[1] = { NULL }; - - grub_cls (); -- grub_printf (" "); -- grub_printf_ (N_("Booting a command list")); -- grub_printf ("\n\n"); - - errs_before = grub_err_printed_errors; - --- -2.9.3 - diff --git a/0047-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch b/0047-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch new file mode 100644 index 0000000..babeed7 --- /dev/null +++ b/0047-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch @@ -0,0 +1,32 @@ +From ee01481e906071d01649b61925eaac0348f9a9a7 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Fri, 7 Jun 2013 14:08:23 -0400 +Subject: [PATCH 047/123] Fix border spacing now that we aren't displaying it + +--- + grub-core/normal/menu_text.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index 64a83862f..1062d64ee 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -331,12 +331,12 @@ grub_menu_init_page (int nested, int edit, + int empty_lines = 1; + int version_msg = 1; + +- geo->border = 1; +- geo->first_entry_x = 1 /* margin */ + 1 /* border */; ++ geo->border = 0; ++ geo->first_entry_x = 0 /* margin */ + 0 /* border */; + geo->entry_width = grub_term_width (term) - 5; + + geo->first_entry_y = 2 /* two empty lines*/ +- + 1 /* GNU GRUB version text */ + 1 /* top border */; ++ + 0 /* GNU GRUB version text */ + 1 /* top border */; + + geo->timeout_lines = 2; + +-- +2.14.3 + diff --git a/0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch b/0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch deleted file mode 100644 index b4972d3..0000000 --- a/0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch +++ /dev/null @@ -1,1963 +0,0 @@ -From cce065ff19272aa908a293632a265211201d7237 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 4 Mar 2014 11:00:23 -0500 -Subject: [PATCH 48/90] Replace a lot of man pages with slightly nicer ones. - -Replace a bunch of machine generated ones with ones that look nicer. ---- - conf/Makefile.extra-dist | 1 - - configure.ac | 23 ++++++ - docs/Makefile.am | 2 - - docs/man/grub-bios-setup.h2m | 6 -- - docs/man/grub-editenv.h2m | 5 -- - docs/man/grub-emu.h2m | 6 -- - docs/man/grub-file.h2m | 2 - - docs/man/grub-fstest.h2m | 4 - - docs/man/grub-glue-efi.h2m | 4 - - docs/man/grub-install.h2m | 6 -- - docs/man/grub-kbdcomp.h2m | 10 --- - docs/man/grub-macbless.h2m | 4 - - docs/man/grub-macho2img.h2m | 4 - - docs/man/grub-menulst2cfg.h2m | 4 - - docs/man/grub-mkconfig.h2m | 4 - - docs/man/grub-mkfont.h2m | 4 - - docs/man/grub-mkimage.h2m | 6 -- - docs/man/grub-mklayout.h2m | 10 --- - docs/man/grub-mknetdir.h2m | 4 - - docs/man/grub-mkpasswd-pbkdf2.h2m | 4 - - docs/man/grub-mkrelpath.h2m | 4 - - docs/man/grub-mkrescue.h2m | 4 - - docs/man/grub-mkstandalone.h2m | 4 - - docs/man/grub-mount.h2m | 2 - - docs/man/grub-ofpathname.h2m | 4 - - docs/man/grub-pe2elf.h2m | 4 - - docs/man/grub-probe.h2m | 4 - - docs/man/grub-reboot.h2m | 5 -- - docs/man/grub-render-label.h2m | 3 - - docs/man/grub-script-check.h2m | 4 - - docs/man/grub-set-default.h2m | 5 -- - docs/man/grub-sparc64-setup.h2m | 6 -- - docs/man/grub-syslinux2cfg.h2m | 4 - - gentpl.py | 5 +- - util/grub-bios-setup.8 | 54 +++++++++++++ - util/grub-editenv.1 | 46 +++++++++++ - util/grub-file.1 | 165 ++++++++++++++++++++++++++++++++++++++ - util/grub-fstest.1 | 99 +++++++++++++++++++++++ - util/grub-glue-efi.1 | 31 +++++++ - util/grub-install.8 | 129 +++++++++++++++++++++++++++++ - util/grub-kbdcomp.1 | 19 +++++ - util/grub-macbless.1 | 22 +++++ - util/grub-menulst2cfg.1 | 12 +++ - util/grub-mkconfig.8 | 17 ++++ - util/grub-mkfont.1 | 87 ++++++++++++++++++++ - util/grub-mkimage.1 | 95 ++++++++++++++++++++++ - util/grub-mklayout.1 | 27 +++++++ - util/grub-mknetdir.1 | 12 +++ - util/grub-mkpasswd-pbkdf2.1 | 27 +++++++ - util/grub-mkrelpath.1 | 12 +++ - util/grub-mkrescue.1 | 123 ++++++++++++++++++++++++++++ - util/grub-mkstandalone.1 | 100 +++++++++++++++++++++++ - util/grub-ofpathname.8 | 12 +++ - util/grub-probe.8 | 80 ++++++++++++++++++ - util/grub-reboot.8 | 21 +++++ - util/grub-render-label.1 | 51 ++++++++++++ - util/grub-script-check.1 | 21 +++++ - util/grub-set-default.8 | 21 +++++ - util/grub-sparc64-setup.8 | 12 +++ - 59 files changed, 1319 insertions(+), 147 deletions(-) - delete mode 100644 docs/man/grub-bios-setup.h2m - delete mode 100644 docs/man/grub-editenv.h2m - delete mode 100644 docs/man/grub-emu.h2m - delete mode 100644 docs/man/grub-file.h2m - delete mode 100644 docs/man/grub-fstest.h2m - delete mode 100644 docs/man/grub-glue-efi.h2m - delete mode 100644 docs/man/grub-install.h2m - delete mode 100644 docs/man/grub-kbdcomp.h2m - delete mode 100644 docs/man/grub-macbless.h2m - delete mode 100644 docs/man/grub-macho2img.h2m - delete mode 100644 docs/man/grub-menulst2cfg.h2m - delete mode 100644 docs/man/grub-mkconfig.h2m - delete mode 100644 docs/man/grub-mkfont.h2m - delete mode 100644 docs/man/grub-mkimage.h2m - delete mode 100644 docs/man/grub-mklayout.h2m - delete mode 100644 docs/man/grub-mknetdir.h2m - delete mode 100644 docs/man/grub-mkpasswd-pbkdf2.h2m - delete mode 100644 docs/man/grub-mkrelpath.h2m - delete mode 100644 docs/man/grub-mkrescue.h2m - delete mode 100644 docs/man/grub-mkstandalone.h2m - delete mode 100644 docs/man/grub-mount.h2m - delete mode 100644 docs/man/grub-ofpathname.h2m - delete mode 100644 docs/man/grub-pe2elf.h2m - delete mode 100644 docs/man/grub-probe.h2m - delete mode 100644 docs/man/grub-reboot.h2m - delete mode 100644 docs/man/grub-render-label.h2m - delete mode 100644 docs/man/grub-script-check.h2m - delete mode 100644 docs/man/grub-set-default.h2m - delete mode 100644 docs/man/grub-sparc64-setup.h2m - delete mode 100644 docs/man/grub-syslinux2cfg.h2m - create mode 100644 util/grub-bios-setup.8 - create mode 100644 util/grub-editenv.1 - create mode 100644 util/grub-file.1 - create mode 100644 util/grub-fstest.1 - create mode 100644 util/grub-glue-efi.1 - create mode 100644 util/grub-install.8 - create mode 100644 util/grub-kbdcomp.1 - create mode 100644 util/grub-macbless.1 - create mode 100644 util/grub-menulst2cfg.1 - create mode 100644 util/grub-mkconfig.8 - create mode 100644 util/grub-mkfont.1 - create mode 100644 util/grub-mkimage.1 - create mode 100644 util/grub-mklayout.1 - create mode 100644 util/grub-mknetdir.1 - create mode 100644 util/grub-mkpasswd-pbkdf2.1 - create mode 100644 util/grub-mkrelpath.1 - create mode 100644 util/grub-mkrescue.1 - create mode 100644 util/grub-mkstandalone.1 - create mode 100644 util/grub-ofpathname.8 - create mode 100644 util/grub-probe.8 - create mode 100644 util/grub-reboot.8 - create mode 100644 util/grub-render-label.1 - create mode 100644 util/grub-script-check.1 - create mode 100644 util/grub-set-default.8 - create mode 100644 util/grub-sparc64-setup.8 - -diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index b16bd92..39eb94b 100644 ---- a/conf/Makefile.extra-dist -+++ b/conf/Makefile.extra-dist -@@ -11,7 +11,6 @@ EXTRA_DIST += unicode - EXTRA_DIST += util/import_gcry.py - EXTRA_DIST += util/import_unicode.py - --EXTRA_DIST += docs/man - EXTRA_DIST += docs/autoiso.cfg - EXTRA_DIST += docs/grub.cfg - EXTRA_DIST += docs/osdetect.cfg -diff --git a/configure.ac b/configure.ac -index ab9134c..9937a82 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -70,6 +70,29 @@ grub_TRANSFORM([grub-set-default]) - grub_TRANSFORM([grub-sparc64-setup]) - grub_TRANSFORM([grub-render-label]) - grub_TRANSFORM([grub-file]) -+grub_TRANSFORM([grub-bios-setup.3]) -+grub_TRANSFORM([grub-editenv.1]) -+grub_TRANSFORM([grub-fstest.3]) -+grub_TRANSFORM([grub-glue-efi.3]) -+grub_TRANSFORM([grub-install.1]) -+grub_TRANSFORM([grub-kbdcomp.3]) -+grub_TRANSFORM([grub-menulst2cfg.1]) -+grub_TRANSFORM([grub-mkconfig.1]) -+grub_TRANSFORM([grub-mkfont.3]) -+grub_TRANSFORM([grub-mkimage.1]) -+grub_TRANSFORM([grub-mklayout.3]) -+grub_TRANSFORM([grub-mknetdir.3]) -+grub_TRANSFORM([grub-mkpasswd-pbkdf2.3]) -+grub_TRANSFORM([grub-mkrelpath.3]) -+grub_TRANSFORM([grub-mkrescue.1]) -+grub_TRANSFORM([grub-mkstandalone.3]) -+grub_TRANSFORM([grub-ofpathname.3]) -+grub_TRANSFORM([grub-probe.3]) -+grub_TRANSFORM([grub-reboot.3]) -+grub_TRANSFORM([grub-render-label.3]) -+grub_TRANSFORM([grub-script-check.3]) -+grub_TRANSFORM([grub-set-default.1]) -+grub_TRANSFORM([grub-sparc64-setup.3]) - - # Optimization flag. Allow user to override. - if test "x$TARGET_CFLAGS" = x; then -diff --git a/docs/Makefile.am b/docs/Makefile.am -index 93eb396..ab28f19 100644 ---- a/docs/Makefile.am -+++ b/docs/Makefile.am -@@ -5,5 +5,3 @@ info_TEXINFOS = grub.texi grub-dev.texi - grub_TEXINFOS = fdl.texi - - EXTRA_DIST = font_char_metrics.png font_char_metrics.txt -- -- -diff --git a/docs/man/grub-bios-setup.h2m b/docs/man/grub-bios-setup.h2m -deleted file mode 100644 -index ac6ede3..0000000 ---- a/docs/man/grub-bios-setup.h2m -+++ /dev/null -@@ -1,6 +0,0 @@ --[NAME] --grub-bios-setup \- set up a device to boot using GRUB --[SEE ALSO] --.BR grub-install (8), --.BR grub-mkimage (1), --.BR grub-mkrescue (1) -diff --git a/docs/man/grub-editenv.h2m b/docs/man/grub-editenv.h2m -deleted file mode 100644 -index 3859d3d..0000000 ---- a/docs/man/grub-editenv.h2m -+++ /dev/null -@@ -1,5 +0,0 @@ --[NAME] --grub-editenv \- edit GRUB environment block --[SEE ALSO] --.BR grub-reboot (8), --.BR grub-set-default (8) -diff --git a/docs/man/grub-emu.h2m b/docs/man/grub-emu.h2m -deleted file mode 100644 -index ef1c000..0000000 ---- a/docs/man/grub-emu.h2m -+++ /dev/null -@@ -1,6 +0,0 @@ --[NAME] --grub-emu \- GRUB emulator --[SEE ALSO] --If you are trying to install GRUB, then you should use --.BR grub-install (8) --rather than this program. -diff --git a/docs/man/grub-file.h2m b/docs/man/grub-file.h2m -deleted file mode 100644 -index e09bb4d..0000000 ---- a/docs/man/grub-file.h2m -+++ /dev/null -@@ -1,2 +0,0 @@ --[NAME] --grub-file \- check file type -diff --git a/docs/man/grub-fstest.h2m b/docs/man/grub-fstest.h2m -deleted file mode 100644 -index 9676b15..0000000 ---- a/docs/man/grub-fstest.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-fstest \- debug tool for GRUB filesystem drivers --[SEE ALSO] --.BR grub-probe (8) -diff --git a/docs/man/grub-glue-efi.h2m b/docs/man/grub-glue-efi.h2m -deleted file mode 100644 -index c1c6ded..0000000 ---- a/docs/man/grub-glue-efi.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-glue-efi \- generate a fat binary for EFI --[DESCRIPTION] --grub-glue-efi processes ia32 and amd64 EFI images and glues them according to Apple format. -diff --git a/docs/man/grub-install.h2m b/docs/man/grub-install.h2m -deleted file mode 100644 -index 8cbbc87..0000000 ---- a/docs/man/grub-install.h2m -+++ /dev/null -@@ -1,6 +0,0 @@ --[NAME] --grub-install \- install GRUB to a device --[SEE ALSO] --.BR grub-mkconfig (8), --.BR grub-mkimage (1), --.BR grub-mkrescue (1) -diff --git a/docs/man/grub-kbdcomp.h2m b/docs/man/grub-kbdcomp.h2m -deleted file mode 100644 -index d81f915..0000000 ---- a/docs/man/grub-kbdcomp.h2m -+++ /dev/null -@@ -1,10 +0,0 @@ --[NAME] --grub-kbdcomp \- generate a GRUB keyboard layout file --[DESCRIPTION] --grub-kbdcomp processes a X keyboard layout description in --.BR keymaps (5) --format into a format that can be used by GRUB's --.B keymap --command. --[SEE ALSO] --.BR grub-mklayout (8) -diff --git a/docs/man/grub-macbless.h2m b/docs/man/grub-macbless.h2m -deleted file mode 100644 -index 0197c00..0000000 ---- a/docs/man/grub-macbless.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-macbless \- bless a mac file/directory --[SEE ALSO] --.BR grub-install (1) -diff --git a/docs/man/grub-macho2img.h2m b/docs/man/grub-macho2img.h2m -deleted file mode 100644 -index d79aaee..0000000 ---- a/docs/man/grub-macho2img.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-macho2img \- convert Mach-O to raw image --[SEE ALSO] --.BR grub-mkimage (1) -diff --git a/docs/man/grub-menulst2cfg.h2m b/docs/man/grub-menulst2cfg.h2m -deleted file mode 100644 -index c2e0055..0000000 ---- a/docs/man/grub-menulst2cfg.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-menulst2cfg \- transform legacy menu.lst into grub.cfg --[SEE ALSO] --.BR grub-mkconfig (8) -diff --git a/docs/man/grub-mkconfig.h2m b/docs/man/grub-mkconfig.h2m -deleted file mode 100644 -index 9b42f81..0000000 ---- a/docs/man/grub-mkconfig.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-mkconfig \- generate a GRUB configuration file --[SEE ALSO] --.BR grub-install (8) -diff --git a/docs/man/grub-mkfont.h2m b/docs/man/grub-mkfont.h2m -deleted file mode 100644 -index d46fe60..0000000 ---- a/docs/man/grub-mkfont.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-mkfont \- make GRUB font files --[SEE ALSO] --.BR grub-mkconfig (8) -diff --git a/docs/man/grub-mkimage.h2m b/docs/man/grub-mkimage.h2m -deleted file mode 100644 -index f0fbc2b..0000000 ---- a/docs/man/grub-mkimage.h2m -+++ /dev/null -@@ -1,6 +0,0 @@ --[NAME] --grub-mkimage \- make a bootable image of GRUB --[SEE ALSO] --.BR grub-install (8), --.BR grub-mkrescue (1), --.BR grub-mknetdir (8) -diff --git a/docs/man/grub-mklayout.h2m b/docs/man/grub-mklayout.h2m -deleted file mode 100644 -index 1e43409..0000000 ---- a/docs/man/grub-mklayout.h2m -+++ /dev/null -@@ -1,10 +0,0 @@ --[NAME] --grub-mklayout \- generate a GRUB keyboard layout file --[DESCRIPTION] --grub-mklayout processes a keyboard layout description in --.BR keymaps (5) --format into a format that can be used by GRUB's --.B keymap --command. --[SEE ALSO] --.BR grub-mkconfig (8) -diff --git a/docs/man/grub-mknetdir.h2m b/docs/man/grub-mknetdir.h2m -deleted file mode 100644 -index a2ef13e..0000000 ---- a/docs/man/grub-mknetdir.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-mknetdir \- prepare a GRUB netboot directory. --[SEE ALSO] --.BR grub-mkimage (1) -diff --git a/docs/man/grub-mkpasswd-pbkdf2.h2m b/docs/man/grub-mkpasswd-pbkdf2.h2m -deleted file mode 100644 -index 4d202f3..0000000 ---- a/docs/man/grub-mkpasswd-pbkdf2.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-mkpasswd-pbkdf2 \- generate hashed password for GRUB --[SEE ALSO] --.BR grub-mkconfig (8) -diff --git a/docs/man/grub-mkrelpath.h2m b/docs/man/grub-mkrelpath.h2m -deleted file mode 100644 -index d01f396..0000000 ---- a/docs/man/grub-mkrelpath.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-mkrelpath \- make a system path relative to its root --[SEE ALSO] --.BR grub-probe (8) -diff --git a/docs/man/grub-mkrescue.h2m b/docs/man/grub-mkrescue.h2m -deleted file mode 100644 -index a427f02..0000000 ---- a/docs/man/grub-mkrescue.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-mkrescue \- make a GRUB rescue image --[SEE ALSO] --.BR grub-mkimage (1) -diff --git a/docs/man/grub-mkstandalone.h2m b/docs/man/grub-mkstandalone.h2m -deleted file mode 100644 -index c773139..0000000 ---- a/docs/man/grub-mkstandalone.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-mkstandalone \- make a memdisk-based GRUB image --[SEE ALSO] --.BR grub-mkimage (1) -diff --git a/docs/man/grub-mount.h2m b/docs/man/grub-mount.h2m -deleted file mode 100644 -index 8d16898..0000000 ---- a/docs/man/grub-mount.h2m -+++ /dev/null -@@ -1,2 +0,0 @@ --[NAME] --grub-mount \- export GRUB filesystem with FUSE -diff --git a/docs/man/grub-ofpathname.h2m b/docs/man/grub-ofpathname.h2m -deleted file mode 100644 -index 74b43ee..0000000 ---- a/docs/man/grub-ofpathname.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-ofpathname \- find OpenBOOT path for a device --[SEE ALSO] --.BR grub-probe (8) -diff --git a/docs/man/grub-pe2elf.h2m b/docs/man/grub-pe2elf.h2m -deleted file mode 100644 -index 7ca29bd..0000000 ---- a/docs/man/grub-pe2elf.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-pe2elf \- convert PE image to ELF --[SEE ALSO] --.BR grub-mkimage (1) -diff --git a/docs/man/grub-probe.h2m b/docs/man/grub-probe.h2m -deleted file mode 100644 -index 6e1ffdc..0000000 ---- a/docs/man/grub-probe.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-probe \- probe device information for GRUB --[SEE ALSO] --.BR grub-fstest (1) -diff --git a/docs/man/grub-reboot.h2m b/docs/man/grub-reboot.h2m -deleted file mode 100644 -index e4acace..0000000 ---- a/docs/man/grub-reboot.h2m -+++ /dev/null -@@ -1,5 +0,0 @@ --[NAME] --grub-reboot \- set the default boot entry for GRUB, for the next boot only --[SEE ALSO] --.BR grub-set-default (8), --.BR grub-editenv (1) -diff --git a/docs/man/grub-render-label.h2m b/docs/man/grub-render-label.h2m -deleted file mode 100644 -index 50ae524..0000000 ---- a/docs/man/grub-render-label.h2m -+++ /dev/null -@@ -1,3 +0,0 @@ --[NAME] --grub-render-label \- generate a .disk_label for Apple Macs. -- -diff --git a/docs/man/grub-script-check.h2m b/docs/man/grub-script-check.h2m -deleted file mode 100644 -index 3653682..0000000 ---- a/docs/man/grub-script-check.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-script-check \- check grub.cfg for syntax errors --[SEE ALSO] --.BR grub-mkconfig (8) -diff --git a/docs/man/grub-set-default.h2m b/docs/man/grub-set-default.h2m -deleted file mode 100644 -index 7945001..0000000 ---- a/docs/man/grub-set-default.h2m -+++ /dev/null -@@ -1,5 +0,0 @@ --[NAME] --grub-set-default \- set the saved default boot entry for GRUB --[SEE ALSO] --.BR grub-reboot (8), --.BR grub-editenv (1) -diff --git a/docs/man/grub-sparc64-setup.h2m b/docs/man/grub-sparc64-setup.h2m -deleted file mode 100644 -index 18f803a..0000000 ---- a/docs/man/grub-sparc64-setup.h2m -+++ /dev/null -@@ -1,6 +0,0 @@ --[NAME] --grub-sparc64-setup \- set up a device to boot using GRUB --[SEE ALSO] --.BR grub-install (8), --.BR grub-mkimage (1), --.BR grub-mkrescue (1) -diff --git a/docs/man/grub-syslinux2cfg.h2m b/docs/man/grub-syslinux2cfg.h2m -deleted file mode 100644 -index ad25c8a..0000000 ---- a/docs/man/grub-syslinux2cfg.h2m -+++ /dev/null -@@ -1,4 +0,0 @@ --[NAME] --grub-syslinux2cfg \- transform syslinux config into grub.cfg --[SEE ALSO] --.BR grub-menulst2cfg (8) -diff --git a/gentpl.py b/gentpl.py -index f08bcc4..f069585 100644 ---- a/gentpl.py -+++ b/gentpl.py -@@ -800,10 +800,7 @@ def manpage(defn, adddeps): - - output("if COND_MAN_PAGES\n") - gvar_add("man_MANS", name + "." + mansection) -- rule(name + "." + mansection, name + " " + adddeps, """ --chmod a+x """ + name + """ --PATH=$(builddir):$$PATH pkgdatadir=$(builddir) $(HELP2MAN) --section=""" + mansection + """ -i $(top_srcdir)/docs/man/""" + name + """.h2m -o $@ """ + name + """ --""") -+ rule(name + "." + mansection, name + " " + adddeps, "cat $(top_srcdir)/util/" + name + "." + mansection + " | $(top_builddir)/config.status --file=$@:-") - gvar_add("CLEANFILES", name + "." + mansection) - output("endif\n") - -diff --git a/util/grub-bios-setup.8 b/util/grub-bios-setup.8 -new file mode 100644 -index 0000000..56f582b ---- /dev/null -+++ b/util/grub-bios-setup.8 -@@ -0,0 +1,54 @@ -+.TH GRUB-BIOS-SETUP 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-bios-setup\fR \(em Set up images to boot from a device. -+ -+.SH SYNOPSIS -+\fBgrub-bios-setup\fR [-a | --allow-floppy] [-b | --boot-image=\fIFILE\fR] -+.RS 17 -+[-c | --core-image=\fIFILE\fR] [-d | --directory=\fIDIR\fR] -+.RE -+.RS 17 -+[-f | --force] [-m | --device-map=\fIFILE\fR] -+.RE -+.RS 17 -+[-s | --skip-fs-probe] [-v | --verbose] \fIDEVICE\fR -+ -+.SH DESCRIPTION -+You should not normally run this program directly. Use grub-install instead. -+ -+.SH OPTIONS -+.TP -+\fB--allow-floppy\fR -+Make the device also bootable as a floppy. This option is the default for -+/dev/fdX devices. Some BIOSes will not boot images created with this option. -+ -+.TP -+\fB--boot-image\fR=\fIFILE\fR -+Use FILE as the boot image. The default value is \fBboot.img\fR. -+ -+.TP -+\fB--core-image\fR=\fIFILE\fR -+Use FILE as ther core image. The default value is \fBcore.img\fR. -+ -+.TP -+\fB--directory\fR=\fIDIR\fR -+Use GRUB files in the directory DIR. The default value is \fB/boot/grub\fR. -+ -+.TP -+\fB--force\fR -+Install even if problems are detected. -+ -+.TP -+\fB--device-map\fR=\fIFILE\fR -+Use FILE as the device map. The default value is /boot/grub/device.map . -+ -+.TP -+\fB--skip-fs-probe\fR -+Do not probe DEVICE for filesystems. -+ -+.TP -+\fB--verbose\fR -+Print verbose messages. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-editenv.1 b/util/grub-editenv.1 -new file mode 100644 -index 0000000..d28ba03 ---- /dev/null -+++ b/util/grub-editenv.1 -@@ -0,0 +1,46 @@ -+.TH GRUB-EDITENV 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-editenv\fR \(em Manage the GRUB environment block. -+ -+.SH SYNOPSIS -+\fBgrub-editenv\fR [-v | --verbose] [\fIFILE\fR] -+.RS 14 -+ -+ -+.SH DESCRIPTION -+\fBgrub-editenv\fR is a command line tool to manage GRUB's stored environment. -+ -+.SH OPTIONS -+.TP -+\fB--verbose\fR -+Print verbose messages. -+ -+.TP -+\fBFILE\fR -+.RS 7 -+File name to use for grub environment. Default is /boot/grub/grubenv . -+.RE -+ -+.SH COMMANDS -+.TP -+\fBcreate\fR -+.RS 7 -+Create a blank environment block file. -+.RE -+ -+.TP -+\fBlist\fR -+.RS 7 -+List the current variables. -+.RE -+ -+.TP -+\fBset\fR [\fINAME\fR=\fIVALUE\fR ...] -+Set variables. -+ -+.TP -+\fBunset [\fINAME\fR ...] -+Delete variables. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-file.1 b/util/grub-file.1 -new file mode 100644 -index 0000000..b29cb32 ---- /dev/null -+++ b/util/grub-file.1 -@@ -0,0 +1,165 @@ -+.TH GRUB-FILE 1 "Web Feb 26 2014" -+.SH NAME -+\fBgrub-file\fR \(em Check if FILE is of specified type. -+ -+.SH SYNOPSIS -+\fBgrub-file\fR (--is-i386-xen-pae-domu | --is-x86_64-xen-domu | -+.RS 11 -+--is-x86-xen-dom0 | --is-x86-multiboot | -+.RE -+.RS 11 -+--is-x86-multiboot2 | --is-arm-linux | --is-arm64-linux | -+.RE -+.RS 11 -+--is-ia64-linux | --is-mips-linux | --is-mipsel-linux | -+.RE -+.RS 11 -+--is-sparc64-linux | --is-powerpc-linux | --is-x86-linux | -+.RE -+.RS 11 -+--is-x86-linux32 | --is-x86-kfreebsd | --is-i386-kfreebsd | -+.RE -+.RS 11 -+--is-x86_64-kfreebsd | --is-x86-knetbsd | -+.RE -+.RS 11 -+--is-i386-knetbsd | --is-x86_64-knetbsd | --is-i386-efi | -+.RE -+.RS 11 -+--is-x86_64-efi | --is-ia64-efi | --is-arm64-efi | -+.RE -+.RS 11 -+--is-arm-efi | --is-hibernated-hiberfil | --is-x86_64-xnu | -+.RE -+.RS 11 -+--is-i386-xnu | --is-xnu-hibr | --is-x86-bios-bootsector) -+.RE -+.RS 11 -+\fIFILE\fR -+ -+.SH DESCRIPTION -+\fBgrub-file\fR is used to check if \fIFILE\fR is of a specified type. -+ -+.SH OPTIONS -+.TP -+--is-i386-xen-pae-domu -+Check if FILE can be booted as i386 PAE Xen unprivileged guest kernel -+ -+.TP -+--is-x86_64-xen-domu -+Check if FILE can be booted as x86_64 Xen unprivileged guest kernel -+ -+.TP -+--is-x86-xen-dom0 -+Check if FILE can be used as Xen x86 privileged guest kernel -+ -+.TP -+--is-x86-multiboot -+Check if FILE can be used as x86 multiboot kernel -+ -+.TP -+--is-x86-multiboot2 -+Check if FILE can be used as x86 multiboot2 kernel -+ -+.TP -+--is-arm-linux -+Check if FILE is ARM Linux -+ -+.TP -+--is-arm64-linux -+Check if FILE is ARM64 Linux -+ -+.TP -+--is-ia64-linux -+Check if FILE is IA64 Linux -+ -+.TP -+--is-mips-linux -+Check if FILE is MIPS Linux -+ -+.TP -+--is-mipsel-linux -+Check if FILE is MIPSEL Linux -+ -+.TP -+--is-sparc64-linux -+Check if FILE is SPARC64 Linux -+ -+.TP -+--is-powerpc-linux -+Check if FILE is POWERPC Linux -+ -+.TP -+--is-x86-linux -+Check if FILE is x86 Linux -+ -+.TP -+--is-x86-linux32 -+Check if FILE is x86 Linux supporting 32-bit protocol -+ -+.TP -+--is-x86-kfreebsd -+Check if FILE is x86 kFreeBSD -+ -+.TP -+--is-i386-kfreebsd -+Check if FILE is i386 kFreeBSD -+ -+.TP -+--is-x86_64-kfreebsd -+Check if FILE is x86_64 kFreeBSD -+ -+.TP -+--is-x86-knetbsd -+Check if FILE is x86 kNetBSD -+ -+.TP -+--is-i386-knetbsd -+Check if FILE is i386 kNetBSD -+ -+.TP -+--is-x86_64-knetbsd -+Check if FILE is x86_64 kNetBSD -+ -+.TP -+--is-i386-efi -+Check if FILE is i386 EFI file -+ -+.TP -+--is-x86_64-efi -+Check if FILE is x86_64 EFI file -+ -+.TP -+--is-ia64-efi -+Check if FILE is IA64 EFI file -+ -+.TP -+--is-arm64-efi -+Check if FILE is ARM64 EFI file -+ -+.TP -+--is-arm-efi -+Check if FILE is ARM EFI file -+ -+.TP -+--is-hibernated-hiberfil -+Check if FILE is hiberfil.sys in hibernated state -+ -+.TP -+--is-x86_64-xnu -+Check if FILE is x86_64 XNU (Mac OS X kernel) -+ -+.TP -+--is-i386-xnu -+Check if FILE is i386 XNU (Mac OS X kernel) -+ -+.TP -+--is-xnu-hibr -+Check if FILE is XNU (Mac OS X kernel) hibernated image -+ -+.TP -+--is-x86-bios-bootsector -+Check if FILE is BIOS bootsector -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-fstest.1 b/util/grub-fstest.1 -new file mode 100644 -index 0000000..792fa78 ---- /dev/null -+++ b/util/grub-fstest.1 -@@ -0,0 +1,99 @@ -+.TH GRUB-FSTEST 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-fstest\fR — Debug tool for GRUB's filesystem driver. -+ -+.SH SYNOPSIS -+\fBgrub-fstest\fR [-c | --diskcount=\fINUM\fR] [-C | --crypto] -+.RS 13 -+[-d | --debug=\fISTRING\fR] [-K | --zfs-key=\fIFILE\fR|\fIprompt\fR] -+.RE -+.RS 13 -+[-n | --length=\fINUM\fR] [-r | --root=\fIDEVICE_NAME\fR] -+.RE -+.RS 13 -+[-s | --skip=\fINUM\fR] [-u | --uncompress] [-v | --verbose] -+.RE -+.RS 13 -+\fIIMAGE_PATH\fR -+ -+.SH DESCRIPTION -+\fBgrub-fstest\fR is a tool for testing GRUB's filesystem drivers. You should not normally need to run this program. -+ -+.SH OPTIONS -+.TP -+\fB--diskcount\fR=\fINUM\fR -+Specify the number of input files. -+ -+.TP -+\fB--crypto\fR -+Mount cryptographic devices. -+ -+.TP -+\fB--debug\fR=\fISTRING\fR -+Set debug environment variable. -+ -+.TP -+\fB--zfs-key\fR=\fIFILE\fR|\fIprompt\fR -+Load ZFS cryptographic key. -+ -+.TP -+\fB--length\fR=\fINUM\fR -+Handle NUM bytes in output file. -+ -+.TP -+\fB--root\fR=\fIDEVICE_NAME\fR -+Set root device. -+ -+.TP -+\fB--skip\fR=\fINUM\fR -+Skip NUM bytes from output file. -+ -+.TP -+\fB--uncompress\fR -+Uncompress data. -+ -+.TP -+\fB--verbose\fR -+Print verbose messages. -+ -+.SH COMMANDS -+.TP -+\fBblocklist\fR \fIFILE\fR -+Display block list of \fIFILE\fR. -+ -+.TP -+\fBcat\fR \fIFILE\fR -+Display \fIFILE\fR on standard output. -+ -+.TP -+\fBcmp\fR \fIFILE\fR \fILOCAL\fR -+Compare \fIFILE\fR with local file \fILOCAL\fR. -+ -+.TP -+\fBcp\fR \fIFILE\fR \fILOCAL\fR -+Copy \fIFILE\fR to local file \fILOCAL\fR. -+ -+.TP -+\fBcrc\fR \fIFILE\fR -+Display the CRC-32 checksum of \fIFILE\fR. -+ -+.TP -+\fBhex\fR \fIFILE\fR -+Display contents of \fIFILE\fR in hexidecimal. -+ -+.TP -+\fBls\fR \fIPATH\fR -+List files at \fIPATH\fR. -+ -+.TP -+\fBxnu_uuid\fR \fIDEVICE\fR -+Display the XNU UUID of \fIDEVICE\fR. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-glue-efi.1 b/util/grub-glue-efi.1 -new file mode 100644 -index 0000000..72bd555 ---- /dev/null -+++ b/util/grub-glue-efi.1 -@@ -0,0 +1,31 @@ -+.TH GRUB-GLUE-EFI 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-glue-efi\fR \(em Create an Apple fat EFI binary. -+ -+.SH SYNOPSIS -+\fBgrub-glue-efi\fR <-3 | --input32=\fIFILE\fR> <-6 | --input64=\fIFILE\fR> -+.RS 15 -+<-o | --output=\fIFILE\fR> [-v | --verbose] -+ -+.SH DESCRIPTION -+\fBgrub-glue-efi\fR creates an Apple fat EFI binary from two EFI binaries. -+ -+.SH OPTIONS -+.TP -+\fB--input32\fR=\fIFILE\fR -+Read 32-bit binary from \fIFILE\fR. -+ -+.TP -+\fB--input64\fR=\fIFILE\fR -+Read 64-bit binary from \fIFILE\fR. -+ -+.TP -+\fB--output\fR=\fIFILE\fR -+Write resulting fat binary to \fIFILE\fR. -+ -+.TP -+\fB--verbose\fR -+Print verbose messages. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-install.8 b/util/grub-install.8 -new file mode 100644 -index 0000000..76272a3 ---- /dev/null -+++ b/util/grub-install.8 -@@ -0,0 +1,129 @@ -+.TH GRUB-INSTALL 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-install\fR \(em Install GRUB on a device. -+ -+.SH SYNOPSIS -+\fBgrub-install\fR [--modules=\fIMODULES\fR] [--install-modules=\fIMODULES\fR] -+.RS 14 -+[--themes=\fITHEMES\fR] [--fonts=\fIFONTS\fR] [--locales=\fILOCALES\fR] -+.RE -+.RS 14 -+[--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR]] [-d | --directory=\fIDIR\fR] -+.RE -+.RS 14 -+[--grub-mkimage=\fIFILE\fR] [--boot-directory=\fIDIR\fR] -+.RE -+.RS 14 -+[--target=\fITARGET\fR] [--grub-setup=\fIFILE\fR] -+.RE -+.RS 14 -+[--grub-mkrelpath=\fIFILE\fR] [--grub-probe=\fIFILE\fR] -+.RE -+.RS 14 -+[--allow-floppy] [--recheck] [--force] [--force-file-id] -+.RE -+.RS 14 -+[--disk-module=\fIMODULE\fR] [--no-nvram] [--removable] -+.RE -+.RS 14 -+[--bootloader-id=\fIID\fR] [--efi-directory=\fIDIR\fR] \fIINSTALL_DEVICE\fR -+ -+.SH DESCRIPTION -+\fBgrub-install\fR installs GRUB onto a device. This includes copying GRUB images into the target directory (generally \fI/boot/grub\fR), and on some platforms may also include installing GRUB onto a boot sector. -+ -+.SH OPTIONS -+.TP -+\fB--modules\fR=\fIMODULES\fR\! -+Pre-load modules specified by \fIMODULES\fR. -+ -+.TP -+\fB--install-modules\fR=\fIMODULES\fR -+Install only \fIMODULES\fR and their dependencies. The default is to install all available modules. -+ -+.TP -+\fB--themes\fR=\fITHEMES\fR -+Install \fITHEMES\fR. The default is to install the \fIstarfield\fR theme, if available. -+ -+.TP -+\fB--fonts\fR=\fIFONTS\fR -+Install \fIFONTS\fR. The default is to install the \fIunicode\fR font. -+ -+.TP -+\fB--locales\fR=\fILOCALES\fR -+Install only locales listed in \fILOCALES\fR. The default is to install all available locales. -+ -+.TP -+\fB--compress\fR=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR -+Compress GRUB files using the specified compression algorithm. -+ -+.TP -+\fB--directory\fR=\fIDIR\fR -+Use images and modules in \fIDIR\fR. -+ -+.TP -+\fB--grub-mkimage\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-mkimage\fR. The default is \fI/usr/bin/grub-mkimage\fR. -+ -+.TP -+\fB--boot-directory\fR=\fIDIR\fR -+Use \fIDIR\fR as the boot directory. The default is \fI/boot\fR. GRUB will put its files in a subdirectory of this directory named \fIgrub\fR. -+ -+.TP -+\fB--target\fR=\fITARGET\fR -+Install GRUB for \fITARGET\fR platform. The default is the platform \fBgrub-install\fR is running on. -+ -+.TP -+\fB--grub-setup\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-setup\fR. The default is \fI/usr/bin/grub-setup\fR. -+ -+.TP -+\fB--grub-mkrelpath\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-mkrelpath\fR. The default is \fI/usr/bin/grub-mkrelpath\fR. -+ -+.TP -+\fB--grub-probe\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-probe\fR. The default is \fI/usr/bin/grub-mkrelpath\fR. -+ -+.TP -+\fB--allow-floppy -+Make the device also bootable as a floppy. This option is the default for /dev/fdX devices. Some BIOSes will not boot images created with this option. -+ -+.TP -+\fB--recheck -+Delete any existing device map and create a new one if necessary. -+ -+.TP -+\fB--force -+Install even if problems are detected. -+ -+.TP -+\fB--force-file-id -+Use identifier file even if UUID is available. -+ -+.TP -+\fB--disk-module\fR=\fIMODULE\fR -+Use \fIMODULE\fR for disk access. This allows you to manually specify either \fIbiosdisk\fR or \fInative\fR disk access. This option is only available on the BIOS target platform. -+ -+.TP -+\fB--no-nvram -+Do not update the \fIboot-device\fR NVRAM variable. This option is only available on IEEE1275 target platforms. -+ -+.TP -+\fB--removable -+Treat the target device as if it is removeable. This option is only available on the EFI target platform. -+ -+.TP -+\fB--bootloader-id\fR=\fIID\fR -+Use \fIID\fR as the bootloader ID. This opption is only available on the EFI target platform. -+ -+.TP -+\fB--efi-directory\fR=\fIDIR\fR -+Use \fIDIR\fR as the EFI System Partition root. This opption is only available on the EFI ta -+rget platform. -+ -+.TP -+\fIINSTALL_DEVICE\fR -+Install GRUB to the block device \fIINSTALL_DEVICE\fR. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-kbdcomp.1 b/util/grub-kbdcomp.1 -new file mode 100644 -index 0000000..0bb969a ---- /dev/null -+++ b/util/grub-kbdcomp.1 -@@ -0,0 +1,19 @@ -+.TH GRUB-KBDCOMP 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-kbdcomp\fR \(em Generate a GRUB keyboard layout file. -+ -+.SH SYNOPSIS -+\fBgrub-kbdcomp\fR <-o | --output=\fIFILE\fR> \fICKBMAP_ARGUMENTS\fR -+ -+.SH DESCRIPTION -+\fBgrub-kbdcomp\fR processes an X keyboard layout description in -+\fBkeymaps\fR(5) format into a format that can be used by GRUB's \fBkeymap\fR -+command. -+ -+.SH OPTIONS -+.TP -+\fB--output\fR=\fIFILE\fR -+Write output to \fIFILE\fR. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-macbless.1 b/util/grub-macbless.1 -new file mode 100644 -index 0000000..41a9618 ---- /dev/null -+++ b/util/grub-macbless.1 -@@ -0,0 +1,22 @@ -+.TH GRUB-MACBLESS 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-macbless\fR \(em Mac-style bless on HFS or HFS+ -+ -+.SH SYNOPSIS -+\fBgrub-macbless\fR [-v | --verbose] [-p | --ppc] \fIFILE\fR | [-x | --x86] \fIFILE\fR -+ -+.SH OPTIONS -+.TP -+--x86 -+Bless for x86 based Macs. -+ -+.TP -+--ppc -+Bless for PPC based Macs. -+ -+.TP -+--verbose -+Print verbose messages. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-menulst2cfg.1 b/util/grub-menulst2cfg.1 -new file mode 100644 -index 0000000..91e2ef8 ---- /dev/null -+++ b/util/grub-menulst2cfg.1 -@@ -0,0 +1,12 @@ -+.TH GRUB-MENULST2CFG 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-menulst2cfg\fR \(em Convert a configuration file from GRUB 0.xx to GRUB 2.xx format. -+ -+.SH SYNOPSIS -+\fBgrub-menulst2cfg\fR [\fIINFILE\fR [\fIOUTFILE\fR]] -+ -+.SH DESCRIPTION -+\fBgrub-menulst2cfg\fR converts a configuration file from GRUB 0.xx to the current format. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 -new file mode 100644 -index 0000000..a2d1f57 ---- /dev/null -+++ b/util/grub-mkconfig.8 -@@ -0,0 +1,17 @@ -+.TH GRUB-MKCONFIG 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mkconfig\fR \(em Generate a GRUB configuration file. -+ -+.SH SYNOPSIS -+\fBgrub-mkconfig\fR [-o | --output=\fIFILE\fR] -+ -+.SH DESCRIPTION -+\fBgrub-mkconfig\fR generates a configuration file for GRUB. -+ -+.SH OPTIONS -+.TP -+\fB--output\fR=\fIFILE\fR -+Write generated output to \fIFILE\fR. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkfont.1 b/util/grub-mkfont.1 -new file mode 100644 -index 0000000..3494857 ---- /dev/null -+++ b/util/grub-mkfont.1 -@@ -0,0 +1,87 @@ -+.TH GRUB-MKFONT 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mkfont\fR \(em Convert common font file formats into the PF2 format. -+ -+.SH SYNOPSIS -+\fBgrub-mkfont\fR [--ascii-bitmaps] [-a | --force-autohint] -+.RS 13 -+[-b | --bold] [-c | --asce=\fINUM\fR] [-d | --desc=\fINUM\fR] -+.RE -+.RS 13 -+[-i | --index=\fINUM\fR] [-n | --name=\fINAME\fR] [--no-bitmap] -+.RE -+.RS 13 -+[--no-hinting] <-o | --output=\fIFILE\fR> -+.RE -+.RS 13 -+[-r | --range=\fIFROM-TO\fR[\fI,FROM-TO\fR]] [-s | --size=\fISIZE\fR] -+.RE -+.RS 13 -+[-v | --verbose] [--width-spec] \fIFONT_FILES\fR -+ -+.SH DESCRIPTION -+\fBgrub-mkfont\fR converts font files from common formats into the PF2 format used by GRUB. -+ -+.SH OPTIONS -+.TP -+--ascii-bitmaps -+Save only bitmaps for ASCII characters. -+ -+.TP -+--force-autohint -+Force generation of automatic hinting. -+ -+.TP -+--bold -+Convert font to bold. -+ -+.TP -+--asce=\fINUM\fR -+Set font ascent to \fINUM\fR. -+ -+.TP -+--desc=\fINUM\fR -+Set font descent to \fINUM\fR. -+ -+.TP -+--index=\fINUM\fR -+Select face index \fINUM\fR. -+ -+.TP -+--name=\fINAME\fR -+Set font family to \fINAME\fR. -+ -+.TP -+--no-bitmap -+Ignore bitmap strikes when loading. -+ -+.TP -+--no-hinting -+Disable hinting. -+ -+.TP -+--output=\fIFILE\fR -+Save ouptut to \fIFILE\fR. This argument is required. -+ -+.TP -+--range=\fIFROM-TO\fR\fI,FROM-TO\fR -+Set the font ranges to each pair of \fIFROM\fR,\fITO\fR. -+ -+.TP -+--size=\fISIZE\fR -+Set font size to \fISIZE\fR. -+ -+.TP -+--verbose -+Print verbose messages. -+ -+.TP -+--width-spec -+Create a width summary file. -+ -+.TP -+\fIFONT_FILES\fR -+The input files to be converted. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkimage.1 b/util/grub-mkimage.1 -new file mode 100644 -index 0000000..4dea4f5 ---- /dev/null -+++ b/util/grub-mkimage.1 -@@ -0,0 +1,95 @@ -+.TH GRUB-MKIMAGE 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mkimage\fR \(em Make a bootable GRUB image. -+ -+.SH SYNOPSIS -+\fBgrub-mkimage\fR [-c | --config=\fRFILE\fI] [-C | --compression=(\fIxz\fR,\fInone\fR,\fIauto\fR)] -+.RS 14 -+[-d | --directory=\fRDIR\fR] [-k | --pubkey=\fIFILE\fR] -+.RE -+.RS 14 -+[-m | --memdisk=\fIFILE\fR] [-n | --note] [-o | --output=\fIFILE\fR] -+.RE -+.RS 14 -+[-O | --format=\fIFORMAT\fR] [-p | --prefix=\fIDIR\fR] -+.RE -+.RS 14 -+[-v | --verbose] \fIMODULES\fR -+ -+.SH DESCRIPTION -+\fBgrub-mkimage\fI builds a bootable image of GRUB. -+ -+.SH OPTIONS -+.TP -+--config=\fIFILE\fR -+Embed \fIFILE\fR as the image's initial configuration file. -+ -+.TP -+--compression=(\fIxz\fR,\fInone\fR,\fIauto\fR) -+Use one of \fIxz\fR, \fInone\fR, or \fIauto\fR as the compression method for the core image. -+ -+.TP -+--directory=\fIDIR\fR -+Use images and modules from \fIDIR\fR. The default value is \fB/usr/lib/grub/\fR. -+ -+.TP -+--pubkey=\fIFILE\fR -+Embed the public key \fIFILE\fR for signature checking. -+ -+.TP -+--memdisk=\fIFILE\fR -+Embed the memdisk image \fIFILE\fR. If no \fB-p\fR option is also specified, this implies \fI-p (memdisk)/boot/grub\fR. -+ -+.TP -+--note -+Add a CHRP \fINOTE\fR section. This option is only valid on IEEE1275 platforms. -+ -+.TP -+--output=\fIFILE\fR -+Write the generated file to \fIFILE\fR. The default is to write to standard output. -+ -+.TP -+--format=\fIFORMAT\fR -+Generate an image in the specified \fIFORMAT\fR. Valid values are: -+.RS -+.RS 4 -+.P -+i386-coreboot, -+i386-multiboot, -+i386-pc, -+i386-pc-pxe, -+i386-efi, -+i386-ieee1275, -+i386-qemu, -+x86_64-efi, -+mipsel-yeeloong-flash, -+mipsel-fuloong2f-flash, -+mipself-loongson-elf, -+powerpc-ieee1275, -+sparc64-ieee1275-raw, -+sparc64-ieee1275-cdcore, -+sparc64-ieee1275-aout, -+ia64-efi, -+mips-arc, -+mipsel-arc, -+mipsel-qemu_mips-elf, -+mips-qemu_mips-flash, -+mipsel-qemu_mips-flash, -+mips-qemu_mips-elf -+.RE -+.RE -+ -+.TP -+--prefix=\fIDIR\fR -+Set prefix directory. The default value is \fI/boot/grub\fR. -+ -+.TP -+--verbose -+Print verbose messages. -+ -+.TP -+\fIMODULES\fR -+Include \fIMODULES\fR. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mklayout.1 b/util/grub-mklayout.1 -new file mode 100644 -index 0000000..d1bbc2e ---- /dev/null -+++ b/util/grub-mklayout.1 -@@ -0,0 +1,27 @@ -+.TH GRUB-MKLAYOUT 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mklayout\fR \(em Generate a GRUB keyboard layout file. -+ -+.SH SYNOPSIS -+\fBgrub-mklayout\fR [-i | --input=\fIFILE\fR] [-o | --output=\fIFILE\fR] -+.RS 15 -+[-v | --verbose] -+ -+.SH DESCRIPTION -+\fBgrub-mklayout\fR generates a GRUB keyboard layout description which corresponds with the Linux console layout description given as input. -+ -+.SH OPTIONS -+.TP -+--input=\fIFILE\fR -+Use \fIFILE\fR as the input. The default value is the standard input device. -+ -+.TP -+--output=\fIFILE\fR -+Use \fIFILE\fR as the output. The default value is the standard output device. -+ -+.TP -+--verbose -+Print verbose messages. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mknetdir.1 b/util/grub-mknetdir.1 -new file mode 100644 -index 0000000..fa7e8d4 ---- /dev/null -+++ b/util/grub-mknetdir.1 -@@ -0,0 +1,12 @@ -+.TH GRUB-MKNETDIR 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mknetdir\fR \(em Prepare a GRUB netboot directory. -+ -+.SH SYNOPSIS -+\fBgrub-mknetdir\fR -+ -+.SH DESCRIPTION -+\fBgrub-mknetdir\fR prepares a directory for GRUB to be netbooted from. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkpasswd-pbkdf2.1 b/util/grub-mkpasswd-pbkdf2.1 -new file mode 100644 -index 0000000..73c437c ---- /dev/null -+++ b/util/grub-mkpasswd-pbkdf2.1 -@@ -0,0 +1,27 @@ -+.TH GRUB-MKPASSWD-PBKDF2 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mkpasswd-pbkdf2\fR \(em Generate a PBKDF2 password hash. -+ -+.SH SYNOPSIS -+\fBgrub-mkpasswd-pbkdf2\fR [-c | --iteration-count=\fINUM\fR] [-l | --buflen=\fINUM\fR] -+.RS 22 -+[-s | --salt=\fINUM\fR] -+ -+.SH DESCRIPTION -+\fBgrub-mkpasswd-pbkdf2\fR generates a PBKDF2 password string suitable for use in a GRUB configuration file. -+ -+.SH OPTIONS -+.TP -+--iteration-count=\fINUM\fR -+Number of PBKDF2 iterations. -+ -+.TP -+--buflen=\fINUM\fR -+Length of generated hash. -+ -+.TP -+--salt=\fINUM\fR -+Length of salt to use. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkrelpath.1 b/util/grub-mkrelpath.1 -new file mode 100644 -index 0000000..85f1113 ---- /dev/null -+++ b/util/grub-mkrelpath.1 -@@ -0,0 +1,12 @@ -+.TH GRUB-MKRELPATH 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mkrelpath\fR \(em Generate a relative GRUB path given an OS path. -+ -+.SH SYNOPSIS -+\fBgrub-mkrelpath\fR \fIFILE\fR -+ -+.SH DESCRIPTION -+\fBgrub-mkrelpath\fR takes an OS filesystem path for \fIFILE\fR and returns a relative path suitable for use in a GRUB configuration file. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkrescue.1 b/util/grub-mkrescue.1 -new file mode 100644 -index 0000000..4ed9fc7 ---- /dev/null -+++ b/util/grub-mkrescue.1 -@@ -0,0 +1,123 @@ -+.TH GRUB-MKRESCUE 3 "Wed Feb 26 2014" -+.SH NAME -+grub-mkrescue \(em Generate a GRUB rescue image using GNU Xorriso. -+ -+.SH SYNOPSIS -+\fBgrub-mkrescue\fR [-o | --output=\fIFILE\fR] [--modules=\fIMODULES\fR] -+.RS 15 -+[--install-modules=\fIMODULES\fR] [--themes=\fITHEMES\fR] -+.RE -+.RS 15 -+[--fonts=\fIFONTS\fR] [--locales=\fILOCALES\fR] -+.RE -+.RS 15 -+[--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR]] [-d | --directory=\fIDIR\fR] -+.RE -+.RS 15 -+[--grub-mkimage=\fIFILE\fR] [--rom-directory=\fIDIR\fR] -+.RE -+.RS 15 -+[--xorriso=\fIFILE\fR] [--grub-glue-efi=\fIFILE\fR] -+.RE -+.RS 15 -+[--grub-render-label=\fIFILE\fR] [--label-font=\fIFILE\fR] -+.RE -+.RS 15 -+[--label-color=\fICOLOR\fR] [--label-bgcolor=\fIFILE\fR] -+.RE -+.RS 15 -+[--product-name=\fISTRING\fR] [--product-version=\fISTRING\fR] -+.RE -+.RS 15 -+[--sparc-boot] [--arcs-boot] -+ -+.SH DESCRIPTION -+\fBgrub-mkrescue\fR can be used to generate a rescue image with the GRUB bootloader. -+ -+.SH OPTIONS -+.TP -+\fB--output\fR=\fIFILE\fR -+Write the generated file to \fIFILE\fR. The default is to write to standard output. -+ -+.TP -+\fB--modules\fR=\fIMODULES\fR -+Pre-load modules specified by \fIMODULES\fR. -+ -+.TP -+\fB--install-modules\fR=\fIMODULES\fR -+Install only \fIMODULES\fR and their dependencies. The default is to install all available modules. -+ -+.TP -+\fB--themes\fR=\fITHEMES\fR -+Install \fITHEMES\fR. The default is to install the \fIstarfield\fR theme, if available. -+ -+.TP -+\fB--fonts\fR=\fIFONTS\fR -+Install \fIFONTS\fR. The default is to install the \fIunicode\fR font. -+ -+.TP -+\fB--locales\fR=\fILOCALES\fR -+Install only locales listed in \fILOCALES\fR. The default is to install all available locales. -+ -+.TP -+\fB--compress\fR[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR] -+Compress GRUB files using the specified compression algorithm. -+ -+.TP -+\fB--directory\fR=\fIDIR\fR -+Use images and modules in \fIDIR\fR. -+ -+.TP -+\fB--grub-mkimage\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-mkimage\fR(1). The default is \fI/usr/bin/grub-mkimage\fR. -+ -+.TP -+\fB--rom-directory\fR=\fIDIR\fR -+Save ROM images in \fIDIR\fR. -+ -+.TP -+\fB--xorriso\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBxorriso\fI. -+ -+.TP -+\fB--grub-glue-efi\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-glue-efi\fR(3). -+ -+.TP -+\fB--grub-render-label\fR=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-render-label\fR(3). -+ -+.TP -+\fB--label-font\fR=\fIFILE\fR -+Use \fIFILE\fR as the font file for generated labels. -+ -+.TP -+\fB--label-color\fR=\fICOLOR\fR -+Use \fICOLOR\fI as the color for generated labels. -+ -+.TP -+\fB--label-bgcolor\fR=\fICOLOR\fR -+Use \fICOLOR\fR as the background color for generated labels. -+ -+.TP -+\fB--product-name\fR=\fISTRING\fR -+Use \fISTRING\fR as the product name in generated labels. -+ -+.TP -+\fB--product-version\fR=\fISTRING\fR -+Use \fISTRING\fR as the product version in generated labels. -+ -+.TP -+\fB--sparc-boot\fR -+Enable booting the SPARC platform. This disables HFS+, APM, ARCS, and "boot as disk image" on the \fIi386-pc\fR target platform. -+ -+.TP -+\fB--arcs-boot\fR -+Enable ARCS booting. This is typically for big-endian MIPS machines, and disables HFS+, APM, sparc64, and "boot as disk image" on the \fIi386-pc\fR target platform. -+ -+.TP -+\fB--\fR -+All options after a \fB--\fR will be passed directly to xorriso's command line when generating the image. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkstandalone.1 b/util/grub-mkstandalone.1 -new file mode 100644 -index 0000000..ba2d2bd ---- /dev/null -+++ b/util/grub-mkstandalone.1 -@@ -0,0 +1,100 @@ -+.TH GRUB-MKSTANDALONE 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-mkstandalone\fR \(em Generate a standalone image in the selected format. -+ -+.SH SYNOPSIS -+\fBgrub-mkstandalone\fR [-o | --output=\fIFILE\fR] [-O | --format=\fIFORMAT\fR] -+.RS 19 -+[-C | --compression=(\fIxz\fR|\fInone\fR|\fIauto\fR)] -+.RE -+.RS 19 -+[--modules=\fIMODULES\fR] [--install-modules=\fIMODULES\fR] -+.RE -+.RS 19 -+[--themes=\fITHEMES\fR] [--fonts=\fIFONTS\fR] -+.RE -+.RS 19 -+[--locales=\fILOCALES\fR] [--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR]] -+.RE -+.RS 19 -+[-d | --directory=\fIDIR\fR] [--grub-mkimage=\fIFILE\fR] -+.RE -+.RS 19 -+\fISOURCE...\fR -+ -+.SH DESCRIPTION -+ -+.SH OPTIONS -+.TP -+--output=\fIFILE\fR -+Write the generated file to \fIFILE\fR. The default is to write to standard output. -+ -+.TP -+--format=\fIFORMAT\fR -+Generate an image in the specified \fIFORMAT\fR. Valid values are: -+.RS -+.RS 4 -+.P -+i386-coreboot, -+i386-multiboot, -+i386-pc, -+i386-pc-pxe, -+i386-efi, -+i386-ieee1275, -+i386-qemu, -+x86_64-efi, -+mipsel-yeeloong-flash, -+mipsel-fuloong2f-flash, -+mipself-loongson-elf, -+powerpc-ieee1275, -+sparc64-ieee1275-raw, -+sparc64-ieee1275-cdcore, -+sparc64-ieee1275-aout, -+ia64-efi, -+mips-arc, -+mipsel-arc, -+mipsel-qemu_mips-elf, -+mips-qemu_mips-flash, -+mipsel-qemu_mips-flash, -+mips-qemu_mips-elf -+.RE -+.RE -+ -+.TP -+--compression=(\fIxz\fR|\fInone\fR|\fIauto\fR) -+Use one of \fIxz\fR, \fInone\fR, or \fIauto\fR as the compression method for the core image. -+ -+.TP -+--modules=\fIMODULES\fR -+Pre-load modules specified by \fIMODULES\fR. -+ -+.TP -+--install-modules=\fIMODULES\fR -+Install only \fIMODULES\fR and their dependencies. The default is to install all available modules. -+ -+.TP -+--themes=\fITHEMES\fR -+Install \fITHEMES\fR. The default is to install the \fIstarfield\fR theme, if available. -+ -+.TP -+--fonts=\fIFONTS\fR -+Install \fIFONTS\fR. The default is to install the \fIunicode\fR font. -+ -+.TP -+--locales=\fILOCALES\fR -+Install only locales listed in \fILOCALES\fR. The default is to install all available locales. -+ -+.TP -+--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR] -+Compress GRUB files using the specified compression algorithm. -+ -+.TP -+--directory=\fIDIR\fR -+Use images and modules in \fIDIR\fR. -+ -+.TP -+--grub-mkimage=\fIFILE\fR -+Use \fIFILE\fR as \fBgrub-mkimage\fR. The default is \fI/usr/bin/grub-mkimage\fR. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-ofpathname.8 b/util/grub-ofpathname.8 -new file mode 100644 -index 0000000..bf3743a ---- /dev/null -+++ b/util/grub-ofpathname.8 -@@ -0,0 +1,12 @@ -+.TH GRUB-OFPATHNAME 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-ofpathname\fR \(em Generate an IEEE-1275 device path for a specified device. -+ -+.SH SYNOPSIS -+\fBgrub-ofpathname\fR \fIDEVICE\fR -+ -+.SH DESCRIPTION -+\fBgrub-ofpathname\fR generates an IEEE-1275 device path for the specified \fIDEVICE\fR. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-probe.8 b/util/grub-probe.8 -new file mode 100644 -index 0000000..04e26c8 ---- /dev/null -+++ b/util/grub-probe.8 -@@ -0,0 +1,80 @@ -+.TH GRUB-PROBE 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-probe\fR \(em Probe device information for a given path. -+ -+.SH SYNOPSIS -+\fBgrub-probe\fR \[-d | --device] [-m | --device-map=\fIFILE\fR] -+.RS 12 -+[-t | --target=(fs|fs_uuid|fs_label|drive|device|partmap| -+.RE -+.RS 28 -+abstraction|cryptodisk_uuid| -+.RE -+.RS 28 -+msdos_parttype)] -+.RE -+.RS 12 -+[-v | --verbose] (PATH|DEVICE) -+ -+.SH DESCRIPTION -+\fBgrub-probe\fR probes a path or device for filesystem and related information. -+ -+.SH OPTIONS -+.TP -+--device -+Final option represents a \fIDEVICE\fR, rather than a filesystem \fIPATH\fR. -+.TP -+--device-map=\fIFILE\fR -+Use \fIFILE\fR as the device map. The default value is \fI/boot/grub/device.map\fR. -+ -+.TP -+--target=(fs|fs_uuid|fs_label|drive|device|partmap|msdos_parttype) -+Select among various output definitions. The default is \fIfs\fR. -+.RS -+.TP -+\fIfs\fR -+filesystem module -+ -+.TP -+\fIfs_uuid\fR -+filesystem UUID -+ -+.TP -+\fIfs_label\fR -+filesystem label -+ -+.TP -+\fIdrive\fR -+GRUB drive name -+ -+.TP -+\fIdevice\fR -+System device -+ -+.TP -+\fIpartmap\fR -+partition map module -+ -+.TP -+\fIabstraction\fR -+abstraction module -+ -+.TP -+\fIcryptodisk_uuid\fR -+cryptographic container -+ -+.TP -+\fImsdos_partmap\fR -+MS-DOS partition map -+.RE -+ -+.TP -+--verbose -+Print verbose output. -+ -+.TP -+(\fIPATH\fR|\fIDEVICE\fR) -+If --device is passed, a block \fIDEVICE\fR. Otherwise, the \fIPATH\fR of a file on the filesystem. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-reboot.8 b/util/grub-reboot.8 -new file mode 100644 -index 0000000..faa5e4e ---- /dev/null -+++ b/util/grub-reboot.8 -@@ -0,0 +1,21 @@ -+.TH GRUB-REBOOT 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-reboot\fR \(em Set the default boot menu entry for the next boot only. -+ -+.SH SYNOPSIS -+\fBgrub-reboot\fR [--boot-directory=\fIDIR\fR] \fIMENU_ENTRY\fR -+ -+.SH DESCRIPTION -+\fBgrub-reboot\fR sets the default boot menu entry for the next boot, but not further boots after that. This command only works for GRUB configuration files created with \fIGRUB_DEFAULT=saved\fR in \fI/etc/default/grub\fR. -+ -+.SH OPTIONS -+.TP -+--boot-directory=\fIDIR\fR -+Find GRUB images under \fIDIR/grub\fR. The default value is \fI/boot\fR, resulting in grub images being search for at \fI/boot/grub\fR. -+ -+.TP -+\fIMENU_ENTRY\fR -+A number, a menu item title or a menu item identifier. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-render-label.1 b/util/grub-render-label.1 -new file mode 100644 -index 0000000..4d51c8a ---- /dev/null -+++ b/util/grub-render-label.1 -@@ -0,0 +1,51 @@ -+.TH GRUB-RENDER-LABEL 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-render-label\fR \(em Render an Apple disk label. -+ -+.SH SYNOPSIS -+\fBgrub-render-label\fR [-b | --bgcolor=\fICOLOR\fR] [-c | --color=\fICOLOR\fR] -+.RS 19 -+[-f | --font=\fIFILE\fR] [-i | --input=\fIFILE\fR] -+.RE -+.RS 19 -+[-o | --output=\fIFILE\fR] [-t | --text=\fISTRING\fR] -+.RE -+.RS 19 -+[-v | --verbose] -+ -+.SH DESCRIPTION -+\fBgrub-render-label\fR renders an Apple disk label (.disk_label) file. -+ -+ -+.SH OPTIONS -+.TP -+\fB--color\fR=\fICOLOR\fR -+Use \fICOLOR\fI as the color for generated labels. -+ -+.TP -+\fB--bgcolor\fR=\fICOLOR\fR -+Use \fICOLOR\fR as the background color for generated labels. -+ -+.TP -+\fB--font\fR=\fIFILE\fR -+Use \fIFILE\fR as the font file for generated labels. -+ -+.TP -+--input=\fIFILE\fR -+Read input text from \fIFILE\fR. -+ -+.TP -+--output=\fIFILE\fR -+Render output to \fIFILE\fR. -+ -+.TP -+--text=\fISTRING\fR -+Use \fISTRING\fR as input text. -+ -+.TP -+--verbose -+Print verbose output. -+ -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-script-check.1 b/util/grub-script-check.1 -new file mode 100644 -index 0000000..0f1f625 ---- /dev/null -+++ b/util/grub-script-check.1 -@@ -0,0 +1,21 @@ -+.TH GRUB-SCRIPT-CHECK 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-script-check\fR \(em Check GRUB configuration file for syntax errors. -+ -+.SH SYNOPSIS -+\fBgrub-script-check\fR [-v | --verbose] \fIPATH\fR -+ -+.SH DESCRIPTION -+\fBgrub-script-check\fR verifies that a specified GRUB configuration file does not contain syntax errors. -+ -+.SH OPTIONS -+.TP -+--verbose -+Print verbose output. -+ -+.TP -+\fIPATH\fR -+Path of the file to use as input. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-set-default.8 b/util/grub-set-default.8 -new file mode 100644 -index 0000000..a96265a ---- /dev/null -+++ b/util/grub-set-default.8 -@@ -0,0 +1,21 @@ -+.TH GRUB-SET-DEFAULT 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-set-default\fR \(em Set the default boot menu entry for GRUB. -+ -+.SH SYNOPSIS -+\fBgrub-set-default\fR [--boot-directory=\fIDIR\fR] \fIMENU_ENTRY\fR -+ -+.SH DESCRIPTION -+\fBgrub-set-default\fR sets the default boot menu entry for all subsequent boots. This command only works for GRUB configuration files created with \fIGRUB_DEFAULT=saved\fR in \fI/etc/default/grub\fR. -+ -+.SH OPTIONS -+.TP -+--boot-directory=\fIDIR\fR -+Find GRUB images under \fIDIR/grub\fR. The default value is \fI/boot\fR, resulting in grub images being search for at \fI/boot/grub\fR. -+ -+.TP -+\fIMENU_ENTRY\fR -+A number, a menu item title or a menu item identifier. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-sparc64-setup.8 b/util/grub-sparc64-setup.8 -new file mode 100644 -index 0000000..37ea2dd ---- /dev/null -+++ b/util/grub-sparc64-setup.8 -@@ -0,0 +1,12 @@ -+.TH GRUB-SPARC64-SETUP 3 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-sparc64-setup\fR \(em Set up a device to boot a sparc64 GRUB image. -+ -+.SH SYNOPSIS -+\fBgrub-sparc64-setup\fR [OPTIONS]. -+ -+.SH DESCRIPTION -+You should not normally run this program directly. Use grub-install instead. -+ -+.SH SEE ALSO -+.BR "info grub" --- -2.9.3 - diff --git a/0048-Use-the-correct-indentation-for-the-term-help-text.patch b/0048-Use-the-correct-indentation-for-the-term-help-text.patch new file mode 100644 index 0000000..447f83d --- /dev/null +++ b/0048-Use-the-correct-indentation-for-the-term-help-text.patch @@ -0,0 +1,28 @@ +From 748c629f47f4191c66011646e010cdf5ab506b90 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Fri, 7 Jun 2013 14:08:49 -0400 +Subject: [PATCH 048/123] Use the correct indentation for the term help text + +That is consistent with the menu help text +--- + grub-core/normal/main.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index f57b7508a..0ce59fdc3 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -426,8 +426,8 @@ grub_normal_reader_init (int nested) + grub_normal_init_page (term, 1); + grub_term_setcursor (term, 1); + +- if (grub_term_width (term) > 3 + STANDARD_MARGIN + 20) +- grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term); ++ if (grub_term_width (term) > 2 * STANDARD_MARGIN + 20) ++ grub_print_message_indented (msg_formatted, STANDARD_MARGIN, STANDARD_MARGIN, term); + else + grub_print_message_indented (msg_formatted, 0, 0, term); + grub_putcode ('\n', term); +-- +2.14.3 + diff --git a/0049-Indent-menu-entries.patch b/0049-Indent-menu-entries.patch new file mode 100644 index 0000000..e5a05b2 --- /dev/null +++ b/0049-Indent-menu-entries.patch @@ -0,0 +1,26 @@ +From 93092c8a33db0cb36392c9684a60c12fbc823554 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Fri, 7 Jun 2013 14:30:55 -0400 +Subject: [PATCH 049/123] Indent menu entries + +--- + grub-core/normal/menu_text.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index 1062d64ee..ecc60f99f 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -239,7 +239,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, + unicode_title[i] = ' '; + + if (data->geo.num_entries > 1) +- grub_putcode (' ', data->term); ++ for (i = 0; i < STANDARD_MARGIN; i++) ++ grub_putcode (' ', data->term); + + grub_print_ucs4_menu (unicode_title, + unicode_title + len, +-- +2.14.3 + diff --git a/0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch b/0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch deleted file mode 100644 index 626253f..0000000 --- a/0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +++ /dev/null @@ -1,45 +0,0 @@ -From c28ddef07d11d790d89ee6ec8e3a8cc7e1aace0d Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Wed, 19 Feb 2014 15:58:43 -0500 -Subject: [PATCH 49/90] use fw_path prefix when fallback searching for grub - config - -When PXE booting via UEFI firmware, grub was searching for grub.cfg -in the fw_path directory where the grub application was found. If -that didn't exist, a fallback search would look for config file names -based on MAC and IP address. However, the search would look in the -prefix directory which may not be the same fw_path. This patch -changes that behavior to use the fw_path directory for the fallback -search. Only if fw_path is NULL will the prefix directory be searched. - -Signed-off-by: Mark Salter ---- - grub-core/normal/main.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 0ce59fd..a3713ef 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -343,7 +343,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), - char *config; - const char *prefix, *fw_path; - -- fw_path = grub_env_get ("fw_path"); -+ prefix = fw_path = grub_env_get ("fw_path"); - if (fw_path) - { - config = grub_xasprintf ("%s/grub.cfg", fw_path); -@@ -366,7 +366,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), - } - } - -- prefix = grub_env_get ("prefix"); -+ if (! prefix) -+ prefix = grub_env_get ("prefix"); - if (prefix) - { - grub_size_t config_len; --- -2.9.3 - diff --git a/0050-Fix-margins.patch b/0050-Fix-margins.patch new file mode 100644 index 0000000..0f00f93 --- /dev/null +++ b/0050-Fix-margins.patch @@ -0,0 +1,37 @@ +From ee7064d8667cf51d12f2cc5ead9b428446c563ad Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Fri, 7 Jun 2013 14:59:36 -0400 +Subject: [PATCH 050/123] Fix margins + +--- + grub-core/normal/menu_text.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index ecc60f99f..0e43f2c10 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -333,17 +333,15 @@ grub_menu_init_page (int nested, int edit, + int version_msg = 1; + + geo->border = 0; +- geo->first_entry_x = 0 /* margin */ + 0 /* border */; +- geo->entry_width = grub_term_width (term) - 5; ++ geo->first_entry_x = 0; /* no margin */ ++ geo->entry_width = grub_term_width (term) - 1; + +- geo->first_entry_y = 2 /* two empty lines*/ +- + 0 /* GNU GRUB version text */ + 1 /* top border */; ++ geo->first_entry_y = 3; /* three empty lines*/ + + geo->timeout_lines = 2; + + /* 3 lines for timeout message and bottom margin. 2 lines for the border. */ + geo->num_entries = grub_term_height (term) - geo->first_entry_y +- - 1 /* bottom border */ + - 1 /* empty line before info message*/ + - geo->timeout_lines /* timeout */ + - 1 /* empty final line */; +-- +2.14.3 + diff --git a/0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch b/0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch deleted file mode 100644 index 4dabe63..0000000 --- a/0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +++ /dev/null @@ -1,114 +0,0 @@ -From 82812e4ade82c9aa4f2e8f091b60b714ecfd82e5 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 6 Mar 2014 11:51:33 -0500 -Subject: [PATCH 50/90] Try mac/guid/etc before grub.cfg on tftp config files. - -Signed-off-by: Peter Jones ---- - grub-core/normal/main.c | 80 ++++++++++++++++++++++++++----------------------- - 1 file changed, 43 insertions(+), 37 deletions(-) - -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index a3713ef..7d9c4f0 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -341,53 +341,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), - /* Guess the config filename. It is necessary to make CONFIG static, - so that it won't get broken by longjmp. */ - char *config; -- const char *prefix, *fw_path; -- -- prefix = fw_path = grub_env_get ("fw_path"); -- if (fw_path) -- { -- config = grub_xasprintf ("%s/grub.cfg", fw_path); -- if (config) -- { -- grub_file_t file; -- -- file = grub_file_open (config); -- if (file) -- { -- grub_file_close (file); -- grub_enter_normal_mode (config); -- } -- else -- { -- /* Ignore all errors. */ -- grub_errno = 0; -- } -- grub_free (config); -- } -- } -+ const char *prefix; - -+ prefix = grub_env_get ("fw_path"); - if (! prefix) - prefix = grub_env_get ("prefix"); -+ - if (prefix) -- { -- grub_size_t config_len; -- config_len = grub_strlen (prefix) + -- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -- config = grub_malloc (config_len); -+ { -+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -+ { -+ grub_size_t config_len; -+ config_len = grub_strlen (prefix) + -+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -+ config = grub_malloc (config_len); -+ -+ if (! config) -+ goto quit; - -- if (! config) -- goto quit; -+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); - -- grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -+ grub_net_search_configfile (config); - -- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -- grub_net_search_configfile (config); -+ grub_enter_normal_mode (config); -+ grub_free (config); -+ config = NULL; -+ } - -- grub_enter_normal_mode (config); -- grub_free (config); -+ if (!config) -+ { -+ config = grub_xasprintf ("%s/grub.cfg", prefix); -+ if (config) -+ { -+ grub_file_t file; -+ -+ file = grub_file_open (config); -+ if (file) -+ { -+ grub_file_close (file); -+ grub_enter_normal_mode (config); -+ } -+ else -+ { -+ /* Ignore all errors. */ -+ grub_errno = 0; -+ } -+ grub_free (config); -+ } -+ } - } - else -- grub_enter_normal_mode (0); -+ { -+ grub_enter_normal_mode (0); -+ } - } - else - grub_enter_normal_mode (argv[0]); --- -2.9.3 - diff --git a/0051-Fix-convert-function-to-support-NVMe-devices.patch b/0051-Fix-convert-function-to-support-NVMe-devices.patch deleted file mode 100644 index 8cda91a..0000000 --- a/0051-Fix-convert-function-to-support-NVMe-devices.patch +++ /dev/null @@ -1,59 +0,0 @@ -From b954efc0812579f973031b24c68a2f593bd89ba1 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 18 Feb 2014 11:34:00 -0500 -Subject: [PATCH 51/90] Fix convert function to support NVMe devices - -This is adapted from the patch at -https://bugzilla.redhat.com/show_bug.cgi?id=1019660 , which is against -the now very old version of convert_system_partition_to_system_disk(). - -As such, it certainly not the right thing for upstream, but should -function for now. - -Resolves: rhbz#1019660 - -Signed-off-by: Peter Jones ---- - util/getroot.c | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/util/getroot.c b/util/getroot.c -index 92c0d70..bf317a2 100644 ---- a/util/getroot.c -+++ b/util/getroot.c -@@ -153,6 +153,7 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part) - { - #if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL - struct stat st; -+ char *path = xmalloc(PATH_MAX); - - if (stat (os_dev, &st) < 0) - { -@@ -165,6 +166,24 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part) - - *is_part = 0; - -+ if (realpath(os_dev, path)) -+ { -+ if ((strncmp ("/dev/nvme", path, 9) == 0)) -+ { -+ char *p = path + 5; -+ p = strchr(p, 'p'); -+ if (p) -+ { -+ *is_part = 1; -+ *p = '\0'; -+ } -+ return path; -+ } -+ } -+ -+ grub_free (path); -+ *is_part = 0; -+ - if (grub_util_device_is_mapped_stat (&st)) - return grub_util_devmapper_part_to_disk (&st, is_part, os_dev); - --- -2.9.3 - diff --git a/0051-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch b/0051-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch new file mode 100644 index 0000000..7036a59 --- /dev/null +++ b/0051-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch @@ -0,0 +1,27 @@ +From 712f456d542ec913c4a5bc13f86443f79912cbf3 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 21 Jun 2013 14:44:08 -0400 +Subject: [PATCH 051/123] Use -2 instead of -1 for our right-hand margin, so + linewrapping works (#976643). + +Signed-off-by: Peter Jones +--- + grub-core/normal/menu_text.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index 0e43f2c10..537d4bf86 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -334,7 +334,7 @@ grub_menu_init_page (int nested, int edit, + + geo->border = 0; + geo->first_entry_x = 0; /* no margin */ +- geo->entry_width = grub_term_width (term) - 1; ++ geo->entry_width = grub_term_width (term) - 2; + + geo->first_entry_y = 3; /* three empty lines*/ + +-- +2.14.3 + diff --git a/0052-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch b/0052-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch deleted file mode 100644 index 9228cd2..0000000 --- a/0052-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 6900527741a21097f57a72854944f3e078a0ee42 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Mon, 10 Feb 2014 16:13:10 -0500 -Subject: [PATCH 52/90] Switch to use APM Mustang device tree, for hardware - testing. - -Signed-off-by: David A. Marlin ---- - util/grub.d/10_linux.in | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 79a747e..462b461 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -232,8 +232,8 @@ while [ "x$list" != "x" ] ; do - - fdt= - for i in "dtb-${version}" "dtb-${alt_version}"; do -- if test -e "${dirname}/${i}/foundation-v8.dtb" ; then -- fdt="${i}/foundation-v8.dtb" -+ if test -e "${dirname}/${i}/apm-mustang.dtb" ; then -+ fdt="${i}/apm-mustang.dtb" - break - fi - done --- -2.9.3 - diff --git a/0052-Use-linux16-when-appropriate-880840.patch b/0052-Use-linux16-when-appropriate-880840.patch new file mode 100644 index 0000000..2e7a77f --- /dev/null +++ b/0052-Use-linux16-when-appropriate-880840.patch @@ -0,0 +1,52 @@ +From aedb9655a10717fe3678a9e2fc720b55f5b0ffbc Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 28 Oct 2013 10:05:07 -0400 +Subject: [PATCH 052/123] Use linux16 when appropriate (#880840) + +The kernel group really would prefer that we use the 16 bit entry point +on x86 bios machines. + +Resolves: rhbz#880840 + +Signed-off-by: Peter Jones +--- + util/grub.d/10_linux.in | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index a3d9711d6..f3bf6acd8 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -76,6 +76,11 @@ linux_entry () + type="$3" + args="$4" + ++ sixteenbit="" ++ case "$machine" in ++ i?86|x86_64) sixteenbit="16" ;; ++ esac ++ + if [ -z "$boot_device_id" ]; then + boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" + fi +@@ -134,7 +139,7 @@ linux_entry () + EOF + else + sed "s/^/$submenu_indentation/" << EOF +- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} ++ linux${sixteenbit} ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} + EOF + fi + if test -n "${initrd}" ; then +@@ -144,7 +149,7 @@ EOF + EOF + else + sed "s/^/$submenu_indentation/" << EOF +- initrd ${rel_dirname}/${initrd} ++ initrd${sixteenbit} ${rel_dirname}/${initrd} + EOF + fi + fi +-- +2.14.3 + diff --git a/0053-Enable-pager-by-default.-985860.patch b/0053-Enable-pager-by-default.-985860.patch new file mode 100644 index 0000000..d67409c --- /dev/null +++ b/0053-Enable-pager-by-default.-985860.patch @@ -0,0 +1,26 @@ +From 0b72348759eaec7d1d488e9788e724a2d48ce3f7 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 28 Oct 2013 10:09:27 -0400 +Subject: [PATCH 053/123] Enable pager by default. (#985860) + +Signed-off-by: Peter Jones +--- + util/grub.d/00_header.in | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in +index 93a90233e..858b526c9 100644 +--- a/util/grub.d/00_header.in ++++ b/util/grub.d/00_header.in +@@ -43,6 +43,8 @@ if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_ + if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi + + cat << EOF ++set pager=1 ++ + if [ -s \$prefix/grubenv ]; then + load_env + fi +-- +2.14.3 + diff --git a/0053-Use-the-default-device-tree-from-the-grub-default-fi.patch b/0053-Use-the-default-device-tree-from-the-grub-default-fi.patch deleted file mode 100644 index 2ba5537..0000000 --- a/0053-Use-the-default-device-tree-from-the-grub-default-fi.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 823290f622902f1ae06efa29efbe4ca15af1aafe Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Wed, 12 Feb 2014 14:54:04 -0500 -Subject: [PATCH 53/90] Use the default device tree from the grub default file - -instead of hardcoding a value. - -Signed-off-by: David A. Marlin ---- - util/grub-mkconfig.in | 3 ++- - util/grub.d/10_linux.in | 4 ++-- - 2 files changed, 4 insertions(+), 3 deletions(-) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index c088b70..9d595ac 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -235,7 +235,8 @@ export GRUB_DEFAULT \ - GRUB_ENABLE_CRYPTODISK \ - GRUB_BADRAM \ - GRUB_OS_PROBER_SKIP_LIST \ -- GRUB_DISABLE_SUBMENU -+ GRUB_DISABLE_SUBMENU \ -+ GRUB_DEFAULT_DTB - - if test "x${grub_cfg}" != "x"; then - rm -f "${grub_cfg}.new" -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 462b461..a9692a0 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -232,8 +232,8 @@ while [ "x$list" != "x" ] ; do - - fdt= - for i in "dtb-${version}" "dtb-${alt_version}"; do -- if test -e "${dirname}/${i}/apm-mustang.dtb" ; then -- fdt="${i}/apm-mustang.dtb" -+ if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then -+ fdt="${i}/${GRUB_DEFAULT_DTB}" - break - fi - done --- -2.9.3 - diff --git a/0054-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch b/0054-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch new file mode 100644 index 0000000..b3c72a9 --- /dev/null +++ b/0054-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch @@ -0,0 +1,27 @@ +From 55d0f5f5fdecfab6c8439520491e08a0178bd5dc Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 28 Oct 2013 10:13:27 -0400 +Subject: [PATCH 054/123] F10 doesn't work on serial, so don't tell the user to + hit it (#987443) + +Signed-off-by: Peter Jones +--- + grub-core/normal/menu_text.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index 537d4bf86..452d55bf9 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -157,7 +157,7 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) + + if (edit) + { +- ret += grub_print_message_indented_real (_("Press Ctrl-x or F10 to start, Ctrl-c or F2 for a \ ++ ret += grub_print_message_indented_real (_("Press Ctrl-x to start, Ctrl-c for a \ + command prompt or Escape to discard edits and return to the menu. Pressing Tab lists possible completions."), + STANDARD_MARGIN, STANDARD_MARGIN, + term, dry_run); +-- +2.14.3 + diff --git a/0054-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0054-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index b5cc967..0000000 --- a/0054-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,46 +0,0 @@ -From e119353dad1eadc771a011f82bf90bd04fc00f9a Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Sat, 15 Feb 2014 15:10:22 -0500 -Subject: [PATCH 54/90] reopen SNP protocol for exclusive use by grub - ---- - grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 5388f95..ea0e0ca 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -330,6 +330,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - { - struct grub_net_card *card; - grub_efi_device_path_t *dp; -+ grub_efi_simple_network_t *net; - - dp = grub_efi_get_device_path (hnd); - if (! dp) -@@ -383,6 +384,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -+ net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -+ GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -+ if (net) { -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -+ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STARTED -+ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -+ continue; -+ card->efi_net = net; -+ } - return; - } - } --- -2.9.3 - diff --git a/0055-Don-t-say-GNU-Linux-in-generated-menus.patch b/0055-Don-t-say-GNU-Linux-in-generated-menus.patch new file mode 100644 index 0000000..988b753 --- /dev/null +++ b/0055-Don-t-say-GNU-Linux-in-generated-menus.patch @@ -0,0 +1,45 @@ +From d110064c73c1604b07cdaa3d41751074b2701142 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 14 Mar 2011 14:27:42 -0400 +Subject: [PATCH 055/123] Don't say "GNU/Linux" in generated menus. + +--- + util/grub.d/10_linux.in | 4 ++-- + util/grub.d/20_linux_xen.in | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index f3bf6acd8..ef52cf3db 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" + CLASS="--class gnu-linux --class gnu --class os" + + if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then +- OS=GNU/Linux ++ OS="$(sed 's, release .*$,,g' /etc/system-release)" + else +- OS="${GRUB_DISTRIBUTOR} GNU/Linux" ++ OS="${GRUB_DISTRIBUTOR}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" + fi + +diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in +index c48af948d..25e3c4136 100644 +--- a/util/grub.d/20_linux_xen.in ++++ b/util/grub.d/20_linux_xen.in +@@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" + CLASS="--class gnu-linux --class gnu --class os --class xen" + + if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then +- OS=GNU/Linux ++ OS="$(sed 's, release .*$,,g' /etc/system-release)" + else +- OS="${GRUB_DISTRIBUTOR} GNU/Linux" ++ OS="${GRUB_DISTRIBUTOR}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" + fi + +-- +2.14.3 + diff --git a/0055-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0055-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index 76b8635..0000000 --- a/0055-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 5d47b56198754190c62179ae10ef175c00d1474d Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 4 Mar 2016 15:13:59 -0500 -Subject: [PATCH 55/90] Revert "reopen SNP protocol for exclusive use by grub" - -This reverts commit a3f2c756ce34c9666bddef35e3b3b85ccecdcffc , which is -obsoleted by these: - -49426e9 efinet: open Simple Network Protocol exclusively -f348aee efinet: enable hardware filters when opening interface -c52ae40 efinet: skip virtual IPv4 and IPv6 devices when enumerating cards - -Signed-off-by: Peter Jones ---- - grub-core/net/drivers/efi/efinet.c | 16 ---------------- - 1 file changed, 16 deletions(-) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index ea0e0ca..5388f95 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -330,7 +330,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - { - struct grub_net_card *card; - grub_efi_device_path_t *dp; -- grub_efi_simple_network_t *net; - - dp = grub_efi_get_device_path (hnd); - if (! dp) -@@ -384,21 +383,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -- net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -- GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -- if (net) { -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -- && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STARTED -- && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -- continue; -- card->efi_net = net; -- } - return; - } - } --- -2.9.3 - diff --git a/0056-Add-grub_util_readlink.patch b/0056-Add-grub_util_readlink.patch deleted file mode 100644 index f15414a..0000000 --- a/0056-Add-grub_util_readlink.patch +++ /dev/null @@ -1,3734 +0,0 @@ -From 5a69c7fbfff14bcea80e781fcd6acad07c904e22 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 3 Sep 2014 10:01:03 -0400 -Subject: [PATCH 56/90] Add grub_util_readlink() - -Add grub_util_readlink(). This requires pulling in stat and readlink from -gnulib, which pulls in stat and related headers, but after that the -implementation is straightforward. - -Signed-off-by: Peter Jones -Reviewed-by: Adam Jackson ---- - grub-core/gnulib/Makefile.am | 177 +++++++- - grub-core/gnulib/gettimeofday.c | 154 +++++++ - grub-core/gnulib/pathmax.h | 83 ++++ - grub-core/gnulib/readlink.c | 74 ++++ - grub-core/gnulib/stat.c | 138 +++++++ - grub-core/gnulib/sys_stat.in.h | 732 ++++++++++++++++++++++++++++++++++ - grub-core/gnulib/sys_time.in.h | 213 ++++++++++ - grub-core/gnulib/sys_types.in.h | 2 + - grub-core/gnulib/time.h | 586 +++++++++++++++++++++++++++ - grub-core/gnulib/time.in.h | 274 +++++++++++++ - grub-core/osdep/windows/hostdisk.c | 6 + - include/grub/osdep/hostfile_aros.h | 6 + - include/grub/osdep/hostfile_unix.h | 6 + - include/grub/osdep/hostfile_windows.h | 2 + - m4/gettimeofday.m4 | 138 +++++++ - m4/gnulib-cache.m4 | 3 +- - m4/gnulib-comp.m4 | 49 +++ - m4/largefile.m4 | 146 +++++++ - m4/pathmax.m4 | 42 ++ - m4/readlink.m4 | 71 ++++ - m4/stat.m4 | 71 ++++ - m4/sys_stat_h.m4 | 96 +++++ - m4/sys_time_h.m4 | 110 +++++ - m4/time_h.m4 | 118 ++++++ - 24 files changed, 3295 insertions(+), 2 deletions(-) - create mode 100644 grub-core/gnulib/gettimeofday.c - create mode 100644 grub-core/gnulib/pathmax.h - create mode 100644 grub-core/gnulib/readlink.c - create mode 100644 grub-core/gnulib/stat.c - create mode 100644 grub-core/gnulib/sys_stat.in.h - create mode 100644 grub-core/gnulib/sys_time.in.h - create mode 100644 grub-core/gnulib/time.h - create mode 100644 grub-core/gnulib/time.in.h - create mode 100644 m4/gettimeofday.m4 - create mode 100644 m4/largefile.m4 - create mode 100644 m4/pathmax.m4 - create mode 100644 m4/readlink.m4 - create mode 100644 m4/stat.m4 - create mode 100644 m4/sys_stat_h.m4 - create mode 100644 m4/sys_time_h.m4 - create mode 100644 m4/time_h.m4 - -diff --git a/grub-core/gnulib/Makefile.am b/grub-core/gnulib/Makefile.am -index 3444397..b7c5e60 100644 ---- a/grub-core/gnulib/Makefile.am -+++ b/grub-core/gnulib/Makefile.am -@@ -21,7 +21,7 @@ - # the same distribution terms as the rest of that program. - # - # Generated by gnulib-tool. --# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex -+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex - - AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects - -@@ -326,6 +326,15 @@ libgnu_a_SOURCES += gettext.h - - ## end gnulib module gettext-h - -+## begin gnulib module gettimeofday -+ -+ -+EXTRA_DIST += gettimeofday.c -+ -+EXTRA_libgnu_a_SOURCES += gettimeofday.c -+ -+## end gnulib module gettimeofday -+ - ## begin gnulib module havelib - - -@@ -596,6 +605,13 @@ EXTRA_libgnu_a_SOURCES += nl_langinfo.c - - ## end gnulib module nl_langinfo - -+## begin gnulib module pathmax -+ -+ -+EXTRA_DIST += pathmax.h -+ -+## end gnulib module pathmax -+ - ## begin gnulib module progname - - libgnu_a_SOURCES += progname.h progname.c -@@ -611,6 +627,15 @@ EXTRA_libgnu_a_SOURCES += rawmemchr.c - - ## end gnulib module rawmemchr - -+## begin gnulib module readlink -+ -+ -+EXTRA_DIST += readlink.c -+ -+EXTRA_libgnu_a_SOURCES += readlink.c -+ -+## end gnulib module readlink -+ - ## begin gnulib module realloc-posix - - -@@ -725,6 +750,15 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h - - ## end gnulib module snippet/warn-on-use - -+## begin gnulib module stat -+ -+ -+EXTRA_DIST += stat.c -+ -+EXTRA_libgnu_a_SOURCES += stat.c -+ -+## end gnulib module stat -+ - ## begin gnulib module stdalign - - BUILT_SOURCES += $(STDALIGN_H) -@@ -1280,6 +1314,102 @@ libgnu_a_SOURCES += strnlen1.h strnlen1.c - - ## end gnulib module strnlen1 - -+## begin gnulib module sys_stat -+ -+BUILT_SOURCES += sys/stat.h -+ -+# We need the following in order to create when the system -+# has one that is incomplete. -+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -+ $(AM_V_at)$(MKDIR_P) sys -+ $(AM_V_GEN)rm -f $@-t $@ && \ -+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ -+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -+ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -+ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ -+ -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ -+ -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \ -+ -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ -+ -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ -+ -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ -+ -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \ -+ -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \ -+ -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \ -+ -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \ -+ -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \ -+ -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \ -+ -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \ -+ -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \ -+ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ -+ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -+ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ -+ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -+ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -+ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ -+ -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ -+ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ -+ -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ -+ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ -+ -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ -+ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ -+ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -+ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \ -+ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -+ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -+ -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ -+ -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ -+ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ -+ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \ -+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ -+ < $(srcdir)/sys_stat.in.h; \ -+ } > $@-t && \ -+ mv $@-t $@ -+MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t -+MOSTLYCLEANDIRS += sys -+ -+EXTRA_DIST += sys_stat.in.h -+ -+## end gnulib module sys_stat -+ -+## begin gnulib module sys_time -+ -+BUILT_SOURCES += sys/time.h -+ -+# We need the following in order to create when the system -+# doesn't have one that works with the given compiler. -+sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -+ $(AM_V_at)$(MKDIR_P) sys -+ $(AM_V_GEN)rm -f $@-t $@ && \ -+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ -+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -+ -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ -+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -+ -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -+ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -+ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -+ -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ -+ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ -+ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -+ -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \ -+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ -+ < $(srcdir)/sys_time.in.h; \ -+ } > $@-t && \ -+ mv $@-t $@ -+MOSTLYCLEANFILES += sys/time.h sys/time.h-t -+ -+EXTRA_DIST += sys_time.in.h -+ -+## end gnulib module sys_time -+ - ## begin gnulib module sys_types - - BUILT_SOURCES += sys/types.h -@@ -1334,6 +1464,51 @@ EXTRA_DIST += sysexits.in.h - - ## end gnulib module sysexits - -+## begin gnulib module time -+ -+BUILT_SOURCES += time.h -+ -+# We need the following in order to create when the system -+# doesn't have one that works with the given compiler. -+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -+ $(AM_V_GEN)rm -f $@-t $@ && \ -+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ -+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -+ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ -+ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -+ -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ -+ -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ -+ -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ -+ -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ -+ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ -+ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ -+ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ -+ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ -+ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ -+ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ -+ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ -+ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ -+ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -+ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -+ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -+ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ -+ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -+ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ -+ < $(srcdir)/time.in.h; \ -+ } > $@-t && \ -+ mv $@-t $@ -+MOSTLYCLEANFILES += time.h time.h-t -+ -+EXTRA_DIST += time.in.h -+ -+## end gnulib module time -+ - ## begin gnulib module unistd - - BUILT_SOURCES += unistd.h -diff --git a/grub-core/gnulib/gettimeofday.c b/grub-core/gnulib/gettimeofday.c -new file mode 100644 -index 0000000..8b2058e ---- /dev/null -+++ b/grub-core/gnulib/gettimeofday.c -@@ -0,0 +1,154 @@ -+/* Provide gettimeofday for systems that don't have it or for which it's broken. -+ -+ Copyright (C) 2001-2003, 2005-2007, 2009-2014 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 -+ the Free Software Foundation; either version 3, 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, see . */ -+ -+/* written by Jim Meyering */ -+ -+#include -+ -+/* Specification. */ -+#include -+ -+#include -+ -+#if HAVE_SYS_TIMEB_H -+# include -+#endif -+ -+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME -+ -+/* Work around the bug in some systems whereby gettimeofday clobbers -+ the static buffer that localtime uses for its return value. The -+ gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has -+ this problem. The tzset replacement is necessary for at least -+ Solaris 2.5, 2.5.1, and 2.6. */ -+ -+static struct tm tm_zero_buffer; -+static struct tm *localtime_buffer_addr = &tm_zero_buffer; -+ -+# undef localtime -+extern struct tm *localtime (time_t const *); -+ -+# undef gmtime -+extern struct tm *gmtime (time_t const *); -+ -+/* This is a wrapper for localtime. It is used only on systems for which -+ gettimeofday clobbers the static buffer used for localtime's result. -+ -+ On the first call, record the address of the static buffer that -+ localtime uses for its result. */ -+ -+struct tm * -+rpl_localtime (time_t const *timep) -+{ -+ struct tm *tm = localtime (timep); -+ -+ if (localtime_buffer_addr == &tm_zero_buffer) -+ localtime_buffer_addr = tm; -+ -+ return tm; -+} -+ -+/* Same as above, since gmtime and localtime use the same buffer. */ -+struct tm * -+rpl_gmtime (time_t const *timep) -+{ -+ struct tm *tm = gmtime (timep); -+ -+ if (localtime_buffer_addr == &tm_zero_buffer) -+ localtime_buffer_addr = tm; -+ -+ return tm; -+} -+ -+#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ -+ -+#if TZSET_CLOBBERS_LOCALTIME -+ -+# undef tzset -+extern void tzset (void); -+ -+/* This is a wrapper for tzset, for systems on which tzset may clobber -+ the static buffer used for localtime's result. */ -+void -+rpl_tzset (void) -+{ -+ /* Save and restore the contents of the buffer used for localtime's -+ result around the call to tzset. */ -+ struct tm save = *localtime_buffer_addr; -+ tzset (); -+ *localtime_buffer_addr = save; -+} -+#endif -+ -+/* This is a wrapper for gettimeofday. It is used only on systems -+ that lack this function, or whose implementation of this function -+ causes problems. */ -+ -+int -+gettimeofday (struct timeval *restrict tv, void *restrict tz) -+{ -+#undef gettimeofday -+#if HAVE_GETTIMEOFDAY -+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME -+ /* Save and restore the contents of the buffer used for localtime's -+ result around the call to gettimeofday. */ -+ struct tm save = *localtime_buffer_addr; -+# endif -+ -+# if defined timeval /* 'struct timeval' overridden by gnulib? */ -+# undef timeval -+ struct timeval otv; -+ int result = gettimeofday (&otv, (struct timezone *) tz); -+ if (result == 0) -+ { -+ tv->tv_sec = otv.tv_sec; -+ tv->tv_usec = otv.tv_usec; -+ } -+# else -+ int result = gettimeofday (tv, (struct timezone *) tz); -+# endif -+ -+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME -+ *localtime_buffer_addr = save; -+# endif -+ -+ return result; -+ -+#else -+ -+# if HAVE__FTIME -+ -+ struct _timeb timebuf; -+ _ftime (&timebuf); -+ tv->tv_sec = timebuf.time; -+ tv->tv_usec = timebuf.millitm * 1000; -+ -+# else -+ -+# if !defined OK_TO_USE_1S_CLOCK -+# error "Only 1-second nominal clock resolution found. Is that intended?" \ -+ "If so, compile with the -DOK_TO_USE_1S_CLOCK option." -+# endif -+ tv->tv_sec = time (NULL); -+ tv->tv_usec = 0; -+ -+# endif -+ -+ return 0; -+ -+#endif -+} -diff --git a/grub-core/gnulib/pathmax.h b/grub-core/gnulib/pathmax.h -new file mode 100644 -index 0000000..33fc355 ---- /dev/null -+++ b/grub-core/gnulib/pathmax.h -@@ -0,0 +1,83 @@ -+/* Define PATH_MAX somehow. Requires sys/types.h. -+ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2014 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 -+ the Free Software Foundation; either version 3, 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, see . */ -+ -+#ifndef _PATHMAX_H -+# define _PATHMAX_H -+ -+/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, -+ including the terminating NUL byte. -+ -+ PATH_MAX is not defined on systems which have no limit on filename length, -+ such as GNU/Hurd. -+ -+ This file does *not* define PATH_MAX always. Programs that use this file -+ can handle the GNU/Hurd case in several ways: -+ - Either with a package-wide handling, or with a per-file handling, -+ - Either through a -+ #ifdef PATH_MAX -+ or through a fallback like -+ #ifndef PATH_MAX -+ # define PATH_MAX 8192 -+ #endif -+ or through a fallback like -+ #ifndef PATH_MAX -+ # define PATH_MAX pathconf ("/", _PC_PATH_MAX) -+ #endif -+ */ -+ -+# include -+ -+# include -+ -+# ifndef _POSIX_PATH_MAX -+# define _POSIX_PATH_MAX 256 -+# endif -+ -+/* Don't include sys/param.h if it already has been. */ -+# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN -+# include -+# endif -+ -+# if !defined PATH_MAX && defined MAXPATHLEN -+# define PATH_MAX MAXPATHLEN -+# endif -+ -+# ifdef __hpux -+/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, -+ *not* including the terminating NUL byte, and is set to 1023. -+ Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is -+ not defined at all any more. */ -+# undef PATH_MAX -+# define PATH_MAX 1024 -+# endif -+ -+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, -+ section "Maximum Path Length Limitation", -+ -+ explains that the maximum size of a filename, including the terminating -+ NUL byte, is 260 = 3 + 256 + 1. -+ This is the same value as -+ - FILENAME_MAX in , -+ - _MAX_PATH in , -+ - MAX_PATH in . -+ Undefine the original value, because mingw's gets it wrong. */ -+# undef PATH_MAX -+# define PATH_MAX 260 -+# endif -+ -+#endif /* _PATHMAX_H */ -diff --git a/grub-core/gnulib/readlink.c b/grub-core/gnulib/readlink.c -new file mode 100644 -index 0000000..4c49639 ---- /dev/null -+++ b/grub-core/gnulib/readlink.c -@@ -0,0 +1,74 @@ -+/* Stub for readlink(). -+ Copyright (C) 2003-2007, 2009-2014 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 -+ 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, see . */ -+ -+#include -+ -+/* Specification. */ -+#include -+ -+#include -+#include -+#include -+ -+#if !HAVE_READLINK -+ -+/* readlink() substitute for systems that don't have a readlink() function, -+ such as DJGPP 2.03 and mingw32. */ -+ -+ssize_t -+readlink (const char *name, char *buf _GL_UNUSED, -+ size_t bufsize _GL_UNUSED) -+{ -+ struct stat statbuf; -+ -+ /* In general we should use lstat() here, not stat(). But on platforms -+ without symbolic links, lstat() - if it exists - would be equivalent to -+ stat(), therefore we can use stat(). This saves us a configure check. */ -+ if (stat (name, &statbuf) >= 0) -+ errno = EINVAL; -+ return -1; -+} -+ -+#else /* HAVE_READLINK */ -+ -+# undef readlink -+ -+/* readlink() wrapper that uses correct types, for systems like cygwin -+ 1.5.x where readlink returns int, and which rejects trailing slash, -+ for Solaris 9. */ -+ -+ssize_t -+rpl_readlink (const char *name, char *buf, size_t bufsize) -+{ -+# if READLINK_TRAILING_SLASH_BUG -+ size_t len = strlen (name); -+ if (len && name[len - 1] == '/') -+ { -+ /* Even if name without the slash is a symlink to a directory, -+ both lstat() and stat() must resolve the trailing slash to -+ the directory rather than the symlink. We can therefore -+ safely use stat() to distinguish between EINVAL and -+ ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ -+ struct stat st; -+ if (stat (name, &st) == 0) -+ errno = EINVAL; -+ return -1; -+ } -+# endif /* READLINK_TRAILING_SLASH_BUG */ -+ return readlink (name, buf, bufsize); -+} -+ -+#endif /* HAVE_READLINK */ -diff --git a/grub-core/gnulib/stat.c b/grub-core/gnulib/stat.c -new file mode 100644 -index 0000000..35f4b0b ---- /dev/null -+++ b/grub-core/gnulib/stat.c -@@ -0,0 +1,138 @@ -+/* Work around platform bugs in stat. -+ Copyright (C) 2009-2014 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 -+ 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, see . */ -+ -+/* written by Eric Blake */ -+ -+/* If the user's config.h happens to include , let it include only -+ the system's here, so that orig_stat doesn't recurse to -+ rpl_stat. */ -+#define __need_system_sys_stat_h -+#include -+ -+/* Get the original definition of stat. It might be defined as a macro. */ -+#include -+#include -+#undef __need_system_sys_stat_h -+ -+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+# if _GL_WINDOWS_64_BIT_ST_SIZE -+# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ -+# define stat _stati64 -+# define REPLACE_FUNC_STAT_DIR 1 -+# undef REPLACE_FUNC_STAT_FILE -+# elif REPLACE_FUNC_STAT_FILE -+/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a. -+ Bypass it. */ -+# define stat _stat -+# define REPLACE_FUNC_STAT_DIR 1 -+# undef REPLACE_FUNC_STAT_FILE -+# endif -+#endif -+ -+static int -+orig_stat (const char *filename, struct stat *buf) -+{ -+ return stat (filename, buf); -+} -+ -+/* Specification. */ -+/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc -+ eliminates this include because of the preliminary #include -+ above. */ -+#include "sys/stat.h" -+ -+#include -+#include -+#include -+#include -+#include "dosname.h" -+#include "verify.h" -+ -+#if REPLACE_FUNC_STAT_DIR -+# include "pathmax.h" -+ /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also -+ have a constant PATH_MAX. */ -+# ifndef PATH_MAX -+# error "Please port this replacement to your platform" -+# endif -+#endif -+ -+/* Store information about NAME into ST. Work around bugs with -+ trailing slashes. Mingw has other bugs (such as st_ino always -+ being 0 on success) which this wrapper does not work around. But -+ at least this implementation provides the ability to emulate fchdir -+ correctly. */ -+ -+int -+rpl_stat (char const *name, struct stat *st) -+{ -+ int result = orig_stat (name, st); -+#if REPLACE_FUNC_STAT_FILE -+ /* Solaris 9 mistakenly succeeds when given a non-directory with a -+ trailing slash. */ -+ if (result == 0 && !S_ISDIR (st->st_mode)) -+ { -+ size_t len = strlen (name); -+ if (ISSLASH (name[len - 1])) -+ { -+ errno = ENOTDIR; -+ return -1; -+ } -+ } -+#endif /* REPLACE_FUNC_STAT_FILE */ -+#if REPLACE_FUNC_STAT_DIR -+ -+ if (result == -1 && errno == ENOENT) -+ { -+ /* Due to mingw's oddities, there are some directories (like -+ c:\) where stat() only succeeds with a trailing slash, and -+ other directories (like c:\windows) where stat() only -+ succeeds without a trailing slash. But we want the two to be -+ synonymous, since chdir() manages either style. Likewise, Mingw also -+ reports ENOENT for names longer than PATH_MAX, when we want -+ ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR. -+ Fortunately, mingw PATH_MAX is small enough for stack -+ allocation. */ -+ char fixed_name[PATH_MAX + 1] = {0}; -+ size_t len = strlen (name); -+ bool check_dir = false; -+ verify (PATH_MAX <= 4096); -+ if (PATH_MAX <= len) -+ errno = ENAMETOOLONG; -+ else if (len) -+ { -+ strcpy (fixed_name, name); -+ if (ISSLASH (fixed_name[len - 1])) -+ { -+ check_dir = true; -+ while (len && ISSLASH (fixed_name[len - 1])) -+ fixed_name[--len] = '\0'; -+ if (!len) -+ fixed_name[0] = '/'; -+ } -+ else -+ fixed_name[len++] = '/'; -+ result = orig_stat (fixed_name, st); -+ if (result == 0 && check_dir && !S_ISDIR (st->st_mode)) -+ { -+ result = -1; -+ errno = ENOTDIR; -+ } -+ } -+ } -+#endif /* REPLACE_FUNC_STAT_DIR */ -+ return result; -+} -diff --git a/grub-core/gnulib/sys_stat.in.h b/grub-core/gnulib/sys_stat.in.h -new file mode 100644 -index 0000000..b47a7ff ---- /dev/null -+++ b/grub-core/gnulib/sys_stat.in.h -@@ -0,0 +1,732 @@ -+/* Provide a more complete sys/stat header file. -+ Copyright (C) 2005-2014 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 -+ the Free Software Foundation; either version 3, 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, see . */ -+ -+/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ -+ -+/* This file is supposed to be used on platforms where is -+ incomplete. It is intended to provide definitions and prototypes -+ needed by an application. Start with what the system provides. */ -+ -+#if __GNUC__ >= 3 -+@PRAGMA_SYSTEM_HEADER@ -+#endif -+@PRAGMA_COLUMNS@ -+ -+#if defined __need_system_sys_stat_h -+/* Special invocation convention. */ -+ -+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ -+ -+#else -+/* Normal invocation convention. */ -+ -+#ifndef _@GUARD_PREFIX@_SYS_STAT_H -+ -+/* Get nlink_t. -+ May also define off_t to a 64-bit type on native Windows. */ -+#include -+ -+/* Get struct timespec. */ -+#include -+ -+/* The include_next requires a split double-inclusion guard. */ -+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ -+ -+#ifndef _@GUARD_PREFIX@_SYS_STAT_H -+#define _@GUARD_PREFIX@_SYS_STAT_H -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+ -+/* Before doing "#define mkdir rpl_mkdir" below, we need to include all -+ headers that may declare mkdir(). Native Windows platforms declare mkdir -+ in and/or , not in . */ -+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+# include /* mingw32, mingw64 */ -+# include /* mingw64, MSVC 9 */ -+#endif -+ -+/* Native Windows platforms declare umask() in . */ -+#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) -+# include -+#endif -+ -+/* Large File Support on native Windows. */ -+#if @WINDOWS_64_BIT_ST_SIZE@ -+# define stat _stati64 -+#endif -+ -+#ifndef S_IFIFO -+# ifdef _S_IFIFO -+# define S_IFIFO _S_IFIFO -+# endif -+#endif -+ -+#ifndef S_IFMT -+# define S_IFMT 0170000 -+#endif -+ -+#if STAT_MACROS_BROKEN -+# undef S_ISBLK -+# undef S_ISCHR -+# undef S_ISDIR -+# undef S_ISFIFO -+# undef S_ISLNK -+# undef S_ISNAM -+# undef S_ISMPB -+# undef S_ISMPC -+# undef S_ISNWK -+# undef S_ISREG -+# undef S_ISSOCK -+#endif -+ -+#ifndef S_ISBLK -+# ifdef S_IFBLK -+# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -+# else -+# define S_ISBLK(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISCHR -+# ifdef S_IFCHR -+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -+# else -+# define S_ISCHR(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISDIR -+# ifdef S_IFDIR -+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -+# else -+# define S_ISDIR(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISDOOR /* Solaris 2.5 and up */ -+# define S_ISDOOR(m) 0 -+#endif -+ -+#ifndef S_ISFIFO -+# ifdef S_IFIFO -+# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -+# else -+# define S_ISFIFO(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISLNK -+# ifdef S_IFLNK -+# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -+# else -+# define S_ISLNK(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISMPB /* V7 */ -+# ifdef S_IFMPB -+# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) -+# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) -+# else -+# define S_ISMPB(m) 0 -+# define S_ISMPC(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISMPX /* AIX */ -+# define S_ISMPX(m) 0 -+#endif -+ -+#ifndef S_ISNAM /* Xenix */ -+# ifdef S_IFNAM -+# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) -+# else -+# define S_ISNAM(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISNWK /* HP/UX */ -+# ifdef S_IFNWK -+# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) -+# else -+# define S_ISNWK(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISPORT /* Solaris 10 and up */ -+# define S_ISPORT(m) 0 -+#endif -+ -+#ifndef S_ISREG -+# ifdef S_IFREG -+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -+# else -+# define S_ISREG(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISSOCK -+# ifdef S_IFSOCK -+# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -+# else -+# define S_ISSOCK(m) 0 -+# endif -+#endif -+ -+ -+#ifndef S_TYPEISMQ -+# define S_TYPEISMQ(p) 0 -+#endif -+ -+#ifndef S_TYPEISTMO -+# define S_TYPEISTMO(p) 0 -+#endif -+ -+ -+#ifndef S_TYPEISSEM -+# ifdef S_INSEM -+# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) -+# else -+# define S_TYPEISSEM(p) 0 -+# endif -+#endif -+ -+#ifndef S_TYPEISSHM -+# ifdef S_INSHD -+# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) -+# else -+# define S_TYPEISSHM(p) 0 -+# endif -+#endif -+ -+/* high performance ("contiguous data") */ -+#ifndef S_ISCTG -+# define S_ISCTG(p) 0 -+#endif -+ -+/* Cray DMF (data migration facility): off line, with data */ -+#ifndef S_ISOFD -+# define S_ISOFD(p) 0 -+#endif -+ -+/* Cray DMF (data migration facility): off line, with no data */ -+#ifndef S_ISOFL -+# define S_ISOFL(p) 0 -+#endif -+ -+/* 4.4BSD whiteout */ -+#ifndef S_ISWHT -+# define S_ISWHT(m) 0 -+#endif -+ -+/* If any of the following are undefined, -+ define them to their de facto standard values. */ -+#if !S_ISUID -+# define S_ISUID 04000 -+#endif -+#if !S_ISGID -+# define S_ISGID 02000 -+#endif -+ -+/* S_ISVTX is a common extension to POSIX. */ -+#ifndef S_ISVTX -+# define S_ISVTX 01000 -+#endif -+ -+#if !S_IRUSR && S_IREAD -+# define S_IRUSR S_IREAD -+#endif -+#if !S_IRUSR -+# define S_IRUSR 00400 -+#endif -+#if !S_IRGRP -+# define S_IRGRP (S_IRUSR >> 3) -+#endif -+#if !S_IROTH -+# define S_IROTH (S_IRUSR >> 6) -+#endif -+ -+#if !S_IWUSR && S_IWRITE -+# define S_IWUSR S_IWRITE -+#endif -+#if !S_IWUSR -+# define S_IWUSR 00200 -+#endif -+#if !S_IWGRP -+# define S_IWGRP (S_IWUSR >> 3) -+#endif -+#if !S_IWOTH -+# define S_IWOTH (S_IWUSR >> 6) -+#endif -+ -+#if !S_IXUSR && S_IEXEC -+# define S_IXUSR S_IEXEC -+#endif -+#if !S_IXUSR -+# define S_IXUSR 00100 -+#endif -+#if !S_IXGRP -+# define S_IXGRP (S_IXUSR >> 3) -+#endif -+#if !S_IXOTH -+# define S_IXOTH (S_IXUSR >> 6) -+#endif -+ -+#if !S_IRWXU -+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -+#endif -+#if !S_IRWXG -+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -+#endif -+#if !S_IRWXO -+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -+#endif -+ -+/* S_IXUGO is a common extension to POSIX. */ -+#if !S_IXUGO -+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) -+#endif -+ -+#ifndef S_IRWXUGO -+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) -+#endif -+ -+/* Macros for futimens and utimensat. */ -+#ifndef UTIME_NOW -+# define UTIME_NOW (-1) -+# define UTIME_OMIT (-2) -+#endif -+ -+ -+#if @GNULIB_FCHMODAT@ -+# if !@HAVE_FCHMODAT@ -+_GL_FUNCDECL_SYS (fchmodat, int, -+ (int fd, char const *file, mode_t mode, int flag) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (fchmodat, int, -+ (int fd, char const *file, mode_t mode, int flag)); -+_GL_CXXALIASWARN (fchmodat); -+#elif defined GNULIB_POSIXCHECK -+# undef fchmodat -+# if HAVE_RAW_DECL_FCHMODAT -+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " -+ "use gnulib module openat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_FSTAT@ -+# if @REPLACE_FSTAT@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef fstat -+# define fstat rpl_fstat -+# endif -+_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); -+_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); -+# else -+_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); -+# endif -+_GL_CXXALIASWARN (fstat); -+#elif @WINDOWS_64_BIT_ST_SIZE@ -+/* Above, we define stat to _stati64. */ -+# define fstat _fstati64 -+#elif defined GNULIB_POSIXCHECK -+# undef fstat -+# if HAVE_RAW_DECL_FSTAT -+_GL_WARN_ON_USE (fstat, "fstat has portability problems - " -+ "use gnulib module fstat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_FSTATAT@ -+# if @REPLACE_FSTATAT@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef fstatat -+# define fstatat rpl_fstatat -+# endif -+_GL_FUNCDECL_RPL (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags) -+ _GL_ARG_NONNULL ((2, 3))); -+_GL_CXXALIAS_RPL (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags)); -+# else -+# if !@HAVE_FSTATAT@ -+_GL_FUNCDECL_SYS (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags) -+ _GL_ARG_NONNULL ((2, 3))); -+# endif -+_GL_CXXALIAS_SYS (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags)); -+# endif -+_GL_CXXALIASWARN (fstatat); -+#elif defined GNULIB_POSIXCHECK -+# undef fstatat -+# if HAVE_RAW_DECL_FSTATAT -+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - " -+ "use gnulib module openat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_FUTIMENS@ -+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens -+ implementation relies on futimesat, which on Solaris 10 makes an invocation -+ to futimens that is meant to invoke the libc's futimens(), not gnulib's -+ futimens(). */ -+# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun) -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef futimens -+# define futimens rpl_futimens -+# endif -+_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2])); -+_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2])); -+# else -+# if !@HAVE_FUTIMENS@ -+_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2])); -+# endif -+_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2])); -+# endif -+# if @HAVE_FUTIMENS@ -+_GL_CXXALIASWARN (futimens); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef futimens -+# if HAVE_RAW_DECL_FUTIMENS -+_GL_WARN_ON_USE (futimens, "futimens is not portable - " -+ "use gnulib module futimens for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_LCHMOD@ -+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME -+ denotes a symbolic link. */ -+# if !@HAVE_LCHMOD@ -+/* The lchmod replacement follows symbolic links. Callers should take -+ this into account; lchmod should be applied only to arguments that -+ are known to not be symbolic links. On hosts that lack lchmod, -+ this can lead to race conditions between the check and the -+ invocation of lchmod, but we know of no workarounds that are -+ reliable in general. You might try requesting support for lchmod -+ from your operating system supplier. */ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define lchmod chmod -+# endif -+/* Need to cast, because on mingw, the second parameter of chmod is -+ int mode. */ -+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int, -+ (const char *filename, mode_t mode)); -+# else -+# if 0 /* assume already declared */ -+_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); -+# endif -+# if @HAVE_LCHMOD@ -+_GL_CXXALIASWARN (lchmod); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef lchmod -+# if HAVE_RAW_DECL_LCHMOD -+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - " -+ "use gnulib module lchmod for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_LSTAT@ -+# if ! @HAVE_LSTAT@ -+/* mingw does not support symlinks, therefore it does not have lstat. But -+ without links, stat does just fine. */ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define lstat stat -+# endif -+_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf)); -+# elif @REPLACE_LSTAT@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef lstat -+# define lstat rpl_lstat -+# endif -+_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf)); -+# else -+_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf)); -+# endif -+# if @HAVE_LSTAT@ -+_GL_CXXALIASWARN (lstat); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef lstat -+# if HAVE_RAW_DECL_LSTAT -+_GL_WARN_ON_USE (lstat, "lstat is unportable - " -+ "use gnulib module lstat for portability"); -+# endif -+#endif -+ -+ -+#if @REPLACE_MKDIR@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef mkdir -+# define mkdir rpl_mkdir -+# endif -+_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); -+#else -+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. -+ Additionally, it declares _mkdir (and depending on compile flags, an -+ alias mkdir), only in the nonstandard includes and , -+ which are included above. */ -+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+ -+# if !GNULIB_defined_rpl_mkdir -+static int -+rpl_mkdir (char const *name, mode_t mode) -+{ -+ return _mkdir (name); -+} -+# define GNULIB_defined_rpl_mkdir 1 -+# endif -+ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define mkdir rpl_mkdir -+# endif -+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); -+# else -+_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); -+# endif -+#endif -+_GL_CXXALIASWARN (mkdir); -+ -+ -+#if @GNULIB_MKDIRAT@ -+# if !@HAVE_MKDIRAT@ -+_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)); -+_GL_CXXALIASWARN (mkdirat); -+#elif defined GNULIB_POSIXCHECK -+# undef mkdirat -+# if HAVE_RAW_DECL_MKDIRAT -+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - " -+ "use gnulib module openat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKFIFO@ -+# if @REPLACE_MKFIFO@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef mkfifo -+# define mkfifo rpl_mkfifo -+# endif -+_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode)); -+# else -+# if !@HAVE_MKFIFO@ -+_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode)); -+# endif -+_GL_CXXALIASWARN (mkfifo); -+#elif defined GNULIB_POSIXCHECK -+# undef mkfifo -+# if HAVE_RAW_DECL_MKFIFO -+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - " -+ "use gnulib module mkfifo for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKFIFOAT@ -+# if !@HAVE_MKFIFOAT@ -+_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); -+_GL_CXXALIASWARN (mkfifoat); -+#elif defined GNULIB_POSIXCHECK -+# undef mkfifoat -+# if HAVE_RAW_DECL_MKFIFOAT -+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - " -+ "use gnulib module mkfifoat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKNOD@ -+# if @REPLACE_MKNOD@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef mknod -+# define mknod rpl_mknod -+# endif -+_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)); -+# else -+# if !@HAVE_MKNOD@ -+_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev) -+ _GL_ARG_NONNULL ((1))); -+# endif -+/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */ -+_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev)); -+# endif -+_GL_CXXALIASWARN (mknod); -+#elif defined GNULIB_POSIXCHECK -+# undef mknod -+# if HAVE_RAW_DECL_MKNOD -+_GL_WARN_ON_USE (mknod, "mknod is not portable - " -+ "use gnulib module mknod for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKNODAT@ -+# if !@HAVE_MKNODAT@ -+_GL_FUNCDECL_SYS (mknodat, int, -+ (int fd, char const *file, mode_t mode, dev_t dev) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (mknodat, int, -+ (int fd, char const *file, mode_t mode, dev_t dev)); -+_GL_CXXALIASWARN (mknodat); -+#elif defined GNULIB_POSIXCHECK -+# undef mknodat -+# if HAVE_RAW_DECL_MKNODAT -+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - " -+ "use gnulib module mkfifoat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_STAT@ -+# if @REPLACE_STAT@ -+/* We can't use the object-like #define stat rpl_stat, because of -+ struct stat. This means that rpl_stat will not be used if the user -+ does (stat)(a,b). Oh well. */ -+# if defined _AIX && defined stat && defined _LARGE_FILES -+ /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, -+ so we have to replace stat64() instead of stat(). */ -+# undef stat64 -+# define stat64(name, st) rpl_stat (name, st) -+# elif @WINDOWS_64_BIT_ST_SIZE@ -+ /* Above, we define stat to _stati64. */ -+# if defined __MINGW32__ && defined _stati64 -+# ifndef _USE_32BIT_TIME_T -+ /* The system headers define _stati64 to _stat64. */ -+# undef _stat64 -+# define _stat64(name, st) rpl_stat (name, st) -+# endif -+# elif defined _MSC_VER && defined _stati64 -+# ifdef _USE_32BIT_TIME_T -+ /* The system headers define _stati64 to _stat32i64. */ -+# undef _stat32i64 -+# define _stat32i64(name, st) rpl_stat (name, st) -+# else -+ /* The system headers define _stati64 to _stat64. */ -+# undef _stat64 -+# define _stat64(name, st) rpl_stat (name, st) -+# endif -+# else -+# undef _stati64 -+# define _stati64(name, st) rpl_stat (name, st) -+# endif -+# elif defined __MINGW32__ && defined stat -+# ifdef _USE_32BIT_TIME_T -+ /* The system headers define stat to _stat32i64. */ -+# undef _stat32i64 -+# define _stat32i64(name, st) rpl_stat (name, st) -+# else -+ /* The system headers define stat to _stat64. */ -+# undef _stat64 -+# define _stat64(name, st) rpl_stat (name, st) -+# endif -+# elif defined _MSC_VER && defined stat -+# ifdef _USE_32BIT_TIME_T -+ /* The system headers define stat to _stat32. */ -+# undef _stat32 -+# define _stat32(name, st) rpl_stat (name, st) -+# else -+ /* The system headers define stat to _stat64i32. */ -+# undef _stat64i32 -+# define _stat64i32(name, st) rpl_stat (name, st) -+# endif -+# else /* !(_AIX ||__MINGW32__ || _MSC_VER) */ -+# undef stat -+# define stat(name, st) rpl_stat (name, st) -+# endif /* !_LARGE_FILES */ -+_GL_EXTERN_C int stat (const char *name, struct stat *buf) -+ _GL_ARG_NONNULL ((1, 2)); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef stat -+# if HAVE_RAW_DECL_STAT -+_GL_WARN_ON_USE (stat, "stat is unportable - " -+ "use gnulib module stat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_UTIMENSAT@ -+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat -+ implementation relies on futimesat, which on Solaris 10 makes an invocation -+ to utimensat that is meant to invoke the libc's utimensat(), not gnulib's -+ utimensat(). */ -+# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun) -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef utimensat -+# define utimensat rpl_utimensat -+# endif -+_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag) -+ _GL_ARG_NONNULL ((2))); -+_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag)); -+# else -+# if !@HAVE_UTIMENSAT@ -+_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag)); -+# endif -+# if @HAVE_UTIMENSAT@ -+_GL_CXXALIASWARN (utimensat); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef utimensat -+# if HAVE_RAW_DECL_UTIMENSAT -+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - " -+ "use gnulib module utimensat for portability"); -+# endif -+#endif -+ -+ -+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ -+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ -+#endif -diff --git a/grub-core/gnulib/sys_time.in.h b/grub-core/gnulib/sys_time.in.h -new file mode 100644 -index 0000000..30057ad ---- /dev/null -+++ b/grub-core/gnulib/sys_time.in.h -@@ -0,0 +1,213 @@ -+/* Provide a more complete sys/time.h. -+ -+ Copyright (C) 2007-2014 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 -+ the Free Software Foundation; either version 3, 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, see . */ -+ -+/* Written by Paul Eggert. */ -+ -+#ifndef _@GUARD_PREFIX@_SYS_TIME_H -+ -+#if __GNUC__ >= 3 -+@PRAGMA_SYSTEM_HEADER@ -+#endif -+@PRAGMA_COLUMNS@ -+ -+/* On Cygwin and on many BSDish systems, includes itself -+ recursively via . -+ Simply delegate to the system's header in this case; it is a no-op. -+ Without this extra ifdef, the C++ gettimeofday declaration below -+ would be a forward declaration in gnulib's nested . */ -+#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_ -+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ -+#else -+ -+/* The include_next requires a split double-inclusion guard. */ -+#if @HAVE_SYS_TIME_H@ -+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ -+#endif -+ -+#ifndef _@GUARD_PREFIX@_SYS_TIME_H -+#define _@GUARD_PREFIX@_SYS_TIME_H -+ -+#if ! @HAVE_SYS_TIME_H@ -+# include -+#endif -+ -+/* On native Windows with MSVC, get the 'struct timeval' type. -+ Also, on native Windows with a 64-bit time_t, where we are overriding the -+ 'struct timeval' type, get all declarations of system functions whose -+ signature contains 'struct timeval'. */ -+#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H -+# define _GL_INCLUDING_WINSOCK2_H -+# include -+# undef _GL_INCLUDING_WINSOCK2_H -+#endif -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ -+ -+# if @REPLACE_STRUCT_TIMEVAL@ -+# define timeval rpl_timeval -+# endif -+ -+# if !GNULIB_defined_struct_timeval -+struct timeval -+{ -+ time_t tv_sec; -+ long int tv_usec; -+}; -+# define GNULIB_defined_struct_timeval 1 -+# endif -+ -+#endif -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#if @GNULIB_GETTIMEOFDAY@ -+# if @REPLACE_GETTIMEOFDAY@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gettimeofday -+# define gettimeofday rpl_gettimeofday -+# endif -+_GL_FUNCDECL_RPL (gettimeofday, int, -+ (struct timeval *restrict, void *restrict) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (gettimeofday, int, -+ (struct timeval *restrict, void *restrict)); -+# else -+# if !@HAVE_GETTIMEOFDAY@ -+_GL_FUNCDECL_SYS (gettimeofday, int, -+ (struct timeval *restrict, void *restrict) -+ _GL_ARG_NONNULL ((1))); -+# endif -+/* Need to cast, because on glibc systems, by default, the second argument is -+ struct timezone *. */ -+_GL_CXXALIAS_SYS_CAST (gettimeofday, int, -+ (struct timeval *restrict, void *restrict)); -+# endif -+_GL_CXXALIASWARN (gettimeofday); -+#elif defined GNULIB_POSIXCHECK -+# undef gettimeofday -+# if HAVE_RAW_DECL_GETTIMEOFDAY -+_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " -+ "use gnulib module gettimeofday for portability"); -+# endif -+#endif -+ -+/* Hide some function declarations from . */ -+ -+#if defined _MSC_VER && @HAVE_WINSOCK2_H@ -+# if !defined _@GUARD_PREFIX@_UNISTD_H -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef close -+# define close close_used_without_including_unistd_h -+# else -+ _GL_WARN_ON_USE (close, -+ "close() used without including "); -+# endif -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gethostname -+# define gethostname gethostname_used_without_including_unistd_h -+# else -+ _GL_WARN_ON_USE (gethostname, -+ "gethostname() used without including "); -+# endif -+# endif -+# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef socket -+# define socket socket_used_without_including_sys_socket_h -+# undef connect -+# define connect connect_used_without_including_sys_socket_h -+# undef accept -+# define accept accept_used_without_including_sys_socket_h -+# undef bind -+# define bind bind_used_without_including_sys_socket_h -+# undef getpeername -+# define getpeername getpeername_used_without_including_sys_socket_h -+# undef getsockname -+# define getsockname getsockname_used_without_including_sys_socket_h -+# undef getsockopt -+# define getsockopt getsockopt_used_without_including_sys_socket_h -+# undef listen -+# define listen listen_used_without_including_sys_socket_h -+# undef recv -+# define recv recv_used_without_including_sys_socket_h -+# undef send -+# define send send_used_without_including_sys_socket_h -+# undef recvfrom -+# define recvfrom recvfrom_used_without_including_sys_socket_h -+# undef sendto -+# define sendto sendto_used_without_including_sys_socket_h -+# undef setsockopt -+# define setsockopt setsockopt_used_without_including_sys_socket_h -+# undef shutdown -+# define shutdown shutdown_used_without_including_sys_socket_h -+# else -+ _GL_WARN_ON_USE (socket, -+ "socket() used without including "); -+ _GL_WARN_ON_USE (connect, -+ "connect() used without including "); -+ _GL_WARN_ON_USE (accept, -+ "accept() used without including "); -+ _GL_WARN_ON_USE (bind, -+ "bind() used without including "); -+ _GL_WARN_ON_USE (getpeername, -+ "getpeername() used without including "); -+ _GL_WARN_ON_USE (getsockname, -+ "getsockname() used without including "); -+ _GL_WARN_ON_USE (getsockopt, -+ "getsockopt() used without including "); -+ _GL_WARN_ON_USE (listen, -+ "listen() used without including "); -+ _GL_WARN_ON_USE (recv, -+ "recv() used without including "); -+ _GL_WARN_ON_USE (send, -+ "send() used without including "); -+ _GL_WARN_ON_USE (recvfrom, -+ "recvfrom() used without including "); -+ _GL_WARN_ON_USE (sendto, -+ "sendto() used without including "); -+ _GL_WARN_ON_USE (setsockopt, -+ "setsockopt() used without including "); -+ _GL_WARN_ON_USE (shutdown, -+ "shutdown() used without including "); -+# endif -+# endif -+# if !defined _@GUARD_PREFIX@_SYS_SELECT_H -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef select -+# define select select_used_without_including_sys_select_h -+# else -+ _GL_WARN_ON_USE (select, -+ "select() used without including "); -+# endif -+# endif -+#endif -+ -+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ -+#endif /* _CYGWIN_SYS_TIME_H */ -+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ -diff --git a/grub-core/gnulib/sys_types.in.h b/grub-core/gnulib/sys_types.in.h -index d7da356..9520c09 100644 ---- a/grub-core/gnulib/sys_types.in.h -+++ b/grub-core/gnulib/sys_types.in.h -@@ -23,7 +23,9 @@ - #ifndef _@GUARD_PREFIX@_SYS_TYPES_H - - /* The include_next requires a split double-inclusion guard. */ -+# define _GL_INCLUDING_SYS_TYPES_H - #@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ -+# undef _GL_INCLUDING_SYS_TYPES_H - - #ifndef _@GUARD_PREFIX@_SYS_TYPES_H - #define _@GUARD_PREFIX@_SYS_TYPES_H -diff --git a/grub-core/gnulib/time.h b/grub-core/gnulib/time.h -new file mode 100644 -index 0000000..b9203d5 ---- /dev/null -+++ b/grub-core/gnulib/time.h -@@ -0,0 +1,586 @@ -+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -+/* A more-standard . -+ -+ Copyright (C) 2007-2014 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 -+ the Free Software Foundation; either version 3, 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, see . */ -+ -+#if __GNUC__ >= 3 -+#pragma GCC system_header -+#endif -+ -+ -+/* Don't get in the way of glibc when it includes time.h merely to -+ declare a few standard symbols, rather than to declare all the -+ symbols. Also, Solaris 8 eventually includes itself -+ recursively; if that is happening, just include the system -+ without adding our own declarations. */ -+#if (defined __need_time_t || defined __need_clock_t \ -+ || defined __need_timespec \ -+ || defined _GL_TIME_H) -+ -+# include_next -+ -+#else -+ -+# define _GL_TIME_H -+ -+# include_next -+ -+/* NetBSD 5.0 mis-defines NULL. */ -+# include -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+#ifndef _GL_CXXDEFS_H -+#define _GL_CXXDEFS_H -+ -+/* The three most frequent use cases of these macros are: -+ -+ * For providing a substitute for a function that is missing on some -+ platforms, but is declared and works fine on the platforms on which -+ it exists: -+ -+ #if @GNULIB_FOO@ -+ # if !@HAVE_FOO@ -+ _GL_FUNCDECL_SYS (foo, ...); -+ # endif -+ _GL_CXXALIAS_SYS (foo, ...); -+ _GL_CXXALIASWARN (foo); -+ #elif defined GNULIB_POSIXCHECK -+ ... -+ #endif -+ -+ * For providing a replacement for a function that exists on all platforms, -+ but is broken/insufficient and needs to be replaced on some platforms: -+ -+ #if @GNULIB_FOO@ -+ # if @REPLACE_FOO@ -+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+ # undef foo -+ # define foo rpl_foo -+ # endif -+ _GL_FUNCDECL_RPL (foo, ...); -+ _GL_CXXALIAS_RPL (foo, ...); -+ # else -+ _GL_CXXALIAS_SYS (foo, ...); -+ # endif -+ _GL_CXXALIASWARN (foo); -+ #elif defined GNULIB_POSIXCHECK -+ ... -+ #endif -+ -+ * For providing a replacement for a function that exists on some platforms -+ but is broken/insufficient and needs to be replaced on some of them and -+ is additionally either missing or undeclared on some other platforms: -+ -+ #if @GNULIB_FOO@ -+ # if @REPLACE_FOO@ -+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+ # undef foo -+ # define foo rpl_foo -+ # endif -+ _GL_FUNCDECL_RPL (foo, ...); -+ _GL_CXXALIAS_RPL (foo, ...); -+ # else -+ # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ -+ _GL_FUNCDECL_SYS (foo, ...); -+ # endif -+ _GL_CXXALIAS_SYS (foo, ...); -+ # endif -+ _GL_CXXALIASWARN (foo); -+ #elif defined GNULIB_POSIXCHECK -+ ... -+ #endif -+*/ -+ -+/* _GL_EXTERN_C declaration; -+ performs the declaration with C linkage. */ -+#if defined __cplusplus -+# define _GL_EXTERN_C extern "C" -+#else -+# define _GL_EXTERN_C extern -+#endif -+ -+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); -+ declares a replacement function, named rpl_func, with the given prototype, -+ consisting of return type, parameters, and attributes. -+ Example: -+ _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) -+ _GL_ARG_NONNULL ((1))); -+ */ -+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ -+ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) -+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ -+ _GL_EXTERN_C rettype rpl_func parameters_and_attributes -+ -+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); -+ declares the system function, named func, with the given prototype, -+ consisting of return type, parameters, and attributes. -+ Example: -+ _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) -+ _GL_ARG_NONNULL ((1))); -+ */ -+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ -+ _GL_EXTERN_C rettype func parameters_and_attributes -+ -+/* _GL_CXXALIAS_RPL (func, rettype, parameters); -+ declares a C++ alias called GNULIB_NAMESPACE::func -+ that redirects to rpl_func, if GNULIB_NAMESPACE is defined. -+ Example: -+ _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); -+ */ -+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ -+ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ rettype (*const func) parameters = ::rpl_func; \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); -+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); -+ except that the C function rpl_func may have a slightly different -+ declaration. A cast is used to silence the "invalid conversion" error -+ that would otherwise occur. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ rettype (*const func) parameters = \ -+ reinterpret_cast(::rpl_func); \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_SYS (func, rettype, parameters); -+ declares a C++ alias called GNULIB_NAMESPACE::func -+ that redirects to the system provided function func, if GNULIB_NAMESPACE -+ is defined. -+ Example: -+ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); -+ */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+ /* If we were to write -+ rettype (*const func) parameters = ::func; -+ like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls -+ better (remove an indirection through a 'static' pointer variable), -+ but then the _GL_CXXALIASWARN macro below would cause a warning not only -+ for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ -+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ static rettype (*func) parameters = ::func; \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); -+ is like _GL_CXXALIAS_SYS (func, rettype, parameters); -+ except that the C function func may have a slightly different declaration. -+ A cast is used to silence the "invalid conversion" error that would -+ otherwise occur. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ static rettype (*func) parameters = \ -+ reinterpret_cast(::func); \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); -+ is like _GL_CXXALIAS_SYS (func, rettype, parameters); -+ except that the C function is picked among a set of overloaded functions, -+ namely the one with rettype2 and parameters2. Two consecutive casts -+ are used to silence the "cannot find a match" and "invalid conversion" -+ errors that would otherwise occur. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+ /* The outer cast must be a reinterpret_cast. -+ The inner cast: When the function is defined as a set of overloaded -+ functions, it works as a static_cast<>, choosing the designated variant. -+ When the function is defined as a single variant, it works as a -+ reinterpret_cast<>. The parenthesized cast syntax works both ways. */ -+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ static rettype (*func) parameters = \ -+ reinterpret_cast( \ -+ (rettype2(*)parameters2)(::func)); \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIASWARN (func); -+ causes a warning to be emitted when ::func is used but not when -+ GNULIB_NAMESPACE::func is used. func must be defined without overloaded -+ variants. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIASWARN(func) \ -+ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) -+# define _GL_CXXALIASWARN_1(func,namespace) \ -+ _GL_CXXALIASWARN_2 (func, namespace) -+/* To work around GCC bug , -+ we enable the warning only when not optimizing. */ -+# if !__OPTIMIZE__ -+# define _GL_CXXALIASWARN_2(func,namespace) \ -+ _GL_WARN_ON_USE (func, \ -+ "The symbol ::" #func " refers to the system function. " \ -+ "Use " #namespace "::" #func " instead.") -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+# define _GL_CXXALIASWARN_2(func,namespace) \ -+ extern __typeof__ (func) func -+# else -+# define _GL_CXXALIASWARN_2(func,namespace) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+# endif -+#else -+# define _GL_CXXALIASWARN(func) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); -+ causes a warning to be emitted when the given overloaded variant of ::func -+ is used but not when GNULIB_NAMESPACE::func is used. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ -+ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ -+ GNULIB_NAMESPACE) -+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ -+ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -+/* To work around GCC bug , -+ we enable the warning only when not optimizing. */ -+# if !__OPTIMIZE__ -+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ -+ _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ -+ "The symbol ::" #func " refers to the system function. " \ -+ "Use " #namespace "::" #func " instead.") -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ -+ extern __typeof__ (func) func -+# else -+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+# endif -+#else -+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+#endif /* _GL_CXXDEFS_H */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools -+ that the values passed as arguments n, ..., m must be non-NULL pointers. -+ n = 1 stands for the first argument, n = 2 for the second argument etc. */ -+#ifndef _GL_ARG_NONNULL -+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 -+# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) -+# else -+# define _GL_ARG_NONNULL(params) -+# endif -+#endif -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+#ifndef _GL_WARN_ON_USE -+ -+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -+/* A compiler attribute is available in gcc versions 4.3.0 and later. */ -+# define _GL_WARN_ON_USE(function, message) \ -+extern __typeof__ (function) function __attribute__ ((__warning__ (message))) -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+/* Verify the existence of the function. */ -+# define _GL_WARN_ON_USE(function, message) \ -+extern __typeof__ (function) function -+# else /* Unsupported. */ -+# define _GL_WARN_ON_USE(function, message) \ -+_GL_WARN_EXTERN_C int _gl_warn_on_use -+# endif -+#endif -+ -+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") -+ is like _GL_WARN_ON_USE (function, "string"), except that the function is -+ declared with the given prototype, consisting of return type, parameters, -+ and attributes. -+ This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does -+ not work in this case. */ -+#ifndef _GL_WARN_ON_USE_CXX -+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -+extern rettype function parameters_and_attributes \ -+ __attribute__ ((__warning__ (msg))) -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+/* Verify the existence of the function. */ -+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -+extern rettype function parameters_and_attributes -+# else /* Unsupported. */ -+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -+_GL_WARN_EXTERN_C int _gl_warn_on_use -+# endif -+#endif -+ -+/* _GL_WARN_EXTERN_C declaration; -+ performs the declaration with C linkage. */ -+#ifndef _GL_WARN_EXTERN_C -+# if defined __cplusplus -+# define _GL_WARN_EXTERN_C extern "C" -+# else -+# define _GL_WARN_EXTERN_C extern -+# endif -+#endif -+ -+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). -+ Or they define it with the wrong member names or define it in -+ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, -+ but the pthreads-win32 library defines it in . */ -+# if ! 1 -+# if 0 -+# include -+# elif 0 -+# include -+# else -+ -+# ifdef __cplusplus -+extern "C" { -+# endif -+ -+# if !GNULIB_defined_struct_timespec -+# undef timespec -+# define timespec rpl_timespec -+struct timespec -+{ -+ time_t tv_sec; -+ long int tv_nsec; -+}; -+# define GNULIB_defined_struct_timespec 1 -+# endif -+ -+# ifdef __cplusplus -+} -+# endif -+ -+# endif -+# endif -+ -+# if !GNULIB_defined_struct_time_t_must_be_integral -+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires -+ time_t to be an integer type, even though C99 permits floating -+ point. We don't know of any implementation that uses floating -+ point, and it is much easier to write code that doesn't have to -+ worry about that corner case, so we force the issue. */ -+struct __time_t_must_be_integral { -+ unsigned int __floating_time_t_unsupported : (time_t) 1; -+}; -+# define GNULIB_defined_struct_time_t_must_be_integral 1 -+# endif -+ -+/* Sleep for at least RQTP seconds unless interrupted, If interrupted, -+ return -1 and store the remaining time into RMTP. See -+ . */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define nanosleep rpl_nanosleep -+# endif -+_GL_FUNCDECL_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# endif -+_GL_CXXALIASWARN (nanosleep); -+# endif -+ -+/* Return the 'time_t' representation of TP and normalize TP. */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define mktime rpl_mktime -+# endif -+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); -+# else -+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); -+# endif -+_GL_CXXALIASWARN (mktime); -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime_r -+# define localtime_r rpl_localtime_r -+# endif -+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if 1 -+_GL_CXXALIASWARN (localtime_r); -+# endif -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime_r -+# define gmtime_r rpl_gmtime_r -+# endif -+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if 1 -+_GL_CXXALIASWARN (gmtime_r); -+# endif -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if 1 -+# if 0 -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime -+# define localtime rpl_localtime -+# endif -+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (localtime); -+# endif -+ -+# if 1 -+# if 0 -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime -+# define gmtime rpl_gmtime -+# endif -+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (gmtime); -+# endif -+ -+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store -+ the resulting broken-down time into TM. See -+ . */ -+# if 0 -+# if ! 1 -+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm) -+ _GL_ARG_NONNULL ((1, 2, 3))); -+# endif -+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm)); -+_GL_CXXALIASWARN (strptime); -+# endif -+ -+/* Convert TM to a time_t value, assuming UTC. */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef timegm -+# define timegm rpl_timegm -+# endif -+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); -+# endif -+_GL_CXXALIASWARN (timegm); -+# endif -+ -+/* Encourage applications to avoid unsafe functions that can overrun -+ buffers when given outlandish struct tm values. Portable -+ applications should use strftime (or even sprintf) instead. */ -+# if defined GNULIB_POSIXCHECK -+# undef asctime -+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef asctime_r -+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime -+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime_r -+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+ -+#endif -diff --git a/grub-core/gnulib/time.in.h b/grub-core/gnulib/time.in.h -new file mode 100644 -index 0000000..81abdf4 ---- /dev/null -+++ b/grub-core/gnulib/time.in.h -@@ -0,0 +1,274 @@ -+/* A more-standard . -+ -+ Copyright (C) 2007-2014 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 -+ the Free Software Foundation; either version 3, 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, see . */ -+ -+#if __GNUC__ >= 3 -+@PRAGMA_SYSTEM_HEADER@ -+#endif -+@PRAGMA_COLUMNS@ -+ -+/* Don't get in the way of glibc when it includes time.h merely to -+ declare a few standard symbols, rather than to declare all the -+ symbols. Also, Solaris 8 eventually includes itself -+ recursively; if that is happening, just include the system -+ without adding our own declarations. */ -+#if (defined __need_time_t || defined __need_clock_t \ -+ || defined __need_timespec \ -+ || defined _@GUARD_PREFIX@_TIME_H) -+ -+# @INCLUDE_NEXT@ @NEXT_TIME_H@ -+ -+#else -+ -+# define _@GUARD_PREFIX@_TIME_H -+ -+# @INCLUDE_NEXT@ @NEXT_TIME_H@ -+ -+/* NetBSD 5.0 mis-defines NULL. */ -+# include -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+ -+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). -+ Or they define it with the wrong member names or define it in -+ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, -+ but the pthreads-win32 library defines it in . */ -+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ -+# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ -+# include -+# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ -+# include -+# else -+ -+# ifdef __cplusplus -+extern "C" { -+# endif -+ -+# if !GNULIB_defined_struct_timespec -+# undef timespec -+# define timespec rpl_timespec -+struct timespec -+{ -+ time_t tv_sec; -+ long int tv_nsec; -+}; -+# define GNULIB_defined_struct_timespec 1 -+# endif -+ -+# ifdef __cplusplus -+} -+# endif -+ -+# endif -+# endif -+ -+# if !GNULIB_defined_struct_time_t_must_be_integral -+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires -+ time_t to be an integer type, even though C99 permits floating -+ point. We don't know of any implementation that uses floating -+ point, and it is much easier to write code that doesn't have to -+ worry about that corner case, so we force the issue. */ -+struct __time_t_must_be_integral { -+ unsigned int __floating_time_t_unsupported : (time_t) 1; -+}; -+# define GNULIB_defined_struct_time_t_must_be_integral 1 -+# endif -+ -+/* Sleep for at least RQTP seconds unless interrupted, If interrupted, -+ return -1 and store the remaining time into RMTP. See -+ . */ -+# if @GNULIB_NANOSLEEP@ -+# if @REPLACE_NANOSLEEP@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define nanosleep rpl_nanosleep -+# endif -+_GL_FUNCDECL_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# else -+# if ! @HAVE_NANOSLEEP@ -+_GL_FUNCDECL_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# endif -+_GL_CXXALIASWARN (nanosleep); -+# endif -+ -+/* Return the 'time_t' representation of TP and normalize TP. */ -+# if @GNULIB_MKTIME@ -+# if @REPLACE_MKTIME@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define mktime rpl_mktime -+# endif -+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); -+# else -+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); -+# endif -+_GL_CXXALIASWARN (mktime); -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if @GNULIB_TIME_R@ -+# if @REPLACE_LOCALTIME_R@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime_r -+# define localtime_r rpl_localtime_r -+# endif -+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! @HAVE_DECL_LOCALTIME_R@ -+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if @HAVE_DECL_LOCALTIME_R@ -+_GL_CXXALIASWARN (localtime_r); -+# endif -+# if @REPLACE_LOCALTIME_R@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime_r -+# define gmtime_r rpl_gmtime_r -+# endif -+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! @HAVE_DECL_LOCALTIME_R@ -+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if @HAVE_DECL_LOCALTIME_R@ -+_GL_CXXALIASWARN (gmtime_r); -+# endif -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if @GNULIB_GETTIMEOFDAY@ -+# if @REPLACE_LOCALTIME@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime -+# define localtime rpl_localtime -+# endif -+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (localtime); -+# endif -+ -+# if @GNULIB_GETTIMEOFDAY@ -+# if @REPLACE_GMTIME@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime -+# define gmtime rpl_gmtime -+# endif -+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (gmtime); -+# endif -+ -+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store -+ the resulting broken-down time into TM. See -+ . */ -+# if @GNULIB_STRPTIME@ -+# if ! @HAVE_STRPTIME@ -+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm) -+ _GL_ARG_NONNULL ((1, 2, 3))); -+# endif -+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm)); -+_GL_CXXALIASWARN (strptime); -+# endif -+ -+/* Convert TM to a time_t value, assuming UTC. */ -+# if @GNULIB_TIMEGM@ -+# if @REPLACE_TIMEGM@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef timegm -+# define timegm rpl_timegm -+# endif -+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); -+# else -+# if ! @HAVE_TIMEGM@ -+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); -+# endif -+_GL_CXXALIASWARN (timegm); -+# endif -+ -+/* Encourage applications to avoid unsafe functions that can overrun -+ buffers when given outlandish struct tm values. Portable -+ applications should use strftime (or even sprintf) instead. */ -+# if defined GNULIB_POSIXCHECK -+# undef asctime -+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef asctime_r -+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime -+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime_r -+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+ -+#endif -diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c -index 85507af..6f49df4 100644 ---- a/grub-core/osdep/windows/hostdisk.c -+++ b/grub-core/osdep/windows/hostdisk.c -@@ -353,6 +353,12 @@ grub_util_mkdir (const char *dir) - free (windows_name); - } - -+ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - int - grub_util_rename (const char *from, const char *to) - { -diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h -index a059c0f..161fbb7 100644 ---- a/include/grub/osdep/hostfile_aros.h -+++ b/include/grub/osdep/hostfile_aros.h -@@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to) - return rename (from, to); - } - -+static inline ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - #define grub_util_mkdir(a) mkdir ((a), 0755) - - struct grub_util_fd -diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h -index 9ffe46f..17cd3aa 100644 ---- a/include/grub/osdep/hostfile_unix.h -+++ b/include/grub/osdep/hostfile_unix.h -@@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to) - return rename (from, to); - } - -+static inline ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - #define grub_util_mkdir(a) mkdir ((a), 0755) - - #if defined (__NetBSD__) -diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h -index bf6451b..8c92d05 100644 ---- a/include/grub/osdep/hostfile_windows.h -+++ b/include/grub/osdep/hostfile_windows.h -@@ -41,6 +41,8 @@ typedef struct grub_util_fd_dir *grub_util_fd_dir_t; - - int - grub_util_rename (const char *from, const char *to); -+ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize); - int - grub_util_unlink (const char *name); - void -diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 -new file mode 100644 -index 0000000..1c2d66e ---- /dev/null -+++ b/m4/gettimeofday.m4 -@@ -0,0 +1,138 @@ -+# serial 21 -+ -+# Copyright (C) 2001-2003, 2005, 2007, 2009-2014 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. -+ -+dnl From Jim Meyering. -+ -+AC_DEFUN([gl_FUNC_GETTIMEOFDAY], -+[ -+ AC_REQUIRE([AC_C_RESTRICT]) -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H]) -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) -+ AC_CHECK_FUNCS_ONCE([gettimeofday]) -+ -+ gl_gettimeofday_timezone=void -+ if test $ac_cv_func_gettimeofday != yes; then -+ HAVE_GETTIMEOFDAY=0 -+ else -+ gl_FUNC_GETTIMEOFDAY_CLOBBER -+ AC_CACHE_CHECK([for gettimeofday with POSIX signature], -+ [gl_cv_func_gettimeofday_posix_signature], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ struct timeval c; -+ int gettimeofday (struct timeval *restrict, void *restrict); -+ ]], -+ [[/* glibc uses struct timezone * rather than the POSIX void * -+ if _GNU_SOURCE is defined. However, since the only portable -+ use of gettimeofday uses NULL as the second parameter, and -+ since the glibc definition is actually more typesafe, it is -+ not worth wrapping this to get a compliant signature. */ -+ int (*f) (struct timeval *restrict, void *restrict) -+ = gettimeofday; -+ int x = f (&c, 0); -+ return !(x | c.tv_sec | c.tv_usec); -+ ]])], -+ [gl_cv_func_gettimeofday_posix_signature=yes], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+int gettimeofday (struct timeval *restrict, struct timezone *restrict); -+ ]])], -+ [gl_cv_func_gettimeofday_posix_signature=almost], -+ [gl_cv_func_gettimeofday_posix_signature=no])])]) -+ if test $gl_cv_func_gettimeofday_posix_signature = almost; then -+ gl_gettimeofday_timezone='struct timezone' -+ elif test $gl_cv_func_gettimeofday_posix_signature != yes; then -+ REPLACE_GETTIMEOFDAY=1 -+ fi -+ dnl If we override 'struct timeval', we also have to override gettimeofday. -+ if test $REPLACE_STRUCT_TIMEVAL = 1; then -+ REPLACE_GETTIMEOFDAY=1 -+ fi -+ m4_ifdef([gl_FUNC_TZSET_CLOBBER], [ -+ gl_FUNC_TZSET_CLOBBER -+ case "$gl_cv_func_tzset_clobber" in -+ *yes) -+ REPLACE_GETTIMEOFDAY=1 -+ gl_GETTIMEOFDAY_REPLACE_LOCALTIME -+ AC_DEFINE([tzset], [rpl_tzset], -+ [Define to rpl_tzset if the wrapper function should be used.]) -+ AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1], -+ [Define if tzset clobbers localtime's static buffer.]) -+ ;; -+ esac -+ ]) -+ fi -+ AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone], -+ [Define this to 'void' or 'struct timezone' to match the system's -+ declaration of the second argument to gettimeofday.]) -+]) -+ -+ -+dnl See if gettimeofday clobbers the static buffer that localtime uses -+dnl for its return value. The gettimeofday function from Mac OS X 10.0.4 -+dnl (i.e., Darwin 1.3.7) has this problem. -+dnl -+dnl If it does, then arrange to use gettimeofday and localtime only via -+dnl the wrapper functions that work around the problem. -+ -+AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], -+[ -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H]) -+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles -+ -+ AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], -+ [gl_cv_func_gettimeofday_clobber], -+ [AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ #include -+ #include -+ #include -+ ]], -+ [[ -+ time_t t = 0; -+ struct tm *lt; -+ struct tm saved_lt; -+ struct timeval tv; -+ lt = localtime (&t); -+ saved_lt = *lt; -+ gettimeofday (&tv, NULL); -+ return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; -+ ]])], -+ [gl_cv_func_gettimeofday_clobber=no], -+ [gl_cv_func_gettimeofday_clobber=yes], -+ [# When cross-compiling: -+ case "$host_os" in -+ # Guess all is fine on glibc systems. -+ *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; -+ # If we don't know, assume the worst. -+ *) gl_cv_func_gettimeofday_clobber="guessing yes" ;; -+ esac -+ ])]) -+ -+ case "$gl_cv_func_gettimeofday_clobber" in -+ *yes) -+ REPLACE_GETTIMEOFDAY=1 -+ gl_GETTIMEOFDAY_REPLACE_LOCALTIME -+ AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1], -+ [Define if gettimeofday clobbers the localtime buffer.]) -+ ;; -+ esac -+]) -+ -+AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [ -+ REPLACE_GMTIME=1 -+ REPLACE_LOCALTIME=1 -+]) -+ -+# Prerequisites of lib/gettimeofday.c. -+AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [ -+ AC_CHECK_HEADERS([sys/timeb.h]) -+ AC_CHECK_FUNCS([_ftime]) -+]) -diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 -index 4089184..ef2ec5b 100644 ---- a/m4/gnulib-cache.m4 -+++ b/m4/gnulib-cache.m4 -@@ -27,7 +27,7 @@ - - - # Specification in the form of a command-line invocation: --# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex -+# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex - - # Specification in the form of a few gnulib-tool.m4 macro invocations: - gl_LOCAL_DIR([]) -@@ -39,6 +39,7 @@ gl_MODULES([ - getline - gettext - progname -+ readlink - regex - ]) - gl_AVOID([]) -diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 -index 7a19f60..66fd0ed 100644 ---- a/m4/gnulib-comp.m4 -+++ b/m4/gnulib-comp.m4 -@@ -60,10 +60,13 @@ AC_DEFUN([gl_EARLY], - # Code from module getopt-posix: - # Code from module gettext: - # Code from module gettext-h: -+ # Code from module gettimeofday: - # Code from module havelib: - # Code from module include_next: - # Code from module intprops: - # Code from module langinfo: -+ # Code from module largefile: -+ AC_REQUIRE([AC_SYS_LARGEFILE]) - # Code from module localcharset: - # Code from module locale: - # Code from module localeconv: -@@ -81,8 +84,10 @@ AC_DEFUN([gl_EARLY], - # Code from module multiarch: - # Code from module nl_langinfo: - # Code from module nocrash: -+ # Code from module pathmax: - # Code from module progname: - # Code from module rawmemchr: -+ # Code from module readlink: - # Code from module realloc-posix: - # Code from module regex: - # Code from module size_max: -@@ -92,6 +97,7 @@ AC_DEFUN([gl_EARLY], - # Code from module snippet/c++defs: - # Code from module snippet/warn-on-use: - # Code from module ssize_t: -+ # Code from module stat: - # Code from module stdalign: - # Code from module stdbool: - # Code from module stddef: -@@ -108,8 +114,11 @@ AC_DEFUN([gl_EARLY], - # Code from module strndup: - # Code from module strnlen: - # Code from module strnlen1: -+ # Code from module sys_stat: -+ # Code from module sys_time: - # Code from module sys_types: - # Code from module sysexits: -+ # Code from module time: - # Code from module unistd: - # Code from module unitypes: - # Code from module uniwidth/base: -@@ -211,7 +220,14 @@ AC_DEFUN([gl_INIT], - AM_GNU_GETTEXT_VERSION([0.18.1]) - AC_SUBST([LIBINTL]) - AC_SUBST([LTLIBINTL]) -+ gl_FUNC_GETTIMEOFDAY -+ if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then -+ AC_LIBOBJ([gettimeofday]) -+ gl_PREREQ_GETTIMEOFDAY -+ fi -+ gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) - gl_LANGINFO_H -+ AC_REQUIRE([gl_LARGEFILE]) - gl_LOCALCHARSET - LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" - AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) -@@ -284,6 +300,7 @@ AC_DEFUN([gl_INIT], - AC_LIBOBJ([nl_langinfo]) - fi - gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) -+ gl_PATHMAX - AC_CHECK_DECLS([program_invocation_name], [], [], [#include ]) - AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ]) - gl_FUNC_RAWMEMCHR -@@ -292,6 +309,12 @@ AC_DEFUN([gl_INIT], - gl_PREREQ_RAWMEMCHR - fi - gl_STRING_MODULE_INDICATOR([rawmemchr]) -+ gl_FUNC_READLINK -+ if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then -+ AC_LIBOBJ([readlink]) -+ gl_PREREQ_READLINK -+ fi -+ gl_UNISTD_MODULE_INDICATOR([readlink]) - gl_FUNC_REALLOC_POSIX - if test $REPLACE_REALLOC = 1; then - AC_LIBOBJ([realloc]) -@@ -309,6 +332,12 @@ AC_DEFUN([gl_INIT], - fi - gl_UNISTD_MODULE_INDICATOR([sleep]) - gt_TYPE_SSIZE_T -+ gl_FUNC_STAT -+ if test $REPLACE_STAT = 1; then -+ AC_LIBOBJ([stat]) -+ gl_PREREQ_STAT -+ fi -+ gl_SYS_STAT_MODULE_INDICATOR([stat]) - gl_STDALIGN_H - AM_STDBOOL_H - gl_STDDEF_H -@@ -355,9 +384,14 @@ AC_DEFUN([gl_INIT], - gl_PREREQ_STRNLEN - fi - gl_STRING_MODULE_INDICATOR([strnlen]) -+ gl_HEADER_SYS_STAT_H -+ AC_PROG_MKDIR_P -+ gl_HEADER_SYS_TIME_H -+ AC_PROG_MKDIR_P - gl_SYS_TYPES_H - AC_PROG_MKDIR_P - gl_SYSEXITS -+ gl_HEADER_TIME_H - gl_UNISTD_H - gl_LIBUNISTRING_LIBHEADER([0.9], [unitypes.h]) - gl_LIBUNISTRING_LIBHEADER([0.9], [uniwidth.h]) -@@ -562,6 +596,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/getopt1.c - lib/getopt_int.h - lib/gettext.h -+ lib/gettimeofday.c - lib/intprops.h - lib/itold.c - lib/langinfo.in.h -@@ -587,6 +622,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/msvc-nothrow.c - lib/msvc-nothrow.h - lib/nl_langinfo.c -+ lib/pathmax.h - lib/printf-args.c - lib/printf-args.h - lib/printf-parse.c -@@ -595,6 +631,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/progname.h - lib/rawmemchr.c - lib/rawmemchr.valgrind -+ lib/readlink.c - lib/realloc.c - lib/ref-add.sin - lib/ref-del.sin -@@ -606,6 +643,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/regexec.c - lib/size_max.h - lib/sleep.c -+ lib/stat.c - lib/stdalign.in.h - lib/stdbool.in.h - lib/stddef.in.h -@@ -627,8 +665,11 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/strnlen.c - lib/strnlen1.c - lib/strnlen1.h -+ lib/sys_stat.in.h -+ lib/sys_time.in.h - lib/sys_types.in.h - lib/sysexits.in.h -+ lib/time.in.h - lib/unistd.c - lib/unistd.in.h - lib/unitypes.in.h -@@ -667,6 +708,7 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/getline.m4 - m4/getopt.m4 - m4/gettext.m4 -+ m4/gettimeofday.m4 - m4/glibc2.m4 - m4/glibc21.m4 - m4/gnulib-common.m4 -@@ -681,6 +723,7 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/inttypes-pri.m4 - m4/inttypes_h.m4 - m4/langinfo_h.m4 -+ m4/largefile.m4 - m4/lcmessage.m4 - m4/lib-ld.m4 - m4/lib-link.m4 -@@ -712,16 +755,19 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/nls.m4 - m4/nocrash.m4 - m4/off_t.m4 -+ m4/pathmax.m4 - m4/po.m4 - m4/printf-posix.m4 - m4/printf.m4 - m4/progtest.m4 - m4/rawmemchr.m4 -+ m4/readlink.m4 - m4/realloc.m4 - m4/regex.m4 - m4/size_max.m4 - m4/sleep.m4 - m4/ssize_t.m4 -+ m4/stat.m4 - m4/stdalign.m4 - m4/stdbool.m4 - m4/stddef_h.m4 -@@ -737,9 +783,12 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/strndup.m4 - m4/strnlen.m4 - m4/sys_socket_h.m4 -+ m4/sys_stat_h.m4 -+ m4/sys_time_h.m4 - m4/sys_types_h.m4 - m4/sysexits.m4 - m4/threadlib.m4 -+ m4/time_h.m4 - m4/uintmax_t.m4 - m4/unistd_h.m4 - m4/vasnprintf.m4 -diff --git a/m4/largefile.m4 b/m4/largefile.m4 -new file mode 100644 -index 0000000..a1b564a ---- /dev/null -+++ b/m4/largefile.m4 -@@ -0,0 +1,146 @@ -+# Enable large files on systems where this is not the default. -+ -+# Copyright 1992-1996, 1998-2014 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. -+ -+# The following implementation works around a problem in autoconf <= 2.69; -+# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, -+# or configures them incorrectly in some cases. -+m4_version_prereq([2.70], [] ,[ -+ -+# _AC_SYS_LARGEFILE_TEST_INCLUDES -+# ------------------------------- -+m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], -+[@%:@include -+ /* Check that off_t can represent 2**63 - 1 correctly. -+ We can't simply define LARGE_OFF_T to be 9223372036854775807, -+ since some C++ compilers masquerading as C compilers -+ incorrectly reject 9223372036854775807. */ -+@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -+ int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 -+ && LARGE_OFF_T % 2147483647 == 1) -+ ? 1 : -1]];[]dnl -+]) -+ -+ -+# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, -+# CACHE-VAR, -+# DESCRIPTION, -+# PROLOGUE, [FUNCTION-BODY]) -+# -------------------------------------------------------- -+m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE], -+[AC_CACHE_CHECK([for $1 value needed for large files], [$3], -+[while :; do -+ m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( -+ [AC_LANG_PROGRAM([$5], [$6])], -+ [$3=no; break]) -+ m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( -+ [AC_LANG_PROGRAM([@%:@define $1 $2 -+$5], [$6])], -+ [$3=$2; break]) -+ $3=unknown -+ break -+done]) -+case $$3 in #( -+ no | unknown) ;; -+ *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);; -+esac -+rm -rf conftest*[]dnl -+])# _AC_SYS_LARGEFILE_MACRO_VALUE -+ -+ -+# AC_SYS_LARGEFILE -+# ---------------- -+# By default, many hosts won't let programs access large files; -+# one must use special compiler options to get large-file access to work. -+# For more details about this brain damage please see: -+# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html -+AC_DEFUN([AC_SYS_LARGEFILE], -+[AC_ARG_ENABLE(largefile, -+ [ --disable-largefile omit support for large files]) -+if test "$enable_largefile" != no; then -+ -+ AC_CACHE_CHECK([for special C compiler options needed for large files], -+ ac_cv_sys_largefile_CC, -+ [ac_cv_sys_largefile_CC=no -+ if test "$GCC" != yes; then -+ ac_save_CC=$CC -+ while :; do -+ # IRIX 6.2 and later do not support large files by default, -+ # so use the C compiler's -n32 option if that helps. -+ AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])]) -+ AC_COMPILE_IFELSE([], [break]) -+ CC="$CC -n32" -+ AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break]) -+ break -+ done -+ CC=$ac_save_CC -+ rm -f conftest.$ac_ext -+ fi]) -+ if test "$ac_cv_sys_largefile_CC" != no; then -+ CC=$CC$ac_cv_sys_largefile_CC -+ fi -+ -+ _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, -+ ac_cv_sys_file_offset_bits, -+ [Number of bits in a file offset, on hosts where this is settable.], -+ [_AC_SYS_LARGEFILE_TEST_INCLUDES]) -+ if test $ac_cv_sys_file_offset_bits = unknown; then -+ _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, -+ ac_cv_sys_large_files, -+ [Define for large files, on AIX-style hosts.], -+ [_AC_SYS_LARGEFILE_TEST_INCLUDES]) -+ fi -+ -+ AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1], -+ [Enable large inode numbers on Mac OS X 10.5.]) -+fi -+])# AC_SYS_LARGEFILE -+])# m4_version_prereq 2.70 -+ -+# Enable large files on systems where this is implemented by Gnulib, not by the -+# system headers. -+# Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib -+# overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively. -+AC_DEFUN([gl_LARGEFILE], -+[ -+ AC_REQUIRE([AC_CANONICAL_HOST]) -+ case "$host_os" in -+ mingw*) -+ dnl Native Windows. -+ dnl mingw64 defines off_t to a 64-bit type already, if -+ dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE. -+ AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1]; -+ ]], -+ [[]])], -+ [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no]) -+ ]) -+ if test $gl_cv_type_off_t_64 = no; then -+ WINDOWS_64_BIT_OFF_T=1 -+ else -+ WINDOWS_64_BIT_OFF_T=0 -+ fi -+ dnl But all native Windows platforms (including mingw64) have a 32-bit -+ dnl st_size member in 'struct stat'. -+ WINDOWS_64_BIT_ST_SIZE=1 -+ ;; -+ *) -+ dnl Nothing to do on gnulib's side. -+ dnl A 64-bit off_t is -+ dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX, -+ dnl OSF/1, Cygwin, -+ dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on -+ dnl glibc, HP-UX, Solaris, -+ dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX, -+ dnl - impossible to achieve on Minix 3.1.8. -+ WINDOWS_64_BIT_OFF_T=0 -+ WINDOWS_64_BIT_ST_SIZE=0 -+ ;; -+ esac -+]) -diff --git a/m4/pathmax.m4 b/m4/pathmax.m4 -new file mode 100644 -index 0000000..114f91f ---- /dev/null -+++ b/m4/pathmax.m4 -@@ -0,0 +1,42 @@ -+# pathmax.m4 serial 10 -+dnl Copyright (C) 2002-2003, 2005-2006, 2009-2014 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. -+ -+AC_DEFUN([gl_PATHMAX], -+[ -+ dnl Prerequisites of lib/pathmax.h. -+ AC_CHECK_HEADERS_ONCE([sys/param.h]) -+]) -+ -+# Expands to a piece of C program that defines PATH_MAX in the same way as -+# "pathmax.h" will do. -+AC_DEFUN([gl_PATHMAX_SNIPPET], [[ -+/* Arrange to define PATH_MAX, like "pathmax.h" does. */ -+#if HAVE_UNISTD_H -+# include -+#endif -+#include -+#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN -+# include -+#endif -+#if !defined PATH_MAX && defined MAXPATHLEN -+# define PATH_MAX MAXPATHLEN -+#endif -+#ifdef __hpux -+# undef PATH_MAX -+# define PATH_MAX 1024 -+#endif -+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+# undef PATH_MAX -+# define PATH_MAX 260 -+#endif -+]]) -+ -+# Prerequisites of gl_PATHMAX_SNIPPET. -+AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ], -+[ -+ AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h]) -+]) -diff --git a/m4/readlink.m4 b/m4/readlink.m4 -new file mode 100644 -index 0000000..f9ce868 ---- /dev/null -+++ b/m4/readlink.m4 -@@ -0,0 +1,71 @@ -+# readlink.m4 serial 12 -+dnl Copyright (C) 2003, 2007, 2009-2014 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. -+ -+AC_DEFUN([gl_FUNC_READLINK], -+[ -+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) -+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles -+ AC_CHECK_FUNCS_ONCE([readlink]) -+ if test $ac_cv_func_readlink = no; then -+ HAVE_READLINK=0 -+ else -+ AC_CACHE_CHECK([whether readlink signature is correct], -+ [gl_cv_decl_readlink_works], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ /* Cause compilation failure if original declaration has wrong type. */ -+ ssize_t readlink (const char *, char *, size_t);]])], -+ [gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])]) -+ dnl Solaris 9 ignores trailing slash. -+ dnl FreeBSD 7.2 dereferences only one level of links with trailing slash. -+ AC_CACHE_CHECK([whether readlink handles trailing slash correctly], -+ [gl_cv_func_readlink_works], -+ [# We have readlink, so assume ln -s works. -+ ln -s conftest.no-such conftest.link -+ ln -s conftest.link conftest.lnk2 -+ AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+]], [[char buf[20]; -+ return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])], -+ [gl_cv_func_readlink_works=yes], [gl_cv_func_readlink_works=no], -+ [case "$host_os" in -+ # Guess yes on glibc systems. -+ *-gnu*) gl_cv_func_readlink_works="guessing yes" ;; -+ # If we don't know, assume the worst. -+ *) gl_cv_func_readlink_works="guessing no" ;; -+ esac -+ ]) -+ rm -f conftest.link conftest.lnk2]) -+ case "$gl_cv_func_readlink_works" in -+ *yes) -+ if test "$gl_cv_decl_readlink_works" != yes; then -+ REPLACE_READLINK=1 -+ fi -+ ;; -+ *) -+ AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink -+ fails to recognize a trailing slash.]) -+ REPLACE_READLINK=1 -+ ;; -+ esac -+ fi -+]) -+ -+# Like gl_FUNC_READLINK, except prepare for separate compilation -+# (no REPLACE_READLINK, no AC_LIBOBJ). -+AC_DEFUN([gl_FUNC_READLINK_SEPARATE], -+[ -+ AC_CHECK_FUNCS_ONCE([readlink]) -+ gl_PREREQ_READLINK -+]) -+ -+# Prerequisites of lib/readlink.c. -+AC_DEFUN([gl_PREREQ_READLINK], -+[ -+ : -+]) -diff --git a/m4/stat.m4 b/m4/stat.m4 -new file mode 100644 -index 0000000..1ae327b ---- /dev/null -+++ b/m4/stat.m4 -@@ -0,0 +1,71 @@ -+# serial 11 -+ -+# Copyright (C) 2009-2014 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. -+ -+AC_DEFUN([gl_FUNC_STAT], -+[ -+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles -+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) -+ AC_CHECK_FUNCS_ONCE([lstat]) -+ dnl mingw is the only known platform where stat(".") and stat("./") differ -+ AC_CACHE_CHECK([whether stat handles trailing slashes on directories], -+ [gl_cv_func_stat_dir_slash], -+ [AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])], -+ [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no], -+ [case $host_os in -+ mingw*) gl_cv_func_stat_dir_slash="guessing no";; -+ *) gl_cv_func_stat_dir_slash="guessing yes";; -+ esac])]) -+ dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/"). -+ dnl (For mingw, this is due to a broken stat() override in libmingwex.a.) -+ dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/"). -+ AC_CACHE_CHECK([whether stat handles trailing slashes on files], -+ [gl_cv_func_stat_file_slash], -+ [touch conftest.tmp -+ # Assume that if we have lstat, we can also check symlinks. -+ if test $ac_cv_func_lstat = yes; then -+ ln -s conftest.tmp conftest.lnk -+ fi -+ AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+]], [[int result = 0; -+ struct stat st; -+ if (!stat ("conftest.tmp/", &st)) -+ result |= 1; -+#if HAVE_LSTAT -+ if (!stat ("conftest.lnk/", &st)) -+ result |= 2; -+#endif -+ return result; -+ ]])], -+ [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no], -+ [case "$host_os" in -+ # Guess yes on glibc systems. -+ *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; -+ # If we don't know, assume the worst. -+ *) gl_cv_func_stat_file_slash="guessing no" ;; -+ esac -+ ]) -+ rm -f conftest.tmp conftest.lnk]) -+ case $gl_cv_func_stat_dir_slash in -+ *no) REPLACE_STAT=1 -+ AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs -+ help when passed a directory name with a trailing slash]);; -+ esac -+ case $gl_cv_func_stat_file_slash in -+ *no) REPLACE_STAT=1 -+ AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs -+ help when passed a file name with a trailing slash]);; -+ esac -+]) -+ -+# Prerequisites of lib/stat.c. -+AC_DEFUN([gl_PREREQ_STAT], [:]) -diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 -new file mode 100644 -index 0000000..eaa7642 ---- /dev/null -+++ b/m4/sys_stat_h.m4 -@@ -0,0 +1,96 @@ -+# sys_stat_h.m4 serial 28 -*- Autoconf -*- -+dnl Copyright (C) 2006-2014 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 Eric Blake. -+dnl Provide a GNU-like . -+ -+AC_DEFUN([gl_HEADER_SYS_STAT_H], -+[ -+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) -+ -+ dnl Check for broken stat macros. -+ AC_REQUIRE([AC_HEADER_STAT]) -+ -+ gl_CHECK_NEXT_HEADERS([sys/stat.h]) -+ -+ dnl Ensure the type mode_t gets defined. -+ AC_REQUIRE([AC_TYPE_MODE_T]) -+ -+ dnl Whether to override 'struct stat'. -+ m4_ifdef([gl_LARGEFILE], [ -+ AC_REQUIRE([gl_LARGEFILE]) -+ ], [ -+ WINDOWS_64_BIT_ST_SIZE=0 -+ ]) -+ AC_SUBST([WINDOWS_64_BIT_ST_SIZE]) -+ if test $WINDOWS_64_BIT_ST_SIZE = 1; then -+ AC_DEFINE([_GL_WINDOWS_64_BIT_ST_SIZE], [1], -+ [Define to 1 if Gnulib overrides 'struct stat' on Windows so that -+ struct stat.st_size becomes 64-bit.]) -+ fi -+ -+ dnl Define types that are supposed to be defined in or -+ dnl . -+ AC_CHECK_TYPE([nlink_t], [], -+ [AC_DEFINE([nlink_t], [int], -+ [Define to the type of st_nlink in struct stat, or a supertype.])], -+ [#include -+ #include ]) -+ -+ dnl Check for declarations of anything we want to poison if the -+ dnl corresponding gnulib module is not in use. -+ gl_WARN_ON_USE_PREPARE([[#include -+ ]], [fchmodat fstat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat -+ mknod mknodat stat utimensat]) -+]) # gl_HEADER_SYS_STAT_H -+ -+AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], -+[ -+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. -+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) -+ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -+ dnl Define it also as a C macro, for the benefit of the unit tests. -+ gl_MODULE_INDICATOR_FOR_TESTS([$1]) -+]) -+ -+AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], -+[ -+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR -+ GNULIB_FCHMODAT=0; AC_SUBST([GNULIB_FCHMODAT]) -+ GNULIB_FSTAT=0; AC_SUBST([GNULIB_FSTAT]) -+ GNULIB_FSTATAT=0; AC_SUBST([GNULIB_FSTATAT]) -+ GNULIB_FUTIMENS=0; AC_SUBST([GNULIB_FUTIMENS]) -+ GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD]) -+ GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT]) -+ GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT]) -+ GNULIB_MKFIFO=0; AC_SUBST([GNULIB_MKFIFO]) -+ GNULIB_MKFIFOAT=0; AC_SUBST([GNULIB_MKFIFOAT]) -+ GNULIB_MKNOD=0; AC_SUBST([GNULIB_MKNOD]) -+ GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT]) -+ GNULIB_STAT=0; AC_SUBST([GNULIB_STAT]) -+ GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT]) -+ dnl Assume proper GNU behavior unless another module says otherwise. -+ HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) -+ HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) -+ HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS]) -+ HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD]) -+ HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT]) -+ HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT]) -+ HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO]) -+ HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT]) -+ HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD]) -+ HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT]) -+ HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT]) -+ REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT]) -+ REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT]) -+ REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS]) -+ REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT]) -+ REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR]) -+ REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO]) -+ REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD]) -+ REPLACE_STAT=0; AC_SUBST([REPLACE_STAT]) -+ REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT]) -+]) -diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 -new file mode 100644 -index 0000000..5c79300 ---- /dev/null -+++ b/m4/sys_time_h.m4 -@@ -0,0 +1,110 @@ -+# Configure a replacement for . -+# serial 8 -+ -+# Copyright (C) 2007, 2009-2014 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. -+ -+# Written by Paul Eggert and Martin Lambers. -+ -+AC_DEFUN([gl_HEADER_SYS_TIME_H], -+[ -+ dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement -+ dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1 -+ dnl statements that occur in other macros. -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY]) -+]) -+ -+AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], -+[ -+ AC_REQUIRE([AC_C_RESTRICT]) -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) -+ AC_CHECK_HEADERS_ONCE([sys/time.h]) -+ gl_CHECK_NEXT_HEADERS([sys/time.h]) -+ -+ if test $ac_cv_header_sys_time_h != yes; then -+ HAVE_SYS_TIME_H=0 -+ fi -+ -+ dnl On native Windows with MSVC, 'struct timeval' is defined in -+ dnl only. So include that header in the list. -+ gl_PREREQ_SYS_H_WINSOCK2 -+ AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#if HAVE_SYS_TIME_H -+ #include -+ #endif -+ #include -+ #if HAVE_WINSOCK2_H -+ # include -+ #endif -+ ]], -+ [[static struct timeval x; x.tv_sec = x.tv_usec;]])], -+ [gl_cv_sys_struct_timeval=yes], -+ [gl_cv_sys_struct_timeval=no]) -+ ]) -+ if test $gl_cv_sys_struct_timeval != yes; then -+ HAVE_STRUCT_TIMEVAL=0 -+ else -+ dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined -+ dnl (in and for mingw64, in only -+ dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is -+ dnl smaller than the 'time_t' type mandated by POSIX. -+ dnl On OpenBSD 5.1 amd64, tv_sec is 64 bits and time_t 32 bits, but -+ dnl that is good enough. -+ AC_CACHE_CHECK([for wide-enough struct timeval.tv_sec member], -+ [gl_cv_sys_struct_timeval_tv_sec], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#if HAVE_SYS_TIME_H -+ #include -+ #endif -+ #include -+ #if HAVE_WINSOCK2_H -+ # include -+ #endif -+ ]], -+ [[static struct timeval x; -+ typedef int verify_tv_sec_type[ -+ sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1 -+ ]; -+ ]])], -+ [gl_cv_sys_struct_timeval_tv_sec=yes], -+ [gl_cv_sys_struct_timeval_tv_sec=no]) -+ ]) -+ if test $gl_cv_sys_struct_timeval_tv_sec != yes; then -+ REPLACE_STRUCT_TIMEVAL=1 -+ fi -+ fi -+ -+ dnl Check for declarations of anything we want to poison if the -+ dnl corresponding gnulib module is not in use. -+ gl_WARN_ON_USE_PREPARE([[ -+#if HAVE_SYS_TIME_H -+# include -+#endif -+#include -+ ]], [gettimeofday]) -+]) -+ -+AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR], -+[ -+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) -+ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -+ dnl Define it also as a C macro, for the benefit of the unit tests. -+ gl_MODULE_INDICATOR_FOR_TESTS([$1]) -+]) -+ -+AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS], -+[ -+ GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY]) -+ dnl Assume POSIX behavior unless another module says otherwise. -+ HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) -+ HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) -+ HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) -+ REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) -+ REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL]) -+]) -diff --git a/m4/time_h.m4 b/m4/time_h.m4 -new file mode 100644 -index 0000000..9852778 ---- /dev/null -+++ b/m4/time_h.m4 -@@ -0,0 +1,118 @@ -+# Configure a more-standard replacement for . -+ -+# Copyright (C) 2000-2001, 2003-2007, 2009-2014 Free Software Foundation, Inc. -+ -+# serial 8 -+ -+# 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. -+ -+# Written by Paul Eggert and Jim Meyering. -+ -+AC_DEFUN([gl_HEADER_TIME_H], -+[ -+ dnl Use AC_REQUIRE here, so that the default behavior below is expanded -+ dnl once only, before all statements that occur in other macros. -+ AC_REQUIRE([gl_HEADER_TIME_H_BODY]) -+]) -+ -+AC_DEFUN([gl_HEADER_TIME_H_BODY], -+[ -+ AC_REQUIRE([AC_C_RESTRICT]) -+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) -+ gl_NEXT_HEADERS([time.h]) -+ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) -+]) -+ -+dnl Check whether 'struct timespec' is declared -+dnl in time.h, sys/time.h, or pthread.h. -+ -+AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], -+[ -+ AC_CHECK_HEADERS_ONCE([sys/time.h]) -+ AC_CACHE_CHECK([for struct timespec in ], -+ [gl_cv_sys_struct_timespec_in_time_h], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ ]], -+ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], -+ [gl_cv_sys_struct_timespec_in_time_h=yes], -+ [gl_cv_sys_struct_timespec_in_time_h=no])]) -+ -+ TIME_H_DEFINES_STRUCT_TIMESPEC=0 -+ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 -+ PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 -+ if test $gl_cv_sys_struct_timespec_in_time_h = yes; then -+ TIME_H_DEFINES_STRUCT_TIMESPEC=1 -+ else -+ AC_CACHE_CHECK([for struct timespec in ], -+ [gl_cv_sys_struct_timespec_in_sys_time_h], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ ]], -+ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], -+ [gl_cv_sys_struct_timespec_in_sys_time_h=yes], -+ [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) -+ if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then -+ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 -+ else -+ AC_CACHE_CHECK([for struct timespec in ], -+ [gl_cv_sys_struct_timespec_in_pthread_h], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ ]], -+ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], -+ [gl_cv_sys_struct_timespec_in_pthread_h=yes], -+ [gl_cv_sys_struct_timespec_in_pthread_h=no])]) -+ if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then -+ PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 -+ fi -+ fi -+ fi -+ AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) -+ AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) -+ AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) -+]) -+ -+AC_DEFUN([gl_TIME_MODULE_INDICATOR], -+[ -+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. -+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) -+ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -+ dnl Define it also as a C macro, for the benefit of the unit tests. -+ gl_MODULE_INDICATOR_FOR_TESTS([$1]) -+]) -+ -+AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], -+[ -+ GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME]) -+ GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP]) -+ GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME]) -+ GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) -+ GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) -+ dnl Assume proper GNU behavior unless another module says otherwise. -+ HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) -+ HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) -+ HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) -+ HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) -+ dnl If another module says to replace or to not replace, do that. -+ dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; -+ dnl this lets maintainers check for portability. -+ REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) -+ REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) -+ REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) -+ REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) -+ -+ dnl Hack so that the time module doesn't depend on the sys_time module. -+ dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent. -+ : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY]) -+ dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME -+ dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier -+ dnl is no longer a big deal. -+ REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) -+ REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) -+]) --- -2.9.3 - diff --git a/0056-Don-t-draw-a-border-around-the-menu.patch b/0056-Don-t-draw-a-border-around-the-menu.patch new file mode 100644 index 0000000..6f85d60 --- /dev/null +++ b/0056-Don-t-draw-a-border-around-the-menu.patch @@ -0,0 +1,74 @@ +From fbd9d8969c059d6e5572b1acfa42ba48bc4299e2 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Wed, 15 May 2013 16:47:33 -0400 +Subject: [PATCH 056/123] Don't draw a border around the menu + +It looks cleaner without it. +--- + grub-core/normal/menu_text.c | 43 ------------------------------------------- + 1 file changed, 43 deletions(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index 452d55bf9..1ed2bd92c 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -108,47 +108,6 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right, + grub_print_message_indented_real (msg, margin_left, margin_right, term, 0); + } + +-static void +-draw_border (struct grub_term_output *term, const struct grub_term_screen_geometry *geo) +-{ +- int i; +- +- grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); +- +- grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1, +- geo->first_entry_y - 1 }); +- grub_putcode (GRUB_UNICODE_CORNER_UL, term); +- for (i = 0; i < geo->entry_width + 1; i++) +- grub_putcode (GRUB_UNICODE_HLINE, term); +- grub_putcode (GRUB_UNICODE_CORNER_UR, term); +- +- for (i = 0; i < geo->num_entries; i++) +- { +- grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1, +- geo->first_entry_y + i }); +- grub_putcode (GRUB_UNICODE_VLINE, term); +- grub_term_gotoxy (term, +- (struct grub_term_coordinate) { geo->first_entry_x + geo->entry_width + 1, +- geo->first_entry_y + i }); +- grub_putcode (GRUB_UNICODE_VLINE, term); +- } +- +- grub_term_gotoxy (term, +- (struct grub_term_coordinate) { geo->first_entry_x - 1, +- geo->first_entry_y - 1 + geo->num_entries + 1 }); +- grub_putcode (GRUB_UNICODE_CORNER_LL, term); +- for (i = 0; i < geo->entry_width + 1; i++) +- grub_putcode (GRUB_UNICODE_HLINE, term); +- grub_putcode (GRUB_UNICODE_CORNER_LR, term); +- +- grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); +- +- grub_term_gotoxy (term, +- (struct grub_term_coordinate) { geo->first_entry_x - 1, +- (geo->first_entry_y - 1 + geo->num_entries +- + GRUB_TERM_MARGIN + 1) }); +-} +- + static int + print_message (int nested, int edit, struct grub_term_output *term, int dry_run) + { +@@ -406,8 +365,6 @@ grub_menu_init_page (int nested, int edit, + + grub_term_normal_color = grub_color_menu_normal; + grub_term_highlight_color = grub_color_menu_highlight; +- if (geo->border) +- draw_border (term, geo); + grub_term_normal_color = old_color_normal; + grub_term_highlight_color = old_color_highlight; + geo->timeout_y = geo->first_entry_y + geo->num_entries +-- +2.14.3 + diff --git a/0057-Make-editenv-chase-symlinks-including-those-across-d.patch b/0057-Make-editenv-chase-symlinks-including-those-across-d.patch deleted file mode 100644 index 689baec..0000000 --- a/0057-Make-editenv-chase-symlinks-including-those-across-d.patch +++ /dev/null @@ -1,106 +0,0 @@ -From a867dc42c711385634d86f04176cf3193d548f1d Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 3 Sep 2014 10:38:00 -0400 -Subject: [PATCH 57/90] Make editenv chase symlinks including those across - devices. - -This lets us make /boot/grub2/grubenv a symlink to -/boot/efi/EFI/fedora/grubenv even though they're different mount points, -which allows /usr/bin/grub2-editenv to be the same across platforms -(i.e. UEFI vs BIOS). - -Signed-off-by: Peter Jones -Reviewed-by: Adam Jackson ---- - Makefile.util.def | 9 +++++++++ - util/editenv.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- - 2 files changed, 53 insertions(+), 2 deletions(-) - -diff --git a/Makefile.util.def b/Makefile.util.def -index 6d452da..2061104 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -230,8 +230,17 @@ program = { - - common = util/grub-editenv.c; - common = util/editenv.c; -+ common = util/grub-install-common.c; - common = grub-core/osdep/init.c; -+ common = grub-core/osdep/compress.c; -+ extra_dist = grub-core/osdep/unix/compress.c; -+ extra_dist = grub-core/osdep/basic/compress.c; -+ common = util/mkimage.c; -+ common = grub-core/osdep/config.c; -+ common = util/config.c; -+ common = util/resolve.c; - -+ ldadd = '$(LIBLZMA)'; - ldadd = libgrubmods.a; - ldadd = libgrubgcry.a; - ldadd = libgrubkern.a; -diff --git a/util/editenv.c b/util/editenv.c -index c6f8d22..d8d1dad 100644 ---- a/util/editenv.c -+++ b/util/editenv.c -@@ -37,6 +37,7 @@ grub_util_create_envblk_file (const char *name) - FILE *fp; - char *buf; - char *namenew; -+ char *rename_target = xstrdup(name); - - buf = xmalloc (DEFAULT_ENVBLK_SIZE); - -@@ -59,7 +60,48 @@ grub_util_create_envblk_file (const char *name) - free (buf); - fclose (fp); - -- if (grub_util_rename (namenew, name) < 0) -- grub_util_error (_("cannot rename the file %s to %s"), namenew, name); -+ ssize_t size = 1; -+ while (1) -+ { -+ char *linkbuf; -+ ssize_t retsize; -+ -+ linkbuf = xmalloc(size+1); -+ retsize = grub_util_readlink (rename_target, linkbuf, size); -+ if (retsize < 0 && (errno == ENOENT || errno == EINVAL)) -+ { -+ free (linkbuf); -+ break; -+ } -+ else if (retsize < 0) -+ { -+ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); -+ free (linkbuf); -+ free (namenew); -+ return; -+ } -+ else if (retsize == size) -+ { -+ free(linkbuf); -+ size += 128; -+ continue; -+ } -+ -+ free (rename_target); -+ linkbuf[retsize] = '\0'; -+ rename_target = linkbuf; -+ } -+ -+ int rc = grub_util_rename (namenew, rename_target); -+ if (rc < 0 && errno == EXDEV) -+ { -+ rc = grub_install_copy_file (namenew, rename_target, 1); -+ grub_util_unlink (namenew); -+ } -+ -+ if (rc < 0) -+ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); -+ - free (namenew); -+ free (rename_target); - } --- -2.9.3 - diff --git a/0057-Use-the-standard-margin-for-the-timeout-string.patch b/0057-Use-the-standard-margin-for-the-timeout-string.patch new file mode 100644 index 0000000..bde17b5 --- /dev/null +++ b/0057-Use-the-standard-margin-for-the-timeout-string.patch @@ -0,0 +1,43 @@ +From 3aeba4760755b9b263ed4ba60dc0431352b63fe7 Mon Sep 17 00:00:00 2001 +From: William Jon McCann +Date: Fri, 7 Jun 2013 10:52:32 -0400 +Subject: [PATCH 057/123] Use the standard margin for the timeout string + +So that it aligns with the other messages +--- + grub-core/normal/menu_text.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index 1ed2bd92c..7681f7d28 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -372,7 +372,7 @@ grub_menu_init_page (int nested, int edit, + if (bottom_message) + { + grub_term_gotoxy (term, +- (struct grub_term_coordinate) { GRUB_TERM_MARGIN, ++ (struct grub_term_coordinate) { STANDARD_MARGIN, + geo->timeout_y }); + + print_message (nested, edit, term, 0); +@@ -407,14 +407,14 @@ menu_text_print_timeout (int timeout, void *dataptr) + if (data->timeout_msg == TIMEOUT_UNKNOWN) + { + data->timeout_msg = grub_print_message_indented_real (msg_translated, +- 3, 1, data->term, 1) ++ STANDARD_MARGIN, 1, data->term, 1) + <= data->geo.timeout_lines ? TIMEOUT_NORMAL : TIMEOUT_TERSE; + if (data->timeout_msg == TIMEOUT_TERSE) + { + grub_free (msg_translated); + msg_translated = grub_xasprintf (_("%ds"), timeout); + if (grub_term_width (data->term) < 10) +- data->timeout_msg = TIMEOUT_TERSE_NO_MARGIN; ++ data->timeout_msg = STANDARD_MARGIN; + } + } + +-- +2.14.3 + diff --git a/0058-Add-.eh_frame-to-list-of-relocations-stripped.patch b/0058-Add-.eh_frame-to-list-of-relocations-stripped.patch new file mode 100644 index 0000000..54f06ac --- /dev/null +++ b/0058-Add-.eh_frame-to-list-of-relocations-stripped.patch @@ -0,0 +1,25 @@ +From 333159a74035a726841c6c888f43d983a40ed959 Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Mon, 13 Jan 2014 21:50:59 -0500 +Subject: [PATCH 058/123] Add .eh_frame to list of relocations stripped + +--- + conf/Makefile.common | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/conf/Makefile.common b/conf/Makefile.common +index 11296b550..a476ab580 100644 +--- a/conf/Makefile.common ++++ b/conf/Makefile.common +@@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding + LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) + CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 + CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) +-STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx ++STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx + + CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding + LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +-- +2.14.3 + diff --git a/0058-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch b/0058-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch deleted file mode 100644 index 354a91f..0000000 --- a/0058-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 14b8db374bfc41fffa278ec33084324008384417 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 4 Sep 2014 14:23:23 -0400 -Subject: [PATCH 58/90] Generate OS and CLASS in 10_linux from /etc/os-release - -This makes us use pretty names in the titles we generate in -grub2-mkconfig when GRUB_DISTRIBUTOR isn't set. - -Resolves: rhbz#996794 - -Signed-off-by: Peter Jones ---- - util/grub.d/10_linux.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index a9692a0..c662726 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -29,7 +29,8 @@ export TEXTDOMAINDIR="@localedir@" - CLASS="--class gnu-linux --class gnu --class os --unrestricted" - - if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then -- OS="$(sed 's, release .*$,,g' /etc/system-release)" -+ OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})" -+ CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}" - else - OS="${GRUB_DISTRIBUTOR}" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" --- -2.9.3 - diff --git a/0059-Make-10_linux-work-with-our-changes-for-linux16-and-.patch b/0059-Make-10_linux-work-with-our-changes-for-linux16-and-.patch new file mode 100644 index 0000000..eb9c04d --- /dev/null +++ b/0059-Make-10_linux-work-with-our-changes-for-linux16-and-.patch @@ -0,0 +1,85 @@ +From 5fa65416bae89efb88015e72cb21c28fe3833fc8 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 14 Jan 2014 13:12:23 -0500 +Subject: [PATCH 059/123] Make 10_linux work with our changes for linux16 and + linuxefi on aarch64 + +Signed-off-by: Peter Jones +--- + util/grub.d/10_linux.in | 31 ++++++++++++++++++++++++++++--- + 1 file changed, 28 insertions(+), 3 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index ef52cf3db..191aebe80 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -77,8 +77,18 @@ linux_entry () + args="$4" + + sixteenbit="" ++ linuxefi="linux" ++ initrdefi="initrd" + case "$machine" in +- i?86|x86_64) sixteenbit="16" ;; ++ i?86|x86_64) ++ sixteenbit="16" ++ linuxefi="linuxefi" ++ initrdefi="initrdefi" ++ ;; ++ aarch64) ++ linuxefi="linux" ++ initrdefi="initrd" ++ ;; + esac + + if [ -z "$boot_device_id" ]; then +@@ -135,7 +145,7 @@ linux_entry () + fi + if [ -d /sys/firmware/efi ]; then + sed "s/^/$submenu_indentation/" << EOF +- linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} ++ ${linuxefi} ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} + EOF + else + sed "s/^/$submenu_indentation/" << EOF +@@ -145,7 +155,7 @@ EOF + if test -n "${initrd}" ; then + if [ -d /sys/firmware/efi ]; then + sed "s/^/$submenu_indentation/" << EOF +- initrdefi ${rel_dirname}/${initrd} ++ ${initrdefi} ${rel_dirname}/${initrd} + EOF + else + sed "s/^/$submenu_indentation/" << EOF +@@ -153,6 +163,13 @@ EOF + EOF + fi + fi ++ if test -n "${fdt}" ; then ++ message="$(gettext_printf "Loading fdt ...")" ++ sed "s/^/$submenu_indentation/" << EOF ++ echo '$(echo "$message" | grub_quote)' ++ devicetree ${rel_dirname}/${fdt} ++EOF ++ fi + sed "s/^/$submenu_indentation/" << EOF + } + EOF +@@ -215,6 +232,14 @@ while [ "x$list" != "x" ] ; do + fi + done + ++ fdt= ++ for i in "dtb-${version}" "dtb-${alt_version}"; do ++ if test -e "${dirname}/${i}/foundation-v8.dtb" ; then ++ fdt="${i}/foundation-v8.dtb" ++ break ++ fi ++ done ++ + config= + for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do + if test -e "${i}" ; then +-- +2.14.3 + diff --git a/0059-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch b/0059-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch deleted file mode 100644 index e24ee4a..0000000 --- a/0059-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 700c631b4c887778951503346afe5b7ee70bf7dd Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 4 Sep 2014 15:52:08 -0400 -Subject: [PATCH 59/90] Minimize the sort ordering for .debug and -rescue- - kernels. - -Resolves: rhbz#1065360 -Signed-off-by: Peter Jones ---- - util/grub-mkconfig_lib.in | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index cf35e41..10fabee 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -248,6 +248,14 @@ version_test_gt () - *.old:*.old) ;; - *.old:*) version_test_gt_a="`echo "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;; - *:*.old) version_test_gt_b="`echo "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;; -+ *-rescue*:*-rescue*) ;; -+ *?debug:*?debug) ;; -+ *-rescue*:*?debug) return 1 ;; -+ *?debug:*-rescue*) return 0 ;; -+ *-rescue*:*) return 1 ;; -+ *:*-rescue*) return 0 ;; -+ *?debug:*) return 1 ;; -+ *:*?debug) return 0 ;; - esac - version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b" - return "$?" --- -2.9.3 - diff --git a/0060-Don-t-print-during-fdt-loading-method.patch b/0060-Don-t-print-during-fdt-loading-method.patch new file mode 100644 index 0000000..80c8b00 --- /dev/null +++ b/0060-Don-t-print-during-fdt-loading-method.patch @@ -0,0 +1,27 @@ +From e89fd78bb3f62064d930c82ad14cd490166d1a2c Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 14 Jan 2014 16:15:46 -0500 +Subject: [PATCH 060/123] Don't print during fdt loading method. + +Signed-off-by: Peter Jones +--- + util/grub.d/10_linux.in | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 191aebe80..452a9f69d 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -164,9 +164,7 @@ EOF + fi + fi + if test -n "${fdt}" ; then +- message="$(gettext_printf "Loading fdt ...")" + sed "s/^/$submenu_indentation/" << EOF +- echo '$(echo "$message" | grub_quote)' + devicetree ${rel_dirname}/${fdt} + EOF + fi +-- +2.14.3 + diff --git a/0060-Load-arm-with-SB-enabled.patch b/0060-Load-arm-with-SB-enabled.patch deleted file mode 100644 index 4a31029..0000000 --- a/0060-Load-arm-with-SB-enabled.patch +++ /dev/null @@ -1,428 +0,0 @@ -From cae0d2cdb28017df75358e0839c60a9c2521cb82 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 18 Sep 2014 11:26:14 -0400 -Subject: [PATCH 60/90] Load arm with SB enabled. - -Make sure we actually try to validate secure boot on this platform (even -though we're not shipping it enabled by default.) - -This means giving the kernel grub's loaded image as the vehicle for the -kernel command line, because we can't call systab->bs->LoadImage() if SB -is enabled. ---- - grub-core/Makefile.core.def | 3 + - grub-core/loader/arm64/linux.c | 117 ++++++++++++++++++++------------------ - grub-core/loader/efi/linux.c | 65 +++++++++++++++++++++ - grub-core/loader/i386/efi/linux.c | 39 +------------ - include/grub/arm64/linux.h | 7 +++ - include/grub/efi/linux.h | 31 ++++++++++ - 6 files changed, 171 insertions(+), 91 deletions(-) - create mode 100644 grub-core/loader/efi/linux.c - create mode 100644 include/grub/efi/linux.h - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index e79bb0c..7fba196 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1676,6 +1676,8 @@ module = { - ia64_efi = loader/ia64/efi/linux.c; - arm = loader/arm/linux.c; - arm64 = loader/arm64/linux.c; -+ arm64 = loader/efi/linux.c; -+ fdt = lib/fdt.c; - common = loader/linux.c; - common = lib/cmdline.c; - enable = noemu; -@@ -1743,6 +1745,7 @@ module = { - name = linuxefi; - efi = loader/i386/efi/linux.c; - efi = lib/cmdline.c; -+ efi = loader/efi/linux.c; - enable = i386_efi; - enable = x86_64_efi; - }; -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 9519d2e..4756ef7 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -39,6 +40,7 @@ static int loaded; - - static void *kernel_addr; - static grub_uint64_t kernel_size; -+static grub_uint32_t handover_offset; - - static char *linux_args; - static grub_uint32_t cmdline_size; -@@ -67,7 +69,8 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) - static grub_err_t - finalize_params_linux (void) - { -- int node, retval; -+ grub_efi_loaded_image_t *loaded_image = NULL; -+ int node, retval, len; - - void *fdt; - -@@ -102,6 +105,26 @@ finalize_params_linux (void) - if (grub_fdt_install() != GRUB_ERR_NONE) - goto failure; - -+ grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", -+ fdt); -+ -+ /* Convert command line to UCS-2 */ -+ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); -+ if (!loaded_image) -+ goto failure; -+ -+ loaded_image->load_options_size = len = -+ (grub_strlen (linux_args) + 1) * sizeof (grub_efi_char16_t); -+ loaded_image->load_options = -+ grub_efi_allocate_pages (0, -+ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); -+ if (!loaded_image->load_options) -+ return grub_error(GRUB_ERR_BAD_OS, "failed to create kernel parameters"); -+ -+ loaded_image->load_options_size = -+ 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, -+ (grub_uint8_t *) linux_args, len, NULL); -+ - return GRUB_ERR_NONE; - - failure: -@@ -109,73 +132,47 @@ failure: - return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); - } - --grub_err_t --grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) -+static void -+free_params (void) - { -- grub_efi_memory_mapped_device_path_t *mempath; -- grub_efi_handle_t image_handle; -- grub_efi_boot_services_t *b; -- grub_efi_status_t status; -- grub_efi_loaded_image_t *loaded_image; -- int len; -- -- mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t)); -- if (!mempath) -- return grub_errno; -- -- mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE; -- mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE; -- mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath)); -- mempath[0].memory_type = GRUB_EFI_LOADER_DATA; -- mempath[0].start_address = addr; -- mempath[0].end_address = addr + size; -+ grub_efi_loaded_image_t *loaded_image = NULL; - -- mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; -- mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -- mempath[1].header.length = sizeof (grub_efi_device_path_t); -- -- b = grub_efi_system_table->boot_services; -- status = b->load_image (0, grub_efi_image_handle, -- (grub_efi_device_path_t *) mempath, -- (void *) addr, size, &image_handle); -- if (status != GRUB_EFI_SUCCESS) -- return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); -+ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); -+ if (loaded_image) -+ { -+ if (loaded_image->load_options) -+ grub_efi_free_pages ((grub_efi_physical_address_t) -+ loaded_image->load_options, -+ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); -+ loaded_image->load_options = NULL; -+ loaded_image->load_options_size = 0; -+ } -+} - -- grub_dprintf ("linux", "linux command line: '%s'\n", args); -+grub_err_t -+grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) -+{ -+ grub_err_t retval; - -- /* Convert command line to UCS-2 */ -- loaded_image = grub_efi_get_loaded_image (image_handle); -- loaded_image->load_options_size = len = -- (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); -- loaded_image->load_options = -- grub_efi_allocate_pages (0, -- GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); -- if (!loaded_image->load_options) -+ retval = finalize_params_linux (); -+ if (retval != GRUB_ERR_NONE) - return grub_errno; - -- loaded_image->load_options_size = -- 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, -- (grub_uint8_t *) args, len, NULL); -- -- grub_dprintf ("linux", "starting image %p\n", image_handle); -- status = b->start_image (image_handle, 0, NULL); -+ grub_dprintf ("linux", "linux command line: '%s'\n", args); - -- /* When successful, not reached */ -- b->unload_image (image_handle); -- grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options, -- GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); -+ retval = grub_efi_linux_boot ((char *)kernel_addr, handover_offset, -+ kernel_addr); - -- return grub_errno; -+ /* Never reached... */ -+ free_params(); -+ return retval; - } - - static grub_err_t - grub_linux_boot (void) - { -- if (finalize_params_linux () != GRUB_ERR_NONE) -- return grub_errno; -- -- return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, -- kernel_size, linux_args)); -+ return grub_arm64_uefi_boot_image ((grub_addr_t)kernel_addr, -+ kernel_size, linux_args); - } - - static grub_err_t -@@ -253,6 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - { - grub_file_t file = 0; - struct grub_arm64_linux_kernel_header lh; -+ struct grub_arm64_linux_pe_header *pe; - - grub_dl_ref (my_mod); - -@@ -297,6 +295,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); - -+ if (!grub_linuxefi_secure_validate (kernel_addr, kernel_size)) -+ { -+ grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); -+ goto fail; -+ } -+ -+ pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); -+ handover_offset = pe->opt.entry_addr; -+ - cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE); - linux_args = grub_malloc (cmdline_size); - if (!linux_args) -diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -new file mode 100644 -index 0000000..aea378a ---- /dev/null -+++ b/grub-core/loader/efi/linux.c -@@ -0,0 +1,65 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2014 Free Software Foundation, Inc. -+ * -+ * GRUB 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. -+ * -+ * GRUB 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 GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define SHIM_LOCK_GUID \ -+ { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } -+ -+struct grub_efi_shim_lock -+{ -+ grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size); -+}; -+typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; -+ -+grub_efi_boolean_t -+grub_linuxefi_secure_validate (void *data, grub_uint32_t size) -+{ -+ grub_efi_guid_t guid = SHIM_LOCK_GUID; -+ grub_efi_shim_lock_t *shim_lock; -+ -+ shim_lock = grub_efi_locate_protocol(&guid, NULL); -+ -+ if (!shim_lock) -+ return 1; -+ -+ if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) -+ return 1; -+ -+ return 0; -+} -+ -+typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); -+ -+grub_err_t -+grub_efi_linux_boot (void *kernel_addr, grub_off_t offset, -+ void *kernel_params) -+{ -+ handover_func hf; -+ -+ hf = (handover_func)((char *)kernel_addr + offset); -+ hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); -+ -+ return GRUB_ERR_BUG; -+} -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index b79e632..e5b7785 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -40,52 +41,18 @@ static char *linux_cmdline; - - #define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) - --#define SHIM_LOCK_GUID \ -- { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } -- --struct grub_efi_shim_lock --{ -- grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size); --}; --typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; -- --static grub_efi_boolean_t --grub_linuxefi_secure_validate (void *data, grub_uint32_t size) --{ -- grub_efi_guid_t guid = SHIM_LOCK_GUID; -- grub_efi_shim_lock_t *shim_lock; -- -- shim_lock = grub_efi_locate_protocol(&guid, NULL); -- -- if (!shim_lock) -- return 1; -- -- if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) -- return 1; -- -- return 0; --} -- --typedef void(*handover_func)(void *, grub_efi_system_table_t *, struct linux_kernel_params *); -- - static grub_err_t - grub_linuxefi_boot (void) - { -- handover_func hf; - int offset = 0; - - #ifdef __x86_64__ - offset = 512; - #endif -- -- hf = (handover_func)((char *)kernel_mem + handover_offset + offset); -- - asm volatile ("cli"); - -- hf (grub_efi_image_handle, grub_efi_system_table, params); -- -- /* Not reached */ -- return GRUB_ERR_NONE; -+ return grub_efi_linux_boot ((char *)kernel_mem, handover_offset + offset, -+ params); - } - - static grub_err_t -diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h -index 1ea2369..a2ba24e 100644 ---- a/include/grub/arm64/linux.h -+++ b/include/grub/arm64/linux.h -@@ -20,6 +20,7 @@ - #define GRUB_LINUX_CPU_HEADER 1 - - #include -+#include - - #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ - -@@ -44,5 +45,11 @@ grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header - *lh); - grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, - char *args); -+struct grub_arm64_linux_pe_header -+{ -+ grub_uint32_t magic; -+ struct grub_pe32_coff_header coff; -+ struct grub_pe64_optional_header opt; -+}; - - #endif /* ! GRUB_LINUX_CPU_HEADER */ -diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h -new file mode 100644 -index 0000000..d9ede36 ---- /dev/null -+++ b/include/grub/efi/linux.h -@@ -0,0 +1,31 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2014 Free Software Foundation, Inc. -+ * -+ * GRUB 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. -+ * -+ * GRUB 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 GRUB. If not, see . -+ */ -+#ifndef GRUB_EFI_LINUX_HEADER -+#define GRUB_EFI_LINUX_HEADER 1 -+ -+#include -+#include -+#include -+ -+grub_efi_boolean_t -+EXPORT_FUNC(grub_linuxefi_secure_validate) (void *data, grub_uint32_t size); -+grub_err_t -+EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, -+ void *kernel_param); -+ -+#endif /* ! GRUB_EFI_LINUX_HEADER */ --- -2.9.3 - diff --git a/0061-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch b/0061-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch new file mode 100644 index 0000000..686dcc7 --- /dev/null +++ b/0061-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch @@ -0,0 +1,36 @@ +From 7683e149c587abf2d35de11c39ddb0810572b2e4 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Mon, 30 Jun 2014 14:16:46 -0400 +Subject: [PATCH 061/123] Don't munge raw spaces when we're doing our cmdline + escaping (#923374) + +Signed-off-by: Peter Jones +--- + grub-core/lib/cmdline.c | 11 +---------- + 1 file changed, 1 insertion(+), 10 deletions(-) + +diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c +index 0a5b2afb9..970ea868c 100644 +--- a/grub-core/lib/cmdline.c ++++ b/grub-core/lib/cmdline.c +@@ -97,16 +97,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + + while (*c) + { +- if (*c == ' ') +- { +- *buf++ = '\\'; +- *buf++ = 'x'; +- *buf++ = '2'; +- *buf++ = '0'; +- c++; +- continue; +- } +- else if (*c == '\\' && *(c+1) == 'x' && ++ if (*c == '\\' && *(c+1) == 'x' && + is_hex(*(c+2)) && is_hex(*(c+3))) + { + *buf++ = *c++; +-- +2.14.3 + diff --git a/0061-Try-prefix-if-fw_path-doesn-t-work.patch b/0061-Try-prefix-if-fw_path-doesn-t-work.patch deleted file mode 100644 index e107208..0000000 --- a/0061-Try-prefix-if-fw_path-doesn-t-work.patch +++ /dev/null @@ -1,211 +0,0 @@ -From d255a98813193eb2c23f9217106b121278843023 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 3 Oct 2014 11:08:03 -0400 -Subject: [PATCH 61/90] Try $prefix if $fw_path doesn't work. - -Related: rhbz#1148652 - -Signed-off-by: Peter Jones ---- - grub-core/kern/ieee1275/init.c | 30 ++++++----- - grub-core/net/net.c | 2 +- - grub-core/normal/main.c | 118 ++++++++++++++++++++--------------------- - 3 files changed, 75 insertions(+), 75 deletions(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 8a3ecd5..8efa1a6 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -139,23 +139,25 @@ grub_machine_get_bootlocation (char **device, char **path) - grub_free (canon); - } - else -- *device = grub_ieee1275_encode_devname (bootpath); -- grub_free (type); -- -- filename = grub_ieee1275_get_filename (bootpath); -- if (filename) - { -- char *lastslash = grub_strrchr (filename, '\\'); -- -- /* Truncate at last directory. */ -- if (lastslash) -+ filename = grub_ieee1275_get_filename (bootpath); -+ if (filename) - { -- *lastslash = '\0'; -- grub_translate_ieee1275_path (filename); -- -- *path = filename; -- } -+ char *lastslash = grub_strrchr (filename, '\\'); -+ -+ /* Truncate at last directory. */ -+ if (lastslash) -+ { -+ *lastslash = '\0'; -+ grub_translate_ieee1275_path (filename); -+ -+ *path = filename; -+ } -+ } -+ *device = grub_ieee1275_encode_devname (bootpath); - } -+ -+ grub_free (type); - grub_free (bootpath); - } - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 0769bf8..16d2ce0 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -1850,7 +1850,7 @@ grub_net_search_configfile (char *config) - /* Remove the remaining minus sign at the end. */ - config[config_len] = '\0'; - -- return GRUB_ERR_NONE; -+ return GRUB_ERR_FILE_NOT_FOUND; - } - - static struct grub_preboot *fini_hnd; -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 7d9c4f0..b69f9e7 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -331,74 +331,72 @@ grub_enter_normal_mode (const char *config) - grub_boot_time ("Exiting normal mode"); - } - -+static grub_err_t -+grub_try_normal (const char *variable) -+{ -+ char *config; -+ const char *prefix; -+ grub_err_t err = GRUB_ERR_FILE_NOT_FOUND; -+ -+ prefix = grub_env_get (variable); -+ if (!prefix) -+ return GRUB_ERR_FILE_NOT_FOUND; -+ -+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -+ { -+ grub_size_t config_len; -+ config_len = grub_strlen (prefix) + -+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -+ config = grub_malloc (config_len); -+ -+ if (! config) -+ return GRUB_ERR_FILE_NOT_FOUND; -+ -+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -+ err = grub_net_search_configfile (config); -+ } -+ -+ if (err != GRUB_ERR_NONE) -+ { -+ config = grub_xasprintf ("%s/grub.cfg", prefix); -+ if (config) -+ { -+ grub_file_t file; -+ file = grub_file_open (config); -+ if (file) -+ { -+ grub_file_close (file); -+ err = GRUB_ERR_NONE; -+ } -+ } -+ } -+ -+ if (err == GRUB_ERR_NONE) -+ grub_enter_normal_mode (config); -+ -+ grub_errno = 0; -+ grub_free (config); -+ return err; -+} -+ - /* Enter normal mode from rescue mode. */ - static grub_err_t - grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), - int argc, char *argv[]) - { -- if (argc == 0) -+ if (argc) -+ grub_enter_normal_mode (argv[0]); -+ else - { -- /* Guess the config filename. It is necessary to make CONFIG static, -- so that it won't get broken by longjmp. */ -- char *config; -- const char *prefix; -- -- prefix = grub_env_get ("fw_path"); -- if (! prefix) -- prefix = grub_env_get ("prefix"); -- -- if (prefix) -- { -- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -- { -- grub_size_t config_len; -- config_len = grub_strlen (prefix) + -- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -- config = grub_malloc (config_len); -- -- if (! config) -- goto quit; -- -- grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -- -- grub_net_search_configfile (config); -- -- grub_enter_normal_mode (config); -- grub_free (config); -- config = NULL; -- } -- -- if (!config) -- { -- config = grub_xasprintf ("%s/grub.cfg", prefix); -- if (config) -- { -- grub_file_t file; -- -- file = grub_file_open (config); -- if (file) -- { -- grub_file_close (file); -- grub_enter_normal_mode (config); -- } -- else -- { -- /* Ignore all errors. */ -- grub_errno = 0; -- } -- grub_free (config); -- } -- } -- } -- else -- { -- grub_enter_normal_mode (0); -- } -+ /* Guess the config filename. */ -+ grub_err_t err; -+ err = grub_try_normal ("fw_path"); -+ if (err == GRUB_ERR_FILE_NOT_FOUND) -+ err = grub_try_normal ("prefix"); -+ if (err == GRUB_ERR_FILE_NOT_FOUND) -+ grub_enter_normal_mode (0); - } -- else -- grub_enter_normal_mode (argv[0]); - --quit: - return 0; - } - --- -2.9.3 - diff --git a/0062-Don-t-require-a-password-to-boot-entries-generated-b.patch b/0062-Don-t-require-a-password-to-boot-entries-generated-b.patch new file mode 100644 index 0000000..c8fc36b --- /dev/null +++ b/0062-Don-t-require-a-password-to-boot-entries-generated-b.patch @@ -0,0 +1,31 @@ +From 8a11a21d904e7e823ee6f17faedbf45a8e28044a Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 11 Feb 2014 11:14:50 -0500 +Subject: [PATCH 062/123] Don't require a password to boot entries generated by + grub-mkconfig. + +When we set a password, we just want that to mean you can't /edit/ an entry. + +Resolves: rhbz#1030176 + +Signed-off-by: Peter Jones +--- + util/grub.d/10_linux.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 452a9f69d..79a747ebd 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -26,7 +26,7 @@ datarootdir="@datarootdir@" + export TEXTDOMAIN=@PACKAGE@ + export TEXTDOMAINDIR="@localedir@" + +-CLASS="--class gnu-linux --class gnu --class os" ++CLASS="--class gnu-linux --class gnu --class os --unrestricted" + + if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then + OS="$(sed 's, release .*$,,g' /etc/system-release)" +-- +2.14.3 + diff --git a/0062-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch b/0062-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch deleted file mode 100644 index 515e1f8..0000000 --- a/0062-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 8e6fc0ea14aa01817cc9103ffd5e328a78e56857 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 27 Oct 2014 09:22:55 -0400 -Subject: [PATCH 62/90] Try to emit linux16/initrd16 and linuxefi/initrdefi in - 30-os_prober. - -Resolves: rhbz#1108296 - -Signed-off-by: Peter Jones ---- - util/grub.d/30_os-prober.in | 30 ++++++++++++++++++++++++++---- - 1 file changed, 26 insertions(+), 4 deletions(-) - -diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 9b8f596..dc98eac 100644 ---- a/util/grub.d/30_os-prober.in -+++ b/util/grub.d/30_os-prober.in -@@ -141,6 +141,28 @@ for OS in ${OSPROBED} ; do - # os-prober returns text string followed by optional counter - CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')" - -+ sixteenbit="" -+ linuxefi="linux" -+ initrdefi="initrd" -+ case "$machine" in -+ i?86|x86_64) -+ sixteenbit="16" -+ linuxefi="linuxefi" -+ initrdefi="initrdefi" -+ ;; -+ aarch64) -+ linuxefi="linux" -+ initrdefi="initrd" -+ esac -+ linux="linux${sixteenbit}" -+ initrd="initrd${sixteenbit}" -+ # there's no way to tell that the /other/ os is booting through UEFI, -+ # but if we are it's an okay bet... -+ if [ -d /sys/firmware/efi ]; then -+ linux=$linuxefi -+ initrd=$initrdefi -+ fi -+ - gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2 - - case ${BOOT} in -@@ -241,11 +263,11 @@ EOF - save_default_entry | grub_add_tab - printf '%s\n' "${prepare_boot_cache}" - cat << EOF -- linux ${LKERNEL} ${LPARAMS} -+ ${linux} ${LKERNEL} ${LPARAMS} - EOF - if [ -n "${LINITRD}" ] ; then - cat << EOF -- initrd ${LINITRD} -+ ${initrd} ${LINITRD} - EOF - fi - cat << EOF -@@ -261,11 +283,11 @@ EOF - save_default_entry | sed -e "s/^/$grub_tab$grub_tab/" - printf '%s\n' "${prepare_boot_cache}" | grub_add_tab - cat << EOF -- linux ${LKERNEL} ${LPARAMS} -+ ${linux} ${LKERNEL} ${LPARAMS} - EOF - if [ -n "${LINITRD}" ] ; then - cat << EOF -- initrd ${LINITRD} -+ ${initrd} ${LINITRD} - EOF - fi - cat << EOF --- -2.9.3 - diff --git a/0063-Don-t-emit-Booting-.-message.patch b/0063-Don-t-emit-Booting-.-message.patch new file mode 100644 index 0000000..5643f86 --- /dev/null +++ b/0063-Don-t-emit-Booting-.-message.patch @@ -0,0 +1,52 @@ +From 5468ac6eef409220e59741ccf1073d92916cdddf Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 18 Feb 2014 09:37:49 -0500 +Subject: [PATCH 063/123] Don't emit "Booting ..." message. + +UI team still hates this stuff, so we're disabling it for RHEL 7. + +Resolves: rhbz#1023142 + +Signed-off-by: Peter Jones +--- + grub-core/normal/menu.c | 4 +++- + grub-core/normal/menu_entry.c | 3 --- + 2 files changed, 3 insertions(+), 4 deletions(-) + +diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c +index 2e8a7bd89..004711dce 100644 +--- a/grub-core/normal/menu.c ++++ b/grub-core/normal/menu.c +@@ -838,12 +838,14 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) + + /* Callback invoked immediately before a menu entry is executed. */ + static void +-notify_booting (grub_menu_entry_t entry, ++notify_booting (grub_menu_entry_t __attribute__((unused)) entry, + void *userdata __attribute__((unused))) + { ++#if 0 + grub_printf (" "); + grub_printf_ (N_("Booting `%s'"), entry->title); + grub_printf ("\n\n"); ++#endif + } + + /* Callback invoked when a default menu entry executed because of a timeout +diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c +index eeeee5580..83490494e 100644 +--- a/grub-core/normal/menu_entry.c ++++ b/grub-core/normal/menu_entry.c +@@ -1167,9 +1167,6 @@ run (struct screen *screen) + char *dummy[1] = { NULL }; + + grub_cls (); +- grub_printf (" "); +- grub_printf_ (N_("Booting a command list")); +- grub_printf ("\n\n"); + + errs_before = grub_err_printed_errors; + +-- +2.14.3 + diff --git a/0063-Make-grub2-mkconfig-construct-titles-that-look-like-.patch b/0063-Make-grub2-mkconfig-construct-titles-that-look-like-.patch deleted file mode 100644 index 15349d8..0000000 --- a/0063-Make-grub2-mkconfig-construct-titles-that-look-like-.patch +++ /dev/null @@ -1,54 +0,0 @@ -From b6e3ffe7ae7e4222cc15876cb72c691112f3c4b0 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 28 Apr 2015 11:15:03 -0400 -Subject: [PATCH 63/90] Make grub2-mkconfig construct titles that look like the - ones we want elsewhere. - -Resolves: rhbz#1215839 - -Signed-off-by: Peter Jones ---- - util/grub.d/10_linux.in | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index c662726..1215241 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -68,6 +68,15 @@ case x"$GRUB_FS" in - ;; - esac - -+mktitle () -+{ -+ local OS_NAME="$(eval $(grep ^NAME= /etc/os-release) ; echo ${NAME})" -+ local OS_VERS="$(eval $(grep ^VERSION= /etc/os-release) ; echo ${VERSION})" -+ -+ local titlestr="${OS_NAME} (%s) ${OS_VERS}" -+ echo -n ${titlestr} -+} -+ - title_correction_code= - - linux_entry () -@@ -98,15 +107,14 @@ linux_entry () - if [ x$type != xsimple ] ; then - case $type in - recovery) -- title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;; -+ title="$(printf "$(mktitle) (recovery mode)" "${version}")" ;; - *) -- title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;; -+ title="$(printf "$(mktitle)" "${version}")" ;; - esac - if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then - replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" - quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" - title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" -- grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")" - fi - echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" - else --- -2.9.3 - diff --git a/0064-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch b/0064-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch new file mode 100644 index 0000000..546f1ac --- /dev/null +++ b/0064-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch @@ -0,0 +1,1963 @@ +From cce065ff19272aa908a293632a265211201d7237 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 4 Mar 2014 11:00:23 -0500 +Subject: [PATCH 064/123] Replace a lot of man pages with slightly nicer ones. + +Replace a bunch of machine generated ones with ones that look nicer. +--- + conf/Makefile.extra-dist | 1 - + configure.ac | 23 ++++++ + docs/Makefile.am | 2 - + docs/man/grub-bios-setup.h2m | 6 -- + docs/man/grub-editenv.h2m | 5 -- + docs/man/grub-emu.h2m | 6 -- + docs/man/grub-file.h2m | 2 - + docs/man/grub-fstest.h2m | 4 - + docs/man/grub-glue-efi.h2m | 4 - + docs/man/grub-install.h2m | 6 -- + docs/man/grub-kbdcomp.h2m | 10 --- + docs/man/grub-macbless.h2m | 4 - + docs/man/grub-macho2img.h2m | 4 - + docs/man/grub-menulst2cfg.h2m | 4 - + docs/man/grub-mkconfig.h2m | 4 - + docs/man/grub-mkfont.h2m | 4 - + docs/man/grub-mkimage.h2m | 6 -- + docs/man/grub-mklayout.h2m | 10 --- + docs/man/grub-mknetdir.h2m | 4 - + docs/man/grub-mkpasswd-pbkdf2.h2m | 4 - + docs/man/grub-mkrelpath.h2m | 4 - + docs/man/grub-mkrescue.h2m | 4 - + docs/man/grub-mkstandalone.h2m | 4 - + docs/man/grub-mount.h2m | 2 - + docs/man/grub-ofpathname.h2m | 4 - + docs/man/grub-pe2elf.h2m | 4 - + docs/man/grub-probe.h2m | 4 - + docs/man/grub-reboot.h2m | 5 -- + docs/man/grub-render-label.h2m | 3 - + docs/man/grub-script-check.h2m | 4 - + docs/man/grub-set-default.h2m | 5 -- + docs/man/grub-sparc64-setup.h2m | 6 -- + docs/man/grub-syslinux2cfg.h2m | 4 - + gentpl.py | 5 +- + util/grub-bios-setup.8 | 54 +++++++++++++ + util/grub-editenv.1 | 46 +++++++++++ + util/grub-file.1 | 165 ++++++++++++++++++++++++++++++++++++++ + util/grub-fstest.1 | 99 +++++++++++++++++++++++ + util/grub-glue-efi.1 | 31 +++++++ + util/grub-install.8 | 129 +++++++++++++++++++++++++++++ + util/grub-kbdcomp.1 | 19 +++++ + util/grub-macbless.1 | 22 +++++ + util/grub-menulst2cfg.1 | 12 +++ + util/grub-mkconfig.8 | 17 ++++ + util/grub-mkfont.1 | 87 ++++++++++++++++++++ + util/grub-mkimage.1 | 95 ++++++++++++++++++++++ + util/grub-mklayout.1 | 27 +++++++ + util/grub-mknetdir.1 | 12 +++ + util/grub-mkpasswd-pbkdf2.1 | 27 +++++++ + util/grub-mkrelpath.1 | 12 +++ + util/grub-mkrescue.1 | 123 ++++++++++++++++++++++++++++ + util/grub-mkstandalone.1 | 100 +++++++++++++++++++++++ + util/grub-ofpathname.8 | 12 +++ + util/grub-probe.8 | 80 ++++++++++++++++++ + util/grub-reboot.8 | 21 +++++ + util/grub-render-label.1 | 51 ++++++++++++ + util/grub-script-check.1 | 21 +++++ + util/grub-set-default.8 | 21 +++++ + util/grub-sparc64-setup.8 | 12 +++ + 59 files changed, 1319 insertions(+), 147 deletions(-) + delete mode 100644 docs/man/grub-bios-setup.h2m + delete mode 100644 docs/man/grub-editenv.h2m + delete mode 100644 docs/man/grub-emu.h2m + delete mode 100644 docs/man/grub-file.h2m + delete mode 100644 docs/man/grub-fstest.h2m + delete mode 100644 docs/man/grub-glue-efi.h2m + delete mode 100644 docs/man/grub-install.h2m + delete mode 100644 docs/man/grub-kbdcomp.h2m + delete mode 100644 docs/man/grub-macbless.h2m + delete mode 100644 docs/man/grub-macho2img.h2m + delete mode 100644 docs/man/grub-menulst2cfg.h2m + delete mode 100644 docs/man/grub-mkconfig.h2m + delete mode 100644 docs/man/grub-mkfont.h2m + delete mode 100644 docs/man/grub-mkimage.h2m + delete mode 100644 docs/man/grub-mklayout.h2m + delete mode 100644 docs/man/grub-mknetdir.h2m + delete mode 100644 docs/man/grub-mkpasswd-pbkdf2.h2m + delete mode 100644 docs/man/grub-mkrelpath.h2m + delete mode 100644 docs/man/grub-mkrescue.h2m + delete mode 100644 docs/man/grub-mkstandalone.h2m + delete mode 100644 docs/man/grub-mount.h2m + delete mode 100644 docs/man/grub-ofpathname.h2m + delete mode 100644 docs/man/grub-pe2elf.h2m + delete mode 100644 docs/man/grub-probe.h2m + delete mode 100644 docs/man/grub-reboot.h2m + delete mode 100644 docs/man/grub-render-label.h2m + delete mode 100644 docs/man/grub-script-check.h2m + delete mode 100644 docs/man/grub-set-default.h2m + delete mode 100644 docs/man/grub-sparc64-setup.h2m + delete mode 100644 docs/man/grub-syslinux2cfg.h2m + create mode 100644 util/grub-bios-setup.8 + create mode 100644 util/grub-editenv.1 + create mode 100644 util/grub-file.1 + create mode 100644 util/grub-fstest.1 + create mode 100644 util/grub-glue-efi.1 + create mode 100644 util/grub-install.8 + create mode 100644 util/grub-kbdcomp.1 + create mode 100644 util/grub-macbless.1 + create mode 100644 util/grub-menulst2cfg.1 + create mode 100644 util/grub-mkconfig.8 + create mode 100644 util/grub-mkfont.1 + create mode 100644 util/grub-mkimage.1 + create mode 100644 util/grub-mklayout.1 + create mode 100644 util/grub-mknetdir.1 + create mode 100644 util/grub-mkpasswd-pbkdf2.1 + create mode 100644 util/grub-mkrelpath.1 + create mode 100644 util/grub-mkrescue.1 + create mode 100644 util/grub-mkstandalone.1 + create mode 100644 util/grub-ofpathname.8 + create mode 100644 util/grub-probe.8 + create mode 100644 util/grub-reboot.8 + create mode 100644 util/grub-render-label.1 + create mode 100644 util/grub-script-check.1 + create mode 100644 util/grub-set-default.8 + create mode 100644 util/grub-sparc64-setup.8 + +diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist +index b16bd9253..39eb94bde 100644 +--- a/conf/Makefile.extra-dist ++++ b/conf/Makefile.extra-dist +@@ -11,7 +11,6 @@ EXTRA_DIST += unicode + EXTRA_DIST += util/import_gcry.py + EXTRA_DIST += util/import_unicode.py + +-EXTRA_DIST += docs/man + EXTRA_DIST += docs/autoiso.cfg + EXTRA_DIST += docs/grub.cfg + EXTRA_DIST += docs/osdetect.cfg +diff --git a/configure.ac b/configure.ac +index ab9134c86..9937a827f 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -70,6 +70,29 @@ grub_TRANSFORM([grub-set-default]) + grub_TRANSFORM([grub-sparc64-setup]) + grub_TRANSFORM([grub-render-label]) + grub_TRANSFORM([grub-file]) ++grub_TRANSFORM([grub-bios-setup.3]) ++grub_TRANSFORM([grub-editenv.1]) ++grub_TRANSFORM([grub-fstest.3]) ++grub_TRANSFORM([grub-glue-efi.3]) ++grub_TRANSFORM([grub-install.1]) ++grub_TRANSFORM([grub-kbdcomp.3]) ++grub_TRANSFORM([grub-menulst2cfg.1]) ++grub_TRANSFORM([grub-mkconfig.1]) ++grub_TRANSFORM([grub-mkfont.3]) ++grub_TRANSFORM([grub-mkimage.1]) ++grub_TRANSFORM([grub-mklayout.3]) ++grub_TRANSFORM([grub-mknetdir.3]) ++grub_TRANSFORM([grub-mkpasswd-pbkdf2.3]) ++grub_TRANSFORM([grub-mkrelpath.3]) ++grub_TRANSFORM([grub-mkrescue.1]) ++grub_TRANSFORM([grub-mkstandalone.3]) ++grub_TRANSFORM([grub-ofpathname.3]) ++grub_TRANSFORM([grub-probe.3]) ++grub_TRANSFORM([grub-reboot.3]) ++grub_TRANSFORM([grub-render-label.3]) ++grub_TRANSFORM([grub-script-check.3]) ++grub_TRANSFORM([grub-set-default.1]) ++grub_TRANSFORM([grub-sparc64-setup.3]) + + # Optimization flag. Allow user to override. + if test "x$TARGET_CFLAGS" = x; then +diff --git a/docs/Makefile.am b/docs/Makefile.am +index 93eb39627..ab28f1996 100644 +--- a/docs/Makefile.am ++++ b/docs/Makefile.am +@@ -5,5 +5,3 @@ info_TEXINFOS = grub.texi grub-dev.texi + grub_TEXINFOS = fdl.texi + + EXTRA_DIST = font_char_metrics.png font_char_metrics.txt +- +- +diff --git a/docs/man/grub-bios-setup.h2m b/docs/man/grub-bios-setup.h2m +deleted file mode 100644 +index ac6ede362..000000000 +--- a/docs/man/grub-bios-setup.h2m ++++ /dev/null +@@ -1,6 +0,0 @@ +-[NAME] +-grub-bios-setup \- set up a device to boot using GRUB +-[SEE ALSO] +-.BR grub-install (8), +-.BR grub-mkimage (1), +-.BR grub-mkrescue (1) +diff --git a/docs/man/grub-editenv.h2m b/docs/man/grub-editenv.h2m +deleted file mode 100644 +index 3859d3d4c..000000000 +--- a/docs/man/grub-editenv.h2m ++++ /dev/null +@@ -1,5 +0,0 @@ +-[NAME] +-grub-editenv \- edit GRUB environment block +-[SEE ALSO] +-.BR grub-reboot (8), +-.BR grub-set-default (8) +diff --git a/docs/man/grub-emu.h2m b/docs/man/grub-emu.h2m +deleted file mode 100644 +index ef1c00065..000000000 +--- a/docs/man/grub-emu.h2m ++++ /dev/null +@@ -1,6 +0,0 @@ +-[NAME] +-grub-emu \- GRUB emulator +-[SEE ALSO] +-If you are trying to install GRUB, then you should use +-.BR grub-install (8) +-rather than this program. +diff --git a/docs/man/grub-file.h2m b/docs/man/grub-file.h2m +deleted file mode 100644 +index e09bb4d31..000000000 +--- a/docs/man/grub-file.h2m ++++ /dev/null +@@ -1,2 +0,0 @@ +-[NAME] +-grub-file \- check file type +diff --git a/docs/man/grub-fstest.h2m b/docs/man/grub-fstest.h2m +deleted file mode 100644 +index 9676b159a..000000000 +--- a/docs/man/grub-fstest.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-fstest \- debug tool for GRUB filesystem drivers +-[SEE ALSO] +-.BR grub-probe (8) +diff --git a/docs/man/grub-glue-efi.h2m b/docs/man/grub-glue-efi.h2m +deleted file mode 100644 +index c1c6ded49..000000000 +--- a/docs/man/grub-glue-efi.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-glue-efi \- generate a fat binary for EFI +-[DESCRIPTION] +-grub-glue-efi processes ia32 and amd64 EFI images and glues them according to Apple format. +diff --git a/docs/man/grub-install.h2m b/docs/man/grub-install.h2m +deleted file mode 100644 +index 8cbbc87a0..000000000 +--- a/docs/man/grub-install.h2m ++++ /dev/null +@@ -1,6 +0,0 @@ +-[NAME] +-grub-install \- install GRUB to a device +-[SEE ALSO] +-.BR grub-mkconfig (8), +-.BR grub-mkimage (1), +-.BR grub-mkrescue (1) +diff --git a/docs/man/grub-kbdcomp.h2m b/docs/man/grub-kbdcomp.h2m +deleted file mode 100644 +index d81f9157e..000000000 +--- a/docs/man/grub-kbdcomp.h2m ++++ /dev/null +@@ -1,10 +0,0 @@ +-[NAME] +-grub-kbdcomp \- generate a GRUB keyboard layout file +-[DESCRIPTION] +-grub-kbdcomp processes a X keyboard layout description in +-.BR keymaps (5) +-format into a format that can be used by GRUB's +-.B keymap +-command. +-[SEE ALSO] +-.BR grub-mklayout (8) +diff --git a/docs/man/grub-macbless.h2m b/docs/man/grub-macbless.h2m +deleted file mode 100644 +index 0197c0087..000000000 +--- a/docs/man/grub-macbless.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-macbless \- bless a mac file/directory +-[SEE ALSO] +-.BR grub-install (1) +diff --git a/docs/man/grub-macho2img.h2m b/docs/man/grub-macho2img.h2m +deleted file mode 100644 +index d79aaeed8..000000000 +--- a/docs/man/grub-macho2img.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-macho2img \- convert Mach-O to raw image +-[SEE ALSO] +-.BR grub-mkimage (1) +diff --git a/docs/man/grub-menulst2cfg.h2m b/docs/man/grub-menulst2cfg.h2m +deleted file mode 100644 +index c2e0055ed..000000000 +--- a/docs/man/grub-menulst2cfg.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-menulst2cfg \- transform legacy menu.lst into grub.cfg +-[SEE ALSO] +-.BR grub-mkconfig (8) +diff --git a/docs/man/grub-mkconfig.h2m b/docs/man/grub-mkconfig.h2m +deleted file mode 100644 +index 9b42f8130..000000000 +--- a/docs/man/grub-mkconfig.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-mkconfig \- generate a GRUB configuration file +-[SEE ALSO] +-.BR grub-install (8) +diff --git a/docs/man/grub-mkfont.h2m b/docs/man/grub-mkfont.h2m +deleted file mode 100644 +index d46fe600e..000000000 +--- a/docs/man/grub-mkfont.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-mkfont \- make GRUB font files +-[SEE ALSO] +-.BR grub-mkconfig (8) +diff --git a/docs/man/grub-mkimage.h2m b/docs/man/grub-mkimage.h2m +deleted file mode 100644 +index f0fbc2bb1..000000000 +--- a/docs/man/grub-mkimage.h2m ++++ /dev/null +@@ -1,6 +0,0 @@ +-[NAME] +-grub-mkimage \- make a bootable image of GRUB +-[SEE ALSO] +-.BR grub-install (8), +-.BR grub-mkrescue (1), +-.BR grub-mknetdir (8) +diff --git a/docs/man/grub-mklayout.h2m b/docs/man/grub-mklayout.h2m +deleted file mode 100644 +index 1e43409c0..000000000 +--- a/docs/man/grub-mklayout.h2m ++++ /dev/null +@@ -1,10 +0,0 @@ +-[NAME] +-grub-mklayout \- generate a GRUB keyboard layout file +-[DESCRIPTION] +-grub-mklayout processes a keyboard layout description in +-.BR keymaps (5) +-format into a format that can be used by GRUB's +-.B keymap +-command. +-[SEE ALSO] +-.BR grub-mkconfig (8) +diff --git a/docs/man/grub-mknetdir.h2m b/docs/man/grub-mknetdir.h2m +deleted file mode 100644 +index a2ef13ec1..000000000 +--- a/docs/man/grub-mknetdir.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-mknetdir \- prepare a GRUB netboot directory. +-[SEE ALSO] +-.BR grub-mkimage (1) +diff --git a/docs/man/grub-mkpasswd-pbkdf2.h2m b/docs/man/grub-mkpasswd-pbkdf2.h2m +deleted file mode 100644 +index 4d202f3da..000000000 +--- a/docs/man/grub-mkpasswd-pbkdf2.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-mkpasswd-pbkdf2 \- generate hashed password for GRUB +-[SEE ALSO] +-.BR grub-mkconfig (8) +diff --git a/docs/man/grub-mkrelpath.h2m b/docs/man/grub-mkrelpath.h2m +deleted file mode 100644 +index d01f3961e..000000000 +--- a/docs/man/grub-mkrelpath.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-mkrelpath \- make a system path relative to its root +-[SEE ALSO] +-.BR grub-probe (8) +diff --git a/docs/man/grub-mkrescue.h2m b/docs/man/grub-mkrescue.h2m +deleted file mode 100644 +index a427f02e3..000000000 +--- a/docs/man/grub-mkrescue.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-mkrescue \- make a GRUB rescue image +-[SEE ALSO] +-.BR grub-mkimage (1) +diff --git a/docs/man/grub-mkstandalone.h2m b/docs/man/grub-mkstandalone.h2m +deleted file mode 100644 +index c77313978..000000000 +--- a/docs/man/grub-mkstandalone.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-mkstandalone \- make a memdisk-based GRUB image +-[SEE ALSO] +-.BR grub-mkimage (1) +diff --git a/docs/man/grub-mount.h2m b/docs/man/grub-mount.h2m +deleted file mode 100644 +index 8d168982d..000000000 +--- a/docs/man/grub-mount.h2m ++++ /dev/null +@@ -1,2 +0,0 @@ +-[NAME] +-grub-mount \- export GRUB filesystem with FUSE +diff --git a/docs/man/grub-ofpathname.h2m b/docs/man/grub-ofpathname.h2m +deleted file mode 100644 +index 74b43eea0..000000000 +--- a/docs/man/grub-ofpathname.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-ofpathname \- find OpenBOOT path for a device +-[SEE ALSO] +-.BR grub-probe (8) +diff --git a/docs/man/grub-pe2elf.h2m b/docs/man/grub-pe2elf.h2m +deleted file mode 100644 +index 7ca29bd70..000000000 +--- a/docs/man/grub-pe2elf.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-pe2elf \- convert PE image to ELF +-[SEE ALSO] +-.BR grub-mkimage (1) +diff --git a/docs/man/grub-probe.h2m b/docs/man/grub-probe.h2m +deleted file mode 100644 +index 6e1ffdcf9..000000000 +--- a/docs/man/grub-probe.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-probe \- probe device information for GRUB +-[SEE ALSO] +-.BR grub-fstest (1) +diff --git a/docs/man/grub-reboot.h2m b/docs/man/grub-reboot.h2m +deleted file mode 100644 +index e4acace65..000000000 +--- a/docs/man/grub-reboot.h2m ++++ /dev/null +@@ -1,5 +0,0 @@ +-[NAME] +-grub-reboot \- set the default boot entry for GRUB, for the next boot only +-[SEE ALSO] +-.BR grub-set-default (8), +-.BR grub-editenv (1) +diff --git a/docs/man/grub-render-label.h2m b/docs/man/grub-render-label.h2m +deleted file mode 100644 +index 50ae5247c..000000000 +--- a/docs/man/grub-render-label.h2m ++++ /dev/null +@@ -1,3 +0,0 @@ +-[NAME] +-grub-render-label \- generate a .disk_label for Apple Macs. +- +diff --git a/docs/man/grub-script-check.h2m b/docs/man/grub-script-check.h2m +deleted file mode 100644 +index 365368267..000000000 +--- a/docs/man/grub-script-check.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-script-check \- check grub.cfg for syntax errors +-[SEE ALSO] +-.BR grub-mkconfig (8) +diff --git a/docs/man/grub-set-default.h2m b/docs/man/grub-set-default.h2m +deleted file mode 100644 +index 7945001c1..000000000 +--- a/docs/man/grub-set-default.h2m ++++ /dev/null +@@ -1,5 +0,0 @@ +-[NAME] +-grub-set-default \- set the saved default boot entry for GRUB +-[SEE ALSO] +-.BR grub-reboot (8), +-.BR grub-editenv (1) +diff --git a/docs/man/grub-sparc64-setup.h2m b/docs/man/grub-sparc64-setup.h2m +deleted file mode 100644 +index 18f803a50..000000000 +--- a/docs/man/grub-sparc64-setup.h2m ++++ /dev/null +@@ -1,6 +0,0 @@ +-[NAME] +-grub-sparc64-setup \- set up a device to boot using GRUB +-[SEE ALSO] +-.BR grub-install (8), +-.BR grub-mkimage (1), +-.BR grub-mkrescue (1) +diff --git a/docs/man/grub-syslinux2cfg.h2m b/docs/man/grub-syslinux2cfg.h2m +deleted file mode 100644 +index ad25c8ab7..000000000 +--- a/docs/man/grub-syslinux2cfg.h2m ++++ /dev/null +@@ -1,4 +0,0 @@ +-[NAME] +-grub-syslinux2cfg \- transform syslinux config into grub.cfg +-[SEE ALSO] +-.BR grub-menulst2cfg (8) +diff --git a/gentpl.py b/gentpl.py +index f08bcc404..f069585e8 100644 +--- a/gentpl.py ++++ b/gentpl.py +@@ -800,10 +800,7 @@ def manpage(defn, adddeps): + + output("if COND_MAN_PAGES\n") + gvar_add("man_MANS", name + "." + mansection) +- rule(name + "." + mansection, name + " " + adddeps, """ +-chmod a+x """ + name + """ +-PATH=$(builddir):$$PATH pkgdatadir=$(builddir) $(HELP2MAN) --section=""" + mansection + """ -i $(top_srcdir)/docs/man/""" + name + """.h2m -o $@ """ + name + """ +-""") ++ rule(name + "." + mansection, name + " " + adddeps, "cat $(top_srcdir)/util/" + name + "." + mansection + " | $(top_builddir)/config.status --file=$@:-") + gvar_add("CLEANFILES", name + "." + mansection) + output("endif\n") + +diff --git a/util/grub-bios-setup.8 b/util/grub-bios-setup.8 +new file mode 100644 +index 000000000..56f582b3d +--- /dev/null ++++ b/util/grub-bios-setup.8 +@@ -0,0 +1,54 @@ ++.TH GRUB-BIOS-SETUP 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-bios-setup\fR \(em Set up images to boot from a device. ++ ++.SH SYNOPSIS ++\fBgrub-bios-setup\fR [-a | --allow-floppy] [-b | --boot-image=\fIFILE\fR] ++.RS 17 ++[-c | --core-image=\fIFILE\fR] [-d | --directory=\fIDIR\fR] ++.RE ++.RS 17 ++[-f | --force] [-m | --device-map=\fIFILE\fR] ++.RE ++.RS 17 ++[-s | --skip-fs-probe] [-v | --verbose] \fIDEVICE\fR ++ ++.SH DESCRIPTION ++You should not normally run this program directly. Use grub-install instead. ++ ++.SH OPTIONS ++.TP ++\fB--allow-floppy\fR ++Make the device also bootable as a floppy. This option is the default for ++/dev/fdX devices. Some BIOSes will not boot images created with this option. ++ ++.TP ++\fB--boot-image\fR=\fIFILE\fR ++Use FILE as the boot image. The default value is \fBboot.img\fR. ++ ++.TP ++\fB--core-image\fR=\fIFILE\fR ++Use FILE as ther core image. The default value is \fBcore.img\fR. ++ ++.TP ++\fB--directory\fR=\fIDIR\fR ++Use GRUB files in the directory DIR. The default value is \fB/boot/grub\fR. ++ ++.TP ++\fB--force\fR ++Install even if problems are detected. ++ ++.TP ++\fB--device-map\fR=\fIFILE\fR ++Use FILE as the device map. The default value is /boot/grub/device.map . ++ ++.TP ++\fB--skip-fs-probe\fR ++Do not probe DEVICE for filesystems. ++ ++.TP ++\fB--verbose\fR ++Print verbose messages. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-editenv.1 b/util/grub-editenv.1 +new file mode 100644 +index 000000000..d28ba03ba +--- /dev/null ++++ b/util/grub-editenv.1 +@@ -0,0 +1,46 @@ ++.TH GRUB-EDITENV 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-editenv\fR \(em Manage the GRUB environment block. ++ ++.SH SYNOPSIS ++\fBgrub-editenv\fR [-v | --verbose] [\fIFILE\fR] ++.RS 14 ++ ++ ++.SH DESCRIPTION ++\fBgrub-editenv\fR is a command line tool to manage GRUB's stored environment. ++ ++.SH OPTIONS ++.TP ++\fB--verbose\fR ++Print verbose messages. ++ ++.TP ++\fBFILE\fR ++.RS 7 ++File name to use for grub environment. Default is /boot/grub/grubenv . ++.RE ++ ++.SH COMMANDS ++.TP ++\fBcreate\fR ++.RS 7 ++Create a blank environment block file. ++.RE ++ ++.TP ++\fBlist\fR ++.RS 7 ++List the current variables. ++.RE ++ ++.TP ++\fBset\fR [\fINAME\fR=\fIVALUE\fR ...] ++Set variables. ++ ++.TP ++\fBunset [\fINAME\fR ...] ++Delete variables. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-file.1 b/util/grub-file.1 +new file mode 100644 +index 000000000..b29cb3278 +--- /dev/null ++++ b/util/grub-file.1 +@@ -0,0 +1,165 @@ ++.TH GRUB-FILE 1 "Web Feb 26 2014" ++.SH NAME ++\fBgrub-file\fR \(em Check if FILE is of specified type. ++ ++.SH SYNOPSIS ++\fBgrub-file\fR (--is-i386-xen-pae-domu | --is-x86_64-xen-domu | ++.RS 11 ++--is-x86-xen-dom0 | --is-x86-multiboot | ++.RE ++.RS 11 ++--is-x86-multiboot2 | --is-arm-linux | --is-arm64-linux | ++.RE ++.RS 11 ++--is-ia64-linux | --is-mips-linux | --is-mipsel-linux | ++.RE ++.RS 11 ++--is-sparc64-linux | --is-powerpc-linux | --is-x86-linux | ++.RE ++.RS 11 ++--is-x86-linux32 | --is-x86-kfreebsd | --is-i386-kfreebsd | ++.RE ++.RS 11 ++--is-x86_64-kfreebsd | --is-x86-knetbsd | ++.RE ++.RS 11 ++--is-i386-knetbsd | --is-x86_64-knetbsd | --is-i386-efi | ++.RE ++.RS 11 ++--is-x86_64-efi | --is-ia64-efi | --is-arm64-efi | ++.RE ++.RS 11 ++--is-arm-efi | --is-hibernated-hiberfil | --is-x86_64-xnu | ++.RE ++.RS 11 ++--is-i386-xnu | --is-xnu-hibr | --is-x86-bios-bootsector) ++.RE ++.RS 11 ++\fIFILE\fR ++ ++.SH DESCRIPTION ++\fBgrub-file\fR is used to check if \fIFILE\fR is of a specified type. ++ ++.SH OPTIONS ++.TP ++--is-i386-xen-pae-domu ++Check if FILE can be booted as i386 PAE Xen unprivileged guest kernel ++ ++.TP ++--is-x86_64-xen-domu ++Check if FILE can be booted as x86_64 Xen unprivileged guest kernel ++ ++.TP ++--is-x86-xen-dom0 ++Check if FILE can be used as Xen x86 privileged guest kernel ++ ++.TP ++--is-x86-multiboot ++Check if FILE can be used as x86 multiboot kernel ++ ++.TP ++--is-x86-multiboot2 ++Check if FILE can be used as x86 multiboot2 kernel ++ ++.TP ++--is-arm-linux ++Check if FILE is ARM Linux ++ ++.TP ++--is-arm64-linux ++Check if FILE is ARM64 Linux ++ ++.TP ++--is-ia64-linux ++Check if FILE is IA64 Linux ++ ++.TP ++--is-mips-linux ++Check if FILE is MIPS Linux ++ ++.TP ++--is-mipsel-linux ++Check if FILE is MIPSEL Linux ++ ++.TP ++--is-sparc64-linux ++Check if FILE is SPARC64 Linux ++ ++.TP ++--is-powerpc-linux ++Check if FILE is POWERPC Linux ++ ++.TP ++--is-x86-linux ++Check if FILE is x86 Linux ++ ++.TP ++--is-x86-linux32 ++Check if FILE is x86 Linux supporting 32-bit protocol ++ ++.TP ++--is-x86-kfreebsd ++Check if FILE is x86 kFreeBSD ++ ++.TP ++--is-i386-kfreebsd ++Check if FILE is i386 kFreeBSD ++ ++.TP ++--is-x86_64-kfreebsd ++Check if FILE is x86_64 kFreeBSD ++ ++.TP ++--is-x86-knetbsd ++Check if FILE is x86 kNetBSD ++ ++.TP ++--is-i386-knetbsd ++Check if FILE is i386 kNetBSD ++ ++.TP ++--is-x86_64-knetbsd ++Check if FILE is x86_64 kNetBSD ++ ++.TP ++--is-i386-efi ++Check if FILE is i386 EFI file ++ ++.TP ++--is-x86_64-efi ++Check if FILE is x86_64 EFI file ++ ++.TP ++--is-ia64-efi ++Check if FILE is IA64 EFI file ++ ++.TP ++--is-arm64-efi ++Check if FILE is ARM64 EFI file ++ ++.TP ++--is-arm-efi ++Check if FILE is ARM EFI file ++ ++.TP ++--is-hibernated-hiberfil ++Check if FILE is hiberfil.sys in hibernated state ++ ++.TP ++--is-x86_64-xnu ++Check if FILE is x86_64 XNU (Mac OS X kernel) ++ ++.TP ++--is-i386-xnu ++Check if FILE is i386 XNU (Mac OS X kernel) ++ ++.TP ++--is-xnu-hibr ++Check if FILE is XNU (Mac OS X kernel) hibernated image ++ ++.TP ++--is-x86-bios-bootsector ++Check if FILE is BIOS bootsector ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-fstest.1 b/util/grub-fstest.1 +new file mode 100644 +index 000000000..792fa7863 +--- /dev/null ++++ b/util/grub-fstest.1 +@@ -0,0 +1,99 @@ ++.TH GRUB-FSTEST 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-fstest\fR — Debug tool for GRUB's filesystem driver. ++ ++.SH SYNOPSIS ++\fBgrub-fstest\fR [-c | --diskcount=\fINUM\fR] [-C | --crypto] ++.RS 13 ++[-d | --debug=\fISTRING\fR] [-K | --zfs-key=\fIFILE\fR|\fIprompt\fR] ++.RE ++.RS 13 ++[-n | --length=\fINUM\fR] [-r | --root=\fIDEVICE_NAME\fR] ++.RE ++.RS 13 ++[-s | --skip=\fINUM\fR] [-u | --uncompress] [-v | --verbose] ++.RE ++.RS 13 ++\fIIMAGE_PATH\fR ++ ++.SH DESCRIPTION ++\fBgrub-fstest\fR is a tool for testing GRUB's filesystem drivers. You should not normally need to run this program. ++ ++.SH OPTIONS ++.TP ++\fB--diskcount\fR=\fINUM\fR ++Specify the number of input files. ++ ++.TP ++\fB--crypto\fR ++Mount cryptographic devices. ++ ++.TP ++\fB--debug\fR=\fISTRING\fR ++Set debug environment variable. ++ ++.TP ++\fB--zfs-key\fR=\fIFILE\fR|\fIprompt\fR ++Load ZFS cryptographic key. ++ ++.TP ++\fB--length\fR=\fINUM\fR ++Handle NUM bytes in output file. ++ ++.TP ++\fB--root\fR=\fIDEVICE_NAME\fR ++Set root device. ++ ++.TP ++\fB--skip\fR=\fINUM\fR ++Skip NUM bytes from output file. ++ ++.TP ++\fB--uncompress\fR ++Uncompress data. ++ ++.TP ++\fB--verbose\fR ++Print verbose messages. ++ ++.SH COMMANDS ++.TP ++\fBblocklist\fR \fIFILE\fR ++Display block list of \fIFILE\fR. ++ ++.TP ++\fBcat\fR \fIFILE\fR ++Display \fIFILE\fR on standard output. ++ ++.TP ++\fBcmp\fR \fIFILE\fR \fILOCAL\fR ++Compare \fIFILE\fR with local file \fILOCAL\fR. ++ ++.TP ++\fBcp\fR \fIFILE\fR \fILOCAL\fR ++Copy \fIFILE\fR to local file \fILOCAL\fR. ++ ++.TP ++\fBcrc\fR \fIFILE\fR ++Display the CRC-32 checksum of \fIFILE\fR. ++ ++.TP ++\fBhex\fR \fIFILE\fR ++Display contents of \fIFILE\fR in hexidecimal. ++ ++.TP ++\fBls\fR \fIPATH\fR ++List files at \fIPATH\fR. ++ ++.TP ++\fBxnu_uuid\fR \fIDEVICE\fR ++Display the XNU UUID of \fIDEVICE\fR. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-glue-efi.1 b/util/grub-glue-efi.1 +new file mode 100644 +index 000000000..72bd555d5 +--- /dev/null ++++ b/util/grub-glue-efi.1 +@@ -0,0 +1,31 @@ ++.TH GRUB-GLUE-EFI 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-glue-efi\fR \(em Create an Apple fat EFI binary. ++ ++.SH SYNOPSIS ++\fBgrub-glue-efi\fR <-3 | --input32=\fIFILE\fR> <-6 | --input64=\fIFILE\fR> ++.RS 15 ++<-o | --output=\fIFILE\fR> [-v | --verbose] ++ ++.SH DESCRIPTION ++\fBgrub-glue-efi\fR creates an Apple fat EFI binary from two EFI binaries. ++ ++.SH OPTIONS ++.TP ++\fB--input32\fR=\fIFILE\fR ++Read 32-bit binary from \fIFILE\fR. ++ ++.TP ++\fB--input64\fR=\fIFILE\fR ++Read 64-bit binary from \fIFILE\fR. ++ ++.TP ++\fB--output\fR=\fIFILE\fR ++Write resulting fat binary to \fIFILE\fR. ++ ++.TP ++\fB--verbose\fR ++Print verbose messages. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-install.8 b/util/grub-install.8 +new file mode 100644 +index 000000000..76272a39d +--- /dev/null ++++ b/util/grub-install.8 +@@ -0,0 +1,129 @@ ++.TH GRUB-INSTALL 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-install\fR \(em Install GRUB on a device. ++ ++.SH SYNOPSIS ++\fBgrub-install\fR [--modules=\fIMODULES\fR] [--install-modules=\fIMODULES\fR] ++.RS 14 ++[--themes=\fITHEMES\fR] [--fonts=\fIFONTS\fR] [--locales=\fILOCALES\fR] ++.RE ++.RS 14 ++[--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR]] [-d | --directory=\fIDIR\fR] ++.RE ++.RS 14 ++[--grub-mkimage=\fIFILE\fR] [--boot-directory=\fIDIR\fR] ++.RE ++.RS 14 ++[--target=\fITARGET\fR] [--grub-setup=\fIFILE\fR] ++.RE ++.RS 14 ++[--grub-mkrelpath=\fIFILE\fR] [--grub-probe=\fIFILE\fR] ++.RE ++.RS 14 ++[--allow-floppy] [--recheck] [--force] [--force-file-id] ++.RE ++.RS 14 ++[--disk-module=\fIMODULE\fR] [--no-nvram] [--removable] ++.RE ++.RS 14 ++[--bootloader-id=\fIID\fR] [--efi-directory=\fIDIR\fR] \fIINSTALL_DEVICE\fR ++ ++.SH DESCRIPTION ++\fBgrub-install\fR installs GRUB onto a device. This includes copying GRUB images into the target directory (generally \fI/boot/grub\fR), and on some platforms may also include installing GRUB onto a boot sector. ++ ++.SH OPTIONS ++.TP ++\fB--modules\fR=\fIMODULES\fR\! ++Pre-load modules specified by \fIMODULES\fR. ++ ++.TP ++\fB--install-modules\fR=\fIMODULES\fR ++Install only \fIMODULES\fR and their dependencies. The default is to install all available modules. ++ ++.TP ++\fB--themes\fR=\fITHEMES\fR ++Install \fITHEMES\fR. The default is to install the \fIstarfield\fR theme, if available. ++ ++.TP ++\fB--fonts\fR=\fIFONTS\fR ++Install \fIFONTS\fR. The default is to install the \fIunicode\fR font. ++ ++.TP ++\fB--locales\fR=\fILOCALES\fR ++Install only locales listed in \fILOCALES\fR. The default is to install all available locales. ++ ++.TP ++\fB--compress\fR=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR ++Compress GRUB files using the specified compression algorithm. ++ ++.TP ++\fB--directory\fR=\fIDIR\fR ++Use images and modules in \fIDIR\fR. ++ ++.TP ++\fB--grub-mkimage\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-mkimage\fR. The default is \fI/usr/bin/grub-mkimage\fR. ++ ++.TP ++\fB--boot-directory\fR=\fIDIR\fR ++Use \fIDIR\fR as the boot directory. The default is \fI/boot\fR. GRUB will put its files in a subdirectory of this directory named \fIgrub\fR. ++ ++.TP ++\fB--target\fR=\fITARGET\fR ++Install GRUB for \fITARGET\fR platform. The default is the platform \fBgrub-install\fR is running on. ++ ++.TP ++\fB--grub-setup\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-setup\fR. The default is \fI/usr/bin/grub-setup\fR. ++ ++.TP ++\fB--grub-mkrelpath\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-mkrelpath\fR. The default is \fI/usr/bin/grub-mkrelpath\fR. ++ ++.TP ++\fB--grub-probe\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-probe\fR. The default is \fI/usr/bin/grub-mkrelpath\fR. ++ ++.TP ++\fB--allow-floppy ++Make the device also bootable as a floppy. This option is the default for /dev/fdX devices. Some BIOSes will not boot images created with this option. ++ ++.TP ++\fB--recheck ++Delete any existing device map and create a new one if necessary. ++ ++.TP ++\fB--force ++Install even if problems are detected. ++ ++.TP ++\fB--force-file-id ++Use identifier file even if UUID is available. ++ ++.TP ++\fB--disk-module\fR=\fIMODULE\fR ++Use \fIMODULE\fR for disk access. This allows you to manually specify either \fIbiosdisk\fR or \fInative\fR disk access. This option is only available on the BIOS target platform. ++ ++.TP ++\fB--no-nvram ++Do not update the \fIboot-device\fR NVRAM variable. This option is only available on IEEE1275 target platforms. ++ ++.TP ++\fB--removable ++Treat the target device as if it is removeable. This option is only available on the EFI target platform. ++ ++.TP ++\fB--bootloader-id\fR=\fIID\fR ++Use \fIID\fR as the bootloader ID. This opption is only available on the EFI target platform. ++ ++.TP ++\fB--efi-directory\fR=\fIDIR\fR ++Use \fIDIR\fR as the EFI System Partition root. This opption is only available on the EFI ta ++rget platform. ++ ++.TP ++\fIINSTALL_DEVICE\fR ++Install GRUB to the block device \fIINSTALL_DEVICE\fR. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-kbdcomp.1 b/util/grub-kbdcomp.1 +new file mode 100644 +index 000000000..0bb969a5b +--- /dev/null ++++ b/util/grub-kbdcomp.1 +@@ -0,0 +1,19 @@ ++.TH GRUB-KBDCOMP 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-kbdcomp\fR \(em Generate a GRUB keyboard layout file. ++ ++.SH SYNOPSIS ++\fBgrub-kbdcomp\fR <-o | --output=\fIFILE\fR> \fICKBMAP_ARGUMENTS\fR ++ ++.SH DESCRIPTION ++\fBgrub-kbdcomp\fR processes an X keyboard layout description in ++\fBkeymaps\fR(5) format into a format that can be used by GRUB's \fBkeymap\fR ++command. ++ ++.SH OPTIONS ++.TP ++\fB--output\fR=\fIFILE\fR ++Write output to \fIFILE\fR. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-macbless.1 b/util/grub-macbless.1 +new file mode 100644 +index 000000000..41a96186f +--- /dev/null ++++ b/util/grub-macbless.1 +@@ -0,0 +1,22 @@ ++.TH GRUB-MACBLESS 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-macbless\fR \(em Mac-style bless on HFS or HFS+ ++ ++.SH SYNOPSIS ++\fBgrub-macbless\fR [-v | --verbose] [-p | --ppc] \fIFILE\fR | [-x | --x86] \fIFILE\fR ++ ++.SH OPTIONS ++.TP ++--x86 ++Bless for x86 based Macs. ++ ++.TP ++--ppc ++Bless for PPC based Macs. ++ ++.TP ++--verbose ++Print verbose messages. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-menulst2cfg.1 b/util/grub-menulst2cfg.1 +new file mode 100644 +index 000000000..91e2ef871 +--- /dev/null ++++ b/util/grub-menulst2cfg.1 +@@ -0,0 +1,12 @@ ++.TH GRUB-MENULST2CFG 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-menulst2cfg\fR \(em Convert a configuration file from GRUB 0.xx to GRUB 2.xx format. ++ ++.SH SYNOPSIS ++\fBgrub-menulst2cfg\fR [\fIINFILE\fR [\fIOUTFILE\fR]] ++ ++.SH DESCRIPTION ++\fBgrub-menulst2cfg\fR converts a configuration file from GRUB 0.xx to the current format. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 +new file mode 100644 +index 000000000..a2d1f577b +--- /dev/null ++++ b/util/grub-mkconfig.8 +@@ -0,0 +1,17 @@ ++.TH GRUB-MKCONFIG 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mkconfig\fR \(em Generate a GRUB configuration file. ++ ++.SH SYNOPSIS ++\fBgrub-mkconfig\fR [-o | --output=\fIFILE\fR] ++ ++.SH DESCRIPTION ++\fBgrub-mkconfig\fR generates a configuration file for GRUB. ++ ++.SH OPTIONS ++.TP ++\fB--output\fR=\fIFILE\fR ++Write generated output to \fIFILE\fR. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkfont.1 b/util/grub-mkfont.1 +new file mode 100644 +index 000000000..349485798 +--- /dev/null ++++ b/util/grub-mkfont.1 +@@ -0,0 +1,87 @@ ++.TH GRUB-MKFONT 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mkfont\fR \(em Convert common font file formats into the PF2 format. ++ ++.SH SYNOPSIS ++\fBgrub-mkfont\fR [--ascii-bitmaps] [-a | --force-autohint] ++.RS 13 ++[-b | --bold] [-c | --asce=\fINUM\fR] [-d | --desc=\fINUM\fR] ++.RE ++.RS 13 ++[-i | --index=\fINUM\fR] [-n | --name=\fINAME\fR] [--no-bitmap] ++.RE ++.RS 13 ++[--no-hinting] <-o | --output=\fIFILE\fR> ++.RE ++.RS 13 ++[-r | --range=\fIFROM-TO\fR[\fI,FROM-TO\fR]] [-s | --size=\fISIZE\fR] ++.RE ++.RS 13 ++[-v | --verbose] [--width-spec] \fIFONT_FILES\fR ++ ++.SH DESCRIPTION ++\fBgrub-mkfont\fR converts font files from common formats into the PF2 format used by GRUB. ++ ++.SH OPTIONS ++.TP ++--ascii-bitmaps ++Save only bitmaps for ASCII characters. ++ ++.TP ++--force-autohint ++Force generation of automatic hinting. ++ ++.TP ++--bold ++Convert font to bold. ++ ++.TP ++--asce=\fINUM\fR ++Set font ascent to \fINUM\fR. ++ ++.TP ++--desc=\fINUM\fR ++Set font descent to \fINUM\fR. ++ ++.TP ++--index=\fINUM\fR ++Select face index \fINUM\fR. ++ ++.TP ++--name=\fINAME\fR ++Set font family to \fINAME\fR. ++ ++.TP ++--no-bitmap ++Ignore bitmap strikes when loading. ++ ++.TP ++--no-hinting ++Disable hinting. ++ ++.TP ++--output=\fIFILE\fR ++Save ouptut to \fIFILE\fR. This argument is required. ++ ++.TP ++--range=\fIFROM-TO\fR\fI,FROM-TO\fR ++Set the font ranges to each pair of \fIFROM\fR,\fITO\fR. ++ ++.TP ++--size=\fISIZE\fR ++Set font size to \fISIZE\fR. ++ ++.TP ++--verbose ++Print verbose messages. ++ ++.TP ++--width-spec ++Create a width summary file. ++ ++.TP ++\fIFONT_FILES\fR ++The input files to be converted. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkimage.1 b/util/grub-mkimage.1 +new file mode 100644 +index 000000000..4dea4f545 +--- /dev/null ++++ b/util/grub-mkimage.1 +@@ -0,0 +1,95 @@ ++.TH GRUB-MKIMAGE 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mkimage\fR \(em Make a bootable GRUB image. ++ ++.SH SYNOPSIS ++\fBgrub-mkimage\fR [-c | --config=\fRFILE\fI] [-C | --compression=(\fIxz\fR,\fInone\fR,\fIauto\fR)] ++.RS 14 ++[-d | --directory=\fRDIR\fR] [-k | --pubkey=\fIFILE\fR] ++.RE ++.RS 14 ++[-m | --memdisk=\fIFILE\fR] [-n | --note] [-o | --output=\fIFILE\fR] ++.RE ++.RS 14 ++[-O | --format=\fIFORMAT\fR] [-p | --prefix=\fIDIR\fR] ++.RE ++.RS 14 ++[-v | --verbose] \fIMODULES\fR ++ ++.SH DESCRIPTION ++\fBgrub-mkimage\fI builds a bootable image of GRUB. ++ ++.SH OPTIONS ++.TP ++--config=\fIFILE\fR ++Embed \fIFILE\fR as the image's initial configuration file. ++ ++.TP ++--compression=(\fIxz\fR,\fInone\fR,\fIauto\fR) ++Use one of \fIxz\fR, \fInone\fR, or \fIauto\fR as the compression method for the core image. ++ ++.TP ++--directory=\fIDIR\fR ++Use images and modules from \fIDIR\fR. The default value is \fB/usr/lib/grub/\fR. ++ ++.TP ++--pubkey=\fIFILE\fR ++Embed the public key \fIFILE\fR for signature checking. ++ ++.TP ++--memdisk=\fIFILE\fR ++Embed the memdisk image \fIFILE\fR. If no \fB-p\fR option is also specified, this implies \fI-p (memdisk)/boot/grub\fR. ++ ++.TP ++--note ++Add a CHRP \fINOTE\fR section. This option is only valid on IEEE1275 platforms. ++ ++.TP ++--output=\fIFILE\fR ++Write the generated file to \fIFILE\fR. The default is to write to standard output. ++ ++.TP ++--format=\fIFORMAT\fR ++Generate an image in the specified \fIFORMAT\fR. Valid values are: ++.RS ++.RS 4 ++.P ++i386-coreboot, ++i386-multiboot, ++i386-pc, ++i386-pc-pxe, ++i386-efi, ++i386-ieee1275, ++i386-qemu, ++x86_64-efi, ++mipsel-yeeloong-flash, ++mipsel-fuloong2f-flash, ++mipself-loongson-elf, ++powerpc-ieee1275, ++sparc64-ieee1275-raw, ++sparc64-ieee1275-cdcore, ++sparc64-ieee1275-aout, ++ia64-efi, ++mips-arc, ++mipsel-arc, ++mipsel-qemu_mips-elf, ++mips-qemu_mips-flash, ++mipsel-qemu_mips-flash, ++mips-qemu_mips-elf ++.RE ++.RE ++ ++.TP ++--prefix=\fIDIR\fR ++Set prefix directory. The default value is \fI/boot/grub\fR. ++ ++.TP ++--verbose ++Print verbose messages. ++ ++.TP ++\fIMODULES\fR ++Include \fIMODULES\fR. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mklayout.1 b/util/grub-mklayout.1 +new file mode 100644 +index 000000000..d1bbc2ec5 +--- /dev/null ++++ b/util/grub-mklayout.1 +@@ -0,0 +1,27 @@ ++.TH GRUB-MKLAYOUT 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mklayout\fR \(em Generate a GRUB keyboard layout file. ++ ++.SH SYNOPSIS ++\fBgrub-mklayout\fR [-i | --input=\fIFILE\fR] [-o | --output=\fIFILE\fR] ++.RS 15 ++[-v | --verbose] ++ ++.SH DESCRIPTION ++\fBgrub-mklayout\fR generates a GRUB keyboard layout description which corresponds with the Linux console layout description given as input. ++ ++.SH OPTIONS ++.TP ++--input=\fIFILE\fR ++Use \fIFILE\fR as the input. The default value is the standard input device. ++ ++.TP ++--output=\fIFILE\fR ++Use \fIFILE\fR as the output. The default value is the standard output device. ++ ++.TP ++--verbose ++Print verbose messages. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mknetdir.1 b/util/grub-mknetdir.1 +new file mode 100644 +index 000000000..fa7e8d4ef +--- /dev/null ++++ b/util/grub-mknetdir.1 +@@ -0,0 +1,12 @@ ++.TH GRUB-MKNETDIR 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mknetdir\fR \(em Prepare a GRUB netboot directory. ++ ++.SH SYNOPSIS ++\fBgrub-mknetdir\fR ++ ++.SH DESCRIPTION ++\fBgrub-mknetdir\fR prepares a directory for GRUB to be netbooted from. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkpasswd-pbkdf2.1 b/util/grub-mkpasswd-pbkdf2.1 +new file mode 100644 +index 000000000..73c437c15 +--- /dev/null ++++ b/util/grub-mkpasswd-pbkdf2.1 +@@ -0,0 +1,27 @@ ++.TH GRUB-MKPASSWD-PBKDF2 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mkpasswd-pbkdf2\fR \(em Generate a PBKDF2 password hash. ++ ++.SH SYNOPSIS ++\fBgrub-mkpasswd-pbkdf2\fR [-c | --iteration-count=\fINUM\fR] [-l | --buflen=\fINUM\fR] ++.RS 22 ++[-s | --salt=\fINUM\fR] ++ ++.SH DESCRIPTION ++\fBgrub-mkpasswd-pbkdf2\fR generates a PBKDF2 password string suitable for use in a GRUB configuration file. ++ ++.SH OPTIONS ++.TP ++--iteration-count=\fINUM\fR ++Number of PBKDF2 iterations. ++ ++.TP ++--buflen=\fINUM\fR ++Length of generated hash. ++ ++.TP ++--salt=\fINUM\fR ++Length of salt to use. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkrelpath.1 b/util/grub-mkrelpath.1 +new file mode 100644 +index 000000000..85f111362 +--- /dev/null ++++ b/util/grub-mkrelpath.1 +@@ -0,0 +1,12 @@ ++.TH GRUB-MKRELPATH 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mkrelpath\fR \(em Generate a relative GRUB path given an OS path. ++ ++.SH SYNOPSIS ++\fBgrub-mkrelpath\fR \fIFILE\fR ++ ++.SH DESCRIPTION ++\fBgrub-mkrelpath\fR takes an OS filesystem path for \fIFILE\fR and returns a relative path suitable for use in a GRUB configuration file. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkrescue.1 b/util/grub-mkrescue.1 +new file mode 100644 +index 000000000..4ed9fc723 +--- /dev/null ++++ b/util/grub-mkrescue.1 +@@ -0,0 +1,123 @@ ++.TH GRUB-MKRESCUE 3 "Wed Feb 26 2014" ++.SH NAME ++grub-mkrescue \(em Generate a GRUB rescue image using GNU Xorriso. ++ ++.SH SYNOPSIS ++\fBgrub-mkrescue\fR [-o | --output=\fIFILE\fR] [--modules=\fIMODULES\fR] ++.RS 15 ++[--install-modules=\fIMODULES\fR] [--themes=\fITHEMES\fR] ++.RE ++.RS 15 ++[--fonts=\fIFONTS\fR] [--locales=\fILOCALES\fR] ++.RE ++.RS 15 ++[--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR]] [-d | --directory=\fIDIR\fR] ++.RE ++.RS 15 ++[--grub-mkimage=\fIFILE\fR] [--rom-directory=\fIDIR\fR] ++.RE ++.RS 15 ++[--xorriso=\fIFILE\fR] [--grub-glue-efi=\fIFILE\fR] ++.RE ++.RS 15 ++[--grub-render-label=\fIFILE\fR] [--label-font=\fIFILE\fR] ++.RE ++.RS 15 ++[--label-color=\fICOLOR\fR] [--label-bgcolor=\fIFILE\fR] ++.RE ++.RS 15 ++[--product-name=\fISTRING\fR] [--product-version=\fISTRING\fR] ++.RE ++.RS 15 ++[--sparc-boot] [--arcs-boot] ++ ++.SH DESCRIPTION ++\fBgrub-mkrescue\fR can be used to generate a rescue image with the GRUB bootloader. ++ ++.SH OPTIONS ++.TP ++\fB--output\fR=\fIFILE\fR ++Write the generated file to \fIFILE\fR. The default is to write to standard output. ++ ++.TP ++\fB--modules\fR=\fIMODULES\fR ++Pre-load modules specified by \fIMODULES\fR. ++ ++.TP ++\fB--install-modules\fR=\fIMODULES\fR ++Install only \fIMODULES\fR and their dependencies. The default is to install all available modules. ++ ++.TP ++\fB--themes\fR=\fITHEMES\fR ++Install \fITHEMES\fR. The default is to install the \fIstarfield\fR theme, if available. ++ ++.TP ++\fB--fonts\fR=\fIFONTS\fR ++Install \fIFONTS\fR. The default is to install the \fIunicode\fR font. ++ ++.TP ++\fB--locales\fR=\fILOCALES\fR ++Install only locales listed in \fILOCALES\fR. The default is to install all available locales. ++ ++.TP ++\fB--compress\fR[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR] ++Compress GRUB files using the specified compression algorithm. ++ ++.TP ++\fB--directory\fR=\fIDIR\fR ++Use images and modules in \fIDIR\fR. ++ ++.TP ++\fB--grub-mkimage\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-mkimage\fR(1). The default is \fI/usr/bin/grub-mkimage\fR. ++ ++.TP ++\fB--rom-directory\fR=\fIDIR\fR ++Save ROM images in \fIDIR\fR. ++ ++.TP ++\fB--xorriso\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBxorriso\fI. ++ ++.TP ++\fB--grub-glue-efi\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-glue-efi\fR(3). ++ ++.TP ++\fB--grub-render-label\fR=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-render-label\fR(3). ++ ++.TP ++\fB--label-font\fR=\fIFILE\fR ++Use \fIFILE\fR as the font file for generated labels. ++ ++.TP ++\fB--label-color\fR=\fICOLOR\fR ++Use \fICOLOR\fI as the color for generated labels. ++ ++.TP ++\fB--label-bgcolor\fR=\fICOLOR\fR ++Use \fICOLOR\fR as the background color for generated labels. ++ ++.TP ++\fB--product-name\fR=\fISTRING\fR ++Use \fISTRING\fR as the product name in generated labels. ++ ++.TP ++\fB--product-version\fR=\fISTRING\fR ++Use \fISTRING\fR as the product version in generated labels. ++ ++.TP ++\fB--sparc-boot\fR ++Enable booting the SPARC platform. This disables HFS+, APM, ARCS, and "boot as disk image" on the \fIi386-pc\fR target platform. ++ ++.TP ++\fB--arcs-boot\fR ++Enable ARCS booting. This is typically for big-endian MIPS machines, and disables HFS+, APM, sparc64, and "boot as disk image" on the \fIi386-pc\fR target platform. ++ ++.TP ++\fB--\fR ++All options after a \fB--\fR will be passed directly to xorriso's command line when generating the image. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkstandalone.1 b/util/grub-mkstandalone.1 +new file mode 100644 +index 000000000..ba2d2bdf2 +--- /dev/null ++++ b/util/grub-mkstandalone.1 +@@ -0,0 +1,100 @@ ++.TH GRUB-MKSTANDALONE 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-mkstandalone\fR \(em Generate a standalone image in the selected format. ++ ++.SH SYNOPSIS ++\fBgrub-mkstandalone\fR [-o | --output=\fIFILE\fR] [-O | --format=\fIFORMAT\fR] ++.RS 19 ++[-C | --compression=(\fIxz\fR|\fInone\fR|\fIauto\fR)] ++.RE ++.RS 19 ++[--modules=\fIMODULES\fR] [--install-modules=\fIMODULES\fR] ++.RE ++.RS 19 ++[--themes=\fITHEMES\fR] [--fonts=\fIFONTS\fR] ++.RE ++.RS 19 ++[--locales=\fILOCALES\fR] [--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR]] ++.RE ++.RS 19 ++[-d | --directory=\fIDIR\fR] [--grub-mkimage=\fIFILE\fR] ++.RE ++.RS 19 ++\fISOURCE...\fR ++ ++.SH DESCRIPTION ++ ++.SH OPTIONS ++.TP ++--output=\fIFILE\fR ++Write the generated file to \fIFILE\fR. The default is to write to standard output. ++ ++.TP ++--format=\fIFORMAT\fR ++Generate an image in the specified \fIFORMAT\fR. Valid values are: ++.RS ++.RS 4 ++.P ++i386-coreboot, ++i386-multiboot, ++i386-pc, ++i386-pc-pxe, ++i386-efi, ++i386-ieee1275, ++i386-qemu, ++x86_64-efi, ++mipsel-yeeloong-flash, ++mipsel-fuloong2f-flash, ++mipself-loongson-elf, ++powerpc-ieee1275, ++sparc64-ieee1275-raw, ++sparc64-ieee1275-cdcore, ++sparc64-ieee1275-aout, ++ia64-efi, ++mips-arc, ++mipsel-arc, ++mipsel-qemu_mips-elf, ++mips-qemu_mips-flash, ++mipsel-qemu_mips-flash, ++mips-qemu_mips-elf ++.RE ++.RE ++ ++.TP ++--compression=(\fIxz\fR|\fInone\fR|\fIauto\fR) ++Use one of \fIxz\fR, \fInone\fR, or \fIauto\fR as the compression method for the core image. ++ ++.TP ++--modules=\fIMODULES\fR ++Pre-load modules specified by \fIMODULES\fR. ++ ++.TP ++--install-modules=\fIMODULES\fR ++Install only \fIMODULES\fR and their dependencies. The default is to install all available modules. ++ ++.TP ++--themes=\fITHEMES\fR ++Install \fITHEMES\fR. The default is to install the \fIstarfield\fR theme, if available. ++ ++.TP ++--fonts=\fIFONTS\fR ++Install \fIFONTS\fR. The default is to install the \fIunicode\fR font. ++ ++.TP ++--locales=\fILOCALES\fR ++Install only locales listed in \fILOCALES\fR. The default is to install all available locales. ++ ++.TP ++--compress[=\fIno\fR,\fIxz\fR,\fIgz\fR,\fIlzo\fR] ++Compress GRUB files using the specified compression algorithm. ++ ++.TP ++--directory=\fIDIR\fR ++Use images and modules in \fIDIR\fR. ++ ++.TP ++--grub-mkimage=\fIFILE\fR ++Use \fIFILE\fR as \fBgrub-mkimage\fR. The default is \fI/usr/bin/grub-mkimage\fR. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-ofpathname.8 b/util/grub-ofpathname.8 +new file mode 100644 +index 000000000..bf3743aeb +--- /dev/null ++++ b/util/grub-ofpathname.8 +@@ -0,0 +1,12 @@ ++.TH GRUB-OFPATHNAME 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-ofpathname\fR \(em Generate an IEEE-1275 device path for a specified device. ++ ++.SH SYNOPSIS ++\fBgrub-ofpathname\fR \fIDEVICE\fR ++ ++.SH DESCRIPTION ++\fBgrub-ofpathname\fR generates an IEEE-1275 device path for the specified \fIDEVICE\fR. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-probe.8 b/util/grub-probe.8 +new file mode 100644 +index 000000000..04e26c832 +--- /dev/null ++++ b/util/grub-probe.8 +@@ -0,0 +1,80 @@ ++.TH GRUB-PROBE 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-probe\fR \(em Probe device information for a given path. ++ ++.SH SYNOPSIS ++\fBgrub-probe\fR \[-d | --device] [-m | --device-map=\fIFILE\fR] ++.RS 12 ++[-t | --target=(fs|fs_uuid|fs_label|drive|device|partmap| ++.RE ++.RS 28 ++abstraction|cryptodisk_uuid| ++.RE ++.RS 28 ++msdos_parttype)] ++.RE ++.RS 12 ++[-v | --verbose] (PATH|DEVICE) ++ ++.SH DESCRIPTION ++\fBgrub-probe\fR probes a path or device for filesystem and related information. ++ ++.SH OPTIONS ++.TP ++--device ++Final option represents a \fIDEVICE\fR, rather than a filesystem \fIPATH\fR. ++.TP ++--device-map=\fIFILE\fR ++Use \fIFILE\fR as the device map. The default value is \fI/boot/grub/device.map\fR. ++ ++.TP ++--target=(fs|fs_uuid|fs_label|drive|device|partmap|msdos_parttype) ++Select among various output definitions. The default is \fIfs\fR. ++.RS ++.TP ++\fIfs\fR ++filesystem module ++ ++.TP ++\fIfs_uuid\fR ++filesystem UUID ++ ++.TP ++\fIfs_label\fR ++filesystem label ++ ++.TP ++\fIdrive\fR ++GRUB drive name ++ ++.TP ++\fIdevice\fR ++System device ++ ++.TP ++\fIpartmap\fR ++partition map module ++ ++.TP ++\fIabstraction\fR ++abstraction module ++ ++.TP ++\fIcryptodisk_uuid\fR ++cryptographic container ++ ++.TP ++\fImsdos_partmap\fR ++MS-DOS partition map ++.RE ++ ++.TP ++--verbose ++Print verbose output. ++ ++.TP ++(\fIPATH\fR|\fIDEVICE\fR) ++If --device is passed, a block \fIDEVICE\fR. Otherwise, the \fIPATH\fR of a file on the filesystem. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-reboot.8 b/util/grub-reboot.8 +new file mode 100644 +index 000000000..faa5e4eec +--- /dev/null ++++ b/util/grub-reboot.8 +@@ -0,0 +1,21 @@ ++.TH GRUB-REBOOT 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-reboot\fR \(em Set the default boot menu entry for the next boot only. ++ ++.SH SYNOPSIS ++\fBgrub-reboot\fR [--boot-directory=\fIDIR\fR] \fIMENU_ENTRY\fR ++ ++.SH DESCRIPTION ++\fBgrub-reboot\fR sets the default boot menu entry for the next boot, but not further boots after that. This command only works for GRUB configuration files created with \fIGRUB_DEFAULT=saved\fR in \fI/etc/default/grub\fR. ++ ++.SH OPTIONS ++.TP ++--boot-directory=\fIDIR\fR ++Find GRUB images under \fIDIR/grub\fR. The default value is \fI/boot\fR, resulting in grub images being search for at \fI/boot/grub\fR. ++ ++.TP ++\fIMENU_ENTRY\fR ++A number, a menu item title or a menu item identifier. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-render-label.1 b/util/grub-render-label.1 +new file mode 100644 +index 000000000..4d51c8abf +--- /dev/null ++++ b/util/grub-render-label.1 +@@ -0,0 +1,51 @@ ++.TH GRUB-RENDER-LABEL 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-render-label\fR \(em Render an Apple disk label. ++ ++.SH SYNOPSIS ++\fBgrub-render-label\fR [-b | --bgcolor=\fICOLOR\fR] [-c | --color=\fICOLOR\fR] ++.RS 19 ++[-f | --font=\fIFILE\fR] [-i | --input=\fIFILE\fR] ++.RE ++.RS 19 ++[-o | --output=\fIFILE\fR] [-t | --text=\fISTRING\fR] ++.RE ++.RS 19 ++[-v | --verbose] ++ ++.SH DESCRIPTION ++\fBgrub-render-label\fR renders an Apple disk label (.disk_label) file. ++ ++ ++.SH OPTIONS ++.TP ++\fB--color\fR=\fICOLOR\fR ++Use \fICOLOR\fI as the color for generated labels. ++ ++.TP ++\fB--bgcolor\fR=\fICOLOR\fR ++Use \fICOLOR\fR as the background color for generated labels. ++ ++.TP ++\fB--font\fR=\fIFILE\fR ++Use \fIFILE\fR as the font file for generated labels. ++ ++.TP ++--input=\fIFILE\fR ++Read input text from \fIFILE\fR. ++ ++.TP ++--output=\fIFILE\fR ++Render output to \fIFILE\fR. ++ ++.TP ++--text=\fISTRING\fR ++Use \fISTRING\fR as input text. ++ ++.TP ++--verbose ++Print verbose output. ++ ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-script-check.1 b/util/grub-script-check.1 +new file mode 100644 +index 000000000..0f1f625b0 +--- /dev/null ++++ b/util/grub-script-check.1 +@@ -0,0 +1,21 @@ ++.TH GRUB-SCRIPT-CHECK 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-script-check\fR \(em Check GRUB configuration file for syntax errors. ++ ++.SH SYNOPSIS ++\fBgrub-script-check\fR [-v | --verbose] \fIPATH\fR ++ ++.SH DESCRIPTION ++\fBgrub-script-check\fR verifies that a specified GRUB configuration file does not contain syntax errors. ++ ++.SH OPTIONS ++.TP ++--verbose ++Print verbose output. ++ ++.TP ++\fIPATH\fR ++Path of the file to use as input. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-set-default.8 b/util/grub-set-default.8 +new file mode 100644 +index 000000000..a96265a15 +--- /dev/null ++++ b/util/grub-set-default.8 +@@ -0,0 +1,21 @@ ++.TH GRUB-SET-DEFAULT 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-set-default\fR \(em Set the default boot menu entry for GRUB. ++ ++.SH SYNOPSIS ++\fBgrub-set-default\fR [--boot-directory=\fIDIR\fR] \fIMENU_ENTRY\fR ++ ++.SH DESCRIPTION ++\fBgrub-set-default\fR sets the default boot menu entry for all subsequent boots. This command only works for GRUB configuration files created with \fIGRUB_DEFAULT=saved\fR in \fI/etc/default/grub\fR. ++ ++.SH OPTIONS ++.TP ++--boot-directory=\fIDIR\fR ++Find GRUB images under \fIDIR/grub\fR. The default value is \fI/boot\fR, resulting in grub images being search for at \fI/boot/grub\fR. ++ ++.TP ++\fIMENU_ENTRY\fR ++A number, a menu item title or a menu item identifier. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-sparc64-setup.8 b/util/grub-sparc64-setup.8 +new file mode 100644 +index 000000000..37ea2dd5e +--- /dev/null ++++ b/util/grub-sparc64-setup.8 +@@ -0,0 +1,12 @@ ++.TH GRUB-SPARC64-SETUP 3 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-sparc64-setup\fR \(em Set up a device to boot a sparc64 GRUB image. ++ ++.SH SYNOPSIS ++\fBgrub-sparc64-setup\fR [OPTIONS]. ++ ++.SH DESCRIPTION ++You should not normally run this program directly. Use grub-install instead. ++ ++.SH SEE ALSO ++.BR "info grub" +-- +2.14.3 + diff --git a/0064-Update-info-with-grub.cfg-netboot-selection-order-11.patch b/0064-Update-info-with-grub.cfg-netboot-selection-order-11.patch deleted file mode 100644 index 8f53451..0000000 --- a/0064-Update-info-with-grub.cfg-netboot-selection-order-11.patch +++ /dev/null @@ -1,70 +0,0 @@ -From c4be6106eae8c1b479c325f531a1f81188f400e8 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Mon, 16 Mar 2015 16:34:51 -0400 -Subject: [PATCH 64/90] Update info with grub.cfg netboot selection order - (#1148650) - -Added documentation to the grub info page that specifies the order -netboot clients will use to select a grub configuration file. - -Resolves rhbz#1148650 ---- - docs/grub.texi | 42 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 42 insertions(+) - -diff --git a/docs/grub.texi b/docs/grub.texi -index 98d4d0d..4c6323b 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -2414,6 +2414,48 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 - Then follow instructions printed out by grub-mknetdir on configuring your DHCP - server. - -+The grub.cfg file is placed in the same directory as the path output by -+grub-mknetdir hereafter referred to as FWPATH. GRUB will search for its -+configuration files in order using the following rules where the appended -+value corresponds to a value on the client machine. -+ -+@example -+@group -+@samp{(FWPATH)}/grub.cfg-@samp{(UUID OF NIC)} -+@samp{(FWPATH)}/grub.cfg-@samp{(MAC ADDRESS OF NIC)} -+@samp{(FWPATH)}/grub.cfg-@samp{(IPv4 OR IPv6 ADDRESS)} -+@samp{(FWPATH)}/grub.cfg -+@end group -+@end example -+ -+The client will only attempt to look up an IPv6 address config once, however, -+it will try the IPv4 multiple times. The concrete example below shows what -+would happen under the IPv4 case. -+ -+@example -+@group -+UUID: 7726a678-7fc0-4853-a4f6-c85ac36a120a -+MAC: 52:54:00:ec:33:81 -+IPV4: 10.0.0.130 (0A000082) -+@end group -+@end example -+ -+@example -+@group -+@samp{(FWPATH)}/grub.cfg-7726a678-7fc0-4853-a4f6-c85ac36a120a -+@samp{(FWPATH)}/grub.cfg-52-54-00-ec-33-81 -+@samp{(FWPATH)}/grub.cfg-0A000082 -+@samp{(FWPATH)}/grub.cfg-0A00008 -+@samp{(FWPATH)}/grub.cfg-0A0000 -+@samp{(FWPATH)}/grub.cfg-0A000 -+@samp{(FWPATH)}/grub.cfg-0A00 -+@samp{(FWPATH)}/grub.cfg-0A0 -+@samp{(FWPATH)}/grub.cfg-0A -+@samp{(FWPATH)}/grub.cfg-0 -+@samp{(FWPATH)}/grub.cfg -+@end group -+@end example -+ - After GRUB has started, files on the TFTP server will be accessible via the - @samp{(tftp)} device. - --- -2.9.3 - diff --git a/0065-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch b/0065-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch deleted file mode 100644 index 1d5d622..0000000 --- a/0065-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch +++ /dev/null @@ -1,460 +0,0 @@ -From 11abe391636d0819902357591aebf0ea01b88130 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Mon, 16 Mar 2015 14:14:19 -0400 -Subject: [PATCH 65/90] Use Distribution Package Sort for grub2-mkconfig - (#1124074) - -Users reported that newly installed kernels on their systems installed -with grub-mkconfig would not appear on the grub boot list in order -starting with the most recent. Added an option for rpm-based systems to -use the rpm-sort library to sort kernels instead. - -Resolves rhbz#1124074 ---- - .gitignore | 1 + - Makefile.util.def | 16 +++ - configure.ac | 29 +++++ - util/grub-mkconfig_lib.in | 11 +- - util/grub-rpm-sort.8 | 12 ++ - util/grub-rpm-sort.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++ - 6 files changed, 349 insertions(+), 1 deletion(-) - create mode 100644 util/grub-rpm-sort.8 - create mode 100644 util/grub-rpm-sort.c - -diff --git a/.gitignore b/.gitignore -index 06c9f3a..7697877 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -124,6 +124,7 @@ grub-ofpathname - grub-probe - grub-reboot - grub-render-label -+grub-rpm-sort - grub-script-check - grub-set-default - grub-shell -diff --git a/Makefile.util.def b/Makefile.util.def -index 2061104..d846b81 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -684,6 +684,22 @@ program = { - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - }; - -+program = { -+ name = grub-rpm-sort; -+ mansection = 8; -+ installdir = sbin; -+ -+ common = grub-core/kern/emu/misc.c; -+ common = grub-core/kern/emu/argp_common.c; -+ common = grub-core/osdep/init.c; -+ common = util/misc.c; -+ common = util/grub-rpm-sort.c; -+ -+ ldadd = grub-core/gnulib/libgnu.a; -+ ldadd = libgrubkern.a; -+ ldadd = '$(LIBDEVMAPPER) $(LIBRPM)'; -+}; -+ - script = { - name = grub-mkconfig; - common = util/grub-mkconfig.in; -diff --git a/configure.ac b/configure.ac -index 9937a82..d5e8d90 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) - grub_TRANSFORM([grub-mkrescue]) - grub_TRANSFORM([grub-probe]) - grub_TRANSFORM([grub-reboot]) -+grub_TRANSFORM([grub-rpm-sort]) - grub_TRANSFORM([grub-script-check]) - grub_TRANSFORM([grub-set-default]) - grub_TRANSFORM([grub-sparc64-setup]) -@@ -88,6 +89,7 @@ grub_TRANSFORM([grub-mkrescue.1]) - grub_TRANSFORM([grub-mkstandalone.3]) - grub_TRANSFORM([grub-ofpathname.3]) - grub_TRANSFORM([grub-probe.3]) -+grub_TRANSFORM([grub-rpm-sort.8]) - grub_TRANSFORM([grub-reboot.3]) - grub_TRANSFORM([grub-render-label.3]) - grub_TRANSFORM([grub-script-check.3]) -@@ -1743,6 +1745,33 @@ fi - - AC_SUBST([LIBDEVMAPPER]) - -+AC_ARG_ENABLE([rpm-sort], -+ [AS_HELP_STRING([--enable-rpm-sort], -+ [enable native rpm sorting of kernels in grub (default=guessed)])]) -+if test x"$enable_rpm_sort" = xno ; then -+ rpm_sort_excuse="explicitly disabled" -+fi -+ -+if test x"$rpm_sort_excuse" = x ; then -+ # Check for rpmlib header. -+ AC_CHECK_HEADER([rpm/rpmlib.h], [], -+ [rpm_sort_excuse="need rpm/rpmlib header"]) -+fi -+ -+if test x"$rpm_sort_excuse" = x ; then -+ # Check for rpm library. -+ AC_CHECK_LIB([rpm], [rpmvercmp], [], -+ [rpm_sort_excuse="rpmlib missing rpmvercmp"]) -+fi -+ -+if test x"$rpm_sort_excuse" = x ; then -+ LIBRPM="-lrpm"; -+ AC_DEFINE([HAVE_RPM], [1], -+ [Define to 1 if you have the rpm library.]) -+fi -+ -+AC_SUBST([LIBRPM]) -+ - LIBGEOM= - if test x$host_kernel = xkfreebsd; then - AC_CHECK_LIB([geom], [geom_gettree], [], -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 10fabee..9c410ea 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -33,6 +33,9 @@ fi - if test "x$grub_mkrelpath" = x; then - grub_mkrelpath="${bindir}/@grub_mkrelpath@" - fi -+if test "x$grub_rpm_sort" = x; then -+ grub_rpm_sort="${sbindir}/@grub_rpm_sort@" -+fi - - if which gettext >/dev/null 2>/dev/null; then - : -@@ -213,6 +216,12 @@ version_sort () - esac - } - -+if [ "x$grub_rpm_sort" != x -a -x "$grub_rpm_sort" ]; then -+ kernel_sort="$grub_rpm_sort" -+else -+ kernel_sort=version_sort -+fi -+ - version_test_numeric () - { - version_test_numeric_a="$1" -@@ -229,7 +238,7 @@ version_test_numeric () - version_test_numeric_a="$version_test_numeric_b" - version_test_numeric_b="$version_test_numeric_c" - fi -- if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | version_sort | head -n 1 | grep -qx "$version_test_numeric_b" ; then -+ if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | "$kernel_sort" | head -n 1 | grep -qx "$version_test_numeric_b" ; then - return 0 - else - return 1 -diff --git a/util/grub-rpm-sort.8 b/util/grub-rpm-sort.8 -new file mode 100644 -index 0000000..8ce2148 ---- /dev/null -+++ b/util/grub-rpm-sort.8 -@@ -0,0 +1,12 @@ -+.TH GRUB-RPM-SORT 8 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-rpm-sort\fR \(em Sort input according to RPM version compare. -+ -+.SH SYNOPSIS -+\fBgrub-rpm-sort\fR [OPTIONS]. -+ -+.SH DESCRIPTION -+You should not normally run this program directly. Use grub-mkconfig instead. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-rpm-sort.c b/util/grub-rpm-sort.c -new file mode 100644 -index 0000000..f33bd1e ---- /dev/null -+++ b/util/grub-rpm-sort.c -@@ -0,0 +1,281 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static size_t -+read_file (const char *input, char **ret) -+{ -+ FILE *in; -+ size_t s; -+ size_t sz = 2048; -+ size_t offset = 0; -+ char *text; -+ -+ if (!strcmp(input, "-")) -+ in = stdin; -+ else -+ in = grub_util_fopen(input, "r"); -+ -+ text = xmalloc (sz); -+ -+ if (!in) -+ grub_util_error (_("cannot open `%s': %s"), input, strerror (errno)); -+ -+ while ((s = fread (text + offset, 1, sz - offset, in)) != 0) -+ { -+ offset += s; -+ if (sz - offset == 0) -+ { -+ sz += 2048; -+ text = xrealloc (text, sz); -+ } -+ } -+ -+ text[offset] = '\0'; -+ *ret = text; -+ -+ if (in != stdin) -+ fclose(in); -+ -+ return offset + 1; -+} -+ -+/* returns name/version/release */ -+/* NULL string pointer returned if nothing found */ -+static void -+split_package_string (char *package_string, char **name, -+ char **version, char **release) -+{ -+ char *package_version, *package_release; -+ -+ /* Release */ -+ package_release = strrchr (package_string, '-'); -+ -+ if (package_release != NULL) -+ *package_release++ = '\0'; -+ -+ *release = package_release; -+ -+ /* Version */ -+ package_version = strrchr(package_string, '-'); -+ -+ if (package_version != NULL) -+ *package_version++ = '\0'; -+ -+ *version = package_version; -+ /* Name */ -+ *name = package_string; -+ -+ /* Bubble up non-null values from release to name */ -+ if (*name == NULL) -+ { -+ *name = (*version == NULL ? *release : *version); -+ *version = *release; -+ *release = NULL; -+ } -+ if (*version == NULL) -+ { -+ *version = *release; -+ *release = NULL; -+ } -+} -+ -+/* -+ * package name-version-release comparator for qsort -+ * expects p, q which are pointers to character strings (char *) -+ * which will not be altered in this function -+ */ -+static int -+package_version_compare (const void *p, const void *q) -+{ -+ char *local_p, *local_q; -+ char *lhs_name, *lhs_version, *lhs_release; -+ char *rhs_name, *rhs_version, *rhs_release; -+ int vercmpflag = 0; -+ -+ local_p = alloca (strlen (*(char * const *)p) + 1); -+ local_q = alloca (strlen (*(char * const *)q) + 1); -+ -+ /* make sure these allocated */ -+ assert (local_p); -+ assert (local_q); -+ -+ strcpy (local_p, *(char * const *)p); -+ strcpy (local_q, *(char * const *)q); -+ -+ split_package_string (local_p, &lhs_name, &lhs_version, &lhs_release); -+ split_package_string (local_q, &rhs_name, &rhs_version, &rhs_release); -+ -+ /* Check Name and return if unequal */ -+ vercmpflag = rpmvercmp ((lhs_name == NULL ? "" : lhs_name), -+ (rhs_name == NULL ? "" : rhs_name)); -+ if (vercmpflag != 0) -+ return vercmpflag; -+ -+ /* Check version and return if unequal */ -+ vercmpflag = rpmvercmp ((lhs_version == NULL ? "" : lhs_version), -+ (rhs_version == NULL ? "" : rhs_version)); -+ if (vercmpflag != 0) -+ return vercmpflag; -+ -+ /* Check release and return the version compare value */ -+ vercmpflag = rpmvercmp ((lhs_release == NULL ? "" : lhs_release), -+ (rhs_release == NULL ? "" : rhs_release)); -+ -+ return vercmpflag; -+} -+ -+static void -+add_input (const char *filename, char ***package_names, size_t *n_package_names) -+{ -+ char *orig_input_buffer = NULL; -+ char *input_buffer; -+ char *position_of_newline; -+ char **names = *package_names; -+ char **new_names = NULL; -+ size_t n_names = *n_package_names; -+ -+ if (!*package_names) -+ new_names = names = xmalloc (sizeof (char *) * 2); -+ -+ if (read_file (filename, &orig_input_buffer) < 2) -+ { -+ if (new_names) -+ free (new_names); -+ if (orig_input_buffer) -+ free (orig_input_buffer); -+ return; -+ } -+ -+ input_buffer = orig_input_buffer; -+ while (input_buffer && *input_buffer && -+ (position_of_newline = strchrnul (input_buffer, '\n'))) -+ { -+ size_t sz = position_of_newline - input_buffer; -+ char *new; -+ -+ if (sz == 0) -+ { -+ input_buffer = position_of_newline + 1; -+ continue; -+ } -+ -+ new = xmalloc (sz+1); -+ strncpy (new, input_buffer, sz); -+ new[sz] = '\0'; -+ -+ names = xrealloc (names, sizeof (char *) * (n_names + 1)); -+ names[n_names] = new; -+ n_names++; -+ -+ /* move buffer ahead to next line */ -+ input_buffer = position_of_newline + 1; -+ if (*position_of_newline == '\0') -+ input_buffer = NULL; -+ } -+ -+ free (orig_input_buffer); -+ -+ *package_names = names; -+ *n_package_names = n_names; -+} -+ -+static char * -+help_filter (int key, const char *text, void *input __attribute__ ((unused))) -+{ -+ return (char *)text; -+} -+ -+static struct argp_option options[] = { -+ { 0, } -+}; -+ -+struct arguments -+{ -+ size_t ninputs; -+ size_t input_max; -+ char **inputs; -+}; -+ -+static error_t -+argp_parser (int key, char *arg, struct argp_state *state) -+{ -+ struct arguments *arguments = state->input; -+ switch (key) -+ { -+ case ARGP_KEY_ARG: -+ assert (arguments->ninputs < arguments->input_max); -+ arguments->inputs[arguments->ninputs++] = xstrdup (arg); -+ break; -+ default: -+ return ARGP_ERR_UNKNOWN; -+ } -+ return 0; -+} -+ -+static struct argp argp = { -+ options, argp_parser, N_("[INPUT_FILES]"), -+ N_("Sort a list of strings in RPM version sort order."), -+ NULL, help_filter, NULL -+}; -+ -+int -+main (int argc, char *argv[]) -+{ -+ struct arguments arguments; -+ char **package_names = NULL; -+ size_t n_package_names = 0; -+ int i; -+ -+ grub_util_host_init (&argc, &argv); -+ -+ memset (&arguments, 0, sizeof (struct arguments)); -+ arguments.input_max = argc+1; -+ arguments.inputs = xmalloc ((arguments.input_max + 1) -+ * sizeof (arguments.inputs[0])); -+ memset (arguments.inputs, 0, (arguments.input_max + 1) -+ * sizeof (arguments.inputs[0])); -+ -+ /* Parse our arguments */ -+ if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0) -+ grub_util_error ("%s", _("Error in parsing command line arguments\n")); -+ -+ /* If there's no inputs in argv, add one for stdin */ -+ if (!arguments.ninputs) -+ { -+ arguments.ninputs = 1; -+ arguments.inputs[0] = xmalloc (2); -+ strcpy(arguments.inputs[0], "-"); -+ } -+ -+ for (i = 0; i < arguments.ninputs; i++) -+ add_input(arguments.inputs[i], &package_names, &n_package_names); -+ -+ if (package_names == NULL || n_package_names < 1) -+ grub_util_error ("%s", _("Invalid input\n")); -+ -+ qsort (package_names, n_package_names, sizeof (char *), -+ package_version_compare); -+ -+ /* send sorted list to stdout */ -+ for (i = 0; i < n_package_names; i++) -+ { -+ fprintf (stdout, "%s\n", package_names[i]); -+ free (package_names[i]); -+ } -+ -+ free (package_names); -+ for (i = 0; i < arguments.ninputs; i++) -+ free (arguments.inputs[i]); -+ -+ free (arguments.inputs); -+ -+ return 0; -+} --- -2.9.3 - diff --git a/0065-use-fw_path-prefix-when-fallback-searching-for-grub-.patch b/0065-use-fw_path-prefix-when-fallback-searching-for-grub-.patch new file mode 100644 index 0000000..d1eb77f --- /dev/null +++ b/0065-use-fw_path-prefix-when-fallback-searching-for-grub-.patch @@ -0,0 +1,45 @@ +From c28ddef07d11d790d89ee6ec8e3a8cc7e1aace0d Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Wed, 19 Feb 2014 15:58:43 -0500 +Subject: [PATCH 065/123] use fw_path prefix when fallback searching for grub + config + +When PXE booting via UEFI firmware, grub was searching for grub.cfg +in the fw_path directory where the grub application was found. If +that didn't exist, a fallback search would look for config file names +based on MAC and IP address. However, the search would look in the +prefix directory which may not be the same fw_path. This patch +changes that behavior to use the fw_path directory for the fallback +search. Only if fw_path is NULL will the prefix directory be searched. + +Signed-off-by: Mark Salter +--- + grub-core/normal/main.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index 0ce59fdc3..a3713efcd 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -343,7 +343,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), + char *config; + const char *prefix, *fw_path; + +- fw_path = grub_env_get ("fw_path"); ++ prefix = fw_path = grub_env_get ("fw_path"); + if (fw_path) + { + config = grub_xasprintf ("%s/grub.cfg", fw_path); +@@ -366,7 +366,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), + } + } + +- prefix = grub_env_get ("prefix"); ++ if (! prefix) ++ prefix = grub_env_get ("prefix"); + if (prefix) + { + grub_size_t config_len; +-- +2.14.3 + diff --git a/0066-Add-friendly-grub2-password-config-tool-985962.patch b/0066-Add-friendly-grub2-password-config-tool-985962.patch deleted file mode 100644 index 156666c..0000000 --- a/0066-Add-friendly-grub2-password-config-tool-985962.patch +++ /dev/null @@ -1,274 +0,0 @@ -From f7574b40f89ded29d82e5cfdb7494f8884bc1cdb Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Thu, 25 Jun 2015 11:13:11 -0400 -Subject: [PATCH 66/90] Add friendly grub2 password config tool (#985962) - -Provided a tool for users to reset the grub2 root user password -without having to alter the grub.cfg. The hashed password now -lives in a root-only-readable configuration file. - -Resolves: rhbz#985962 ---- - .gitignore | 1 + - Makefile.util.def | 13 +++++ - configure.ac | 1 + - util/grub-mkconfig.in | 2 + - util/grub-setpassword.8 | 28 +++++++++++ - util/grub-setpassword.in | 123 +++++++++++++++++++++++++++++++++++++++++++++++ - util/grub.d/01_users.in | 11 +++++ - 7 files changed, 179 insertions(+) - create mode 100644 util/grub-setpassword.8 - create mode 100644 util/grub-setpassword.in - create mode 100644 util/grub.d/01_users.in - -diff --git a/.gitignore b/.gitignore -index 7697877..53a391e 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -127,6 +127,7 @@ grub-render-label - grub-rpm-sort - grub-script-check - grub-set-default -+grub-setpassword - grub-shell - grub-shell-tester - grub-sparc64-setup -diff --git a/Makefile.util.def b/Makefile.util.def -index d846b81..226c46b 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -440,6 +440,12 @@ script = { - }; - - script = { -+ name = '01_users'; -+ common = util/grub.d/01_users.in; -+ installdir = grubconf; -+}; -+ -+script = { - name = '10_windows'; - common = util/grub.d/10_windows.in; - installdir = grubconf; -@@ -722,6 +728,13 @@ script = { - }; - - script = { -+ name = grub-setpassword; -+ common = util/grub-setpassword.in; -+ mansection = 8; -+ installdir = sbin; -+}; -+ -+script = { - name = grub-mkconfig_lib; - common = util/grub-mkconfig_lib.in; - installdir = noinst; -diff --git a/configure.ac b/configure.ac -index d5e8d90..67ff20c 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) - grub_TRANSFORM([grub-mkrescue]) - grub_TRANSFORM([grub-probe]) - grub_TRANSFORM([grub-reboot]) -+grub_TRANSFORM([grub-setpassword]) - grub_TRANSFORM([grub-rpm-sort]) - grub_TRANSFORM([grub-script-check]) - grub_TRANSFORM([grub-set-default]) -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 9d595ac..fb87247 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -263,6 +263,8 @@ for i in "${grub_mkconfig_dir}"/* ; do - *~) ;; - # emacsen autosave files. FIXME: support other editors - */\#*\#) ;; -+ # rpm config files of yore. -+ *.rpmsave|*.rpmnew|*.rpmorig) ;; - *) - if grub_file_is_not_garbage "$i" && test -x "$i" ; then - echo -diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 -new file mode 100644 -index 0000000..49200a8 ---- /dev/null -+++ b/util/grub-setpassword.8 -@@ -0,0 +1,28 @@ -+.TH GRUB-SETPASSWORD 3 "Thu Jun 25 2015" -+.SH NAME -+\fBgrub-setpassword\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. -+ -+.SH SYNOPSIS -+\fBgrub-setpassword\fR [OPTION] -+ -+.SH DESCRIPTION -+\fBgrub-setpassword\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. -+ -+The file has the format: -+GRUB2_PASSWORD=<\fIhashed password\fR>. -+ -+.SH OPTIONS -+.TP -+-h, --help -+Display program usage and exit. -+.TP -+-v, --version -+Display the current version. -+.TP -+-o, --output[=\fIDIRECTORY PATH\fR] -+Choose the file path to which user.cfg will be written. -+ -+.SH SEE ALSO -+.BR "info grub" -+ -+.BR "info grub2-mkpasswd-pbkdf2" -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -new file mode 100644 -index 0000000..dd76f00 ---- /dev/null -+++ b/util/grub-setpassword.in -@@ -0,0 +1,123 @@ -+#!/bin/sh -e -+ -+if [ -d /sys/firmware/efi/efivars/ ]; then -+ grubdir=`echo "/@bootdirname@/efi/EFI/redhat/" | sed 's,//*,/,g'` -+else -+ grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` -+fi -+ -+PACKAGE_VERSION="@PACKAGE_VERSION@" -+PACKAGE_NAME="@PACKAGE_NAME@" -+self=`basename $0` -+bindir="@bindir@" -+grub_mkpasswd="${bindir}/@grub_mkpasswd_pbkdf2@" -+ -+# Usage: usage -+# Print the usage. -+usage () { -+ cat <&2 -+ exit 1 -+ fi -+ echo $1 -+} -+ -+# Ensure that it's the root user running this script -+if [ "${EUID}" -ne 0 ]; then -+ echo "The grub bootloader password may only be set by root." -+ usage -+ exit 2 -+fi -+ -+# Check the arguments. -+while test $# -gt 0 -+do -+ option=$1 -+ shift -+ -+ case "$option" in -+ -h | --help) -+ usage -+ exit 0 ;; -+ -v | --version) -+ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" -+ exit 0 ;; -+ -o | --output) -+ OUTPUT_PATH=`argument $option "$@"`; shift ;; -+ --output=*) -+ OUTPUT_PATH=`echo "$option" | sed 's/--output=//'` ;; -+ -o=*) -+ OUTPUT_PATH=`echo "$option" | sed 's/-o=//'` ;; -+ esac -+done -+ -+# set user input or default path for user.cfg file -+if [ -z "${OUTPUT_PATH}" ]; then -+ OUTPUT_PATH="${grubdir}" -+fi -+ -+if [ ! -d "${OUTPUT_PATH}" ]; then -+ echo "${OUTPUT_PATH} does not exist." -+ usage -+ exit 2; -+fi -+ -+ttyopt=$(stty -g) -+fixtty() { -+ stty ${ttyopt} -+} -+ -+trap fixtty EXIT -+stty -echo -+ -+# prompt & confirm new grub2 root user password -+echo -n "Enter password: " -+read PASSWORD -+echo -+echo -n "Confirm password: " -+read PASSWORD_CONFIRM -+echo -+stty ${ttyopt} -+ -+getpass() { -+ local P0 -+ local P1 -+ P0="$1" && shift -+ P1="$1" && shift -+ -+ ( echo ${P0} ; echo ${P1} ) | \ -+ ${grub_mkpasswd} | \ -+ grep -v '[eE]nter password:' | \ -+ sed -e "s/PBKDF2 hash of your password is //" -+} -+ -+MYPASS="$(getpass "${PASSWORD}" "${PASSWORD_CONFIRM}")" -+if [ -z "${MYPASS}" ]; then -+ echo "${self}: error: empty password" 1>&2 -+ exit 1 -+fi -+ -+# on the ESP, these will fail to set the permissions, but it's okay because -+# the directory is protected. -+install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : -+chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : -+echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" -diff --git a/util/grub.d/01_users.in b/util/grub.d/01_users.in -new file mode 100644 -index 0000000..db2f44b ---- /dev/null -+++ b/util/grub.d/01_users.in -@@ -0,0 +1,11 @@ -+#!/bin/sh -e -+cat << EOF -+if [ -f \${prefix}/user.cfg ]; then -+ source \${prefix}/user.cfg -+ if [ -n "\${GRUB2_PASSWORD}" ]; then -+ set superusers="root" -+ export superusers -+ password_pbkdf2 root \${GRUB2_PASSWORD} -+ fi -+fi -+EOF --- -2.9.3 - diff --git a/0066-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch b/0066-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch new file mode 100644 index 0000000..1bc2859 --- /dev/null +++ b/0066-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch @@ -0,0 +1,115 @@ +From 82812e4ade82c9aa4f2e8f091b60b714ecfd82e5 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 6 Mar 2014 11:51:33 -0500 +Subject: [PATCH 066/123] Try mac/guid/etc before grub.cfg on tftp config + files. + +Signed-off-by: Peter Jones +--- + grub-core/normal/main.c | 80 ++++++++++++++++++++++++++----------------------- + 1 file changed, 43 insertions(+), 37 deletions(-) + +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index a3713efcd..7d9c4f09b 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -341,53 +341,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), + /* Guess the config filename. It is necessary to make CONFIG static, + so that it won't get broken by longjmp. */ + char *config; +- const char *prefix, *fw_path; +- +- prefix = fw_path = grub_env_get ("fw_path"); +- if (fw_path) +- { +- config = grub_xasprintf ("%s/grub.cfg", fw_path); +- if (config) +- { +- grub_file_t file; +- +- file = grub_file_open (config); +- if (file) +- { +- grub_file_close (file); +- grub_enter_normal_mode (config); +- } +- else +- { +- /* Ignore all errors. */ +- grub_errno = 0; +- } +- grub_free (config); +- } +- } ++ const char *prefix; + ++ prefix = grub_env_get ("fw_path"); + if (! prefix) + prefix = grub_env_get ("prefix"); ++ + if (prefix) +- { +- grub_size_t config_len; +- config_len = grub_strlen (prefix) + +- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); +- config = grub_malloc (config_len); ++ { ++ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) ++ { ++ grub_size_t config_len; ++ config_len = grub_strlen (prefix) + ++ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); ++ config = grub_malloc (config_len); ++ ++ if (! config) ++ goto quit; + +- if (! config) +- goto quit; ++ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); + +- grub_snprintf (config, config_len, "%s/grub.cfg", prefix); ++ grub_net_search_configfile (config); + +- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) +- grub_net_search_configfile (config); ++ grub_enter_normal_mode (config); ++ grub_free (config); ++ config = NULL; ++ } + +- grub_enter_normal_mode (config); +- grub_free (config); ++ if (!config) ++ { ++ config = grub_xasprintf ("%s/grub.cfg", prefix); ++ if (config) ++ { ++ grub_file_t file; ++ ++ file = grub_file_open (config); ++ if (file) ++ { ++ grub_file_close (file); ++ grub_enter_normal_mode (config); ++ } ++ else ++ { ++ /* Ignore all errors. */ ++ grub_errno = 0; ++ } ++ grub_free (config); ++ } ++ } + } + else +- grub_enter_normal_mode (0); ++ { ++ grub_enter_normal_mode (0); ++ } + } + else + grub_enter_normal_mode (argv[0]); +-- +2.14.3 + diff --git a/0067-Fix-convert-function-to-support-NVMe-devices.patch b/0067-Fix-convert-function-to-support-NVMe-devices.patch new file mode 100644 index 0000000..bc246d5 --- /dev/null +++ b/0067-Fix-convert-function-to-support-NVMe-devices.patch @@ -0,0 +1,59 @@ +From b954efc0812579f973031b24c68a2f593bd89ba1 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 18 Feb 2014 11:34:00 -0500 +Subject: [PATCH 067/123] Fix convert function to support NVMe devices + +This is adapted from the patch at +https://bugzilla.redhat.com/show_bug.cgi?id=1019660 , which is against +the now very old version of convert_system_partition_to_system_disk(). + +As such, it certainly not the right thing for upstream, but should +function for now. + +Resolves: rhbz#1019660 + +Signed-off-by: Peter Jones +--- + util/getroot.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/util/getroot.c b/util/getroot.c +index 92c0d709b..bf317a28e 100644 +--- a/util/getroot.c ++++ b/util/getroot.c +@@ -153,6 +153,7 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part) + { + #if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL + struct stat st; ++ char *path = xmalloc(PATH_MAX); + + if (stat (os_dev, &st) < 0) + { +@@ -165,6 +166,24 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part) + + *is_part = 0; + ++ if (realpath(os_dev, path)) ++ { ++ if ((strncmp ("/dev/nvme", path, 9) == 0)) ++ { ++ char *p = path + 5; ++ p = strchr(p, 'p'); ++ if (p) ++ { ++ *is_part = 1; ++ *p = '\0'; ++ } ++ return path; ++ } ++ } ++ ++ grub_free (path); ++ *is_part = 0; ++ + if (grub_util_device_is_mapped_stat (&st)) + return grub_util_devmapper_part_to_disk (&st, is_part, os_dev); + +-- +2.14.3 + diff --git a/0067-Fix-race-in-EFI-validation.patch b/0067-Fix-race-in-EFI-validation.patch deleted file mode 100644 index 4667b47..0000000 --- a/0067-Fix-race-in-EFI-validation.patch +++ /dev/null @@ -1,97 +0,0 @@ -From a605e7af01dc697021b96fe6fbaf92ef3fca017c Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Tue, 14 Jul 2015 16:58:51 -0700 -Subject: [PATCH 67/90] Fix race in EFI validation - ---- - grub-core/loader/i386/efi/linux.c | 44 ++++++++++----------------------------- - 1 file changed, 11 insertions(+), 33 deletions(-) - -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index e5b7785..7ccf32d 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -154,7 +154,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_file_t file = 0; - struct linux_kernel_header lh; - grub_ssize_t len, start, filelen; -- void *kernel; -+ void *kernel = NULL; - - grub_dl_ref (my_mod); - -@@ -191,10 +191,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_file_seek (file, 0); -- -- grub_free(kernel); -- - params = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(16384)); - - if (! params) -@@ -203,15 +199,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- memset (params, 0, 16384); -+ grub_memset (params, 0, 16384); - -- if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) -- { -- if (!grub_errno) -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -- argv[0]); -- goto fail; -- } -+ grub_memcpy (&lh, kernel, sizeof (lh)); - - if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) - { -@@ -271,27 +261,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- if (grub_file_seek (file, start) == (grub_off_t) -1) -- { -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -- argv[0]); -- goto fail; -- } -+ grub_memcpy (kernel_mem, (char *)kernel + start, len); -+ grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); -+ loaded=1; - -- if (grub_file_read (file, kernel_mem, len) != len && !grub_errno) -- { -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -- argv[0]); -- } -- -- if (grub_errno == GRUB_ERR_NONE) -- { -- grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); -- loaded = 1; -- lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; -- } -- -- memcpy(params, &lh, 2 * 512); -+ lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; -+ grub_memcpy (params, &lh, 2 * 512); - - params->type_of_loader = 0x21; - -@@ -300,6 +275,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - if (file) - grub_file_close (file); - -+ if (kernel) -+ grub_free (kernel); -+ - if (grub_errno != GRUB_ERR_NONE) - { - grub_dl_unref (my_mod); --- -2.9.3 - diff --git a/0068-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch b/0068-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch new file mode 100644 index 0000000..24bab94 --- /dev/null +++ b/0068-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch @@ -0,0 +1,29 @@ +From 6900527741a21097f57a72854944f3e078a0ee42 Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Mon, 10 Feb 2014 16:13:10 -0500 +Subject: [PATCH 068/123] Switch to use APM Mustang device tree, for hardware + testing. + +Signed-off-by: David A. Marlin +--- + util/grub.d/10_linux.in | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 79a747ebd..462b461ff 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -232,8 +232,8 @@ while [ "x$list" != "x" ] ; do + + fdt= + for i in "dtb-${version}" "dtb-${alt_version}"; do +- if test -e "${dirname}/${i}/foundation-v8.dtb" ; then +- fdt="${i}/foundation-v8.dtb" ++ if test -e "${dirname}/${i}/apm-mustang.dtb" ; then ++ fdt="${i}/apm-mustang.dtb" + break + fi + done +-- +2.14.3 + diff --git a/0068-ppc64le-sync-mkconfig-to-disk-1212114.patch b/0068-ppc64le-sync-mkconfig-to-disk-1212114.patch deleted file mode 100644 index 9af7bc6..0000000 --- a/0068-ppc64le-sync-mkconfig-to-disk-1212114.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 63efe6a207f59ffa9e55cc10a0aed272f3571227 Mon Sep 17 00:00:00 2001 -From: Don Zickus -Date: Wed, 22 Jul 2015 13:59:55 -0400 -Subject: [PATCH 68/90] ppc64le sync mkconfig to disk (#1212114) - -If creating a new grub2 entry using grub2-mkconfig, the entry is not -immediately sync'd to disk. If a crash happens before the writeback, -the subsequent reboot fails because the grub2.cfg is corrupted. - -Address this by forcing all the changes (mainly the fs meta data) to disk -before finishing the grub2 conf changes. - -Tested by 'grub2-mkconfig -o /etc/grub22.cfg; echo c > /proc/sysrq-trigger'. - -Before, the machine would panic and on reboot be stuck without a grub.cfg -to read. After, works as expected. - -Resolves: rhbz#1212114 ---- - util/grub-mkconfig.in | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index fb87247..73a18f7 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -294,3 +294,12 @@ fi - - gettext "done" >&2 - echo >&2 -+ -+# make sure changes make it to the disk. -+# if /boot is a mountpoint, force the meta data on disk -+# to by-pass writeback delay. -+# PPC64LE-only to deal with Petitboot issues -+ARCH=$(uname -m) -+if [ "${ARCH}" = "ppc64le" ]; then -+ sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot -+fi --- -2.9.3 - diff --git a/0069-Use-device-part-of-chainloader-target-if-present.patch b/0069-Use-device-part-of-chainloader-target-if-present.patch deleted file mode 100644 index 2b3dcf7..0000000 --- a/0069-Use-device-part-of-chainloader-target-if-present.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 9d47b2c482b6db238c99fe106f4b2e3c612f3a91 Mon Sep 17 00:00:00 2001 -From: Raymund Will -Date: Fri, 10 Apr 2015 01:45:02 -0400 -Subject: [PATCH 69/90] Use device part of chainloader target, if present. - -Otherwise chainloading is restricted to '$root', which might not even -be readable by EFI! - -v1. use grub_file_get_device_name() to get device name - -Signed-off-by: Michael Chang -Signed-off-by: Peter Jones ---- - grub-core/loader/efi/chainloader.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 522a716..6b47497 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -219,8 +219,11 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - if (! file) - goto fail; - -- /* Get the root device's device path. */ -- dev = grub_device_open (0); -+ /* Get the device path from filename. */ -+ char *devname = grub_file_get_device_name (filename); -+ dev = grub_device_open (devname); -+ if (devname) -+ grub_free (devname); - if (! dev) - goto fail; - --- -2.9.3 - diff --git a/0069-Use-the-default-device-tree-from-the-grub-default-fi.patch b/0069-Use-the-default-device-tree-from-the-grub-default-fi.patch new file mode 100644 index 0000000..47db64c --- /dev/null +++ b/0069-Use-the-default-device-tree-from-the-grub-default-fi.patch @@ -0,0 +1,46 @@ +From 823290f622902f1ae06efa29efbe4ca15af1aafe Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Wed, 12 Feb 2014 14:54:04 -0500 +Subject: [PATCH 069/123] Use the default device tree from the grub default + file + +instead of hardcoding a value. + +Signed-off-by: David A. Marlin +--- + util/grub-mkconfig.in | 3 ++- + util/grub.d/10_linux.in | 4 ++-- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index c088b7054..9d595ac05 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -235,7 +235,8 @@ export GRUB_DEFAULT \ + GRUB_ENABLE_CRYPTODISK \ + GRUB_BADRAM \ + GRUB_OS_PROBER_SKIP_LIST \ +- GRUB_DISABLE_SUBMENU ++ GRUB_DISABLE_SUBMENU \ ++ GRUB_DEFAULT_DTB + + if test "x${grub_cfg}" != "x"; then + rm -f "${grub_cfg}.new" +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 462b461ff..a9692a0c2 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -232,8 +232,8 @@ while [ "x$list" != "x" ] ; do + + fdt= + for i in "dtb-${version}" "dtb-${alt_version}"; do +- if test -e "${dirname}/${i}/apm-mustang.dtb" ; then +- fdt="${i}/apm-mustang.dtb" ++ if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then ++ fdt="${i}/${GRUB_DEFAULT_DTB}" + break + fi + done +-- +2.14.3 + diff --git a/0070-Add-secureboot-support-on-efi-chainloader.patch b/0070-Add-secureboot-support-on-efi-chainloader.patch deleted file mode 100644 index 03fd5ca..0000000 --- a/0070-Add-secureboot-support-on-efi-chainloader.patch +++ /dev/null @@ -1,800 +0,0 @@ -From 9cbf35d19f4ffafdf2683acf7b6a320b55bbdfca Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 6 Oct 2015 13:04:37 -0400 -Subject: [PATCH 70/90] Add secureboot support on efi chainloader - -Expand the chainloader to be able to verify the image by means of shim -lock protocol. The PE/COFF image is loaded and relocated by the -chainloader instead of calling LoadImage and StartImage UEFI boot -Service as they require positive verification result from keys enrolled -in KEK or DB. The shim will use MOK in addition to firmware enrolled -keys to verify the image. - -The chainloader module could be used to load other UEFI bootloaders, -such as xen.efi, and could be signed by any of MOK, KEK or DB. - -Based on https://build.opensuse.org/package/view_file/openSUSE:Factory/grub2/grub2-secureboot-chainloader.patch - -Signed-off-by: Peter Jones ---- - grub-core/loader/efi/chainloader.c | 612 ++++++++++++++++++++++++++++++++++--- - include/grub/efi/pe32.h | 20 +- - 2 files changed, 595 insertions(+), 37 deletions(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 6b47497..3cbb6c5 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -32,6 +32,8 @@ - #include - #include - #include -+#include -+#include - #include - #include - #include -@@ -46,9 +48,14 @@ static grub_dl_t my_mod; - - static grub_efi_physical_address_t address; - static grub_efi_uintn_t pages; -+static grub_ssize_t fsize; - static grub_efi_device_path_t *file_path; - static grub_efi_handle_t image_handle; - static grub_efi_char16_t *cmdline; -+static grub_ssize_t cmdline_len; -+static grub_efi_handle_t dev_handle; -+ -+static grub_efi_status_t (*entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); - - static grub_err_t - grub_chainloader_unload (void) -@@ -63,6 +70,7 @@ grub_chainloader_unload (void) - grub_free (cmdline); - cmdline = 0; - file_path = 0; -+ dev_handle = 0; - - grub_dl_unref (my_mod); - return GRUB_ERR_NONE; -@@ -187,12 +195,523 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) - return file_path; - } - -+#define SHIM_LOCK_GUID \ -+ { 0x605dab50, 0xe046, 0x4300, { 0xab,0xb6,0x3d,0xd8,0x10,0xdd,0x8b,0x23 } } -+ -+typedef union -+{ -+ struct grub_pe32_header_32 pe32; -+ struct grub_pe32_header_64 pe32plus; -+} grub_pe_header_t; -+ -+struct pe_coff_loader_image_context -+{ -+ grub_efi_uint64_t image_address; -+ grub_efi_uint64_t image_size; -+ grub_efi_uint64_t entry_point; -+ grub_efi_uintn_t size_of_headers; -+ grub_efi_uint16_t image_type; -+ grub_efi_uint16_t number_of_sections; -+ grub_efi_uint32_t section_alignment; -+ struct grub_pe32_section_table *first_section; -+ struct grub_pe32_data_directory *reloc_dir; -+ struct grub_pe32_data_directory *sec_dir; -+ grub_efi_uint64_t number_of_rva_and_sizes; -+ grub_pe_header_t *pe_hdr; -+}; -+ -+typedef struct pe_coff_loader_image_context pe_coff_loader_image_context_t; -+ -+struct grub_efi_shim_lock -+{ -+ grub_efi_status_t (*verify)(void *buffer, -+ grub_efi_uint32_t size); -+ grub_efi_status_t (*hash)(void *data, -+ grub_efi_int32_t datasize, -+ pe_coff_loader_image_context_t *context, -+ grub_efi_uint8_t *sha256hash, -+ grub_efi_uint8_t *sha1hash); -+ grub_efi_status_t (*context)(void *data, -+ grub_efi_uint32_t size, -+ pe_coff_loader_image_context_t *context); -+}; -+ -+typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; -+ -+static grub_efi_boolean_t -+read_header (void *data, grub_efi_uint32_t size, -+ pe_coff_loader_image_context_t *context) -+{ -+ grub_efi_guid_t guid = SHIM_LOCK_GUID; -+ grub_efi_shim_lock_t *shim_lock; -+ grub_efi_status_t status; -+ -+ shim_lock = grub_efi_locate_protocol (&guid, NULL); -+ -+ if (!shim_lock) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "no shim lock protocol"); -+ return 0; -+ } -+ -+ status = shim_lock->context (data, size, context); -+ -+ if (status == GRUB_EFI_SUCCESS) -+ { -+ grub_dprintf ("chain", "context success\n"); -+ return 1; -+ } -+ -+ switch (status) -+ { -+ case GRUB_EFI_UNSUPPORTED: -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "context error unsupported"); -+ break; -+ case GRUB_EFI_INVALID_PARAMETER: -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "context error invalid parameter"); -+ break; -+ default: -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "context error code"); -+ break; -+ } -+ -+ return 0; -+} -+ -+static void* -+image_address (void *image, grub_efi_uint64_t sz, grub_efi_uint64_t adr) -+{ -+ if (adr > sz) -+ return NULL; -+ -+ return ((grub_uint8_t*)image + adr); -+} -+ -+static int -+image_is_64_bit (grub_pe_header_t *pe_hdr) -+{ -+ /* .Magic is the same offset in all cases */ -+ if (pe_hdr->pe32plus.optional_header.magic == GRUB_PE32_PE64_MAGIC) -+ return 1; -+ return 0; -+} -+ -+static const grub_uint16_t machine_type = -+#if defined(__x86_64__) -+ GRUB_PE32_MACHINE_X86_64; -+#elif defined(__aarch64__) -+ GRUB_PE32_MACHINE_ARM64; -+#elif defined(__arm__) -+ GRUB_PE32_MACHINE_ARMTHUMB_MIXED; -+#elif defined(__i386__) || defined(__i486__) || defined(__i686__) -+ GRUB_PE32_MACHINE_I386; -+#elif defined(__ia64__) -+ GRUB_PE32_MACHINE_IA64; -+#else -+#error this architecture is not supported by grub2 -+#endif -+ -+static grub_efi_status_t -+relocate_coff (pe_coff_loader_image_context_t *context, -+ struct grub_pe32_section_table *section, -+ void *orig, void *data) -+{ -+ struct grub_pe32_data_directory *reloc_base, *reloc_base_end; -+ grub_efi_uint64_t adjust; -+ struct grub_pe32_fixup_block *reloc, *reloc_end; -+ char *fixup, *fixup_base, *fixup_data = NULL; -+ grub_efi_uint16_t *fixup_16; -+ grub_efi_uint32_t *fixup_32; -+ grub_efi_uint64_t *fixup_64; -+ grub_efi_uint64_t size = context->image_size; -+ void *image_end = (char *)orig + size; -+ int n = 0; -+ -+ if (image_is_64_bit (context->pe_hdr)) -+ context->pe_hdr->pe32plus.optional_header.image_base = -+ (grub_uint64_t)(unsigned long)data; -+ else -+ context->pe_hdr->pe32.optional_header.image_base = -+ (grub_uint32_t)(unsigned long)data; -+ -+ /* Alright, so here's how this works: -+ * -+ * context->reloc_dir gives us two things: -+ * - the VA the table of base relocation blocks are (maybe) to be -+ * mapped at (reloc_dir->rva) -+ * - the virtual size (reloc_dir->size) -+ * -+ * The .reloc section (section here) gives us some other things: -+ * - the name! kind of. (section->name) -+ * - the virtual size (section->virtual_size), which should be the same -+ * as RelocDir->Size -+ * - the virtual address (section->virtual_address) -+ * - the file section size (section->raw_data_size), which is -+ * a multiple of optional_header->file_alignment. Only useful for image -+ * validation, not really useful for iteration bounds. -+ * - the file address (section->raw_data_offset) -+ * - a bunch of stuff we don't use that's 0 in our binaries usually -+ * - Flags (section->characteristics) -+ * -+ * and then the thing that's actually at the file address is an array -+ * of struct grub_pe32_fixup_block structs with some values packed behind -+ * them. The block_size field of this structure includes the -+ * structure itself, and adding it to that structure's address will -+ * yield the next entry in the array. -+ */ -+ -+ reloc_base = image_address (orig, size, section->raw_data_offset); -+ reloc_base_end = image_address (orig, size, section->raw_data_offset -+ + section->virtual_size - 1); -+ -+ grub_dprintf ("chain", "reloc_base %p reloc_base_end %p\n", reloc_base, -+ reloc_base_end); -+ -+ if (!reloc_base && !reloc_base_end) -+ return GRUB_EFI_SUCCESS; -+ -+ if (!reloc_base || !reloc_base_end) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc table overflows binary"); -+ return GRUB_EFI_UNSUPPORTED; -+ } -+ -+ adjust = (grub_uint64_t)data - context->image_address; -+ if (adjust == 0) -+ return GRUB_EFI_SUCCESS; -+ -+ while (reloc_base < reloc_base_end) -+ { -+ grub_uint16_t *entry; -+ reloc = (struct grub_pe32_fixup_block *)((char*)reloc_base); -+ -+ if ((reloc_base->size == 0) || -+ (reloc_base->size > context->reloc_dir->size)) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, -+ "Reloc %d block size %d is invalid\n", n, -+ reloc_base->size); -+ return GRUB_EFI_UNSUPPORTED; -+ } -+ -+ entry = &reloc->entries[0]; -+ reloc_end = (struct grub_pe32_fixup_block *) -+ ((char *)reloc_base + reloc_base->size); -+ -+ if ((void *)reloc_end < data || (void *)reloc_end > image_end) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc entry %d overflows binary", -+ n); -+ return GRUB_EFI_UNSUPPORTED; -+ } -+ -+ fixup_base = image_address(data, size, reloc_base->rva); -+ -+ if (!fixup_base) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc %d Invalid fixupbase", n); -+ return GRUB_EFI_UNSUPPORTED; -+ } -+ -+ while ((void *)entry < (void *)reloc_end) -+ { -+ fixup = fixup_base + (*entry & 0xFFF); -+ switch ((*entry) >> 12) -+ { -+ case GRUB_PE32_REL_BASED_ABSOLUTE: -+ break; -+ case GRUB_PE32_REL_BASED_HIGH: -+ fixup_16 = (grub_uint16_t *)fixup; -+ *fixup_16 = (grub_uint16_t) -+ (*fixup_16 + ((grub_uint16_t)((grub_uint32_t)adjust >> 16))); -+ if (fixup_data != NULL) -+ { -+ *(grub_uint16_t *) fixup_data = *fixup_16; -+ fixup_data = fixup_data + sizeof (grub_uint16_t); -+ } -+ break; -+ case GRUB_PE32_REL_BASED_LOW: -+ fixup_16 = (grub_uint16_t *)fixup; -+ *fixup_16 = (grub_uint16_t) (*fixup_16 + (grub_uint16_t)adjust); -+ if (fixup_data != NULL) -+ { -+ *(grub_uint16_t *) fixup_data = *fixup_16; -+ fixup_data = fixup_data + sizeof (grub_uint16_t); -+ } -+ break; -+ case GRUB_PE32_REL_BASED_HIGHLOW: -+ fixup_32 = (grub_uint32_t *)fixup; -+ *fixup_32 = *fixup_32 + (grub_uint32_t)adjust; -+ if (fixup_data != NULL) -+ { -+ fixup_data = (char *)ALIGN_UP ((grub_addr_t)fixup_data, sizeof (grub_uint32_t)); -+ *(grub_uint32_t *) fixup_data = *fixup_32; -+ fixup_data += sizeof (grub_uint32_t); -+ } -+ break; -+ case GRUB_PE32_REL_BASED_DIR64: -+ fixup_64 = (grub_uint64_t *)fixup; -+ *fixup_64 = *fixup_64 + (grub_uint64_t)adjust; -+ if (fixup_data != NULL) -+ { -+ fixup_data = (char *)ALIGN_UP ((grub_addr_t)fixup_data, sizeof (grub_uint64_t)); -+ *(grub_uint64_t *) fixup_data = *fixup_64; -+ fixup_data += sizeof (grub_uint64_t); -+ } -+ break; -+ default: -+ grub_error (GRUB_ERR_BAD_ARGUMENT, -+ "Reloc %d unknown relocation type %d", -+ n, (*entry) >> 12); -+ return GRUB_EFI_UNSUPPORTED; -+ } -+ entry += 1; -+ } -+ reloc_base = (struct grub_pe32_data_directory *)reloc_end; -+ n++; -+ } -+ -+ return GRUB_EFI_SUCCESS; -+} -+ -+static grub_efi_device_path_t * -+grub_efi_get_media_file_path (grub_efi_device_path_t *dp) -+{ -+ while (1) -+ { -+ grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); -+ grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); -+ -+ if (type == GRUB_EFI_END_DEVICE_PATH_TYPE) -+ break; -+ else if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE -+ && subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE) -+ return dp; -+ -+ dp = GRUB_EFI_NEXT_DEVICE_PATH (dp); -+ } -+ -+ return NULL; -+} -+ -+static grub_efi_boolean_t -+handle_image (void *data, grub_efi_uint32_t datasize) -+{ -+ grub_efi_boot_services_t *b; -+ grub_efi_loaded_image_t *li, li_bak; -+ grub_efi_status_t efi_status; -+ char *buffer = NULL; -+ char *buffer_aligned = NULL; -+ grub_efi_uint32_t i, size; -+ struct grub_pe32_section_table *section; -+ char *base, *end; -+ pe_coff_loader_image_context_t context; -+ grub_uint32_t section_alignment; -+ grub_uint32_t buffer_size; -+ -+ b = grub_efi_system_table->boot_services; -+ -+ if (read_header (data, datasize, &context)) -+ { -+ grub_dprintf ("chain", "Succeed to read header\n"); -+ } -+ else -+ { -+ grub_dprintf ("chain", "Failed to read header\n"); -+ goto error_exit; -+ } -+ -+ section_alignment = context.section_alignment; -+ buffer_size = context.image_size + section_alignment; -+ -+ efi_status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, -+ buffer_size, &buffer); -+ -+ if (efi_status != GRUB_EFI_SUCCESS) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto error_exit; -+ } -+ -+ buffer_aligned = (char *)ALIGN_UP ((grub_addr_t)buffer, section_alignment); -+ -+ if (!buffer_aligned) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto error_exit; -+ } -+ -+ grub_memcpy (buffer_aligned, data, context.size_of_headers); -+ -+ char *reloc_base, *reloc_base_end; -+ reloc_base = image_address (buffer_aligned, datasize, -+ context.reloc_dir->rva); -+ /* RelocBaseEnd here is the address of the last byte of the table */ -+ reloc_base_end = image_address (buffer_aligned, datasize, -+ context.reloc_dir->rva -+ + context.reloc_dir->size - 1); -+ struct grub_pe32_section_table *reloc_section = NULL; -+ -+ section = context.first_section; -+ for (i = 0; i < context.number_of_sections; i++, section++) -+ { -+ size = section->virtual_size; -+ if (size > section->raw_data_size) -+ size = section->raw_data_size; -+ -+ base = image_address (buffer_aligned, context.image_size, -+ section->virtual_address); -+ end = image_address (buffer_aligned, context.image_size, -+ section->virtual_address + size - 1); -+ -+ -+ /* We do want to process .reloc, but it's often marked -+ * discardable, so we don't want to memcpy it. */ -+ if (grub_memcmp (section->name, ".reloc\0\0", 8) == 0) -+ { -+ if (reloc_section) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, -+ "Image has multiple relocation sections"); -+ goto error_exit; -+ } -+ -+ /* If it has nonzero sizes, and our bounds check -+ * made sense, and the VA and size match RelocDir's -+ * versions, then we believe in this section table. */ -+ if (section->raw_data_size && section->virtual_size && -+ base && end && reloc_base == base && reloc_base_end == end) -+ { -+ reloc_section = section; -+ } -+ } -+ -+ if (section->characteristics && GRUB_PE32_SCN_MEM_DISCARDABLE) -+ continue; -+ -+ if (!base || !end) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid section size"); -+ goto error_exit; -+ } -+ -+ if (section->virtual_address < context.size_of_headers || -+ section->raw_data_offset < context.size_of_headers) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, -+ "Section %d is inside image headers", i); -+ goto error_exit; -+ } -+ -+ if (section->raw_data_size > 0) -+ grub_memcpy (base, (grub_efi_uint8_t*)data + section->raw_data_offset, -+ size); -+ -+ if (size < section->virtual_size) -+ grub_memset (base + size, 0, section->virtual_size - size); -+ -+ grub_dprintf ("chain", "copied section %s\n", section->name); -+ } -+ -+ /* 5 == EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC */ -+ if (context.number_of_rva_and_sizes <= 5) -+ { -+ grub_dprintf ("chain", "image has no relocation entry\n"); -+ goto error_exit; -+ } -+ -+ if (context.reloc_dir->size && reloc_section) -+ { -+ /* run the relocation fixups */ -+ efi_status = relocate_coff (&context, reloc_section, data, -+ buffer_aligned); -+ -+ if (efi_status != GRUB_EFI_SUCCESS) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "relocation failed"); -+ goto error_exit; -+ } -+ } -+ -+ entry_point = image_address (buffer_aligned, context.image_size, -+ context.entry_point); -+ -+ if (!entry_point) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid entry point"); -+ goto error_exit; -+ } -+ -+ li = grub_efi_get_loaded_image (grub_efi_image_handle); -+ if (!li) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "no loaded image available"); -+ goto error_exit; -+ } -+ -+ grub_memcpy (&li_bak, li, sizeof (grub_efi_loaded_image_t)); -+ li->image_base = buffer_aligned; -+ li->image_size = context.image_size; -+ li->load_options = cmdline; -+ li->load_options_size = cmdline_len; -+ li->file_path = grub_efi_get_media_file_path (file_path); -+ li->device_handle = dev_handle; -+ if (li->file_path) -+ { -+ grub_printf ("file path: "); -+ grub_efi_print_device_path (li->file_path); -+ } -+ else -+ { -+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file path found"); -+ goto error_exit; -+ } -+ -+ efi_status = efi_call_2 (entry_point, grub_efi_image_handle, -+ grub_efi_system_table); -+ -+ grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); -+ efi_status = efi_call_1 (b->free_pool, buffer); -+ -+ return 1; -+ -+error_exit: -+ if (buffer) -+ efi_call_1 (b->free_pool, buffer); -+ -+ return 0; -+} -+ -+static grub_err_t -+grub_secureboot_chainloader_unload (void) -+{ -+ grub_efi_boot_services_t *b; -+ -+ b = grub_efi_system_table->boot_services; -+ efi_call_2 (b->free_pages, address, pages); -+ grub_free (file_path); -+ grub_free (cmdline); -+ cmdline = 0; -+ file_path = 0; -+ dev_handle = 0; -+ -+ grub_dl_unref (my_mod); -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_secureboot_chainloader_boot (void) -+{ -+ handle_image ((void *)address, fsize); -+ grub_loader_unset (); -+ return grub_errno; -+} -+ - static grub_err_t - grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) - { - grub_file_t file = 0; -- grub_ssize_t size; - grub_efi_status_t status; - grub_efi_boot_services_t *b; - grub_device_t dev = 0; -@@ -200,7 +719,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - grub_efi_loaded_image_t *loaded_image; - char *filename; - void *boot_image = 0; -- grub_efi_handle_t dev_handle = 0; - - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -212,9 +730,36 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - address = 0; - image_handle = 0; - file_path = 0; -+ dev_handle = 0; - - b = grub_efi_system_table->boot_services; - -+ if (argc > 1) -+ { -+ int i; -+ grub_efi_char16_t *p16; -+ -+ for (i = 1, cmdline_len = 0; i < argc; i++) -+ cmdline_len += grub_strlen (argv[i]) + 1; -+ -+ cmdline_len *= sizeof (grub_efi_char16_t); -+ cmdline = p16 = grub_malloc (cmdline_len); -+ if (! cmdline) -+ goto fail; -+ -+ for (i = 1; i < argc; i++) -+ { -+ char *p8; -+ -+ p8 = argv[i]; -+ while (*p8) -+ *(p16++) = *(p8++); -+ -+ *(p16++) = ' '; -+ } -+ *(--p16) = 0; -+ } -+ - file = grub_file_open (filename); - if (! file) - goto fail; -@@ -263,14 +808,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - grub_printf ("file path: "); - grub_efi_print_device_path (file_path); - -- size = grub_file_size (file); -- if (!size) -+ fsize = grub_file_size (file); -+ if (!fsize) - { - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - goto fail; - } -- pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12); -+ pages = (((grub_efi_uintn_t) fsize + ((1 << 12) - 1)) >> 12); - - status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, - GRUB_EFI_LOADER_CODE, -@@ -284,7 +829,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - } - - boot_image = (void *) ((grub_addr_t) address); -- if (grub_file_read (file, boot_image, size) != size) -+ if (grub_file_read (file, boot_image, fsize) != fsize) - { - if (grub_errno == GRUB_ERR_NONE) - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -294,7 +839,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - } - - #if defined (__i386__) || defined (__x86_64__) -- if (size >= (grub_ssize_t) sizeof (struct grub_macho_fat_header)) -+ if (fsize >= (grub_ssize_t) sizeof (struct grub_macho_fat_header)) - { - struct grub_macho_fat_header *head = boot_image; - if (head->magic -@@ -303,6 +848,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - grub_uint32_t i; - struct grub_macho_fat_arch *archs - = (struct grub_macho_fat_arch *) (head + 1); -+ -+ if (grub_efi_secure_boot()) -+ { -+ grub_error (GRUB_ERR_BAD_OS, -+ "MACHO binaries are forbidden with Secure Boot"); -+ goto fail; -+ } -+ - for (i = 0; i < grub_cpu_to_le32 (head->nfat_arch); i++) - { - if (GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT (archs[i].cputype)) -@@ -317,21 +870,28 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - > ~grub_cpu_to_le32 (archs[i].size) - || grub_cpu_to_le32 (archs[i].offset) - + grub_cpu_to_le32 (archs[i].size) -- > (grub_size_t) size) -+ > (grub_size_t) fsize) - { - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - goto fail; - } - boot_image = (char *) boot_image + grub_cpu_to_le32 (archs[i].offset); -- size = grub_cpu_to_le32 (archs[i].size); -+ fsize = grub_cpu_to_le32 (archs[i].size); - } - } - #endif - -+ if (grub_linuxefi_secure_validate((void *)address, fsize)) -+ { -+ grub_file_close (file); -+ grub_loader_set (grub_secureboot_chainloader_boot, -+ grub_secureboot_chainloader_unload, 0); -+ return 0; -+ } -+ - status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, -- boot_image, size, -- &image_handle); -+ boot_image, fsize, &image_handle); - if (status != GRUB_EFI_SUCCESS) - { - if (status == GRUB_EFI_OUT_OF_RESOURCES) -@@ -353,33 +913,10 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - } - loaded_image->device_handle = dev_handle; - -- if (argc > 1) -+ if (cmdline) - { -- int i, len; -- grub_efi_char16_t *p16; -- -- for (i = 1, len = 0; i < argc; i++) -- len += grub_strlen (argv[i]) + 1; -- -- len *= sizeof (grub_efi_char16_t); -- cmdline = p16 = grub_malloc (len); -- if (! cmdline) -- goto fail; -- -- for (i = 1; i < argc; i++) -- { -- char *p8; -- -- p8 = argv[i]; -- while (*p8) -- *(p16++) = *(p8++); -- -- *(p16++) = ' '; -- } -- *(--p16) = 0; -- - loaded_image->load_options = cmdline; -- loaded_image->load_options_size = len; -+ loaded_image->load_options_size = cmdline_len; - } - - grub_file_close (file); -@@ -401,6 +938,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - if (address) - efi_call_2 (b->free_pages, address, pages); - -+ if (cmdline) -+ grub_free (cmdline); -+ - grub_dl_unref (my_mod); - - return grub_errno; -diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h -index f79c36c..f79782e 100644 ---- a/include/grub/efi/pe32.h -+++ b/include/grub/efi/pe32.h -@@ -212,7 +212,11 @@ struct grub_pe64_optional_header - struct grub_pe32_section_table - { - char name[8]; -- grub_uint32_t virtual_size; -+ union -+ { -+ grub_uint32_t physical_address; -+ grub_uint32_t virtual_size; -+ }; - grub_uint32_t virtual_address; - grub_uint32_t raw_data_size; - grub_uint32_t raw_data_offset; -@@ -263,6 +267,20 @@ struct grub_pe32_header - #endif - }; - -+struct grub_pe32_header_32 -+{ -+ char signature[GRUB_PE32_SIGNATURE_SIZE]; -+ struct grub_pe32_coff_header coff_header; -+ struct grub_pe32_optional_header optional_header; -+}; -+ -+struct grub_pe32_header_64 -+{ -+ char signature[GRUB_PE32_SIGNATURE_SIZE]; -+ struct grub_pe32_coff_header coff_header; -+ struct grub_pe64_optional_header optional_header; -+}; -+ - struct grub_pe32_fixup_block - { - grub_uint32_t page_rva; --- -2.9.3 - diff --git a/0070-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0070-reopen-SNP-protocol-for-exclusive-use-by-grub.patch new file mode 100644 index 0000000..faac7a4 --- /dev/null +++ b/0070-reopen-SNP-protocol-for-exclusive-use-by-grub.patch @@ -0,0 +1,46 @@ +From e119353dad1eadc771a011f82bf90bd04fc00f9a Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Sat, 15 Feb 2014 15:10:22 -0500 +Subject: [PATCH 070/123] reopen SNP protocol for exclusive use by grub + +--- + grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c +index 5388f952b..ea0e0ca36 100644 +--- a/grub-core/net/drivers/efi/efinet.c ++++ b/grub-core/net/drivers/efi/efinet.c +@@ -330,6 +330,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + { + struct grub_net_card *card; + grub_efi_device_path_t *dp; ++ grub_efi_simple_network_t *net; + + dp = grub_efi_get_device_path (hnd); + if (! dp) +@@ -383,6 +384,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + &pxe_mode->dhcp_ack, + sizeof (pxe_mode->dhcp_ack), + 1, device, path); ++ net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, ++ GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); ++ if (net) { ++ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED ++ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) ++ continue; ++ ++ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) ++ continue; ++ ++ if (net->mode->state == GRUB_EFI_NETWORK_STARTED ++ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) ++ continue; ++ card->efi_net = net; ++ } + return; + } + } +-- +2.14.3 + diff --git a/0071-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch b/0071-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch deleted file mode 100644 index 5592b97..0000000 --- a/0071-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch +++ /dev/null @@ -1,494 +0,0 @@ -From c1d31b6a26e5542142d569c94a70f1dc8e07afd6 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 6 Oct 2015 16:09:25 -0400 -Subject: [PATCH 71/90] Make any of the loaders that link in efi mode honor - secure boot. - -And in this case "honor" means "even if somebody does link this in, they -won't register commands if SB is enabled." - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.am | 1 + - grub-core/Makefile.core.def | 1 + - grub-core/commands/iorw.c | 7 +++++ - grub-core/commands/memrw.c | 7 +++++ - grub-core/kern/efi/efi.c | 28 ------------------ - grub-core/kern/efi/sb.c | 58 ++++++++++++++++++++++++++++++++++++++ - grub-core/loader/efi/appleloader.c | 7 +++++ - grub-core/loader/efi/chainloader.c | 1 + - grub-core/loader/i386/bsd.c | 7 +++++ - grub-core/loader/i386/linux.c | 7 +++++ - grub-core/loader/i386/pc/linux.c | 7 +++++ - grub-core/loader/multiboot.c | 7 +++++ - grub-core/loader/xnu.c | 7 +++++ - include/grub/efi/efi.h | 1 - - include/grub/efi/sb.h | 29 +++++++++++++++++++ - include/grub/ia64/linux.h | 0 - include/grub/mips/linux.h | 0 - include/grub/powerpc/linux.h | 0 - include/grub/sparc64/linux.h | 0 - 19 files changed, 146 insertions(+), 29 deletions(-) - create mode 100644 grub-core/kern/efi/sb.c - create mode 100644 include/grub/efi/sb.h - create mode 100644 include/grub/ia64/linux.h - create mode 100644 include/grub/mips/linux.h - create mode 100644 include/grub/powerpc/linux.h - create mode 100644 include/grub/sparc64/linux.h - -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index 04e9395..fd715a8 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -71,6 +71,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 7fba196..ac195d1 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -178,6 +178,7 @@ kernel = { - i386_multiboot = kern/i386/pc/acpi.c; - i386_coreboot = kern/acpi.c; - i386_multiboot = kern/acpi.c; -+ common = kern/efi/sb.c; - - x86 = kern/i386/tsc.c; - x86 = kern/i386/tsc_pit.c; -diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c -index a0c164e..41a7f3f 100644 ---- a/grub-core/commands/iorw.c -+++ b/grub-core/commands/iorw.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -118,6 +119,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) - - GRUB_MOD_INIT(memrw) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - cmd_read_byte = - grub_register_extcmd ("inb", grub_cmd_read, 0, - N_("PORT"), N_("Read 8-bit value from PORT."), -@@ -146,6 +150,9 @@ GRUB_MOD_INIT(memrw) - - GRUB_MOD_FINI(memrw) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - grub_unregister_extcmd (cmd_read_byte); - grub_unregister_extcmd (cmd_read_word); - grub_unregister_extcmd (cmd_read_dword); -diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c -index 98769ea..088cbe9 100644 ---- a/grub-core/commands/memrw.c -+++ b/grub-core/commands/memrw.c -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -120,6 +121,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) - - GRUB_MOD_INIT(memrw) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - cmd_read_byte = - grub_register_extcmd ("read_byte", grub_cmd_read, 0, - N_("ADDR"), N_("Read 8-bit value from ADDR."), -@@ -148,6 +152,9 @@ GRUB_MOD_INIT(memrw) - - GRUB_MOD_FINI(memrw) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - grub_unregister_extcmd (cmd_read_byte); - grub_unregister_extcmd (cmd_read_word); - grub_unregister_extcmd (cmd_read_dword); -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 0859910..101307f 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -269,34 +269,6 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - return NULL; - } - --grub_efi_boolean_t --grub_efi_secure_boot (void) --{ -- grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; -- grub_size_t datasize; -- char *secure_boot = NULL; -- char *setup_mode = NULL; -- grub_efi_boolean_t ret = 0; -- -- secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -- -- if (datasize != 1 || !secure_boot) -- goto out; -- -- setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -- -- if (datasize != 1 || !setup_mode) -- goto out; -- -- if (*secure_boot && !*setup_mode) -- ret = 1; -- -- out: -- grub_free (secure_boot); -- grub_free (setup_mode); -- return ret; --} -- - #pragma GCC diagnostic ignored "-Wcast-align" - - /* Search the mods section from the PE32/PE32+ image. This code uses -diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c -new file mode 100644 -index 0000000..a41b6c5 ---- /dev/null -+++ b/grub-core/kern/efi/sb.c -@@ -0,0 +1,58 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2014 Free Software Foundation, Inc. -+ * -+ * GRUB 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. -+ * -+ * GRUB 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 GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+int -+grub_efi_secure_boot (void) -+{ -+#ifdef GRUB_MACHINE_EFI -+ grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; -+ grub_size_t datasize; -+ char *secure_boot = NULL; -+ char *setup_mode = NULL; -+ grub_efi_boolean_t ret = 0; -+ -+ secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -+ -+ if (datasize != 1 || !secure_boot) -+ goto out; -+ -+ setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -+ -+ if (datasize != 1 || !setup_mode) -+ goto out; -+ -+ if (*secure_boot && !*setup_mode) -+ ret = 1; -+ -+ out: -+ grub_free (secure_boot); -+ grub_free (setup_mode); -+ return ret; -+#else -+ return 0; -+#endif -+} -diff --git a/grub-core/loader/efi/appleloader.c b/grub-core/loader/efi/appleloader.c -index 74888c4..69c2a10 100644 ---- a/grub-core/loader/efi/appleloader.c -+++ b/grub-core/loader/efi/appleloader.c -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -227,6 +228,9 @@ static grub_command_t cmd; - - GRUB_MOD_INIT(appleloader) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - cmd = grub_register_command ("appleloader", grub_cmd_appleloader, - N_("[OPTS]"), - /* TRANSLATORS: This command is used on EFI to -@@ -238,5 +242,8 @@ GRUB_MOD_INIT(appleloader) - - GRUB_MOD_FINI(appleloader) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - grub_unregister_command (cmd); - } -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 3cbb6c5..c4184fa 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -34,6 +34,7 @@ - #include - #include - #include -+#include - #include - #include - #include -diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c -index 7f96515..87709aa 100644 ---- a/grub-core/loader/i386/bsd.c -+++ b/grub-core/loader/i386/bsd.c -@@ -38,6 +38,7 @@ - #ifdef GRUB_MACHINE_PCBIOS - #include - #endif -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -2124,6 +2125,9 @@ static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk; - - GRUB_MOD_INIT (bsd) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - /* Net and OpenBSD kernels are often compressed. */ - grub_dl_load ("gzio"); - -@@ -2163,6 +2167,9 @@ GRUB_MOD_INIT (bsd) - - GRUB_MOD_FINI (bsd) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - grub_unregister_extcmd (cmd_freebsd); - grub_unregister_extcmd (cmd_openbsd); - grub_unregister_extcmd (cmd_netbsd); -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index fddcc46..b0afcca 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -1136,6 +1137,9 @@ static grub_command_t cmd_linux, cmd_initrd; - - GRUB_MOD_INIT(linux) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, N_("Load Linux.")); - cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, -@@ -1145,6 +1149,9 @@ GRUB_MOD_INIT(linux) - - GRUB_MOD_FINI(linux) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - grub_unregister_command (cmd_linux); - grub_unregister_command (cmd_initrd); - } -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index a293b17..9128315 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -472,6 +473,9 @@ static grub_command_t cmd_linux, cmd_initrd; - - GRUB_MOD_INIT(linux16) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - cmd_linux = - grub_register_command ("linux16", grub_cmd_linux, - 0, N_("Load Linux.")); -@@ -483,6 +487,9 @@ GRUB_MOD_INIT(linux16) - - GRUB_MOD_FINI(linux16) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - grub_unregister_command (cmd_linux); - grub_unregister_command (cmd_initrd); - } -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 73aa0aa..64a6513 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -42,6 +42,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -391,6 +392,9 @@ static grub_command_t cmd_multiboot, cmd_module; - - GRUB_MOD_INIT(multiboot) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - cmd_multiboot = - #ifdef GRUB_USE_MULTIBOOT2 - grub_register_command ("multiboot2", grub_cmd_multiboot, -@@ -411,6 +415,9 @@ GRUB_MOD_INIT(multiboot) - - GRUB_MOD_FINI(multiboot) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - grub_unregister_command (cmd_multiboot); - grub_unregister_command (cmd_module); - } -diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c -index c9885b1..df8dfdb 100644 ---- a/grub-core/loader/xnu.c -+++ b/grub-core/loader/xnu.c -@@ -33,6 +33,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -1469,6 +1470,9 @@ static grub_extcmd_t cmd_splash; - - GRUB_MOD_INIT(xnu) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0, - N_("Load XNU image.")); - cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64, -@@ -1509,6 +1513,9 @@ GRUB_MOD_INIT(xnu) - - GRUB_MOD_FINI(xnu) - { -+ if (grub_efi_secure_boot()) -+ return; -+ - #ifndef GRUB_MACHINE_EMU - grub_unregister_command (cmd_resume); - #endif -diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 2245632..9a2da0e 100644 ---- a/include/grub/efi/efi.h -+++ b/include/grub/efi/efi.h -@@ -76,7 +76,6 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, - const grub_efi_guid_t *guid, - void *data, - grub_size_t datasize); --grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void); - int - EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, - const grub_efi_device_path_t *dp2); -diff --git a/include/grub/efi/sb.h b/include/grub/efi/sb.h -new file mode 100644 -index 0000000..9629fbb ---- /dev/null -+++ b/include/grub/efi/sb.h -@@ -0,0 +1,29 @@ -+/* sb.h - declare functions for EFI Secure Boot support */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. -+ * -+ * GRUB 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. -+ * -+ * GRUB 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 GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_EFI_SB_HEADER -+#define GRUB_EFI_SB_HEADER 1 -+ -+#include -+#include -+ -+/* Functions. */ -+int EXPORT_FUNC (grub_efi_secure_boot) (void); -+ -+#endif /* ! GRUB_EFI_SB_HEADER */ -diff --git a/include/grub/ia64/linux.h b/include/grub/ia64/linux.h -new file mode 100644 -index 0000000..e69de29 -diff --git a/include/grub/mips/linux.h b/include/grub/mips/linux.h -new file mode 100644 -index 0000000..e69de29 -diff --git a/include/grub/powerpc/linux.h b/include/grub/powerpc/linux.h -new file mode 100644 -index 0000000..e69de29 -diff --git a/include/grub/sparc64/linux.h b/include/grub/sparc64/linux.h -new file mode 100644 -index 0000000..e69de29 --- -2.9.3 - diff --git a/0071-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0071-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch new file mode 100644 index 0000000..26f4890 --- /dev/null +++ b/0071-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch @@ -0,0 +1,55 @@ +From 5d47b56198754190c62179ae10ef175c00d1474d Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 4 Mar 2016 15:13:59 -0500 +Subject: [PATCH 071/123] Revert "reopen SNP protocol for exclusive use by + grub" + +This reverts commit a3f2c756ce34c9666bddef35e3b3b85ccecdcffc , which is +obsoleted by these: + +49426e9 efinet: open Simple Network Protocol exclusively +f348aee efinet: enable hardware filters when opening interface +c52ae40 efinet: skip virtual IPv4 and IPv6 devices when enumerating cards + +Signed-off-by: Peter Jones +--- + grub-core/net/drivers/efi/efinet.c | 16 ---------------- + 1 file changed, 16 deletions(-) + +diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c +index ea0e0ca36..5388f952b 100644 +--- a/grub-core/net/drivers/efi/efinet.c ++++ b/grub-core/net/drivers/efi/efinet.c +@@ -330,7 +330,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + { + struct grub_net_card *card; + grub_efi_device_path_t *dp; +- grub_efi_simple_network_t *net; + + dp = grub_efi_get_device_path (hnd); + if (! dp) +@@ -384,21 +383,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + &pxe_mode->dhcp_ack, + sizeof (pxe_mode->dhcp_ack), + 1, device, path); +- net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, +- GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); +- if (net) { +- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED +- && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) +- continue; +- +- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) +- continue; +- +- if (net->mode->state == GRUB_EFI_NETWORK_STARTED +- && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) +- continue; +- card->efi_net = net; +- } + return; + } + } +-- +2.14.3 + diff --git a/0072-Add-grub_util_readlink.patch b/0072-Add-grub_util_readlink.patch new file mode 100644 index 0000000..2633d7e --- /dev/null +++ b/0072-Add-grub_util_readlink.patch @@ -0,0 +1,3734 @@ +From 5a69c7fbfff14bcea80e781fcd6acad07c904e22 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 3 Sep 2014 10:01:03 -0400 +Subject: [PATCH 072/123] Add grub_util_readlink() + +Add grub_util_readlink(). This requires pulling in stat and readlink from +gnulib, which pulls in stat and related headers, but after that the +implementation is straightforward. + +Signed-off-by: Peter Jones +Reviewed-by: Adam Jackson +--- + grub-core/gnulib/Makefile.am | 177 +++++++- + grub-core/gnulib/gettimeofday.c | 154 +++++++ + grub-core/gnulib/pathmax.h | 83 ++++ + grub-core/gnulib/readlink.c | 74 ++++ + grub-core/gnulib/stat.c | 138 +++++++ + grub-core/gnulib/sys_stat.in.h | 732 ++++++++++++++++++++++++++++++++++ + grub-core/gnulib/sys_time.in.h | 213 ++++++++++ + grub-core/gnulib/sys_types.in.h | 2 + + grub-core/gnulib/time.h | 586 +++++++++++++++++++++++++++ + grub-core/gnulib/time.in.h | 274 +++++++++++++ + grub-core/osdep/windows/hostdisk.c | 6 + + include/grub/osdep/hostfile_aros.h | 6 + + include/grub/osdep/hostfile_unix.h | 6 + + include/grub/osdep/hostfile_windows.h | 2 + + m4/gettimeofday.m4 | 138 +++++++ + m4/gnulib-cache.m4 | 3 +- + m4/gnulib-comp.m4 | 49 +++ + m4/largefile.m4 | 146 +++++++ + m4/pathmax.m4 | 42 ++ + m4/readlink.m4 | 71 ++++ + m4/stat.m4 | 71 ++++ + m4/sys_stat_h.m4 | 96 +++++ + m4/sys_time_h.m4 | 110 +++++ + m4/time_h.m4 | 118 ++++++ + 24 files changed, 3295 insertions(+), 2 deletions(-) + create mode 100644 grub-core/gnulib/gettimeofday.c + create mode 100644 grub-core/gnulib/pathmax.h + create mode 100644 grub-core/gnulib/readlink.c + create mode 100644 grub-core/gnulib/stat.c + create mode 100644 grub-core/gnulib/sys_stat.in.h + create mode 100644 grub-core/gnulib/sys_time.in.h + create mode 100644 grub-core/gnulib/time.h + create mode 100644 grub-core/gnulib/time.in.h + create mode 100644 m4/gettimeofday.m4 + create mode 100644 m4/largefile.m4 + create mode 100644 m4/pathmax.m4 + create mode 100644 m4/readlink.m4 + create mode 100644 m4/stat.m4 + create mode 100644 m4/sys_stat_h.m4 + create mode 100644 m4/sys_time_h.m4 + create mode 100644 m4/time_h.m4 + +diff --git a/grub-core/gnulib/Makefile.am b/grub-core/gnulib/Makefile.am +index 3444397fe..b7c5e60e1 100644 +--- a/grub-core/gnulib/Makefile.am ++++ b/grub-core/gnulib/Makefile.am +@@ -21,7 +21,7 @@ + # the same distribution terms as the rest of that program. + # + # Generated by gnulib-tool. +-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex ++# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex + + AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects + +@@ -326,6 +326,15 @@ libgnu_a_SOURCES += gettext.h + + ## end gnulib module gettext-h + ++## begin gnulib module gettimeofday ++ ++ ++EXTRA_DIST += gettimeofday.c ++ ++EXTRA_libgnu_a_SOURCES += gettimeofday.c ++ ++## end gnulib module gettimeofday ++ + ## begin gnulib module havelib + + +@@ -596,6 +605,13 @@ EXTRA_libgnu_a_SOURCES += nl_langinfo.c + + ## end gnulib module nl_langinfo + ++## begin gnulib module pathmax ++ ++ ++EXTRA_DIST += pathmax.h ++ ++## end gnulib module pathmax ++ + ## begin gnulib module progname + + libgnu_a_SOURCES += progname.h progname.c +@@ -611,6 +627,15 @@ EXTRA_libgnu_a_SOURCES += rawmemchr.c + + ## end gnulib module rawmemchr + ++## begin gnulib module readlink ++ ++ ++EXTRA_DIST += readlink.c ++ ++EXTRA_libgnu_a_SOURCES += readlink.c ++ ++## end gnulib module readlink ++ + ## begin gnulib module realloc-posix + + +@@ -725,6 +750,15 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h + + ## end gnulib module snippet/warn-on-use + ++## begin gnulib module stat ++ ++ ++EXTRA_DIST += stat.c ++ ++EXTRA_libgnu_a_SOURCES += stat.c ++ ++## end gnulib module stat ++ + ## begin gnulib module stdalign + + BUILT_SOURCES += $(STDALIGN_H) +@@ -1280,6 +1314,102 @@ libgnu_a_SOURCES += strnlen1.h strnlen1.c + + ## end gnulib module strnlen1 + ++## begin gnulib module sys_stat ++ ++BUILT_SOURCES += sys/stat.h ++ ++# We need the following in order to create when the system ++# has one that is incomplete. ++sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) ++ $(AM_V_at)$(MKDIR_P) sys ++ $(AM_V_GEN)rm -f $@-t $@ && \ ++ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ ++ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ ++ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ ++ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ ++ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ ++ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ ++ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ ++ -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ ++ -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \ ++ -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ ++ -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ ++ -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ ++ -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \ ++ -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \ ++ -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \ ++ -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \ ++ -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \ ++ -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \ ++ -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \ ++ -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \ ++ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ ++ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ ++ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ ++ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ ++ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ ++ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ ++ -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ ++ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ ++ -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ ++ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ ++ -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ ++ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ ++ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ ++ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \ ++ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ ++ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ ++ -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ ++ -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ ++ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ ++ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \ ++ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ ++ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ ++ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ ++ < $(srcdir)/sys_stat.in.h; \ ++ } > $@-t && \ ++ mv $@-t $@ ++MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t ++MOSTLYCLEANDIRS += sys ++ ++EXTRA_DIST += sys_stat.in.h ++ ++## end gnulib module sys_stat ++ ++## begin gnulib module sys_time ++ ++BUILT_SOURCES += sys/time.h ++ ++# We need the following in order to create when the system ++# doesn't have one that works with the given compiler. ++sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) ++ $(AM_V_at)$(MKDIR_P) sys ++ $(AM_V_GEN)rm -f $@-t $@ && \ ++ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ ++ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ ++ -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ ++ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ ++ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ ++ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ ++ -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ ++ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ ++ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ ++ -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ ++ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ ++ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ ++ -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \ ++ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ ++ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ ++ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ ++ < $(srcdir)/sys_time.in.h; \ ++ } > $@-t && \ ++ mv $@-t $@ ++MOSTLYCLEANFILES += sys/time.h sys/time.h-t ++ ++EXTRA_DIST += sys_time.in.h ++ ++## end gnulib module sys_time ++ + ## begin gnulib module sys_types + + BUILT_SOURCES += sys/types.h +@@ -1334,6 +1464,51 @@ EXTRA_DIST += sysexits.in.h + + ## end gnulib module sysexits + ++## begin gnulib module time ++ ++BUILT_SOURCES += time.h ++ ++# We need the following in order to create when the system ++# doesn't have one that works with the given compiler. ++time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) ++ $(AM_V_GEN)rm -f $@-t $@ && \ ++ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ ++ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ ++ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ ++ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ ++ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ ++ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ ++ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ ++ -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ ++ -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ ++ -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ ++ -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ ++ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ ++ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ ++ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ ++ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ ++ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ ++ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ ++ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ ++ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ ++ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ ++ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ ++ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ ++ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ ++ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ ++ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ ++ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ ++ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ ++ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ ++ < $(srcdir)/time.in.h; \ ++ } > $@-t && \ ++ mv $@-t $@ ++MOSTLYCLEANFILES += time.h time.h-t ++ ++EXTRA_DIST += time.in.h ++ ++## end gnulib module time ++ + ## begin gnulib module unistd + + BUILT_SOURCES += unistd.h +diff --git a/grub-core/gnulib/gettimeofday.c b/grub-core/gnulib/gettimeofday.c +new file mode 100644 +index 000000000..8b2058e8c +--- /dev/null ++++ b/grub-core/gnulib/gettimeofday.c +@@ -0,0 +1,154 @@ ++/* Provide gettimeofday for systems that don't have it or for which it's broken. ++ ++ Copyright (C) 2001-2003, 2005-2007, 2009-2014 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 ++ the Free Software Foundation; either version 3, 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, see . */ ++ ++/* written by Jim Meyering */ ++ ++#include ++ ++/* Specification. */ ++#include ++ ++#include ++ ++#if HAVE_SYS_TIMEB_H ++# include ++#endif ++ ++#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME ++ ++/* Work around the bug in some systems whereby gettimeofday clobbers ++ the static buffer that localtime uses for its return value. The ++ gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has ++ this problem. The tzset replacement is necessary for at least ++ Solaris 2.5, 2.5.1, and 2.6. */ ++ ++static struct tm tm_zero_buffer; ++static struct tm *localtime_buffer_addr = &tm_zero_buffer; ++ ++# undef localtime ++extern struct tm *localtime (time_t const *); ++ ++# undef gmtime ++extern struct tm *gmtime (time_t const *); ++ ++/* This is a wrapper for localtime. It is used only on systems for which ++ gettimeofday clobbers the static buffer used for localtime's result. ++ ++ On the first call, record the address of the static buffer that ++ localtime uses for its result. */ ++ ++struct tm * ++rpl_localtime (time_t const *timep) ++{ ++ struct tm *tm = localtime (timep); ++ ++ if (localtime_buffer_addr == &tm_zero_buffer) ++ localtime_buffer_addr = tm; ++ ++ return tm; ++} ++ ++/* Same as above, since gmtime and localtime use the same buffer. */ ++struct tm * ++rpl_gmtime (time_t const *timep) ++{ ++ struct tm *tm = gmtime (timep); ++ ++ if (localtime_buffer_addr == &tm_zero_buffer) ++ localtime_buffer_addr = tm; ++ ++ return tm; ++} ++ ++#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ ++ ++#if TZSET_CLOBBERS_LOCALTIME ++ ++# undef tzset ++extern void tzset (void); ++ ++/* This is a wrapper for tzset, for systems on which tzset may clobber ++ the static buffer used for localtime's result. */ ++void ++rpl_tzset (void) ++{ ++ /* Save and restore the contents of the buffer used for localtime's ++ result around the call to tzset. */ ++ struct tm save = *localtime_buffer_addr; ++ tzset (); ++ *localtime_buffer_addr = save; ++} ++#endif ++ ++/* This is a wrapper for gettimeofday. It is used only on systems ++ that lack this function, or whose implementation of this function ++ causes problems. */ ++ ++int ++gettimeofday (struct timeval *restrict tv, void *restrict tz) ++{ ++#undef gettimeofday ++#if HAVE_GETTIMEOFDAY ++# if GETTIMEOFDAY_CLOBBERS_LOCALTIME ++ /* Save and restore the contents of the buffer used for localtime's ++ result around the call to gettimeofday. */ ++ struct tm save = *localtime_buffer_addr; ++# endif ++ ++# if defined timeval /* 'struct timeval' overridden by gnulib? */ ++# undef timeval ++ struct timeval otv; ++ int result = gettimeofday (&otv, (struct timezone *) tz); ++ if (result == 0) ++ { ++ tv->tv_sec = otv.tv_sec; ++ tv->tv_usec = otv.tv_usec; ++ } ++# else ++ int result = gettimeofday (tv, (struct timezone *) tz); ++# endif ++ ++# if GETTIMEOFDAY_CLOBBERS_LOCALTIME ++ *localtime_buffer_addr = save; ++# endif ++ ++ return result; ++ ++#else ++ ++# if HAVE__FTIME ++ ++ struct _timeb timebuf; ++ _ftime (&timebuf); ++ tv->tv_sec = timebuf.time; ++ tv->tv_usec = timebuf.millitm * 1000; ++ ++# else ++ ++# if !defined OK_TO_USE_1S_CLOCK ++# error "Only 1-second nominal clock resolution found. Is that intended?" \ ++ "If so, compile with the -DOK_TO_USE_1S_CLOCK option." ++# endif ++ tv->tv_sec = time (NULL); ++ tv->tv_usec = 0; ++ ++# endif ++ ++ return 0; ++ ++#endif ++} +diff --git a/grub-core/gnulib/pathmax.h b/grub-core/gnulib/pathmax.h +new file mode 100644 +index 000000000..33fc3553d +--- /dev/null ++++ b/grub-core/gnulib/pathmax.h +@@ -0,0 +1,83 @@ ++/* Define PATH_MAX somehow. Requires sys/types.h. ++ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2014 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 ++ the Free Software Foundation; either version 3, 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, see . */ ++ ++#ifndef _PATHMAX_H ++# define _PATHMAX_H ++ ++/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, ++ including the terminating NUL byte. ++ ++ PATH_MAX is not defined on systems which have no limit on filename length, ++ such as GNU/Hurd. ++ ++ This file does *not* define PATH_MAX always. Programs that use this file ++ can handle the GNU/Hurd case in several ways: ++ - Either with a package-wide handling, or with a per-file handling, ++ - Either through a ++ #ifdef PATH_MAX ++ or through a fallback like ++ #ifndef PATH_MAX ++ # define PATH_MAX 8192 ++ #endif ++ or through a fallback like ++ #ifndef PATH_MAX ++ # define PATH_MAX pathconf ("/", _PC_PATH_MAX) ++ #endif ++ */ ++ ++# include ++ ++# include ++ ++# ifndef _POSIX_PATH_MAX ++# define _POSIX_PATH_MAX 256 ++# endif ++ ++/* Don't include sys/param.h if it already has been. */ ++# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN ++# include ++# endif ++ ++# if !defined PATH_MAX && defined MAXPATHLEN ++# define PATH_MAX MAXPATHLEN ++# endif ++ ++# ifdef __hpux ++/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, ++ *not* including the terminating NUL byte, and is set to 1023. ++ Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is ++ not defined at all any more. */ ++# undef PATH_MAX ++# define PATH_MAX 1024 ++# endif ++ ++# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ ++/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, ++ section "Maximum Path Length Limitation", ++ ++ explains that the maximum size of a filename, including the terminating ++ NUL byte, is 260 = 3 + 256 + 1. ++ This is the same value as ++ - FILENAME_MAX in , ++ - _MAX_PATH in , ++ - MAX_PATH in . ++ Undefine the original value, because mingw's gets it wrong. */ ++# undef PATH_MAX ++# define PATH_MAX 260 ++# endif ++ ++#endif /* _PATHMAX_H */ +diff --git a/grub-core/gnulib/readlink.c b/grub-core/gnulib/readlink.c +new file mode 100644 +index 000000000..4c4963951 +--- /dev/null ++++ b/grub-core/gnulib/readlink.c +@@ -0,0 +1,74 @@ ++/* Stub for readlink(). ++ Copyright (C) 2003-2007, 2009-2014 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 ++ 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, see . */ ++ ++#include ++ ++/* Specification. */ ++#include ++ ++#include ++#include ++#include ++ ++#if !HAVE_READLINK ++ ++/* readlink() substitute for systems that don't have a readlink() function, ++ such as DJGPP 2.03 and mingw32. */ ++ ++ssize_t ++readlink (const char *name, char *buf _GL_UNUSED, ++ size_t bufsize _GL_UNUSED) ++{ ++ struct stat statbuf; ++ ++ /* In general we should use lstat() here, not stat(). But on platforms ++ without symbolic links, lstat() - if it exists - would be equivalent to ++ stat(), therefore we can use stat(). This saves us a configure check. */ ++ if (stat (name, &statbuf) >= 0) ++ errno = EINVAL; ++ return -1; ++} ++ ++#else /* HAVE_READLINK */ ++ ++# undef readlink ++ ++/* readlink() wrapper that uses correct types, for systems like cygwin ++ 1.5.x where readlink returns int, and which rejects trailing slash, ++ for Solaris 9. */ ++ ++ssize_t ++rpl_readlink (const char *name, char *buf, size_t bufsize) ++{ ++# if READLINK_TRAILING_SLASH_BUG ++ size_t len = strlen (name); ++ if (len && name[len - 1] == '/') ++ { ++ /* Even if name without the slash is a symlink to a directory, ++ both lstat() and stat() must resolve the trailing slash to ++ the directory rather than the symlink. We can therefore ++ safely use stat() to distinguish between EINVAL and ++ ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ ++ struct stat st; ++ if (stat (name, &st) == 0) ++ errno = EINVAL; ++ return -1; ++ } ++# endif /* READLINK_TRAILING_SLASH_BUG */ ++ return readlink (name, buf, bufsize); ++} ++ ++#endif /* HAVE_READLINK */ +diff --git a/grub-core/gnulib/stat.c b/grub-core/gnulib/stat.c +new file mode 100644 +index 000000000..35f4b0b1a +--- /dev/null ++++ b/grub-core/gnulib/stat.c +@@ -0,0 +1,138 @@ ++/* Work around platform bugs in stat. ++ Copyright (C) 2009-2014 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 ++ 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, see . */ ++ ++/* written by Eric Blake */ ++ ++/* If the user's config.h happens to include , let it include only ++ the system's here, so that orig_stat doesn't recurse to ++ rpl_stat. */ ++#define __need_system_sys_stat_h ++#include ++ ++/* Get the original definition of stat. It might be defined as a macro. */ ++#include ++#include ++#undef __need_system_sys_stat_h ++ ++#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ ++# if _GL_WINDOWS_64_BIT_ST_SIZE ++# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ ++# define stat _stati64 ++# define REPLACE_FUNC_STAT_DIR 1 ++# undef REPLACE_FUNC_STAT_FILE ++# elif REPLACE_FUNC_STAT_FILE ++/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a. ++ Bypass it. */ ++# define stat _stat ++# define REPLACE_FUNC_STAT_DIR 1 ++# undef REPLACE_FUNC_STAT_FILE ++# endif ++#endif ++ ++static int ++orig_stat (const char *filename, struct stat *buf) ++{ ++ return stat (filename, buf); ++} ++ ++/* Specification. */ ++/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc ++ eliminates this include because of the preliminary #include ++ above. */ ++#include "sys/stat.h" ++ ++#include ++#include ++#include ++#include ++#include "dosname.h" ++#include "verify.h" ++ ++#if REPLACE_FUNC_STAT_DIR ++# include "pathmax.h" ++ /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also ++ have a constant PATH_MAX. */ ++# ifndef PATH_MAX ++# error "Please port this replacement to your platform" ++# endif ++#endif ++ ++/* Store information about NAME into ST. Work around bugs with ++ trailing slashes. Mingw has other bugs (such as st_ino always ++ being 0 on success) which this wrapper does not work around. But ++ at least this implementation provides the ability to emulate fchdir ++ correctly. */ ++ ++int ++rpl_stat (char const *name, struct stat *st) ++{ ++ int result = orig_stat (name, st); ++#if REPLACE_FUNC_STAT_FILE ++ /* Solaris 9 mistakenly succeeds when given a non-directory with a ++ trailing slash. */ ++ if (result == 0 && !S_ISDIR (st->st_mode)) ++ { ++ size_t len = strlen (name); ++ if (ISSLASH (name[len - 1])) ++ { ++ errno = ENOTDIR; ++ return -1; ++ } ++ } ++#endif /* REPLACE_FUNC_STAT_FILE */ ++#if REPLACE_FUNC_STAT_DIR ++ ++ if (result == -1 && errno == ENOENT) ++ { ++ /* Due to mingw's oddities, there are some directories (like ++ c:\) where stat() only succeeds with a trailing slash, and ++ other directories (like c:\windows) where stat() only ++ succeeds without a trailing slash. But we want the two to be ++ synonymous, since chdir() manages either style. Likewise, Mingw also ++ reports ENOENT for names longer than PATH_MAX, when we want ++ ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR. ++ Fortunately, mingw PATH_MAX is small enough for stack ++ allocation. */ ++ char fixed_name[PATH_MAX + 1] = {0}; ++ size_t len = strlen (name); ++ bool check_dir = false; ++ verify (PATH_MAX <= 4096); ++ if (PATH_MAX <= len) ++ errno = ENAMETOOLONG; ++ else if (len) ++ { ++ strcpy (fixed_name, name); ++ if (ISSLASH (fixed_name[len - 1])) ++ { ++ check_dir = true; ++ while (len && ISSLASH (fixed_name[len - 1])) ++ fixed_name[--len] = '\0'; ++ if (!len) ++ fixed_name[0] = '/'; ++ } ++ else ++ fixed_name[len++] = '/'; ++ result = orig_stat (fixed_name, st); ++ if (result == 0 && check_dir && !S_ISDIR (st->st_mode)) ++ { ++ result = -1; ++ errno = ENOTDIR; ++ } ++ } ++ } ++#endif /* REPLACE_FUNC_STAT_DIR */ ++ return result; ++} +diff --git a/grub-core/gnulib/sys_stat.in.h b/grub-core/gnulib/sys_stat.in.h +new file mode 100644 +index 000000000..b47a7ff0a +--- /dev/null ++++ b/grub-core/gnulib/sys_stat.in.h +@@ -0,0 +1,732 @@ ++/* Provide a more complete sys/stat header file. ++ Copyright (C) 2005-2014 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 ++ the Free Software Foundation; either version 3, 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, see . */ ++ ++/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ ++ ++/* This file is supposed to be used on platforms where is ++ incomplete. It is intended to provide definitions and prototypes ++ needed by an application. Start with what the system provides. */ ++ ++#if __GNUC__ >= 3 ++@PRAGMA_SYSTEM_HEADER@ ++#endif ++@PRAGMA_COLUMNS@ ++ ++#if defined __need_system_sys_stat_h ++/* Special invocation convention. */ ++ ++#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ ++ ++#else ++/* Normal invocation convention. */ ++ ++#ifndef _@GUARD_PREFIX@_SYS_STAT_H ++ ++/* Get nlink_t. ++ May also define off_t to a 64-bit type on native Windows. */ ++#include ++ ++/* Get struct timespec. */ ++#include ++ ++/* The include_next requires a split double-inclusion guard. */ ++#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ ++ ++#ifndef _@GUARD_PREFIX@_SYS_STAT_H ++#define _@GUARD_PREFIX@_SYS_STAT_H ++ ++/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ ++ ++/* The definition of _GL_ARG_NONNULL is copied here. */ ++ ++/* The definition of _GL_WARN_ON_USE is copied here. */ ++ ++/* Before doing "#define mkdir rpl_mkdir" below, we need to include all ++ headers that may declare mkdir(). Native Windows platforms declare mkdir ++ in and/or , not in . */ ++#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ ++# include /* mingw32, mingw64 */ ++# include /* mingw64, MSVC 9 */ ++#endif ++ ++/* Native Windows platforms declare umask() in . */ ++#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) ++# include ++#endif ++ ++/* Large File Support on native Windows. */ ++#if @WINDOWS_64_BIT_ST_SIZE@ ++# define stat _stati64 ++#endif ++ ++#ifndef S_IFIFO ++# ifdef _S_IFIFO ++# define S_IFIFO _S_IFIFO ++# endif ++#endif ++ ++#ifndef S_IFMT ++# define S_IFMT 0170000 ++#endif ++ ++#if STAT_MACROS_BROKEN ++# undef S_ISBLK ++# undef S_ISCHR ++# undef S_ISDIR ++# undef S_ISFIFO ++# undef S_ISLNK ++# undef S_ISNAM ++# undef S_ISMPB ++# undef S_ISMPC ++# undef S_ISNWK ++# undef S_ISREG ++# undef S_ISSOCK ++#endif ++ ++#ifndef S_ISBLK ++# ifdef S_IFBLK ++# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) ++# else ++# define S_ISBLK(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISCHR ++# ifdef S_IFCHR ++# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) ++# else ++# define S_ISCHR(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISDIR ++# ifdef S_IFDIR ++# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) ++# else ++# define S_ISDIR(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISDOOR /* Solaris 2.5 and up */ ++# define S_ISDOOR(m) 0 ++#endif ++ ++#ifndef S_ISFIFO ++# ifdef S_IFIFO ++# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) ++# else ++# define S_ISFIFO(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISLNK ++# ifdef S_IFLNK ++# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) ++# else ++# define S_ISLNK(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISMPB /* V7 */ ++# ifdef S_IFMPB ++# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) ++# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) ++# else ++# define S_ISMPB(m) 0 ++# define S_ISMPC(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISMPX /* AIX */ ++# define S_ISMPX(m) 0 ++#endif ++ ++#ifndef S_ISNAM /* Xenix */ ++# ifdef S_IFNAM ++# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) ++# else ++# define S_ISNAM(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISNWK /* HP/UX */ ++# ifdef S_IFNWK ++# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) ++# else ++# define S_ISNWK(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISPORT /* Solaris 10 and up */ ++# define S_ISPORT(m) 0 ++#endif ++ ++#ifndef S_ISREG ++# ifdef S_IFREG ++# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) ++# else ++# define S_ISREG(m) 0 ++# endif ++#endif ++ ++#ifndef S_ISSOCK ++# ifdef S_IFSOCK ++# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) ++# else ++# define S_ISSOCK(m) 0 ++# endif ++#endif ++ ++ ++#ifndef S_TYPEISMQ ++# define S_TYPEISMQ(p) 0 ++#endif ++ ++#ifndef S_TYPEISTMO ++# define S_TYPEISTMO(p) 0 ++#endif ++ ++ ++#ifndef S_TYPEISSEM ++# ifdef S_INSEM ++# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) ++# else ++# define S_TYPEISSEM(p) 0 ++# endif ++#endif ++ ++#ifndef S_TYPEISSHM ++# ifdef S_INSHD ++# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) ++# else ++# define S_TYPEISSHM(p) 0 ++# endif ++#endif ++ ++/* high performance ("contiguous data") */ ++#ifndef S_ISCTG ++# define S_ISCTG(p) 0 ++#endif ++ ++/* Cray DMF (data migration facility): off line, with data */ ++#ifndef S_ISOFD ++# define S_ISOFD(p) 0 ++#endif ++ ++/* Cray DMF (data migration facility): off line, with no data */ ++#ifndef S_ISOFL ++# define S_ISOFL(p) 0 ++#endif ++ ++/* 4.4BSD whiteout */ ++#ifndef S_ISWHT ++# define S_ISWHT(m) 0 ++#endif ++ ++/* If any of the following are undefined, ++ define them to their de facto standard values. */ ++#if !S_ISUID ++# define S_ISUID 04000 ++#endif ++#if !S_ISGID ++# define S_ISGID 02000 ++#endif ++ ++/* S_ISVTX is a common extension to POSIX. */ ++#ifndef S_ISVTX ++# define S_ISVTX 01000 ++#endif ++ ++#if !S_IRUSR && S_IREAD ++# define S_IRUSR S_IREAD ++#endif ++#if !S_IRUSR ++# define S_IRUSR 00400 ++#endif ++#if !S_IRGRP ++# define S_IRGRP (S_IRUSR >> 3) ++#endif ++#if !S_IROTH ++# define S_IROTH (S_IRUSR >> 6) ++#endif ++ ++#if !S_IWUSR && S_IWRITE ++# define S_IWUSR S_IWRITE ++#endif ++#if !S_IWUSR ++# define S_IWUSR 00200 ++#endif ++#if !S_IWGRP ++# define S_IWGRP (S_IWUSR >> 3) ++#endif ++#if !S_IWOTH ++# define S_IWOTH (S_IWUSR >> 6) ++#endif ++ ++#if !S_IXUSR && S_IEXEC ++# define S_IXUSR S_IEXEC ++#endif ++#if !S_IXUSR ++# define S_IXUSR 00100 ++#endif ++#if !S_IXGRP ++# define S_IXGRP (S_IXUSR >> 3) ++#endif ++#if !S_IXOTH ++# define S_IXOTH (S_IXUSR >> 6) ++#endif ++ ++#if !S_IRWXU ++# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) ++#endif ++#if !S_IRWXG ++# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) ++#endif ++#if !S_IRWXO ++# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) ++#endif ++ ++/* S_IXUGO is a common extension to POSIX. */ ++#if !S_IXUGO ++# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) ++#endif ++ ++#ifndef S_IRWXUGO ++# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) ++#endif ++ ++/* Macros for futimens and utimensat. */ ++#ifndef UTIME_NOW ++# define UTIME_NOW (-1) ++# define UTIME_OMIT (-2) ++#endif ++ ++ ++#if @GNULIB_FCHMODAT@ ++# if !@HAVE_FCHMODAT@ ++_GL_FUNCDECL_SYS (fchmodat, int, ++ (int fd, char const *file, mode_t mode, int flag) ++ _GL_ARG_NONNULL ((2))); ++# endif ++_GL_CXXALIAS_SYS (fchmodat, int, ++ (int fd, char const *file, mode_t mode, int flag)); ++_GL_CXXALIASWARN (fchmodat); ++#elif defined GNULIB_POSIXCHECK ++# undef fchmodat ++# if HAVE_RAW_DECL_FCHMODAT ++_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " ++ "use gnulib module openat for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_FSTAT@ ++# if @REPLACE_FSTAT@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef fstat ++# define fstat rpl_fstat ++# endif ++_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); ++_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); ++# else ++_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); ++# endif ++_GL_CXXALIASWARN (fstat); ++#elif @WINDOWS_64_BIT_ST_SIZE@ ++/* Above, we define stat to _stati64. */ ++# define fstat _fstati64 ++#elif defined GNULIB_POSIXCHECK ++# undef fstat ++# if HAVE_RAW_DECL_FSTAT ++_GL_WARN_ON_USE (fstat, "fstat has portability problems - " ++ "use gnulib module fstat for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_FSTATAT@ ++# if @REPLACE_FSTATAT@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef fstatat ++# define fstatat rpl_fstatat ++# endif ++_GL_FUNCDECL_RPL (fstatat, int, ++ (int fd, char const *name, struct stat *st, int flags) ++ _GL_ARG_NONNULL ((2, 3))); ++_GL_CXXALIAS_RPL (fstatat, int, ++ (int fd, char const *name, struct stat *st, int flags)); ++# else ++# if !@HAVE_FSTATAT@ ++_GL_FUNCDECL_SYS (fstatat, int, ++ (int fd, char const *name, struct stat *st, int flags) ++ _GL_ARG_NONNULL ((2, 3))); ++# endif ++_GL_CXXALIAS_SYS (fstatat, int, ++ (int fd, char const *name, struct stat *st, int flags)); ++# endif ++_GL_CXXALIASWARN (fstatat); ++#elif defined GNULIB_POSIXCHECK ++# undef fstatat ++# if HAVE_RAW_DECL_FSTATAT ++_GL_WARN_ON_USE (fstatat, "fstatat is not portable - " ++ "use gnulib module openat for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_FUTIMENS@ ++/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens ++ implementation relies on futimesat, which on Solaris 10 makes an invocation ++ to futimens that is meant to invoke the libc's futimens(), not gnulib's ++ futimens(). */ ++# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun) ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef futimens ++# define futimens rpl_futimens ++# endif ++_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2])); ++_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2])); ++# else ++# if !@HAVE_FUTIMENS@ ++_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2])); ++# endif ++_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2])); ++# endif ++# if @HAVE_FUTIMENS@ ++_GL_CXXALIASWARN (futimens); ++# endif ++#elif defined GNULIB_POSIXCHECK ++# undef futimens ++# if HAVE_RAW_DECL_FUTIMENS ++_GL_WARN_ON_USE (futimens, "futimens is not portable - " ++ "use gnulib module futimens for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_LCHMOD@ ++/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME ++ denotes a symbolic link. */ ++# if !@HAVE_LCHMOD@ ++/* The lchmod replacement follows symbolic links. Callers should take ++ this into account; lchmod should be applied only to arguments that ++ are known to not be symbolic links. On hosts that lack lchmod, ++ this can lead to race conditions between the check and the ++ invocation of lchmod, but we know of no workarounds that are ++ reliable in general. You might try requesting support for lchmod ++ from your operating system supplier. */ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define lchmod chmod ++# endif ++/* Need to cast, because on mingw, the second parameter of chmod is ++ int mode. */ ++_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int, ++ (const char *filename, mode_t mode)); ++# else ++# if 0 /* assume already declared */ ++_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) ++ _GL_ARG_NONNULL ((1))); ++# endif ++_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); ++# endif ++# if @HAVE_LCHMOD@ ++_GL_CXXALIASWARN (lchmod); ++# endif ++#elif defined GNULIB_POSIXCHECK ++# undef lchmod ++# if HAVE_RAW_DECL_LCHMOD ++_GL_WARN_ON_USE (lchmod, "lchmod is unportable - " ++ "use gnulib module lchmod for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_LSTAT@ ++# if ! @HAVE_LSTAT@ ++/* mingw does not support symlinks, therefore it does not have lstat. But ++ without links, stat does just fine. */ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define lstat stat ++# endif ++_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf)); ++# elif @REPLACE_LSTAT@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef lstat ++# define lstat rpl_lstat ++# endif ++_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf) ++ _GL_ARG_NONNULL ((1, 2))); ++_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf)); ++# else ++_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf)); ++# endif ++# if @HAVE_LSTAT@ ++_GL_CXXALIASWARN (lstat); ++# endif ++#elif defined GNULIB_POSIXCHECK ++# undef lstat ++# if HAVE_RAW_DECL_LSTAT ++_GL_WARN_ON_USE (lstat, "lstat is unportable - " ++ "use gnulib module lstat for portability"); ++# endif ++#endif ++ ++ ++#if @REPLACE_MKDIR@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef mkdir ++# define mkdir rpl_mkdir ++# endif ++_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); ++#else ++/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. ++ Additionally, it declares _mkdir (and depending on compile flags, an ++ alias mkdir), only in the nonstandard includes and , ++ which are included above. */ ++# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ ++ ++# if !GNULIB_defined_rpl_mkdir ++static int ++rpl_mkdir (char const *name, mode_t mode) ++{ ++ return _mkdir (name); ++} ++# define GNULIB_defined_rpl_mkdir 1 ++# endif ++ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define mkdir rpl_mkdir ++# endif ++_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); ++# else ++_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); ++# endif ++#endif ++_GL_CXXALIASWARN (mkdir); ++ ++ ++#if @GNULIB_MKDIRAT@ ++# if !@HAVE_MKDIRAT@ ++_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode) ++ _GL_ARG_NONNULL ((2))); ++# endif ++_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)); ++_GL_CXXALIASWARN (mkdirat); ++#elif defined GNULIB_POSIXCHECK ++# undef mkdirat ++# if HAVE_RAW_DECL_MKDIRAT ++_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - " ++ "use gnulib module openat for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_MKFIFO@ ++# if @REPLACE_MKFIFO@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef mkfifo ++# define mkfifo rpl_mkfifo ++# endif ++_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode)); ++# else ++# if !@HAVE_MKFIFO@ ++_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode) ++ _GL_ARG_NONNULL ((1))); ++# endif ++_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode)); ++# endif ++_GL_CXXALIASWARN (mkfifo); ++#elif defined GNULIB_POSIXCHECK ++# undef mkfifo ++# if HAVE_RAW_DECL_MKFIFO ++_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - " ++ "use gnulib module mkfifo for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_MKFIFOAT@ ++# if !@HAVE_MKFIFOAT@ ++_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) ++ _GL_ARG_NONNULL ((2))); ++# endif ++_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); ++_GL_CXXALIASWARN (mkfifoat); ++#elif defined GNULIB_POSIXCHECK ++# undef mkfifoat ++# if HAVE_RAW_DECL_MKFIFOAT ++_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - " ++ "use gnulib module mkfifoat for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_MKNOD@ ++# if @REPLACE_MKNOD@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef mknod ++# define mknod rpl_mknod ++# endif ++_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)); ++# else ++# if !@HAVE_MKNOD@ ++_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev) ++ _GL_ARG_NONNULL ((1))); ++# endif ++/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */ ++_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev)); ++# endif ++_GL_CXXALIASWARN (mknod); ++#elif defined GNULIB_POSIXCHECK ++# undef mknod ++# if HAVE_RAW_DECL_MKNOD ++_GL_WARN_ON_USE (mknod, "mknod is not portable - " ++ "use gnulib module mknod for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_MKNODAT@ ++# if !@HAVE_MKNODAT@ ++_GL_FUNCDECL_SYS (mknodat, int, ++ (int fd, char const *file, mode_t mode, dev_t dev) ++ _GL_ARG_NONNULL ((2))); ++# endif ++_GL_CXXALIAS_SYS (mknodat, int, ++ (int fd, char const *file, mode_t mode, dev_t dev)); ++_GL_CXXALIASWARN (mknodat); ++#elif defined GNULIB_POSIXCHECK ++# undef mknodat ++# if HAVE_RAW_DECL_MKNODAT ++_GL_WARN_ON_USE (mknodat, "mknodat is not portable - " ++ "use gnulib module mkfifoat for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_STAT@ ++# if @REPLACE_STAT@ ++/* We can't use the object-like #define stat rpl_stat, because of ++ struct stat. This means that rpl_stat will not be used if the user ++ does (stat)(a,b). Oh well. */ ++# if defined _AIX && defined stat && defined _LARGE_FILES ++ /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, ++ so we have to replace stat64() instead of stat(). */ ++# undef stat64 ++# define stat64(name, st) rpl_stat (name, st) ++# elif @WINDOWS_64_BIT_ST_SIZE@ ++ /* Above, we define stat to _stati64. */ ++# if defined __MINGW32__ && defined _stati64 ++# ifndef _USE_32BIT_TIME_T ++ /* The system headers define _stati64 to _stat64. */ ++# undef _stat64 ++# define _stat64(name, st) rpl_stat (name, st) ++# endif ++# elif defined _MSC_VER && defined _stati64 ++# ifdef _USE_32BIT_TIME_T ++ /* The system headers define _stati64 to _stat32i64. */ ++# undef _stat32i64 ++# define _stat32i64(name, st) rpl_stat (name, st) ++# else ++ /* The system headers define _stati64 to _stat64. */ ++# undef _stat64 ++# define _stat64(name, st) rpl_stat (name, st) ++# endif ++# else ++# undef _stati64 ++# define _stati64(name, st) rpl_stat (name, st) ++# endif ++# elif defined __MINGW32__ && defined stat ++# ifdef _USE_32BIT_TIME_T ++ /* The system headers define stat to _stat32i64. */ ++# undef _stat32i64 ++# define _stat32i64(name, st) rpl_stat (name, st) ++# else ++ /* The system headers define stat to _stat64. */ ++# undef _stat64 ++# define _stat64(name, st) rpl_stat (name, st) ++# endif ++# elif defined _MSC_VER && defined stat ++# ifdef _USE_32BIT_TIME_T ++ /* The system headers define stat to _stat32. */ ++# undef _stat32 ++# define _stat32(name, st) rpl_stat (name, st) ++# else ++ /* The system headers define stat to _stat64i32. */ ++# undef _stat64i32 ++# define _stat64i32(name, st) rpl_stat (name, st) ++# endif ++# else /* !(_AIX ||__MINGW32__ || _MSC_VER) */ ++# undef stat ++# define stat(name, st) rpl_stat (name, st) ++# endif /* !_LARGE_FILES */ ++_GL_EXTERN_C int stat (const char *name, struct stat *buf) ++ _GL_ARG_NONNULL ((1, 2)); ++# endif ++#elif defined GNULIB_POSIXCHECK ++# undef stat ++# if HAVE_RAW_DECL_STAT ++_GL_WARN_ON_USE (stat, "stat is unportable - " ++ "use gnulib module stat for portability"); ++# endif ++#endif ++ ++ ++#if @GNULIB_UTIMENSAT@ ++/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat ++ implementation relies on futimesat, which on Solaris 10 makes an invocation ++ to utimensat that is meant to invoke the libc's utimensat(), not gnulib's ++ utimensat(). */ ++# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun) ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef utimensat ++# define utimensat rpl_utimensat ++# endif ++_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name, ++ struct timespec const times[2], int flag) ++ _GL_ARG_NONNULL ((2))); ++_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name, ++ struct timespec const times[2], int flag)); ++# else ++# if !@HAVE_UTIMENSAT@ ++_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, ++ struct timespec const times[2], int flag) ++ _GL_ARG_NONNULL ((2))); ++# endif ++_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, ++ struct timespec const times[2], int flag)); ++# endif ++# if @HAVE_UTIMENSAT@ ++_GL_CXXALIASWARN (utimensat); ++# endif ++#elif defined GNULIB_POSIXCHECK ++# undef utimensat ++# if HAVE_RAW_DECL_UTIMENSAT ++_GL_WARN_ON_USE (utimensat, "utimensat is not portable - " ++ "use gnulib module utimensat for portability"); ++# endif ++#endif ++ ++ ++#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ ++#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ ++#endif +diff --git a/grub-core/gnulib/sys_time.in.h b/grub-core/gnulib/sys_time.in.h +new file mode 100644 +index 000000000..30057ad49 +--- /dev/null ++++ b/grub-core/gnulib/sys_time.in.h +@@ -0,0 +1,213 @@ ++/* Provide a more complete sys/time.h. ++ ++ Copyright (C) 2007-2014 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 ++ the Free Software Foundation; either version 3, 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, see . */ ++ ++/* Written by Paul Eggert. */ ++ ++#ifndef _@GUARD_PREFIX@_SYS_TIME_H ++ ++#if __GNUC__ >= 3 ++@PRAGMA_SYSTEM_HEADER@ ++#endif ++@PRAGMA_COLUMNS@ ++ ++/* On Cygwin and on many BSDish systems, includes itself ++ recursively via . ++ Simply delegate to the system's header in this case; it is a no-op. ++ Without this extra ifdef, the C++ gettimeofday declaration below ++ would be a forward declaration in gnulib's nested . */ ++#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_ ++# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ ++#else ++ ++/* The include_next requires a split double-inclusion guard. */ ++#if @HAVE_SYS_TIME_H@ ++# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ ++#endif ++ ++#ifndef _@GUARD_PREFIX@_SYS_TIME_H ++#define _@GUARD_PREFIX@_SYS_TIME_H ++ ++#if ! @HAVE_SYS_TIME_H@ ++# include ++#endif ++ ++/* On native Windows with MSVC, get the 'struct timeval' type. ++ Also, on native Windows with a 64-bit time_t, where we are overriding the ++ 'struct timeval' type, get all declarations of system functions whose ++ signature contains 'struct timeval'. */ ++#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H ++# define _GL_INCLUDING_WINSOCK2_H ++# include ++# undef _GL_INCLUDING_WINSOCK2_H ++#endif ++ ++/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ ++ ++/* The definition of _GL_ARG_NONNULL is copied here. */ ++ ++/* The definition of _GL_WARN_ON_USE is copied here. */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ ++ ++# if @REPLACE_STRUCT_TIMEVAL@ ++# define timeval rpl_timeval ++# endif ++ ++# if !GNULIB_defined_struct_timeval ++struct timeval ++{ ++ time_t tv_sec; ++ long int tv_usec; ++}; ++# define GNULIB_defined_struct_timeval 1 ++# endif ++ ++#endif ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#if @GNULIB_GETTIMEOFDAY@ ++# if @REPLACE_GETTIMEOFDAY@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef gettimeofday ++# define gettimeofday rpl_gettimeofday ++# endif ++_GL_FUNCDECL_RPL (gettimeofday, int, ++ (struct timeval *restrict, void *restrict) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (gettimeofday, int, ++ (struct timeval *restrict, void *restrict)); ++# else ++# if !@HAVE_GETTIMEOFDAY@ ++_GL_FUNCDECL_SYS (gettimeofday, int, ++ (struct timeval *restrict, void *restrict) ++ _GL_ARG_NONNULL ((1))); ++# endif ++/* Need to cast, because on glibc systems, by default, the second argument is ++ struct timezone *. */ ++_GL_CXXALIAS_SYS_CAST (gettimeofday, int, ++ (struct timeval *restrict, void *restrict)); ++# endif ++_GL_CXXALIASWARN (gettimeofday); ++#elif defined GNULIB_POSIXCHECK ++# undef gettimeofday ++# if HAVE_RAW_DECL_GETTIMEOFDAY ++_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " ++ "use gnulib module gettimeofday for portability"); ++# endif ++#endif ++ ++/* Hide some function declarations from . */ ++ ++#if defined _MSC_VER && @HAVE_WINSOCK2_H@ ++# if !defined _@GUARD_PREFIX@_UNISTD_H ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef close ++# define close close_used_without_including_unistd_h ++# else ++ _GL_WARN_ON_USE (close, ++ "close() used without including "); ++# endif ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef gethostname ++# define gethostname gethostname_used_without_including_unistd_h ++# else ++ _GL_WARN_ON_USE (gethostname, ++ "gethostname() used without including "); ++# endif ++# endif ++# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef socket ++# define socket socket_used_without_including_sys_socket_h ++# undef connect ++# define connect connect_used_without_including_sys_socket_h ++# undef accept ++# define accept accept_used_without_including_sys_socket_h ++# undef bind ++# define bind bind_used_without_including_sys_socket_h ++# undef getpeername ++# define getpeername getpeername_used_without_including_sys_socket_h ++# undef getsockname ++# define getsockname getsockname_used_without_including_sys_socket_h ++# undef getsockopt ++# define getsockopt getsockopt_used_without_including_sys_socket_h ++# undef listen ++# define listen listen_used_without_including_sys_socket_h ++# undef recv ++# define recv recv_used_without_including_sys_socket_h ++# undef send ++# define send send_used_without_including_sys_socket_h ++# undef recvfrom ++# define recvfrom recvfrom_used_without_including_sys_socket_h ++# undef sendto ++# define sendto sendto_used_without_including_sys_socket_h ++# undef setsockopt ++# define setsockopt setsockopt_used_without_including_sys_socket_h ++# undef shutdown ++# define shutdown shutdown_used_without_including_sys_socket_h ++# else ++ _GL_WARN_ON_USE (socket, ++ "socket() used without including "); ++ _GL_WARN_ON_USE (connect, ++ "connect() used without including "); ++ _GL_WARN_ON_USE (accept, ++ "accept() used without including "); ++ _GL_WARN_ON_USE (bind, ++ "bind() used without including "); ++ _GL_WARN_ON_USE (getpeername, ++ "getpeername() used without including "); ++ _GL_WARN_ON_USE (getsockname, ++ "getsockname() used without including "); ++ _GL_WARN_ON_USE (getsockopt, ++ "getsockopt() used without including "); ++ _GL_WARN_ON_USE (listen, ++ "listen() used without including "); ++ _GL_WARN_ON_USE (recv, ++ "recv() used without including "); ++ _GL_WARN_ON_USE (send, ++ "send() used without including "); ++ _GL_WARN_ON_USE (recvfrom, ++ "recvfrom() used without including "); ++ _GL_WARN_ON_USE (sendto, ++ "sendto() used without including "); ++ _GL_WARN_ON_USE (setsockopt, ++ "setsockopt() used without including "); ++ _GL_WARN_ON_USE (shutdown, ++ "shutdown() used without including "); ++# endif ++# endif ++# if !defined _@GUARD_PREFIX@_SYS_SELECT_H ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef select ++# define select select_used_without_including_sys_select_h ++# else ++ _GL_WARN_ON_USE (select, ++ "select() used without including "); ++# endif ++# endif ++#endif ++ ++#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ ++#endif /* _CYGWIN_SYS_TIME_H */ ++#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ +diff --git a/grub-core/gnulib/sys_types.in.h b/grub-core/gnulib/sys_types.in.h +index d7da35623..9520c0903 100644 +--- a/grub-core/gnulib/sys_types.in.h ++++ b/grub-core/gnulib/sys_types.in.h +@@ -23,7 +23,9 @@ + #ifndef _@GUARD_PREFIX@_SYS_TYPES_H + + /* The include_next requires a split double-inclusion guard. */ ++# define _GL_INCLUDING_SYS_TYPES_H + #@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ ++# undef _GL_INCLUDING_SYS_TYPES_H + + #ifndef _@GUARD_PREFIX@_SYS_TYPES_H + #define _@GUARD_PREFIX@_SYS_TYPES_H +diff --git a/grub-core/gnulib/time.h b/grub-core/gnulib/time.h +new file mode 100644 +index 000000000..b9203d556 +--- /dev/null ++++ b/grub-core/gnulib/time.h +@@ -0,0 +1,586 @@ ++/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ ++/* A more-standard . ++ ++ Copyright (C) 2007-2014 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 ++ the Free Software Foundation; either version 3, 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, see . */ ++ ++#if __GNUC__ >= 3 ++#pragma GCC system_header ++#endif ++ ++ ++/* Don't get in the way of glibc when it includes time.h merely to ++ declare a few standard symbols, rather than to declare all the ++ symbols. Also, Solaris 8 eventually includes itself ++ recursively; if that is happening, just include the system ++ without adding our own declarations. */ ++#if (defined __need_time_t || defined __need_clock_t \ ++ || defined __need_timespec \ ++ || defined _GL_TIME_H) ++ ++# include_next ++ ++#else ++ ++# define _GL_TIME_H ++ ++# include_next ++ ++/* NetBSD 5.0 mis-defines NULL. */ ++# include ++ ++/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ ++#ifndef _GL_CXXDEFS_H ++#define _GL_CXXDEFS_H ++ ++/* The three most frequent use cases of these macros are: ++ ++ * For providing a substitute for a function that is missing on some ++ platforms, but is declared and works fine on the platforms on which ++ it exists: ++ ++ #if @GNULIB_FOO@ ++ # if !@HAVE_FOO@ ++ _GL_FUNCDECL_SYS (foo, ...); ++ # endif ++ _GL_CXXALIAS_SYS (foo, ...); ++ _GL_CXXALIASWARN (foo); ++ #elif defined GNULIB_POSIXCHECK ++ ... ++ #endif ++ ++ * For providing a replacement for a function that exists on all platforms, ++ but is broken/insufficient and needs to be replaced on some platforms: ++ ++ #if @GNULIB_FOO@ ++ # if @REPLACE_FOO@ ++ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++ # undef foo ++ # define foo rpl_foo ++ # endif ++ _GL_FUNCDECL_RPL (foo, ...); ++ _GL_CXXALIAS_RPL (foo, ...); ++ # else ++ _GL_CXXALIAS_SYS (foo, ...); ++ # endif ++ _GL_CXXALIASWARN (foo); ++ #elif defined GNULIB_POSIXCHECK ++ ... ++ #endif ++ ++ * For providing a replacement for a function that exists on some platforms ++ but is broken/insufficient and needs to be replaced on some of them and ++ is additionally either missing or undeclared on some other platforms: ++ ++ #if @GNULIB_FOO@ ++ # if @REPLACE_FOO@ ++ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++ # undef foo ++ # define foo rpl_foo ++ # endif ++ _GL_FUNCDECL_RPL (foo, ...); ++ _GL_CXXALIAS_RPL (foo, ...); ++ # else ++ # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ ++ _GL_FUNCDECL_SYS (foo, ...); ++ # endif ++ _GL_CXXALIAS_SYS (foo, ...); ++ # endif ++ _GL_CXXALIASWARN (foo); ++ #elif defined GNULIB_POSIXCHECK ++ ... ++ #endif ++*/ ++ ++/* _GL_EXTERN_C declaration; ++ performs the declaration with C linkage. */ ++#if defined __cplusplus ++# define _GL_EXTERN_C extern "C" ++#else ++# define _GL_EXTERN_C extern ++#endif ++ ++/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); ++ declares a replacement function, named rpl_func, with the given prototype, ++ consisting of return type, parameters, and attributes. ++ Example: ++ _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) ++ _GL_ARG_NONNULL ((1))); ++ */ ++#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ ++ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) ++#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ ++ _GL_EXTERN_C rettype rpl_func parameters_and_attributes ++ ++/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); ++ declares the system function, named func, with the given prototype, ++ consisting of return type, parameters, and attributes. ++ Example: ++ _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) ++ _GL_ARG_NONNULL ((1))); ++ */ ++#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ ++ _GL_EXTERN_C rettype func parameters_and_attributes ++ ++/* _GL_CXXALIAS_RPL (func, rettype, parameters); ++ declares a C++ alias called GNULIB_NAMESPACE::func ++ that redirects to rpl_func, if GNULIB_NAMESPACE is defined. ++ Example: ++ _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); ++ */ ++#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ ++ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) ++#if defined __cplusplus && defined GNULIB_NAMESPACE ++# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ ++ namespace GNULIB_NAMESPACE \ ++ { \ ++ rettype (*const func) parameters = ::rpl_func; \ ++ } \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#else ++# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#endif ++ ++/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); ++ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); ++ except that the C function rpl_func may have a slightly different ++ declaration. A cast is used to silence the "invalid conversion" error ++ that would otherwise occur. */ ++#if defined __cplusplus && defined GNULIB_NAMESPACE ++# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ ++ namespace GNULIB_NAMESPACE \ ++ { \ ++ rettype (*const func) parameters = \ ++ reinterpret_cast(::rpl_func); \ ++ } \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#else ++# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#endif ++ ++/* _GL_CXXALIAS_SYS (func, rettype, parameters); ++ declares a C++ alias called GNULIB_NAMESPACE::func ++ that redirects to the system provided function func, if GNULIB_NAMESPACE ++ is defined. ++ Example: ++ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); ++ */ ++#if defined __cplusplus && defined GNULIB_NAMESPACE ++ /* If we were to write ++ rettype (*const func) parameters = ::func; ++ like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls ++ better (remove an indirection through a 'static' pointer variable), ++ but then the _GL_CXXALIASWARN macro below would cause a warning not only ++ for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ ++# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ ++ namespace GNULIB_NAMESPACE \ ++ { \ ++ static rettype (*func) parameters = ::func; \ ++ } \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#else ++# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#endif ++ ++/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); ++ is like _GL_CXXALIAS_SYS (func, rettype, parameters); ++ except that the C function func may have a slightly different declaration. ++ A cast is used to silence the "invalid conversion" error that would ++ otherwise occur. */ ++#if defined __cplusplus && defined GNULIB_NAMESPACE ++# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ ++ namespace GNULIB_NAMESPACE \ ++ { \ ++ static rettype (*func) parameters = \ ++ reinterpret_cast(::func); \ ++ } \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#else ++# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#endif ++ ++/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); ++ is like _GL_CXXALIAS_SYS (func, rettype, parameters); ++ except that the C function is picked among a set of overloaded functions, ++ namely the one with rettype2 and parameters2. Two consecutive casts ++ are used to silence the "cannot find a match" and "invalid conversion" ++ errors that would otherwise occur. */ ++#if defined __cplusplus && defined GNULIB_NAMESPACE ++ /* The outer cast must be a reinterpret_cast. ++ The inner cast: When the function is defined as a set of overloaded ++ functions, it works as a static_cast<>, choosing the designated variant. ++ When the function is defined as a single variant, it works as a ++ reinterpret_cast<>. The parenthesized cast syntax works both ways. */ ++# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ ++ namespace GNULIB_NAMESPACE \ ++ { \ ++ static rettype (*func) parameters = \ ++ reinterpret_cast( \ ++ (rettype2(*)parameters2)(::func)); \ ++ } \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#else ++# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#endif ++ ++/* _GL_CXXALIASWARN (func); ++ causes a warning to be emitted when ::func is used but not when ++ GNULIB_NAMESPACE::func is used. func must be defined without overloaded ++ variants. */ ++#if defined __cplusplus && defined GNULIB_NAMESPACE ++# define _GL_CXXALIASWARN(func) \ ++ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) ++# define _GL_CXXALIASWARN_1(func,namespace) \ ++ _GL_CXXALIASWARN_2 (func, namespace) ++/* To work around GCC bug , ++ we enable the warning only when not optimizing. */ ++# if !__OPTIMIZE__ ++# define _GL_CXXALIASWARN_2(func,namespace) \ ++ _GL_WARN_ON_USE (func, \ ++ "The symbol ::" #func " refers to the system function. " \ ++ "Use " #namespace "::" #func " instead.") ++# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING ++# define _GL_CXXALIASWARN_2(func,namespace) \ ++ extern __typeof__ (func) func ++# else ++# define _GL_CXXALIASWARN_2(func,namespace) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++# endif ++#else ++# define _GL_CXXALIASWARN(func) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#endif ++ ++/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); ++ causes a warning to be emitted when the given overloaded variant of ::func ++ is used but not when GNULIB_NAMESPACE::func is used. */ ++#if defined __cplusplus && defined GNULIB_NAMESPACE ++# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ ++ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ ++ GNULIB_NAMESPACE) ++# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ ++ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) ++/* To work around GCC bug , ++ we enable the warning only when not optimizing. */ ++# if !__OPTIMIZE__ ++# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ ++ _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ ++ "The symbol ::" #func " refers to the system function. " \ ++ "Use " #namespace "::" #func " instead.") ++# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING ++# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ ++ extern __typeof__ (func) func ++# else ++# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++# endif ++#else ++# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ ++ _GL_EXTERN_C int _gl_cxxalias_dummy ++#endif ++ ++#endif /* _GL_CXXDEFS_H */ ++ ++/* The definition of _GL_ARG_NONNULL is copied here. */ ++/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools ++ that the values passed as arguments n, ..., m must be non-NULL pointers. ++ n = 1 stands for the first argument, n = 2 for the second argument etc. */ ++#ifndef _GL_ARG_NONNULL ++# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 ++# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) ++# else ++# define _GL_ARG_NONNULL(params) ++# endif ++#endif ++ ++/* The definition of _GL_WARN_ON_USE is copied here. */ ++#ifndef _GL_WARN_ON_USE ++ ++# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) ++/* A compiler attribute is available in gcc versions 4.3.0 and later. */ ++# define _GL_WARN_ON_USE(function, message) \ ++extern __typeof__ (function) function __attribute__ ((__warning__ (message))) ++# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING ++/* Verify the existence of the function. */ ++# define _GL_WARN_ON_USE(function, message) \ ++extern __typeof__ (function) function ++# else /* Unsupported. */ ++# define _GL_WARN_ON_USE(function, message) \ ++_GL_WARN_EXTERN_C int _gl_warn_on_use ++# endif ++#endif ++ ++/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") ++ is like _GL_WARN_ON_USE (function, "string"), except that the function is ++ declared with the given prototype, consisting of return type, parameters, ++ and attributes. ++ This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does ++ not work in this case. */ ++#ifndef _GL_WARN_ON_USE_CXX ++# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) ++# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ ++extern rettype function parameters_and_attributes \ ++ __attribute__ ((__warning__ (msg))) ++# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING ++/* Verify the existence of the function. */ ++# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ ++extern rettype function parameters_and_attributes ++# else /* Unsupported. */ ++# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ ++_GL_WARN_EXTERN_C int _gl_warn_on_use ++# endif ++#endif ++ ++/* _GL_WARN_EXTERN_C declaration; ++ performs the declaration with C linkage. */ ++#ifndef _GL_WARN_EXTERN_C ++# if defined __cplusplus ++# define _GL_WARN_EXTERN_C extern "C" ++# else ++# define _GL_WARN_EXTERN_C extern ++# endif ++#endif ++ ++/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). ++ Or they define it with the wrong member names or define it in ++ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, ++ but the pthreads-win32 library defines it in . */ ++# if ! 1 ++# if 0 ++# include ++# elif 0 ++# include ++# else ++ ++# ifdef __cplusplus ++extern "C" { ++# endif ++ ++# if !GNULIB_defined_struct_timespec ++# undef timespec ++# define timespec rpl_timespec ++struct timespec ++{ ++ time_t tv_sec; ++ long int tv_nsec; ++}; ++# define GNULIB_defined_struct_timespec 1 ++# endif ++ ++# ifdef __cplusplus ++} ++# endif ++ ++# endif ++# endif ++ ++# if !GNULIB_defined_struct_time_t_must_be_integral ++/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires ++ time_t to be an integer type, even though C99 permits floating ++ point. We don't know of any implementation that uses floating ++ point, and it is much easier to write code that doesn't have to ++ worry about that corner case, so we force the issue. */ ++struct __time_t_must_be_integral { ++ unsigned int __floating_time_t_unsupported : (time_t) 1; ++}; ++# define GNULIB_defined_struct_time_t_must_be_integral 1 ++# endif ++ ++/* Sleep for at least RQTP seconds unless interrupted, If interrupted, ++ return -1 and store the remaining time into RMTP. See ++ . */ ++# if 0 ++# if GNULIB_PORTCHECK ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define nanosleep rpl_nanosleep ++# endif ++_GL_FUNCDECL_RPL (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp)); ++# else ++# if ! 1 ++_GL_FUNCDECL_SYS (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp) ++ _GL_ARG_NONNULL ((1))); ++# endif ++_GL_CXXALIAS_SYS (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp)); ++# endif ++_GL_CXXALIASWARN (nanosleep); ++# endif ++ ++/* Return the 'time_t' representation of TP and normalize TP. */ ++# if 0 ++# if GNULIB_PORTCHECK ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define mktime rpl_mktime ++# endif ++_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); ++# else ++_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); ++# endif ++_GL_CXXALIASWARN (mktime); ++# endif ++ ++/* Convert TIMER to RESULT, assuming local time and UTC respectively. See ++ and ++ . */ ++# if 0 ++# if GNULIB_PORTCHECK ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef localtime_r ++# define localtime_r rpl_localtime_r ++# endif ++_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# else ++# if ! 1 ++_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++# endif ++_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# endif ++# if 1 ++_GL_CXXALIASWARN (localtime_r); ++# endif ++# if GNULIB_PORTCHECK ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef gmtime_r ++# define gmtime_r rpl_gmtime_r ++# endif ++_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# else ++# if ! 1 ++_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++# endif ++_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# endif ++# if 1 ++_GL_CXXALIASWARN (gmtime_r); ++# endif ++# endif ++ ++/* Convert TIMER to RESULT, assuming local time and UTC respectively. See ++ and ++ . */ ++# if 1 ++# if 0 ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef localtime ++# define localtime rpl_localtime ++# endif ++_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); ++# else ++_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); ++# endif ++_GL_CXXALIASWARN (localtime); ++# endif ++ ++# if 1 ++# if 0 ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef gmtime ++# define gmtime rpl_gmtime ++# endif ++_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); ++# else ++_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); ++# endif ++_GL_CXXALIASWARN (gmtime); ++# endif ++ ++/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store ++ the resulting broken-down time into TM. See ++ . */ ++# if 0 ++# if ! 1 ++_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, ++ char const *restrict __format, ++ struct tm *restrict __tm) ++ _GL_ARG_NONNULL ((1, 2, 3))); ++# endif ++_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, ++ char const *restrict __format, ++ struct tm *restrict __tm)); ++_GL_CXXALIASWARN (strptime); ++# endif ++ ++/* Convert TM to a time_t value, assuming UTC. */ ++# if 0 ++# if GNULIB_PORTCHECK ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef timegm ++# define timegm rpl_timegm ++# endif ++_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); ++# else ++# if ! 1 ++_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); ++# endif ++_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); ++# endif ++_GL_CXXALIASWARN (timegm); ++# endif ++ ++/* Encourage applications to avoid unsafe functions that can overrun ++ buffers when given outlandish struct tm values. Portable ++ applications should use strftime (or even sprintf) instead. */ ++# if defined GNULIB_POSIXCHECK ++# undef asctime ++_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++# if defined GNULIB_POSIXCHECK ++# undef asctime_r ++_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++# if defined GNULIB_POSIXCHECK ++# undef ctime ++_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++# if defined GNULIB_POSIXCHECK ++# undef ctime_r ++_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++ ++#endif +diff --git a/grub-core/gnulib/time.in.h b/grub-core/gnulib/time.in.h +new file mode 100644 +index 000000000..81abdf46e +--- /dev/null ++++ b/grub-core/gnulib/time.in.h +@@ -0,0 +1,274 @@ ++/* A more-standard . ++ ++ Copyright (C) 2007-2014 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 ++ the Free Software Foundation; either version 3, 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, see . */ ++ ++#if __GNUC__ >= 3 ++@PRAGMA_SYSTEM_HEADER@ ++#endif ++@PRAGMA_COLUMNS@ ++ ++/* Don't get in the way of glibc when it includes time.h merely to ++ declare a few standard symbols, rather than to declare all the ++ symbols. Also, Solaris 8 eventually includes itself ++ recursively; if that is happening, just include the system ++ without adding our own declarations. */ ++#if (defined __need_time_t || defined __need_clock_t \ ++ || defined __need_timespec \ ++ || defined _@GUARD_PREFIX@_TIME_H) ++ ++# @INCLUDE_NEXT@ @NEXT_TIME_H@ ++ ++#else ++ ++# define _@GUARD_PREFIX@_TIME_H ++ ++# @INCLUDE_NEXT@ @NEXT_TIME_H@ ++ ++/* NetBSD 5.0 mis-defines NULL. */ ++# include ++ ++/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ ++ ++/* The definition of _GL_ARG_NONNULL is copied here. */ ++ ++/* The definition of _GL_WARN_ON_USE is copied here. */ ++ ++/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). ++ Or they define it with the wrong member names or define it in ++ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, ++ but the pthreads-win32 library defines it in . */ ++# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ ++# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ ++# include ++# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ ++# include ++# else ++ ++# ifdef __cplusplus ++extern "C" { ++# endif ++ ++# if !GNULIB_defined_struct_timespec ++# undef timespec ++# define timespec rpl_timespec ++struct timespec ++{ ++ time_t tv_sec; ++ long int tv_nsec; ++}; ++# define GNULIB_defined_struct_timespec 1 ++# endif ++ ++# ifdef __cplusplus ++} ++# endif ++ ++# endif ++# endif ++ ++# if !GNULIB_defined_struct_time_t_must_be_integral ++/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires ++ time_t to be an integer type, even though C99 permits floating ++ point. We don't know of any implementation that uses floating ++ point, and it is much easier to write code that doesn't have to ++ worry about that corner case, so we force the issue. */ ++struct __time_t_must_be_integral { ++ unsigned int __floating_time_t_unsupported : (time_t) 1; ++}; ++# define GNULIB_defined_struct_time_t_must_be_integral 1 ++# endif ++ ++/* Sleep for at least RQTP seconds unless interrupted, If interrupted, ++ return -1 and store the remaining time into RMTP. See ++ . */ ++# if @GNULIB_NANOSLEEP@ ++# if @REPLACE_NANOSLEEP@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define nanosleep rpl_nanosleep ++# endif ++_GL_FUNCDECL_RPL (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp)); ++# else ++# if ! @HAVE_NANOSLEEP@ ++_GL_FUNCDECL_SYS (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp) ++ _GL_ARG_NONNULL ((1))); ++# endif ++_GL_CXXALIAS_SYS (nanosleep, int, ++ (struct timespec const *__rqtp, struct timespec *__rmtp)); ++# endif ++_GL_CXXALIASWARN (nanosleep); ++# endif ++ ++/* Return the 'time_t' representation of TP and normalize TP. */ ++# if @GNULIB_MKTIME@ ++# if @REPLACE_MKTIME@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define mktime rpl_mktime ++# endif ++_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); ++# else ++_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); ++# endif ++_GL_CXXALIASWARN (mktime); ++# endif ++ ++/* Convert TIMER to RESULT, assuming local time and UTC respectively. See ++ and ++ . */ ++# if @GNULIB_TIME_R@ ++# if @REPLACE_LOCALTIME_R@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef localtime_r ++# define localtime_r rpl_localtime_r ++# endif ++_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# else ++# if ! @HAVE_DECL_LOCALTIME_R@ ++_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++# endif ++_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# endif ++# if @HAVE_DECL_LOCALTIME_R@ ++_GL_CXXALIASWARN (localtime_r); ++# endif ++# if @REPLACE_LOCALTIME_R@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef gmtime_r ++# define gmtime_r rpl_gmtime_r ++# endif ++_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# else ++# if ! @HAVE_DECL_LOCALTIME_R@ ++_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result) ++ _GL_ARG_NONNULL ((1, 2))); ++# endif ++_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, ++ struct tm *restrict __result)); ++# endif ++# if @HAVE_DECL_LOCALTIME_R@ ++_GL_CXXALIASWARN (gmtime_r); ++# endif ++# endif ++ ++/* Convert TIMER to RESULT, assuming local time and UTC respectively. See ++ and ++ . */ ++# if @GNULIB_GETTIMEOFDAY@ ++# if @REPLACE_LOCALTIME@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef localtime ++# define localtime rpl_localtime ++# endif ++_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); ++# else ++_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); ++# endif ++_GL_CXXALIASWARN (localtime); ++# endif ++ ++# if @GNULIB_GETTIMEOFDAY@ ++# if @REPLACE_GMTIME@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef gmtime ++# define gmtime rpl_gmtime ++# endif ++_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) ++ _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); ++# else ++_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); ++# endif ++_GL_CXXALIASWARN (gmtime); ++# endif ++ ++/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store ++ the resulting broken-down time into TM. See ++ . */ ++# if @GNULIB_STRPTIME@ ++# if ! @HAVE_STRPTIME@ ++_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, ++ char const *restrict __format, ++ struct tm *restrict __tm) ++ _GL_ARG_NONNULL ((1, 2, 3))); ++# endif ++_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, ++ char const *restrict __format, ++ struct tm *restrict __tm)); ++_GL_CXXALIASWARN (strptime); ++# endif ++ ++/* Convert TM to a time_t value, assuming UTC. */ ++# if @GNULIB_TIMEGM@ ++# if @REPLACE_TIMEGM@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# undef timegm ++# define timegm rpl_timegm ++# endif ++_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); ++_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); ++# else ++# if ! @HAVE_TIMEGM@ ++_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); ++# endif ++_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); ++# endif ++_GL_CXXALIASWARN (timegm); ++# endif ++ ++/* Encourage applications to avoid unsafe functions that can overrun ++ buffers when given outlandish struct tm values. Portable ++ applications should use strftime (or even sprintf) instead. */ ++# if defined GNULIB_POSIXCHECK ++# undef asctime ++_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++# if defined GNULIB_POSIXCHECK ++# undef asctime_r ++_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++# if defined GNULIB_POSIXCHECK ++# undef ctime ++_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++# if defined GNULIB_POSIXCHECK ++# undef ctime_r ++_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " ++ "better use strftime (or even sprintf) instead"); ++# endif ++ ++#endif +diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c +index 85507af88..6f49df465 100644 +--- a/grub-core/osdep/windows/hostdisk.c ++++ b/grub-core/osdep/windows/hostdisk.c +@@ -353,6 +353,12 @@ grub_util_mkdir (const char *dir) + free (windows_name); + } + ++ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize) ++{ ++ return readlink(name, buf, bufsize); ++} ++ + int + grub_util_rename (const char *from, const char *to) + { +diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h +index a059c0fa4..161fbb7bd 100644 +--- a/include/grub/osdep/hostfile_aros.h ++++ b/include/grub/osdep/hostfile_aros.h +@@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to) + return rename (from, to); + } + ++static inline ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize) ++{ ++ return readlink(name, buf, bufsize); ++} ++ + #define grub_util_mkdir(a) mkdir ((a), 0755) + + struct grub_util_fd +diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h +index 9ffe46fa3..17cd3aa8b 100644 +--- a/include/grub/osdep/hostfile_unix.h ++++ b/include/grub/osdep/hostfile_unix.h +@@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to) + return rename (from, to); + } + ++static inline ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize) ++{ ++ return readlink(name, buf, bufsize); ++} ++ + #define grub_util_mkdir(a) mkdir ((a), 0755) + + #if defined (__NetBSD__) +diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h +index bf6451b6d..8c92d0591 100644 +--- a/include/grub/osdep/hostfile_windows.h ++++ b/include/grub/osdep/hostfile_windows.h +@@ -41,6 +41,8 @@ typedef struct grub_util_fd_dir *grub_util_fd_dir_t; + + int + grub_util_rename (const char *from, const char *to); ++ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize); + int + grub_util_unlink (const char *name); + void +diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 +new file mode 100644 +index 000000000..1c2d66ee2 +--- /dev/null ++++ b/m4/gettimeofday.m4 +@@ -0,0 +1,138 @@ ++# serial 21 ++ ++# Copyright (C) 2001-2003, 2005, 2007, 2009-2014 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. ++ ++dnl From Jim Meyering. ++ ++AC_DEFUN([gl_FUNC_GETTIMEOFDAY], ++[ ++ AC_REQUIRE([AC_C_RESTRICT]) ++ AC_REQUIRE([gl_HEADER_SYS_TIME_H]) ++ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) ++ AC_CHECK_FUNCS_ONCE([gettimeofday]) ++ ++ gl_gettimeofday_timezone=void ++ if test $ac_cv_func_gettimeofday != yes; then ++ HAVE_GETTIMEOFDAY=0 ++ else ++ gl_FUNC_GETTIMEOFDAY_CLOBBER ++ AC_CACHE_CHECK([for gettimeofday with POSIX signature], ++ [gl_cv_func_gettimeofday_posix_signature], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ struct timeval c; ++ int gettimeofday (struct timeval *restrict, void *restrict); ++ ]], ++ [[/* glibc uses struct timezone * rather than the POSIX void * ++ if _GNU_SOURCE is defined. However, since the only portable ++ use of gettimeofday uses NULL as the second parameter, and ++ since the glibc definition is actually more typesafe, it is ++ not worth wrapping this to get a compliant signature. */ ++ int (*f) (struct timeval *restrict, void *restrict) ++ = gettimeofday; ++ int x = f (&c, 0); ++ return !(x | c.tv_sec | c.tv_usec); ++ ]])], ++ [gl_cv_func_gettimeofday_posix_signature=yes], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++int gettimeofday (struct timeval *restrict, struct timezone *restrict); ++ ]])], ++ [gl_cv_func_gettimeofday_posix_signature=almost], ++ [gl_cv_func_gettimeofday_posix_signature=no])])]) ++ if test $gl_cv_func_gettimeofday_posix_signature = almost; then ++ gl_gettimeofday_timezone='struct timezone' ++ elif test $gl_cv_func_gettimeofday_posix_signature != yes; then ++ REPLACE_GETTIMEOFDAY=1 ++ fi ++ dnl If we override 'struct timeval', we also have to override gettimeofday. ++ if test $REPLACE_STRUCT_TIMEVAL = 1; then ++ REPLACE_GETTIMEOFDAY=1 ++ fi ++ m4_ifdef([gl_FUNC_TZSET_CLOBBER], [ ++ gl_FUNC_TZSET_CLOBBER ++ case "$gl_cv_func_tzset_clobber" in ++ *yes) ++ REPLACE_GETTIMEOFDAY=1 ++ gl_GETTIMEOFDAY_REPLACE_LOCALTIME ++ AC_DEFINE([tzset], [rpl_tzset], ++ [Define to rpl_tzset if the wrapper function should be used.]) ++ AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1], ++ [Define if tzset clobbers localtime's static buffer.]) ++ ;; ++ esac ++ ]) ++ fi ++ AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone], ++ [Define this to 'void' or 'struct timezone' to match the system's ++ declaration of the second argument to gettimeofday.]) ++]) ++ ++ ++dnl See if gettimeofday clobbers the static buffer that localtime uses ++dnl for its return value. The gettimeofday function from Mac OS X 10.0.4 ++dnl (i.e., Darwin 1.3.7) has this problem. ++dnl ++dnl If it does, then arrange to use gettimeofday and localtime only via ++dnl the wrapper functions that work around the problem. ++ ++AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], ++[ ++ AC_REQUIRE([gl_HEADER_SYS_TIME_H]) ++ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles ++ ++ AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], ++ [gl_cv_func_gettimeofday_clobber], ++ [AC_RUN_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ #include ++ #include ++ #include ++ ]], ++ [[ ++ time_t t = 0; ++ struct tm *lt; ++ struct tm saved_lt; ++ struct timeval tv; ++ lt = localtime (&t); ++ saved_lt = *lt; ++ gettimeofday (&tv, NULL); ++ return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; ++ ]])], ++ [gl_cv_func_gettimeofday_clobber=no], ++ [gl_cv_func_gettimeofday_clobber=yes], ++ [# When cross-compiling: ++ case "$host_os" in ++ # Guess all is fine on glibc systems. ++ *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; ++ # If we don't know, assume the worst. ++ *) gl_cv_func_gettimeofday_clobber="guessing yes" ;; ++ esac ++ ])]) ++ ++ case "$gl_cv_func_gettimeofday_clobber" in ++ *yes) ++ REPLACE_GETTIMEOFDAY=1 ++ gl_GETTIMEOFDAY_REPLACE_LOCALTIME ++ AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1], ++ [Define if gettimeofday clobbers the localtime buffer.]) ++ ;; ++ esac ++]) ++ ++AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [ ++ REPLACE_GMTIME=1 ++ REPLACE_LOCALTIME=1 ++]) ++ ++# Prerequisites of lib/gettimeofday.c. ++AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [ ++ AC_CHECK_HEADERS([sys/timeb.h]) ++ AC_CHECK_FUNCS([_ftime]) ++]) +diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 +index 408918440..ef2ec5bcc 100644 +--- a/m4/gnulib-cache.m4 ++++ b/m4/gnulib-cache.m4 +@@ -27,7 +27,7 @@ + + + # Specification in the form of a command-line invocation: +-# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex ++# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex + + # Specification in the form of a few gnulib-tool.m4 macro invocations: + gl_LOCAL_DIR([]) +@@ -39,6 +39,7 @@ gl_MODULES([ + getline + gettext + progname ++ readlink + regex + ]) + gl_AVOID([]) +diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 +index 7a19f60d8..66fd0eda9 100644 +--- a/m4/gnulib-comp.m4 ++++ b/m4/gnulib-comp.m4 +@@ -60,10 +60,13 @@ AC_DEFUN([gl_EARLY], + # Code from module getopt-posix: + # Code from module gettext: + # Code from module gettext-h: ++ # Code from module gettimeofday: + # Code from module havelib: + # Code from module include_next: + # Code from module intprops: + # Code from module langinfo: ++ # Code from module largefile: ++ AC_REQUIRE([AC_SYS_LARGEFILE]) + # Code from module localcharset: + # Code from module locale: + # Code from module localeconv: +@@ -81,8 +84,10 @@ AC_DEFUN([gl_EARLY], + # Code from module multiarch: + # Code from module nl_langinfo: + # Code from module nocrash: ++ # Code from module pathmax: + # Code from module progname: + # Code from module rawmemchr: ++ # Code from module readlink: + # Code from module realloc-posix: + # Code from module regex: + # Code from module size_max: +@@ -92,6 +97,7 @@ AC_DEFUN([gl_EARLY], + # Code from module snippet/c++defs: + # Code from module snippet/warn-on-use: + # Code from module ssize_t: ++ # Code from module stat: + # Code from module stdalign: + # Code from module stdbool: + # Code from module stddef: +@@ -108,8 +114,11 @@ AC_DEFUN([gl_EARLY], + # Code from module strndup: + # Code from module strnlen: + # Code from module strnlen1: ++ # Code from module sys_stat: ++ # Code from module sys_time: + # Code from module sys_types: + # Code from module sysexits: ++ # Code from module time: + # Code from module unistd: + # Code from module unitypes: + # Code from module uniwidth/base: +@@ -211,7 +220,14 @@ AC_DEFUN([gl_INIT], + AM_GNU_GETTEXT_VERSION([0.18.1]) + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) ++ gl_FUNC_GETTIMEOFDAY ++ if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then ++ AC_LIBOBJ([gettimeofday]) ++ gl_PREREQ_GETTIMEOFDAY ++ fi ++ gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) + gl_LANGINFO_H ++ AC_REQUIRE([gl_LARGEFILE]) + gl_LOCALCHARSET + LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" + AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) +@@ -284,6 +300,7 @@ AC_DEFUN([gl_INIT], + AC_LIBOBJ([nl_langinfo]) + fi + gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) ++ gl_PATHMAX + AC_CHECK_DECLS([program_invocation_name], [], [], [#include ]) + AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ]) + gl_FUNC_RAWMEMCHR +@@ -292,6 +309,12 @@ AC_DEFUN([gl_INIT], + gl_PREREQ_RAWMEMCHR + fi + gl_STRING_MODULE_INDICATOR([rawmemchr]) ++ gl_FUNC_READLINK ++ if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then ++ AC_LIBOBJ([readlink]) ++ gl_PREREQ_READLINK ++ fi ++ gl_UNISTD_MODULE_INDICATOR([readlink]) + gl_FUNC_REALLOC_POSIX + if test $REPLACE_REALLOC = 1; then + AC_LIBOBJ([realloc]) +@@ -309,6 +332,12 @@ AC_DEFUN([gl_INIT], + fi + gl_UNISTD_MODULE_INDICATOR([sleep]) + gt_TYPE_SSIZE_T ++ gl_FUNC_STAT ++ if test $REPLACE_STAT = 1; then ++ AC_LIBOBJ([stat]) ++ gl_PREREQ_STAT ++ fi ++ gl_SYS_STAT_MODULE_INDICATOR([stat]) + gl_STDALIGN_H + AM_STDBOOL_H + gl_STDDEF_H +@@ -355,9 +384,14 @@ AC_DEFUN([gl_INIT], + gl_PREREQ_STRNLEN + fi + gl_STRING_MODULE_INDICATOR([strnlen]) ++ gl_HEADER_SYS_STAT_H ++ AC_PROG_MKDIR_P ++ gl_HEADER_SYS_TIME_H ++ AC_PROG_MKDIR_P + gl_SYS_TYPES_H + AC_PROG_MKDIR_P + gl_SYSEXITS ++ gl_HEADER_TIME_H + gl_UNISTD_H + gl_LIBUNISTRING_LIBHEADER([0.9], [unitypes.h]) + gl_LIBUNISTRING_LIBHEADER([0.9], [uniwidth.h]) +@@ -562,6 +596,7 @@ AC_DEFUN([gl_FILE_LIST], [ + lib/getopt1.c + lib/getopt_int.h + lib/gettext.h ++ lib/gettimeofday.c + lib/intprops.h + lib/itold.c + lib/langinfo.in.h +@@ -587,6 +622,7 @@ AC_DEFUN([gl_FILE_LIST], [ + lib/msvc-nothrow.c + lib/msvc-nothrow.h + lib/nl_langinfo.c ++ lib/pathmax.h + lib/printf-args.c + lib/printf-args.h + lib/printf-parse.c +@@ -595,6 +631,7 @@ AC_DEFUN([gl_FILE_LIST], [ + lib/progname.h + lib/rawmemchr.c + lib/rawmemchr.valgrind ++ lib/readlink.c + lib/realloc.c + lib/ref-add.sin + lib/ref-del.sin +@@ -606,6 +643,7 @@ AC_DEFUN([gl_FILE_LIST], [ + lib/regexec.c + lib/size_max.h + lib/sleep.c ++ lib/stat.c + lib/stdalign.in.h + lib/stdbool.in.h + lib/stddef.in.h +@@ -627,8 +665,11 @@ AC_DEFUN([gl_FILE_LIST], [ + lib/strnlen.c + lib/strnlen1.c + lib/strnlen1.h ++ lib/sys_stat.in.h ++ lib/sys_time.in.h + lib/sys_types.in.h + lib/sysexits.in.h ++ lib/time.in.h + lib/unistd.c + lib/unistd.in.h + lib/unitypes.in.h +@@ -667,6 +708,7 @@ AC_DEFUN([gl_FILE_LIST], [ + m4/getline.m4 + m4/getopt.m4 + m4/gettext.m4 ++ m4/gettimeofday.m4 + m4/glibc2.m4 + m4/glibc21.m4 + m4/gnulib-common.m4 +@@ -681,6 +723,7 @@ AC_DEFUN([gl_FILE_LIST], [ + m4/inttypes-pri.m4 + m4/inttypes_h.m4 + m4/langinfo_h.m4 ++ m4/largefile.m4 + m4/lcmessage.m4 + m4/lib-ld.m4 + m4/lib-link.m4 +@@ -712,16 +755,19 @@ AC_DEFUN([gl_FILE_LIST], [ + m4/nls.m4 + m4/nocrash.m4 + m4/off_t.m4 ++ m4/pathmax.m4 + m4/po.m4 + m4/printf-posix.m4 + m4/printf.m4 + m4/progtest.m4 + m4/rawmemchr.m4 ++ m4/readlink.m4 + m4/realloc.m4 + m4/regex.m4 + m4/size_max.m4 + m4/sleep.m4 + m4/ssize_t.m4 ++ m4/stat.m4 + m4/stdalign.m4 + m4/stdbool.m4 + m4/stddef_h.m4 +@@ -737,9 +783,12 @@ AC_DEFUN([gl_FILE_LIST], [ + m4/strndup.m4 + m4/strnlen.m4 + m4/sys_socket_h.m4 ++ m4/sys_stat_h.m4 ++ m4/sys_time_h.m4 + m4/sys_types_h.m4 + m4/sysexits.m4 + m4/threadlib.m4 ++ m4/time_h.m4 + m4/uintmax_t.m4 + m4/unistd_h.m4 + m4/vasnprintf.m4 +diff --git a/m4/largefile.m4 b/m4/largefile.m4 +new file mode 100644 +index 000000000..a1b564ad9 +--- /dev/null ++++ b/m4/largefile.m4 +@@ -0,0 +1,146 @@ ++# Enable large files on systems where this is not the default. ++ ++# Copyright 1992-1996, 1998-2014 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. ++ ++# The following implementation works around a problem in autoconf <= 2.69; ++# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, ++# or configures them incorrectly in some cases. ++m4_version_prereq([2.70], [] ,[ ++ ++# _AC_SYS_LARGEFILE_TEST_INCLUDES ++# ------------------------------- ++m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], ++[@%:@include ++ /* Check that off_t can represent 2**63 - 1 correctly. ++ We can't simply define LARGE_OFF_T to be 9223372036854775807, ++ since some C++ compilers masquerading as C compilers ++ incorrectly reject 9223372036854775807. */ ++@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) ++ int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 ++ && LARGE_OFF_T % 2147483647 == 1) ++ ? 1 : -1]];[]dnl ++]) ++ ++ ++# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, ++# CACHE-VAR, ++# DESCRIPTION, ++# PROLOGUE, [FUNCTION-BODY]) ++# -------------------------------------------------------- ++m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE], ++[AC_CACHE_CHECK([for $1 value needed for large files], [$3], ++[while :; do ++ m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( ++ [AC_LANG_PROGRAM([$5], [$6])], ++ [$3=no; break]) ++ m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( ++ [AC_LANG_PROGRAM([@%:@define $1 $2 ++$5], [$6])], ++ [$3=$2; break]) ++ $3=unknown ++ break ++done]) ++case $$3 in #( ++ no | unknown) ;; ++ *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);; ++esac ++rm -rf conftest*[]dnl ++])# _AC_SYS_LARGEFILE_MACRO_VALUE ++ ++ ++# AC_SYS_LARGEFILE ++# ---------------- ++# By default, many hosts won't let programs access large files; ++# one must use special compiler options to get large-file access to work. ++# For more details about this brain damage please see: ++# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html ++AC_DEFUN([AC_SYS_LARGEFILE], ++[AC_ARG_ENABLE(largefile, ++ [ --disable-largefile omit support for large files]) ++if test "$enable_largefile" != no; then ++ ++ AC_CACHE_CHECK([for special C compiler options needed for large files], ++ ac_cv_sys_largefile_CC, ++ [ac_cv_sys_largefile_CC=no ++ if test "$GCC" != yes; then ++ ac_save_CC=$CC ++ while :; do ++ # IRIX 6.2 and later do not support large files by default, ++ # so use the C compiler's -n32 option if that helps. ++ AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])]) ++ AC_COMPILE_IFELSE([], [break]) ++ CC="$CC -n32" ++ AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break]) ++ break ++ done ++ CC=$ac_save_CC ++ rm -f conftest.$ac_ext ++ fi]) ++ if test "$ac_cv_sys_largefile_CC" != no; then ++ CC=$CC$ac_cv_sys_largefile_CC ++ fi ++ ++ _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ++ ac_cv_sys_file_offset_bits, ++ [Number of bits in a file offset, on hosts where this is settable.], ++ [_AC_SYS_LARGEFILE_TEST_INCLUDES]) ++ if test $ac_cv_sys_file_offset_bits = unknown; then ++ _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ++ ac_cv_sys_large_files, ++ [Define for large files, on AIX-style hosts.], ++ [_AC_SYS_LARGEFILE_TEST_INCLUDES]) ++ fi ++ ++ AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1], ++ [Enable large inode numbers on Mac OS X 10.5.]) ++fi ++])# AC_SYS_LARGEFILE ++])# m4_version_prereq 2.70 ++ ++# Enable large files on systems where this is implemented by Gnulib, not by the ++# system headers. ++# Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib ++# overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively. ++AC_DEFUN([gl_LARGEFILE], ++[ ++ AC_REQUIRE([AC_CANONICAL_HOST]) ++ case "$host_os" in ++ mingw*) ++ dnl Native Windows. ++ dnl mingw64 defines off_t to a 64-bit type already, if ++ dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE. ++ AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1]; ++ ]], ++ [[]])], ++ [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no]) ++ ]) ++ if test $gl_cv_type_off_t_64 = no; then ++ WINDOWS_64_BIT_OFF_T=1 ++ else ++ WINDOWS_64_BIT_OFF_T=0 ++ fi ++ dnl But all native Windows platforms (including mingw64) have a 32-bit ++ dnl st_size member in 'struct stat'. ++ WINDOWS_64_BIT_ST_SIZE=1 ++ ;; ++ *) ++ dnl Nothing to do on gnulib's side. ++ dnl A 64-bit off_t is ++ dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX, ++ dnl OSF/1, Cygwin, ++ dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on ++ dnl glibc, HP-UX, Solaris, ++ dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX, ++ dnl - impossible to achieve on Minix 3.1.8. ++ WINDOWS_64_BIT_OFF_T=0 ++ WINDOWS_64_BIT_ST_SIZE=0 ++ ;; ++ esac ++]) +diff --git a/m4/pathmax.m4 b/m4/pathmax.m4 +new file mode 100644 +index 000000000..114f91f04 +--- /dev/null ++++ b/m4/pathmax.m4 +@@ -0,0 +1,42 @@ ++# pathmax.m4 serial 10 ++dnl Copyright (C) 2002-2003, 2005-2006, 2009-2014 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. ++ ++AC_DEFUN([gl_PATHMAX], ++[ ++ dnl Prerequisites of lib/pathmax.h. ++ AC_CHECK_HEADERS_ONCE([sys/param.h]) ++]) ++ ++# Expands to a piece of C program that defines PATH_MAX in the same way as ++# "pathmax.h" will do. ++AC_DEFUN([gl_PATHMAX_SNIPPET], [[ ++/* Arrange to define PATH_MAX, like "pathmax.h" does. */ ++#if HAVE_UNISTD_H ++# include ++#endif ++#include ++#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN ++# include ++#endif ++#if !defined PATH_MAX && defined MAXPATHLEN ++# define PATH_MAX MAXPATHLEN ++#endif ++#ifdef __hpux ++# undef PATH_MAX ++# define PATH_MAX 1024 ++#endif ++#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ ++# undef PATH_MAX ++# define PATH_MAX 260 ++#endif ++]]) ++ ++# Prerequisites of gl_PATHMAX_SNIPPET. ++AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ], ++[ ++ AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h]) ++]) +diff --git a/m4/readlink.m4 b/m4/readlink.m4 +new file mode 100644 +index 000000000..f9ce868c2 +--- /dev/null ++++ b/m4/readlink.m4 +@@ -0,0 +1,71 @@ ++# readlink.m4 serial 12 ++dnl Copyright (C) 2003, 2007, 2009-2014 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. ++ ++AC_DEFUN([gl_FUNC_READLINK], ++[ ++ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) ++ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles ++ AC_CHECK_FUNCS_ONCE([readlink]) ++ if test $ac_cv_func_readlink = no; then ++ HAVE_READLINK=0 ++ else ++ AC_CACHE_CHECK([whether readlink signature is correct], ++ [gl_cv_decl_readlink_works], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ /* Cause compilation failure if original declaration has wrong type. */ ++ ssize_t readlink (const char *, char *, size_t);]])], ++ [gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])]) ++ dnl Solaris 9 ignores trailing slash. ++ dnl FreeBSD 7.2 dereferences only one level of links with trailing slash. ++ AC_CACHE_CHECK([whether readlink handles trailing slash correctly], ++ [gl_cv_func_readlink_works], ++ [# We have readlink, so assume ln -s works. ++ ln -s conftest.no-such conftest.link ++ ln -s conftest.link conftest.lnk2 ++ AC_RUN_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++]], [[char buf[20]; ++ return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])], ++ [gl_cv_func_readlink_works=yes], [gl_cv_func_readlink_works=no], ++ [case "$host_os" in ++ # Guess yes on glibc systems. ++ *-gnu*) gl_cv_func_readlink_works="guessing yes" ;; ++ # If we don't know, assume the worst. ++ *) gl_cv_func_readlink_works="guessing no" ;; ++ esac ++ ]) ++ rm -f conftest.link conftest.lnk2]) ++ case "$gl_cv_func_readlink_works" in ++ *yes) ++ if test "$gl_cv_decl_readlink_works" != yes; then ++ REPLACE_READLINK=1 ++ fi ++ ;; ++ *) ++ AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink ++ fails to recognize a trailing slash.]) ++ REPLACE_READLINK=1 ++ ;; ++ esac ++ fi ++]) ++ ++# Like gl_FUNC_READLINK, except prepare for separate compilation ++# (no REPLACE_READLINK, no AC_LIBOBJ). ++AC_DEFUN([gl_FUNC_READLINK_SEPARATE], ++[ ++ AC_CHECK_FUNCS_ONCE([readlink]) ++ gl_PREREQ_READLINK ++]) ++ ++# Prerequisites of lib/readlink.c. ++AC_DEFUN([gl_PREREQ_READLINK], ++[ ++ : ++]) +diff --git a/m4/stat.m4 b/m4/stat.m4 +new file mode 100644 +index 000000000..1ae327b36 +--- /dev/null ++++ b/m4/stat.m4 +@@ -0,0 +1,71 @@ ++# serial 11 ++ ++# Copyright (C) 2009-2014 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. ++ ++AC_DEFUN([gl_FUNC_STAT], ++[ ++ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles ++ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) ++ AC_CHECK_FUNCS_ONCE([lstat]) ++ dnl mingw is the only known platform where stat(".") and stat("./") differ ++ AC_CACHE_CHECK([whether stat handles trailing slashes on directories], ++ [gl_cv_func_stat_dir_slash], ++ [AC_RUN_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])], ++ [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no], ++ [case $host_os in ++ mingw*) gl_cv_func_stat_dir_slash="guessing no";; ++ *) gl_cv_func_stat_dir_slash="guessing yes";; ++ esac])]) ++ dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/"). ++ dnl (For mingw, this is due to a broken stat() override in libmingwex.a.) ++ dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/"). ++ AC_CACHE_CHECK([whether stat handles trailing slashes on files], ++ [gl_cv_func_stat_file_slash], ++ [touch conftest.tmp ++ # Assume that if we have lstat, we can also check symlinks. ++ if test $ac_cv_func_lstat = yes; then ++ ln -s conftest.tmp conftest.lnk ++ fi ++ AC_RUN_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++]], [[int result = 0; ++ struct stat st; ++ if (!stat ("conftest.tmp/", &st)) ++ result |= 1; ++#if HAVE_LSTAT ++ if (!stat ("conftest.lnk/", &st)) ++ result |= 2; ++#endif ++ return result; ++ ]])], ++ [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no], ++ [case "$host_os" in ++ # Guess yes on glibc systems. ++ *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; ++ # If we don't know, assume the worst. ++ *) gl_cv_func_stat_file_slash="guessing no" ;; ++ esac ++ ]) ++ rm -f conftest.tmp conftest.lnk]) ++ case $gl_cv_func_stat_dir_slash in ++ *no) REPLACE_STAT=1 ++ AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs ++ help when passed a directory name with a trailing slash]);; ++ esac ++ case $gl_cv_func_stat_file_slash in ++ *no) REPLACE_STAT=1 ++ AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs ++ help when passed a file name with a trailing slash]);; ++ esac ++]) ++ ++# Prerequisites of lib/stat.c. ++AC_DEFUN([gl_PREREQ_STAT], [:]) +diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 +new file mode 100644 +index 000000000..eaa7642ba +--- /dev/null ++++ b/m4/sys_stat_h.m4 +@@ -0,0 +1,96 @@ ++# sys_stat_h.m4 serial 28 -*- Autoconf -*- ++dnl Copyright (C) 2006-2014 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 Eric Blake. ++dnl Provide a GNU-like . ++ ++AC_DEFUN([gl_HEADER_SYS_STAT_H], ++[ ++ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) ++ ++ dnl Check for broken stat macros. ++ AC_REQUIRE([AC_HEADER_STAT]) ++ ++ gl_CHECK_NEXT_HEADERS([sys/stat.h]) ++ ++ dnl Ensure the type mode_t gets defined. ++ AC_REQUIRE([AC_TYPE_MODE_T]) ++ ++ dnl Whether to override 'struct stat'. ++ m4_ifdef([gl_LARGEFILE], [ ++ AC_REQUIRE([gl_LARGEFILE]) ++ ], [ ++ WINDOWS_64_BIT_ST_SIZE=0 ++ ]) ++ AC_SUBST([WINDOWS_64_BIT_ST_SIZE]) ++ if test $WINDOWS_64_BIT_ST_SIZE = 1; then ++ AC_DEFINE([_GL_WINDOWS_64_BIT_ST_SIZE], [1], ++ [Define to 1 if Gnulib overrides 'struct stat' on Windows so that ++ struct stat.st_size becomes 64-bit.]) ++ fi ++ ++ dnl Define types that are supposed to be defined in or ++ dnl . ++ AC_CHECK_TYPE([nlink_t], [], ++ [AC_DEFINE([nlink_t], [int], ++ [Define to the type of st_nlink in struct stat, or a supertype.])], ++ [#include ++ #include ]) ++ ++ dnl Check for declarations of anything we want to poison if the ++ dnl corresponding gnulib module is not in use. ++ gl_WARN_ON_USE_PREPARE([[#include ++ ]], [fchmodat fstat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat ++ mknod mknodat stat utimensat]) ++]) # gl_HEADER_SYS_STAT_H ++ ++AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], ++[ ++ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. ++ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) ++ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ++ dnl Define it also as a C macro, for the benefit of the unit tests. ++ gl_MODULE_INDICATOR_FOR_TESTS([$1]) ++]) ++ ++AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], ++[ ++ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR ++ GNULIB_FCHMODAT=0; AC_SUBST([GNULIB_FCHMODAT]) ++ GNULIB_FSTAT=0; AC_SUBST([GNULIB_FSTAT]) ++ GNULIB_FSTATAT=0; AC_SUBST([GNULIB_FSTATAT]) ++ GNULIB_FUTIMENS=0; AC_SUBST([GNULIB_FUTIMENS]) ++ GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD]) ++ GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT]) ++ GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT]) ++ GNULIB_MKFIFO=0; AC_SUBST([GNULIB_MKFIFO]) ++ GNULIB_MKFIFOAT=0; AC_SUBST([GNULIB_MKFIFOAT]) ++ GNULIB_MKNOD=0; AC_SUBST([GNULIB_MKNOD]) ++ GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT]) ++ GNULIB_STAT=0; AC_SUBST([GNULIB_STAT]) ++ GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT]) ++ dnl Assume proper GNU behavior unless another module says otherwise. ++ HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) ++ HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) ++ HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS]) ++ HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD]) ++ HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT]) ++ HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT]) ++ HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO]) ++ HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT]) ++ HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD]) ++ HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT]) ++ HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT]) ++ REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT]) ++ REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT]) ++ REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS]) ++ REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT]) ++ REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR]) ++ REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO]) ++ REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD]) ++ REPLACE_STAT=0; AC_SUBST([REPLACE_STAT]) ++ REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT]) ++]) +diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 +new file mode 100644 +index 000000000..5c79300f8 +--- /dev/null ++++ b/m4/sys_time_h.m4 +@@ -0,0 +1,110 @@ ++# Configure a replacement for . ++# serial 8 ++ ++# Copyright (C) 2007, 2009-2014 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. ++ ++# Written by Paul Eggert and Martin Lambers. ++ ++AC_DEFUN([gl_HEADER_SYS_TIME_H], ++[ ++ dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement ++ dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1 ++ dnl statements that occur in other macros. ++ AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY]) ++]) ++ ++AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], ++[ ++ AC_REQUIRE([AC_C_RESTRICT]) ++ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) ++ AC_CHECK_HEADERS_ONCE([sys/time.h]) ++ gl_CHECK_NEXT_HEADERS([sys/time.h]) ++ ++ if test $ac_cv_header_sys_time_h != yes; then ++ HAVE_SYS_TIME_H=0 ++ fi ++ ++ dnl On native Windows with MSVC, 'struct timeval' is defined in ++ dnl only. So include that header in the list. ++ gl_PREREQ_SYS_H_WINSOCK2 ++ AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#if HAVE_SYS_TIME_H ++ #include ++ #endif ++ #include ++ #if HAVE_WINSOCK2_H ++ # include ++ #endif ++ ]], ++ [[static struct timeval x; x.tv_sec = x.tv_usec;]])], ++ [gl_cv_sys_struct_timeval=yes], ++ [gl_cv_sys_struct_timeval=no]) ++ ]) ++ if test $gl_cv_sys_struct_timeval != yes; then ++ HAVE_STRUCT_TIMEVAL=0 ++ else ++ dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined ++ dnl (in and for mingw64, in only ++ dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is ++ dnl smaller than the 'time_t' type mandated by POSIX. ++ dnl On OpenBSD 5.1 amd64, tv_sec is 64 bits and time_t 32 bits, but ++ dnl that is good enough. ++ AC_CACHE_CHECK([for wide-enough struct timeval.tv_sec member], ++ [gl_cv_sys_struct_timeval_tv_sec], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#if HAVE_SYS_TIME_H ++ #include ++ #endif ++ #include ++ #if HAVE_WINSOCK2_H ++ # include ++ #endif ++ ]], ++ [[static struct timeval x; ++ typedef int verify_tv_sec_type[ ++ sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1 ++ ]; ++ ]])], ++ [gl_cv_sys_struct_timeval_tv_sec=yes], ++ [gl_cv_sys_struct_timeval_tv_sec=no]) ++ ]) ++ if test $gl_cv_sys_struct_timeval_tv_sec != yes; then ++ REPLACE_STRUCT_TIMEVAL=1 ++ fi ++ fi ++ ++ dnl Check for declarations of anything we want to poison if the ++ dnl corresponding gnulib module is not in use. ++ gl_WARN_ON_USE_PREPARE([[ ++#if HAVE_SYS_TIME_H ++# include ++#endif ++#include ++ ]], [gettimeofday]) ++]) ++ ++AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR], ++[ ++ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. ++ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) ++ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ++ dnl Define it also as a C macro, for the benefit of the unit tests. ++ gl_MODULE_INDICATOR_FOR_TESTS([$1]) ++]) ++ ++AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS], ++[ ++ GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY]) ++ dnl Assume POSIX behavior unless another module says otherwise. ++ HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) ++ HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) ++ HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) ++ REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) ++ REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL]) ++]) +diff --git a/m4/time_h.m4 b/m4/time_h.m4 +new file mode 100644 +index 000000000..9852778f9 +--- /dev/null ++++ b/m4/time_h.m4 +@@ -0,0 +1,118 @@ ++# Configure a more-standard replacement for . ++ ++# Copyright (C) 2000-2001, 2003-2007, 2009-2014 Free Software Foundation, Inc. ++ ++# serial 8 ++ ++# 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. ++ ++# Written by Paul Eggert and Jim Meyering. ++ ++AC_DEFUN([gl_HEADER_TIME_H], ++[ ++ dnl Use AC_REQUIRE here, so that the default behavior below is expanded ++ dnl once only, before all statements that occur in other macros. ++ AC_REQUIRE([gl_HEADER_TIME_H_BODY]) ++]) ++ ++AC_DEFUN([gl_HEADER_TIME_H_BODY], ++[ ++ AC_REQUIRE([AC_C_RESTRICT]) ++ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) ++ gl_NEXT_HEADERS([time.h]) ++ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) ++]) ++ ++dnl Check whether 'struct timespec' is declared ++dnl in time.h, sys/time.h, or pthread.h. ++ ++AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], ++[ ++ AC_CHECK_HEADERS_ONCE([sys/time.h]) ++ AC_CACHE_CHECK([for struct timespec in ], ++ [gl_cv_sys_struct_timespec_in_time_h], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ ]], ++ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], ++ [gl_cv_sys_struct_timespec_in_time_h=yes], ++ [gl_cv_sys_struct_timespec_in_time_h=no])]) ++ ++ TIME_H_DEFINES_STRUCT_TIMESPEC=0 ++ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 ++ PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 ++ if test $gl_cv_sys_struct_timespec_in_time_h = yes; then ++ TIME_H_DEFINES_STRUCT_TIMESPEC=1 ++ else ++ AC_CACHE_CHECK([for struct timespec in ], ++ [gl_cv_sys_struct_timespec_in_sys_time_h], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ ]], ++ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], ++ [gl_cv_sys_struct_timespec_in_sys_time_h=yes], ++ [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) ++ if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then ++ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 ++ else ++ AC_CACHE_CHECK([for struct timespec in ], ++ [gl_cv_sys_struct_timespec_in_pthread_h], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ ]], ++ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], ++ [gl_cv_sys_struct_timespec_in_pthread_h=yes], ++ [gl_cv_sys_struct_timespec_in_pthread_h=no])]) ++ if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then ++ PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 ++ fi ++ fi ++ fi ++ AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) ++ AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) ++ AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) ++]) ++ ++AC_DEFUN([gl_TIME_MODULE_INDICATOR], ++[ ++ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. ++ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) ++ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ++ dnl Define it also as a C macro, for the benefit of the unit tests. ++ gl_MODULE_INDICATOR_FOR_TESTS([$1]) ++]) ++ ++AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], ++[ ++ GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME]) ++ GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP]) ++ GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME]) ++ GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) ++ GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) ++ dnl Assume proper GNU behavior unless another module says otherwise. ++ HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) ++ HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) ++ HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) ++ HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) ++ dnl If another module says to replace or to not replace, do that. ++ dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; ++ dnl this lets maintainers check for portability. ++ REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) ++ REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) ++ REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) ++ REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) ++ ++ dnl Hack so that the time module doesn't depend on the sys_time module. ++ dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent. ++ : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY]) ++ dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME ++ dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier ++ dnl is no longer a big deal. ++ REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) ++ REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) ++]) +-- +2.14.3 + diff --git a/0072-Fix-security-issue-when-reading-username-and-passwor.patch b/0072-Fix-security-issue-when-reading-username-and-passwor.patch deleted file mode 100644 index 7f2b486..0000000 --- a/0072-Fix-security-issue-when-reading-username-and-passwor.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 5a0d703884a73f93a68753c6ed64bdf08797c82a Mon Sep 17 00:00:00 2001 -From: Hector Marco-Gisbert -Date: Fri, 13 Nov 2015 16:21:09 +0100 -Subject: [PATCH 72/90] Fix security issue when reading username and password - - This patch fixes two integer underflows at: - * grub-core/lib/crypto.c - * grub-core/normal/auth.c - -Resolves: CVE-2015-8370 - -Signed-off-by: Hector Marco-Gisbert -Signed-off-by: Ismael Ripoll-Ripoll ---- - grub-core/lib/crypto.c | 2 +- - grub-core/normal/auth.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c -index 683a8aa..c5ab9eb 100644 ---- a/grub-core/lib/crypto.c -+++ b/grub-core/lib/crypto.c -@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size) - break; - } - -- if (key == '\b') -+ if (key == '\b' && cur_len) - { - if (cur_len) - cur_len--; -diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c -index 7338f82..6d6dc7d 100644 ---- a/grub-core/normal/auth.c -+++ b/grub-core/normal/auth.c -@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size) - break; - } - -- if (key == '\b') -+ if (key == '\b' && cur_len) - { - if (cur_len) - { --- -2.9.3 - diff --git a/0073-Make-editenv-chase-symlinks-including-those-across-d.patch b/0073-Make-editenv-chase-symlinks-including-those-across-d.patch new file mode 100644 index 0000000..0f0b6c5 --- /dev/null +++ b/0073-Make-editenv-chase-symlinks-including-those-across-d.patch @@ -0,0 +1,106 @@ +From a867dc42c711385634d86f04176cf3193d548f1d Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 3 Sep 2014 10:38:00 -0400 +Subject: [PATCH 073/123] Make editenv chase symlinks including those across + devices. + +This lets us make /boot/grub2/grubenv a symlink to +/boot/efi/EFI/fedora/grubenv even though they're different mount points, +which allows /usr/bin/grub2-editenv to be the same across platforms +(i.e. UEFI vs BIOS). + +Signed-off-by: Peter Jones +Reviewed-by: Adam Jackson +--- + Makefile.util.def | 9 +++++++++ + util/editenv.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 53 insertions(+), 2 deletions(-) + +diff --git a/Makefile.util.def b/Makefile.util.def +index 6d452da02..206110458 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -230,8 +230,17 @@ program = { + + common = util/grub-editenv.c; + common = util/editenv.c; ++ common = util/grub-install-common.c; + common = grub-core/osdep/init.c; ++ common = grub-core/osdep/compress.c; ++ extra_dist = grub-core/osdep/unix/compress.c; ++ extra_dist = grub-core/osdep/basic/compress.c; ++ common = util/mkimage.c; ++ common = grub-core/osdep/config.c; ++ common = util/config.c; ++ common = util/resolve.c; + ++ ldadd = '$(LIBLZMA)'; + ldadd = libgrubmods.a; + ldadd = libgrubgcry.a; + ldadd = libgrubkern.a; +diff --git a/util/editenv.c b/util/editenv.c +index c6f8d2298..d8d1dad6a 100644 +--- a/util/editenv.c ++++ b/util/editenv.c +@@ -37,6 +37,7 @@ grub_util_create_envblk_file (const char *name) + FILE *fp; + char *buf; + char *namenew; ++ char *rename_target = xstrdup(name); + + buf = xmalloc (DEFAULT_ENVBLK_SIZE); + +@@ -59,7 +60,48 @@ grub_util_create_envblk_file (const char *name) + free (buf); + fclose (fp); + +- if (grub_util_rename (namenew, name) < 0) +- grub_util_error (_("cannot rename the file %s to %s"), namenew, name); ++ ssize_t size = 1; ++ while (1) ++ { ++ char *linkbuf; ++ ssize_t retsize; ++ ++ linkbuf = xmalloc(size+1); ++ retsize = grub_util_readlink (rename_target, linkbuf, size); ++ if (retsize < 0 && (errno == ENOENT || errno == EINVAL)) ++ { ++ free (linkbuf); ++ break; ++ } ++ else if (retsize < 0) ++ { ++ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); ++ free (linkbuf); ++ free (namenew); ++ return; ++ } ++ else if (retsize == size) ++ { ++ free(linkbuf); ++ size += 128; ++ continue; ++ } ++ ++ free (rename_target); ++ linkbuf[retsize] = '\0'; ++ rename_target = linkbuf; ++ } ++ ++ int rc = grub_util_rename (namenew, rename_target); ++ if (rc < 0 && errno == EXDEV) ++ { ++ rc = grub_install_copy_file (namenew, rename_target, 1); ++ grub_util_unlink (namenew); ++ } ++ ++ if (rc < 0) ++ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); ++ + free (namenew); ++ free (rename_target); + } +-- +2.14.3 + diff --git a/0073-Make-grub_fatal-also-backtrace.patch b/0073-Make-grub_fatal-also-backtrace.patch deleted file mode 100644 index bac1ecb..0000000 --- a/0073-Make-grub_fatal-also-backtrace.patch +++ /dev/null @@ -1,175 +0,0 @@ -From c37a4f02e5fd0c3aa5f54baaeaf32eed0e3c110b Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 27 Jan 2016 09:22:42 -0500 -Subject: [PATCH 73/90] Make grub_fatal() also backtrace. - ---- - grub-core/Makefile.core.def | 3 ++ - grub-core/kern/misc.c | 8 +++++- - grub-core/lib/arm64/backtrace.c | 62 +++++++++++++++++++++++++++++++++++++++++ - grub-core/lib/backtrace.c | 2 ++ - grub-core/lib/i386/backtrace.c | 14 +++++++++- - 5 files changed, 87 insertions(+), 2 deletions(-) - create mode 100644 grub-core/lib/arm64/backtrace.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index ac195d1..990e41b 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -157,6 +157,9 @@ kernel = { - - softdiv = lib/division.c; - -+ x86 = lib/i386/backtrace.c; -+ x86 = lib/backtrace.c; -+ - i386 = kern/i386/dl.c; - i386_xen = kern/i386/dl.c; - -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 81be344..d7dcd97 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - - union printf_arg - { -@@ -1087,8 +1088,13 @@ grub_xasprintf (const char *fmt, ...) - static void __attribute__ ((noreturn)) - grub_abort (void) - { -+#ifndef GRUB_UTIL -+#if defined(__i386__) || defined(__x86_64__) -+ grub_backtrace(); -+#endif -+#endif - grub_printf ("\nAborted."); -- -+ - #ifndef GRUB_UTIL - if (grub_term_inputs) - #endif -diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c -new file mode 100644 -index 0000000..1079b53 ---- /dev/null -+++ b/grub-core/lib/arm64/backtrace.c -@@ -0,0 +1,62 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2009 Free Software Foundation, Inc. -+ * -+ * GRUB 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. -+ * -+ * GRUB 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 GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define MAX_STACK_FRAME 102400 -+ -+void -+grub_backtrace_pointer (int frame) -+{ -+ while (1) -+ { -+ void *lp = __builtin_return_address (frame); -+ if (!lp) -+ break; -+ -+ lp = __builtin_extract_return_addr (lp); -+ -+ grub_printf ("%p: ", lp); -+ grub_backtrace_print_address (lp); -+ grub_printf (" ("); -+ for (i = 0; i < 2; i++) -+ grub_printf ("%p,", ((void **)ptr) [i + 2]); -+ grub_printf ("%p)\n", ((void **)ptr) [i + 2]); -+ nptr = *(void **)ptr; -+ if (nptr < ptr || (void **) nptr - (void **) ptr > MAX_STACK_FRAME -+ || nptr == ptr) -+ { -+ grub_printf ("Invalid stack frame at %p (%p)\n", ptr, nptr); -+ break; -+ } -+ ptr = nptr; -+ } -+} -+ -+void -+grub_backtrace (void) -+{ -+ grub_backtrace_pointer (1); -+} -+ -diff --git a/grub-core/lib/backtrace.c b/grub-core/lib/backtrace.c -index 825a880..c0ad6ab 100644 ---- a/grub-core/lib/backtrace.c -+++ b/grub-core/lib/backtrace.c -@@ -29,6 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - void - grub_backtrace_print_address (void *addr) - { -+#ifndef GRUB_UTIL - grub_dl_t mod; - - FOR_DL_MODULES (mod) -@@ -44,6 +45,7 @@ grub_backtrace_print_address (void *addr) - } - } - -+#endif - grub_printf ("%p", addr); - } - -diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c -index c3e03c7..c67273d 100644 ---- a/grub-core/lib/i386/backtrace.c -+++ b/grub-core/lib/i386/backtrace.c -@@ -15,11 +15,23 @@ - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ -+#include -+#ifdef GRUB_UTIL -+#define REALLY_GRUB_UTIL GRUB_UTIL -+#undef GRUB_UTIL -+#endif -+ -+#include -+#include -+ -+#ifdef REALLY_GRUB_UTIL -+#define GRUB_UTIL REALLY_GRUB_UTIL -+#undef REALLY_GRUB_UTIL -+#endif - - #include - #include - #include --#include - #include - #include - #include --- -2.9.3 - diff --git a/0074-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch b/0074-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch new file mode 100644 index 0000000..58d9354 --- /dev/null +++ b/0074-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch @@ -0,0 +1,33 @@ +From 14b8db374bfc41fffa278ec33084324008384417 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 4 Sep 2014 14:23:23 -0400 +Subject: [PATCH 074/123] Generate OS and CLASS in 10_linux from + /etc/os-release + +This makes us use pretty names in the titles we generate in +grub2-mkconfig when GRUB_DISTRIBUTOR isn't set. + +Resolves: rhbz#996794 + +Signed-off-by: Peter Jones +--- + util/grub.d/10_linux.in | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index a9692a0c2..c6627268c 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -29,7 +29,8 @@ export TEXTDOMAINDIR="@localedir@" + CLASS="--class gnu-linux --class gnu --class os --unrestricted" + + if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then +- OS="$(sed 's, release .*$,,g' /etc/system-release)" ++ OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})" ++ CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}" + else + OS="${GRUB_DISTRIBUTOR}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" +-- +2.14.3 + diff --git a/0074-Rework-linux-command.patch b/0074-Rework-linux-command.patch deleted file mode 100644 index 25b3e62..0000000 --- a/0074-Rework-linux-command.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 33d11870bbc2fa554fa9344c3c180279c258736a Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:12:39 -0700 -Subject: [PATCH 74/90] Rework linux command - -We want a single buffer that contains the entire kernel image in order to -perform a TPM measurement. Allocate one and copy the entire kernel into it -before pulling out the individual blocks later on. ---- - grub-core/loader/i386/linux.c | 34 +++++++++++++++++++++------------- - 1 file changed, 21 insertions(+), 13 deletions(-) - -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index b0afcca..5eb7d17 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -681,12 +681,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_file_t file = 0; - struct linux_kernel_header lh; - grub_uint8_t setup_sects; -- grub_size_t real_size, prot_size, prot_file_size; -+ grub_size_t real_size, prot_size, prot_file_size, kernel_offset; - grub_ssize_t len; - int i; - grub_size_t align, min_align; - int relocatable; - grub_uint64_t preferred_address = GRUB_LINUX_BZIMAGE_ADDR; -+ grub_uint8_t *kernel = NULL; - - grub_dl_ref (my_mod); - -@@ -700,7 +701,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - if (! file) - goto fail; - -- if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) -+ len = grub_file_size (file); -+ kernel = grub_malloc (len); -+ if (!kernel) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer")); -+ goto fail; -+ } -+ -+ if (grub_file_read (file, kernel, len) != len) - { - if (!grub_errno) - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -708,6 +717,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_memcpy (&lh, kernel, sizeof (lh)); -+ kernel_offset = sizeof (lh); -+ - if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) - { - grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); -@@ -807,13 +819,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - linux_params.ps_mouse = linux_params.padding10 = 0; - - len = sizeof (linux_params) - sizeof (lh); -- if (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len) -- { -- if (!grub_errno) -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -- argv[0]); -- goto fail; -- } -+ -+ grub_memcpy (&linux_params + sizeof (lh), kernel + kernel_offset, len); -+ kernel_offset += len; - - linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; - -@@ -872,7 +880,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - /* The other parameters are filled when booting. */ - -- grub_file_seek (file, real_size + GRUB_DISK_SECTOR_SIZE); -+ kernel_offset = real_size + GRUB_DISK_SECTOR_SIZE; - - grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n", - (unsigned) real_size, (unsigned) prot_size); -@@ -1017,9 +1025,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - (sizeof (LINUX_IMAGE) - 1)); - - len = prot_file_size; -- if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno) -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -- argv[0]); -+ grub_memcpy (prot_mode_mem, kernel + kernel_offset, len); - - if (grub_errno == GRUB_ERR_NONE) - { -@@ -1030,6 +1036,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - fail: - -+ grub_free (kernel); -+ - if (file) - grub_file_close (file); - --- -2.9.3 - diff --git a/0075-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch b/0075-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch new file mode 100644 index 0000000..0a46ce5 --- /dev/null +++ b/0075-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch @@ -0,0 +1,34 @@ +From 700c631b4c887778951503346afe5b7ee70bf7dd Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 4 Sep 2014 15:52:08 -0400 +Subject: [PATCH 075/123] Minimize the sort ordering for .debug and -rescue- + kernels. + +Resolves: rhbz#1065360 +Signed-off-by: Peter Jones +--- + util/grub-mkconfig_lib.in | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in +index cf35e4174..10fabee5e 100644 +--- a/util/grub-mkconfig_lib.in ++++ b/util/grub-mkconfig_lib.in +@@ -248,6 +248,14 @@ version_test_gt () + *.old:*.old) ;; + *.old:*) version_test_gt_a="`echo "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;; + *:*.old) version_test_gt_b="`echo "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;; ++ *-rescue*:*-rescue*) ;; ++ *?debug:*?debug) ;; ++ *-rescue*:*?debug) return 1 ;; ++ *?debug:*-rescue*) return 0 ;; ++ *-rescue*:*) return 1 ;; ++ *:*-rescue*) return 0 ;; ++ *?debug:*) return 1 ;; ++ *:*?debug) return 0 ;; + esac + version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b" + return "$?" +-- +2.14.3 + diff --git a/0075-Rework-linux16-command.patch b/0075-Rework-linux16-command.patch deleted file mode 100644 index a153932..0000000 --- a/0075-Rework-linux16-command.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 0b86b309de12b4f3ea920124faa60841ffedf472 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:20:58 -0700 -Subject: [PATCH 75/90] Rework linux16 command - -We want a single buffer that contains the entire kernel image in order to -perform a TPM measurement. Allocate one and copy the entire kernel int it -before pulling out the individual blocks later on. ---- - grub-core/loader/i386/pc/linux.c | 34 +++++++++++++++++++++------------- - 1 file changed, 21 insertions(+), 13 deletions(-) - -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 9128315..b864e54 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -124,13 +124,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_file_t file = 0; - struct linux_kernel_header lh; - grub_uint8_t setup_sects; -- grub_size_t real_size; -+ grub_size_t real_size, kernel_offset = 0; - grub_ssize_t len; - int i; - char *grub_linux_prot_chunk; - int grub_linux_is_bzimage; - grub_addr_t grub_linux_prot_target; - grub_err_t err; -+ grub_uint8_t *kernel = NULL; - - grub_dl_ref (my_mod); - -@@ -144,7 +145,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - if (! file) - goto fail; - -- if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) -+ len = grub_file_size (file); -+ kernel = grub_malloc (len); -+ if (!kernel) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer")); -+ goto fail; -+ } -+ -+ if (grub_file_read (file, kernel, len) != len) - { - if (!grub_errno) - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -152,6 +161,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_memcpy (&lh, kernel, sizeof (lh)); -+ kernel_offset = sizeof (lh); -+ - if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) - { - grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); -@@ -315,13 +327,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_memmove (grub_linux_real_chunk, &lh, sizeof (lh)); - - len = real_size + GRUB_DISK_SECTOR_SIZE - sizeof (lh); -- if (grub_file_read (file, grub_linux_real_chunk + sizeof (lh), len) != len) -- { -- if (!grub_errno) -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -- argv[0]); -- goto fail; -- } -+ grub_memcpy (grub_linux_real_chunk + sizeof (lh), kernel + kernel_offset, -+ len); -+ kernel_offset += len; - - if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) - || grub_le_to_cpu16 (lh.version) < 0x0200) -@@ -356,10 +364,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - len = grub_linux16_prot_size; -- if (grub_file_read (file, grub_linux_prot_chunk, grub_linux16_prot_size) -- != (grub_ssize_t) grub_linux16_prot_size && !grub_errno) -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -- argv[0]); -+ grub_memcpy (grub_linux_prot_chunk, kernel + kernel_offset, len); -+ kernel_offset += len; - - if (grub_errno == GRUB_ERR_NONE) - { -@@ -369,6 +375,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - fail: - -+ grub_free (kernel); -+ - if (file) - grub_file_close (file); - --- -2.9.3 - diff --git a/0076-Load-arm-with-SB-enabled.patch b/0076-Load-arm-with-SB-enabled.patch new file mode 100644 index 0000000..86e67ec --- /dev/null +++ b/0076-Load-arm-with-SB-enabled.patch @@ -0,0 +1,428 @@ +From cae0d2cdb28017df75358e0839c60a9c2521cb82 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 18 Sep 2014 11:26:14 -0400 +Subject: [PATCH 076/123] Load arm with SB enabled. + +Make sure we actually try to validate secure boot on this platform (even +though we're not shipping it enabled by default.) + +This means giving the kernel grub's loaded image as the vehicle for the +kernel command line, because we can't call systab->bs->LoadImage() if SB +is enabled. +--- + grub-core/Makefile.core.def | 3 + + grub-core/loader/arm64/linux.c | 117 ++++++++++++++++++++------------------ + grub-core/loader/efi/linux.c | 65 +++++++++++++++++++++ + grub-core/loader/i386/efi/linux.c | 39 +------------ + include/grub/arm64/linux.h | 7 +++ + include/grub/efi/linux.h | 31 ++++++++++ + 6 files changed, 171 insertions(+), 91 deletions(-) + create mode 100644 grub-core/loader/efi/linux.c + create mode 100644 include/grub/efi/linux.h + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index e79bb0cc5..7fba196b3 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -1676,6 +1676,8 @@ module = { + ia64_efi = loader/ia64/efi/linux.c; + arm = loader/arm/linux.c; + arm64 = loader/arm64/linux.c; ++ arm64 = loader/efi/linux.c; ++ fdt = lib/fdt.c; + common = loader/linux.c; + common = lib/cmdline.c; + enable = noemu; +@@ -1743,6 +1745,7 @@ module = { + name = linuxefi; + efi = loader/i386/efi/linux.c; + efi = lib/cmdline.c; ++ efi = loader/efi/linux.c; + enable = i386_efi; + enable = x86_64_efi; + }; +diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c +index 9519d2e4d..4756ef71f 100644 +--- a/grub-core/loader/arm64/linux.c ++++ b/grub-core/loader/arm64/linux.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -39,6 +40,7 @@ static int loaded; + + static void *kernel_addr; + static grub_uint64_t kernel_size; ++static grub_uint32_t handover_offset; + + static char *linux_args; + static grub_uint32_t cmdline_size; +@@ -67,7 +69,8 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) + static grub_err_t + finalize_params_linux (void) + { +- int node, retval; ++ grub_efi_loaded_image_t *loaded_image = NULL; ++ int node, retval, len; + + void *fdt; + +@@ -102,6 +105,26 @@ finalize_params_linux (void) + if (grub_fdt_install() != GRUB_ERR_NONE) + goto failure; + ++ grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", ++ fdt); ++ ++ /* Convert command line to UCS-2 */ ++ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); ++ if (!loaded_image) ++ goto failure; ++ ++ loaded_image->load_options_size = len = ++ (grub_strlen (linux_args) + 1) * sizeof (grub_efi_char16_t); ++ loaded_image->load_options = ++ grub_efi_allocate_pages (0, ++ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); ++ if (!loaded_image->load_options) ++ return grub_error(GRUB_ERR_BAD_OS, "failed to create kernel parameters"); ++ ++ loaded_image->load_options_size = ++ 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, ++ (grub_uint8_t *) linux_args, len, NULL); ++ + return GRUB_ERR_NONE; + + failure: +@@ -109,73 +132,47 @@ failure: + return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); + } + +-grub_err_t +-grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) ++static void ++free_params (void) + { +- grub_efi_memory_mapped_device_path_t *mempath; +- grub_efi_handle_t image_handle; +- grub_efi_boot_services_t *b; +- grub_efi_status_t status; +- grub_efi_loaded_image_t *loaded_image; +- int len; +- +- mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t)); +- if (!mempath) +- return grub_errno; +- +- mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE; +- mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE; +- mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath)); +- mempath[0].memory_type = GRUB_EFI_LOADER_DATA; +- mempath[0].start_address = addr; +- mempath[0].end_address = addr + size; ++ grub_efi_loaded_image_t *loaded_image = NULL; + +- mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; +- mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; +- mempath[1].header.length = sizeof (grub_efi_device_path_t); +- +- b = grub_efi_system_table->boot_services; +- status = b->load_image (0, grub_efi_image_handle, +- (grub_efi_device_path_t *) mempath, +- (void *) addr, size, &image_handle); +- if (status != GRUB_EFI_SUCCESS) +- return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); ++ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); ++ if (loaded_image) ++ { ++ if (loaded_image->load_options) ++ grub_efi_free_pages ((grub_efi_physical_address_t) ++ loaded_image->load_options, ++ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); ++ loaded_image->load_options = NULL; ++ loaded_image->load_options_size = 0; ++ } ++} + +- grub_dprintf ("linux", "linux command line: '%s'\n", args); ++grub_err_t ++grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) ++{ ++ grub_err_t retval; + +- /* Convert command line to UCS-2 */ +- loaded_image = grub_efi_get_loaded_image (image_handle); +- loaded_image->load_options_size = len = +- (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); +- loaded_image->load_options = +- grub_efi_allocate_pages (0, +- GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); +- if (!loaded_image->load_options) ++ retval = finalize_params_linux (); ++ if (retval != GRUB_ERR_NONE) + return grub_errno; + +- loaded_image->load_options_size = +- 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, +- (grub_uint8_t *) args, len, NULL); +- +- grub_dprintf ("linux", "starting image %p\n", image_handle); +- status = b->start_image (image_handle, 0, NULL); ++ grub_dprintf ("linux", "linux command line: '%s'\n", args); + +- /* When successful, not reached */ +- b->unload_image (image_handle); +- grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options, +- GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); ++ retval = grub_efi_linux_boot ((char *)kernel_addr, handover_offset, ++ kernel_addr); + +- return grub_errno; ++ /* Never reached... */ ++ free_params(); ++ return retval; + } + + static grub_err_t + grub_linux_boot (void) + { +- if (finalize_params_linux () != GRUB_ERR_NONE) +- return grub_errno; +- +- return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, +- kernel_size, linux_args)); ++ return grub_arm64_uefi_boot_image ((grub_addr_t)kernel_addr, ++ kernel_size, linux_args); + } + + static grub_err_t +@@ -253,6 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + { + grub_file_t file = 0; + struct grub_arm64_linux_kernel_header lh; ++ struct grub_arm64_linux_pe_header *pe; + + grub_dl_ref (my_mod); + +@@ -297,6 +295,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); + ++ if (!grub_linuxefi_secure_validate (kernel_addr, kernel_size)) ++ { ++ grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); ++ goto fail; ++ } ++ ++ pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); ++ handover_offset = pe->opt.entry_addr; ++ + cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE); + linux_args = grub_malloc (cmdline_size); + if (!linux_args) +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +new file mode 100644 +index 000000000..aea378adf +--- /dev/null ++++ b/grub-core/loader/efi/linux.c +@@ -0,0 +1,65 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2014 Free Software Foundation, Inc. ++ * ++ * GRUB 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. ++ * ++ * GRUB 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 GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define SHIM_LOCK_GUID \ ++ { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } ++ ++struct grub_efi_shim_lock ++{ ++ grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size); ++}; ++typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; ++ ++grub_efi_boolean_t ++grub_linuxefi_secure_validate (void *data, grub_uint32_t size) ++{ ++ grub_efi_guid_t guid = SHIM_LOCK_GUID; ++ grub_efi_shim_lock_t *shim_lock; ++ ++ shim_lock = grub_efi_locate_protocol(&guid, NULL); ++ ++ if (!shim_lock) ++ return 1; ++ ++ if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) ++ return 1; ++ ++ return 0; ++} ++ ++typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); ++ ++grub_err_t ++grub_efi_linux_boot (void *kernel_addr, grub_off_t offset, ++ void *kernel_params) ++{ ++ handover_func hf; ++ ++ hf = (handover_func)((char *)kernel_addr + offset); ++ hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); ++ ++ return GRUB_ERR_BUG; ++} +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index b79e6320b..e5b778577 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -40,52 +41,18 @@ static char *linux_cmdline; + + #define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) + +-#define SHIM_LOCK_GUID \ +- { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } +- +-struct grub_efi_shim_lock +-{ +- grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size); +-}; +-typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; +- +-static grub_efi_boolean_t +-grub_linuxefi_secure_validate (void *data, grub_uint32_t size) +-{ +- grub_efi_guid_t guid = SHIM_LOCK_GUID; +- grub_efi_shim_lock_t *shim_lock; +- +- shim_lock = grub_efi_locate_protocol(&guid, NULL); +- +- if (!shim_lock) +- return 1; +- +- if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) +- return 1; +- +- return 0; +-} +- +-typedef void(*handover_func)(void *, grub_efi_system_table_t *, struct linux_kernel_params *); +- + static grub_err_t + grub_linuxefi_boot (void) + { +- handover_func hf; + int offset = 0; + + #ifdef __x86_64__ + offset = 512; + #endif +- +- hf = (handover_func)((char *)kernel_mem + handover_offset + offset); +- + asm volatile ("cli"); + +- hf (grub_efi_image_handle, grub_efi_system_table, params); +- +- /* Not reached */ +- return GRUB_ERR_NONE; ++ return grub_efi_linux_boot ((char *)kernel_mem, handover_offset + offset, ++ params); + } + + static grub_err_t +diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h +index 1ea23696e..a2ba24e9f 100644 +--- a/include/grub/arm64/linux.h ++++ b/include/grub/arm64/linux.h +@@ -20,6 +20,7 @@ + #define GRUB_LINUX_CPU_HEADER 1 + + #include ++#include + + #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ + +@@ -44,5 +45,11 @@ grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header + *lh); + grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, + char *args); ++struct grub_arm64_linux_pe_header ++{ ++ grub_uint32_t magic; ++ struct grub_pe32_coff_header coff; ++ struct grub_pe64_optional_header opt; ++}; + + #endif /* ! GRUB_LINUX_CPU_HEADER */ +diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h +new file mode 100644 +index 000000000..d9ede3677 +--- /dev/null ++++ b/include/grub/efi/linux.h +@@ -0,0 +1,31 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2014 Free Software Foundation, Inc. ++ * ++ * GRUB 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. ++ * ++ * GRUB 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 GRUB. If not, see . ++ */ ++#ifndef GRUB_EFI_LINUX_HEADER ++#define GRUB_EFI_LINUX_HEADER 1 ++ ++#include ++#include ++#include ++ ++grub_efi_boolean_t ++EXPORT_FUNC(grub_linuxefi_secure_validate) (void *data, grub_uint32_t size); ++grub_err_t ++EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, ++ void *kernel_param); ++ ++#endif /* ! GRUB_EFI_LINUX_HEADER */ +-- +2.14.3 + diff --git a/0076-Make-grub-editenv-build-again.patch b/0076-Make-grub-editenv-build-again.patch deleted file mode 100644 index ec632e1..0000000 --- a/0076-Make-grub-editenv-build-again.patch +++ /dev/null @@ -1,30 +0,0 @@ -From edaa6c877917816d57603e26d660107c82ffbb5d Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 4 Mar 2016 16:29:13 -0500 -Subject: [PATCH 76/90] Make grub-editenv build again. - -36212460d3565b18439a3a8130b28e6c97702c6a split how some of the mkimage -utility functions are defined, and they wind up being linked into -grub-editenv. Most utilities got fixed, but this one was missed. - -Signed-off-by: Peter Jones ---- - Makefile.util.def | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/Makefile.util.def b/Makefile.util.def -index 226c46b..8007de9 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -236,6 +236,8 @@ program = { - extra_dist = grub-core/osdep/unix/compress.c; - extra_dist = grub-core/osdep/basic/compress.c; - common = util/mkimage.c; -+ common = util/grub-mkimage32.c; -+ common = util/grub-mkimage64.c; - common = grub-core/osdep/config.c; - common = util/config.c; - common = util/resolve.c; --- -2.9.3 - diff --git a/0077-Fix-locale-issue-in-grub-setpassword-1294243.patch b/0077-Fix-locale-issue-in-grub-setpassword-1294243.patch deleted file mode 100644 index 9070392..0000000 --- a/0077-Fix-locale-issue-in-grub-setpassword-1294243.patch +++ /dev/null @@ -1,30 +0,0 @@ -From d2f552900d87b62ca0dbc740902d561bc32f32be Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Fri, 29 Jan 2016 17:34:02 -0500 -Subject: [PATCH 77/90] Fix locale issue in grub-setpassword (#1294243) - -A shell substitution was expecting non-translated output to grab the -hashed password and put it in the user.cfg file. Modified code to force -the generic C locale when this particular piece of code is run. - -Resolves: rhbz#1294243 ---- - util/grub-setpassword.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index dd76f00..2923f43 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -105,7 +105,7 @@ getpass() { - P1="$1" && shift - - ( echo ${P0} ; echo ${P1} ) | \ -- ${grub_mkpasswd} | \ -+ LC_ALL=C ${grub_mkpasswd} | \ - grep -v '[eE]nter password:' | \ - sed -e "s/PBKDF2 hash of your password is //" - } --- -2.9.3 - diff --git a/0077-Try-prefix-if-fw_path-doesn-t-work.patch b/0077-Try-prefix-if-fw_path-doesn-t-work.patch new file mode 100644 index 0000000..2136e0a --- /dev/null +++ b/0077-Try-prefix-if-fw_path-doesn-t-work.patch @@ -0,0 +1,211 @@ +From d255a98813193eb2c23f9217106b121278843023 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 3 Oct 2014 11:08:03 -0400 +Subject: [PATCH 077/123] Try $prefix if $fw_path doesn't work. + +Related: rhbz#1148652 + +Signed-off-by: Peter Jones +--- + grub-core/kern/ieee1275/init.c | 30 ++++++----- + grub-core/net/net.c | 2 +- + grub-core/normal/main.c | 118 ++++++++++++++++++++--------------------- + 3 files changed, 75 insertions(+), 75 deletions(-) + +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 8a3ecd580..8efa1a6ed 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -139,23 +139,25 @@ grub_machine_get_bootlocation (char **device, char **path) + grub_free (canon); + } + else +- *device = grub_ieee1275_encode_devname (bootpath); +- grub_free (type); +- +- filename = grub_ieee1275_get_filename (bootpath); +- if (filename) + { +- char *lastslash = grub_strrchr (filename, '\\'); +- +- /* Truncate at last directory. */ +- if (lastslash) ++ filename = grub_ieee1275_get_filename (bootpath); ++ if (filename) + { +- *lastslash = '\0'; +- grub_translate_ieee1275_path (filename); +- +- *path = filename; +- } ++ char *lastslash = grub_strrchr (filename, '\\'); ++ ++ /* Truncate at last directory. */ ++ if (lastslash) ++ { ++ *lastslash = '\0'; ++ grub_translate_ieee1275_path (filename); ++ ++ *path = filename; ++ } ++ } ++ *device = grub_ieee1275_encode_devname (bootpath); + } ++ ++ grub_free (type); + grub_free (bootpath); + } + +diff --git a/grub-core/net/net.c b/grub-core/net/net.c +index 0769bf850..16d2ce06d 100644 +--- a/grub-core/net/net.c ++++ b/grub-core/net/net.c +@@ -1850,7 +1850,7 @@ grub_net_search_configfile (char *config) + /* Remove the remaining minus sign at the end. */ + config[config_len] = '\0'; + +- return GRUB_ERR_NONE; ++ return GRUB_ERR_FILE_NOT_FOUND; + } + + static struct grub_preboot *fini_hnd; +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index 7d9c4f09b..b69f9e738 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -331,74 +331,72 @@ grub_enter_normal_mode (const char *config) + grub_boot_time ("Exiting normal mode"); + } + ++static grub_err_t ++grub_try_normal (const char *variable) ++{ ++ char *config; ++ const char *prefix; ++ grub_err_t err = GRUB_ERR_FILE_NOT_FOUND; ++ ++ prefix = grub_env_get (variable); ++ if (!prefix) ++ return GRUB_ERR_FILE_NOT_FOUND; ++ ++ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) ++ { ++ grub_size_t config_len; ++ config_len = grub_strlen (prefix) + ++ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); ++ config = grub_malloc (config_len); ++ ++ if (! config) ++ return GRUB_ERR_FILE_NOT_FOUND; ++ ++ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); ++ err = grub_net_search_configfile (config); ++ } ++ ++ if (err != GRUB_ERR_NONE) ++ { ++ config = grub_xasprintf ("%s/grub.cfg", prefix); ++ if (config) ++ { ++ grub_file_t file; ++ file = grub_file_open (config); ++ if (file) ++ { ++ grub_file_close (file); ++ err = GRUB_ERR_NONE; ++ } ++ } ++ } ++ ++ if (err == GRUB_ERR_NONE) ++ grub_enter_normal_mode (config); ++ ++ grub_errno = 0; ++ grub_free (config); ++ return err; ++} ++ + /* Enter normal mode from rescue mode. */ + static grub_err_t + grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), + int argc, char *argv[]) + { +- if (argc == 0) ++ if (argc) ++ grub_enter_normal_mode (argv[0]); ++ else + { +- /* Guess the config filename. It is necessary to make CONFIG static, +- so that it won't get broken by longjmp. */ +- char *config; +- const char *prefix; +- +- prefix = grub_env_get ("fw_path"); +- if (! prefix) +- prefix = grub_env_get ("prefix"); +- +- if (prefix) +- { +- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) +- { +- grub_size_t config_len; +- config_len = grub_strlen (prefix) + +- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); +- config = grub_malloc (config_len); +- +- if (! config) +- goto quit; +- +- grub_snprintf (config, config_len, "%s/grub.cfg", prefix); +- +- grub_net_search_configfile (config); +- +- grub_enter_normal_mode (config); +- grub_free (config); +- config = NULL; +- } +- +- if (!config) +- { +- config = grub_xasprintf ("%s/grub.cfg", prefix); +- if (config) +- { +- grub_file_t file; +- +- file = grub_file_open (config); +- if (file) +- { +- grub_file_close (file); +- grub_enter_normal_mode (config); +- } +- else +- { +- /* Ignore all errors. */ +- grub_errno = 0; +- } +- grub_free (config); +- } +- } +- } +- else +- { +- grub_enter_normal_mode (0); +- } ++ /* Guess the config filename. */ ++ grub_err_t err; ++ err = grub_try_normal ("fw_path"); ++ if (err == GRUB_ERR_FILE_NOT_FOUND) ++ err = grub_try_normal ("prefix"); ++ if (err == GRUB_ERR_FILE_NOT_FOUND) ++ grub_enter_normal_mode (0); + } +- else +- grub_enter_normal_mode (argv[0]); + +-quit: + return 0; + } + +-- +2.14.3 + diff --git a/0078-Fix-up-some-man-pages-rpmdiff-noticed.patch b/0078-Fix-up-some-man-pages-rpmdiff-noticed.patch deleted file mode 100644 index f0130b3..0000000 --- a/0078-Fix-up-some-man-pages-rpmdiff-noticed.patch +++ /dev/null @@ -1,153 +0,0 @@ -From 216188f920d3ade19626d6e8fe450cea2c427e53 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 23 Sep 2014 09:58:49 -0400 -Subject: [PATCH 78/90] Fix up some man pages rpmdiff noticed. - ---- - configure.ac | 2 ++ - util/grub-macbless.8 | 26 +++++++++++++++++++ - util/grub-mkimage.1 | 2 +- - util/grub-syslinux2cfg.1 | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 94 insertions(+), 1 deletion(-) - create mode 100644 util/grub-macbless.8 - create mode 100644 util/grub-syslinux2cfg.1 - -diff --git a/configure.ac b/configure.ac -index 67ff20c..25de2c1 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -78,6 +78,7 @@ grub_TRANSFORM([grub-fstest.3]) - grub_TRANSFORM([grub-glue-efi.3]) - grub_TRANSFORM([grub-install.1]) - grub_TRANSFORM([grub-kbdcomp.3]) -+grub_TRANSFORM([grub-macbless.8]) - grub_TRANSFORM([grub-menulst2cfg.1]) - grub_TRANSFORM([grub-mkconfig.1]) - grub_TRANSFORM([grub-mkfont.3]) -@@ -96,6 +97,7 @@ grub_TRANSFORM([grub-render-label.3]) - grub_TRANSFORM([grub-script-check.3]) - grub_TRANSFORM([grub-set-default.1]) - grub_TRANSFORM([grub-sparc64-setup.3]) -+grub_TRANSFORM([grub-syslinux2cfg.1]) - - # Optimization flag. Allow user to override. - if test "x$TARGET_CFLAGS" = x; then -diff --git a/util/grub-macbless.8 b/util/grub-macbless.8 -new file mode 100644 -index 0000000..ae842f3 ---- /dev/null -+++ b/util/grub-macbless.8 -@@ -0,0 +1,26 @@ -+.TH GRUB-MACBLESS 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-macbless\fR \(em Mac-style bless utility for HFS or HFS+ -+ -+.SH SYNOPSIS -+\fBgrub-macbless\fR [-p | --ppc] [-v | --verbose] [-x | --x86] \fIFILE\fR -+ -+.SH DESCRIPTION -+\fBgrub-mkimage\fR blesses a file on an HFS or HFS+ file system, so that it -+can be used to boot a Mac. -+ -+.SH OPTIONS -+.TP -+--ppc -+Bless the file for use on PPC-based Macs. -+ -+.TP -+--verbose -+Print verbose messages. -+ -+.TP -+--x86 -+Bless the file for use on x86-based Macs. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-mkimage.1 b/util/grub-mkimage.1 -index 4dea4f5..0eaaafe 100644 ---- a/util/grub-mkimage.1 -+++ b/util/grub-mkimage.1 -@@ -17,7 +17,7 @@ - [-v | --verbose] \fIMODULES\fR - - .SH DESCRIPTION --\fBgrub-mkimage\fI builds a bootable image of GRUB. -+\fBgrub-mkimage\fR builds a bootable image of GRUB. - - .SH OPTIONS - .TP -diff --git a/util/grub-syslinux2cfg.1 b/util/grub-syslinux2cfg.1 -new file mode 100644 -index 0000000..8530948 ---- /dev/null -+++ b/util/grub-syslinux2cfg.1 -@@ -0,0 +1,65 @@ -+.TH GRUB-SYSLINUX2CFG 1 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-syslinux2cfg\fR \(em Transform a syslinux config file into a GRUB config. -+ -+.SH SYNOPSIS -+\fBgrub-syslinux2cfg\fR [-c | --cwd=\fRDIR\fI] [-r | --root=\fIDIR\fR] [-v | --verbose] -+.RE -+.RS 25 -+[-t | --target-root=\fIDIR\fR] [-T | --target-cwd=\fIDIR\fR] -+.RE -+.RS 25 -+[-o | --output=\fIFILE\fR] [[-i | --isolinux] | -+.RE -+.RS 46 -+ [-s | --syslinux] | -+.RE -+.RS 46 -+ [-p | --pxelinux]] \fIFILE\fR -+ -+.SH DESCRIPTION -+\fBgrub-syslinux2cfg\fR builds a GRUB configuration file out of an existing -+syslinux configuration file. -+ -+.SH OPTIONS -+.TP -+--cwd=\fIDIR\fR -+Set \fIDIR\fR as syslinux's working directory. The default is to use the -+parent directory of the input file. -+ -+.TP -+--root=\fIDIR\fR -+Set \fIDIR\fR as the root directory of the syslinux disk. The default value -+is "/". -+ -+.TP -+--verbose -+Print verbose messages. -+ -+.TP -+--target-root=\fIDIR\fR -+Root directory as it will be seen at runtime. The default value is "/". -+ -+.TP -+--target-cwd=\fIDIR\fR -+Working directory of syslinux as it will be seen at runtime. The default -+value is the parent directory of the input file. -+ -+.TP -+--output=\fIFILE\fR -+Write the new config file to \fIFILE\fR. The default value is standard output. -+ -+.TP -+--isolinux -+Assume that the input file is an isolinux configuration file. -+ -+.TP -+--pxelinux -+Assume that the input file is a pxelinux configuration file. -+ -+.TP -+--syslinux -+Assume that the input file is a syslinux configuration file. -+ -+.SH SEE ALSO -+.BR "info grub" --- -2.9.3 - diff --git a/0078-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch b/0078-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch new file mode 100644 index 0000000..e073d9f --- /dev/null +++ b/0078-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch @@ -0,0 +1,77 @@ +From 8e6fc0ea14aa01817cc9103ffd5e328a78e56857 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 27 Oct 2014 09:22:55 -0400 +Subject: [PATCH 078/123] Try to emit linux16/initrd16 and linuxefi/initrdefi + in 30-os_prober. + +Resolves: rhbz#1108296 + +Signed-off-by: Peter Jones +--- + util/grub.d/30_os-prober.in | 30 ++++++++++++++++++++++++++---- + 1 file changed, 26 insertions(+), 4 deletions(-) + +diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in +index 9b8f5968e..dc98eace9 100644 +--- a/util/grub.d/30_os-prober.in ++++ b/util/grub.d/30_os-prober.in +@@ -141,6 +141,28 @@ for OS in ${OSPROBED} ; do + # os-prober returns text string followed by optional counter + CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')" + ++ sixteenbit="" ++ linuxefi="linux" ++ initrdefi="initrd" ++ case "$machine" in ++ i?86|x86_64) ++ sixteenbit="16" ++ linuxefi="linuxefi" ++ initrdefi="initrdefi" ++ ;; ++ aarch64) ++ linuxefi="linux" ++ initrdefi="initrd" ++ esac ++ linux="linux${sixteenbit}" ++ initrd="initrd${sixteenbit}" ++ # there's no way to tell that the /other/ os is booting through UEFI, ++ # but if we are it's an okay bet... ++ if [ -d /sys/firmware/efi ]; then ++ linux=$linuxefi ++ initrd=$initrdefi ++ fi ++ + gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2 + + case ${BOOT} in +@@ -241,11 +263,11 @@ EOF + save_default_entry | grub_add_tab + printf '%s\n' "${prepare_boot_cache}" + cat << EOF +- linux ${LKERNEL} ${LPARAMS} ++ ${linux} ${LKERNEL} ${LPARAMS} + EOF + if [ -n "${LINITRD}" ] ; then + cat << EOF +- initrd ${LINITRD} ++ ${initrd} ${LINITRD} + EOF + fi + cat << EOF +@@ -261,11 +283,11 @@ EOF + save_default_entry | sed -e "s/^/$grub_tab$grub_tab/" + printf '%s\n' "${prepare_boot_cache}" | grub_add_tab + cat << EOF +- linux ${LKERNEL} ${LPARAMS} ++ ${linux} ${LKERNEL} ${LPARAMS} + EOF + if [ -n "${LINITRD}" ] ; then + cat << EOF +- initrd ${LINITRD} ++ ${initrd} ${LINITRD} + EOF + fi + cat << EOF +-- +2.14.3 + diff --git a/0079-Handle-rssd-storage-devices.patch b/0079-Handle-rssd-storage-devices.patch deleted file mode 100644 index c37338c..0000000 --- a/0079-Handle-rssd-storage-devices.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 90e2d3fbb161d494cdfc0ad0da740a6a4f651d70 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 30 Jun 2015 15:50:41 -0400 -Subject: [PATCH 79/90] Handle rssd storage devices. - -Resolves: rhbz#1087962 - -Signed-off-by: Peter Jones ---- - grub-core/osdep/linux/getroot.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 09e7e6e..ad7b774 100644 ---- a/grub-core/osdep/linux/getroot.c -+++ b/grub-core/osdep/linux/getroot.c -@@ -898,6 +898,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, - return path; - } - -+ /* If this is an rssd device. */ -+ if ((strncmp ("rssd", p, 4) == 0) && p[4] >= 'a' && p[4] <= 'z') -+ { -+ char *pp = p + 4; -+ while (*pp >= 'a' && *pp <= 'z') -+ pp++; -+ if (*pp) -+ *is_part = 1; -+ /* /dev/rssd[a-z]+[0-9]* */ -+ *pp = '\0'; -+ return path; -+ } -+ - /* If this is a loop device */ - if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9') - { --- -2.9.3 - diff --git a/0079-Make-grub2-mkconfig-construct-titles-that-look-like-.patch b/0079-Make-grub2-mkconfig-construct-titles-that-look-like-.patch new file mode 100644 index 0000000..e8090b4 --- /dev/null +++ b/0079-Make-grub2-mkconfig-construct-titles-that-look-like-.patch @@ -0,0 +1,54 @@ +From b6e3ffe7ae7e4222cc15876cb72c691112f3c4b0 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 28 Apr 2015 11:15:03 -0400 +Subject: [PATCH 079/123] Make grub2-mkconfig construct titles that look like + the ones we want elsewhere. + +Resolves: rhbz#1215839 + +Signed-off-by: Peter Jones +--- + util/grub.d/10_linux.in | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index c6627268c..121524185 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -68,6 +68,15 @@ case x"$GRUB_FS" in + ;; + esac + ++mktitle () ++{ ++ local OS_NAME="$(eval $(grep ^NAME= /etc/os-release) ; echo ${NAME})" ++ local OS_VERS="$(eval $(grep ^VERSION= /etc/os-release) ; echo ${VERSION})" ++ ++ local titlestr="${OS_NAME} (%s) ${OS_VERS}" ++ echo -n ${titlestr} ++} ++ + title_correction_code= + + linux_entry () +@@ -98,15 +107,14 @@ linux_entry () + if [ x$type != xsimple ] ; then + case $type in + recovery) +- title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;; ++ title="$(printf "$(mktitle) (recovery mode)" "${version}")" ;; + *) +- title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;; ++ title="$(printf "$(mktitle)" "${version}")" ;; + esac + if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then + replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" + quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" + title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" +- grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")" + fi + echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" + else +-- +2.14.3 + diff --git a/0080-Update-info-with-grub.cfg-netboot-selection-order-11.patch b/0080-Update-info-with-grub.cfg-netboot-selection-order-11.patch new file mode 100644 index 0000000..95ecbec --- /dev/null +++ b/0080-Update-info-with-grub.cfg-netboot-selection-order-11.patch @@ -0,0 +1,70 @@ +From c4be6106eae8c1b479c325f531a1f81188f400e8 Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Mon, 16 Mar 2015 16:34:51 -0400 +Subject: [PATCH 080/123] Update info with grub.cfg netboot selection order + (#1148650) + +Added documentation to the grub info page that specifies the order +netboot clients will use to select a grub configuration file. + +Resolves rhbz#1148650 +--- + docs/grub.texi | 42 ++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 42 insertions(+) + +diff --git a/docs/grub.texi b/docs/grub.texi +index 98d4d0d52..4c6323b39 100644 +--- a/docs/grub.texi ++++ b/docs/grub.texi +@@ -2414,6 +2414,48 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 + Then follow instructions printed out by grub-mknetdir on configuring your DHCP + server. + ++The grub.cfg file is placed in the same directory as the path output by ++grub-mknetdir hereafter referred to as FWPATH. GRUB will search for its ++configuration files in order using the following rules where the appended ++value corresponds to a value on the client machine. ++ ++@example ++@group ++@samp{(FWPATH)}/grub.cfg-@samp{(UUID OF NIC)} ++@samp{(FWPATH)}/grub.cfg-@samp{(MAC ADDRESS OF NIC)} ++@samp{(FWPATH)}/grub.cfg-@samp{(IPv4 OR IPv6 ADDRESS)} ++@samp{(FWPATH)}/grub.cfg ++@end group ++@end example ++ ++The client will only attempt to look up an IPv6 address config once, however, ++it will try the IPv4 multiple times. The concrete example below shows what ++would happen under the IPv4 case. ++ ++@example ++@group ++UUID: 7726a678-7fc0-4853-a4f6-c85ac36a120a ++MAC: 52:54:00:ec:33:81 ++IPV4: 10.0.0.130 (0A000082) ++@end group ++@end example ++ ++@example ++@group ++@samp{(FWPATH)}/grub.cfg-7726a678-7fc0-4853-a4f6-c85ac36a120a ++@samp{(FWPATH)}/grub.cfg-52-54-00-ec-33-81 ++@samp{(FWPATH)}/grub.cfg-0A000082 ++@samp{(FWPATH)}/grub.cfg-0A00008 ++@samp{(FWPATH)}/grub.cfg-0A0000 ++@samp{(FWPATH)}/grub.cfg-0A000 ++@samp{(FWPATH)}/grub.cfg-0A00 ++@samp{(FWPATH)}/grub.cfg-0A0 ++@samp{(FWPATH)}/grub.cfg-0A ++@samp{(FWPATH)}/grub.cfg-0 ++@samp{(FWPATH)}/grub.cfg ++@end group ++@end example ++ + After GRUB has started, files on the TFTP server will be accessible via the + @samp{(tftp)} device. + +-- +2.14.3 + diff --git a/0080-Warn-if-grub-password-will-not-be-read-1290803.patch b/0080-Warn-if-grub-password-will-not-be-read-1290803.patch deleted file mode 100644 index 44c210d..0000000 --- a/0080-Warn-if-grub-password-will-not-be-read-1290803.patch +++ /dev/null @@ -1,31 +0,0 @@ -From f46e9b0378cfaced22f0de5e8061ddb0c6829ee8 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Mon, 22 Feb 2016 15:30:05 -0500 -Subject: [PATCH 80/90] Warn if grub password will not be read (#1290803) - -It is possible for a system to have never run grub-mkconfig and add the -section that reads the user.cfg file which contains a user set GRUB -password. Users in that scenario will now be warned that grub-mkconfig -must be run prior to their newly set password taking effect. - -Resolves: rhbz#1290803 ---- - util/grub-setpassword.in | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index 2923f43..dd7b793 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -121,3 +121,8 @@ fi - install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : - chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : - echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" -+ -+if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${grubdir}/grub.cfg"; then -+ echo "WARNING: The current configuration lacks password support!" -+ echo "Update your configuration with @grub_mkconfig@ to support this feature." -+fi --- -2.9.3 - diff --git a/0081-Clean-up-grub-setpassword-documentation-1290799.patch b/0081-Clean-up-grub-setpassword-documentation-1290799.patch deleted file mode 100644 index aa217ae..0000000 --- a/0081-Clean-up-grub-setpassword-documentation-1290799.patch +++ /dev/null @@ -1,58 +0,0 @@ -From f41adcd85164ef8a0d0918f0508f29dcf3c7467d Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Tue, 26 Jan 2016 10:28:35 -0500 -Subject: [PATCH 81/90] Clean up grub-setpassword documentation (#1290799) - -The output for --help had some errors. Corrected those and polished the -text to be a little easier to follow. Carried verbage over to man page -to maintain internal consistency. - -Resolves: rhbz#1290799 ---- - util/grub-setpassword.8 | 2 +- - util/grub-setpassword.in | 15 +++++++-------- - 2 files changed, 8 insertions(+), 9 deletions(-) - -diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 -index 49200a8..dc91dd6 100644 ---- a/util/grub-setpassword.8 -+++ b/util/grub-setpassword.8 -@@ -19,7 +19,7 @@ Display program usage and exit. - -v, --version - Display the current version. - .TP ---o, --output[=\fIDIRECTORY PATH\fR] -+-o, --output=<\fIDIRECTORY\fR> - Choose the file path to which user.cfg will be written. - - .SH SEE ALSO -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index dd7b793..d7924af 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -16,15 +16,14 @@ grub_mkpasswd="${bindir}/@grub_mkpasswd_pbkdf2@" - # Print the usage. - usage () { - cat < put user.cfg in a user-selected directory - - Report bugs at https://bugzilla.redhat.com. - EOF --- -2.9.3 - diff --git a/0081-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch b/0081-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch new file mode 100644 index 0000000..03a2c07 --- /dev/null +++ b/0081-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch @@ -0,0 +1,460 @@ +From 11abe391636d0819902357591aebf0ea01b88130 Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Mon, 16 Mar 2015 14:14:19 -0400 +Subject: [PATCH 081/123] Use Distribution Package Sort for grub2-mkconfig + (#1124074) + +Users reported that newly installed kernels on their systems installed +with grub-mkconfig would not appear on the grub boot list in order +starting with the most recent. Added an option for rpm-based systems to +use the rpm-sort library to sort kernels instead. + +Resolves rhbz#1124074 +--- + .gitignore | 1 + + Makefile.util.def | 16 +++ + configure.ac | 29 +++++ + util/grub-mkconfig_lib.in | 11 +- + util/grub-rpm-sort.8 | 12 ++ + util/grub-rpm-sort.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 349 insertions(+), 1 deletion(-) + create mode 100644 util/grub-rpm-sort.8 + create mode 100644 util/grub-rpm-sort.c + +diff --git a/.gitignore b/.gitignore +index 06c9f3ab7..7697877ca 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -124,6 +124,7 @@ grub-ofpathname + grub-probe + grub-reboot + grub-render-label ++grub-rpm-sort + grub-script-check + grub-set-default + grub-shell +diff --git a/Makefile.util.def b/Makefile.util.def +index 206110458..d846b81b5 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -684,6 +684,22 @@ program = { + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + }; + ++program = { ++ name = grub-rpm-sort; ++ mansection = 8; ++ installdir = sbin; ++ ++ common = grub-core/kern/emu/misc.c; ++ common = grub-core/kern/emu/argp_common.c; ++ common = grub-core/osdep/init.c; ++ common = util/misc.c; ++ common = util/grub-rpm-sort.c; ++ ++ ldadd = grub-core/gnulib/libgnu.a; ++ ldadd = libgrubkern.a; ++ ldadd = '$(LIBDEVMAPPER) $(LIBRPM)'; ++}; ++ + script = { + name = grub-mkconfig; + common = util/grub-mkconfig.in; +diff --git a/configure.ac b/configure.ac +index 9937a827f..d5e8d90f3 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) + grub_TRANSFORM([grub-mkrescue]) + grub_TRANSFORM([grub-probe]) + grub_TRANSFORM([grub-reboot]) ++grub_TRANSFORM([grub-rpm-sort]) + grub_TRANSFORM([grub-script-check]) + grub_TRANSFORM([grub-set-default]) + grub_TRANSFORM([grub-sparc64-setup]) +@@ -88,6 +89,7 @@ grub_TRANSFORM([grub-mkrescue.1]) + grub_TRANSFORM([grub-mkstandalone.3]) + grub_TRANSFORM([grub-ofpathname.3]) + grub_TRANSFORM([grub-probe.3]) ++grub_TRANSFORM([grub-rpm-sort.8]) + grub_TRANSFORM([grub-reboot.3]) + grub_TRANSFORM([grub-render-label.3]) + grub_TRANSFORM([grub-script-check.3]) +@@ -1743,6 +1745,33 @@ fi + + AC_SUBST([LIBDEVMAPPER]) + ++AC_ARG_ENABLE([rpm-sort], ++ [AS_HELP_STRING([--enable-rpm-sort], ++ [enable native rpm sorting of kernels in grub (default=guessed)])]) ++if test x"$enable_rpm_sort" = xno ; then ++ rpm_sort_excuse="explicitly disabled" ++fi ++ ++if test x"$rpm_sort_excuse" = x ; then ++ # Check for rpmlib header. ++ AC_CHECK_HEADER([rpm/rpmlib.h], [], ++ [rpm_sort_excuse="need rpm/rpmlib header"]) ++fi ++ ++if test x"$rpm_sort_excuse" = x ; then ++ # Check for rpm library. ++ AC_CHECK_LIB([rpm], [rpmvercmp], [], ++ [rpm_sort_excuse="rpmlib missing rpmvercmp"]) ++fi ++ ++if test x"$rpm_sort_excuse" = x ; then ++ LIBRPM="-lrpm"; ++ AC_DEFINE([HAVE_RPM], [1], ++ [Define to 1 if you have the rpm library.]) ++fi ++ ++AC_SUBST([LIBRPM]) ++ + LIBGEOM= + if test x$host_kernel = xkfreebsd; then + AC_CHECK_LIB([geom], [geom_gettree], [], +diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in +index 10fabee5e..9c410eae4 100644 +--- a/util/grub-mkconfig_lib.in ++++ b/util/grub-mkconfig_lib.in +@@ -33,6 +33,9 @@ fi + if test "x$grub_mkrelpath" = x; then + grub_mkrelpath="${bindir}/@grub_mkrelpath@" + fi ++if test "x$grub_rpm_sort" = x; then ++ grub_rpm_sort="${sbindir}/@grub_rpm_sort@" ++fi + + if which gettext >/dev/null 2>/dev/null; then + : +@@ -213,6 +216,12 @@ version_sort () + esac + } + ++if [ "x$grub_rpm_sort" != x -a -x "$grub_rpm_sort" ]; then ++ kernel_sort="$grub_rpm_sort" ++else ++ kernel_sort=version_sort ++fi ++ + version_test_numeric () + { + version_test_numeric_a="$1" +@@ -229,7 +238,7 @@ version_test_numeric () + version_test_numeric_a="$version_test_numeric_b" + version_test_numeric_b="$version_test_numeric_c" + fi +- if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | version_sort | head -n 1 | grep -qx "$version_test_numeric_b" ; then ++ if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | "$kernel_sort" | head -n 1 | grep -qx "$version_test_numeric_b" ; then + return 0 + else + return 1 +diff --git a/util/grub-rpm-sort.8 b/util/grub-rpm-sort.8 +new file mode 100644 +index 000000000..8ce214884 +--- /dev/null ++++ b/util/grub-rpm-sort.8 +@@ -0,0 +1,12 @@ ++.TH GRUB-RPM-SORT 8 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-rpm-sort\fR \(em Sort input according to RPM version compare. ++ ++.SH SYNOPSIS ++\fBgrub-rpm-sort\fR [OPTIONS]. ++ ++.SH DESCRIPTION ++You should not normally run this program directly. Use grub-mkconfig instead. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-rpm-sort.c b/util/grub-rpm-sort.c +new file mode 100644 +index 000000000..f33bd1ed5 +--- /dev/null ++++ b/util/grub-rpm-sort.c +@@ -0,0 +1,281 @@ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++static size_t ++read_file (const char *input, char **ret) ++{ ++ FILE *in; ++ size_t s; ++ size_t sz = 2048; ++ size_t offset = 0; ++ char *text; ++ ++ if (!strcmp(input, "-")) ++ in = stdin; ++ else ++ in = grub_util_fopen(input, "r"); ++ ++ text = xmalloc (sz); ++ ++ if (!in) ++ grub_util_error (_("cannot open `%s': %s"), input, strerror (errno)); ++ ++ while ((s = fread (text + offset, 1, sz - offset, in)) != 0) ++ { ++ offset += s; ++ if (sz - offset == 0) ++ { ++ sz += 2048; ++ text = xrealloc (text, sz); ++ } ++ } ++ ++ text[offset] = '\0'; ++ *ret = text; ++ ++ if (in != stdin) ++ fclose(in); ++ ++ return offset + 1; ++} ++ ++/* returns name/version/release */ ++/* NULL string pointer returned if nothing found */ ++static void ++split_package_string (char *package_string, char **name, ++ char **version, char **release) ++{ ++ char *package_version, *package_release; ++ ++ /* Release */ ++ package_release = strrchr (package_string, '-'); ++ ++ if (package_release != NULL) ++ *package_release++ = '\0'; ++ ++ *release = package_release; ++ ++ /* Version */ ++ package_version = strrchr(package_string, '-'); ++ ++ if (package_version != NULL) ++ *package_version++ = '\0'; ++ ++ *version = package_version; ++ /* Name */ ++ *name = package_string; ++ ++ /* Bubble up non-null values from release to name */ ++ if (*name == NULL) ++ { ++ *name = (*version == NULL ? *release : *version); ++ *version = *release; ++ *release = NULL; ++ } ++ if (*version == NULL) ++ { ++ *version = *release; ++ *release = NULL; ++ } ++} ++ ++/* ++ * package name-version-release comparator for qsort ++ * expects p, q which are pointers to character strings (char *) ++ * which will not be altered in this function ++ */ ++static int ++package_version_compare (const void *p, const void *q) ++{ ++ char *local_p, *local_q; ++ char *lhs_name, *lhs_version, *lhs_release; ++ char *rhs_name, *rhs_version, *rhs_release; ++ int vercmpflag = 0; ++ ++ local_p = alloca (strlen (*(char * const *)p) + 1); ++ local_q = alloca (strlen (*(char * const *)q) + 1); ++ ++ /* make sure these allocated */ ++ assert (local_p); ++ assert (local_q); ++ ++ strcpy (local_p, *(char * const *)p); ++ strcpy (local_q, *(char * const *)q); ++ ++ split_package_string (local_p, &lhs_name, &lhs_version, &lhs_release); ++ split_package_string (local_q, &rhs_name, &rhs_version, &rhs_release); ++ ++ /* Check Name and return if unequal */ ++ vercmpflag = rpmvercmp ((lhs_name == NULL ? "" : lhs_name), ++ (rhs_name == NULL ? "" : rhs_name)); ++ if (vercmpflag != 0) ++ return vercmpflag; ++ ++ /* Check version and return if unequal */ ++ vercmpflag = rpmvercmp ((lhs_version == NULL ? "" : lhs_version), ++ (rhs_version == NULL ? "" : rhs_version)); ++ if (vercmpflag != 0) ++ return vercmpflag; ++ ++ /* Check release and return the version compare value */ ++ vercmpflag = rpmvercmp ((lhs_release == NULL ? "" : lhs_release), ++ (rhs_release == NULL ? "" : rhs_release)); ++ ++ return vercmpflag; ++} ++ ++static void ++add_input (const char *filename, char ***package_names, size_t *n_package_names) ++{ ++ char *orig_input_buffer = NULL; ++ char *input_buffer; ++ char *position_of_newline; ++ char **names = *package_names; ++ char **new_names = NULL; ++ size_t n_names = *n_package_names; ++ ++ if (!*package_names) ++ new_names = names = xmalloc (sizeof (char *) * 2); ++ ++ if (read_file (filename, &orig_input_buffer) < 2) ++ { ++ if (new_names) ++ free (new_names); ++ if (orig_input_buffer) ++ free (orig_input_buffer); ++ return; ++ } ++ ++ input_buffer = orig_input_buffer; ++ while (input_buffer && *input_buffer && ++ (position_of_newline = strchrnul (input_buffer, '\n'))) ++ { ++ size_t sz = position_of_newline - input_buffer; ++ char *new; ++ ++ if (sz == 0) ++ { ++ input_buffer = position_of_newline + 1; ++ continue; ++ } ++ ++ new = xmalloc (sz+1); ++ strncpy (new, input_buffer, sz); ++ new[sz] = '\0'; ++ ++ names = xrealloc (names, sizeof (char *) * (n_names + 1)); ++ names[n_names] = new; ++ n_names++; ++ ++ /* move buffer ahead to next line */ ++ input_buffer = position_of_newline + 1; ++ if (*position_of_newline == '\0') ++ input_buffer = NULL; ++ } ++ ++ free (orig_input_buffer); ++ ++ *package_names = names; ++ *n_package_names = n_names; ++} ++ ++static char * ++help_filter (int key, const char *text, void *input __attribute__ ((unused))) ++{ ++ return (char *)text; ++} ++ ++static struct argp_option options[] = { ++ { 0, } ++}; ++ ++struct arguments ++{ ++ size_t ninputs; ++ size_t input_max; ++ char **inputs; ++}; ++ ++static error_t ++argp_parser (int key, char *arg, struct argp_state *state) ++{ ++ struct arguments *arguments = state->input; ++ switch (key) ++ { ++ case ARGP_KEY_ARG: ++ assert (arguments->ninputs < arguments->input_max); ++ arguments->inputs[arguments->ninputs++] = xstrdup (arg); ++ break; ++ default: ++ return ARGP_ERR_UNKNOWN; ++ } ++ return 0; ++} ++ ++static struct argp argp = { ++ options, argp_parser, N_("[INPUT_FILES]"), ++ N_("Sort a list of strings in RPM version sort order."), ++ NULL, help_filter, NULL ++}; ++ ++int ++main (int argc, char *argv[]) ++{ ++ struct arguments arguments; ++ char **package_names = NULL; ++ size_t n_package_names = 0; ++ int i; ++ ++ grub_util_host_init (&argc, &argv); ++ ++ memset (&arguments, 0, sizeof (struct arguments)); ++ arguments.input_max = argc+1; ++ arguments.inputs = xmalloc ((arguments.input_max + 1) ++ * sizeof (arguments.inputs[0])); ++ memset (arguments.inputs, 0, (arguments.input_max + 1) ++ * sizeof (arguments.inputs[0])); ++ ++ /* Parse our arguments */ ++ if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0) ++ grub_util_error ("%s", _("Error in parsing command line arguments\n")); ++ ++ /* If there's no inputs in argv, add one for stdin */ ++ if (!arguments.ninputs) ++ { ++ arguments.ninputs = 1; ++ arguments.inputs[0] = xmalloc (2); ++ strcpy(arguments.inputs[0], "-"); ++ } ++ ++ for (i = 0; i < arguments.ninputs; i++) ++ add_input(arguments.inputs[i], &package_names, &n_package_names); ++ ++ if (package_names == NULL || n_package_names < 1) ++ grub_util_error ("%s", _("Invalid input\n")); ++ ++ qsort (package_names, n_package_names, sizeof (char *), ++ package_version_compare); ++ ++ /* send sorted list to stdout */ ++ for (i = 0; i < n_package_names; i++) ++ { ++ fprintf (stdout, "%s\n", package_names[i]); ++ free (package_names[i]); ++ } ++ ++ free (package_names); ++ for (i = 0; i < arguments.ninputs; i++) ++ free (arguments.inputs[i]); ++ ++ free (arguments.inputs); ++ ++ return 0; ++} +-- +2.14.3 + diff --git a/0082-Add-friendly-grub2-password-config-tool-985962.patch b/0082-Add-friendly-grub2-password-config-tool-985962.patch new file mode 100644 index 0000000..d5b2e6e --- /dev/null +++ b/0082-Add-friendly-grub2-password-config-tool-985962.patch @@ -0,0 +1,274 @@ +From f7574b40f89ded29d82e5cfdb7494f8884bc1cdb Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Thu, 25 Jun 2015 11:13:11 -0400 +Subject: [PATCH 082/123] Add friendly grub2 password config tool (#985962) + +Provided a tool for users to reset the grub2 root user password +without having to alter the grub.cfg. The hashed password now +lives in a root-only-readable configuration file. + +Resolves: rhbz#985962 +--- + .gitignore | 1 + + Makefile.util.def | 13 +++++ + configure.ac | 1 + + util/grub-mkconfig.in | 2 + + util/grub-setpassword.8 | 28 +++++++++++ + util/grub-setpassword.in | 123 +++++++++++++++++++++++++++++++++++++++++++++++ + util/grub.d/01_users.in | 11 +++++ + 7 files changed, 179 insertions(+) + create mode 100644 util/grub-setpassword.8 + create mode 100644 util/grub-setpassword.in + create mode 100644 util/grub.d/01_users.in + +diff --git a/.gitignore b/.gitignore +index 7697877ca..53a391e62 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -127,6 +127,7 @@ grub-render-label + grub-rpm-sort + grub-script-check + grub-set-default ++grub-setpassword + grub-shell + grub-shell-tester + grub-sparc64-setup +diff --git a/Makefile.util.def b/Makefile.util.def +index d846b81b5..226c46b2d 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -439,6 +439,12 @@ script = { + installdir = grubconf; + }; + ++script = { ++ name = '01_users'; ++ common = util/grub.d/01_users.in; ++ installdir = grubconf; ++}; ++ + script = { + name = '10_windows'; + common = util/grub.d/10_windows.in; +@@ -721,6 +727,13 @@ script = { + installdir = sbin; + }; + ++script = { ++ name = grub-setpassword; ++ common = util/grub-setpassword.in; ++ mansection = 8; ++ installdir = sbin; ++}; ++ + script = { + name = grub-mkconfig_lib; + common = util/grub-mkconfig_lib.in; +diff --git a/configure.ac b/configure.ac +index d5e8d90f3..67ff20cfd 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) + grub_TRANSFORM([grub-mkrescue]) + grub_TRANSFORM([grub-probe]) + grub_TRANSFORM([grub-reboot]) ++grub_TRANSFORM([grub-setpassword]) + grub_TRANSFORM([grub-rpm-sort]) + grub_TRANSFORM([grub-script-check]) + grub_TRANSFORM([grub-set-default]) +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 9d595ac05..fb8724708 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -263,6 +263,8 @@ for i in "${grub_mkconfig_dir}"/* ; do + *~) ;; + # emacsen autosave files. FIXME: support other editors + */\#*\#) ;; ++ # rpm config files of yore. ++ *.rpmsave|*.rpmnew|*.rpmorig) ;; + *) + if grub_file_is_not_garbage "$i" && test -x "$i" ; then + echo +diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 +new file mode 100644 +index 000000000..49200a848 +--- /dev/null ++++ b/util/grub-setpassword.8 +@@ -0,0 +1,28 @@ ++.TH GRUB-SETPASSWORD 3 "Thu Jun 25 2015" ++.SH NAME ++\fBgrub-setpassword\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. ++ ++.SH SYNOPSIS ++\fBgrub-setpassword\fR [OPTION] ++ ++.SH DESCRIPTION ++\fBgrub-setpassword\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. ++ ++The file has the format: ++GRUB2_PASSWORD=<\fIhashed password\fR>. ++ ++.SH OPTIONS ++.TP ++-h, --help ++Display program usage and exit. ++.TP ++-v, --version ++Display the current version. ++.TP ++-o, --output[=\fIDIRECTORY PATH\fR] ++Choose the file path to which user.cfg will be written. ++ ++.SH SEE ALSO ++.BR "info grub" ++ ++.BR "info grub2-mkpasswd-pbkdf2" +diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in +new file mode 100644 +index 000000000..dd76f00fc +--- /dev/null ++++ b/util/grub-setpassword.in +@@ -0,0 +1,123 @@ ++#!/bin/sh -e ++ ++if [ -d /sys/firmware/efi/efivars/ ]; then ++ grubdir=`echo "/@bootdirname@/efi/EFI/redhat/" | sed 's,//*,/,g'` ++else ++ grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` ++fi ++ ++PACKAGE_VERSION="@PACKAGE_VERSION@" ++PACKAGE_NAME="@PACKAGE_NAME@" ++self=`basename $0` ++bindir="@bindir@" ++grub_mkpasswd="${bindir}/@grub_mkpasswd_pbkdf2@" ++ ++# Usage: usage ++# Print the usage. ++usage () { ++ cat <&2 ++ exit 1 ++ fi ++ echo $1 ++} ++ ++# Ensure that it's the root user running this script ++if [ "${EUID}" -ne 0 ]; then ++ echo "The grub bootloader password may only be set by root." ++ usage ++ exit 2 ++fi ++ ++# Check the arguments. ++while test $# -gt 0 ++do ++ option=$1 ++ shift ++ ++ case "$option" in ++ -h | --help) ++ usage ++ exit 0 ;; ++ -v | --version) ++ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" ++ exit 0 ;; ++ -o | --output) ++ OUTPUT_PATH=`argument $option "$@"`; shift ;; ++ --output=*) ++ OUTPUT_PATH=`echo "$option" | sed 's/--output=//'` ;; ++ -o=*) ++ OUTPUT_PATH=`echo "$option" | sed 's/-o=//'` ;; ++ esac ++done ++ ++# set user input or default path for user.cfg file ++if [ -z "${OUTPUT_PATH}" ]; then ++ OUTPUT_PATH="${grubdir}" ++fi ++ ++if [ ! -d "${OUTPUT_PATH}" ]; then ++ echo "${OUTPUT_PATH} does not exist." ++ usage ++ exit 2; ++fi ++ ++ttyopt=$(stty -g) ++fixtty() { ++ stty ${ttyopt} ++} ++ ++trap fixtty EXIT ++stty -echo ++ ++# prompt & confirm new grub2 root user password ++echo -n "Enter password: " ++read PASSWORD ++echo ++echo -n "Confirm password: " ++read PASSWORD_CONFIRM ++echo ++stty ${ttyopt} ++ ++getpass() { ++ local P0 ++ local P1 ++ P0="$1" && shift ++ P1="$1" && shift ++ ++ ( echo ${P0} ; echo ${P1} ) | \ ++ ${grub_mkpasswd} | \ ++ grep -v '[eE]nter password:' | \ ++ sed -e "s/PBKDF2 hash of your password is //" ++} ++ ++MYPASS="$(getpass "${PASSWORD}" "${PASSWORD_CONFIRM}")" ++if [ -z "${MYPASS}" ]; then ++ echo "${self}: error: empty password" 1>&2 ++ exit 1 ++fi ++ ++# on the ESP, these will fail to set the permissions, but it's okay because ++# the directory is protected. ++install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : ++chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : ++echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" +diff --git a/util/grub.d/01_users.in b/util/grub.d/01_users.in +new file mode 100644 +index 000000000..db2f44bfb +--- /dev/null ++++ b/util/grub.d/01_users.in +@@ -0,0 +1,11 @@ ++#!/bin/sh -e ++cat << EOF ++if [ -f \${prefix}/user.cfg ]; then ++ source \${prefix}/user.cfg ++ if [ -n "\${GRUB2_PASSWORD}" ]; then ++ set superusers="root" ++ export superusers ++ password_pbkdf2 root \${GRUB2_PASSWORD} ++ fi ++fi ++EOF +-- +2.14.3 + diff --git a/0082-Re-work-some-intricacies-of-PE-loading.patch b/0082-Re-work-some-intricacies-of-PE-loading.patch deleted file mode 100644 index 094b519..0000000 --- a/0082-Re-work-some-intricacies-of-PE-loading.patch +++ /dev/null @@ -1,353 +0,0 @@ -From e2b22111a8ec58091603fc785f54b1b998888735 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 9 Jun 2016 12:22:29 -0400 -Subject: [PATCH 82/90] Re-work some intricacies of PE loading. - -The PE spec is not a well written document, and awesomely every place -where there's an ambiguous way to read something, Windows' bootmgfw.efi -takes a different read than either of them. ---- - grub-core/loader/efi/chainloader.c | 156 +++++++++++++++++++++++++++++-------- - include/grub/efi/pe32.h | 32 +++++++- - 2 files changed, 152 insertions(+), 36 deletions(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index c4184fa..323f873 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -297,7 +297,7 @@ image_is_64_bit (grub_pe_header_t *pe_hdr) - return 0; - } - --static const grub_uint16_t machine_type = -+static const grub_uint16_t machine_type __attribute__((__unused__)) = - #if defined(__x86_64__) - GRUB_PE32_MACHINE_X86_64; - #elif defined(__aarch64__) -@@ -363,10 +363,10 @@ relocate_coff (pe_coff_loader_image_context_t *context, - - reloc_base = image_address (orig, size, section->raw_data_offset); - reloc_base_end = image_address (orig, size, section->raw_data_offset -- + section->virtual_size - 1); -+ + section->virtual_size); - -- grub_dprintf ("chain", "reloc_base %p reloc_base_end %p\n", reloc_base, -- reloc_base_end); -+ grub_dprintf ("chain", "relocate_coff(): reloc_base %p reloc_base_end %p\n", -+ reloc_base, reloc_base_end); - - if (!reloc_base && !reloc_base_end) - return GRUB_EFI_SUCCESS; -@@ -503,12 +503,13 @@ handle_image (void *data, grub_efi_uint32_t datasize) - grub_efi_status_t efi_status; - char *buffer = NULL; - char *buffer_aligned = NULL; -- grub_efi_uint32_t i, size; -+ grub_efi_uint32_t i; - struct grub_pe32_section_table *section; - char *base, *end; - pe_coff_loader_image_context_t context; - grub_uint32_t section_alignment; - grub_uint32_t buffer_size; -+ int found_entry_point = 0; - - b = grub_efi_system_table->boot_services; - -@@ -522,8 +523,28 @@ handle_image (void *data, grub_efi_uint32_t datasize) - goto error_exit; - } - -+ /* -+ * The spec says, uselessly, of SectionAlignment: -+ * ===== -+ * The alignment (in bytes) of sections when they are loaded into -+ * memory. It must be greater than or equal to FileAlignment. The -+ * default is the page size for the architecture. -+ * ===== -+ * Which doesn't tell you whose responsibility it is to enforce the -+ * "default", or when. It implies that the value in the field must -+ * be > FileAlignment (also poorly defined), but it appears visual -+ * studio will happily write 512 for FileAlignment (its default) and -+ * 0 for SectionAlignment, intending to imply PAGE_SIZE. -+ * -+ * We only support one page size, so if it's zero, nerf it to 4096. -+ */ - section_alignment = context.section_alignment; -+ if (section_alignment == 0) -+ section_alignment = 4096; -+ - buffer_size = context.image_size + section_alignment; -+ grub_dprintf ("chain", "image size is %08lx, datasize is %08x\n", -+ context.image_size, datasize); - - efi_status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, - buffer_size, &buffer); -@@ -535,7 +556,6 @@ handle_image (void *data, grub_efi_uint32_t datasize) - } - - buffer_aligned = (char *)ALIGN_UP ((grub_addr_t)buffer, section_alignment); -- - if (!buffer_aligned) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -@@ -544,27 +564,62 @@ handle_image (void *data, grub_efi_uint32_t datasize) - - grub_memcpy (buffer_aligned, data, context.size_of_headers); - -+ entry_point = image_address (buffer_aligned, context.image_size, -+ context.entry_point); -+ -+ grub_dprintf ("chain", "entry_point: %p\n", entry_point); -+ if (!entry_point) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid entry point"); -+ goto error_exit; -+ } -+ - char *reloc_base, *reloc_base_end; -- reloc_base = image_address (buffer_aligned, datasize, -+ grub_dprintf ("chain", "reloc_dir: %p reloc_size: 0x%08x\n", -+ (void *)(unsigned long long)context.reloc_dir->rva, -+ context.reloc_dir->size); -+ reloc_base = image_address (buffer_aligned, context.image_size, - context.reloc_dir->rva); - /* RelocBaseEnd here is the address of the last byte of the table */ -- reloc_base_end = image_address (buffer_aligned, datasize, -+ reloc_base_end = image_address (buffer_aligned, context.image_size, - context.reloc_dir->rva - + context.reloc_dir->size - 1); -+ grub_dprintf ("chain", "reloc_base: %p reloc_base_end: %p\n", -+ reloc_base, reloc_base_end); -+ - struct grub_pe32_section_table *reloc_section = NULL; - - section = context.first_section; - for (i = 0; i < context.number_of_sections; i++, section++) - { -- size = section->virtual_size; -- if (size > section->raw_data_size) -- size = section->raw_data_size; -+ char name[9]; - - base = image_address (buffer_aligned, context.image_size, - section->virtual_address); - end = image_address (buffer_aligned, context.image_size, -- section->virtual_address + size - 1); -+ section->virtual_address + section->virtual_size -1); - -+ grub_strncpy(name, section->name, 9); -+ name[8] = '\0'; -+ grub_dprintf ("chain", "Section %d \"%s\" at %p..%p\n", i, -+ name, base, end); -+ -+ if (end < base) -+ { -+ grub_dprintf ("chain", " base is %p but end is %p... bad.\n", -+ base, end); -+ grub_error (GRUB_ERR_BAD_ARGUMENT, -+ "Image has invalid negative size"); -+ goto error_exit; -+ } -+ -+ if (section->virtual_address <= context.entry_point && -+ (section->virtual_address + section->raw_data_size - 1) -+ > context.entry_point) -+ { -+ found_entry_point++; -+ grub_dprintf ("chain", " section contains entry point\n"); -+ } - - /* We do want to process .reloc, but it's often marked - * discardable, so we don't want to memcpy it. */ -@@ -583,21 +638,46 @@ handle_image (void *data, grub_efi_uint32_t datasize) - if (section->raw_data_size && section->virtual_size && - base && end && reloc_base == base && reloc_base_end == end) - { -+ grub_dprintf ("chain", " section is relocation section\n"); - reloc_section = section; - } -+ else -+ { -+ grub_dprintf ("chain", " section is not reloc section?\n"); -+ grub_dprintf ("chain", " rds: 0x%08x, vs: %08x\n", -+ section->raw_data_size, section->virtual_size); -+ grub_dprintf ("chain", " base: %p end: %p\n", base, end); -+ grub_dprintf ("chain", " reloc_base: %p reloc_base_end: %p\n", -+ reloc_base, reloc_base_end); -+ } - } - -- if (section->characteristics && GRUB_PE32_SCN_MEM_DISCARDABLE) -- continue; -+ grub_dprintf ("chain", " Section characteristics are %08x\n", -+ section->characteristics); -+ grub_dprintf ("chain", " Section virtual size: %08x\n", -+ section->virtual_size); -+ grub_dprintf ("chain", " Section raw_data size: %08x\n", -+ section->raw_data_size); -+ if (section->characteristics & GRUB_PE32_SCN_MEM_DISCARDABLE) -+ { -+ grub_dprintf ("chain", " Discarding section\n"); -+ continue; -+ } - - if (!base || !end) - { -+ grub_dprintf ("chain", " section is invalid\n"); - grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid section size"); - goto error_exit; - } - -- if (section->virtual_address < context.size_of_headers || -- section->raw_data_offset < context.size_of_headers) -+ if (section->characteristics & GRUB_PE32_SCN_CNT_UNINITIALIZED_DATA) -+ { -+ if (section->raw_data_size != 0) -+ grub_dprintf ("chain", " UNINITIALIZED_DATA section has data?\n"); -+ } -+ else if (section->virtual_address < context.size_of_headers || -+ section->raw_data_offset < context.size_of_headers) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, - "Section %d is inside image headers", i); -@@ -605,13 +685,24 @@ handle_image (void *data, grub_efi_uint32_t datasize) - } - - if (section->raw_data_size > 0) -- grub_memcpy (base, (grub_efi_uint8_t*)data + section->raw_data_offset, -- size); -+ { -+ grub_dprintf ("chain", " copying 0x%08x bytes to %p\n", -+ section->raw_data_size, base); -+ grub_memcpy (base, -+ (grub_efi_uint8_t*)data + section->raw_data_offset, -+ section->raw_data_size); -+ } - -- if (size < section->virtual_size) -- grub_memset (base + size, 0, section->virtual_size - size); -+ if (section->raw_data_size < section->virtual_size) -+ { -+ grub_dprintf ("chain", " padding with 0x%08x bytes at %p\n", -+ section->virtual_size - section->raw_data_size, -+ base + section->raw_data_size); -+ grub_memset (base + section->raw_data_size, 0, -+ section->virtual_size - section->raw_data_size); -+ } - -- grub_dprintf ("chain", "copied section %s\n", section->name); -+ grub_dprintf ("chain", " finished section %s\n", name); - } - - /* 5 == EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC */ -@@ -634,12 +725,15 @@ handle_image (void *data, grub_efi_uint32_t datasize) - } - } - -- entry_point = image_address (buffer_aligned, context.image_size, -- context.entry_point); -- -- if (!entry_point) -+ if (!found_entry_point) - { -- grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid entry point"); -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "entry point is not within sections"); -+ goto error_exit; -+ } -+ if (found_entry_point > 1) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "%d sections contain entry point", -+ found_entry_point); - goto error_exit; - } - -@@ -657,26 +751,24 @@ handle_image (void *data, grub_efi_uint32_t datasize) - li->load_options_size = cmdline_len; - li->file_path = grub_efi_get_media_file_path (file_path); - li->device_handle = dev_handle; -- if (li->file_path) -- { -- grub_printf ("file path: "); -- grub_efi_print_device_path (li->file_path); -- } -- else -+ if (!li->file_path) - { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file path found"); - goto error_exit; - } - -+ grub_dprintf ("chain", "booting via entry point\n"); - efi_status = efi_call_2 (entry_point, grub_efi_image_handle, - grub_efi_system_table); - -+ grub_dprintf ("chain", "entry_point returned %ld\n", efi_status); - grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); - efi_status = efi_call_1 (b->free_pool, buffer); - - return 1; - - error_exit: -+ grub_dprintf ("chain", "error_exit: grub_errno: %d\n", grub_errno); - if (buffer) - efi_call_1 (b->free_pool, buffer); - -diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h -index f79782e..8396bde 100644 ---- a/include/grub/efi/pe32.h -+++ b/include/grub/efi/pe32.h -@@ -227,12 +227,18 @@ struct grub_pe32_section_table - grub_uint32_t characteristics; - }; - -+#define GRUB_PE32_SCN_TYPE_NO_PAD 0x00000008 - #define GRUB_PE32_SCN_CNT_CODE 0x00000020 - #define GRUB_PE32_SCN_CNT_INITIALIZED_DATA 0x00000040 --#define GRUB_PE32_SCN_MEM_DISCARDABLE 0x02000000 --#define GRUB_PE32_SCN_MEM_EXECUTE 0x20000000 --#define GRUB_PE32_SCN_MEM_READ 0x40000000 --#define GRUB_PE32_SCN_MEM_WRITE 0x80000000 -+#define GRUB_PE32_SCN_CNT_UNINITIALIZED_DATA 0x00000080 -+#define GRUB_PE32_SCN_LNK_OTHER 0x00000100 -+#define GRUB_PE32_SCN_LNK_INFO 0x00000200 -+#define GRUB_PE32_SCN_LNK_REMOVE 0x00000800 -+#define GRUB_PE32_SCN_LNK_COMDAT 0x00001000 -+#define GRUB_PE32_SCN_GPREL 0x00008000 -+#define GRUB_PE32_SCN_MEM_16BIT 0x00020000 -+#define GRUB_PE32_SCN_MEM_LOCKED 0x00040000 -+#define GRUB_PE32_SCN_MEM_PRELOAD 0x00080000 - - #define GRUB_PE32_SCN_ALIGN_1BYTES 0x00100000 - #define GRUB_PE32_SCN_ALIGN_2BYTES 0x00200000 -@@ -241,10 +247,28 @@ struct grub_pe32_section_table - #define GRUB_PE32_SCN_ALIGN_16BYTES 0x00500000 - #define GRUB_PE32_SCN_ALIGN_32BYTES 0x00600000 - #define GRUB_PE32_SCN_ALIGN_64BYTES 0x00700000 -+#define GRUB_PE32_SCN_ALIGN_128BYTES 0x00800000 -+#define GRUB_PE32_SCN_ALIGN_256BYTES 0x00900000 -+#define GRUB_PE32_SCN_ALIGN_512BYTES 0x00A00000 -+#define GRUB_PE32_SCN_ALIGN_1024BYTES 0x00B00000 -+#define GRUB_PE32_SCN_ALIGN_2048BYTES 0x00C00000 -+#define GRUB_PE32_SCN_ALIGN_4096BYTES 0x00D00000 -+#define GRUB_PE32_SCN_ALIGN_8192BYTES 0x00E00000 - - #define GRUB_PE32_SCN_ALIGN_SHIFT 20 - #define GRUB_PE32_SCN_ALIGN_MASK 7 - -+#define GRUB_PE32_SCN_LNK_NRELOC_OVFL 0x01000000 -+#define GRUB_PE32_SCN_MEM_DISCARDABLE 0x02000000 -+#define GRUB_PE32_SCN_MEM_NOT_CACHED 0x04000000 -+#define GRUB_PE32_SCN_MEM_NOT_PAGED 0x08000000 -+#define GRUB_PE32_SCN_MEM_SHARED 0x10000000 -+#define GRUB_PE32_SCN_MEM_EXECUTE 0x20000000 -+#define GRUB_PE32_SCN_MEM_READ 0x40000000 -+#define GRUB_PE32_SCN_MEM_WRITE 0x80000000 -+ -+ -+ - #define GRUB_PE32_SIGNATURE_SIZE 4 - - struct grub_pe32_header --- -2.9.3 - diff --git a/0083-Fix-race-in-EFI-validation.patch b/0083-Fix-race-in-EFI-validation.patch new file mode 100644 index 0000000..bdf1896 --- /dev/null +++ b/0083-Fix-race-in-EFI-validation.patch @@ -0,0 +1,97 @@ +From a605e7af01dc697021b96fe6fbaf92ef3fca017c Mon Sep 17 00:00:00 2001 +From: Matthew Garrett +Date: Tue, 14 Jul 2015 16:58:51 -0700 +Subject: [PATCH 083/123] Fix race in EFI validation + +--- + grub-core/loader/i386/efi/linux.c | 44 ++++++++++----------------------------- + 1 file changed, 11 insertions(+), 33 deletions(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index e5b778577..7ccf32d9d 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -154,7 +154,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_file_t file = 0; + struct linux_kernel_header lh; + grub_ssize_t len, start, filelen; +- void *kernel; ++ void *kernel = NULL; + + grub_dl_ref (my_mod); + +@@ -191,10 +191,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- grub_file_seek (file, 0); +- +- grub_free(kernel); +- + params = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(16384)); + + if (! params) +@@ -203,15 +199,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- memset (params, 0, 16384); ++ grub_memset (params, 0, 16384); + +- if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) +- { +- if (!grub_errno) +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +- argv[0]); +- goto fail; +- } ++ grub_memcpy (&lh, kernel, sizeof (lh)); + + if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) + { +@@ -271,27 +261,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- if (grub_file_seek (file, start) == (grub_off_t) -1) +- { +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +- argv[0]); +- goto fail; +- } ++ grub_memcpy (kernel_mem, (char *)kernel + start, len); ++ grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); ++ loaded=1; + +- if (grub_file_read (file, kernel_mem, len) != len && !grub_errno) +- { +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +- argv[0]); +- } +- +- if (grub_errno == GRUB_ERR_NONE) +- { +- grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); +- loaded = 1; +- lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; +- } +- +- memcpy(params, &lh, 2 * 512); ++ lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; ++ grub_memcpy (params, &lh, 2 * 512); + + params->type_of_loader = 0x21; + +@@ -300,6 +275,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + if (file) + grub_file_close (file); + ++ if (kernel) ++ grub_free (kernel); ++ + if (grub_errno != GRUB_ERR_NONE) + { + grub_dl_unref (my_mod); +-- +2.14.3 + diff --git a/0083-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch b/0083-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch deleted file mode 100644 index c0458e9..0000000 --- a/0083-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch +++ /dev/null @@ -1,386 +0,0 @@ -From 8b4deb97529ba7ff689a11639f2a5bfdb29ad2ea Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 10 Jun 2016 14:06:15 -0400 -Subject: [PATCH 83/90] Rework even more of efi chainload so non-sb cases work - right. - -This ensures that if shim protocol is not loaded, or is loaded but shim -is disabled, we will fall back to a correct load method for the efi -chain loader. - -Here's what I tested with this version: - -results expected actual ------------------------------------------------------------- -sb + enabled + shim + fedora success success -sb + enabled + shim + win success success -sb + enabled + grub + fedora fail fail -sb + enabled + grub + win fail fail - -sb + mokdisabled + shim + fedora success success -sb + mokdisabled + shim + win success success -sb + mokdisabled + grub + fedora fail fail -sb + mokdisabled + grub + win fail fail - -sb disabled + shim + fedora success success* -sb disabled + shim + win success success* -sb disabled + grub + fedora success success -sb disabled + grub + win success success - -nosb + shim + fedora success success* -nosb + shim + win success success* -nosb + grub + fedora success success -nosb + grub + win success success - -* for some reason shim protocol is being installed in these cases, and I - can't see why, but I think it may be this firmware build returning an - erroneous value. But this effectively falls back to the mokdisabled - behavior, which works correctly, and the presence of the "grub" (i.e. - no shim) tests effectively tests the desired behavior here. - -Resolves: rhbz#1344512 - -Signed-off-by: Peter Jones ---- - grub-core/kern/efi/sb.c | 14 +++-- - grub-core/loader/arm64/linux.c | 4 +- - grub-core/loader/efi/chainloader.c | 115 ++++++++++++++++++++++--------------- - grub-core/loader/efi/linux.c | 13 +++-- - grub-core/loader/i386/efi/linux.c | 10 +++- - include/grub/efi/linux.h | 2 +- - 6 files changed, 99 insertions(+), 59 deletions(-) - -diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c -index a41b6c5..d74778b 100644 ---- a/grub-core/kern/efi/sb.c -+++ b/grub-core/kern/efi/sb.c -@@ -36,14 +36,20 @@ grub_efi_secure_boot (void) - grub_efi_boolean_t ret = 0; - - secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -- - if (datasize != 1 || !secure_boot) -- goto out; -+ { -+ grub_dprintf ("secureboot", "No SecureBoot variable\n"); -+ goto out; -+ } -+ grub_dprintf ("secureboot", "SecureBoot: %d\n", *secure_boot); - - setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -- - if (datasize != 1 || !setup_mode) -- goto out; -+ { -+ grub_dprintf ("secureboot", "No SetupMode variable\n"); -+ goto out; -+ } -+ grub_dprintf ("secureboot", "SetupMode: %d\n", *setup_mode); - - if (*secure_boot && !*setup_mode) - ret = 1; -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 4756ef7..f83820e 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -251,6 +251,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_file_t file = 0; - struct grub_arm64_linux_kernel_header lh; - struct grub_arm64_linux_pe_header *pe; -+ int rc; - - grub_dl_ref (my_mod); - -@@ -295,7 +296,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); - -- if (!grub_linuxefi_secure_validate (kernel_addr, kernel_size)) -+ rc = grub_linuxefi_secure_validate (kernel_addr, kernel_size); -+ if (rc < 0) - { - grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); - goto fail; -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 323f873..49a7662 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -178,7 +178,6 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) - /* Fill the file path for the directory. */ - d = (grub_efi_device_path_t *) ((char *) file_path - + ((char *) d - (char *) dp)); -- grub_efi_print_device_path (d); - copy_file_path ((grub_efi_file_path_device_path_t *) d, - dir_start, dir_end - dir_start); - -@@ -248,10 +247,9 @@ read_header (void *data, grub_efi_uint32_t size, - grub_efi_status_t status; - - shim_lock = grub_efi_locate_protocol (&guid, NULL); -- - if (!shim_lock) - { -- grub_error (GRUB_ERR_BAD_ARGUMENT, "no shim lock protocol"); -+ grub_dprintf ("chain", "no shim lock protocol"); - return 0; - } - -@@ -276,7 +274,7 @@ read_header (void *data, grub_efi_uint32_t size, - break; - } - -- return 0; -+ return -1; - } - - static void* -@@ -510,17 +508,24 @@ handle_image (void *data, grub_efi_uint32_t datasize) - grub_uint32_t section_alignment; - grub_uint32_t buffer_size; - int found_entry_point = 0; -+ int rc; - - b = grub_efi_system_table->boot_services; - -- if (read_header (data, datasize, &context)) -+ rc = read_header (data, datasize, &context); -+ if (rc < 0) - { -- grub_dprintf ("chain", "Succeed to read header\n"); -+ grub_dprintf ("chain", "Failed to read header\n"); -+ goto error_exit; -+ } -+ else if (rc == 0) -+ { -+ grub_dprintf ("chain", "Secure Boot is not enabled\n"); -+ return 0; - } - else - { -- grub_dprintf ("chain", "Failed to read header\n"); -- goto error_exit; -+ grub_dprintf ("chain", "Header read without error\n"); - } - - /* -@@ -793,9 +798,55 @@ grub_secureboot_chainloader_unload (void) - } - - static grub_err_t -+grub_load_and_start_image(void *boot_image) -+{ -+ grub_efi_boot_services_t *b; -+ grub_efi_status_t status; -+ grub_efi_loaded_image_t *loaded_image; -+ -+ b = grub_efi_system_table->boot_services; -+ -+ status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, -+ boot_image, fsize, &image_handle); -+ if (status != GRUB_EFI_SUCCESS) -+ { -+ if (status == GRUB_EFI_OUT_OF_RESOURCES) -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources"); -+ else -+ grub_error (GRUB_ERR_BAD_OS, "cannot load image"); -+ return -1; -+ } -+ -+ /* LoadImage does not set a device handler when the image is -+ loaded from memory, so it is necessary to set it explicitly here. -+ This is a mess. */ -+ loaded_image = grub_efi_get_loaded_image (image_handle); -+ if (! loaded_image) -+ { -+ grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); -+ return -1; -+ } -+ loaded_image->device_handle = dev_handle; -+ -+ if (cmdline) -+ { -+ loaded_image->load_options = cmdline; -+ loaded_image->load_options_size = cmdline_len; -+ } -+ -+ return 0; -+} -+ -+static grub_err_t - grub_secureboot_chainloader_boot (void) - { -- handle_image ((void *)address, fsize); -+ int rc; -+ rc = handle_image ((void *)address, fsize); -+ if (rc == 0) -+ { -+ grub_load_and_start_image((void *)address); -+ } -+ - grub_loader_unset (); - return grub_errno; - } -@@ -809,9 +860,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - grub_efi_boot_services_t *b; - grub_device_t dev = 0; - grub_efi_device_path_t *dp = 0; -- grub_efi_loaded_image_t *loaded_image; - char *filename; - void *boot_image = 0; -+ int rc; - - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -898,9 +949,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - if (! file_path) - goto fail; - -- grub_printf ("file path: "); -- grub_efi_print_device_path (file_path); -- - fsize = grub_file_size (file); - if (!fsize) - { -@@ -975,51 +1023,28 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - } - #endif - -- if (grub_linuxefi_secure_validate((void *)address, fsize)) -+ rc = grub_linuxefi_secure_validate((void *)address, fsize); -+ grub_dprintf ("chain", "linuxefi_secure_validate: %d\n", rc); -+ if (rc > 0) - { - grub_file_close (file); - grub_loader_set (grub_secureboot_chainloader_boot, - grub_secureboot_chainloader_unload, 0); - return 0; - } -- -- status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, -- boot_image, fsize, &image_handle); -- if (status != GRUB_EFI_SUCCESS) -+ else if (rc == 0) - { -- if (status == GRUB_EFI_OUT_OF_RESOURCES) -- grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources"); -- else -- grub_error (GRUB_ERR_BAD_OS, "cannot load image"); -- -- goto fail; -- } -- -- /* LoadImage does not set a device handler when the image is -- loaded from memory, so it is necessary to set it explicitly here. -- This is a mess. */ -- loaded_image = grub_efi_get_loaded_image (image_handle); -- if (! loaded_image) -- { -- grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); -- goto fail; -- } -- loaded_image->device_handle = dev_handle; -+ grub_load_and_start_image(boot_image); -+ grub_file_close (file); -+ grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); - -- if (cmdline) -- { -- loaded_image->load_options = cmdline; -- loaded_image->load_options_size = cmdline_len; -+ return 0; - } - - grub_file_close (file); - grub_device_close (dev); - -- grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); -- return 0; -- -- fail: -- -+fail: - if (dev) - grub_device_close (dev); - -diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index aea378a..8890bdf 100644 ---- a/grub-core/loader/efi/linux.c -+++ b/grub-core/loader/efi/linux.c -@@ -33,21 +33,24 @@ struct grub_efi_shim_lock - }; - typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; - --grub_efi_boolean_t -+int - grub_linuxefi_secure_validate (void *data, grub_uint32_t size) - { - grub_efi_guid_t guid = SHIM_LOCK_GUID; - grub_efi_shim_lock_t *shim_lock; -+ grub_efi_status_t status; - - shim_lock = grub_efi_locate_protocol(&guid, NULL); -- -+ grub_dprintf ("secureboot", "shim_lock: %p\n", shim_lock); - if (!shim_lock) -- return 1; -+ return 0; - -- if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) -+ status = shim_lock->verify(data, size); -+ grub_dprintf ("secureboot", "shim_lock->verify(): %ld\n", status); -+ if (status == GRUB_EFI_SUCCESS) - return 1; - -- return 0; -+ return -1; - } - - typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 7ccf32d..82f75b7 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -155,6 +155,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - struct linux_kernel_header lh; - grub_ssize_t len, start, filelen; - void *kernel = NULL; -+ int rc; - - grub_dl_ref (my_mod); - -@@ -180,13 +181,16 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - if (grub_file_read (file, kernel, filelen) != filelen) - { -- grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), argv[0]); -+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), -+ argv[0]); - goto fail; - } - -- if (! grub_linuxefi_secure_validate (kernel, filelen)) -+ rc = grub_linuxefi_secure_validate (kernel, filelen); -+ if (rc < 0) - { -- grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); -+ grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), -+ argv[0]); - grub_free (kernel); - goto fail; - } -diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h -index d9ede36..0033d93 100644 ---- a/include/grub/efi/linux.h -+++ b/include/grub/efi/linux.h -@@ -22,7 +22,7 @@ - #include - #include - --grub_efi_boolean_t -+int - EXPORT_FUNC(grub_linuxefi_secure_validate) (void *data, grub_uint32_t size); - grub_err_t - EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, --- -2.9.3 - diff --git a/0084-linuxefi-fix-double-free-on-verification-failure.patch b/0084-linuxefi-fix-double-free-on-verification-failure.patch deleted file mode 100644 index e783733..0000000 --- a/0084-linuxefi-fix-double-free-on-verification-failure.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0a3a4d0b69b5d68f3e4b6b74fe2e6b5d4dcace4f Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 14 Jun 2016 09:50:25 -0400 -Subject: [PATCH 84/90] linuxefi: fix double free on verification failure. - -Signed-off-by: Peter Jones ---- - grub-core/loader/i386/efi/linux.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 82f75b7..010bf98 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -191,7 +191,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - { - grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), - argv[0]); -- grub_free (kernel); - goto fail; - } - --- -2.9.3 - diff --git a/0084-ppc64le-sync-mkconfig-to-disk-1212114.patch b/0084-ppc64le-sync-mkconfig-to-disk-1212114.patch new file mode 100644 index 0000000..978373e --- /dev/null +++ b/0084-ppc64le-sync-mkconfig-to-disk-1212114.patch @@ -0,0 +1,42 @@ +From 63efe6a207f59ffa9e55cc10a0aed272f3571227 Mon Sep 17 00:00:00 2001 +From: Don Zickus +Date: Wed, 22 Jul 2015 13:59:55 -0400 +Subject: [PATCH 084/123] ppc64le sync mkconfig to disk (#1212114) + +If creating a new grub2 entry using grub2-mkconfig, the entry is not +immediately sync'd to disk. If a crash happens before the writeback, +the subsequent reboot fails because the grub2.cfg is corrupted. + +Address this by forcing all the changes (mainly the fs meta data) to disk +before finishing the grub2 conf changes. + +Tested by 'grub2-mkconfig -o /etc/grub22.cfg; echo c > /proc/sysrq-trigger'. + +Before, the machine would panic and on reboot be stuck without a grub.cfg +to read. After, works as expected. + +Resolves: rhbz#1212114 +--- + util/grub-mkconfig.in | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index fb8724708..73a18f723 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -294,3 +294,12 @@ fi + + gettext "done" >&2 + echo >&2 ++ ++# make sure changes make it to the disk. ++# if /boot is a mountpoint, force the meta data on disk ++# to by-pass writeback delay. ++# PPC64LE-only to deal with Petitboot issues ++ARCH=$(uname -m) ++if [ "${ARCH}" = "ppc64le" ]; then ++ sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot ++fi +-- +2.14.3 + diff --git a/0085-Use-device-part-of-chainloader-target-if-present.patch b/0085-Use-device-part-of-chainloader-target-if-present.patch new file mode 100644 index 0000000..fc4e46f --- /dev/null +++ b/0085-Use-device-part-of-chainloader-target-if-present.patch @@ -0,0 +1,37 @@ +From 9d47b2c482b6db238c99fe106f4b2e3c612f3a91 Mon Sep 17 00:00:00 2001 +From: Raymund Will +Date: Fri, 10 Apr 2015 01:45:02 -0400 +Subject: [PATCH 085/123] Use device part of chainloader target, if present. + +Otherwise chainloading is restricted to '$root', which might not even +be readable by EFI! + +v1. use grub_file_get_device_name() to get device name + +Signed-off-by: Michael Chang +Signed-off-by: Peter Jones +--- + grub-core/loader/efi/chainloader.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 522a716e3..6b47497d7 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -219,8 +219,11 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + if (! file) + goto fail; + +- /* Get the root device's device path. */ +- dev = grub_device_open (0); ++ /* Get the device path from filename. */ ++ char *devname = grub_file_get_device_name (filename); ++ dev = grub_device_open (devname); ++ if (devname) ++ grub_free (devname); + if (! dev) + goto fail; + +-- +2.14.3 + diff --git a/0085-fix-machine-type-test-in-30_os-prober.in.patch b/0085-fix-machine-type-test-in-30_os-prober.in.patch deleted file mode 100644 index fa2b435..0000000 --- a/0085-fix-machine-type-test-in-30_os-prober.in.patch +++ /dev/null @@ -1,25 +0,0 @@ -From be4d338b0c086e9cbbd2d353cd88abad67c000c9 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 11 Jul 2016 13:36:45 -0400 -Subject: [PATCH 85/90] fix machine type test in 30_os-prober.in - -Signed-off-by: Peter Jones ---- - util/grub.d/30_os-prober.in | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index dc98eac..e40274f 100644 ---- a/util/grub.d/30_os-prober.in -+++ b/util/grub.d/30_os-prober.in -@@ -144,6 +144,7 @@ for OS in ${OSPROBED} ; do - sixteenbit="" - linuxefi="linux" - initrdefi="initrd" -+ machine=`uname -m` - case "$machine" in - i?86|x86_64) - sixteenbit="16" --- -2.9.3 - diff --git a/0086-Add-secureboot-support-on-efi-chainloader.patch b/0086-Add-secureboot-support-on-efi-chainloader.patch new file mode 100644 index 0000000..7f9f1c4 --- /dev/null +++ b/0086-Add-secureboot-support-on-efi-chainloader.patch @@ -0,0 +1,800 @@ +From 9cbf35d19f4ffafdf2683acf7b6a320b55bbdfca Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 6 Oct 2015 13:04:37 -0400 +Subject: [PATCH 086/123] Add secureboot support on efi chainloader + +Expand the chainloader to be able to verify the image by means of shim +lock protocol. The PE/COFF image is loaded and relocated by the +chainloader instead of calling LoadImage and StartImage UEFI boot +Service as they require positive verification result from keys enrolled +in KEK or DB. The shim will use MOK in addition to firmware enrolled +keys to verify the image. + +The chainloader module could be used to load other UEFI bootloaders, +such as xen.efi, and could be signed by any of MOK, KEK or DB. + +Based on https://build.opensuse.org/package/view_file/openSUSE:Factory/grub2/grub2-secureboot-chainloader.patch + +Signed-off-by: Peter Jones +--- + grub-core/loader/efi/chainloader.c | 612 ++++++++++++++++++++++++++++++++++--- + include/grub/efi/pe32.h | 20 +- + 2 files changed, 595 insertions(+), 37 deletions(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 6b47497d7..3cbb6c5b8 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -32,6 +32,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include +@@ -46,9 +48,14 @@ static grub_dl_t my_mod; + + static grub_efi_physical_address_t address; + static grub_efi_uintn_t pages; ++static grub_ssize_t fsize; + static grub_efi_device_path_t *file_path; + static grub_efi_handle_t image_handle; + static grub_efi_char16_t *cmdline; ++static grub_ssize_t cmdline_len; ++static grub_efi_handle_t dev_handle; ++ ++static grub_efi_status_t (*entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); + + static grub_err_t + grub_chainloader_unload (void) +@@ -63,6 +70,7 @@ grub_chainloader_unload (void) + grub_free (cmdline); + cmdline = 0; + file_path = 0; ++ dev_handle = 0; + + grub_dl_unref (my_mod); + return GRUB_ERR_NONE; +@@ -187,12 +195,523 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) + return file_path; + } + ++#define SHIM_LOCK_GUID \ ++ { 0x605dab50, 0xe046, 0x4300, { 0xab,0xb6,0x3d,0xd8,0x10,0xdd,0x8b,0x23 } } ++ ++typedef union ++{ ++ struct grub_pe32_header_32 pe32; ++ struct grub_pe32_header_64 pe32plus; ++} grub_pe_header_t; ++ ++struct pe_coff_loader_image_context ++{ ++ grub_efi_uint64_t image_address; ++ grub_efi_uint64_t image_size; ++ grub_efi_uint64_t entry_point; ++ grub_efi_uintn_t size_of_headers; ++ grub_efi_uint16_t image_type; ++ grub_efi_uint16_t number_of_sections; ++ grub_efi_uint32_t section_alignment; ++ struct grub_pe32_section_table *first_section; ++ struct grub_pe32_data_directory *reloc_dir; ++ struct grub_pe32_data_directory *sec_dir; ++ grub_efi_uint64_t number_of_rva_and_sizes; ++ grub_pe_header_t *pe_hdr; ++}; ++ ++typedef struct pe_coff_loader_image_context pe_coff_loader_image_context_t; ++ ++struct grub_efi_shim_lock ++{ ++ grub_efi_status_t (*verify)(void *buffer, ++ grub_efi_uint32_t size); ++ grub_efi_status_t (*hash)(void *data, ++ grub_efi_int32_t datasize, ++ pe_coff_loader_image_context_t *context, ++ grub_efi_uint8_t *sha256hash, ++ grub_efi_uint8_t *sha1hash); ++ grub_efi_status_t (*context)(void *data, ++ grub_efi_uint32_t size, ++ pe_coff_loader_image_context_t *context); ++}; ++ ++typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; ++ ++static grub_efi_boolean_t ++read_header (void *data, grub_efi_uint32_t size, ++ pe_coff_loader_image_context_t *context) ++{ ++ grub_efi_guid_t guid = SHIM_LOCK_GUID; ++ grub_efi_shim_lock_t *shim_lock; ++ grub_efi_status_t status; ++ ++ shim_lock = grub_efi_locate_protocol (&guid, NULL); ++ ++ if (!shim_lock) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "no shim lock protocol"); ++ return 0; ++ } ++ ++ status = shim_lock->context (data, size, context); ++ ++ if (status == GRUB_EFI_SUCCESS) ++ { ++ grub_dprintf ("chain", "context success\n"); ++ return 1; ++ } ++ ++ switch (status) ++ { ++ case GRUB_EFI_UNSUPPORTED: ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "context error unsupported"); ++ break; ++ case GRUB_EFI_INVALID_PARAMETER: ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "context error invalid parameter"); ++ break; ++ default: ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "context error code"); ++ break; ++ } ++ ++ return 0; ++} ++ ++static void* ++image_address (void *image, grub_efi_uint64_t sz, grub_efi_uint64_t adr) ++{ ++ if (adr > sz) ++ return NULL; ++ ++ return ((grub_uint8_t*)image + adr); ++} ++ ++static int ++image_is_64_bit (grub_pe_header_t *pe_hdr) ++{ ++ /* .Magic is the same offset in all cases */ ++ if (pe_hdr->pe32plus.optional_header.magic == GRUB_PE32_PE64_MAGIC) ++ return 1; ++ return 0; ++} ++ ++static const grub_uint16_t machine_type = ++#if defined(__x86_64__) ++ GRUB_PE32_MACHINE_X86_64; ++#elif defined(__aarch64__) ++ GRUB_PE32_MACHINE_ARM64; ++#elif defined(__arm__) ++ GRUB_PE32_MACHINE_ARMTHUMB_MIXED; ++#elif defined(__i386__) || defined(__i486__) || defined(__i686__) ++ GRUB_PE32_MACHINE_I386; ++#elif defined(__ia64__) ++ GRUB_PE32_MACHINE_IA64; ++#else ++#error this architecture is not supported by grub2 ++#endif ++ ++static grub_efi_status_t ++relocate_coff (pe_coff_loader_image_context_t *context, ++ struct grub_pe32_section_table *section, ++ void *orig, void *data) ++{ ++ struct grub_pe32_data_directory *reloc_base, *reloc_base_end; ++ grub_efi_uint64_t adjust; ++ struct grub_pe32_fixup_block *reloc, *reloc_end; ++ char *fixup, *fixup_base, *fixup_data = NULL; ++ grub_efi_uint16_t *fixup_16; ++ grub_efi_uint32_t *fixup_32; ++ grub_efi_uint64_t *fixup_64; ++ grub_efi_uint64_t size = context->image_size; ++ void *image_end = (char *)orig + size; ++ int n = 0; ++ ++ if (image_is_64_bit (context->pe_hdr)) ++ context->pe_hdr->pe32plus.optional_header.image_base = ++ (grub_uint64_t)(unsigned long)data; ++ else ++ context->pe_hdr->pe32.optional_header.image_base = ++ (grub_uint32_t)(unsigned long)data; ++ ++ /* Alright, so here's how this works: ++ * ++ * context->reloc_dir gives us two things: ++ * - the VA the table of base relocation blocks are (maybe) to be ++ * mapped at (reloc_dir->rva) ++ * - the virtual size (reloc_dir->size) ++ * ++ * The .reloc section (section here) gives us some other things: ++ * - the name! kind of. (section->name) ++ * - the virtual size (section->virtual_size), which should be the same ++ * as RelocDir->Size ++ * - the virtual address (section->virtual_address) ++ * - the file section size (section->raw_data_size), which is ++ * a multiple of optional_header->file_alignment. Only useful for image ++ * validation, not really useful for iteration bounds. ++ * - the file address (section->raw_data_offset) ++ * - a bunch of stuff we don't use that's 0 in our binaries usually ++ * - Flags (section->characteristics) ++ * ++ * and then the thing that's actually at the file address is an array ++ * of struct grub_pe32_fixup_block structs with some values packed behind ++ * them. The block_size field of this structure includes the ++ * structure itself, and adding it to that structure's address will ++ * yield the next entry in the array. ++ */ ++ ++ reloc_base = image_address (orig, size, section->raw_data_offset); ++ reloc_base_end = image_address (orig, size, section->raw_data_offset ++ + section->virtual_size - 1); ++ ++ grub_dprintf ("chain", "reloc_base %p reloc_base_end %p\n", reloc_base, ++ reloc_base_end); ++ ++ if (!reloc_base && !reloc_base_end) ++ return GRUB_EFI_SUCCESS; ++ ++ if (!reloc_base || !reloc_base_end) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc table overflows binary"); ++ return GRUB_EFI_UNSUPPORTED; ++ } ++ ++ adjust = (grub_uint64_t)data - context->image_address; ++ if (adjust == 0) ++ return GRUB_EFI_SUCCESS; ++ ++ while (reloc_base < reloc_base_end) ++ { ++ grub_uint16_t *entry; ++ reloc = (struct grub_pe32_fixup_block *)((char*)reloc_base); ++ ++ if ((reloc_base->size == 0) || ++ (reloc_base->size > context->reloc_dir->size)) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, ++ "Reloc %d block size %d is invalid\n", n, ++ reloc_base->size); ++ return GRUB_EFI_UNSUPPORTED; ++ } ++ ++ entry = &reloc->entries[0]; ++ reloc_end = (struct grub_pe32_fixup_block *) ++ ((char *)reloc_base + reloc_base->size); ++ ++ if ((void *)reloc_end < data || (void *)reloc_end > image_end) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc entry %d overflows binary", ++ n); ++ return GRUB_EFI_UNSUPPORTED; ++ } ++ ++ fixup_base = image_address(data, size, reloc_base->rva); ++ ++ if (!fixup_base) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc %d Invalid fixupbase", n); ++ return GRUB_EFI_UNSUPPORTED; ++ } ++ ++ while ((void *)entry < (void *)reloc_end) ++ { ++ fixup = fixup_base + (*entry & 0xFFF); ++ switch ((*entry) >> 12) ++ { ++ case GRUB_PE32_REL_BASED_ABSOLUTE: ++ break; ++ case GRUB_PE32_REL_BASED_HIGH: ++ fixup_16 = (grub_uint16_t *)fixup; ++ *fixup_16 = (grub_uint16_t) ++ (*fixup_16 + ((grub_uint16_t)((grub_uint32_t)adjust >> 16))); ++ if (fixup_data != NULL) ++ { ++ *(grub_uint16_t *) fixup_data = *fixup_16; ++ fixup_data = fixup_data + sizeof (grub_uint16_t); ++ } ++ break; ++ case GRUB_PE32_REL_BASED_LOW: ++ fixup_16 = (grub_uint16_t *)fixup; ++ *fixup_16 = (grub_uint16_t) (*fixup_16 + (grub_uint16_t)adjust); ++ if (fixup_data != NULL) ++ { ++ *(grub_uint16_t *) fixup_data = *fixup_16; ++ fixup_data = fixup_data + sizeof (grub_uint16_t); ++ } ++ break; ++ case GRUB_PE32_REL_BASED_HIGHLOW: ++ fixup_32 = (grub_uint32_t *)fixup; ++ *fixup_32 = *fixup_32 + (grub_uint32_t)adjust; ++ if (fixup_data != NULL) ++ { ++ fixup_data = (char *)ALIGN_UP ((grub_addr_t)fixup_data, sizeof (grub_uint32_t)); ++ *(grub_uint32_t *) fixup_data = *fixup_32; ++ fixup_data += sizeof (grub_uint32_t); ++ } ++ break; ++ case GRUB_PE32_REL_BASED_DIR64: ++ fixup_64 = (grub_uint64_t *)fixup; ++ *fixup_64 = *fixup_64 + (grub_uint64_t)adjust; ++ if (fixup_data != NULL) ++ { ++ fixup_data = (char *)ALIGN_UP ((grub_addr_t)fixup_data, sizeof (grub_uint64_t)); ++ *(grub_uint64_t *) fixup_data = *fixup_64; ++ fixup_data += sizeof (grub_uint64_t); ++ } ++ break; ++ default: ++ grub_error (GRUB_ERR_BAD_ARGUMENT, ++ "Reloc %d unknown relocation type %d", ++ n, (*entry) >> 12); ++ return GRUB_EFI_UNSUPPORTED; ++ } ++ entry += 1; ++ } ++ reloc_base = (struct grub_pe32_data_directory *)reloc_end; ++ n++; ++ } ++ ++ return GRUB_EFI_SUCCESS; ++} ++ ++static grub_efi_device_path_t * ++grub_efi_get_media_file_path (grub_efi_device_path_t *dp) ++{ ++ while (1) ++ { ++ grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); ++ grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); ++ ++ if (type == GRUB_EFI_END_DEVICE_PATH_TYPE) ++ break; ++ else if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE ++ && subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE) ++ return dp; ++ ++ dp = GRUB_EFI_NEXT_DEVICE_PATH (dp); ++ } ++ ++ return NULL; ++} ++ ++static grub_efi_boolean_t ++handle_image (void *data, grub_efi_uint32_t datasize) ++{ ++ grub_efi_boot_services_t *b; ++ grub_efi_loaded_image_t *li, li_bak; ++ grub_efi_status_t efi_status; ++ char *buffer = NULL; ++ char *buffer_aligned = NULL; ++ grub_efi_uint32_t i, size; ++ struct grub_pe32_section_table *section; ++ char *base, *end; ++ pe_coff_loader_image_context_t context; ++ grub_uint32_t section_alignment; ++ grub_uint32_t buffer_size; ++ ++ b = grub_efi_system_table->boot_services; ++ ++ if (read_header (data, datasize, &context)) ++ { ++ grub_dprintf ("chain", "Succeed to read header\n"); ++ } ++ else ++ { ++ grub_dprintf ("chain", "Failed to read header\n"); ++ goto error_exit; ++ } ++ ++ section_alignment = context.section_alignment; ++ buffer_size = context.image_size + section_alignment; ++ ++ efi_status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, ++ buffer_size, &buffer); ++ ++ if (efi_status != GRUB_EFI_SUCCESS) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto error_exit; ++ } ++ ++ buffer_aligned = (char *)ALIGN_UP ((grub_addr_t)buffer, section_alignment); ++ ++ if (!buffer_aligned) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto error_exit; ++ } ++ ++ grub_memcpy (buffer_aligned, data, context.size_of_headers); ++ ++ char *reloc_base, *reloc_base_end; ++ reloc_base = image_address (buffer_aligned, datasize, ++ context.reloc_dir->rva); ++ /* RelocBaseEnd here is the address of the last byte of the table */ ++ reloc_base_end = image_address (buffer_aligned, datasize, ++ context.reloc_dir->rva ++ + context.reloc_dir->size - 1); ++ struct grub_pe32_section_table *reloc_section = NULL; ++ ++ section = context.first_section; ++ for (i = 0; i < context.number_of_sections; i++, section++) ++ { ++ size = section->virtual_size; ++ if (size > section->raw_data_size) ++ size = section->raw_data_size; ++ ++ base = image_address (buffer_aligned, context.image_size, ++ section->virtual_address); ++ end = image_address (buffer_aligned, context.image_size, ++ section->virtual_address + size - 1); ++ ++ ++ /* We do want to process .reloc, but it's often marked ++ * discardable, so we don't want to memcpy it. */ ++ if (grub_memcmp (section->name, ".reloc\0\0", 8) == 0) ++ { ++ if (reloc_section) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, ++ "Image has multiple relocation sections"); ++ goto error_exit; ++ } ++ ++ /* If it has nonzero sizes, and our bounds check ++ * made sense, and the VA and size match RelocDir's ++ * versions, then we believe in this section table. */ ++ if (section->raw_data_size && section->virtual_size && ++ base && end && reloc_base == base && reloc_base_end == end) ++ { ++ reloc_section = section; ++ } ++ } ++ ++ if (section->characteristics && GRUB_PE32_SCN_MEM_DISCARDABLE) ++ continue; ++ ++ if (!base || !end) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid section size"); ++ goto error_exit; ++ } ++ ++ if (section->virtual_address < context.size_of_headers || ++ section->raw_data_offset < context.size_of_headers) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, ++ "Section %d is inside image headers", i); ++ goto error_exit; ++ } ++ ++ if (section->raw_data_size > 0) ++ grub_memcpy (base, (grub_efi_uint8_t*)data + section->raw_data_offset, ++ size); ++ ++ if (size < section->virtual_size) ++ grub_memset (base + size, 0, section->virtual_size - size); ++ ++ grub_dprintf ("chain", "copied section %s\n", section->name); ++ } ++ ++ /* 5 == EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC */ ++ if (context.number_of_rva_and_sizes <= 5) ++ { ++ grub_dprintf ("chain", "image has no relocation entry\n"); ++ goto error_exit; ++ } ++ ++ if (context.reloc_dir->size && reloc_section) ++ { ++ /* run the relocation fixups */ ++ efi_status = relocate_coff (&context, reloc_section, data, ++ buffer_aligned); ++ ++ if (efi_status != GRUB_EFI_SUCCESS) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "relocation failed"); ++ goto error_exit; ++ } ++ } ++ ++ entry_point = image_address (buffer_aligned, context.image_size, ++ context.entry_point); ++ ++ if (!entry_point) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid entry point"); ++ goto error_exit; ++ } ++ ++ li = grub_efi_get_loaded_image (grub_efi_image_handle); ++ if (!li) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "no loaded image available"); ++ goto error_exit; ++ } ++ ++ grub_memcpy (&li_bak, li, sizeof (grub_efi_loaded_image_t)); ++ li->image_base = buffer_aligned; ++ li->image_size = context.image_size; ++ li->load_options = cmdline; ++ li->load_options_size = cmdline_len; ++ li->file_path = grub_efi_get_media_file_path (file_path); ++ li->device_handle = dev_handle; ++ if (li->file_path) ++ { ++ grub_printf ("file path: "); ++ grub_efi_print_device_path (li->file_path); ++ } ++ else ++ { ++ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file path found"); ++ goto error_exit; ++ } ++ ++ efi_status = efi_call_2 (entry_point, grub_efi_image_handle, ++ grub_efi_system_table); ++ ++ grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); ++ efi_status = efi_call_1 (b->free_pool, buffer); ++ ++ return 1; ++ ++error_exit: ++ if (buffer) ++ efi_call_1 (b->free_pool, buffer); ++ ++ return 0; ++} ++ ++static grub_err_t ++grub_secureboot_chainloader_unload (void) ++{ ++ grub_efi_boot_services_t *b; ++ ++ b = grub_efi_system_table->boot_services; ++ efi_call_2 (b->free_pages, address, pages); ++ grub_free (file_path); ++ grub_free (cmdline); ++ cmdline = 0; ++ file_path = 0; ++ dev_handle = 0; ++ ++ grub_dl_unref (my_mod); ++ return GRUB_ERR_NONE; ++} ++ ++static grub_err_t ++grub_secureboot_chainloader_boot (void) ++{ ++ handle_image ((void *)address, fsize); ++ grub_loader_unset (); ++ return grub_errno; ++} ++ + static grub_err_t + grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) + { + grub_file_t file = 0; +- grub_ssize_t size; + grub_efi_status_t status; + grub_efi_boot_services_t *b; + grub_device_t dev = 0; +@@ -200,7 +719,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + grub_efi_loaded_image_t *loaded_image; + char *filename; + void *boot_image = 0; +- grub_efi_handle_t dev_handle = 0; + + if (argc == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); +@@ -212,9 +730,36 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + address = 0; + image_handle = 0; + file_path = 0; ++ dev_handle = 0; + + b = grub_efi_system_table->boot_services; + ++ if (argc > 1) ++ { ++ int i; ++ grub_efi_char16_t *p16; ++ ++ for (i = 1, cmdline_len = 0; i < argc; i++) ++ cmdline_len += grub_strlen (argv[i]) + 1; ++ ++ cmdline_len *= sizeof (grub_efi_char16_t); ++ cmdline = p16 = grub_malloc (cmdline_len); ++ if (! cmdline) ++ goto fail; ++ ++ for (i = 1; i < argc; i++) ++ { ++ char *p8; ++ ++ p8 = argv[i]; ++ while (*p8) ++ *(p16++) = *(p8++); ++ ++ *(p16++) = ' '; ++ } ++ *(--p16) = 0; ++ } ++ + file = grub_file_open (filename); + if (! file) + goto fail; +@@ -263,14 +808,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + grub_printf ("file path: "); + grub_efi_print_device_path (file_path); + +- size = grub_file_size (file); +- if (!size) ++ fsize = grub_file_size (file); ++ if (!fsize) + { + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + goto fail; + } +- pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12); ++ pages = (((grub_efi_uintn_t) fsize + ((1 << 12) - 1)) >> 12); + + status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, + GRUB_EFI_LOADER_CODE, +@@ -284,7 +829,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + } + + boot_image = (void *) ((grub_addr_t) address); +- if (grub_file_read (file, boot_image, size) != size) ++ if (grub_file_read (file, boot_image, fsize) != fsize) + { + if (grub_errno == GRUB_ERR_NONE) + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +@@ -294,7 +839,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + } + + #if defined (__i386__) || defined (__x86_64__) +- if (size >= (grub_ssize_t) sizeof (struct grub_macho_fat_header)) ++ if (fsize >= (grub_ssize_t) sizeof (struct grub_macho_fat_header)) + { + struct grub_macho_fat_header *head = boot_image; + if (head->magic +@@ -303,6 +848,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + grub_uint32_t i; + struct grub_macho_fat_arch *archs + = (struct grub_macho_fat_arch *) (head + 1); ++ ++ if (grub_efi_secure_boot()) ++ { ++ grub_error (GRUB_ERR_BAD_OS, ++ "MACHO binaries are forbidden with Secure Boot"); ++ goto fail; ++ } ++ + for (i = 0; i < grub_cpu_to_le32 (head->nfat_arch); i++) + { + if (GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT (archs[i].cputype)) +@@ -317,21 +870,28 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + > ~grub_cpu_to_le32 (archs[i].size) + || grub_cpu_to_le32 (archs[i].offset) + + grub_cpu_to_le32 (archs[i].size) +- > (grub_size_t) size) ++ > (grub_size_t) fsize) + { + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + goto fail; + } + boot_image = (char *) boot_image + grub_cpu_to_le32 (archs[i].offset); +- size = grub_cpu_to_le32 (archs[i].size); ++ fsize = grub_cpu_to_le32 (archs[i].size); + } + } + #endif + ++ if (grub_linuxefi_secure_validate((void *)address, fsize)) ++ { ++ grub_file_close (file); ++ grub_loader_set (grub_secureboot_chainloader_boot, ++ grub_secureboot_chainloader_unload, 0); ++ return 0; ++ } ++ + status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, +- boot_image, size, +- &image_handle); ++ boot_image, fsize, &image_handle); + if (status != GRUB_EFI_SUCCESS) + { + if (status == GRUB_EFI_OUT_OF_RESOURCES) +@@ -353,33 +913,10 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + } + loaded_image->device_handle = dev_handle; + +- if (argc > 1) ++ if (cmdline) + { +- int i, len; +- grub_efi_char16_t *p16; +- +- for (i = 1, len = 0; i < argc; i++) +- len += grub_strlen (argv[i]) + 1; +- +- len *= sizeof (grub_efi_char16_t); +- cmdline = p16 = grub_malloc (len); +- if (! cmdline) +- goto fail; +- +- for (i = 1; i < argc; i++) +- { +- char *p8; +- +- p8 = argv[i]; +- while (*p8) +- *(p16++) = *(p8++); +- +- *(p16++) = ' '; +- } +- *(--p16) = 0; +- + loaded_image->load_options = cmdline; +- loaded_image->load_options_size = len; ++ loaded_image->load_options_size = cmdline_len; + } + + grub_file_close (file); +@@ -401,6 +938,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + if (address) + efi_call_2 (b->free_pages, address, pages); + ++ if (cmdline) ++ grub_free (cmdline); ++ + grub_dl_unref (my_mod); + + return grub_errno; +diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h +index f79c36c02..f79782e1b 100644 +--- a/include/grub/efi/pe32.h ++++ b/include/grub/efi/pe32.h +@@ -212,7 +212,11 @@ struct grub_pe64_optional_header + struct grub_pe32_section_table + { + char name[8]; +- grub_uint32_t virtual_size; ++ union ++ { ++ grub_uint32_t physical_address; ++ grub_uint32_t virtual_size; ++ }; + grub_uint32_t virtual_address; + grub_uint32_t raw_data_size; + grub_uint32_t raw_data_offset; +@@ -263,6 +267,20 @@ struct grub_pe32_header + #endif + }; + ++struct grub_pe32_header_32 ++{ ++ char signature[GRUB_PE32_SIGNATURE_SIZE]; ++ struct grub_pe32_coff_header coff_header; ++ struct grub_pe32_optional_header optional_header; ++}; ++ ++struct grub_pe32_header_64 ++{ ++ char signature[GRUB_PE32_SIGNATURE_SIZE]; ++ struct grub_pe32_coff_header coff_header; ++ struct grub_pe64_optional_header optional_header; ++}; ++ + struct grub_pe32_fixup_block + { + grub_uint32_t page_rva; +-- +2.14.3 + diff --git a/0086-ppc64le-has-no-separate-boot-mount-1261926.patch b/0086-ppc64le-has-no-separate-boot-mount-1261926.patch deleted file mode 100644 index 2b04641..0000000 --- a/0086-ppc64le-has-no-separate-boot-mount-1261926.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 12a2215a6f13f2503a9e38d84fff64789c6a34b7 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Fri, 17 Jun 2016 11:47:34 -0400 -Subject: [PATCH 86/90] ppc64le has no separate /boot mount (#1261926) - -The patch for rhbz#1212114 ensures that ppc64le systems sync grub config -changes to disk prior to grub-mkconfig completion and a reboot. - -This patch required checking for /boot as its own mount point because -issuing fsfreeze to a root partition is unwise. For administrators who -configured a ppc64le system with no separate /boot partition, the failed -check results in an error message. The file is written and would work -most of the time, however, it also introduces a corner case where the -behavior manifested in rhbz#1212114 could re-appear on these systems. - -The system call issued by fsfreeeze is being issued by methods within -the anaconda installer and can be removed from GRUB proper. - -Related: rhbz#1315468 -Resolves: rhbz#1261926 ---- - util/grub-mkconfig.in | 9 --------- - 1 file changed, 9 deletions(-) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 73a18f7..fb87247 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -294,12 +294,3 @@ fi - - gettext "done" >&2 - echo >&2 -- --# make sure changes make it to the disk. --# if /boot is a mountpoint, force the meta data on disk --# to by-pass writeback delay. --# PPC64LE-only to deal with Petitboot issues --ARCH=$(uname -m) --if [ "${ARCH}" = "ppc64le" ]; then -- sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot --fi --- -2.9.3 - diff --git a/0087-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch b/0087-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch deleted file mode 100644 index 5297ac6..0000000 --- a/0087-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +++ /dev/null @@ -1,302 +0,0 @@ -From d3d42740661dce4df12330e57a1681a3b296622e Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 23 Jun 2016 11:01:39 -0400 -Subject: [PATCH 87/90] Add grub-get-kernel-settings and use it in 10_linux - -This patch adds grub-get-kernel-settings, which reads the system kernel -installation configuration from /etc/sysconfig/kernel, and outputs -${GRUB_...} variables suitable for evaluation by grub-mkconfig. Those -variables are then used by 10_linux to choose whether or not to create -debug stanzas. - -Resolves: rhbz#1226325 ---- - .gitignore | 1 + - Makefile.util.def | 7 +++ - configure.ac | 2 + - util/bash-completion.d/grub-completion.bash.in | 22 ++++++++ - util/grub-get-kernel-settings.3 | 20 +++++++ - util/grub-get-kernel-settings.in | 78 ++++++++++++++++++++++++++ - util/grub-mkconfig.in | 3 + - util/grub.d/10_linux.in | 23 ++++++-- - 8 files changed, 151 insertions(+), 5 deletions(-) - create mode 100644 util/grub-get-kernel-settings.3 - create mode 100644 util/grub-get-kernel-settings.in - -diff --git a/.gitignore b/.gitignore -index 53a391e..f2f1ef5 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -112,6 +112,7 @@ grub-emu-lite - grub-file - grub-fs-tester - grub-fstest -+grub-get-kernel-settings - grub-glue-efi - grub-install - grub-kbdcomp -diff --git a/Makefile.util.def b/Makefile.util.def -index 8007de9..38cdf4c 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -716,6 +716,13 @@ script = { - }; - - script = { -+ name = grub-get-kernel-settings; -+ common = util/grub-get-kernel-settings.in; -+ mansection = 3; -+ installdir = sbin; -+}; -+ -+script = { - name = grub-set-default; - common = util/grub-set-default.in; - mansection = 8; -diff --git a/configure.ac b/configure.ac -index 25de2c1..1d8f7e7 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -58,6 +58,7 @@ grub_TRANSFORM([grub-install]) - grub_TRANSFORM([grub-mkconfig]) - grub_TRANSFORM([grub-mkfont]) - grub_TRANSFORM([grub-mkimage]) -+grub_TRANSFORM([grub-get-kernel-settings]) - grub_TRANSFORM([grub-glue-efi]) - grub_TRANSFORM([grub-mklayout]) - grub_TRANSFORM([grub-mkpasswd-pbkdf2]) -@@ -75,6 +76,7 @@ grub_TRANSFORM([grub-file]) - grub_TRANSFORM([grub-bios-setup.3]) - grub_TRANSFORM([grub-editenv.1]) - grub_TRANSFORM([grub-fstest.3]) -+grub_TRANSFORM([grub-get-kernel-settings.3]) - grub_TRANSFORM([grub-glue-efi.3]) - grub_TRANSFORM([grub-install.1]) - grub_TRANSFORM([grub-kbdcomp.3]) -diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in -index 44bf135..5c4acd4 100644 ---- a/util/bash-completion.d/grub-completion.bash.in -+++ b/util/bash-completion.d/grub-completion.bash.in -@@ -265,6 +265,28 @@ unset __grub_sparc64_setup_program - - - # -+# grub-get-kernel-settings -+# -+_grub_get_kernel_settings () { -+ local cur -+ -+ COMPREPLY=() -+ cur=`_get_cword` -+ -+ if [[ "$cur" == -* ]]; then -+ __grubcomp "$(__grub_get_options_from_help)" -+ else -+ # Default complete with a filename -+ _filedir -+ fi -+} -+__grub_get_kernel_settings_program="@grub_get_kernel_settings@" -+have ${__grub_get_kernel_settings_program} && \ -+ complete -F _grub_get_kernel_settings -o filenames ${__grub_get_kernel_settings_program} -+unset __grub_get_kernel_settings_program -+ -+ -+# - # grub-install - # - _grub_install () { -diff --git a/util/grub-get-kernel-settings.3 b/util/grub-get-kernel-settings.3 -new file mode 100644 -index 0000000..ba33330 ---- /dev/null -+++ b/util/grub-get-kernel-settings.3 -@@ -0,0 +1,20 @@ -+.TH GRUB-GET-KERNEL-SETTINGS 3 "Thu Jun 25 2015" -+.SH NAME -+\fBgrub-get-kernel-settings\fR \(em Evaluate the system's kernel installation settings for use while making a grub configuration file. -+ -+.SH SYNOPSIS -+\fBgrub-get-kernel-settings\fR [OPTION] -+ -+.SH DESCRIPTION -+\fBgrub-get-kernel-settings\fR reads the kernel installation settings on the host system, and emits a set of grub settings suitable for use when creating a grub configuration file. -+ -+.SH OPTIONS -+.TP -+-h, --help -+Display program usage and exit. -+.TP -+-v, --version -+Display the current version. -+ -+.SH SEE ALSO -+.BR "info grub" -diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in -new file mode 100644 -index 0000000..1204621 ---- /dev/null -+++ b/util/grub-get-kernel-settings.in -@@ -0,0 +1,78 @@ -+#!/bin/sh -+set -e -+ -+# Evaluate new-kernel-pkg's configuration file. -+# Copyright (C) 2016 Free Software Foundation, Inc. -+# -+# GRUB 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. -+# -+# GRUB 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 GRUB. If not, see . -+ -+PACKAGE_NAME=@PACKAGE_NAME@ -+PACKAGE_VERSION=@PACKAGE_VERSION@ -+datadir="@datadir@" -+if [ "x$pkgdatadir" = x ]; then -+ pkgdatadir="${datadir}/@PACKAGE@" -+fi -+ -+self=`basename $0` -+ -+export TEXTDOMAIN=@PACKAGE@ -+export TEXTDOMAINDIR="@localedir@" -+ -+. "${pkgdatadir}/grub-mkconfig_lib" -+ -+# Usage: usage -+# Print the usage. -+usage () { -+ gettext_printf "Usage: %s [OPTION]\n" "$self" -+ gettext "Evaluate new-kernel-pkg configuration"; echo -+ echo -+ print_option_help "-h, --help" "$(gettext "print this message and exit")" -+ print_option_help "-v, --version" "$(gettext "print the version information and exit")" -+ echo -+} -+ -+# Check the arguments. -+while test $# -gt 0 -+do -+ option=$1 -+ shift -+ -+ case "$option" in -+ -h | --help) -+ usage -+ exit 0 ;; -+ -v | --version) -+ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" -+ exit 0 ;; -+ -*) -+ gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 -+ usage -+ exit 1 -+ ;; -+ # Explicitly ignore non-option arguments, for compatibility. -+ esac -+done -+ -+if test -f /etc/sysconfig/kernel ; then -+ . /etc/sysconfig/kernel -+fi -+ -+if [ "$MAKEDEBUG" = "yes" ]; then -+ echo GRUB_LINUX_MAKE_DEBUG=true -+ echo export GRUB_LINUX_MAKE_DEBUG -+ echo GRUB_CMDLINE_LINUX_DEBUG=\"systemd.log_level=debug systemd.log_target=kmsg\" -+ echo export GRUB_CMDLINE_LINUX_DEBUG -+ echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\" -+ echo export GRUB_LINUX_DEBUG_TITLE_POSTFIX -+fi -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index fb87247..e32de5e 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -45,6 +45,7 @@ grub_probe="${sbindir}/@grub_probe@" - grub_file="${bindir}/@grub_file@" - grub_editenv="${bindir}/@grub_editenv@" - grub_script_check="${bindir}/@grub_script_check@" -+grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" - - export TEXTDOMAIN=@PACKAGE@ - export TEXTDOMAINDIR="@localedir@" -@@ -151,6 +152,8 @@ if test -f ${sysconfdir}/default/grub ; then - . ${sysconfdir}/default/grub - fi - -+eval "$("${grub_get_kernel_settings}")" || true -+ - if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_UUID" ]; then - GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" - fi -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 1215241..0c5b227 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -84,7 +84,8 @@ linux_entry () - os="$1" - version="$2" - type="$3" -- args="$4" -+ isdebug="$4" -+ args="$5" - - sixteenbit="" - linuxefi="linux" -@@ -116,6 +117,9 @@ linux_entry () - quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" - title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" - fi -+ if [ x$isdebug = xdebug ]; then -+ title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}" -+ fi - echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" - else - echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -@@ -273,11 +277,15 @@ while [ "x$list" != "x" ] ; do - fi - - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then -- linux_entry "${OS}" "${version}" simple \ -+ linux_entry "${OS}" "${version}" simple standard \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -+ linux_entry "${OS}" "${version}" simple debug \ -+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" -+ fi - - submenu_indentation="$grub_tab" -- -+ - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" - fi -@@ -286,10 +294,15 @@ while [ "x$list" != "x" ] ; do - is_top_level=false - fi - -- linux_entry "${OS}" "${version}" advanced \ -+ linux_entry "${OS}" "${version}" advanced standard \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -+ linux_entry "${OS}" "${version}" advanced debug \ -+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" -+ fi -+ - if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then -- linux_entry "${OS}" "${version}" recovery \ -+ linux_entry "${OS}" "${version}" recovery standard \ - "single ${GRUB_CMDLINE_LINUX}" - fi - --- -2.9.3 - diff --git a/0087-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch b/0087-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch new file mode 100644 index 0000000..d76aeda --- /dev/null +++ b/0087-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch @@ -0,0 +1,494 @@ +From c1d31b6a26e5542142d569c94a70f1dc8e07afd6 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 6 Oct 2015 16:09:25 -0400 +Subject: [PATCH 087/123] Make any of the loaders that link in efi mode honor + secure boot. + +And in this case "honor" means "even if somebody does link this in, they +won't register commands if SB is enabled." + +Signed-off-by: Peter Jones +--- + grub-core/Makefile.am | 1 + + grub-core/Makefile.core.def | 1 + + grub-core/commands/iorw.c | 7 +++++ + grub-core/commands/memrw.c | 7 +++++ + grub-core/kern/efi/efi.c | 28 ------------------ + grub-core/kern/efi/sb.c | 58 ++++++++++++++++++++++++++++++++++++++ + grub-core/loader/efi/appleloader.c | 7 +++++ + grub-core/loader/efi/chainloader.c | 1 + + grub-core/loader/i386/bsd.c | 7 +++++ + grub-core/loader/i386/linux.c | 7 +++++ + grub-core/loader/i386/pc/linux.c | 7 +++++ + grub-core/loader/multiboot.c | 7 +++++ + grub-core/loader/xnu.c | 7 +++++ + include/grub/efi/efi.h | 1 - + include/grub/efi/sb.h | 29 +++++++++++++++++++ + include/grub/ia64/linux.h | 0 + include/grub/mips/linux.h | 0 + include/grub/powerpc/linux.h | 0 + include/grub/sparc64/linux.h | 0 + 19 files changed, 146 insertions(+), 29 deletions(-) + create mode 100644 grub-core/kern/efi/sb.c + create mode 100644 include/grub/efi/sb.h + create mode 100644 include/grub/ia64/linux.h + create mode 100644 include/grub/mips/linux.h + create mode 100644 include/grub/powerpc/linux.h + create mode 100644 include/grub/sparc64/linux.h + +diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am +index 04e9395fd..fd715a8ea 100644 +--- a/grub-core/Makefile.am ++++ b/grub-core/Makefile.am +@@ -71,6 +71,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h ++KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index 7fba196b3..ac195d10e 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -178,6 +178,7 @@ kernel = { + i386_multiboot = kern/i386/pc/acpi.c; + i386_coreboot = kern/acpi.c; + i386_multiboot = kern/acpi.c; ++ common = kern/efi/sb.c; + + x86 = kern/i386/tsc.c; + x86 = kern/i386/tsc_pit.c; +diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c +index a0c164e54..41a7f3f04 100644 +--- a/grub-core/commands/iorw.c ++++ b/grub-core/commands/iorw.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -118,6 +119,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) + + GRUB_MOD_INIT(memrw) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + cmd_read_byte = + grub_register_extcmd ("inb", grub_cmd_read, 0, + N_("PORT"), N_("Read 8-bit value from PORT."), +@@ -146,6 +150,9 @@ GRUB_MOD_INIT(memrw) + + GRUB_MOD_FINI(memrw) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + grub_unregister_extcmd (cmd_read_byte); + grub_unregister_extcmd (cmd_read_word); + grub_unregister_extcmd (cmd_read_dword); +diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c +index 98769eadb..088cbe9e2 100644 +--- a/grub-core/commands/memrw.c ++++ b/grub-core/commands/memrw.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -120,6 +121,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) + + GRUB_MOD_INIT(memrw) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + cmd_read_byte = + grub_register_extcmd ("read_byte", grub_cmd_read, 0, + N_("ADDR"), N_("Read 8-bit value from ADDR."), +@@ -148,6 +152,9 @@ GRUB_MOD_INIT(memrw) + + GRUB_MOD_FINI(memrw) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + grub_unregister_extcmd (cmd_read_byte); + grub_unregister_extcmd (cmd_read_word); + grub_unregister_extcmd (cmd_read_dword); +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index 08599101a..101307fc7 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -269,34 +269,6 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, + return NULL; + } + +-grub_efi_boolean_t +-grub_efi_secure_boot (void) +-{ +- grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; +- grub_size_t datasize; +- char *secure_boot = NULL; +- char *setup_mode = NULL; +- grub_efi_boolean_t ret = 0; +- +- secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); +- +- if (datasize != 1 || !secure_boot) +- goto out; +- +- setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); +- +- if (datasize != 1 || !setup_mode) +- goto out; +- +- if (*secure_boot && !*setup_mode) +- ret = 1; +- +- out: +- grub_free (secure_boot); +- grub_free (setup_mode); +- return ret; +-} +- + #pragma GCC diagnostic ignored "-Wcast-align" + + /* Search the mods section from the PE32/PE32+ image. This code uses +diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c +new file mode 100644 +index 000000000..a41b6c5b8 +--- /dev/null ++++ b/grub-core/kern/efi/sb.c +@@ -0,0 +1,58 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2014 Free Software Foundation, Inc. ++ * ++ * GRUB 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. ++ * ++ * GRUB 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 GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++int ++grub_efi_secure_boot (void) ++{ ++#ifdef GRUB_MACHINE_EFI ++ grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; ++ grub_size_t datasize; ++ char *secure_boot = NULL; ++ char *setup_mode = NULL; ++ grub_efi_boolean_t ret = 0; ++ ++ secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); ++ ++ if (datasize != 1 || !secure_boot) ++ goto out; ++ ++ setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); ++ ++ if (datasize != 1 || !setup_mode) ++ goto out; ++ ++ if (*secure_boot && !*setup_mode) ++ ret = 1; ++ ++ out: ++ grub_free (secure_boot); ++ grub_free (setup_mode); ++ return ret; ++#else ++ return 0; ++#endif ++} +diff --git a/grub-core/loader/efi/appleloader.c b/grub-core/loader/efi/appleloader.c +index 74888c463..69c2a10d3 100644 +--- a/grub-core/loader/efi/appleloader.c ++++ b/grub-core/loader/efi/appleloader.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -227,6 +228,9 @@ static grub_command_t cmd; + + GRUB_MOD_INIT(appleloader) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + cmd = grub_register_command ("appleloader", grub_cmd_appleloader, + N_("[OPTS]"), + /* TRANSLATORS: This command is used on EFI to +@@ -238,5 +242,8 @@ GRUB_MOD_INIT(appleloader) + + GRUB_MOD_FINI(appleloader) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + grub_unregister_command (cmd); + } +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 3cbb6c5b8..c4184fa64 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -34,6 +34,7 @@ + #include + #include + #include ++#include + #include + #include + #include +diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c +index 7f96515da..87709aa23 100644 +--- a/grub-core/loader/i386/bsd.c ++++ b/grub-core/loader/i386/bsd.c +@@ -38,6 +38,7 @@ + #ifdef GRUB_MACHINE_PCBIOS + #include + #endif ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -2124,6 +2125,9 @@ static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk; + + GRUB_MOD_INIT (bsd) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + /* Net and OpenBSD kernels are often compressed. */ + grub_dl_load ("gzio"); + +@@ -2163,6 +2167,9 @@ GRUB_MOD_INIT (bsd) + + GRUB_MOD_FINI (bsd) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + grub_unregister_extcmd (cmd_freebsd); + grub_unregister_extcmd (cmd_openbsd); + grub_unregister_extcmd (cmd_netbsd); +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index fddcc461d..b0afccac9 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -1136,6 +1137,9 @@ static grub_command_t cmd_linux, cmd_initrd; + + GRUB_MOD_INIT(linux) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + cmd_linux = grub_register_command ("linux", grub_cmd_linux, + 0, N_("Load Linux.")); + cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, +@@ -1145,6 +1149,9 @@ GRUB_MOD_INIT(linux) + + GRUB_MOD_FINI(linux) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + grub_unregister_command (cmd_linux); + grub_unregister_command (cmd_initrd); + } +diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c +index a293b17aa..91283157e 100644 +--- a/grub-core/loader/i386/pc/linux.c ++++ b/grub-core/loader/i386/pc/linux.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -472,6 +473,9 @@ static grub_command_t cmd_linux, cmd_initrd; + + GRUB_MOD_INIT(linux16) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + cmd_linux = + grub_register_command ("linux16", grub_cmd_linux, + 0, N_("Load Linux.")); +@@ -483,6 +487,9 @@ GRUB_MOD_INIT(linux16) + + GRUB_MOD_FINI(linux16) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + grub_unregister_command (cmd_linux); + grub_unregister_command (cmd_initrd); + } +diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c +index 73aa0aa12..64a651322 100644 +--- a/grub-core/loader/multiboot.c ++++ b/grub-core/loader/multiboot.c +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -391,6 +392,9 @@ static grub_command_t cmd_multiboot, cmd_module; + + GRUB_MOD_INIT(multiboot) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + cmd_multiboot = + #ifdef GRUB_USE_MULTIBOOT2 + grub_register_command ("multiboot2", grub_cmd_multiboot, +@@ -411,6 +415,9 @@ GRUB_MOD_INIT(multiboot) + + GRUB_MOD_FINI(multiboot) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + grub_unregister_command (cmd_multiboot); + grub_unregister_command (cmd_module); + } +diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c +index c9885b1bc..df8dfdb4b 100644 +--- a/grub-core/loader/xnu.c ++++ b/grub-core/loader/xnu.c +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -1469,6 +1470,9 @@ static grub_extcmd_t cmd_splash; + + GRUB_MOD_INIT(xnu) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0, + N_("Load XNU image.")); + cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64, +@@ -1509,6 +1513,9 @@ GRUB_MOD_INIT(xnu) + + GRUB_MOD_FINI(xnu) + { ++ if (grub_efi_secure_boot()) ++ return; ++ + #ifndef GRUB_MACHINE_EMU + grub_unregister_command (cmd_resume); + #endif +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index 22456327e..9a2da0eb3 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -76,7 +76,6 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, + const grub_efi_guid_t *guid, + void *data, + grub_size_t datasize); +-grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void); + int + EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, + const grub_efi_device_path_t *dp2); +diff --git a/include/grub/efi/sb.h b/include/grub/efi/sb.h +new file mode 100644 +index 000000000..9629fbb0f +--- /dev/null ++++ b/include/grub/efi/sb.h +@@ -0,0 +1,29 @@ ++/* sb.h - declare functions for EFI Secure Boot support */ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. ++ * ++ * GRUB 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. ++ * ++ * GRUB 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 GRUB. If not, see . ++ */ ++ ++#ifndef GRUB_EFI_SB_HEADER ++#define GRUB_EFI_SB_HEADER 1 ++ ++#include ++#include ++ ++/* Functions. */ ++int EXPORT_FUNC (grub_efi_secure_boot) (void); ++ ++#endif /* ! GRUB_EFI_SB_HEADER */ +diff --git a/include/grub/ia64/linux.h b/include/grub/ia64/linux.h +new file mode 100644 +index 000000000..e69de29bb +diff --git a/include/grub/mips/linux.h b/include/grub/mips/linux.h +new file mode 100644 +index 000000000..e69de29bb +diff --git a/include/grub/powerpc/linux.h b/include/grub/powerpc/linux.h +new file mode 100644 +index 000000000..e69de29bb +diff --git a/include/grub/sparc64/linux.h b/include/grub/sparc64/linux.h +new file mode 100644 +index 000000000..e69de29bb +-- +2.14.3 + diff --git a/0088-Fix-security-issue-when-reading-username-and-passwor.patch b/0088-Fix-security-issue-when-reading-username-and-passwor.patch new file mode 100644 index 0000000..39dfa3c --- /dev/null +++ b/0088-Fix-security-issue-when-reading-username-and-passwor.patch @@ -0,0 +1,47 @@ +From 5a0d703884a73f93a68753c6ed64bdf08797c82a Mon Sep 17 00:00:00 2001 +From: Hector Marco-Gisbert +Date: Fri, 13 Nov 2015 16:21:09 +0100 +Subject: [PATCH 088/123] Fix security issue when reading username and password + + This patch fixes two integer underflows at: + * grub-core/lib/crypto.c + * grub-core/normal/auth.c + +Resolves: CVE-2015-8370 + +Signed-off-by: Hector Marco-Gisbert +Signed-off-by: Ismael Ripoll-Ripoll +--- + grub-core/lib/crypto.c | 2 +- + grub-core/normal/auth.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c +index 683a8aaa7..c5ab9eb18 100644 +--- a/grub-core/lib/crypto.c ++++ b/grub-core/lib/crypto.c +@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size) + break; + } + +- if (key == '\b') ++ if (key == '\b' && cur_len) + { + if (cur_len) + cur_len--; +diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c +index 7338f8245..6d6dc7ded 100644 +--- a/grub-core/normal/auth.c ++++ b/grub-core/normal/auth.c +@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size) + break; + } + +- if (key == '\b') ++ if (key == '\b' && cur_len) + { + if (cur_len) + { +-- +2.14.3 + diff --git a/0088-Normalize-slashes-in-tftp-paths.patch b/0088-Normalize-slashes-in-tftp-paths.patch deleted file mode 100644 index ffaaf81..0000000 --- a/0088-Normalize-slashes-in-tftp-paths.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 22d26153c1d92b8a42d1ec823b7f7c77c1cc0a8c Mon Sep 17 00:00:00 2001 -From: Lenny Szubowicz -Date: Mon, 29 Aug 2016 11:04:48 -0400 -Subject: [PATCH 88/90] Normalize slashes in tftp paths. - -Some tftp servers do not handle multiple consecutive slashes correctly; -this patch avoids sending tftp requests with non-normalized paths. - -Signed-off-by: Peter Jones ---- - grub-core/net/tftp.c | 24 +++++++++++++++++++++++- - 1 file changed, 23 insertions(+), 1 deletion(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 7d90bf6..63bbc28 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -300,6 +300,25 @@ destroy_pq (tftp_data_t data) - grub_priority_queue_destroy (data->pq); - } - -+/* Create a normalized copy of the filename. -+ Compress any string of consecutive forward slashes to a single forward -+ slash. */ -+static void -+grub_normalize_filename (char *normalized, const char *filename) -+{ -+ char *dest = normalized; -+ char *src = filename; -+ -+ while (*src != '\0') -+ { -+ if (src[0] == '/' && src[1] == '/') -+ src++; -+ else -+ *dest++ = *src++; -+ } -+ *dest = '\0'; -+} -+ - static grub_err_t - tftp_open (struct grub_file *file, const char *filename) - { -@@ -337,7 +356,10 @@ tftp_open (struct grub_file *file, const char *filename) - rrqlen = 0; - - tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ); -- grub_strcpy (rrq, filename); -+ -+ /* Copy and normalize the filename to work-around issues on some tftp -+ servers when file names are being matched for remapping. */ -+ grub_normalize_filename (rrq, filename); - rrqlen += grub_strlen (filename) + 1; - rrq += grub_strlen (filename) + 1; - --- -2.9.3 - diff --git a/0089-Make-grub_fatal-also-backtrace.patch b/0089-Make-grub_fatal-also-backtrace.patch new file mode 100644 index 0000000..d5b1a9c --- /dev/null +++ b/0089-Make-grub_fatal-also-backtrace.patch @@ -0,0 +1,175 @@ +From c37a4f02e5fd0c3aa5f54baaeaf32eed0e3c110b Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 27 Jan 2016 09:22:42 -0500 +Subject: [PATCH 089/123] Make grub_fatal() also backtrace. + +--- + grub-core/Makefile.core.def | 3 ++ + grub-core/kern/misc.c | 8 +++++- + grub-core/lib/arm64/backtrace.c | 62 +++++++++++++++++++++++++++++++++++++++++ + grub-core/lib/backtrace.c | 2 ++ + grub-core/lib/i386/backtrace.c | 14 +++++++++- + 5 files changed, 87 insertions(+), 2 deletions(-) + create mode 100644 grub-core/lib/arm64/backtrace.c + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index ac195d10e..990e41b55 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -157,6 +157,9 @@ kernel = { + + softdiv = lib/division.c; + ++ x86 = lib/i386/backtrace.c; ++ x86 = lib/backtrace.c; ++ + i386 = kern/i386/dl.c; + i386_xen = kern/i386/dl.c; + +diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c +index 81be34424..d7dcd9725 100644 +--- a/grub-core/kern/misc.c ++++ b/grub-core/kern/misc.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + union printf_arg + { +@@ -1087,8 +1088,13 @@ grub_xasprintf (const char *fmt, ...) + static void __attribute__ ((noreturn)) + grub_abort (void) + { ++#ifndef GRUB_UTIL ++#if defined(__i386__) || defined(__x86_64__) ++ grub_backtrace(); ++#endif ++#endif + grub_printf ("\nAborted."); +- ++ + #ifndef GRUB_UTIL + if (grub_term_inputs) + #endif +diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c +new file mode 100644 +index 000000000..1079b5380 +--- /dev/null ++++ b/grub-core/lib/arm64/backtrace.c +@@ -0,0 +1,62 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2009 Free Software Foundation, Inc. ++ * ++ * GRUB 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. ++ * ++ * GRUB 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 GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MAX_STACK_FRAME 102400 ++ ++void ++grub_backtrace_pointer (int frame) ++{ ++ while (1) ++ { ++ void *lp = __builtin_return_address (frame); ++ if (!lp) ++ break; ++ ++ lp = __builtin_extract_return_addr (lp); ++ ++ grub_printf ("%p: ", lp); ++ grub_backtrace_print_address (lp); ++ grub_printf (" ("); ++ for (i = 0; i < 2; i++) ++ grub_printf ("%p,", ((void **)ptr) [i + 2]); ++ grub_printf ("%p)\n", ((void **)ptr) [i + 2]); ++ nptr = *(void **)ptr; ++ if (nptr < ptr || (void **) nptr - (void **) ptr > MAX_STACK_FRAME ++ || nptr == ptr) ++ { ++ grub_printf ("Invalid stack frame at %p (%p)\n", ptr, nptr); ++ break; ++ } ++ ptr = nptr; ++ } ++} ++ ++void ++grub_backtrace (void) ++{ ++ grub_backtrace_pointer (1); ++} ++ +diff --git a/grub-core/lib/backtrace.c b/grub-core/lib/backtrace.c +index 825a8800e..c0ad6ab8b 100644 +--- a/grub-core/lib/backtrace.c ++++ b/grub-core/lib/backtrace.c +@@ -29,6 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); + void + grub_backtrace_print_address (void *addr) + { ++#ifndef GRUB_UTIL + grub_dl_t mod; + + FOR_DL_MODULES (mod) +@@ -44,6 +45,7 @@ grub_backtrace_print_address (void *addr) + } + } + ++#endif + grub_printf ("%p", addr); + } + +diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c +index c3e03c727..c67273db3 100644 +--- a/grub-core/lib/i386/backtrace.c ++++ b/grub-core/lib/i386/backtrace.c +@@ -15,11 +15,23 @@ + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ ++#include ++#ifdef GRUB_UTIL ++#define REALLY_GRUB_UTIL GRUB_UTIL ++#undef GRUB_UTIL ++#endif ++ ++#include ++#include ++ ++#ifdef REALLY_GRUB_UTIL ++#define GRUB_UTIL REALLY_GRUB_UTIL ++#undef REALLY_GRUB_UTIL ++#endif + + #include + #include + #include +-#include + #include + #include + #include +-- +2.14.3 + diff --git a/0089-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch b/0089-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch deleted file mode 100644 index 05d297a..0000000 --- a/0089-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 54d9b46779dab340984dde1077c4f2b685caf0b1 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Mon, 21 Nov 2016 15:34:00 +0100 -Subject: [PATCH 89/90] efi/chainloader: fix wrong sanity check in - relocate_coff() - -In relocate_coff(), the relocation entries are parsed from the original -image (not the section-wise copied image). The original image is -pointed-to by the "orig" pointer. The current check - - (void *)reloc_end < data - -compares the addresses of independent memory allocations. "data" is a typo -here, it should be "orig". - -Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1347291 -Signed-off-by: Laszlo Ersek -Tested-by: Bogdan Costescu -Tested-by: Juan Orti ---- - grub-core/loader/efi/chainloader.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 49a7662..1bd7ffb 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -397,7 +397,7 @@ relocate_coff (pe_coff_loader_image_context_t *context, - reloc_end = (struct grub_pe32_fixup_block *) - ((char *)reloc_base + reloc_base->size); - -- if ((void *)reloc_end < data || (void *)reloc_end > image_end) -+ if ((void *)reloc_end < orig || (void *)reloc_end > image_end) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc entry %d overflows binary", - n); --- -2.9.3 - diff --git a/0090-Rework-linux-command.patch b/0090-Rework-linux-command.patch new file mode 100644 index 0000000..8a80bbe --- /dev/null +++ b/0090-Rework-linux-command.patch @@ -0,0 +1,107 @@ +From 33d11870bbc2fa554fa9344c3c180279c258736a Mon Sep 17 00:00:00 2001 +From: Matthew Garrett +Date: Sun, 9 Aug 2015 16:12:39 -0700 +Subject: [PATCH 090/123] Rework linux command + +We want a single buffer that contains the entire kernel image in order to +perform a TPM measurement. Allocate one and copy the entire kernel into it +before pulling out the individual blocks later on. +--- + grub-core/loader/i386/linux.c | 34 +++++++++++++++++++++------------- + 1 file changed, 21 insertions(+), 13 deletions(-) + +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index b0afccac9..5eb7d17db 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -681,12 +681,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_file_t file = 0; + struct linux_kernel_header lh; + grub_uint8_t setup_sects; +- grub_size_t real_size, prot_size, prot_file_size; ++ grub_size_t real_size, prot_size, prot_file_size, kernel_offset; + grub_ssize_t len; + int i; + grub_size_t align, min_align; + int relocatable; + grub_uint64_t preferred_address = GRUB_LINUX_BZIMAGE_ADDR; ++ grub_uint8_t *kernel = NULL; + + grub_dl_ref (my_mod); + +@@ -700,7 +701,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + if (! file) + goto fail; + +- if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) ++ len = grub_file_size (file); ++ kernel = grub_malloc (len); ++ if (!kernel) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer")); ++ goto fail; ++ } ++ ++ if (grub_file_read (file, kernel, len) != len) + { + if (!grub_errno) + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +@@ -708,6 +717,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++ grub_memcpy (&lh, kernel, sizeof (lh)); ++ kernel_offset = sizeof (lh); ++ + if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) + { + grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); +@@ -807,13 +819,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + linux_params.ps_mouse = linux_params.padding10 = 0; + + len = sizeof (linux_params) - sizeof (lh); +- if (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len) +- { +- if (!grub_errno) +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +- argv[0]); +- goto fail; +- } ++ ++ grub_memcpy (&linux_params + sizeof (lh), kernel + kernel_offset, len); ++ kernel_offset += len; + + linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; + +@@ -872,7 +880,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + /* The other parameters are filled when booting. */ + +- grub_file_seek (file, real_size + GRUB_DISK_SECTOR_SIZE); ++ kernel_offset = real_size + GRUB_DISK_SECTOR_SIZE; + + grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n", + (unsigned) real_size, (unsigned) prot_size); +@@ -1017,9 +1025,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + - (sizeof (LINUX_IMAGE) - 1)); + + len = prot_file_size; +- if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno) +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +- argv[0]); ++ grub_memcpy (prot_mode_mem, kernel + kernel_offset, len); + + if (grub_errno == GRUB_ERR_NONE) + { +@@ -1030,6 +1036,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + fail: + ++ grub_free (kernel); ++ + if (file) + grub_file_close (file); + +-- +2.14.3 + diff --git a/0090-efi-chainloader-truncate-overlong-relocation-section.patch b/0090-efi-chainloader-truncate-overlong-relocation-section.patch deleted file mode 100644 index 372c069..0000000 --- a/0090-efi-chainloader-truncate-overlong-relocation-section.patch +++ /dev/null @@ -1,113 +0,0 @@ -From e85054f3b65bdb2afe2a71062f8145d9fef63051 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Wed, 23 Nov 2016 06:27:09 +0100 -Subject: [PATCH 90/90] efi/chainloader: truncate overlong relocation section - -The UEFI Windows 7 boot loader ("EFI/Microsoft/Boot/bootmgfw.efi", SHA1 -31b410e029bba87d2068c65a80b88882f9f8ea25) has inconsistent headers. - -Compare: - -> The Data Directory -> ... -> Entry 5 00000000000d9000 00000574 Base Relocation Directory [.reloc] - -Versus: - -> Sections: -> Idx Name Size VMA LMA File off ... -> ... -> 10 .reloc 00000e22 00000000100d9000 00000000100d9000 000a1800 ... - -That is, the size reported by the RelocDir entry (0x574) is smaller than -the virtual size of the .reloc section (0xe22). - -Quoting the grub2 debug log for the same: - -> chainloader.c:595: reloc_dir: 0xd9000 reloc_size: 0x00000574 -> chainloader.c:603: reloc_base: 0x7d208000 reloc_base_end: 0x7d208573 -> ... -> chainloader.c:620: Section 10 ".reloc" at 0x7d208000..0x7d208e21 -> chainloader.c:661: section is not reloc section? -> chainloader.c:663: rds: 0x00001000, vs: 00000e22 -> chainloader.c:664: base: 0x7d208000 end: 0x7d208e21 -> chainloader.c:666: reloc_base: 0x7d208000 reloc_base_end: 0x7d208573 -> chainloader.c:671: Section characteristics are 42000040 -> chainloader.c:673: Section virtual size: 00000e22 -> chainloader.c:675: Section raw_data size: 00001000 -> chainloader.c:678: Discarding section - -After hexdumping "bootmgfw.efi" and manually walking its relocation blocks -(yes, really), I determined that the (smaller) RelocDir value is correct. -The remaining area that extends up to the .reloc section size (== 0xe22 - -0x574 == 0x8ae bytes) exists as zero padding in the file. - -This zero padding shouldn't be passed to relocate_coff() for parsing. In -order to cope with it, split the handling of .reloc sections into the -following branches: - -- original case (equal size): original behavior (--> relocation - attempted), - -- overlong .reloc section (longer than reported by RelocDir): truncate the - section to the RelocDir size for the purposes of relocate_coff(), and - attempt relocation, - -- .reloc section is too short, or other checks fail: original behavior - (--> relocation not attempted). - -Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1347291 -Signed-off-by: Laszlo Ersek ---- - grub-core/loader/efi/chainloader.c | 26 +++++++++++++++++++++----- - 1 file changed, 21 insertions(+), 5 deletions(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 1bd7ffb..70c95ee 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -592,7 +592,7 @@ handle_image (void *data, grub_efi_uint32_t datasize) - grub_dprintf ("chain", "reloc_base: %p reloc_base_end: %p\n", - reloc_base, reloc_base_end); - -- struct grub_pe32_section_table *reloc_section = NULL; -+ struct grub_pe32_section_table *reloc_section = NULL, fake_reloc_section; - - section = context.first_section; - for (i = 0; i < context.number_of_sections; i++, section++) -@@ -641,12 +641,28 @@ handle_image (void *data, grub_efi_uint32_t datasize) - * made sense, and the VA and size match RelocDir's - * versions, then we believe in this section table. */ - if (section->raw_data_size && section->virtual_size && -- base && end && reloc_base == base && reloc_base_end == end) -+ base && end && reloc_base == base) - { -- grub_dprintf ("chain", " section is relocation section\n"); -- reloc_section = section; -+ if (reloc_base_end == end) -+ { -+ grub_dprintf ("chain", " section is relocation section\n"); -+ reloc_section = section; -+ } -+ else if (reloc_base_end && reloc_base_end < end) -+ { -+ /* Bogus virtual size in the reloc section -- RelocDir -+ * reported a smaller Base Relocation Directory. Decrease -+ * the section's virtual size so that it equal RelocDir's -+ * idea, but only for the purposes of relocate_coff(). */ -+ grub_dprintf ("chain", -+ " section is (overlong) relocation section\n"); -+ grub_memcpy (&fake_reloc_section, section, sizeof *section); -+ fake_reloc_section.virtual_size -= (end - reloc_base_end); -+ reloc_section = &fake_reloc_section; -+ } - } -- else -+ -+ if (!reloc_section) - { - grub_dprintf ("chain", " section is not reloc section?\n"); - grub_dprintf ("chain", " rds: 0x%08x, vs: %08x\n", --- -2.9.3 - diff --git a/0091-Fix-malformed-tftp-packets.patch b/0091-Fix-malformed-tftp-packets.patch deleted file mode 100644 index d6fc8c9..0000000 --- a/0091-Fix-malformed-tftp-packets.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 20e077f4b5be64518b8ff996c11973132e8a9ff3 Mon Sep 17 00:00:00 2001 -From: Mark Salter -Date: Tue, 7 Mar 2017 18:26:17 -0500 -Subject: [PATCH 091/105] Fix malformed tftp packets - -0088-Normalize-slashes-in-tftp-paths.patch collapses multiple contiguous -slashes in a filename into one slash in the tftp packet filename field. -However, the packet buffer pointer is advanced using the original name. -This leaves unitialized data between the name field and the type field -leading to tftp errors. Use the length of the normalized name to avoid -this. - -Signed-off-by: Mark Salter ---- - grub-core/net/tftp.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 63bbc28ef..c4b5205d0 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -360,8 +360,8 @@ tftp_open (struct grub_file *file, const char *filename) - /* Copy and normalize the filename to work-around issues on some tftp - servers when file names are being matched for remapping. */ - grub_normalize_filename (rrq, filename); -- rrqlen += grub_strlen (filename) + 1; -- rrq += grub_strlen (filename) + 1; -+ rrqlen += grub_strlen (rrq) + 1; -+ rrq += grub_strlen (rrq) + 1; - - grub_strcpy (rrq, "octet"); - rrqlen += grub_strlen ("octet") + 1; --- -2.13.0 - diff --git a/0091-Rework-linux16-command.patch b/0091-Rework-linux16-command.patch new file mode 100644 index 0000000..a33ec32 --- /dev/null +++ b/0091-Rework-linux16-command.patch @@ -0,0 +1,101 @@ +From 0b86b309de12b4f3ea920124faa60841ffedf472 Mon Sep 17 00:00:00 2001 +From: Matthew Garrett +Date: Sun, 9 Aug 2015 16:20:58 -0700 +Subject: [PATCH 091/123] Rework linux16 command + +We want a single buffer that contains the entire kernel image in order to +perform a TPM measurement. Allocate one and copy the entire kernel int it +before pulling out the individual blocks later on. +--- + grub-core/loader/i386/pc/linux.c | 34 +++++++++++++++++++++------------- + 1 file changed, 21 insertions(+), 13 deletions(-) + +diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c +index 91283157e..b864e5403 100644 +--- a/grub-core/loader/i386/pc/linux.c ++++ b/grub-core/loader/i386/pc/linux.c +@@ -124,13 +124,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_file_t file = 0; + struct linux_kernel_header lh; + grub_uint8_t setup_sects; +- grub_size_t real_size; ++ grub_size_t real_size, kernel_offset = 0; + grub_ssize_t len; + int i; + char *grub_linux_prot_chunk; + int grub_linux_is_bzimage; + grub_addr_t grub_linux_prot_target; + grub_err_t err; ++ grub_uint8_t *kernel = NULL; + + grub_dl_ref (my_mod); + +@@ -144,7 +145,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + if (! file) + goto fail; + +- if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) ++ len = grub_file_size (file); ++ kernel = grub_malloc (len); ++ if (!kernel) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer")); ++ goto fail; ++ } ++ ++ if (grub_file_read (file, kernel, len) != len) + { + if (!grub_errno) + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +@@ -152,6 +161,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++ grub_memcpy (&lh, kernel, sizeof (lh)); ++ kernel_offset = sizeof (lh); ++ + if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) + { + grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); +@@ -315,13 +327,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_memmove (grub_linux_real_chunk, &lh, sizeof (lh)); + + len = real_size + GRUB_DISK_SECTOR_SIZE - sizeof (lh); +- if (grub_file_read (file, grub_linux_real_chunk + sizeof (lh), len) != len) +- { +- if (!grub_errno) +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +- argv[0]); +- goto fail; +- } ++ grub_memcpy (grub_linux_real_chunk + sizeof (lh), kernel + kernel_offset, ++ len); ++ kernel_offset += len; + + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) + || grub_le_to_cpu16 (lh.version) < 0x0200) +@@ -356,10 +364,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } + + len = grub_linux16_prot_size; +- if (grub_file_read (file, grub_linux_prot_chunk, grub_linux16_prot_size) +- != (grub_ssize_t) grub_linux16_prot_size && !grub_errno) +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), +- argv[0]); ++ grub_memcpy (grub_linux_prot_chunk, kernel + kernel_offset, len); ++ kernel_offset += len; + + if (grub_errno == GRUB_ERR_NONE) + { +@@ -369,6 +375,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + fail: + ++ grub_free (kernel); ++ + if (file) + grub_file_close (file); + +-- +2.14.3 + diff --git a/0092-Make-grub-editenv-build-again.patch b/0092-Make-grub-editenv-build-again.patch new file mode 100644 index 0000000..8c82627 --- /dev/null +++ b/0092-Make-grub-editenv-build-again.patch @@ -0,0 +1,30 @@ +From edaa6c877917816d57603e26d660107c82ffbb5d Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 4 Mar 2016 16:29:13 -0500 +Subject: [PATCH 092/123] Make grub-editenv build again. + +36212460d3565b18439a3a8130b28e6c97702c6a split how some of the mkimage +utility functions are defined, and they wind up being linked into +grub-editenv. Most utilities got fixed, but this one was missed. + +Signed-off-by: Peter Jones +--- + Makefile.util.def | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Makefile.util.def b/Makefile.util.def +index 226c46b2d..8007de945 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -236,6 +236,8 @@ program = { + extra_dist = grub-core/osdep/unix/compress.c; + extra_dist = grub-core/osdep/basic/compress.c; + common = util/mkimage.c; ++ common = util/grub-mkimage32.c; ++ common = util/grub-mkimage64.c; + common = grub-core/osdep/config.c; + common = util/config.c; + common = util/resolve.c; +-- +2.14.3 + diff --git a/0092-bz1374141-fix-incorrect-mask-for-ppc64.patch b/0092-bz1374141-fix-incorrect-mask-for-ppc64.patch deleted file mode 100644 index dc77074..0000000 --- a/0092-bz1374141-fix-incorrect-mask-for-ppc64.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 3c49ce8c64b74f535891dd0caa420f1b9dfd9b60 Mon Sep 17 00:00:00 2001 -From: Masahiro Matsuya -Date: Sat, 29 Oct 2016 08:35:26 +0900 -Subject: [PATCH 092/105] bz1374141 fix incorrect mask for ppc64 - -The netmask configured in firmware is not respected on ppc64 (big endian). -When 255.255.252.0 is set as netmask in firmware, the following is the value of bootpath string in grub_ieee1275_parse_bootpath(). - - /vdevice/l-lan@30000002:speed=auto,duplex=auto,192.168.88.10,,192.168.89.113,192.168.88.1,5,5,255.255.252.0,512 - -The netmask in this bootpath is no problem, since it's a value specified in firmware. But, -The value of 'subnet_mask.ipv4' was set with 0xfffffc00, and __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4)) returned 16 (not 22). -As a result, 16 was used for netmask wrongly. - -1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4 (=0xfffffc00) -0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32 (subnet_mask.ipv4) -1111 1111 0000 0011 0000 0000 0000 0000 # ~grub_le_to_cpu32 (subnet_mask.ipv4) - -And, the count of zero with __builtin_ctz can be 16. -This patch changes it as below. - -1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4 (=0xfffffc00) -0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32 (subnet_mask.ipv4) -1111 1111 1111 1111 1111 1100 0000 0000 # grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)) -0000 0000 0000 0000 0000 0011 1111 1111 # ~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)) - -The count of zero with __builtin_clz can be 22. (clz counts the number of one bits preceding the most significant zero bit) ---- - grub-core/net/drivers/ieee1275/ofnet.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index 6bd3b922e..efc4e175a 100644 ---- a/grub-core/net/drivers/ieee1275/ofnet.c -+++ b/grub-core/net/drivers/ieee1275/ofnet.c -@@ -208,7 +208,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, - inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr, - flags); - grub_net_add_ipv4_local (inter, -- __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); -+ __builtin_clz (~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)))); - } - - if (gateway_addr.ipv4 != 0) --- -2.13.0 - diff --git a/0093-Fix-locale-issue-in-grub-setpassword-1294243.patch b/0093-Fix-locale-issue-in-grub-setpassword-1294243.patch new file mode 100644 index 0000000..dcf35a1 --- /dev/null +++ b/0093-Fix-locale-issue-in-grub-setpassword-1294243.patch @@ -0,0 +1,30 @@ +From d2f552900d87b62ca0dbc740902d561bc32f32be Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Fri, 29 Jan 2016 17:34:02 -0500 +Subject: [PATCH 093/123] Fix locale issue in grub-setpassword (#1294243) + +A shell substitution was expecting non-translated output to grab the +hashed password and put it in the user.cfg file. Modified code to force +the generic C locale when this particular piece of code is run. + +Resolves: rhbz#1294243 +--- + util/grub-setpassword.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in +index dd76f00fc..2923f437e 100644 +--- a/util/grub-setpassword.in ++++ b/util/grub-setpassword.in +@@ -105,7 +105,7 @@ getpass() { + P1="$1" && shift + + ( echo ${P0} ; echo ${P1} ) | \ +- ${grub_mkpasswd} | \ ++ LC_ALL=C ${grub_mkpasswd} | \ + grep -v '[eE]nter password:' | \ + sed -e "s/PBKDF2 hash of your password is //" + } +-- +2.14.3 + diff --git a/0093-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch b/0093-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch deleted file mode 100644 index 27d7d65..0000000 --- a/0093-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch +++ /dev/null @@ -1,314 +0,0 @@ -From a159c349f05b21f4d3d7c876200f94481ae1a081 Mon Sep 17 00:00:00 2001 -From: Andrei Borzenkov -Date: Tue, 4 Apr 2017 19:23:55 +0300 -Subject: [PATCH 093/105] i386, x86_64, ppc: fix switch fallthrough cases with - GCC7 - -In util/getroot and efidisk slightly modify exitsing comment to mostly -retain it but still make GCC7 compliant with respect to fall through -annotation. - -In grub-core/lib/xzembed/xz_dec_lzma2.c it adds same comments as -upstream. - -In grub-core/tests/setjmp_tets.c declare functions as "noreturn" to -suppress GCC7 warning. - -In grub-core/gnulib/regexec.c use new __attribute__, because existing -annotation is not recognized by GCC7 parser (which requires that comment -immediately precedes case statement). - -Otherwise add FALLTHROUGH comment. - -Closes: 50598 ---- - grub-core/commands/hdparm.c | 1 + - grub-core/commands/nativedisk.c | 1 + - grub-core/disk/cryptodisk.c | 1 + - grub-core/disk/efi/efidisk.c | 2 +- - grub-core/efiemu/mm.c | 1 + - grub-core/gdb/cstub.c | 1 + - grub-core/gnulib/regexec.c | 3 +++ - grub-core/lib/xzembed/xz_dec_lzma2.c | 4 ++++ - grub-core/lib/xzembed/xz_dec_stream.c | 6 ++++++ - grub-core/loader/i386/linux.c | 3 +++ - grub-core/tests/setjmp_test.c | 5 ++++- - grub-core/video/ieee1275.c | 1 + - grub-core/video/readers/jpeg.c | 1 + - util/getroot.c | 2 +- - util/grub-install.c | 1 + - util/grub-mkimagexx.c | 1 + - util/grub-mount.c | 1 + - 17 files changed, 32 insertions(+), 3 deletions(-) - -diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c -index f6b178eae..d3fa9661e 100644 ---- a/grub-core/commands/hdparm.c -+++ b/grub-core/commands/hdparm.c -@@ -328,6 +328,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args) - ata = ((struct grub_scsi *) disk->data)->data; - break; - } -+ /* FALLTHROUGH */ - default: - grub_disk_close (disk); - return grub_error (GRUB_ERR_IO, "not an ATA device"); -diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c -index 345f97c4d..2f56a870e 100644 ---- a/grub-core/commands/nativedisk.c -+++ b/grub-core/commands/nativedisk.c -@@ -79,6 +79,7 @@ get_uuid (const char *name, char **uuid, int getnative) - case GRUB_DISK_DEVICE_XEN: - if (getnative) - break; -+ /* FALLTHROUGH */ - - /* Virtual disks. */ - /* GRUB dynamically generated files. */ -diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c -index 1e03a091c..bd60a66b3 100644 ---- a/grub-core/disk/cryptodisk.c -+++ b/grub-core/disk/cryptodisk.c -@@ -282,6 +282,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev, - break; - case GRUB_CRYPTODISK_MODE_IV_PLAIN64: - iv[1] = grub_cpu_to_le32 (sector >> 32); -+ /* FALLTHROUGH */ - case GRUB_CRYPTODISK_MODE_IV_PLAIN: - iv[0] = grub_cpu_to_le32 (sector & 0xFFFFFFFF); - break; -diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c -index 3b79f7bbc..a1a52a0a8 100644 ---- a/grub-core/disk/efi/efidisk.c -+++ b/grub-core/disk/efi/efidisk.c -@@ -215,7 +215,7 @@ name_devices (struct grub_efidisk_data *devices) - { - case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE: - is_hard_drive = 1; -- /* Fall through by intention. */ -+ /* Intentionally fall through. */ - case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE: - { - struct grub_efidisk_data *parent, *parent2; -diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c -index e606dbffc..52a032f7b 100644 ---- a/grub-core/efiemu/mm.c -+++ b/grub-core/efiemu/mm.c -@@ -417,6 +417,7 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, - default: - grub_dprintf ("efiemu", - "Unknown memory type %d. Assuming unusable\n", type); -+ /* FALLTHROUGH */ - case GRUB_MEMORY_RESERVED: - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_UNUSABLE_MEMORY); -diff --git a/grub-core/gdb/cstub.c b/grub-core/gdb/cstub.c -index c94411b10..b64acd70f 100644 ---- a/grub-core/gdb/cstub.c -+++ b/grub-core/gdb/cstub.c -@@ -336,6 +336,7 @@ grub_gdb_trap (int trap_no) - /* sAA..AA: Step one instruction from AA..AA(optional). */ - case 's': - stepping = 1; -+ /* FALLTHROUGH */ - - /* cAA..AA: Continue at address AA..AA(optional). */ - case 'c': -diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c -index f632cd47b..a7776f088 100644 ---- a/grub-core/gnulib/regexec.c -+++ b/grub-core/gnulib/regexec.c -@@ -4099,6 +4099,9 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node, - case OP_UTF8_PERIOD: - if (ch >= ASCII_CHARS) - return false; -+#if defined __GNUC__ && __GNUC__ >= 7 -+ __attribute__ ((fallthrough)); -+#endif - /* FALLTHROUGH */ - #endif - case OP_PERIOD: -diff --git a/grub-core/lib/xzembed/xz_dec_lzma2.c b/grub-core/lib/xzembed/xz_dec_lzma2.c -index 8a2a1183d..af7b77079 100644 ---- a/grub-core/lib/xzembed/xz_dec_lzma2.c -+++ b/grub-core/lib/xzembed/xz_dec_lzma2.c -@@ -1044,6 +1044,8 @@ enum xz_ret xz_dec_lzma2_run( - - s->lzma2.sequence = SEQ_LZMA_PREPARE; - -+ /* Fall through */ -+ - case SEQ_LZMA_PREPARE: - if (s->lzma2.compressed < RC_INIT_BYTES) - return XZ_DATA_ERROR; -@@ -1054,6 +1056,8 @@ enum xz_ret xz_dec_lzma2_run( - s->lzma2.compressed -= RC_INIT_BYTES; - s->lzma2.sequence = SEQ_LZMA_RUN; - -+ /* Fall through */ -+ - case SEQ_LZMA_RUN: - /* - * Set dictionary limit to indicate how much we want -diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c -index c16b13060..a29751e14 100644 ---- a/grub-core/lib/xzembed/xz_dec_stream.c -+++ b/grub-core/lib/xzembed/xz_dec_stream.c -@@ -750,6 +750,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) - - s->sequence = SEQ_BLOCK_START; - -+ /* FALLTHROUGH */ - case SEQ_BLOCK_START: - /* We need one byte of input to continue. */ - if (b->in_pos == b->in_size) -@@ -773,6 +774,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) - s->temp.pos = 0; - s->sequence = SEQ_BLOCK_HEADER; - -+ /* FALLTHROUGH */ - case SEQ_BLOCK_HEADER: - if (!fill_temp(s, b)) - return XZ_OK; -@@ -783,6 +785,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) - - s->sequence = SEQ_BLOCK_UNCOMPRESS; - -+ /* FALLTHROUGH */ - case SEQ_BLOCK_UNCOMPRESS: - ret = dec_block(s, b); - if (ret != XZ_STREAM_END) -@@ -810,6 +813,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) - - s->sequence = SEQ_BLOCK_CHECK; - -+ /* FALLTHROUGH */ - case SEQ_BLOCK_CHECK: - ret = hash_validate(s, b, 0); - if (ret != XZ_STREAM_END) -@@ -858,6 +862,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) - - s->sequence = SEQ_INDEX_CRC32; - -+ /* FALLTHROUGH */ - case SEQ_INDEX_CRC32: - ret = hash_validate(s, b, 1); - if (ret != XZ_STREAM_END) -@@ -866,6 +871,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) - s->temp.size = STREAM_HEADER_SIZE; - s->sequence = SEQ_STREAM_FOOTER; - -+ /* FALLTHROUGH */ - case SEQ_STREAM_FOOTER: - if (!fill_temp(s, b)) - return XZ_OK; -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 5eb7d17db..b1335f9ed 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -993,10 +993,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - { - case 'g': - shift += 10; -+ /* FALLTHROUGH */ - case 'm': - shift += 10; -+ /* FALLTHROUGH */ - case 'k': - shift += 10; -+ /* FALLTHROUGH */ - default: - break; - } -diff --git a/grub-core/tests/setjmp_test.c b/grub-core/tests/setjmp_test.c -index 390cb26eb..604a6ce8f 100644 ---- a/grub-core/tests/setjmp_test.c -+++ b/grub-core/tests/setjmp_test.c -@@ -25,7 +25,10 @@ GRUB_MOD_LICENSE ("GPLv3+"); - static grub_jmp_buf jmp_point; - static int expected, ctr; - --#pragma GCC diagnostic ignored "-Wmissing-noreturn" -+/* This fixes GCC7 "unintentional fallthrough" warning */ -+static void jmp0 (void) __attribute__ ((noreturn)); -+static void jmp1 (void) __attribute__ ((noreturn)); -+static void jmp2 (void) __attribute__ ((noreturn)); - - static void - jmp0 (void) -diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c -index 813ab38e1..b8e4b3feb 100644 ---- a/grub-core/video/ieee1275.c -+++ b/grub-core/video/ieee1275.c -@@ -181,6 +181,7 @@ grub_video_ieee1275_fill_mode_info (grub_ieee1275_phandle_t dev, - case 32: - out->reserved_mask_size = 8; - out->reserved_field_pos = 24; -+ /* FALLTHROUGH */ - - case 24: - out->red_mask_size = 8; -diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c -index c3e0df240..21b0d9ded 100644 ---- a/grub-core/video/readers/jpeg.c -+++ b/grub-core/video/readers/jpeg.c -@@ -736,6 +736,7 @@ grub_jpeg_decode_jpeg (struct grub_jpeg_data *data) - case JPEG_MARKER_SOS: /* Start Of Scan. */ - if (grub_jpeg_decode_sos (data)) - break; -+ /* FALLTHROUGH */ - case JPEG_MARKER_RST0: /* Restart. */ - case JPEG_MARKER_RST1: - case JPEG_MARKER_RST2: -diff --git a/util/getroot.c b/util/getroot.c -index bf317a28e..fa3460d6c 100644 ---- a/util/getroot.c -+++ b/util/getroot.c -@@ -99,7 +99,7 @@ grub_util_pull_device (const char *os_dev) - { - case GRUB_DEV_ABSTRACTION_LVM: - grub_util_pull_lvm_by_command (os_dev); -- /* Fallthrough in case that lvm-tools are unavailable. */ -+ /* Fallthrough - in case that lvm-tools are unavailable. */ - case GRUB_DEV_ABSTRACTION_LUKS: - grub_util_pull_devmapper (os_dev); - return; -diff --git a/util/grub-install.c b/util/grub-install.c -index 6c89c2b0c..9074d3e9e 100644 ---- a/util/grub-install.c -+++ b/util/grub-install.c -@@ -1851,6 +1851,7 @@ main (int argc, char *argv[]) - free (mach_kernel); - break; - } -+ /* FALLTHROUGH */ - case GRUB_INSTALL_PLATFORM_ARM_EFI: - case GRUB_INSTALL_PLATFORM_ARM64_EFI: - case GRUB_INSTALL_PLATFORM_IA64_EFI: -diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c -index 353a9407a..95ceab629 100644 ---- a/util/grub-mkimagexx.c -+++ b/util/grub-mkimagexx.c -@@ -908,6 +908,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - + sym->st_value - - image_target->vaddr_offset)); - } -+ /* FALLTHROUGH */ - case R_IA64_LTOFF_FPTR22: - *gpptr = grub_host_to_target64 (addend + sym_addr); - grub_ia64_add_value_to_slot_21 ((grub_addr_t) target, -diff --git a/util/grub-mount.c b/util/grub-mount.c -index aca5f82e3..a25db8a71 100644 ---- a/util/grub-mount.c -+++ b/util/grub-mount.c -@@ -530,6 +530,7 @@ argp_parser (int key, char *arg, struct argp_state *state) - if (arg[0] != '-') - break; - -+ /* FALLTHROUGH */ - default: - if (!arg) - return 0; --- -2.13.0 - diff --git a/0094-Fix-up-some-man-pages-rpmdiff-noticed.patch b/0094-Fix-up-some-man-pages-rpmdiff-noticed.patch new file mode 100644 index 0000000..a070ffc --- /dev/null +++ b/0094-Fix-up-some-man-pages-rpmdiff-noticed.patch @@ -0,0 +1,153 @@ +From 216188f920d3ade19626d6e8fe450cea2c427e53 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 23 Sep 2014 09:58:49 -0400 +Subject: [PATCH 094/123] Fix up some man pages rpmdiff noticed. + +--- + configure.ac | 2 ++ + util/grub-macbless.8 | 26 +++++++++++++++++++ + util/grub-mkimage.1 | 2 +- + util/grub-syslinux2cfg.1 | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 94 insertions(+), 1 deletion(-) + create mode 100644 util/grub-macbless.8 + create mode 100644 util/grub-syslinux2cfg.1 + +diff --git a/configure.ac b/configure.ac +index 67ff20cfd..25de2c12a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -78,6 +78,7 @@ grub_TRANSFORM([grub-fstest.3]) + grub_TRANSFORM([grub-glue-efi.3]) + grub_TRANSFORM([grub-install.1]) + grub_TRANSFORM([grub-kbdcomp.3]) ++grub_TRANSFORM([grub-macbless.8]) + grub_TRANSFORM([grub-menulst2cfg.1]) + grub_TRANSFORM([grub-mkconfig.1]) + grub_TRANSFORM([grub-mkfont.3]) +@@ -96,6 +97,7 @@ grub_TRANSFORM([grub-render-label.3]) + grub_TRANSFORM([grub-script-check.3]) + grub_TRANSFORM([grub-set-default.1]) + grub_TRANSFORM([grub-sparc64-setup.3]) ++grub_TRANSFORM([grub-syslinux2cfg.1]) + + # Optimization flag. Allow user to override. + if test "x$TARGET_CFLAGS" = x; then +diff --git a/util/grub-macbless.8 b/util/grub-macbless.8 +new file mode 100644 +index 000000000..ae842f3a6 +--- /dev/null ++++ b/util/grub-macbless.8 +@@ -0,0 +1,26 @@ ++.TH GRUB-MACBLESS 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-macbless\fR \(em Mac-style bless utility for HFS or HFS+ ++ ++.SH SYNOPSIS ++\fBgrub-macbless\fR [-p | --ppc] [-v | --verbose] [-x | --x86] \fIFILE\fR ++ ++.SH DESCRIPTION ++\fBgrub-mkimage\fR blesses a file on an HFS or HFS+ file system, so that it ++can be used to boot a Mac. ++ ++.SH OPTIONS ++.TP ++--ppc ++Bless the file for use on PPC-based Macs. ++ ++.TP ++--verbose ++Print verbose messages. ++ ++.TP ++--x86 ++Bless the file for use on x86-based Macs. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-mkimage.1 b/util/grub-mkimage.1 +index 4dea4f545..0eaaafe50 100644 +--- a/util/grub-mkimage.1 ++++ b/util/grub-mkimage.1 +@@ -17,7 +17,7 @@ + [-v | --verbose] \fIMODULES\fR + + .SH DESCRIPTION +-\fBgrub-mkimage\fI builds a bootable image of GRUB. ++\fBgrub-mkimage\fR builds a bootable image of GRUB. + + .SH OPTIONS + .TP +diff --git a/util/grub-syslinux2cfg.1 b/util/grub-syslinux2cfg.1 +new file mode 100644 +index 000000000..853094827 +--- /dev/null ++++ b/util/grub-syslinux2cfg.1 +@@ -0,0 +1,65 @@ ++.TH GRUB-SYSLINUX2CFG 1 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-syslinux2cfg\fR \(em Transform a syslinux config file into a GRUB config. ++ ++.SH SYNOPSIS ++\fBgrub-syslinux2cfg\fR [-c | --cwd=\fRDIR\fI] [-r | --root=\fIDIR\fR] [-v | --verbose] ++.RE ++.RS 25 ++[-t | --target-root=\fIDIR\fR] [-T | --target-cwd=\fIDIR\fR] ++.RE ++.RS 25 ++[-o | --output=\fIFILE\fR] [[-i | --isolinux] | ++.RE ++.RS 46 ++ [-s | --syslinux] | ++.RE ++.RS 46 ++ [-p | --pxelinux]] \fIFILE\fR ++ ++.SH DESCRIPTION ++\fBgrub-syslinux2cfg\fR builds a GRUB configuration file out of an existing ++syslinux configuration file. ++ ++.SH OPTIONS ++.TP ++--cwd=\fIDIR\fR ++Set \fIDIR\fR as syslinux's working directory. The default is to use the ++parent directory of the input file. ++ ++.TP ++--root=\fIDIR\fR ++Set \fIDIR\fR as the root directory of the syslinux disk. The default value ++is "/". ++ ++.TP ++--verbose ++Print verbose messages. ++ ++.TP ++--target-root=\fIDIR\fR ++Root directory as it will be seen at runtime. The default value is "/". ++ ++.TP ++--target-cwd=\fIDIR\fR ++Working directory of syslinux as it will be seen at runtime. The default ++value is the parent directory of the input file. ++ ++.TP ++--output=\fIFILE\fR ++Write the new config file to \fIFILE\fR. The default value is standard output. ++ ++.TP ++--isolinux ++Assume that the input file is an isolinux configuration file. ++ ++.TP ++--pxelinux ++Assume that the input file is a pxelinux configuration file. ++ ++.TP ++--syslinux ++Assume that the input file is a syslinux configuration file. ++ ++.SH SEE ALSO ++.BR "info grub" +-- +2.14.3 + diff --git a/0094-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch b/0094-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch deleted file mode 100644 index c167995..0000000 --- a/0094-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch +++ /dev/null @@ -1,65 +0,0 @@ -From bc96a64f7947ef8c09f59392ec63ddf0937d20f9 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:31:46 -0400 -Subject: [PATCH 094/105] Work around autoconf 2.69 having a terrible - AC_HEADER_MAJOR - ---- - configure.ac | 38 +++++++++++++++++++++++++++++++++++++- - 1 file changed, 37 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 1d8f7e745..70204bbf0 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -424,10 +424,46 @@ else - AC_PATH_PROG(HELP2MAN, help2man) - fi - -+# AC_HEADER_MAJOR_OI -+# --------------- -+AN_FUNCTION([major], [AC_HEADER_MAJOR_OI]) -+AN_FUNCTION([makedev], [AC_HEADER_MAJOR_OI]) -+AN_FUNCTION([minor], [AC_HEADER_MAJOR_OI]) -+AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR_OI]) -+AC_DEFUN([AC_HEADER_MAJOR_OI], -+[AC_CACHE_CHECK(whether sys/sysmacros.h defines makedev, -+ ac_cv_header_sys_sysmacros_h_makedev, -+[AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], -+ [[return makedev(0, 0);]])], -+ [ac_cv_header_sys_sysmacros_h_makedev=yes], -+ [ac_cv_header_sys_sysmacros_h_makedev=no]) -+]) -+ -+if test $ac_cv_header_sys_sysmacros_h_makedev = no; then -+AC_CHECK_HEADER(sys/mkdev.h, -+ [AC_DEFINE(MAJOR_IN_MKDEV, 1, -+ [Define to 1 if `major', `minor', and `makedev' are -+ declared in .])]) -+ -+ if test $ac_cv_header_sys_mkdev_h = no; then -+ AC_CHECK_HEADER(sys/types.h, -+ [AC_DEFINE(MAJOR_IN_TYPES, 1, -+ [Define to 1 if `major', `minor', and `makedev' -+ are declared in .])]) -+ fi -+ -+else -+ AC_DEFINE(MAJOR_IN_SYSMACROS, 1, -+ [Define to 1 if `major', `minor', and `makedev' -+ are declared in .]) -+fi -+])# AC_HEADER_MAJOR_OI -+ -+ - # Check for functions and headers. - AC_CHECK_FUNCS(posix_memalign memalign getextmntent) - AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) --AC_HEADER_MAJOR -+AC_HEADER_MAJOR_OI - - AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default - #include --- -2.13.0 - diff --git a/0095-Fix-a-btrfs-read-before-init-bug.patch b/0095-Fix-a-btrfs-read-before-init-bug.patch deleted file mode 100644 index fdad7f1..0000000 --- a/0095-Fix-a-btrfs-read-before-init-bug.patch +++ /dev/null @@ -1,39 +0,0 @@ -From de37bf80fed16a991a9218ca5fb73008f59cd689 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:35:47 -0400 -Subject: [PATCH 095/105] Fix a btrfs read-before-init bug - ---- - grub-core/fs/btrfs.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 9cffa91fa..cb25b9ddd 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -232,10 +232,6 @@ read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) - for (i = 0; i < ARRAY_SIZE (superblock_sectors); i++) - { - struct grub_btrfs_superblock sblock; -- /* Don't try additional superblocks beyond device size. */ -- if (i && (grub_le_to_cpu64 (sblock.this_device.size) -- >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i]) -- break; - err = grub_disk_read (disk, superblock_sectors[i], 0, - sizeof (sblock), &sblock); - if (err == GRUB_ERR_OUT_OF_RANGE) -@@ -247,6 +243,11 @@ read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) - if (i == 0 || grub_le_to_cpu64 (sblock.generation) - > grub_le_to_cpu64 (sb->generation)) - grub_memcpy (sb, &sblock, sizeof (sblock)); -+ -+ /* Don't try additional superblocks beyond device size. */ -+ if (i && (grub_le_to_cpu64 (sblock.this_device.size) -+ >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i]) -+ break; - } - - if ((err == GRUB_ERR_OUT_OF_RANGE || !err) && i == 0) --- -2.13.0 - diff --git a/0095-Handle-rssd-storage-devices.patch b/0095-Handle-rssd-storage-devices.patch new file mode 100644 index 0000000..c91898a --- /dev/null +++ b/0095-Handle-rssd-storage-devices.patch @@ -0,0 +1,39 @@ +From 90e2d3fbb161d494cdfc0ad0da740a6a4f651d70 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 30 Jun 2015 15:50:41 -0400 +Subject: [PATCH 095/123] Handle rssd storage devices. + +Resolves: rhbz#1087962 + +Signed-off-by: Peter Jones +--- + grub-core/osdep/linux/getroot.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c +index 09e7e6e6d..ad7b77411 100644 +--- a/grub-core/osdep/linux/getroot.c ++++ b/grub-core/osdep/linux/getroot.c +@@ -898,6 +898,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, + return path; + } + ++ /* If this is an rssd device. */ ++ if ((strncmp ("rssd", p, 4) == 0) && p[4] >= 'a' && p[4] <= 'z') ++ { ++ char *pp = p + 4; ++ while (*pp >= 'a' && *pp <= 'z') ++ pp++; ++ if (*pp) ++ *is_part = 1; ++ /* /dev/rssd[a-z]+[0-9]* */ ++ *pp = '\0'; ++ return path; ++ } ++ + /* If this is a loop device */ + if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9') + { +-- +2.14.3 + diff --git a/0096-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch b/0096-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch deleted file mode 100644 index b28346a..0000000 --- a/0096-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch +++ /dev/null @@ -1,46 +0,0 @@ -From e26bdce564d529852f8f3d27874dc15467839033 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:42:57 -0400 -Subject: [PATCH 096/105] Don't use dynamic sized arrays since we don't build - with -std=c99 - ---- - grub-core/net/net.c | 17 ++++++++++++++--- - 1 file changed, 14 insertions(+), 3 deletions(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 16d2ce06d..b4325750f 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -1781,14 +1781,25 @@ grub_net_search_configfile (char *config) - { - /* By the Client UUID. */ - -- char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) + -- sizeof ("_clientuuid") + 1]; -- grub_snprintf (client_uuid_var, sizeof (client_uuid_var), -+ char *client_uuid_var; -+ grub_size_t client_uuid_var_size; -+ -+ client_uuid_var_size = grub_snprintf (NULL, 0, -+ "net_%s_clientuuid", inf->name); -+ if (client_uuid_var_size <= 0) -+ continue; -+ client_uuid_var_size += 1; -+ client_uuid_var = grub_malloc(client_uuid_var_size); -+ if (!client_uuid_var) -+ continue; -+ grub_snprintf (client_uuid_var, client_uuid_var_size, - "net_%s_clientuuid", inf->name); - - const char *client_uuid; - client_uuid = grub_env_get (client_uuid_var); - -+ grub_free(client_uuid_var); -+ - if (client_uuid) - { - grub_strcpy (suffix, client_uuid); --- -2.13.0 - diff --git a/0096-Warn-if-grub-password-will-not-be-read-1290803.patch b/0096-Warn-if-grub-password-will-not-be-read-1290803.patch new file mode 100644 index 0000000..4c690d6 --- /dev/null +++ b/0096-Warn-if-grub-password-will-not-be-read-1290803.patch @@ -0,0 +1,31 @@ +From f46e9b0378cfaced22f0de5e8061ddb0c6829ee8 Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Mon, 22 Feb 2016 15:30:05 -0500 +Subject: [PATCH 096/123] Warn if grub password will not be read (#1290803) + +It is possible for a system to have never run grub-mkconfig and add the +section that reads the user.cfg file which contains a user set GRUB +password. Users in that scenario will now be warned that grub-mkconfig +must be run prior to their newly set password taking effect. + +Resolves: rhbz#1290803 +--- + util/grub-setpassword.in | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in +index 2923f437e..dd7b79326 100644 +--- a/util/grub-setpassword.in ++++ b/util/grub-setpassword.in +@@ -121,3 +121,8 @@ fi + install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : + chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : + echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" ++ ++if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${grubdir}/grub.cfg"; then ++ echo "WARNING: The current configuration lacks password support!" ++ echo "Update your configuration with @grub_mkconfig@ to support this feature." ++fi +-- +2.14.3 + diff --git a/0097-Clean-up-grub-setpassword-documentation-1290799.patch b/0097-Clean-up-grub-setpassword-documentation-1290799.patch new file mode 100644 index 0000000..b385a5a --- /dev/null +++ b/0097-Clean-up-grub-setpassword-documentation-1290799.patch @@ -0,0 +1,58 @@ +From f41adcd85164ef8a0d0918f0508f29dcf3c7467d Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Tue, 26 Jan 2016 10:28:35 -0500 +Subject: [PATCH 097/123] Clean up grub-setpassword documentation (#1290799) + +The output for --help had some errors. Corrected those and polished the +text to be a little easier to follow. Carried verbage over to man page +to maintain internal consistency. + +Resolves: rhbz#1290799 +--- + util/grub-setpassword.8 | 2 +- + util/grub-setpassword.in | 15 +++++++-------- + 2 files changed, 8 insertions(+), 9 deletions(-) + +diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 +index 49200a848..dc91dd669 100644 +--- a/util/grub-setpassword.8 ++++ b/util/grub-setpassword.8 +@@ -19,7 +19,7 @@ Display program usage and exit. + -v, --version + Display the current version. + .TP +--o, --output[=\fIDIRECTORY PATH\fR] ++-o, --output=<\fIDIRECTORY\fR> + Choose the file path to which user.cfg will be written. + + .SH SEE ALSO +diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in +index dd7b79326..d7924af51 100644 +--- a/util/grub-setpassword.in ++++ b/util/grub-setpassword.in +@@ -16,15 +16,14 @@ grub_mkpasswd="${bindir}/@grub_mkpasswd_pbkdf2@" + # Print the usage. + usage () { + cat < put user.cfg in a user-selected directory + + Report bugs at https://bugzilla.redhat.com. + EOF +-- +2.14.3 + diff --git a/0097-don-t-ignore-const.patch b/0097-don-t-ignore-const.patch deleted file mode 100644 index 14a65f3..0000000 --- a/0097-don-t-ignore-const.patch +++ /dev/null @@ -1,25 +0,0 @@ -From f2b28326d5aa2cdcaa56def8a806fbcc23962c03 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:43:22 -0400 -Subject: [PATCH 097/105] don't ignore const - ---- - grub-core/net/tftp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index c4b5205d0..dd4ce6b23 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -307,7 +307,7 @@ static void - grub_normalize_filename (char *normalized, const char *filename) - { - char *dest = normalized; -- char *src = filename; -+ const char *src = filename; - - while (*src != '\0') - { --- -2.13.0 - diff --git a/0098-Re-work-some-intricacies-of-PE-loading.patch b/0098-Re-work-some-intricacies-of-PE-loading.patch new file mode 100644 index 0000000..38964f9 --- /dev/null +++ b/0098-Re-work-some-intricacies-of-PE-loading.patch @@ -0,0 +1,353 @@ +From e2b22111a8ec58091603fc785f54b1b998888735 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 9 Jun 2016 12:22:29 -0400 +Subject: [PATCH 098/123] Re-work some intricacies of PE loading. + +The PE spec is not a well written document, and awesomely every place +where there's an ambiguous way to read something, Windows' bootmgfw.efi +takes a different read than either of them. +--- + grub-core/loader/efi/chainloader.c | 156 +++++++++++++++++++++++++++++-------- + include/grub/efi/pe32.h | 32 +++++++- + 2 files changed, 152 insertions(+), 36 deletions(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index c4184fa64..323f8738b 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -297,7 +297,7 @@ image_is_64_bit (grub_pe_header_t *pe_hdr) + return 0; + } + +-static const grub_uint16_t machine_type = ++static const grub_uint16_t machine_type __attribute__((__unused__)) = + #if defined(__x86_64__) + GRUB_PE32_MACHINE_X86_64; + #elif defined(__aarch64__) +@@ -363,10 +363,10 @@ relocate_coff (pe_coff_loader_image_context_t *context, + + reloc_base = image_address (orig, size, section->raw_data_offset); + reloc_base_end = image_address (orig, size, section->raw_data_offset +- + section->virtual_size - 1); ++ + section->virtual_size); + +- grub_dprintf ("chain", "reloc_base %p reloc_base_end %p\n", reloc_base, +- reloc_base_end); ++ grub_dprintf ("chain", "relocate_coff(): reloc_base %p reloc_base_end %p\n", ++ reloc_base, reloc_base_end); + + if (!reloc_base && !reloc_base_end) + return GRUB_EFI_SUCCESS; +@@ -503,12 +503,13 @@ handle_image (void *data, grub_efi_uint32_t datasize) + grub_efi_status_t efi_status; + char *buffer = NULL; + char *buffer_aligned = NULL; +- grub_efi_uint32_t i, size; ++ grub_efi_uint32_t i; + struct grub_pe32_section_table *section; + char *base, *end; + pe_coff_loader_image_context_t context; + grub_uint32_t section_alignment; + grub_uint32_t buffer_size; ++ int found_entry_point = 0; + + b = grub_efi_system_table->boot_services; + +@@ -522,8 +523,28 @@ handle_image (void *data, grub_efi_uint32_t datasize) + goto error_exit; + } + ++ /* ++ * The spec says, uselessly, of SectionAlignment: ++ * ===== ++ * The alignment (in bytes) of sections when they are loaded into ++ * memory. It must be greater than or equal to FileAlignment. The ++ * default is the page size for the architecture. ++ * ===== ++ * Which doesn't tell you whose responsibility it is to enforce the ++ * "default", or when. It implies that the value in the field must ++ * be > FileAlignment (also poorly defined), but it appears visual ++ * studio will happily write 512 for FileAlignment (its default) and ++ * 0 for SectionAlignment, intending to imply PAGE_SIZE. ++ * ++ * We only support one page size, so if it's zero, nerf it to 4096. ++ */ + section_alignment = context.section_alignment; ++ if (section_alignment == 0) ++ section_alignment = 4096; ++ + buffer_size = context.image_size + section_alignment; ++ grub_dprintf ("chain", "image size is %08lx, datasize is %08x\n", ++ context.image_size, datasize); + + efi_status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, + buffer_size, &buffer); +@@ -535,7 +556,6 @@ handle_image (void *data, grub_efi_uint32_t datasize) + } + + buffer_aligned = (char *)ALIGN_UP ((grub_addr_t)buffer, section_alignment); +- + if (!buffer_aligned) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); +@@ -544,27 +564,62 @@ handle_image (void *data, grub_efi_uint32_t datasize) + + grub_memcpy (buffer_aligned, data, context.size_of_headers); + ++ entry_point = image_address (buffer_aligned, context.image_size, ++ context.entry_point); ++ ++ grub_dprintf ("chain", "entry_point: %p\n", entry_point); ++ if (!entry_point) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid entry point"); ++ goto error_exit; ++ } ++ + char *reloc_base, *reloc_base_end; +- reloc_base = image_address (buffer_aligned, datasize, ++ grub_dprintf ("chain", "reloc_dir: %p reloc_size: 0x%08x\n", ++ (void *)(unsigned long long)context.reloc_dir->rva, ++ context.reloc_dir->size); ++ reloc_base = image_address (buffer_aligned, context.image_size, + context.reloc_dir->rva); + /* RelocBaseEnd here is the address of the last byte of the table */ +- reloc_base_end = image_address (buffer_aligned, datasize, ++ reloc_base_end = image_address (buffer_aligned, context.image_size, + context.reloc_dir->rva + + context.reloc_dir->size - 1); ++ grub_dprintf ("chain", "reloc_base: %p reloc_base_end: %p\n", ++ reloc_base, reloc_base_end); ++ + struct grub_pe32_section_table *reloc_section = NULL; + + section = context.first_section; + for (i = 0; i < context.number_of_sections; i++, section++) + { +- size = section->virtual_size; +- if (size > section->raw_data_size) +- size = section->raw_data_size; ++ char name[9]; + + base = image_address (buffer_aligned, context.image_size, + section->virtual_address); + end = image_address (buffer_aligned, context.image_size, +- section->virtual_address + size - 1); ++ section->virtual_address + section->virtual_size -1); + ++ grub_strncpy(name, section->name, 9); ++ name[8] = '\0'; ++ grub_dprintf ("chain", "Section %d \"%s\" at %p..%p\n", i, ++ name, base, end); ++ ++ if (end < base) ++ { ++ grub_dprintf ("chain", " base is %p but end is %p... bad.\n", ++ base, end); ++ grub_error (GRUB_ERR_BAD_ARGUMENT, ++ "Image has invalid negative size"); ++ goto error_exit; ++ } ++ ++ if (section->virtual_address <= context.entry_point && ++ (section->virtual_address + section->raw_data_size - 1) ++ > context.entry_point) ++ { ++ found_entry_point++; ++ grub_dprintf ("chain", " section contains entry point\n"); ++ } + + /* We do want to process .reloc, but it's often marked + * discardable, so we don't want to memcpy it. */ +@@ -583,21 +638,46 @@ handle_image (void *data, grub_efi_uint32_t datasize) + if (section->raw_data_size && section->virtual_size && + base && end && reloc_base == base && reloc_base_end == end) + { ++ grub_dprintf ("chain", " section is relocation section\n"); + reloc_section = section; + } ++ else ++ { ++ grub_dprintf ("chain", " section is not reloc section?\n"); ++ grub_dprintf ("chain", " rds: 0x%08x, vs: %08x\n", ++ section->raw_data_size, section->virtual_size); ++ grub_dprintf ("chain", " base: %p end: %p\n", base, end); ++ grub_dprintf ("chain", " reloc_base: %p reloc_base_end: %p\n", ++ reloc_base, reloc_base_end); ++ } + } + +- if (section->characteristics && GRUB_PE32_SCN_MEM_DISCARDABLE) +- continue; ++ grub_dprintf ("chain", " Section characteristics are %08x\n", ++ section->characteristics); ++ grub_dprintf ("chain", " Section virtual size: %08x\n", ++ section->virtual_size); ++ grub_dprintf ("chain", " Section raw_data size: %08x\n", ++ section->raw_data_size); ++ if (section->characteristics & GRUB_PE32_SCN_MEM_DISCARDABLE) ++ { ++ grub_dprintf ("chain", " Discarding section\n"); ++ continue; ++ } + + if (!base || !end) + { ++ grub_dprintf ("chain", " section is invalid\n"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid section size"); + goto error_exit; + } + +- if (section->virtual_address < context.size_of_headers || +- section->raw_data_offset < context.size_of_headers) ++ if (section->characteristics & GRUB_PE32_SCN_CNT_UNINITIALIZED_DATA) ++ { ++ if (section->raw_data_size != 0) ++ grub_dprintf ("chain", " UNINITIALIZED_DATA section has data?\n"); ++ } ++ else if (section->virtual_address < context.size_of_headers || ++ section->raw_data_offset < context.size_of_headers) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, + "Section %d is inside image headers", i); +@@ -605,13 +685,24 @@ handle_image (void *data, grub_efi_uint32_t datasize) + } + + if (section->raw_data_size > 0) +- grub_memcpy (base, (grub_efi_uint8_t*)data + section->raw_data_offset, +- size); ++ { ++ grub_dprintf ("chain", " copying 0x%08x bytes to %p\n", ++ section->raw_data_size, base); ++ grub_memcpy (base, ++ (grub_efi_uint8_t*)data + section->raw_data_offset, ++ section->raw_data_size); ++ } + +- if (size < section->virtual_size) +- grub_memset (base + size, 0, section->virtual_size - size); ++ if (section->raw_data_size < section->virtual_size) ++ { ++ grub_dprintf ("chain", " padding with 0x%08x bytes at %p\n", ++ section->virtual_size - section->raw_data_size, ++ base + section->raw_data_size); ++ grub_memset (base + section->raw_data_size, 0, ++ section->virtual_size - section->raw_data_size); ++ } + +- grub_dprintf ("chain", "copied section %s\n", section->name); ++ grub_dprintf ("chain", " finished section %s\n", name); + } + + /* 5 == EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC */ +@@ -634,12 +725,15 @@ handle_image (void *data, grub_efi_uint32_t datasize) + } + } + +- entry_point = image_address (buffer_aligned, context.image_size, +- context.entry_point); +- +- if (!entry_point) ++ if (!found_entry_point) + { +- grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid entry point"); ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "entry point is not within sections"); ++ goto error_exit; ++ } ++ if (found_entry_point > 1) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, "%d sections contain entry point", ++ found_entry_point); + goto error_exit; + } + +@@ -657,26 +751,24 @@ handle_image (void *data, grub_efi_uint32_t datasize) + li->load_options_size = cmdline_len; + li->file_path = grub_efi_get_media_file_path (file_path); + li->device_handle = dev_handle; +- if (li->file_path) +- { +- grub_printf ("file path: "); +- grub_efi_print_device_path (li->file_path); +- } +- else ++ if (!li->file_path) + { + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file path found"); + goto error_exit; + } + ++ grub_dprintf ("chain", "booting via entry point\n"); + efi_status = efi_call_2 (entry_point, grub_efi_image_handle, + grub_efi_system_table); + ++ grub_dprintf ("chain", "entry_point returned %ld\n", efi_status); + grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); + efi_status = efi_call_1 (b->free_pool, buffer); + + return 1; + + error_exit: ++ grub_dprintf ("chain", "error_exit: grub_errno: %d\n", grub_errno); + if (buffer) + efi_call_1 (b->free_pool, buffer); + +diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h +index f79782e1b..8396bde49 100644 +--- a/include/grub/efi/pe32.h ++++ b/include/grub/efi/pe32.h +@@ -227,12 +227,18 @@ struct grub_pe32_section_table + grub_uint32_t characteristics; + }; + ++#define GRUB_PE32_SCN_TYPE_NO_PAD 0x00000008 + #define GRUB_PE32_SCN_CNT_CODE 0x00000020 + #define GRUB_PE32_SCN_CNT_INITIALIZED_DATA 0x00000040 +-#define GRUB_PE32_SCN_MEM_DISCARDABLE 0x02000000 +-#define GRUB_PE32_SCN_MEM_EXECUTE 0x20000000 +-#define GRUB_PE32_SCN_MEM_READ 0x40000000 +-#define GRUB_PE32_SCN_MEM_WRITE 0x80000000 ++#define GRUB_PE32_SCN_CNT_UNINITIALIZED_DATA 0x00000080 ++#define GRUB_PE32_SCN_LNK_OTHER 0x00000100 ++#define GRUB_PE32_SCN_LNK_INFO 0x00000200 ++#define GRUB_PE32_SCN_LNK_REMOVE 0x00000800 ++#define GRUB_PE32_SCN_LNK_COMDAT 0x00001000 ++#define GRUB_PE32_SCN_GPREL 0x00008000 ++#define GRUB_PE32_SCN_MEM_16BIT 0x00020000 ++#define GRUB_PE32_SCN_MEM_LOCKED 0x00040000 ++#define GRUB_PE32_SCN_MEM_PRELOAD 0x00080000 + + #define GRUB_PE32_SCN_ALIGN_1BYTES 0x00100000 + #define GRUB_PE32_SCN_ALIGN_2BYTES 0x00200000 +@@ -241,10 +247,28 @@ struct grub_pe32_section_table + #define GRUB_PE32_SCN_ALIGN_16BYTES 0x00500000 + #define GRUB_PE32_SCN_ALIGN_32BYTES 0x00600000 + #define GRUB_PE32_SCN_ALIGN_64BYTES 0x00700000 ++#define GRUB_PE32_SCN_ALIGN_128BYTES 0x00800000 ++#define GRUB_PE32_SCN_ALIGN_256BYTES 0x00900000 ++#define GRUB_PE32_SCN_ALIGN_512BYTES 0x00A00000 ++#define GRUB_PE32_SCN_ALIGN_1024BYTES 0x00B00000 ++#define GRUB_PE32_SCN_ALIGN_2048BYTES 0x00C00000 ++#define GRUB_PE32_SCN_ALIGN_4096BYTES 0x00D00000 ++#define GRUB_PE32_SCN_ALIGN_8192BYTES 0x00E00000 + + #define GRUB_PE32_SCN_ALIGN_SHIFT 20 + #define GRUB_PE32_SCN_ALIGN_MASK 7 + ++#define GRUB_PE32_SCN_LNK_NRELOC_OVFL 0x01000000 ++#define GRUB_PE32_SCN_MEM_DISCARDABLE 0x02000000 ++#define GRUB_PE32_SCN_MEM_NOT_CACHED 0x04000000 ++#define GRUB_PE32_SCN_MEM_NOT_PAGED 0x08000000 ++#define GRUB_PE32_SCN_MEM_SHARED 0x10000000 ++#define GRUB_PE32_SCN_MEM_EXECUTE 0x20000000 ++#define GRUB_PE32_SCN_MEM_READ 0x40000000 ++#define GRUB_PE32_SCN_MEM_WRITE 0x80000000 ++ ++ ++ + #define GRUB_PE32_SIGNATURE_SIZE 4 + + struct grub_pe32_header +-- +2.14.3 + diff --git a/0098-don-t-use-int-for-efi-status.patch b/0098-don-t-use-int-for-efi-status.patch deleted file mode 100644 index b5eaeda..0000000 --- a/0098-don-t-use-int-for-efi-status.patch +++ /dev/null @@ -1,25 +0,0 @@ -From c694f0875585ed90c1429c7ea28be55613c5e817 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:44:59 -0400 -Subject: [PATCH 098/105] don't use int for efi status - ---- - grub-core/kern/efi/efi.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 101307fc7..e22c97675 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -157,7 +157,7 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) - void - grub_exit (int retval) - { -- int rc = GRUB_EFI_LOAD_ERROR; -+ grub_efi_status_t rc = GRUB_EFI_LOAD_ERROR; - - if (retval == 0) - rc = GRUB_EFI_SUCCESS; --- -2.13.0 - diff --git a/0099-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch b/0099-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch new file mode 100644 index 0000000..46a1895 --- /dev/null +++ b/0099-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch @@ -0,0 +1,387 @@ +From 8b4deb97529ba7ff689a11639f2a5bfdb29ad2ea Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 10 Jun 2016 14:06:15 -0400 +Subject: [PATCH 099/123] Rework even more of efi chainload so non-sb cases + work right. + +This ensures that if shim protocol is not loaded, or is loaded but shim +is disabled, we will fall back to a correct load method for the efi +chain loader. + +Here's what I tested with this version: + +results expected actual +------------------------------------------------------------ +sb + enabled + shim + fedora success success +sb + enabled + shim + win success success +sb + enabled + grub + fedora fail fail +sb + enabled + grub + win fail fail + +sb + mokdisabled + shim + fedora success success +sb + mokdisabled + shim + win success success +sb + mokdisabled + grub + fedora fail fail +sb + mokdisabled + grub + win fail fail + +sb disabled + shim + fedora success success* +sb disabled + shim + win success success* +sb disabled + grub + fedora success success +sb disabled + grub + win success success + +nosb + shim + fedora success success* +nosb + shim + win success success* +nosb + grub + fedora success success +nosb + grub + win success success + +* for some reason shim protocol is being installed in these cases, and I + can't see why, but I think it may be this firmware build returning an + erroneous value. But this effectively falls back to the mokdisabled + behavior, which works correctly, and the presence of the "grub" (i.e. + no shim) tests effectively tests the desired behavior here. + +Resolves: rhbz#1344512 + +Signed-off-by: Peter Jones +--- + grub-core/kern/efi/sb.c | 14 +++-- + grub-core/loader/arm64/linux.c | 4 +- + grub-core/loader/efi/chainloader.c | 115 ++++++++++++++++++++++--------------- + grub-core/loader/efi/linux.c | 13 +++-- + grub-core/loader/i386/efi/linux.c | 10 +++- + include/grub/efi/linux.h | 2 +- + 6 files changed, 99 insertions(+), 59 deletions(-) + +diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c +index a41b6c5b8..d74778b0c 100644 +--- a/grub-core/kern/efi/sb.c ++++ b/grub-core/kern/efi/sb.c +@@ -36,14 +36,20 @@ grub_efi_secure_boot (void) + grub_efi_boolean_t ret = 0; + + secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); +- + if (datasize != 1 || !secure_boot) +- goto out; ++ { ++ grub_dprintf ("secureboot", "No SecureBoot variable\n"); ++ goto out; ++ } ++ grub_dprintf ("secureboot", "SecureBoot: %d\n", *secure_boot); + + setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); +- + if (datasize != 1 || !setup_mode) +- goto out; ++ { ++ grub_dprintf ("secureboot", "No SetupMode variable\n"); ++ goto out; ++ } ++ grub_dprintf ("secureboot", "SetupMode: %d\n", *setup_mode); + + if (*secure_boot && !*setup_mode) + ret = 1; +diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c +index 4756ef71f..f83820e61 100644 +--- a/grub-core/loader/arm64/linux.c ++++ b/grub-core/loader/arm64/linux.c +@@ -251,6 +251,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_file_t file = 0; + struct grub_arm64_linux_kernel_header lh; + struct grub_arm64_linux_pe_header *pe; ++ int rc; + + grub_dl_ref (my_mod); + +@@ -295,7 +296,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); + +- if (!grub_linuxefi_secure_validate (kernel_addr, kernel_size)) ++ rc = grub_linuxefi_secure_validate (kernel_addr, kernel_size); ++ if (rc < 0) + { + grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); + goto fail; +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 323f8738b..49a7662fa 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -178,7 +178,6 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) + /* Fill the file path for the directory. */ + d = (grub_efi_device_path_t *) ((char *) file_path + + ((char *) d - (char *) dp)); +- grub_efi_print_device_path (d); + copy_file_path ((grub_efi_file_path_device_path_t *) d, + dir_start, dir_end - dir_start); + +@@ -248,10 +247,9 @@ read_header (void *data, grub_efi_uint32_t size, + grub_efi_status_t status; + + shim_lock = grub_efi_locate_protocol (&guid, NULL); +- + if (!shim_lock) + { +- grub_error (GRUB_ERR_BAD_ARGUMENT, "no shim lock protocol"); ++ grub_dprintf ("chain", "no shim lock protocol"); + return 0; + } + +@@ -276,7 +274,7 @@ read_header (void *data, grub_efi_uint32_t size, + break; + } + +- return 0; ++ return -1; + } + + static void* +@@ -510,17 +508,24 @@ handle_image (void *data, grub_efi_uint32_t datasize) + grub_uint32_t section_alignment; + grub_uint32_t buffer_size; + int found_entry_point = 0; ++ int rc; + + b = grub_efi_system_table->boot_services; + +- if (read_header (data, datasize, &context)) ++ rc = read_header (data, datasize, &context); ++ if (rc < 0) + { +- grub_dprintf ("chain", "Succeed to read header\n"); ++ grub_dprintf ("chain", "Failed to read header\n"); ++ goto error_exit; ++ } ++ else if (rc == 0) ++ { ++ grub_dprintf ("chain", "Secure Boot is not enabled\n"); ++ return 0; + } + else + { +- grub_dprintf ("chain", "Failed to read header\n"); +- goto error_exit; ++ grub_dprintf ("chain", "Header read without error\n"); + } + + /* +@@ -792,10 +797,56 @@ grub_secureboot_chainloader_unload (void) + return GRUB_ERR_NONE; + } + ++static grub_err_t ++grub_load_and_start_image(void *boot_image) ++{ ++ grub_efi_boot_services_t *b; ++ grub_efi_status_t status; ++ grub_efi_loaded_image_t *loaded_image; ++ ++ b = grub_efi_system_table->boot_services; ++ ++ status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, ++ boot_image, fsize, &image_handle); ++ if (status != GRUB_EFI_SUCCESS) ++ { ++ if (status == GRUB_EFI_OUT_OF_RESOURCES) ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources"); ++ else ++ grub_error (GRUB_ERR_BAD_OS, "cannot load image"); ++ return -1; ++ } ++ ++ /* LoadImage does not set a device handler when the image is ++ loaded from memory, so it is necessary to set it explicitly here. ++ This is a mess. */ ++ loaded_image = grub_efi_get_loaded_image (image_handle); ++ if (! loaded_image) ++ { ++ grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); ++ return -1; ++ } ++ loaded_image->device_handle = dev_handle; ++ ++ if (cmdline) ++ { ++ loaded_image->load_options = cmdline; ++ loaded_image->load_options_size = cmdline_len; ++ } ++ ++ return 0; ++} ++ + static grub_err_t + grub_secureboot_chainloader_boot (void) + { +- handle_image ((void *)address, fsize); ++ int rc; ++ rc = handle_image ((void *)address, fsize); ++ if (rc == 0) ++ { ++ grub_load_and_start_image((void *)address); ++ } ++ + grub_loader_unset (); + return grub_errno; + } +@@ -809,9 +860,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + grub_efi_boot_services_t *b; + grub_device_t dev = 0; + grub_efi_device_path_t *dp = 0; +- grub_efi_loaded_image_t *loaded_image; + char *filename; + void *boot_image = 0; ++ int rc; + + if (argc == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); +@@ -898,9 +949,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + if (! file_path) + goto fail; + +- grub_printf ("file path: "); +- grub_efi_print_device_path (file_path); +- + fsize = grub_file_size (file); + if (!fsize) + { +@@ -975,51 +1023,28 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + } + #endif + +- if (grub_linuxefi_secure_validate((void *)address, fsize)) ++ rc = grub_linuxefi_secure_validate((void *)address, fsize); ++ grub_dprintf ("chain", "linuxefi_secure_validate: %d\n", rc); ++ if (rc > 0) + { + grub_file_close (file); + grub_loader_set (grub_secureboot_chainloader_boot, + grub_secureboot_chainloader_unload, 0); + return 0; + } +- +- status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, +- boot_image, fsize, &image_handle); +- if (status != GRUB_EFI_SUCCESS) ++ else if (rc == 0) + { +- if (status == GRUB_EFI_OUT_OF_RESOURCES) +- grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources"); +- else +- grub_error (GRUB_ERR_BAD_OS, "cannot load image"); +- +- goto fail; +- } +- +- /* LoadImage does not set a device handler when the image is +- loaded from memory, so it is necessary to set it explicitly here. +- This is a mess. */ +- loaded_image = grub_efi_get_loaded_image (image_handle); +- if (! loaded_image) +- { +- grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); +- goto fail; +- } +- loaded_image->device_handle = dev_handle; ++ grub_load_and_start_image(boot_image); ++ grub_file_close (file); ++ grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); + +- if (cmdline) +- { +- loaded_image->load_options = cmdline; +- loaded_image->load_options_size = cmdline_len; ++ return 0; + } + + grub_file_close (file); + grub_device_close (dev); + +- grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); +- return 0; +- +- fail: +- ++fail: + if (dev) + grub_device_close (dev); + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index aea378adf..8890bdf05 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -33,21 +33,24 @@ struct grub_efi_shim_lock + }; + typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; + +-grub_efi_boolean_t ++int + grub_linuxefi_secure_validate (void *data, grub_uint32_t size) + { + grub_efi_guid_t guid = SHIM_LOCK_GUID; + grub_efi_shim_lock_t *shim_lock; ++ grub_efi_status_t status; + + shim_lock = grub_efi_locate_protocol(&guid, NULL); +- ++ grub_dprintf ("secureboot", "shim_lock: %p\n", shim_lock); + if (!shim_lock) +- return 1; ++ return 0; + +- if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) ++ status = shim_lock->verify(data, size); ++ grub_dprintf ("secureboot", "shim_lock->verify(): %ld\n", status); ++ if (status == GRUB_EFI_SUCCESS) + return 1; + +- return 0; ++ return -1; + } + + typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 7ccf32d9d..82f75b7f3 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -155,6 +155,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + struct linux_kernel_header lh; + grub_ssize_t len, start, filelen; + void *kernel = NULL; ++ int rc; + + grub_dl_ref (my_mod); + +@@ -180,13 +181,16 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + if (grub_file_read (file, kernel, filelen) != filelen) + { +- grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), argv[0]); ++ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), ++ argv[0]); + goto fail; + } + +- if (! grub_linuxefi_secure_validate (kernel, filelen)) ++ rc = grub_linuxefi_secure_validate (kernel, filelen); ++ if (rc < 0) + { +- grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); ++ grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), ++ argv[0]); + grub_free (kernel); + goto fail; + } +diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h +index d9ede3677..0033d9305 100644 +--- a/include/grub/efi/linux.h ++++ b/include/grub/efi/linux.h +@@ -22,7 +22,7 @@ + #include + #include + +-grub_efi_boolean_t ++int + EXPORT_FUNC(grub_linuxefi_secure_validate) (void *data, grub_uint32_t size); + grub_err_t + EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, +-- +2.14.3 + diff --git a/0099-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch b/0099-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch deleted file mode 100644 index 0fc88d2..0000000 --- a/0099-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch +++ /dev/null @@ -1,32 +0,0 @@ -From cd15c392fb277ea7a98fe9cc25e12b8bea703aaf Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:46:23 -0400 -Subject: [PATCH 099/105] make GRUB_MOD_INIT() declare its function prototypes. - ---- - include/grub/dl.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/include/grub/dl.h b/include/grub/dl.h -index 9562fa663..5ed58858e 100644 ---- a/include/grub/dl.h -+++ b/include/grub/dl.h -@@ -54,6 +54,7 @@ grub_mod_fini (void) - - #define GRUB_MOD_INIT(name) \ - static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \ -+extern void grub_##name##_init (void); \ - void \ - grub_##name##_init (void) { grub_mod_init (0); } \ - static void \ -@@ -61,6 +62,7 @@ grub_mod_init (grub_dl_t mod __attribute__ ((unused))) - - #define GRUB_MOD_FINI(name) \ - static void grub_mod_fini (void) __attribute__ ((used)); \ -+extern void grub_##name##_fini (void); \ - void \ - grub_##name##_fini (void) { grub_mod_fini (); } \ - static void \ --- -2.13.0 - diff --git a/0100-Add-some-grub_dprintf-in-the-linuxefi-path.patch b/0100-Add-some-grub_dprintf-in-the-linuxefi-path.patch deleted file mode 100644 index 754bb54..0000000 --- a/0100-Add-some-grub_dprintf-in-the-linuxefi-path.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 9fb8798e6c8a2241e157de414460f1d7dab89c00 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 9 May 2016 14:15:17 -0400 -Subject: [PATCH 100/105] Add some grub_dprintf() in the linuxefi path. - -Signed-off-by: Peter Jones ---- - grub-core/loader/efi/linux.c | 16 +++++++++++++--- - grub-core/loader/i386/efi/linux.c | 10 +++++++++- - 2 files changed, 22 insertions(+), 4 deletions(-) - -diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index 8890bdf05..dbf63e20e 100644 ---- a/grub-core/loader/efi/linux.c -+++ b/grub-core/loader/efi/linux.c -@@ -43,12 +43,22 @@ grub_linuxefi_secure_validate (void *data, grub_uint32_t size) - shim_lock = grub_efi_locate_protocol(&guid, NULL); - grub_dprintf ("secureboot", "shim_lock: %p\n", shim_lock); - if (!shim_lock) -- return 0; -+ { -+ grub_dprintf ("secureboot", "shim not available\n"); -+ return 0; -+ } - -- status = shim_lock->verify(data, size); -+ grub_dprintf ("secureboot", "Asking shim to verify kernel signature\n"); -+ status = shim_lock->verify (data, size); - grub_dprintf ("secureboot", "shim_lock->verify(): %ld\n", status); - if (status == GRUB_EFI_SUCCESS) -- return 1; -+ { -+ grub_dprintf ("secureboot", "Kernel signature verification passed\n"); -+ return 1; -+ } -+ -+ grub_dprintf ("secureboot", "Kernel signature verification failed (0x%lx)\n", -+ (unsigned long) status); - - return -1; - } -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 010bf982d..a95e29700 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -114,6 +114,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_dprintf ("linuxefi", "initrd_mem = %lx\n", (unsigned long) initrd_mem); -+ - params->ramdisk_size = size; - params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem; - -@@ -202,6 +204,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_dprintf ("linuxefi", "params = %lx\n", (unsigned long) params); -+ - grub_memset (params, 0, 16384); - - grub_memcpy (&lh, kernel, sizeof (lh)); -@@ -239,6 +243,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_dprintf ("linuxefi", "linux_cmdline = %lx\n", -+ (unsigned long)linux_cmdline); -+ - grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, - linux_cmdline + sizeof (LINUX_IMAGE) - 1, -@@ -272,9 +279,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_memcpy (params, &lh, 2 * 512); - - params->type_of_loader = 0x21; -+ grub_dprintf("linuxefi", "kernel_mem: %p handover_offset: %08x\n", -+ kernel_mem, handover_offset); - - fail: -- - if (file) - grub_file_close (file); - --- -2.13.0 - diff --git a/0100-linuxefi-fix-double-free-on-verification-failure.patch b/0100-linuxefi-fix-double-free-on-verification-failure.patch new file mode 100644 index 0000000..5d629f8 --- /dev/null +++ b/0100-linuxefi-fix-double-free-on-verification-failure.patch @@ -0,0 +1,25 @@ +From 0a3a4d0b69b5d68f3e4b6b74fe2e6b5d4dcace4f Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 14 Jun 2016 09:50:25 -0400 +Subject: [PATCH 100/123] linuxefi: fix double free on verification failure. + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/efi/linux.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 82f75b7f3..010bf982d 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -191,7 +191,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + { + grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), + argv[0]); +- grub_free (kernel); + goto fail; + } + +-- +2.14.3 + diff --git a/0101-fix-machine-type-test-in-30_os-prober.in.patch b/0101-fix-machine-type-test-in-30_os-prober.in.patch new file mode 100644 index 0000000..c059652 --- /dev/null +++ b/0101-fix-machine-type-test-in-30_os-prober.in.patch @@ -0,0 +1,25 @@ +From be4d338b0c086e9cbbd2d353cd88abad67c000c9 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 11 Jul 2016 13:36:45 -0400 +Subject: [PATCH 101/123] fix machine type test in 30_os-prober.in + +Signed-off-by: Peter Jones +--- + util/grub.d/30_os-prober.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in +index dc98eace9..e40274fc0 100644 +--- a/util/grub.d/30_os-prober.in ++++ b/util/grub.d/30_os-prober.in +@@ -144,6 +144,7 @@ for OS in ${OSPROBED} ; do + sixteenbit="" + linuxefi="linux" + initrdefi="initrd" ++ machine=`uname -m` + case "$machine" in + i?86|x86_64) + sixteenbit="16" +-- +2.14.3 + diff --git a/0101-linuxefi-minor-cleanups.patch b/0101-linuxefi-minor-cleanups.patch deleted file mode 100644 index df59162..0000000 --- a/0101-linuxefi-minor-cleanups.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 5678a5ad6b2560a293f757c0c74b3da45619bb9f Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 14 Feb 2017 16:31:52 -0500 -Subject: [PATCH 101/105] linuxefi: minor cleanups - -Signed-off-by: Peter Jones ---- - grub-core/loader/i386/efi/linux.c | 30 ++++++++++++++++++++---------- - 1 file changed, 20 insertions(+), 10 deletions(-) - -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index a95e29700..806031838 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -61,13 +61,18 @@ grub_linuxefi_unload (void) - grub_dl_unref (my_mod); - loaded = 0; - if (initrd_mem) -- grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, -+ BYTES_TO_PAGES(params->ramdisk_size)); - if (linux_cmdline) -- grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) -+ linux_cmdline, -+ BYTES_TO_PAGES(params->cmdline_size + 1)); - if (kernel_mem) -- grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, -+ BYTES_TO_PAGES(kernel_size)); - if (params) -- grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, -+ BYTES_TO_PAGES(16384)); - return GRUB_ERR_NONE; - } - -@@ -117,7 +122,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - grub_dprintf ("linuxefi", "initrd_mem = %lx\n", (unsigned long) initrd_mem); - - params->ramdisk_size = size; -- params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem; -+ params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem; - - ptr = initrd_mem; - -@@ -144,7 +149,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - grub_free (files); - - if (initrd_mem && grub_errno) -- grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(size)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, -+ BYTES_TO_PAGES(size)); - - return grub_errno; - } -@@ -251,7 +257,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - linux_cmdline + sizeof (LINUX_IMAGE) - 1, - lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); - -- lh.cmd_line_ptr = (grub_uint32_t)(grub_uint64_t)linux_cmdline; -+ lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; - - handover_offset = lh.handover_offset; - -@@ -296,13 +302,17 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - if (linux_cmdline && !loaded) -- grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) -+ linux_cmdline, -+ BYTES_TO_PAGES(lh.cmdline_size + 1)); - - if (kernel_mem && !loaded) -- grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, -+ BYTES_TO_PAGES(kernel_size)); - - if (params && !loaded) -- grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); -+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, -+ BYTES_TO_PAGES(16384)); - - return grub_errno; - } --- -2.13.0 - diff --git a/0102-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch b/0102-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch deleted file mode 100644 index 5681b37..0000000 --- a/0102-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch +++ /dev/null @@ -1,261 +0,0 @@ -From a6a55b951426419d5db76916b97bfeb2a505fff5 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 14 Feb 2017 16:18:54 -0500 -Subject: [PATCH 102/105] Handle multi-arch (64-on-32) boot in linuxefi loader. - -Allow booting 64-bit kernels on 32-bit EFI on x86. - -Signed-off-by: Peter Jones ---- - grub-core/loader/efi/linux.c | 9 +++- - grub-core/loader/i386/efi/linux.c | 108 ++++++++++++++++++++++++++------------ - include/grub/i386/linux.h | 7 ++- - 3 files changed, 88 insertions(+), 36 deletions(-) - -diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index dbf63e20e..7fe7201a3 100644 ---- a/grub-core/loader/efi/linux.c -+++ b/grub-core/loader/efi/linux.c -@@ -66,12 +66,17 @@ grub_linuxefi_secure_validate (void *data, grub_uint32_t size) - typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); - - grub_err_t --grub_efi_linux_boot (void *kernel_addr, grub_off_t offset, -+grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, - void *kernel_params) - { - handover_func hf; -+ int offset = 0; - -- hf = (handover_func)((char *)kernel_addr + offset); -+#ifdef __x86_64__ -+ offset = 512; -+#endif -+ -+ hf = (handover_func)((char *)kernel_addr + handover_offset + offset); - hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); - - return GRUB_ERR_BUG; -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 806031838..52dc71903 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -44,14 +44,10 @@ static char *linux_cmdline; - static grub_err_t - grub_linuxefi_boot (void) - { -- int offset = 0; -- --#ifdef __x86_64__ -- offset = 512; --#endif - asm volatile ("cli"); - -- return grub_efi_linux_boot ((char *)kernel_mem, handover_offset + offset, -+ return grub_efi_linux_boot ((char *)kernel_mem, -+ handover_offset, - params); - } - -@@ -155,14 +151,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - return grub_errno; - } - -+#define MIN(a, b) \ -+ ({ typeof (a) _a = (a); \ -+ typeof (b) _b = (b); \ -+ _a < _b ? _a : _b; }) -+ - static grub_err_t - grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) - { - grub_file_t file = 0; -- struct linux_kernel_header lh; -+ struct linux_kernel_header *lh; - grub_ssize_t len, start, filelen; - void *kernel = NULL; -+ int setup_header_end_offset; - int rc; - - grub_dl_ref (my_mod); -@@ -202,47 +204,78 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- params = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(16384)); -- -+ params = grub_efi_allocate_pages_max (0x3fffffff, -+ BYTES_TO_PAGES(sizeof(*params))); - if (! params) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); - goto fail; - } - -- grub_dprintf ("linuxefi", "params = %lx\n", (unsigned long) params); -- -- grub_memset (params, 0, 16384); -- -- grub_memcpy (&lh, kernel, sizeof (lh)); -- -- if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) -+ grub_dprintf ("linuxefi", "params = %p\n", (unsigned long) params); -+ -+ grub_memset (params, 0, sizeof(*params)); -+ -+ setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201); -+ grub_dprintf ("linuxefi", "copying %d bytes from %p to %p\n", -+ MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1, -+ (grub_uint8_t *)kernel + 0x1f1, -+ (grub_uint8_t *)params + 0x1f1); -+ grub_memcpy ((grub_uint8_t *)params + 0x1f1, -+ (grub_uint8_t *)kernel + 0x1f1, -+ MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); -+ lh = (struct linux_kernel_header *)params; -+ grub_dprintf ("linuxefi", "lh is at %p\n", lh); -+ grub_dprintf ("linuxefi", "checking lh->boot_flag\n"); -+ if (lh->boot_flag != grub_cpu_to_le16 (0xaa55)) - { - grub_error (GRUB_ERR_BAD_OS, N_("invalid magic number")); - goto fail; - } - -- if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS) -+ grub_dprintf ("linuxefi", "checking lh->setup_sects\n"); -+ if (lh->setup_sects > GRUB_LINUX_MAX_SETUP_SECTS) - { - grub_error (GRUB_ERR_BAD_OS, N_("too many setup sectors")); - goto fail; - } - -- if (lh.version < grub_cpu_to_le16 (0x020b)) -+ grub_dprintf ("linuxefi", "checking lh->version\n"); -+ if (lh->version < grub_cpu_to_le16 (0x020b)) - { - grub_error (GRUB_ERR_BAD_OS, N_("kernel too old")); - goto fail; - } - -- if (!lh.handover_offset) -+ grub_dprintf ("linuxefi", "checking lh->handover_offset\n"); -+ if (!lh->handover_offset) - { - grub_error (GRUB_ERR_BAD_OS, N_("kernel doesn't support EFI handover")); - goto fail; - } - -- linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, -- BYTES_TO_PAGES(lh.cmdline_size + 1)); -+#ifdef defined(__x86_64__) || defined(__aarch64__) -+ grub_dprintf ("linuxefi", "checking lh->xloadflags\n"); -+ if (!(lh->xloadflags & LINUX_XLF_KERNEL_64)) -+ { -+ grub_error (GRUB_ERR_BAD_OS, N_("kernel doesn't support 64-bit CPUs")); -+ goto fail; -+ } -+#endif -+ -+#if defined(__i386__) -+ if ((lh->xloadflags & LINUX_XLF_KERNEL_64) && -+ !(lh->xloadflags & LINUX_XLF_EFI_HANDOVER_32)) -+ { -+ grub_error (GRUB_ERR_BAD_OS, -+ N_("kernel doesn't support 32-bit handover")); -+ goto fail; -+ } -+#endif - -+ grub_dprintf ("linuxefi", "setting up cmdline\n"); -+ linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, -+ BYTES_TO_PAGES(lh->cmdline_size + 1)); - if (!linux_cmdline) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline")); -@@ -255,21 +288,23 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); - grub_create_loader_cmdline (argc, argv, - linux_cmdline + sizeof (LINUX_IMAGE) - 1, -- lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); -+ lh->cmdline_size - (sizeof (LINUX_IMAGE) - 1)); - -- lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; -+ grub_dprintf ("linuxefi", "setting lh->cmd_line_ptr\n"); -+ lh->cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; - -- handover_offset = lh.handover_offset; -+ grub_dprintf ("linuxefi", "computing handover offset\n"); -+ handover_offset = lh->handover_offset; - -- start = (lh.setup_sects + 1) * 512; -+ start = (lh->setup_sects + 1) * 512; - len = grub_file_size(file) - start; - -- kernel_mem = grub_efi_allocate_pages(lh.pref_address, -- BYTES_TO_PAGES(lh.init_size)); -+ kernel_mem = grub_efi_allocate_pages(lh->pref_address, -+ BYTES_TO_PAGES(lh->init_size)); - - if (!kernel_mem) - kernel_mem = grub_efi_allocate_pages_max(0x3fffffff, -- BYTES_TO_PAGES(lh.init_size)); -+ BYTES_TO_PAGES(lh->init_size)); - - if (!kernel_mem) - { -@@ -277,14 +312,21 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_memcpy (kernel_mem, (char *)kernel + start, len); -+ grub_dprintf ("linuxefi", "kernel_mem = %lx\n", (unsigned long) kernel_mem); -+ - grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); - loaded=1; -+ grub_dprintf ("linuxefi", "setting lh->code32_start to %p\n", kernel_mem); -+ lh->code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem; -+ -+ grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); - -- lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; -- grub_memcpy (params, &lh, 2 * 512); -+ grub_dprintf ("linuxefi", "setting lh->type_of_loader\n"); -+ lh->type_of_loader = 0x6; - -- params->type_of_loader = 0x21; -+ grub_dprintf ("linuxefi", "setting lh->ext_loader_{type,ver}\n"); -+ params->ext_loader_type = 0; -+ params->ext_loader_ver = 2; - grub_dprintf("linuxefi", "kernel_mem: %p handover_offset: %08x\n", - kernel_mem, handover_offset); - -@@ -304,7 +346,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - if (linux_cmdline && !loaded) - grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) - linux_cmdline, -- BYTES_TO_PAGES(lh.cmdline_size + 1)); -+ BYTES_TO_PAGES(lh->cmdline_size + 1)); - - if (kernel_mem && !loaded) - grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, -diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index fc36bdaf3..110ecf806 100644 ---- a/include/grub/i386/linux.h -+++ b/include/grub/i386/linux.h -@@ -130,7 +130,12 @@ struct linux_kernel_header - grub_uint32_t kernel_alignment; - grub_uint8_t relocatable; - grub_uint8_t min_alignment; -- grub_uint8_t pad[2]; -+#define LINUX_XLF_KERNEL_64 (1<<0) -+#define LINUX_XLF_CAN_BE_LOADED_ABOVE_4G (1<<1) -+#define LINUX_XLF_EFI_HANDOVER_32 (1<<2) -+#define LINUX_XLF_EFI_HANDOVER_64 (1<<3) -+#define LINUX_XLF_EFI_KEXEC (1<<4) -+ grub_uint16_t xloadflags; - grub_uint32_t cmdline_size; - grub_uint32_t hardware_subarch; - grub_uint64_t hardware_subarch_data; --- -2.13.0 - diff --git a/0102-ppc64le-has-no-separate-boot-mount-1261926.patch b/0102-ppc64le-has-no-separate-boot-mount-1261926.patch new file mode 100644 index 0000000..fbae65d --- /dev/null +++ b/0102-ppc64le-has-no-separate-boot-mount-1261926.patch @@ -0,0 +1,44 @@ +From 12a2215a6f13f2503a9e38d84fff64789c6a34b7 Mon Sep 17 00:00:00 2001 +From: Robert Marshall +Date: Fri, 17 Jun 2016 11:47:34 -0400 +Subject: [PATCH 102/123] ppc64le has no separate /boot mount (#1261926) + +The patch for rhbz#1212114 ensures that ppc64le systems sync grub config +changes to disk prior to grub-mkconfig completion and a reboot. + +This patch required checking for /boot as its own mount point because +issuing fsfreeze to a root partition is unwise. For administrators who +configured a ppc64le system with no separate /boot partition, the failed +check results in an error message. The file is written and would work +most of the time, however, it also introduces a corner case where the +behavior manifested in rhbz#1212114 could re-appear on these systems. + +The system call issued by fsfreeeze is being issued by methods within +the anaconda installer and can be removed from GRUB proper. + +Related: rhbz#1315468 +Resolves: rhbz#1261926 +--- + util/grub-mkconfig.in | 9 --------- + 1 file changed, 9 deletions(-) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 73a18f723..fb8724708 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -294,12 +294,3 @@ fi + + gettext "done" >&2 + echo >&2 +- +-# make sure changes make it to the disk. +-# if /boot is a mountpoint, force the meta data on disk +-# to by-pass writeback delay. +-# PPC64LE-only to deal with Petitboot issues +-ARCH=$(uname -m) +-if [ "${ARCH}" = "ppc64le" ]; then +- sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot +-fi +-- +2.14.3 + diff --git a/0103-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch b/0103-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch new file mode 100644 index 0000000..7a0af44 --- /dev/null +++ b/0103-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch @@ -0,0 +1,302 @@ +From d3d42740661dce4df12330e57a1681a3b296622e Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 23 Jun 2016 11:01:39 -0400 +Subject: [PATCH 103/123] Add grub-get-kernel-settings and use it in 10_linux + +This patch adds grub-get-kernel-settings, which reads the system kernel +installation configuration from /etc/sysconfig/kernel, and outputs +${GRUB_...} variables suitable for evaluation by grub-mkconfig. Those +variables are then used by 10_linux to choose whether or not to create +debug stanzas. + +Resolves: rhbz#1226325 +--- + .gitignore | 1 + + Makefile.util.def | 7 +++ + configure.ac | 2 + + util/bash-completion.d/grub-completion.bash.in | 22 ++++++++ + util/grub-get-kernel-settings.3 | 20 +++++++ + util/grub-get-kernel-settings.in | 78 ++++++++++++++++++++++++++ + util/grub-mkconfig.in | 3 + + util/grub.d/10_linux.in | 23 ++++++-- + 8 files changed, 151 insertions(+), 5 deletions(-) + create mode 100644 util/grub-get-kernel-settings.3 + create mode 100644 util/grub-get-kernel-settings.in + +diff --git a/.gitignore b/.gitignore +index 53a391e62..f2f1ef59c 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -112,6 +112,7 @@ grub-emu-lite + grub-file + grub-fs-tester + grub-fstest ++grub-get-kernel-settings + grub-glue-efi + grub-install + grub-kbdcomp +diff --git a/Makefile.util.def b/Makefile.util.def +index 8007de945..38cdf4ccc 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -715,6 +715,13 @@ script = { + installdir = sbin; + }; + ++script = { ++ name = grub-get-kernel-settings; ++ common = util/grub-get-kernel-settings.in; ++ mansection = 3; ++ installdir = sbin; ++}; ++ + script = { + name = grub-set-default; + common = util/grub-set-default.in; +diff --git a/configure.ac b/configure.ac +index 25de2c12a..1d8f7e745 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -58,6 +58,7 @@ grub_TRANSFORM([grub-install]) + grub_TRANSFORM([grub-mkconfig]) + grub_TRANSFORM([grub-mkfont]) + grub_TRANSFORM([grub-mkimage]) ++grub_TRANSFORM([grub-get-kernel-settings]) + grub_TRANSFORM([grub-glue-efi]) + grub_TRANSFORM([grub-mklayout]) + grub_TRANSFORM([grub-mkpasswd-pbkdf2]) +@@ -75,6 +76,7 @@ grub_TRANSFORM([grub-file]) + grub_TRANSFORM([grub-bios-setup.3]) + grub_TRANSFORM([grub-editenv.1]) + grub_TRANSFORM([grub-fstest.3]) ++grub_TRANSFORM([grub-get-kernel-settings.3]) + grub_TRANSFORM([grub-glue-efi.3]) + grub_TRANSFORM([grub-install.1]) + grub_TRANSFORM([grub-kbdcomp.3]) +diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in +index 44bf135b9..5c4acd496 100644 +--- a/util/bash-completion.d/grub-completion.bash.in ++++ b/util/bash-completion.d/grub-completion.bash.in +@@ -264,6 +264,28 @@ have ${__grub_sparc64_setup_program} && \ + unset __grub_sparc64_setup_program + + ++# ++# grub-get-kernel-settings ++# ++_grub_get_kernel_settings () { ++ local cur ++ ++ COMPREPLY=() ++ cur=`_get_cword` ++ ++ if [[ "$cur" == -* ]]; then ++ __grubcomp "$(__grub_get_options_from_help)" ++ else ++ # Default complete with a filename ++ _filedir ++ fi ++} ++__grub_get_kernel_settings_program="@grub_get_kernel_settings@" ++have ${__grub_get_kernel_settings_program} && \ ++ complete -F _grub_get_kernel_settings -o filenames ${__grub_get_kernel_settings_program} ++unset __grub_get_kernel_settings_program ++ ++ + # + # grub-install + # +diff --git a/util/grub-get-kernel-settings.3 b/util/grub-get-kernel-settings.3 +new file mode 100644 +index 000000000..ba33330e2 +--- /dev/null ++++ b/util/grub-get-kernel-settings.3 +@@ -0,0 +1,20 @@ ++.TH GRUB-GET-KERNEL-SETTINGS 3 "Thu Jun 25 2015" ++.SH NAME ++\fBgrub-get-kernel-settings\fR \(em Evaluate the system's kernel installation settings for use while making a grub configuration file. ++ ++.SH SYNOPSIS ++\fBgrub-get-kernel-settings\fR [OPTION] ++ ++.SH DESCRIPTION ++\fBgrub-get-kernel-settings\fR reads the kernel installation settings on the host system, and emits a set of grub settings suitable for use when creating a grub configuration file. ++ ++.SH OPTIONS ++.TP ++-h, --help ++Display program usage and exit. ++.TP ++-v, --version ++Display the current version. ++ ++.SH SEE ALSO ++.BR "info grub" +diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in +new file mode 100644 +index 000000000..120462198 +--- /dev/null ++++ b/util/grub-get-kernel-settings.in +@@ -0,0 +1,78 @@ ++#!/bin/sh ++set -e ++ ++# Evaluate new-kernel-pkg's configuration file. ++# Copyright (C) 2016 Free Software Foundation, Inc. ++# ++# GRUB 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. ++# ++# GRUB 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 GRUB. If not, see . ++ ++PACKAGE_NAME=@PACKAGE_NAME@ ++PACKAGE_VERSION=@PACKAGE_VERSION@ ++datadir="@datadir@" ++if [ "x$pkgdatadir" = x ]; then ++ pkgdatadir="${datadir}/@PACKAGE@" ++fi ++ ++self=`basename $0` ++ ++export TEXTDOMAIN=@PACKAGE@ ++export TEXTDOMAINDIR="@localedir@" ++ ++. "${pkgdatadir}/grub-mkconfig_lib" ++ ++# Usage: usage ++# Print the usage. ++usage () { ++ gettext_printf "Usage: %s [OPTION]\n" "$self" ++ gettext "Evaluate new-kernel-pkg configuration"; echo ++ echo ++ print_option_help "-h, --help" "$(gettext "print this message and exit")" ++ print_option_help "-v, --version" "$(gettext "print the version information and exit")" ++ echo ++} ++ ++# Check the arguments. ++while test $# -gt 0 ++do ++ option=$1 ++ shift ++ ++ case "$option" in ++ -h | --help) ++ usage ++ exit 0 ;; ++ -v | --version) ++ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" ++ exit 0 ;; ++ -*) ++ gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 ++ usage ++ exit 1 ++ ;; ++ # Explicitly ignore non-option arguments, for compatibility. ++ esac ++done ++ ++if test -f /etc/sysconfig/kernel ; then ++ . /etc/sysconfig/kernel ++fi ++ ++if [ "$MAKEDEBUG" = "yes" ]; then ++ echo GRUB_LINUX_MAKE_DEBUG=true ++ echo export GRUB_LINUX_MAKE_DEBUG ++ echo GRUB_CMDLINE_LINUX_DEBUG=\"systemd.log_level=debug systemd.log_target=kmsg\" ++ echo export GRUB_CMDLINE_LINUX_DEBUG ++ echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\" ++ echo export GRUB_LINUX_DEBUG_TITLE_POSTFIX ++fi +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index fb8724708..e32de5ef3 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -45,6 +45,7 @@ grub_probe="${sbindir}/@grub_probe@" + grub_file="${bindir}/@grub_file@" + grub_editenv="${bindir}/@grub_editenv@" + grub_script_check="${bindir}/@grub_script_check@" ++grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" + + export TEXTDOMAIN=@PACKAGE@ + export TEXTDOMAINDIR="@localedir@" +@@ -151,6 +152,8 @@ if test -f ${sysconfdir}/default/grub ; then + . ${sysconfdir}/default/grub + fi + ++eval "$("${grub_get_kernel_settings}")" || true ++ + if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_UUID" ]; then + GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" + fi +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 121524185..0c5b227a4 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -84,7 +84,8 @@ linux_entry () + os="$1" + version="$2" + type="$3" +- args="$4" ++ isdebug="$4" ++ args="$5" + + sixteenbit="" + linuxefi="linux" +@@ -116,6 +117,9 @@ linux_entry () + quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" + title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" + fi ++ if [ x$isdebug = xdebug ]; then ++ title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}" ++ fi + echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" + else + echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" +@@ -273,11 +277,15 @@ while [ "x$list" != "x" ] ; do + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then +- linux_entry "${OS}" "${version}" simple \ ++ linux_entry "${OS}" "${version}" simple standard \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then ++ linux_entry "${OS}" "${version}" simple debug \ ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" ++ fi + + submenu_indentation="$grub_tab" +- ++ + if [ -z "$boot_device_id" ]; then + boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" + fi +@@ -286,10 +294,15 @@ while [ "x$list" != "x" ] ; do + is_top_level=false + fi + +- linux_entry "${OS}" "${version}" advanced \ ++ linux_entry "${OS}" "${version}" advanced standard \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then ++ linux_entry "${OS}" "${version}" advanced debug \ ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" ++ fi ++ + if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then +- linux_entry "${OS}" "${version}" recovery \ ++ linux_entry "${OS}" "${version}" recovery standard \ + "single ${GRUB_CMDLINE_LINUX}" + fi + +-- +2.14.3 + diff --git a/0103-Clean-up-some-errors-in-the-linuxefi-loader.patch b/0103-Clean-up-some-errors-in-the-linuxefi-loader.patch deleted file mode 100644 index 6cde434..0000000 --- a/0103-Clean-up-some-errors-in-the-linuxefi-loader.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 266bbbe624274a0eb174bb294c70e197848f3991 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 24 May 2017 15:58:18 -0400 -Subject: [PATCH 103/105] Clean up some errors in the linuxefi loader - -Signed-off-by: Peter Jones ---- - grub-core/loader/i386/efi/linux.c | 18 +++++++++--------- - 1 file changed, 9 insertions(+), 9 deletions(-) - -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 52dc71903..19950d2f2 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -161,8 +161,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) - { - grub_file_t file = 0; -- struct linux_kernel_header *lh; -- grub_ssize_t len, start, filelen; -+ struct linux_kernel_header *lh = NULL; -+ grub_ssize_t start, filelen; - void *kernel = NULL; - int setup_header_end_offset; - int rc; -@@ -212,18 +212,19 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_dprintf ("linuxefi", "params = %p\n", (unsigned long) params); -+ grub_dprintf ("linuxefi", "params = %p\n", params); - - grub_memset (params, 0, sizeof(*params)); - - setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201); -- grub_dprintf ("linuxefi", "copying %d bytes from %p to %p\n", -- MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1, -+ grub_dprintf ("linuxefi", "copying %zu bytes from %p to %p\n", -+ MIN((grub_size_t)0x202+setup_header_end_offset, -+ sizeof (*params)) - 0x1f1, - (grub_uint8_t *)kernel + 0x1f1, - (grub_uint8_t *)params + 0x1f1); - grub_memcpy ((grub_uint8_t *)params + 0x1f1, - (grub_uint8_t *)kernel + 0x1f1, -- MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); -+ MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); - lh = (struct linux_kernel_header *)params; - grub_dprintf ("linuxefi", "lh is at %p\n", lh); - grub_dprintf ("linuxefi", "checking lh->boot_flag\n"); -@@ -254,7 +255,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - --#ifdef defined(__x86_64__) || defined(__aarch64__) -+#if defined(__x86_64__) || defined(__aarch64__) - grub_dprintf ("linuxefi", "checking lh->xloadflags\n"); - if (!(lh->xloadflags & LINUX_XLF_KERNEL_64)) - { -@@ -297,7 +298,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - handover_offset = lh->handover_offset; - - start = (lh->setup_sects + 1) * 512; -- len = grub_file_size(file) - start; - - kernel_mem = grub_efi_allocate_pages(lh->pref_address, - BYTES_TO_PAGES(lh->init_size)); -@@ -343,7 +343,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - loaded = 0; - } - -- if (linux_cmdline && !loaded) -+ if (linux_cmdline && lh && !loaded) - grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) - linux_cmdline, - BYTES_TO_PAGES(lh->cmdline_size + 1)); --- -2.13.0 - diff --git a/0104-Fix-up-linux-params-usage.patch b/0104-Fix-up-linux-params-usage.patch deleted file mode 100644 index d744ea5..0000000 --- a/0104-Fix-up-linux-params-usage.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 3019712d45a7934a2bf21de8e2745c03701b05cc Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 30 May 2017 14:16:07 -0400 -Subject: [PATCH 104/105] Fix up linux params usage... - -Related: rhbz#1310763 - -Signed-off-by: Peter Jones ---- - grub-core/loader/i386/linux.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index b1335f9ed..763863abe 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -680,6 +680,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - { - grub_file_t file = 0; - struct linux_kernel_header lh; -+ grub_uint8_t *linux_params_ptr; - grub_uint8_t setup_sects; - grub_size_t real_size, prot_size, prot_file_size, kernel_offset; - grub_ssize_t len; -@@ -811,6 +812,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - preferred_address)) - goto fail; - -+ - grub_memset (&linux_params, 0, sizeof (linux_params)); - grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1); - -@@ -820,7 +822,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - len = sizeof (linux_params) - sizeof (lh); - -- grub_memcpy (&linux_params + sizeof (lh), kernel + kernel_offset, len); -+ linux_params_ptr = (void *)&linux_params; -+ grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len); - kernel_offset += len; - - linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; --- -2.13.0 - diff --git a/0104-Normalize-slashes-in-tftp-paths.patch b/0104-Normalize-slashes-in-tftp-paths.patch new file mode 100644 index 0000000..4592753 --- /dev/null +++ b/0104-Normalize-slashes-in-tftp-paths.patch @@ -0,0 +1,58 @@ +From 22d26153c1d92b8a42d1ec823b7f7c77c1cc0a8c Mon Sep 17 00:00:00 2001 +From: Lenny Szubowicz +Date: Mon, 29 Aug 2016 11:04:48 -0400 +Subject: [PATCH 104/123] Normalize slashes in tftp paths. + +Some tftp servers do not handle multiple consecutive slashes correctly; +this patch avoids sending tftp requests with non-normalized paths. + +Signed-off-by: Peter Jones +--- + grub-core/net/tftp.c | 24 +++++++++++++++++++++++- + 1 file changed, 23 insertions(+), 1 deletion(-) + +diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c +index 7d90bf66e..63bbc28ef 100644 +--- a/grub-core/net/tftp.c ++++ b/grub-core/net/tftp.c +@@ -300,6 +300,25 @@ destroy_pq (tftp_data_t data) + grub_priority_queue_destroy (data->pq); + } + ++/* Create a normalized copy of the filename. ++ Compress any string of consecutive forward slashes to a single forward ++ slash. */ ++static void ++grub_normalize_filename (char *normalized, const char *filename) ++{ ++ char *dest = normalized; ++ char *src = filename; ++ ++ while (*src != '\0') ++ { ++ if (src[0] == '/' && src[1] == '/') ++ src++; ++ else ++ *dest++ = *src++; ++ } ++ *dest = '\0'; ++} ++ + static grub_err_t + tftp_open (struct grub_file *file, const char *filename) + { +@@ -337,7 +356,10 @@ tftp_open (struct grub_file *file, const char *filename) + rrqlen = 0; + + tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ); +- grub_strcpy (rrq, filename); ++ ++ /* Copy and normalize the filename to work-around issues on some tftp ++ servers when file names are being matched for remapping. */ ++ grub_normalize_filename (rrq, filename); + rrqlen += grub_strlen (filename) + 1; + rrq += grub_strlen (filename) + 1; + +-- +2.14.3 + diff --git a/0105-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch b/0105-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch deleted file mode 100644 index 69cabc4..0000000 --- a/0105-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch +++ /dev/null @@ -1,45 +0,0 @@ -From c38aad7b173cbe4e84fb52efbd4ef6a03503a3b1 Mon Sep 17 00:00:00 2001 -From: Mark Salter -Date: Mon, 17 Apr 2017 08:44:29 -0400 -Subject: [PATCH 105/105] arm64: make sure fdt has #address-cells and - #size-cells properties - -Recent upstream changes to kexec-tools relies on #address-cells -and #size-cells properties in the FDT. If grub2 needs to create -a chosen node, it is likely because firmware did not provide one. -In that case, set #address-cells and #size-cells properties to -make sure they exist. ---- - grub-core/loader/arm64/linux.c | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index f83820e61..f32151f3b 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -81,7 +81,21 @@ finalize_params_linux (void) - - node = grub_fdt_find_subnode (fdt, 0, "chosen"); - if (node < 0) -- node = grub_fdt_add_subnode (fdt, 0, "chosen"); -+ { -+ /* -+ * If we have to create a chosen node, Make sure we -+ * have #address-cells and #size-cells properties. -+ */ -+ retval = grub_fdt_set_prop32(fdt, 0, "#address-cells", 2); -+ if (retval) -+ goto failure; -+ -+ retval = grub_fdt_set_prop32(fdt, 0, "#size-cells", 2); -+ if (retval) -+ goto failure; -+ -+ node = grub_fdt_add_subnode (fdt, 0, "chosen"); -+ } - - if (node < 1) - goto failure; --- -2.13.0 - diff --git a/0105-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch b/0105-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch new file mode 100644 index 0000000..8222fda --- /dev/null +++ b/0105-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch @@ -0,0 +1,39 @@ +From 54d9b46779dab340984dde1077c4f2b685caf0b1 Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Mon, 21 Nov 2016 15:34:00 +0100 +Subject: [PATCH 105/123] efi/chainloader: fix wrong sanity check in + relocate_coff() + +In relocate_coff(), the relocation entries are parsed from the original +image (not the section-wise copied image). The original image is +pointed-to by the "orig" pointer. The current check + + (void *)reloc_end < data + +compares the addresses of independent memory allocations. "data" is a typo +here, it should be "orig". + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1347291 +Signed-off-by: Laszlo Ersek +Tested-by: Bogdan Costescu +Tested-by: Juan Orti +--- + grub-core/loader/efi/chainloader.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 49a7662fa..1bd7ffb31 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -397,7 +397,7 @@ relocate_coff (pe_coff_loader_image_context_t *context, + reloc_end = (struct grub_pe32_fixup_block *) + ((char *)reloc_base + reloc_base->size); + +- if ((void *)reloc_end < data || (void *)reloc_end > image_end) ++ if ((void *)reloc_end < orig || (void *)reloc_end > image_end) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, "Reloc entry %d overflows binary", + n); +-- +2.14.3 + diff --git a/0106-efi-chainloader-truncate-overlong-relocation-section.patch b/0106-efi-chainloader-truncate-overlong-relocation-section.patch new file mode 100644 index 0000000..c45658e --- /dev/null +++ b/0106-efi-chainloader-truncate-overlong-relocation-section.patch @@ -0,0 +1,113 @@ +From e85054f3b65bdb2afe2a71062f8145d9fef63051 Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Wed, 23 Nov 2016 06:27:09 +0100 +Subject: [PATCH 106/123] efi/chainloader: truncate overlong relocation section + +The UEFI Windows 7 boot loader ("EFI/Microsoft/Boot/bootmgfw.efi", SHA1 +31b410e029bba87d2068c65a80b88882f9f8ea25) has inconsistent headers. + +Compare: + +> The Data Directory +> ... +> Entry 5 00000000000d9000 00000574 Base Relocation Directory [.reloc] + +Versus: + +> Sections: +> Idx Name Size VMA LMA File off ... +> ... +> 10 .reloc 00000e22 00000000100d9000 00000000100d9000 000a1800 ... + +That is, the size reported by the RelocDir entry (0x574) is smaller than +the virtual size of the .reloc section (0xe22). + +Quoting the grub2 debug log for the same: + +> chainloader.c:595: reloc_dir: 0xd9000 reloc_size: 0x00000574 +> chainloader.c:603: reloc_base: 0x7d208000 reloc_base_end: 0x7d208573 +> ... +> chainloader.c:620: Section 10 ".reloc" at 0x7d208000..0x7d208e21 +> chainloader.c:661: section is not reloc section? +> chainloader.c:663: rds: 0x00001000, vs: 00000e22 +> chainloader.c:664: base: 0x7d208000 end: 0x7d208e21 +> chainloader.c:666: reloc_base: 0x7d208000 reloc_base_end: 0x7d208573 +> chainloader.c:671: Section characteristics are 42000040 +> chainloader.c:673: Section virtual size: 00000e22 +> chainloader.c:675: Section raw_data size: 00001000 +> chainloader.c:678: Discarding section + +After hexdumping "bootmgfw.efi" and manually walking its relocation blocks +(yes, really), I determined that the (smaller) RelocDir value is correct. +The remaining area that extends up to the .reloc section size (== 0xe22 - +0x574 == 0x8ae bytes) exists as zero padding in the file. + +This zero padding shouldn't be passed to relocate_coff() for parsing. In +order to cope with it, split the handling of .reloc sections into the +following branches: + +- original case (equal size): original behavior (--> relocation + attempted), + +- overlong .reloc section (longer than reported by RelocDir): truncate the + section to the RelocDir size for the purposes of relocate_coff(), and + attempt relocation, + +- .reloc section is too short, or other checks fail: original behavior + (--> relocation not attempted). + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1347291 +Signed-off-by: Laszlo Ersek +--- + grub-core/loader/efi/chainloader.c | 26 +++++++++++++++++++++----- + 1 file changed, 21 insertions(+), 5 deletions(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 1bd7ffb31..70c95ee35 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -592,7 +592,7 @@ handle_image (void *data, grub_efi_uint32_t datasize) + grub_dprintf ("chain", "reloc_base: %p reloc_base_end: %p\n", + reloc_base, reloc_base_end); + +- struct grub_pe32_section_table *reloc_section = NULL; ++ struct grub_pe32_section_table *reloc_section = NULL, fake_reloc_section; + + section = context.first_section; + for (i = 0; i < context.number_of_sections; i++, section++) +@@ -641,12 +641,28 @@ handle_image (void *data, grub_efi_uint32_t datasize) + * made sense, and the VA and size match RelocDir's + * versions, then we believe in this section table. */ + if (section->raw_data_size && section->virtual_size && +- base && end && reloc_base == base && reloc_base_end == end) ++ base && end && reloc_base == base) + { +- grub_dprintf ("chain", " section is relocation section\n"); +- reloc_section = section; ++ if (reloc_base_end == end) ++ { ++ grub_dprintf ("chain", " section is relocation section\n"); ++ reloc_section = section; ++ } ++ else if (reloc_base_end && reloc_base_end < end) ++ { ++ /* Bogus virtual size in the reloc section -- RelocDir ++ * reported a smaller Base Relocation Directory. Decrease ++ * the section's virtual size so that it equal RelocDir's ++ * idea, but only for the purposes of relocate_coff(). */ ++ grub_dprintf ("chain", ++ " section is (overlong) relocation section\n"); ++ grub_memcpy (&fake_reloc_section, section, sizeof *section); ++ fake_reloc_section.virtual_size -= (end - reloc_base_end); ++ reloc_section = &fake_reloc_section; ++ } + } +- else ++ ++ if (!reloc_section) + { + grub_dprintf ("chain", " section is not reloc section?\n"); + grub_dprintf ("chain", " rds: 0x%08x, vs: %08x\n", +-- +2.14.3 + diff --git a/0107-Fix-malformed-tftp-packets.patch b/0107-Fix-malformed-tftp-packets.patch new file mode 100644 index 0000000..e7e3071 --- /dev/null +++ b/0107-Fix-malformed-tftp-packets.patch @@ -0,0 +1,35 @@ +From 20e077f4b5be64518b8ff996c11973132e8a9ff3 Mon Sep 17 00:00:00 2001 +From: Mark Salter +Date: Tue, 7 Mar 2017 18:26:17 -0500 +Subject: [PATCH 107/123] Fix malformed tftp packets + +0088-Normalize-slashes-in-tftp-paths.patch collapses multiple contiguous +slashes in a filename into one slash in the tftp packet filename field. +However, the packet buffer pointer is advanced using the original name. +This leaves unitialized data between the name field and the type field +leading to tftp errors. Use the length of the normalized name to avoid +this. + +Signed-off-by: Mark Salter +--- + grub-core/net/tftp.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c +index 63bbc28ef..c4b5205d0 100644 +--- a/grub-core/net/tftp.c ++++ b/grub-core/net/tftp.c +@@ -360,8 +360,8 @@ tftp_open (struct grub_file *file, const char *filename) + /* Copy and normalize the filename to work-around issues on some tftp + servers when file names are being matched for remapping. */ + grub_normalize_filename (rrq, filename); +- rrqlen += grub_strlen (filename) + 1; +- rrq += grub_strlen (filename) + 1; ++ rrqlen += grub_strlen (rrq) + 1; ++ rrq += grub_strlen (rrq) + 1; + + grub_strcpy (rrq, "octet"); + rrqlen += grub_strlen ("octet") + 1; +-- +2.14.3 + diff --git a/0108-bz1374141-fix-incorrect-mask-for-ppc64.patch b/0108-bz1374141-fix-incorrect-mask-for-ppc64.patch new file mode 100644 index 0000000..f07f50d --- /dev/null +++ b/0108-bz1374141-fix-incorrect-mask-for-ppc64.patch @@ -0,0 +1,47 @@ +From 3c49ce8c64b74f535891dd0caa420f1b9dfd9b60 Mon Sep 17 00:00:00 2001 +From: Masahiro Matsuya +Date: Sat, 29 Oct 2016 08:35:26 +0900 +Subject: [PATCH 108/123] bz1374141 fix incorrect mask for ppc64 + +The netmask configured in firmware is not respected on ppc64 (big endian). +When 255.255.252.0 is set as netmask in firmware, the following is the value of bootpath string in grub_ieee1275_parse_bootpath(). + + /vdevice/l-lan@30000002:speed=auto,duplex=auto,192.168.88.10,,192.168.89.113,192.168.88.1,5,5,255.255.252.0,512 + +The netmask in this bootpath is no problem, since it's a value specified in firmware. But, +The value of 'subnet_mask.ipv4' was set with 0xfffffc00, and __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4)) returned 16 (not 22). +As a result, 16 was used for netmask wrongly. + +1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4 (=0xfffffc00) +0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32 (subnet_mask.ipv4) +1111 1111 0000 0011 0000 0000 0000 0000 # ~grub_le_to_cpu32 (subnet_mask.ipv4) + +And, the count of zero with __builtin_ctz can be 16. +This patch changes it as below. + +1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4 (=0xfffffc00) +0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32 (subnet_mask.ipv4) +1111 1111 1111 1111 1111 1100 0000 0000 # grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)) +0000 0000 0000 0000 0000 0011 1111 1111 # ~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)) + +The count of zero with __builtin_clz can be 22. (clz counts the number of one bits preceding the most significant zero bit) +--- + grub-core/net/drivers/ieee1275/ofnet.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c +index 6bd3b922e..efc4e175a 100644 +--- a/grub-core/net/drivers/ieee1275/ofnet.c ++++ b/grub-core/net/drivers/ieee1275/ofnet.c +@@ -208,7 +208,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, + inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr, + flags); + grub_net_add_ipv4_local (inter, +- __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); ++ __builtin_clz (~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)))); + } + + if (gateway_addr.ipv4 != 0) +-- +2.14.3 + diff --git a/0109-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch b/0109-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch new file mode 100644 index 0000000..0ce5b21 --- /dev/null +++ b/0109-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch @@ -0,0 +1,314 @@ +From a159c349f05b21f4d3d7c876200f94481ae1a081 Mon Sep 17 00:00:00 2001 +From: Andrei Borzenkov +Date: Tue, 4 Apr 2017 19:23:55 +0300 +Subject: [PATCH 109/123] i386, x86_64, ppc: fix switch fallthrough cases with + GCC7 + +In util/getroot and efidisk slightly modify exitsing comment to mostly +retain it but still make GCC7 compliant with respect to fall through +annotation. + +In grub-core/lib/xzembed/xz_dec_lzma2.c it adds same comments as +upstream. + +In grub-core/tests/setjmp_tets.c declare functions as "noreturn" to +suppress GCC7 warning. + +In grub-core/gnulib/regexec.c use new __attribute__, because existing +annotation is not recognized by GCC7 parser (which requires that comment +immediately precedes case statement). + +Otherwise add FALLTHROUGH comment. + +Closes: 50598 +--- + grub-core/commands/hdparm.c | 1 + + grub-core/commands/nativedisk.c | 1 + + grub-core/disk/cryptodisk.c | 1 + + grub-core/disk/efi/efidisk.c | 2 +- + grub-core/efiemu/mm.c | 1 + + grub-core/gdb/cstub.c | 1 + + grub-core/gnulib/regexec.c | 3 +++ + grub-core/lib/xzembed/xz_dec_lzma2.c | 4 ++++ + grub-core/lib/xzembed/xz_dec_stream.c | 6 ++++++ + grub-core/loader/i386/linux.c | 3 +++ + grub-core/tests/setjmp_test.c | 5 ++++- + grub-core/video/ieee1275.c | 1 + + grub-core/video/readers/jpeg.c | 1 + + util/getroot.c | 2 +- + util/grub-install.c | 1 + + util/grub-mkimagexx.c | 1 + + util/grub-mount.c | 1 + + 17 files changed, 32 insertions(+), 3 deletions(-) + +diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c +index f6b178eae..d3fa9661e 100644 +--- a/grub-core/commands/hdparm.c ++++ b/grub-core/commands/hdparm.c +@@ -328,6 +328,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args) + ata = ((struct grub_scsi *) disk->data)->data; + break; + } ++ /* FALLTHROUGH */ + default: + grub_disk_close (disk); + return grub_error (GRUB_ERR_IO, "not an ATA device"); +diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c +index 345f97c4d..2f56a870e 100644 +--- a/grub-core/commands/nativedisk.c ++++ b/grub-core/commands/nativedisk.c +@@ -79,6 +79,7 @@ get_uuid (const char *name, char **uuid, int getnative) + case GRUB_DISK_DEVICE_XEN: + if (getnative) + break; ++ /* FALLTHROUGH */ + + /* Virtual disks. */ + /* GRUB dynamically generated files. */ +diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c +index 1e03a091c..bd60a66b3 100644 +--- a/grub-core/disk/cryptodisk.c ++++ b/grub-core/disk/cryptodisk.c +@@ -282,6 +282,7 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev, + break; + case GRUB_CRYPTODISK_MODE_IV_PLAIN64: + iv[1] = grub_cpu_to_le32 (sector >> 32); ++ /* FALLTHROUGH */ + case GRUB_CRYPTODISK_MODE_IV_PLAIN: + iv[0] = grub_cpu_to_le32 (sector & 0xFFFFFFFF); + break; +diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c +index 3b79f7bbc..a1a52a0a8 100644 +--- a/grub-core/disk/efi/efidisk.c ++++ b/grub-core/disk/efi/efidisk.c +@@ -215,7 +215,7 @@ name_devices (struct grub_efidisk_data *devices) + { + case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE: + is_hard_drive = 1; +- /* Fall through by intention. */ ++ /* Intentionally fall through. */ + case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE: + { + struct grub_efidisk_data *parent, *parent2; +diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c +index e606dbffc..52a032f7b 100644 +--- a/grub-core/efiemu/mm.c ++++ b/grub-core/efiemu/mm.c +@@ -417,6 +417,7 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, + default: + grub_dprintf ("efiemu", + "Unknown memory type %d. Assuming unusable\n", type); ++ /* FALLTHROUGH */ + case GRUB_MEMORY_RESERVED: + return grub_efiemu_add_to_mmap (addr, size, + GRUB_EFI_UNUSABLE_MEMORY); +diff --git a/grub-core/gdb/cstub.c b/grub-core/gdb/cstub.c +index c94411b10..b64acd70f 100644 +--- a/grub-core/gdb/cstub.c ++++ b/grub-core/gdb/cstub.c +@@ -336,6 +336,7 @@ grub_gdb_trap (int trap_no) + /* sAA..AA: Step one instruction from AA..AA(optional). */ + case 's': + stepping = 1; ++ /* FALLTHROUGH */ + + /* cAA..AA: Continue at address AA..AA(optional). */ + case 'c': +diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c +index f632cd47b..a7776f088 100644 +--- a/grub-core/gnulib/regexec.c ++++ b/grub-core/gnulib/regexec.c +@@ -4099,6 +4099,9 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node, + case OP_UTF8_PERIOD: + if (ch >= ASCII_CHARS) + return false; ++#if defined __GNUC__ && __GNUC__ >= 7 ++ __attribute__ ((fallthrough)); ++#endif + /* FALLTHROUGH */ + #endif + case OP_PERIOD: +diff --git a/grub-core/lib/xzembed/xz_dec_lzma2.c b/grub-core/lib/xzembed/xz_dec_lzma2.c +index 8a2a1183d..af7b77079 100644 +--- a/grub-core/lib/xzembed/xz_dec_lzma2.c ++++ b/grub-core/lib/xzembed/xz_dec_lzma2.c +@@ -1044,6 +1044,8 @@ enum xz_ret xz_dec_lzma2_run( + + s->lzma2.sequence = SEQ_LZMA_PREPARE; + ++ /* Fall through */ ++ + case SEQ_LZMA_PREPARE: + if (s->lzma2.compressed < RC_INIT_BYTES) + return XZ_DATA_ERROR; +@@ -1054,6 +1056,8 @@ enum xz_ret xz_dec_lzma2_run( + s->lzma2.compressed -= RC_INIT_BYTES; + s->lzma2.sequence = SEQ_LZMA_RUN; + ++ /* Fall through */ ++ + case SEQ_LZMA_RUN: + /* + * Set dictionary limit to indicate how much we want +diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c +index c16b13060..a29751e14 100644 +--- a/grub-core/lib/xzembed/xz_dec_stream.c ++++ b/grub-core/lib/xzembed/xz_dec_stream.c +@@ -750,6 +750,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) + + s->sequence = SEQ_BLOCK_START; + ++ /* FALLTHROUGH */ + case SEQ_BLOCK_START: + /* We need one byte of input to continue. */ + if (b->in_pos == b->in_size) +@@ -773,6 +774,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) + s->temp.pos = 0; + s->sequence = SEQ_BLOCK_HEADER; + ++ /* FALLTHROUGH */ + case SEQ_BLOCK_HEADER: + if (!fill_temp(s, b)) + return XZ_OK; +@@ -783,6 +785,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) + + s->sequence = SEQ_BLOCK_UNCOMPRESS; + ++ /* FALLTHROUGH */ + case SEQ_BLOCK_UNCOMPRESS: + ret = dec_block(s, b); + if (ret != XZ_STREAM_END) +@@ -810,6 +813,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) + + s->sequence = SEQ_BLOCK_CHECK; + ++ /* FALLTHROUGH */ + case SEQ_BLOCK_CHECK: + ret = hash_validate(s, b, 0); + if (ret != XZ_STREAM_END) +@@ -858,6 +862,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) + + s->sequence = SEQ_INDEX_CRC32; + ++ /* FALLTHROUGH */ + case SEQ_INDEX_CRC32: + ret = hash_validate(s, b, 1); + if (ret != XZ_STREAM_END) +@@ -866,6 +871,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b) + s->temp.size = STREAM_HEADER_SIZE; + s->sequence = SEQ_STREAM_FOOTER; + ++ /* FALLTHROUGH */ + case SEQ_STREAM_FOOTER: + if (!fill_temp(s, b)) + return XZ_OK; +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index 5eb7d17db..b1335f9ed 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -993,10 +993,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + { + case 'g': + shift += 10; ++ /* FALLTHROUGH */ + case 'm': + shift += 10; ++ /* FALLTHROUGH */ + case 'k': + shift += 10; ++ /* FALLTHROUGH */ + default: + break; + } +diff --git a/grub-core/tests/setjmp_test.c b/grub-core/tests/setjmp_test.c +index 390cb26eb..604a6ce8f 100644 +--- a/grub-core/tests/setjmp_test.c ++++ b/grub-core/tests/setjmp_test.c +@@ -25,7 +25,10 @@ GRUB_MOD_LICENSE ("GPLv3+"); + static grub_jmp_buf jmp_point; + static int expected, ctr; + +-#pragma GCC diagnostic ignored "-Wmissing-noreturn" ++/* This fixes GCC7 "unintentional fallthrough" warning */ ++static void jmp0 (void) __attribute__ ((noreturn)); ++static void jmp1 (void) __attribute__ ((noreturn)); ++static void jmp2 (void) __attribute__ ((noreturn)); + + static void + jmp0 (void) +diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c +index 813ab38e1..b8e4b3feb 100644 +--- a/grub-core/video/ieee1275.c ++++ b/grub-core/video/ieee1275.c +@@ -181,6 +181,7 @@ grub_video_ieee1275_fill_mode_info (grub_ieee1275_phandle_t dev, + case 32: + out->reserved_mask_size = 8; + out->reserved_field_pos = 24; ++ /* FALLTHROUGH */ + + case 24: + out->red_mask_size = 8; +diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c +index c3e0df240..21b0d9ded 100644 +--- a/grub-core/video/readers/jpeg.c ++++ b/grub-core/video/readers/jpeg.c +@@ -736,6 +736,7 @@ grub_jpeg_decode_jpeg (struct grub_jpeg_data *data) + case JPEG_MARKER_SOS: /* Start Of Scan. */ + if (grub_jpeg_decode_sos (data)) + break; ++ /* FALLTHROUGH */ + case JPEG_MARKER_RST0: /* Restart. */ + case JPEG_MARKER_RST1: + case JPEG_MARKER_RST2: +diff --git a/util/getroot.c b/util/getroot.c +index bf317a28e..fa3460d6c 100644 +--- a/util/getroot.c ++++ b/util/getroot.c +@@ -99,7 +99,7 @@ grub_util_pull_device (const char *os_dev) + { + case GRUB_DEV_ABSTRACTION_LVM: + grub_util_pull_lvm_by_command (os_dev); +- /* Fallthrough in case that lvm-tools are unavailable. */ ++ /* Fallthrough - in case that lvm-tools are unavailable. */ + case GRUB_DEV_ABSTRACTION_LUKS: + grub_util_pull_devmapper (os_dev); + return; +diff --git a/util/grub-install.c b/util/grub-install.c +index 6c89c2b0c..9074d3e9e 100644 +--- a/util/grub-install.c ++++ b/util/grub-install.c +@@ -1851,6 +1851,7 @@ main (int argc, char *argv[]) + free (mach_kernel); + break; + } ++ /* FALLTHROUGH */ + case GRUB_INSTALL_PLATFORM_ARM_EFI: + case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_IA64_EFI: +diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c +index 353a9407a..95ceab629 100644 +--- a/util/grub-mkimagexx.c ++++ b/util/grub-mkimagexx.c +@@ -908,6 +908,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, + + sym->st_value + - image_target->vaddr_offset)); + } ++ /* FALLTHROUGH */ + case R_IA64_LTOFF_FPTR22: + *gpptr = grub_host_to_target64 (addend + sym_addr); + grub_ia64_add_value_to_slot_21 ((grub_addr_t) target, +diff --git a/util/grub-mount.c b/util/grub-mount.c +index aca5f82e3..a25db8a71 100644 +--- a/util/grub-mount.c ++++ b/util/grub-mount.c +@@ -530,6 +530,7 @@ argp_parser (int key, char *arg, struct argp_state *state) + if (arg[0] != '-') + break; + ++ /* FALLTHROUGH */ + default: + if (!arg) + return 0; +-- +2.14.3 + diff --git a/0110-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch b/0110-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch new file mode 100644 index 0000000..65f400c --- /dev/null +++ b/0110-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch @@ -0,0 +1,65 @@ +From bc96a64f7947ef8c09f59392ec63ddf0937d20f9 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 26 Jun 2017 12:31:46 -0400 +Subject: [PATCH 110/123] Work around autoconf 2.69 having a terrible + AC_HEADER_MAJOR + +--- + configure.ac | 38 +++++++++++++++++++++++++++++++++++++- + 1 file changed, 37 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 1d8f7e745..70204bbf0 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -424,10 +424,46 @@ else + AC_PATH_PROG(HELP2MAN, help2man) + fi + ++# AC_HEADER_MAJOR_OI ++# --------------- ++AN_FUNCTION([major], [AC_HEADER_MAJOR_OI]) ++AN_FUNCTION([makedev], [AC_HEADER_MAJOR_OI]) ++AN_FUNCTION([minor], [AC_HEADER_MAJOR_OI]) ++AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR_OI]) ++AC_DEFUN([AC_HEADER_MAJOR_OI], ++[AC_CACHE_CHECK(whether sys/sysmacros.h defines makedev, ++ ac_cv_header_sys_sysmacros_h_makedev, ++[AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], ++ [[return makedev(0, 0);]])], ++ [ac_cv_header_sys_sysmacros_h_makedev=yes], ++ [ac_cv_header_sys_sysmacros_h_makedev=no]) ++]) ++ ++if test $ac_cv_header_sys_sysmacros_h_makedev = no; then ++AC_CHECK_HEADER(sys/mkdev.h, ++ [AC_DEFINE(MAJOR_IN_MKDEV, 1, ++ [Define to 1 if `major', `minor', and `makedev' are ++ declared in .])]) ++ ++ if test $ac_cv_header_sys_mkdev_h = no; then ++ AC_CHECK_HEADER(sys/types.h, ++ [AC_DEFINE(MAJOR_IN_TYPES, 1, ++ [Define to 1 if `major', `minor', and `makedev' ++ are declared in .])]) ++ fi ++ ++else ++ AC_DEFINE(MAJOR_IN_SYSMACROS, 1, ++ [Define to 1 if `major', `minor', and `makedev' ++ are declared in .]) ++fi ++])# AC_HEADER_MAJOR_OI ++ ++ + # Check for functions and headers. + AC_CHECK_FUNCS(posix_memalign memalign getextmntent) + AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) +-AC_HEADER_MAJOR ++AC_HEADER_MAJOR_OI + + AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default + #include +-- +2.14.3 + diff --git a/0111-Fix-a-btrfs-read-before-init-bug.patch b/0111-Fix-a-btrfs-read-before-init-bug.patch new file mode 100644 index 0000000..7133dbc --- /dev/null +++ b/0111-Fix-a-btrfs-read-before-init-bug.patch @@ -0,0 +1,39 @@ +From de37bf80fed16a991a9218ca5fb73008f59cd689 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 26 Jun 2017 12:35:47 -0400 +Subject: [PATCH 111/123] Fix a btrfs read-before-init bug + +--- + grub-core/fs/btrfs.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c +index 9cffa91fa..cb25b9ddd 100644 +--- a/grub-core/fs/btrfs.c ++++ b/grub-core/fs/btrfs.c +@@ -232,10 +232,6 @@ read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) + for (i = 0; i < ARRAY_SIZE (superblock_sectors); i++) + { + struct grub_btrfs_superblock sblock; +- /* Don't try additional superblocks beyond device size. */ +- if (i && (grub_le_to_cpu64 (sblock.this_device.size) +- >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i]) +- break; + err = grub_disk_read (disk, superblock_sectors[i], 0, + sizeof (sblock), &sblock); + if (err == GRUB_ERR_OUT_OF_RANGE) +@@ -247,6 +243,11 @@ read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) + if (i == 0 || grub_le_to_cpu64 (sblock.generation) + > grub_le_to_cpu64 (sb->generation)) + grub_memcpy (sb, &sblock, sizeof (sblock)); ++ ++ /* Don't try additional superblocks beyond device size. */ ++ if (i && (grub_le_to_cpu64 (sblock.this_device.size) ++ >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i]) ++ break; + } + + if ((err == GRUB_ERR_OUT_OF_RANGE || !err) && i == 0) +-- +2.14.3 + diff --git a/0112-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch b/0112-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch new file mode 100644 index 0000000..a6f60de --- /dev/null +++ b/0112-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch @@ -0,0 +1,46 @@ +From e26bdce564d529852f8f3d27874dc15467839033 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 26 Jun 2017 12:42:57 -0400 +Subject: [PATCH 112/123] Don't use dynamic sized arrays since we don't build + with -std=c99 + +--- + grub-core/net/net.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/grub-core/net/net.c b/grub-core/net/net.c +index 16d2ce06d..b4325750f 100644 +--- a/grub-core/net/net.c ++++ b/grub-core/net/net.c +@@ -1781,14 +1781,25 @@ grub_net_search_configfile (char *config) + { + /* By the Client UUID. */ + +- char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) + +- sizeof ("_clientuuid") + 1]; +- grub_snprintf (client_uuid_var, sizeof (client_uuid_var), ++ char *client_uuid_var; ++ grub_size_t client_uuid_var_size; ++ ++ client_uuid_var_size = grub_snprintf (NULL, 0, ++ "net_%s_clientuuid", inf->name); ++ if (client_uuid_var_size <= 0) ++ continue; ++ client_uuid_var_size += 1; ++ client_uuid_var = grub_malloc(client_uuid_var_size); ++ if (!client_uuid_var) ++ continue; ++ grub_snprintf (client_uuid_var, client_uuid_var_size, + "net_%s_clientuuid", inf->name); + + const char *client_uuid; + client_uuid = grub_env_get (client_uuid_var); + ++ grub_free(client_uuid_var); ++ + if (client_uuid) + { + grub_strcpy (suffix, client_uuid); +-- +2.14.3 + diff --git a/0113-don-t-ignore-const.patch b/0113-don-t-ignore-const.patch new file mode 100644 index 0000000..6e0a983 --- /dev/null +++ b/0113-don-t-ignore-const.patch @@ -0,0 +1,25 @@ +From f2b28326d5aa2cdcaa56def8a806fbcc23962c03 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 26 Jun 2017 12:43:22 -0400 +Subject: [PATCH 113/123] don't ignore const + +--- + grub-core/net/tftp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c +index c4b5205d0..dd4ce6b23 100644 +--- a/grub-core/net/tftp.c ++++ b/grub-core/net/tftp.c +@@ -307,7 +307,7 @@ static void + grub_normalize_filename (char *normalized, const char *filename) + { + char *dest = normalized; +- char *src = filename; ++ const char *src = filename; + + while (*src != '\0') + { +-- +2.14.3 + diff --git a/0114-don-t-use-int-for-efi-status.patch b/0114-don-t-use-int-for-efi-status.patch new file mode 100644 index 0000000..1a27b3d --- /dev/null +++ b/0114-don-t-use-int-for-efi-status.patch @@ -0,0 +1,25 @@ +From c694f0875585ed90c1429c7ea28be55613c5e817 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 26 Jun 2017 12:44:59 -0400 +Subject: [PATCH 114/123] don't use int for efi status + +--- + grub-core/kern/efi/efi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index 101307fc7..e22c97675 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -157,7 +157,7 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) + void + grub_exit (int retval) + { +- int rc = GRUB_EFI_LOAD_ERROR; ++ grub_efi_status_t rc = GRUB_EFI_LOAD_ERROR; + + if (retval == 0) + rc = GRUB_EFI_SUCCESS; +-- +2.14.3 + diff --git a/0115-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch b/0115-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch new file mode 100644 index 0000000..2a6c612 --- /dev/null +++ b/0115-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch @@ -0,0 +1,32 @@ +From cd15c392fb277ea7a98fe9cc25e12b8bea703aaf Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 26 Jun 2017 12:46:23 -0400 +Subject: [PATCH 115/123] make GRUB_MOD_INIT() declare its function prototypes. + +--- + include/grub/dl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/grub/dl.h b/include/grub/dl.h +index 9562fa663..5ed58858e 100644 +--- a/include/grub/dl.h ++++ b/include/grub/dl.h +@@ -54,6 +54,7 @@ grub_mod_fini (void) + + #define GRUB_MOD_INIT(name) \ + static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \ ++extern void grub_##name##_init (void); \ + void \ + grub_##name##_init (void) { grub_mod_init (0); } \ + static void \ +@@ -61,6 +62,7 @@ grub_mod_init (grub_dl_t mod __attribute__ ((unused))) + + #define GRUB_MOD_FINI(name) \ + static void grub_mod_fini (void) __attribute__ ((used)); \ ++extern void grub_##name##_fini (void); \ + void \ + grub_##name##_fini (void) { grub_mod_fini (); } \ + static void \ +-- +2.14.3 + diff --git a/0116-Add-some-grub_dprintf-in-the-linuxefi-path.patch b/0116-Add-some-grub_dprintf-in-the-linuxefi-path.patch new file mode 100644 index 0000000..1f8ec57 --- /dev/null +++ b/0116-Add-some-grub_dprintf-in-the-linuxefi-path.patch @@ -0,0 +1,88 @@ +From 9fb8798e6c8a2241e157de414460f1d7dab89c00 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 9 May 2016 14:15:17 -0400 +Subject: [PATCH 116/123] Add some grub_dprintf() in the linuxefi path. + +Signed-off-by: Peter Jones +--- + grub-core/loader/efi/linux.c | 16 +++++++++++++--- + grub-core/loader/i386/efi/linux.c | 10 +++++++++- + 2 files changed, 22 insertions(+), 4 deletions(-) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index 8890bdf05..dbf63e20e 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -43,12 +43,22 @@ grub_linuxefi_secure_validate (void *data, grub_uint32_t size) + shim_lock = grub_efi_locate_protocol(&guid, NULL); + grub_dprintf ("secureboot", "shim_lock: %p\n", shim_lock); + if (!shim_lock) +- return 0; ++ { ++ grub_dprintf ("secureboot", "shim not available\n"); ++ return 0; ++ } + +- status = shim_lock->verify(data, size); ++ grub_dprintf ("secureboot", "Asking shim to verify kernel signature\n"); ++ status = shim_lock->verify (data, size); + grub_dprintf ("secureboot", "shim_lock->verify(): %ld\n", status); + if (status == GRUB_EFI_SUCCESS) +- return 1; ++ { ++ grub_dprintf ("secureboot", "Kernel signature verification passed\n"); ++ return 1; ++ } ++ ++ grub_dprintf ("secureboot", "Kernel signature verification failed (0x%lx)\n", ++ (unsigned long) status); + + return -1; + } +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 010bf982d..a95e29700 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -114,6 +114,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++ grub_dprintf ("linuxefi", "initrd_mem = %lx\n", (unsigned long) initrd_mem); ++ + params->ramdisk_size = size; + params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem; + +@@ -202,6 +204,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++ grub_dprintf ("linuxefi", "params = %lx\n", (unsigned long) params); ++ + grub_memset (params, 0, 16384); + + grub_memcpy (&lh, kernel, sizeof (lh)); +@@ -239,6 +243,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++ grub_dprintf ("linuxefi", "linux_cmdline = %lx\n", ++ (unsigned long)linux_cmdline); ++ + grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, + linux_cmdline + sizeof (LINUX_IMAGE) - 1, +@@ -272,9 +279,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_memcpy (params, &lh, 2 * 512); + + params->type_of_loader = 0x21; ++ grub_dprintf("linuxefi", "kernel_mem: %p handover_offset: %08x\n", ++ kernel_mem, handover_offset); + + fail: +- + if (file) + grub_file_close (file); + +-- +2.14.3 + diff --git a/0117-linuxefi-minor-cleanups.patch b/0117-linuxefi-minor-cleanups.patch new file mode 100644 index 0000000..cf37779 --- /dev/null +++ b/0117-linuxefi-minor-cleanups.patch @@ -0,0 +1,89 @@ +From 5678a5ad6b2560a293f757c0c74b3da45619bb9f Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 14 Feb 2017 16:31:52 -0500 +Subject: [PATCH 117/123] linuxefi: minor cleanups + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/efi/linux.c | 30 ++++++++++++++++++++---------- + 1 file changed, 20 insertions(+), 10 deletions(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index a95e29700..806031838 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -61,13 +61,18 @@ grub_linuxefi_unload (void) + grub_dl_unref (my_mod); + loaded = 0; + if (initrd_mem) +- grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(params->ramdisk_size)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, ++ BYTES_TO_PAGES(params->ramdisk_size)); + if (linux_cmdline) +- grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(params->cmdline_size + 1)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) ++ linux_cmdline, ++ BYTES_TO_PAGES(params->cmdline_size + 1)); + if (kernel_mem) +- grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, ++ BYTES_TO_PAGES(kernel_size)); + if (params) +- grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, ++ BYTES_TO_PAGES(16384)); + return GRUB_ERR_NONE; + } + +@@ -117,7 +122,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + grub_dprintf ("linuxefi", "initrd_mem = %lx\n", (unsigned long) initrd_mem); + + params->ramdisk_size = size; +- params->ramdisk_image = (grub_uint32_t)(grub_uint64_t) initrd_mem; ++ params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem; + + ptr = initrd_mem; + +@@ -144,7 +149,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + grub_free (files); + + if (initrd_mem && grub_errno) +- grub_efi_free_pages((grub_efi_physical_address_t)initrd_mem, BYTES_TO_PAGES(size)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, ++ BYTES_TO_PAGES(size)); + + return grub_errno; + } +@@ -251,7 +257,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + linux_cmdline + sizeof (LINUX_IMAGE) - 1, + lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); + +- lh.cmd_line_ptr = (grub_uint32_t)(grub_uint64_t)linux_cmdline; ++ lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; + + handover_offset = lh.handover_offset; + +@@ -296,13 +302,17 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } + + if (linux_cmdline && !loaded) +- grub_efi_free_pages((grub_efi_physical_address_t)linux_cmdline, BYTES_TO_PAGES(lh.cmdline_size + 1)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) ++ linux_cmdline, ++ BYTES_TO_PAGES(lh.cmdline_size + 1)); + + if (kernel_mem && !loaded) +- grub_efi_free_pages((grub_efi_physical_address_t)kernel_mem, BYTES_TO_PAGES(kernel_size)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, ++ BYTES_TO_PAGES(kernel_size)); + + if (params && !loaded) +- grub_efi_free_pages((grub_efi_physical_address_t)params, BYTES_TO_PAGES(16384)); ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, ++ BYTES_TO_PAGES(16384)); + + return grub_errno; + } +-- +2.14.3 + diff --git a/0118-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch b/0118-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch new file mode 100644 index 0000000..07cd757 --- /dev/null +++ b/0118-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch @@ -0,0 +1,261 @@ +From a6a55b951426419d5db76916b97bfeb2a505fff5 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 14 Feb 2017 16:18:54 -0500 +Subject: [PATCH 118/123] Handle multi-arch (64-on-32) boot in linuxefi loader. + +Allow booting 64-bit kernels on 32-bit EFI on x86. + +Signed-off-by: Peter Jones +--- + grub-core/loader/efi/linux.c | 9 +++- + grub-core/loader/i386/efi/linux.c | 108 ++++++++++++++++++++++++++------------ + include/grub/i386/linux.h | 7 ++- + 3 files changed, 88 insertions(+), 36 deletions(-) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index dbf63e20e..7fe7201a3 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -66,12 +66,17 @@ grub_linuxefi_secure_validate (void *data, grub_uint32_t size) + typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); + + grub_err_t +-grub_efi_linux_boot (void *kernel_addr, grub_off_t offset, ++grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, + void *kernel_params) + { + handover_func hf; ++ int offset = 0; + +- hf = (handover_func)((char *)kernel_addr + offset); ++#ifdef __x86_64__ ++ offset = 512; ++#endif ++ ++ hf = (handover_func)((char *)kernel_addr + handover_offset + offset); + hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); + + return GRUB_ERR_BUG; +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 806031838..52dc71903 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -44,14 +44,10 @@ static char *linux_cmdline; + static grub_err_t + grub_linuxefi_boot (void) + { +- int offset = 0; +- +-#ifdef __x86_64__ +- offset = 512; +-#endif + asm volatile ("cli"); + +- return grub_efi_linux_boot ((char *)kernel_mem, handover_offset + offset, ++ return grub_efi_linux_boot ((char *)kernel_mem, ++ handover_offset, + params); + } + +@@ -155,14 +151,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + return grub_errno; + } + ++#define MIN(a, b) \ ++ ({ typeof (a) _a = (a); \ ++ typeof (b) _b = (b); \ ++ _a < _b ? _a : _b; }) ++ + static grub_err_t + grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) + { + grub_file_t file = 0; +- struct linux_kernel_header lh; ++ struct linux_kernel_header *lh; + grub_ssize_t len, start, filelen; + void *kernel = NULL; ++ int setup_header_end_offset; + int rc; + + grub_dl_ref (my_mod); +@@ -202,47 +204,78 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- params = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(16384)); +- ++ params = grub_efi_allocate_pages_max (0x3fffffff, ++ BYTES_TO_PAGES(sizeof(*params))); + if (! params) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); + goto fail; + } + +- grub_dprintf ("linuxefi", "params = %lx\n", (unsigned long) params); +- +- grub_memset (params, 0, 16384); +- +- grub_memcpy (&lh, kernel, sizeof (lh)); +- +- if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) ++ grub_dprintf ("linuxefi", "params = %p\n", (unsigned long) params); ++ ++ grub_memset (params, 0, sizeof(*params)); ++ ++ setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201); ++ grub_dprintf ("linuxefi", "copying %d bytes from %p to %p\n", ++ MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1, ++ (grub_uint8_t *)kernel + 0x1f1, ++ (grub_uint8_t *)params + 0x1f1); ++ grub_memcpy ((grub_uint8_t *)params + 0x1f1, ++ (grub_uint8_t *)kernel + 0x1f1, ++ MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); ++ lh = (struct linux_kernel_header *)params; ++ grub_dprintf ("linuxefi", "lh is at %p\n", lh); ++ grub_dprintf ("linuxefi", "checking lh->boot_flag\n"); ++ if (lh->boot_flag != grub_cpu_to_le16 (0xaa55)) + { + grub_error (GRUB_ERR_BAD_OS, N_("invalid magic number")); + goto fail; + } + +- if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS) ++ grub_dprintf ("linuxefi", "checking lh->setup_sects\n"); ++ if (lh->setup_sects > GRUB_LINUX_MAX_SETUP_SECTS) + { + grub_error (GRUB_ERR_BAD_OS, N_("too many setup sectors")); + goto fail; + } + +- if (lh.version < grub_cpu_to_le16 (0x020b)) ++ grub_dprintf ("linuxefi", "checking lh->version\n"); ++ if (lh->version < grub_cpu_to_le16 (0x020b)) + { + grub_error (GRUB_ERR_BAD_OS, N_("kernel too old")); + goto fail; + } + +- if (!lh.handover_offset) ++ grub_dprintf ("linuxefi", "checking lh->handover_offset\n"); ++ if (!lh->handover_offset) + { + grub_error (GRUB_ERR_BAD_OS, N_("kernel doesn't support EFI handover")); + goto fail; + } + +- linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, +- BYTES_TO_PAGES(lh.cmdline_size + 1)); ++#ifdef defined(__x86_64__) || defined(__aarch64__) ++ grub_dprintf ("linuxefi", "checking lh->xloadflags\n"); ++ if (!(lh->xloadflags & LINUX_XLF_KERNEL_64)) ++ { ++ grub_error (GRUB_ERR_BAD_OS, N_("kernel doesn't support 64-bit CPUs")); ++ goto fail; ++ } ++#endif ++ ++#if defined(__i386__) ++ if ((lh->xloadflags & LINUX_XLF_KERNEL_64) && ++ !(lh->xloadflags & LINUX_XLF_EFI_HANDOVER_32)) ++ { ++ grub_error (GRUB_ERR_BAD_OS, ++ N_("kernel doesn't support 32-bit handover")); ++ goto fail; ++ } ++#endif + ++ grub_dprintf ("linuxefi", "setting up cmdline\n"); ++ linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, ++ BYTES_TO_PAGES(lh->cmdline_size + 1)); + if (!linux_cmdline) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline")); +@@ -255,21 +288,23 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, + linux_cmdline + sizeof (LINUX_IMAGE) - 1, +- lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); ++ lh->cmdline_size - (sizeof (LINUX_IMAGE) - 1)); + +- lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; ++ grub_dprintf ("linuxefi", "setting lh->cmd_line_ptr\n"); ++ lh->cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; + +- handover_offset = lh.handover_offset; ++ grub_dprintf ("linuxefi", "computing handover offset\n"); ++ handover_offset = lh->handover_offset; + +- start = (lh.setup_sects + 1) * 512; ++ start = (lh->setup_sects + 1) * 512; + len = grub_file_size(file) - start; + +- kernel_mem = grub_efi_allocate_pages(lh.pref_address, +- BYTES_TO_PAGES(lh.init_size)); ++ kernel_mem = grub_efi_allocate_pages(lh->pref_address, ++ BYTES_TO_PAGES(lh->init_size)); + + if (!kernel_mem) + kernel_mem = grub_efi_allocate_pages_max(0x3fffffff, +- BYTES_TO_PAGES(lh.init_size)); ++ BYTES_TO_PAGES(lh->init_size)); + + if (!kernel_mem) + { +@@ -277,14 +312,21 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- grub_memcpy (kernel_mem, (char *)kernel + start, len); ++ grub_dprintf ("linuxefi", "kernel_mem = %lx\n", (unsigned long) kernel_mem); ++ + grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); + loaded=1; ++ grub_dprintf ("linuxefi", "setting lh->code32_start to %p\n", kernel_mem); ++ lh->code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem; ++ ++ grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); + +- lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; +- grub_memcpy (params, &lh, 2 * 512); ++ grub_dprintf ("linuxefi", "setting lh->type_of_loader\n"); ++ lh->type_of_loader = 0x6; + +- params->type_of_loader = 0x21; ++ grub_dprintf ("linuxefi", "setting lh->ext_loader_{type,ver}\n"); ++ params->ext_loader_type = 0; ++ params->ext_loader_ver = 2; + grub_dprintf("linuxefi", "kernel_mem: %p handover_offset: %08x\n", + kernel_mem, handover_offset); + +@@ -304,7 +346,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + if (linux_cmdline && !loaded) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) + linux_cmdline, +- BYTES_TO_PAGES(lh.cmdline_size + 1)); ++ BYTES_TO_PAGES(lh->cmdline_size + 1)); + + if (kernel_mem && !loaded) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, +diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h +index fc36bdaf3..110ecf806 100644 +--- a/include/grub/i386/linux.h ++++ b/include/grub/i386/linux.h +@@ -130,7 +130,12 @@ struct linux_kernel_header + grub_uint32_t kernel_alignment; + grub_uint8_t relocatable; + grub_uint8_t min_alignment; +- grub_uint8_t pad[2]; ++#define LINUX_XLF_KERNEL_64 (1<<0) ++#define LINUX_XLF_CAN_BE_LOADED_ABOVE_4G (1<<1) ++#define LINUX_XLF_EFI_HANDOVER_32 (1<<2) ++#define LINUX_XLF_EFI_HANDOVER_64 (1<<3) ++#define LINUX_XLF_EFI_KEXEC (1<<4) ++ grub_uint16_t xloadflags; + grub_uint32_t cmdline_size; + grub_uint32_t hardware_subarch; + grub_uint64_t hardware_subarch_data; +-- +2.14.3 + diff --git a/0119-Clean-up-some-errors-in-the-linuxefi-loader.patch b/0119-Clean-up-some-errors-in-the-linuxefi-loader.patch new file mode 100644 index 0000000..05ec225 --- /dev/null +++ b/0119-Clean-up-some-errors-in-the-linuxefi-loader.patch @@ -0,0 +1,78 @@ +From 266bbbe624274a0eb174bb294c70e197848f3991 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 24 May 2017 15:58:18 -0400 +Subject: [PATCH 119/123] Clean up some errors in the linuxefi loader + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/efi/linux.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 52dc71903..19950d2f2 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -161,8 +161,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) + { + grub_file_t file = 0; +- struct linux_kernel_header *lh; +- grub_ssize_t len, start, filelen; ++ struct linux_kernel_header *lh = NULL; ++ grub_ssize_t start, filelen; + void *kernel = NULL; + int setup_header_end_offset; + int rc; +@@ -212,18 +212,19 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- grub_dprintf ("linuxefi", "params = %p\n", (unsigned long) params); ++ grub_dprintf ("linuxefi", "params = %p\n", params); + + grub_memset (params, 0, sizeof(*params)); + + setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201); +- grub_dprintf ("linuxefi", "copying %d bytes from %p to %p\n", +- MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1, ++ grub_dprintf ("linuxefi", "copying %zu bytes from %p to %p\n", ++ MIN((grub_size_t)0x202+setup_header_end_offset, ++ sizeof (*params)) - 0x1f1, + (grub_uint8_t *)kernel + 0x1f1, + (grub_uint8_t *)params + 0x1f1); + grub_memcpy ((grub_uint8_t *)params + 0x1f1, + (grub_uint8_t *)kernel + 0x1f1, +- MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); ++ MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); + lh = (struct linux_kernel_header *)params; + grub_dprintf ("linuxefi", "lh is at %p\n", lh); + grub_dprintf ("linuxefi", "checking lh->boot_flag\n"); +@@ -254,7 +255,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +-#ifdef defined(__x86_64__) || defined(__aarch64__) ++#if defined(__x86_64__) || defined(__aarch64__) + grub_dprintf ("linuxefi", "checking lh->xloadflags\n"); + if (!(lh->xloadflags & LINUX_XLF_KERNEL_64)) + { +@@ -297,7 +298,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + handover_offset = lh->handover_offset; + + start = (lh->setup_sects + 1) * 512; +- len = grub_file_size(file) - start; + + kernel_mem = grub_efi_allocate_pages(lh->pref_address, + BYTES_TO_PAGES(lh->init_size)); +@@ -343,7 +343,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + loaded = 0; + } + +- if (linux_cmdline && !loaded) ++ if (linux_cmdline && lh && !loaded) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) + linux_cmdline, + BYTES_TO_PAGES(lh->cmdline_size + 1)); +-- +2.14.3 + diff --git a/0120-Fix-up-linux-params-usage.patch b/0120-Fix-up-linux-params-usage.patch new file mode 100644 index 0000000..98e6713 --- /dev/null +++ b/0120-Fix-up-linux-params-usage.patch @@ -0,0 +1,45 @@ +From 3019712d45a7934a2bf21de8e2745c03701b05cc Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 30 May 2017 14:16:07 -0400 +Subject: [PATCH 120/123] Fix up linux params usage... + +Related: rhbz#1310763 + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/linux.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index b1335f9ed..763863abe 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -680,6 +680,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + { + grub_file_t file = 0; + struct linux_kernel_header lh; ++ grub_uint8_t *linux_params_ptr; + grub_uint8_t setup_sects; + grub_size_t real_size, prot_size, prot_file_size, kernel_offset; + grub_ssize_t len; +@@ -811,6 +812,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + preferred_address)) + goto fail; + ++ + grub_memset (&linux_params, 0, sizeof (linux_params)); + grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1); + +@@ -820,7 +822,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + len = sizeof (linux_params) - sizeof (lh); + +- grub_memcpy (&linux_params + sizeof (lh), kernel + kernel_offset, len); ++ linux_params_ptr = (void *)&linux_params; ++ grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len); + kernel_offset += len; + + linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; +-- +2.14.3 + diff --git a/0121-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch b/0121-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch new file mode 100644 index 0000000..ddb9057 --- /dev/null +++ b/0121-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch @@ -0,0 +1,45 @@ +From c38aad7b173cbe4e84fb52efbd4ef6a03503a3b1 Mon Sep 17 00:00:00 2001 +From: Mark Salter +Date: Mon, 17 Apr 2017 08:44:29 -0400 +Subject: [PATCH 121/123] arm64: make sure fdt has #address-cells and + #size-cells properties + +Recent upstream changes to kexec-tools relies on #address-cells +and #size-cells properties in the FDT. If grub2 needs to create +a chosen node, it is likely because firmware did not provide one. +In that case, set #address-cells and #size-cells properties to +make sure they exist. +--- + grub-core/loader/arm64/linux.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c +index f83820e61..f32151f3b 100644 +--- a/grub-core/loader/arm64/linux.c ++++ b/grub-core/loader/arm64/linux.c +@@ -81,7 +81,21 @@ finalize_params_linux (void) + + node = grub_fdt_find_subnode (fdt, 0, "chosen"); + if (node < 0) +- node = grub_fdt_add_subnode (fdt, 0, "chosen"); ++ { ++ /* ++ * If we have to create a chosen node, Make sure we ++ * have #address-cells and #size-cells properties. ++ */ ++ retval = grub_fdt_set_prop32(fdt, 0, "#address-cells", 2); ++ if (retval) ++ goto failure; ++ ++ retval = grub_fdt_set_prop32(fdt, 0, "#size-cells", 2); ++ if (retval) ++ goto failure; ++ ++ node = grub_fdt_add_subnode (fdt, 0, "chosen"); ++ } + + if (node < 1) + goto failure; +-- +2.14.3 + diff --git a/0122-tsc-Change-default-tsc-calibration-method-to-pmtimer.patch b/0122-tsc-Change-default-tsc-calibration-method-to-pmtimer.patch new file mode 100644 index 0000000..92a5b56 --- /dev/null +++ b/0122-tsc-Change-default-tsc-calibration-method-to-pmtimer.patch @@ -0,0 +1,32 @@ +From 8a8023951ccdf08035a58cefe6ff98098e2c4029 Mon Sep 17 00:00:00 2001 +From: "David E. Box" +Date: Fri, 15 Sep 2017 15:37:05 -0700 +Subject: [PATCH 122/123] tsc: Change default tsc calibration method to pmtimer + on EFI systems + +On efi systems, make pmtimer based tsc calibration the default over the +pit. This prevents Grub from hanging on Intel SoC systems that power gate +the pit. + +Signed-off-by: David E. Box +Reviewed-by: Daniel Kiper +--- + grub-core/kern/i386/tsc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c +index 2e85289d8..f266eb131 100644 +--- a/grub-core/kern/i386/tsc.c ++++ b/grub-core/kern/i386/tsc.c +@@ -68,7 +68,7 @@ grub_tsc_init (void) + #ifdef GRUB_MACHINE_XEN + (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode()); + #elif defined (GRUB_MACHINE_EFI) +- (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); ++ (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); + #elif defined (GRUB_MACHINE_COREBOOT) + (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode()); + #else +-- +2.14.3 + diff --git a/0123-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch b/0123-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch new file mode 100644 index 0000000..c3716f7 --- /dev/null +++ b/0123-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch @@ -0,0 +1,96 @@ +From 1b536bd5c774e5ce9ff5fcefff141eebf6d4ce07 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 7 Nov 2017 17:12:17 -0500 +Subject: [PATCH 123/123] Make pmtimer tsc calibration not take 51 seconds to + fail. + +On my laptop running at 2.4GHz, if I run a VM where tsc calibration +using pmtimer will fail presuming a broken pmtimer, it takes ~51 seconds +to do so (as measured with the stopwatch on my phone), with a tsc delta +of 0x1cd1c85300, or around 125 billion cycles. + +If instead of trying to wait for 5-200ms to show up on the pmtimer, we try +to wait for 5-200us, it decides it's broken in ~0x7998f9e TSCs, aka ~2 +million cycles, or more or less instantly. + +Additionally, this reading the pmtimer was returning 0xffffffff anyway, +and that's obviously an invalid return. I've added a check for that and +0 so we don't bother waiting for the test if what we're seeing is dead +pins with no response at all. + +Signed-off-by: Peter Jones +--- + grub-core/kern/i386/tsc_pmtimer.c | 43 ++++++++++++++++++++++++++++++--------- + 1 file changed, 33 insertions(+), 10 deletions(-) + +diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c +index c9c361699..609402b83 100644 +--- a/grub-core/kern/i386/tsc_pmtimer.c ++++ b/grub-core/kern/i386/tsc_pmtimer.c +@@ -38,30 +38,53 @@ grub_pmtimer_wait_count_tsc (grub_port_t pmtimer, + grub_uint64_t start_tsc; + grub_uint64_t end_tsc; + int num_iter = 0; ++ int bad_reads = 0; + +- start = grub_inl (pmtimer) & 0xffffff; ++ start = grub_inl (pmtimer) & 0x3fff; + last = start; + end = start + num_pm_ticks; + start_tsc = grub_get_tsc (); + while (1) + { +- cur = grub_inl (pmtimer) & 0xffffff; ++ cur = grub_inl (pmtimer); ++ ++ /* If we get 10 reads in a row that are obviously dead pins, there's no ++ reason to do this thousands of times. ++ */ ++ if (cur == 0xffffffff || cur == 0) ++ { ++ bad_reads++; ++ grub_dprintf ("pmtimer", "cur: 0x%08x bad_reads: %d\n", cur, bad_reads); ++ ++ if (bad_reads == 10) ++ return 0; ++ } ++ else if (bad_reads) ++ bad_reads = 0; ++ ++ cur &= 0x3fff; ++ + if (cur < last) +- cur |= 0x1000000; ++ cur |= 0x4000; + num_iter++; + if (cur >= end) + { + end_tsc = grub_get_tsc (); ++ grub_dprintf ("pmtimer", "tsc delta is 0x%016lx\n", ++ end_tsc - start_tsc); + return end_tsc - start_tsc; + } +- /* Check for broken PM timer. +- 50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz) +- if after this time we still don't have 1 ms on pmtimer, then +- pmtimer is broken. ++ /* Check for broken PM timer. 5000 TSCs is between 5us (10GHz) and ++ 200us (250 MHz). If after this time we still don't have 1us on ++ pmtimer, then pmtimer is broken. + */ +- if ((num_iter & 0xffffff) == 0 && grub_get_tsc () - start_tsc > 5000000) { +- return 0; +- } ++ end_tsc = grub_get_tsc(); ++ if ((num_iter & 0x3fff) == 0 && end_tsc - start_tsc > 5000) ++ { ++ grub_dprintf ("pmtimer", "tsc delta is 0x%016lx\n", ++ end_tsc - start_tsc); ++ return 0; ++ } + } + } + +-- +2.14.3 + diff --git a/grub.patches b/grub.patches index 2c5c610..edb55a5 100644 --- a/grub.patches +++ b/grub.patches @@ -1,106 +1,123 @@ -Patch0000: grub-2.02-beta3-to-origin-master.patch -Patch0001: 0001-IBM-client-architecture-CAS-reboot-support.patch -Patch0002: 0002-for-ppc-reset-console-display-attr-when-clear-screen.patch -Patch0003: 0003-Disable-GRUB-video-support-for-IBM-power-machines.patch -Patch0004: 0004-Fix-bzr-s-ignore-artificats-in-.gitignore.patch -Patch0005: 0005-Honor-a-symlink-when-generating-configuration-by-gru.patch -Patch0006: 0006-Move-bash-completion-script-922997.patch -Patch0007: 0007-Update-to-minilzo-2.08.patch -Patch0008: 0008-Add-vlan-tag-support-on-IBM-PPC-machines.patch -Patch0009: 0009-Allow-fallback-to-include-entries-by-title-not-just-.patch -Patch0010: 0010-Add-GRUB_DISABLE_UUID.patch -Patch0011: 0011-Make-exit-take-a-return-code.patch -Patch0012: 0012-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch -Patch0013: 0013-Make-efi-machines-load-an-env-block-from-a-variable.patch -Patch0014: 0014-DHCP-client-ID-and-UUID-options-added.patch -Patch0015: 0015-trim-arp-packets-with-abnormal-size.patch -Patch0016: 0016-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch -Patch0017: 0017-Add-support-for-UEFI-operating-systems-returned-by-o.patch -Patch0018: 0018-Migrate-PPC-from-Yaboot-to-Grub2.patch -Patch0019: 0019-Add-fw_path-variable-revised.patch -Patch0020: 0020-Add-support-for-linuxefi.patch -Patch0021: 0021-Use-linuxefi-and-initrdefi-where-appropriate.patch -Patch0022: 0022-Don-t-allow-insmod-when-secure-boot-is-enabled.patch -Patch0023: 0023-Pass-x-hex-hex-straight-through-unmolested.patch -Patch0024: 0024-Add-X-option-to-printf-functions.patch -Patch0025: 0025-Search-for-specific-config-file-for-netboot.patch -Patch0026: 0026-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch -Patch0027: 0027-Don-t-write-messages-to-the-screen.patch -Patch0028: 0028-Don-t-print-GNU-GRUB-header.patch -Patch0029: 0029-Don-t-add-to-highlighted-row.patch -Patch0030: 0030-Message-string-cleanups.patch -Patch0031: 0031-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch -Patch0032: 0032-Use-the-correct-indentation-for-the-term-help-text.patch -Patch0033: 0033-Indent-menu-entries.patch -Patch0034: 0034-Fix-margins.patch -Patch0035: 0035-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch -Patch0036: 0036-Use-linux16-when-appropriate-880840.patch -Patch0037: 0037-Enable-pager-by-default.-985860.patch -Patch0038: 0038-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch -Patch0039: 0039-Don-t-say-GNU-Linux-in-generated-menus.patch -Patch0040: 0040-Don-t-draw-a-border-around-the-menu.patch -Patch0041: 0041-Use-the-standard-margin-for-the-timeout-string.patch -Patch0042: 0042-Add-.eh_frame-to-list-of-relocations-stripped.patch -Patch0043: 0043-Make-10_linux-work-with-our-changes-for-linux16-and-.patch -Patch0044: 0044-Don-t-print-during-fdt-loading-method.patch -Patch0045: 0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch -Patch0046: 0046-Don-t-require-a-password-to-boot-entries-generated-b.patch -Patch0047: 0047-Don-t-emit-Booting-.-message.patch -Patch0048: 0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch -Patch0049: 0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch -Patch0050: 0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch -Patch0051: 0051-Fix-convert-function-to-support-NVMe-devices.patch -Patch0052: 0052-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch -Patch0053: 0053-Use-the-default-device-tree-from-the-grub-default-fi.patch -Patch0054: 0054-reopen-SNP-protocol-for-exclusive-use-by-grub.patch -Patch0055: 0055-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch -Patch0056: 0056-Add-grub_util_readlink.patch -Patch0057: 0057-Make-editenv-chase-symlinks-including-those-across-d.patch -Patch0058: 0058-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch -Patch0059: 0059-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch -Patch0060: 0060-Load-arm-with-SB-enabled.patch -Patch0061: 0061-Try-prefix-if-fw_path-doesn-t-work.patch -Patch0062: 0062-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch -Patch0063: 0063-Make-grub2-mkconfig-construct-titles-that-look-like-.patch -Patch0064: 0064-Update-info-with-grub.cfg-netboot-selection-order-11.patch -Patch0065: 0065-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch -Patch0066: 0066-Add-friendly-grub2-password-config-tool-985962.patch -Patch0067: 0067-Fix-race-in-EFI-validation.patch -Patch0068: 0068-ppc64le-sync-mkconfig-to-disk-1212114.patch -Patch0069: 0069-Use-device-part-of-chainloader-target-if-present.patch -Patch0070: 0070-Add-secureboot-support-on-efi-chainloader.patch -Patch0071: 0071-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch -Patch0072: 0072-Fix-security-issue-when-reading-username-and-passwor.patch -Patch0073: 0073-Make-grub_fatal-also-backtrace.patch -Patch0074: 0074-Rework-linux-command.patch -Patch0075: 0075-Rework-linux16-command.patch -Patch0076: 0076-Make-grub-editenv-build-again.patch -Patch0077: 0077-Fix-locale-issue-in-grub-setpassword-1294243.patch -Patch0078: 0078-Fix-up-some-man-pages-rpmdiff-noticed.patch -Patch0079: 0079-Handle-rssd-storage-devices.patch -Patch0080: 0080-Warn-if-grub-password-will-not-be-read-1290803.patch -Patch0081: 0081-Clean-up-grub-setpassword-documentation-1290799.patch -Patch0082: 0082-Re-work-some-intricacies-of-PE-loading.patch -Patch0083: 0083-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch -Patch0084: 0084-linuxefi-fix-double-free-on-verification-failure.patch -Patch0085: 0085-fix-machine-type-test-in-30_os-prober.in.patch -Patch0086: 0086-ppc64le-has-no-separate-boot-mount-1261926.patch -Patch0087: 0087-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch -Patch0088: 0088-Normalize-slashes-in-tftp-paths.patch -Patch0089: 0089-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch -Patch0090: 0090-efi-chainloader-truncate-overlong-relocation-section.patch -Patch0091: 0091-Fix-malformed-tftp-packets.patch -Patch0092: 0092-bz1374141-fix-incorrect-mask-for-ppc64.patch -Patch0093: 0093-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch -Patch0094: 0094-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch -Patch0095: 0095-Fix-a-btrfs-read-before-init-bug.patch -Patch0096: 0096-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch -Patch0097: 0097-don-t-ignore-const.patch -Patch0098: 0098-don-t-use-int-for-efi-status.patch -Patch0099: 0099-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch -Patch0100: 0100-Add-some-grub_dprintf-in-the-linuxefi-path.patch -Patch0101: 0101-linuxefi-minor-cleanups.patch -Patch0102: 0102-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch -Patch0103: 0103-Clean-up-some-errors-in-the-linuxefi-loader.patch -Patch0104: 0104-Fix-up-linux-params-usage.patch -Patch0105: 0105-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch +Patch0001: 0001-NEWS-update.patch +Patch0002: 0002-10_linux-Fix-grouping-of-tests-for-GRUB_DEVICE.patch +Patch0003: 0003-20_linux_xen-fix-test-for-GRUB_DEVICE.patch +Patch0004: 0004-multiboot2-Remove-useless-GRUB_PACKED.patch +Patch0005: 0005-xen_file-Fix-invalid-payload-size.patch +Patch0006: 0006-Failed-config-now-returns-exit-code-1252311.patch +Patch0007: 0007-Makefile.util.def-add-LIBINTL-to-grub-macbless-flags.patch +Patch0008: 0008-Remove-the-variable-oldname-which-is-attempting-to-f.patch +Patch0009: 0009-bootp-fix-memory-leak-in-grub_cmd_dhcpopt.patch +Patch0010: 0010-bootp-check-that-interface-is-not-NULL-in-configure_.patch +Patch0011: 0011-configure-set-fno-pie-together-with-fno-PIE.patch +Patch0012: 0012-http-fix-superfluous-null-line-in-range-request-head.patch +Patch0013: 0013-build-Use-AC_HEADER_MAJOR-to-find-device-macros.patch +Patch0014: 0014-http-reset-EOF-indication-in-http_seek.patch +Patch0015: 0015-net-reset-net-stall-in-grub_net_seek_real.patch +Patch0016: 0016-net-translate-pxe-prefix-to-tftp-when-checking-for-s.patch +Patch0017: 0017-IBM-client-architecture-CAS-reboot-support.patch +Patch0018: 0018-for-ppc-reset-console-display-attr-when-clear-screen.patch +Patch0019: 0019-Disable-GRUB-video-support-for-IBM-power-machines.patch +Patch0020: 0020-Fix-bzr-s-ignore-artificats-in-.gitignore.patch +Patch0021: 0021-Honor-a-symlink-when-generating-configuration-by-gru.patch +Patch0022: 0022-Move-bash-completion-script-922997.patch +Patch0023: 0023-Update-to-minilzo-2.08.patch +Patch0024: 0024-Add-vlan-tag-support-on-IBM-PPC-machines.patch +Patch0025: 0025-Allow-fallback-to-include-entries-by-title-not-just-.patch +Patch0026: 0026-Add-GRUB_DISABLE_UUID.patch +Patch0027: 0027-Make-exit-take-a-return-code.patch +Patch0028: 0028-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch +Patch0029: 0029-Make-efi-machines-load-an-env-block-from-a-variable.patch +Patch0030: 0030-DHCP-client-ID-and-UUID-options-added.patch +Patch0031: 0031-trim-arp-packets-with-abnormal-size.patch +Patch0032: 0032-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch +Patch0033: 0033-Add-support-for-UEFI-operating-systems-returned-by-o.patch +Patch0034: 0034-Migrate-PPC-from-Yaboot-to-Grub2.patch +Patch0035: 0035-Add-fw_path-variable-revised.patch +Patch0036: 0036-Add-support-for-linuxefi.patch +Patch0037: 0037-Use-linuxefi-and-initrdefi-where-appropriate.patch +Patch0038: 0038-Don-t-allow-insmod-when-secure-boot-is-enabled.patch +Patch0039: 0039-Pass-x-hex-hex-straight-through-unmolested.patch +Patch0040: 0040-Add-X-option-to-printf-functions.patch +Patch0041: 0041-Search-for-specific-config-file-for-netboot.patch +Patch0042: 0042-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +Patch0043: 0043-Don-t-write-messages-to-the-screen.patch +Patch0044: 0044-Don-t-print-GNU-GRUB-header.patch +Patch0045: 0045-Don-t-add-to-highlighted-row.patch +Patch0046: 0046-Message-string-cleanups.patch +Patch0047: 0047-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch +Patch0048: 0048-Use-the-correct-indentation-for-the-term-help-text.patch +Patch0049: 0049-Indent-menu-entries.patch +Patch0050: 0050-Fix-margins.patch +Patch0051: 0051-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch +Patch0052: 0052-Use-linux16-when-appropriate-880840.patch +Patch0053: 0053-Enable-pager-by-default.-985860.patch +Patch0054: 0054-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch +Patch0055: 0055-Don-t-say-GNU-Linux-in-generated-menus.patch +Patch0056: 0056-Don-t-draw-a-border-around-the-menu.patch +Patch0057: 0057-Use-the-standard-margin-for-the-timeout-string.patch +Patch0058: 0058-Add-.eh_frame-to-list-of-relocations-stripped.patch +Patch0059: 0059-Make-10_linux-work-with-our-changes-for-linux16-and-.patch +Patch0060: 0060-Don-t-print-during-fdt-loading-method.patch +Patch0061: 0061-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch +Patch0062: 0062-Don-t-require-a-password-to-boot-entries-generated-b.patch +Patch0063: 0063-Don-t-emit-Booting-.-message.patch +Patch0064: 0064-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch +Patch0065: 0065-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +Patch0066: 0066-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +Patch0067: 0067-Fix-convert-function-to-support-NVMe-devices.patch +Patch0068: 0068-Switch-to-use-APM-Mustang-device-tree-for-hardware-t.patch +Patch0069: 0069-Use-the-default-device-tree-from-the-grub-default-fi.patch +Patch0070: 0070-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +Patch0071: 0071-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +Patch0072: 0072-Add-grub_util_readlink.patch +Patch0073: 0073-Make-editenv-chase-symlinks-including-those-across-d.patch +Patch0074: 0074-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch +Patch0075: 0075-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch +Patch0076: 0076-Load-arm-with-SB-enabled.patch +Patch0077: 0077-Try-prefix-if-fw_path-doesn-t-work.patch +Patch0078: 0078-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch +Patch0079: 0079-Make-grub2-mkconfig-construct-titles-that-look-like-.patch +Patch0080: 0080-Update-info-with-grub.cfg-netboot-selection-order-11.patch +Patch0081: 0081-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch +Patch0082: 0082-Add-friendly-grub2-password-config-tool-985962.patch +Patch0083: 0083-Fix-race-in-EFI-validation.patch +Patch0084: 0084-ppc64le-sync-mkconfig-to-disk-1212114.patch +Patch0085: 0085-Use-device-part-of-chainloader-target-if-present.patch +Patch0086: 0086-Add-secureboot-support-on-efi-chainloader.patch +Patch0087: 0087-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch +Patch0088: 0088-Fix-security-issue-when-reading-username-and-passwor.patch +Patch0089: 0089-Make-grub_fatal-also-backtrace.patch +Patch0090: 0090-Rework-linux-command.patch +Patch0091: 0091-Rework-linux16-command.patch +Patch0092: 0092-Make-grub-editenv-build-again.patch +Patch0093: 0093-Fix-locale-issue-in-grub-setpassword-1294243.patch +Patch0094: 0094-Fix-up-some-man-pages-rpmdiff-noticed.patch +Patch0095: 0095-Handle-rssd-storage-devices.patch +Patch0096: 0096-Warn-if-grub-password-will-not-be-read-1290803.patch +Patch0097: 0097-Clean-up-grub-setpassword-documentation-1290799.patch +Patch0098: 0098-Re-work-some-intricacies-of-PE-loading.patch +Patch0099: 0099-Rework-even-more-of-efi-chainload-so-non-sb-cases-wo.patch +Patch0100: 0100-linuxefi-fix-double-free-on-verification-failure.patch +Patch0101: 0101-fix-machine-type-test-in-30_os-prober.in.patch +Patch0102: 0102-ppc64le-has-no-separate-boot-mount-1261926.patch +Patch0103: 0103-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +Patch0104: 0104-Normalize-slashes-in-tftp-paths.patch +Patch0105: 0105-efi-chainloader-fix-wrong-sanity-check-in-relocate_c.patch +Patch0106: 0106-efi-chainloader-truncate-overlong-relocation-section.patch +Patch0107: 0107-Fix-malformed-tftp-packets.patch +Patch0108: 0108-bz1374141-fix-incorrect-mask-for-ppc64.patch +Patch0109: 0109-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch +Patch0110: 0110-Work-around-autoconf-2.69-having-a-terrible-AC_HEADE.patch +Patch0111: 0111-Fix-a-btrfs-read-before-init-bug.patch +Patch0112: 0112-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch +Patch0113: 0113-don-t-ignore-const.patch +Patch0114: 0114-don-t-use-int-for-efi-status.patch +Patch0115: 0115-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch +Patch0116: 0116-Add-some-grub_dprintf-in-the-linuxefi-path.patch +Patch0117: 0117-linuxefi-minor-cleanups.patch +Patch0118: 0118-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch +Patch0119: 0119-Clean-up-some-errors-in-the-linuxefi-loader.patch +Patch0120: 0120-Fix-up-linux-params-usage.patch +Patch0121: 0121-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch +Patch0122: 0122-tsc-Change-default-tsc-calibration-method-to-pmtimer.patch +Patch0123: 0123-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch diff --git a/grub2.spec b/grub2.spec index 87e6cea..438bc1a 100644 --- a/grub2.spec +++ b/grub2.spec @@ -45,7 +45,7 @@ Name: grub2 Epoch: 1 Version: 2.02 -Release: 0.42%{?dist} +Release: 0.43%{?dist} Summary: Bootloader with support for Linux, Multiboot and more Group: System Environment/Base @@ -546,6 +546,10 @@ fi %{_datarootdir}/grub/themes/starfield %changelog +* Wed Jan 17 2018 Peter Jones - 2.02-0.43 +- Pull in patches for Apollo Lake hardware + Resolves: rhbz#1519311 + * Thu Aug 03 2017 Peter Jones - 2.02-0.42 - Rebuild this so it gets SB signed correctly. Related: rhbz#1335533