Commit Graph

153 Commits

Author SHA1 Message Date
Vladimir Serbinenko 064360e667 Remove libgcc dependency.
libgcc for boot environment isn't always present and compatible.
libgcc is often absent if endianness or bit-size at boot is different
from running OS.
libgcc may use optimised opcodes that aren't available on boot time.
So instead of relying on libgcc shipped with the compiler, supply
the functions in GRUB directly.
Tests are present to ensure that those replacement functions behave the
way compiler expects them to.
2015-03-03 20:50:37 +01:00
Vladimir Serbinenko f034fab620 Supply signed division to fix ARM compilation.
Previously we supplied only unsigned divisions on platforms that need software
division.
Yet compiler may itself use a signed division. A typical example would be a
difference between 2 pointers which involves division by object size.
2015-02-23 04:12:04 +01:00
Vladimir Serbinenko aee2502cb5 Provide __aeabi_mem{cpy,set}
Fixes ARM compilation
2015-02-21 16:07:59 +01:00
Vladimir Serbinenko e360b5d176 * include/grub/misc.h (grub_div_roundup): Remove as it's unused. 2015-01-21 17:42:14 +01:00
Andrey Borzenkov f371dd5da8 fix include loop on MinGW due to libintl.h pulling stdio.h
In file included from ./include/grub/dl.h:23:0,
                 from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3:
./include/grub/list.h:34:18: warning: conflicting types for 'grub_list_push' [en
abled by default]
 void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
                  ^
./include/grub/symbol.h:68:25: note: in definition of macro 'EXPORT_FUNC'
 # define EXPORT_FUNC(x) x
                         ^
In file included from ./include/grub/fs.h:30:0,
                 from ./include/grub/file.h:25,
                 from ./grub-core/lib/posix_wrap/stdio.h:23,
                 from c:\mingw\include\libintl.h:314,
                 from ./include/grub/i18n.h:33,
                 from ./include/grub/misc.h:27,
                 from ./include/grub/list.h:25,
                 from ./include/grub/dl.h:28,
                 from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3:
./include/grub/partition.h:106:3: note: previous implicit declaration of 'grub_l
ist_push' was here
   grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
   ^
list.h needs just ATTRIBUTE_ERROR from misc.h; split compiler features
into separate file grub/compiler.h and include it instead.
2014-01-18 21:22:57 +04:00
Vladimir Serbinenko 0d4aa91d0d * include/grub/misc.h (grub_strtol): Fix overflow. 2013-12-21 14:35:46 +01:00
Vladimir Serbinenko eba2afeda1 Add __attribute__ ((sysv_abi)) only if it's really needed.
Some compilers don't support it.
2013-12-18 13:09:39 +01:00
Vladimir Serbinenko 252a289cb3 Determine the need for mingw-related stubs at compile time rather than
using not very significant $target_os.
2013-12-16 14:18:15 +01:00
Vladimir Serbinenko d5c14e1e26 Fix mips-emu compilation. 2013-12-08 17:49:02 +01:00
Vladimir Serbinenko 4a0aaad022 clang emits calls to abort () under some unknown conditions.
Export abort () when compiling with clang.
2013-11-22 12:42:58 +01:00
Vladimir Serbinenko 8df6eff6da * include/grub/misc.h: Replace check for __sparc64__ with one for
__sparc__ as __sparc64__ isn't actually defined.
2013-11-17 01:01:47 +01:00
Vladimir Serbinenko 6fcec43954 Replace libgcc version of ctz with our own.
On upcoming arm64 port libgcc ctz* are not usable in standalone
	environment. Since we need ctz* for this case and implementation is
	in C we may as well use it on all concerned platforms.
2013-11-15 03:28:34 +01:00
Colin Watson 81a2e438dc * grub-core/kern/misc.c: Don't redirect divisions in the
GRUB_UTIL case.
* include/grub/misc.h: Likewise.
2013-11-13 14:47:23 +00:00
Vladimir Serbinenko 5e77d9cfc1 * grub-core/kern/arm/misc.S: Add __muldi3 and __aeabi_lmul. Those
helper functions are needed for thumb.
2013-11-13 09:52:33 +01:00
Vladimir Serbinenko 16057d6bbb Redirect all divisions to grub_divmod64. 2013-11-13 00:53:53 +01:00
Vladimir Serbinenko 8506a64149 * include/grub/misc.h [__APPLE__]: Do not add regparm(0) on x86_64.
* grub-core/kern/misc.c (__bzero) [__APPLE__]: New function.
2013-11-11 22:53:30 +01:00
Vladimir Serbinenko e6c368d468 * include/grub/misc.h (grub_dprintf): Use unnamed vararg.
(grub_boot_time): Likewise.
2013-11-07 01:23:06 +01:00
Vladimir Serbinenko eb03ede014 * grub-core/fs/ext2.c (grub_ext2_read_symlink): Use memcpy rather
strncpy.
	* grub-core/fs/jfs.c (grub_jfs_lookup_symlink): Likewise.
	* grub-core/kern/misc.c (grub_strncpy): Move from here ...
	* include/grub/misc.h (grub_strncpy): ... to here. Make inline.
	* grub-core/net/net.c (grub_net_addr_to_str): Use COMPILE_TIME_ASSERT
	+ strcpy rather than strncpy.
2013-11-01 18:44:46 +01:00
Vladimir Serbinenko e54b8f536b * include/grub/misc.h (grub_strcat): Removed. All users changed to
more appropriate functions.
2013-11-01 16:27:37 +01:00
Vladimir Serbinenko a8f15bceea * grub-core/kern/misc.c (grub_abort): Make static 2013-10-27 14:13:39 +01:00
Vladimir Serbinenko 2a8a75855c * grub-core/fs/iso9660.c: Replace strncat with memcpy.
* include/grub/misc.h: Remove strncat.
	* grub-core/lib/posix_wrap/string.h: Likewise.
2013-10-26 12:49:51 +02:00
Vladimir 'phcoder' Serbinenko 00f72e890b * grub-core/kern/misc.c (grub_isprint): Move to ...
* include/grub/misc.h (grub_isprint): ... here. Make inline.

	Saves 20 bytes on compressed image due to remving exporting.
2013-10-21 13:25:56 +02:00
Vladimir 'phcoder' Serbinenko fb320faf88 * include/grub/misc.h: Don't use warn_unused_result on gcc < 3.4.
* include/grub/emu/misc.h: Likewise.
2013-10-18 16:34:18 +02:00
Vladimir 'phcoder' Serbinenko ee8c1b295a * include/grub/misc.h: Use gnu_printf only on gcc 4.4 or later. 2013-10-13 21:17:54 +02:00
Vladimir 'phcoder' Serbinenko eac6ae822c * include/grub/misc.h: Use gnu_printf rather than printf as format
template since our functions are independent of libc.
2013-10-12 07:49:36 +02:00
Vladimir 'phcoder' Serbinenko 1eed0e6ebc * tests/priority_queue_unit_test.cc: New test. 2013-05-07 11:30:48 +02:00
Vladimir 'phcoder' Serbinenko a6393224c4 Make 'make check' work on emu. 2013-04-27 02:00:16 +02:00
Vladimir 'phcoder' Serbinenko 0467a5ddf0 Move GRUB_CHAR_BIT to types.h. 2013-04-05 10:31:12 +02:00
Vladimir 'phcoder' Serbinenko 1a78d573c7 * grub-core/commands/verify.c: Save verified file to avoid it being
tampered with after verification was done.
2013-04-03 17:32:33 +02:00
Vladimir Testov c3578acfbb * grub-core/gfxmenu/gui_circular_progress.c: Take both width and height
into account when calculating radius.
2013-04-03 09:20:29 +02:00
Vladimir 'phcoder' Serbinenko e744219bb6 Implement boot time analysis framework. 2013-03-19 20:25:09 +01:00
Vladimir 'phcoder' Serbinenko 19ce697dfd Remove all trampoline support. Add -Wtrampolines when
present. Remove symbols used for trampolines to make
	link fail if trampolines are present.
2013-03-03 15:57:30 +01:00
Vladimir 'phcoder' Serbinenko 4a5a3c4abc * include/grub/list.h (grub_bad_type_cast_real): Remove return.
* include/grub/misc.h (ATTRIBUTE_ERROR): Make into noreturn attribute
	on older compiler.
2012-05-28 17:45:53 +02:00
Vladimir 'phcoder' Serbinenko f7194551c4 * include/grub/misc.h (memcmp) [__APPLE__]: Mark as regparm 0.
(memmove) [__APPLE__]: Likewise.
	(memcpy) [__APPLE__]: Likewise.
	(memset) [__APPLE__]: Likewise.
	* grub-core/kern/misc.c (memcmp) [__APPLE__]: Likewise.
	(memmove) [__APPLE__]: Likewise.
	(memcpy) [__APPLE__]: Likewise.
	(memset) [__APPLE__]: Likewise.
2012-05-28 17:37:18 +02:00
Vladimir 'phcoder' Serbinenko ce41ab7aab * grub-core/kern/misc.c (grub_strcmp): Use unsigned comparison as
per common usage and preffered in several parts of code.
	(grub_memcmp): Likewise.
	(grub_strncmp): Likewise.
	* include/grub/misc.h (grub_strcasecmp): Likewise.
	(grub_strncasecmp): Likewise.
	* Makefile.util.def (cmp_test): New test.
	(grub_script_strcmp): Likewise.
	* tests/cmp_unit_test.c: New file.
	* tests/grub_script_strcmp.in: Likewise.
	* grub-core/fs/hfsplus.c (grub_hfsplus_cmp_catkey): Add a comment.
2012-05-04 12:08:22 +02:00
Vladimir 'phcoder' Serbinenko 1a2fd1e674 * include/grub/misc.h (ALIGN_UP_OVERHEAD): New define.
* grub-core/loader/i386/linux.c (grub_cmd_initrd): Align initrds at 4.
	* grub-core/loader/i386/pc/linux.c (grub_cmd_initrd): Likewise.
	* grub-core/loader/ia64/efi/linux.c (grub_cmd_initrd): Likewise.
	* grub-core/loader/mips/linux.c (grub_cmd_initrd): Likewise.
	* grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_initrd): Likewise.
	* grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_initrd): Likewise.
2012-03-05 01:17:55 +01:00
Vladimir 'phcoder' Serbinenko 10133b5ff3 * grub-core/kern/misc.c (grub_stpcpy): Move from here ...
* include/grub/misc.h (grub_stpcpy): ... to here. Inlined.
2012-02-26 23:55:18 +01:00
Vladimir 'phcoder' Serbinenko f991dd3c32 * include/grub/misc.h (grub_error_save): Fix cleaning grub_errno. 2012-02-12 17:21:09 +01:00
Vladimir 'phcoder' Serbinenko d61386e21d Improve string. Gettextize. 2012-02-12 15:25:25 +01:00
Vladimir 'phcoder' Serbinenko 44318d6168 * include/grub/misc.h: Avoid evaluationg NEED_ENABLE_EXECUTE_STACK and
NEED_REGISTER_FRAME_INFO in GRUB_UTIL.
2012-02-10 12:45:32 +01:00
Vladimir 'phcoder' Serbinenko 9c4b5c13e6 Improve gettext support. Stylistic fixes and error handling fixes while
on it.
2012-02-08 19:26:01 +01:00
Vladimir 'phcoder' Serbinenko aca002f7e4 * grub-core/kern/err.c (GRUB_MAX_ERRMSG): Move to ...
* include/grub/err.h (GRUB_MAX_ERRMSG): ... here.
	* include/grub/err.h (grub_error_saved): New struct.
	(grub_errmsg): Make array size explicit.
	* include/grub/misc.h (grub_error_save): New function.
	(grub_error_load): Likewise.
	* grub-core/kern/err.c (grub_error_stack_items): Use grub_error_saved.
	(grub_error_push): Update `errno' member name.
	(grub_error_pop): Likewise
	* grub-core/net/tftp.c (tftp_data): New member save_err.
	(tftp_receive): Save error.
	(tftp_open): Restore error.
2012-02-05 10:24:53 +01:00
Vladimir 'phcoder' Serbinenko 9c2710789f Eliminate grub_min/grub_max prone to overflow usage.
* grub-core/bus/usb/usbhub.c (grub_usb_add_hub): Eliminate grub_min.
	(poll_nonroot_hub): Likewise.
	* grub-core/fs/affs.c (grub_affs_iterate_dir): Likewise.
	(grub_affs_label): Likewise.
	* grub-core/fs/btrfs.c (grub_btrfs_lzo_decompress): Likewise.
	* grub-core/fs/hfs.c (grub_hfs_dir): Likewise.
	(grub_hfs_label): Likewise.
	* grub-core/fs/hfsplus.c (grub_hfsplus_cmp_catkey): Likewise.
	* grub-core/fs/zfs/zfs.c (MIN): Remove.
	(zap_leaf_array_equal): Use grub_size. Remove MIN.
	(zap_leaf_array_get): Likewise.
	(dnode_get_path): Likewise.
	* grub-core/io/lzopio.c (grub_lzopio_read): Eliminate grub_min.
	* grub-core/io/xzio.c (grub_xzio_read): Likewise.
	* grub-core/script/execute.c (grub_script_break): Likewise.
	* grub-core/script/lexer.c (grub_script_lexer_record): Eliminate
	grub_max.
	* grub-core/script/yylex.l (grub_lexer_yyrealloc): Likewise.
	* include/grub/misc.h (grub_min): Removed.
	(grub_max): Likewise.
2012-01-14 15:44:34 +01:00
Vladimir 'phcoder' Serbinenko bd67ad0f70 merge mainline into net 2011-12-15 20:51:35 +01:00
Vladimir 'phcoder' Serbinenko 0d51ee20ee * include/grub/emu/misc.h (xasprintf): Add missing format attribute.
* include/grub/mips/kernel.h (grub_halt): Remove redundant declaration.
	* include/grub/mips/qemu_mips/kernel.h (grub_halt): Likewise.
	* include/grub/misc.h (grub_reboot)
	[GRUB_MACHINE_EMU || GRUB_MACHINE_QEMU_MIPS]: Export.
	(grub_halt) [__mips__]: Likewise.
2011-12-13 14:51:41 +01:00
Vladimir 'phcoder' Serbinenko c5fc563aff Enable UTF8 in gnulib regexp.
* config.h.in (RE_ENABLE_I18N) [!GRUB_UTIL]: New define.
	* grub-core/lib/posix_wrap/ctype.h (islower): Use grub_islower.
	(isupper): Use grub_isupper.
	(isascii): New inline function.
	* grub-core/lib/posix_wrap/wchar.h: Replace dummy with real contents.
	* grub-core/lib/posix_wrap/wctype.h: Likewise.
	* grub-core/normal/charset.c (grub_utf8_process): New function.
	(grub_utf8_to_utf16): Use grub_utf8_process.
	(grub_encode_utf8_character): New function.
	(grub_ucs4_to_utf8): Use grub_encode_utf8_character.
	* include/grub/charset.h (grub_utf8_process): New declaration.
	(grub_encode_utf8_character): Likewise.
	* include/grub/misc.h (grub_islower): New inline function.
	(grub_isupper): Likewise.
	(grub_strchrsub): Moved down to fix the definitions.
2011-12-13 00:50:49 +01:00
Vladimir 'phcoder' Serbinenko 067fdf0055 * grub-core/kern/misc.c (grub_strstr): Moved from here ...
* include/grub/misc.h (grub_strstr): ... here. Make static and inline.
2011-11-11 20:02:51 +01:00
Vladimir 'phcoder' Serbinenko 57b0125004 * include/grub/misc.h (grub_strncat): Fix the order of conditionals to
avoid accessing beyond the array.
2011-11-09 14:47:45 +01:00
Vladimir 'phcoder' Serbinenko 4e94ae6575 * include/grub/misc.h (grub_memcpy): Declare grub_memcpy with static
inline function rather than a define.
2011-10-23 23:25:06 +02:00
Vladimir 'phcoder' Serbinenko 544c24876e Move grub_reboot out of the kernel.
* grub-core/Makefile.core.def (reboot): Add platform-specific files.
	* grub-core/kern/efi/efi.c (grub_reboot): Moved to ...
	* grub-core/lib/efi/reboot.c: ... here.
	* grub-core/kern/i386/efi/startup.S: Remove including of realmode.S.
	* grub-core/kern/i386/ieee1275/startup.S: Likewise.
	* grub-core/kern/i386/pc/startup.S (grub_exit): Inline cold_reboot.
	* grub-core/kern/i386/realmode.S (grub_reboot): Moved to...
	* grub-core/lib/i386/reboot_trampoline.S: ... here.
	* grub-core/kern/ieee1275/openfw.c (grub_reboot): Moved to...
	* grub-core/lib/ieee1275/reboot.c: ... here.
	* grub-core/kern/mips/arc/init.c (grub_reboot): Moved to...
	* grub-core/lib/mips/arc/reboot.c: ... here.
	* grub-core/kern/mips/loongson/init.c (grub_reboot): Moved to...
	* grub-core/lib/mips/loongson/reboot.c: ...here.
	* grub-core/kern/mips/qemu_mips/init.c (grub_reboot): Moved to...
	* grub-core/lib/mips/qemu_mips/reboot.c: ... here.
	* include/grub/emu/misc.h (grub_reboot): New function declaration.
	* include/grub/i386/reboot.h: New file.
	* include/grub/mips/loongson/ec.h: Fix includes.
	* include/grub/mips/qemu_mips/kernel.h (grub_reboot): Removed.
	* include/grub/misc.h (grub_reboot): Don't mark as kernel function.
	* grub-core/lib/i386/reboot.c: New file.
2011-10-19 16:53:18 +02:00