merge mainline into arm

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-05-11 10:24:24 +02:00
commit 8e71d87482
490 changed files with 29659 additions and 8612 deletions

View file

@ -151,6 +151,7 @@ endif
if COND_mips_arc
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
endif
if COND_mips_qemu_mips
@ -159,6 +160,7 @@ KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap_scale.h
@ -177,6 +179,7 @@ KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/time.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap_scale.h
@ -228,6 +231,7 @@ if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/export.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
if COND_GRUB_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
endif

View file

@ -30,6 +30,20 @@ script = {
common = gdb_grub.in;
};
script = {
installdir = platform;
name = grub.chrp;
common = boot/powerpc/grub.chrp.in;
enable = powerpc_ieee1275;
};
script = {
installdir = platform;
name = bootinfo.txt;
common = boot/powerpc/bootinfo.txt.in;
enable = powerpc_ieee1275;
};
kernel = {
name = kernel;
@ -62,9 +76,10 @@ kernel = {
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
mips_arc_ldflags = '-Wl,-Ttext,0x8bd00000';
mips_arc_ldflags = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK';
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
emu_cflags = '$(CFLAGS_GNULIB)';
@ -132,7 +147,9 @@ kernel = {
i386 = kern/i386/dl.c;
i386_coreboot_multiboot_qemu = kern/i386/coreboot/init.c;
i386_coreboot = kern/i386/coreboot/init.c;
i386_multiboot = kern/i386/coreboot/init.c;
i386_qemu = kern/i386/qemu/init.c;
i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c;
efi = disk/efi/efidisk.c;
@ -214,7 +231,7 @@ kernel = {
emu = disk/host.c;
emu = gnulib/progname.c;
emu = gnulib/error.c;
emu = kern/emu/error.c;
emu = kern/emu/cache_s.S;
emu = kern/emu/hostdisk.c;
emu = kern/emu/hostfs.c;
@ -254,9 +271,9 @@ program = {
emu = kern/emu/full.c;
emu_nodist = grub_emu_init.c;
ldadd = 'kernel.img$(EXEEXT)';
ldadd = 'kernel.exec$(EXEEXT)';
ldadd = '$(MODULE_FILES)';
ldadd = '$(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
ldadd = 'gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
enable = emu;
};
@ -267,8 +284,8 @@ program = {
emu = kern/emu/lite.c;
emu_nodist = symlist.c;
ldadd = 'kernel.img$(EXEEXT)';
ldadd = '$(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
ldadd = 'kernel.exec$(EXEEXT)';
ldadd = 'gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
enable = emu;
};
@ -295,12 +312,34 @@ image = {
enable = sparc64_ieee1275;
};
image = {
name = boot_hybrid;
i386_pc = boot/i386/pc/boot.S;
cppflags = '-DHYBRID_BOOT=1';
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
objcopyflags = '-O binary';
enable = i386_pc;
};
image = {
name = cdboot;
i386_pc = boot/i386/pc/cdboot.S;
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big';
sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000';
sparc64_ieee1275_cppflags = '-DCDBOOT=1';
objcopyflags = '-O binary';
enable = sparc64_ieee1275;
enable = i386_pc;
};
@ -354,9 +393,7 @@ image = {
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x8bc00000';
mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '-lgcc';
cflags = '-Wno-unreachable-code -static-libgcc';
enable = mips;
@ -370,9 +407,7 @@ image = {
cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x8bc00000';
mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '-lgcc';
cflags = '-static-libgcc';
enable = mips;
@ -469,7 +504,7 @@ module = {
module = {
name = uhci;
common = bus/usb/uhci.c;
enable = x86;
enable = pci;
};
module = {
@ -494,6 +529,15 @@ module = {
enable = i386_multiboot;
};
module = {
name = nativedisk;
common = commands/nativedisk.c;
enable = x86;
enable = mips_loongson;
enable = mips_qemu_mips;
};
module = {
name = emupci;
common = bus/emu/pci.c;
@ -1164,6 +1208,11 @@ module = {
common = fs/hfsplus.c;
};
module = {
name = hfspluscomp;
common = fs/hfspluscomp.c;
};
module = {
name = iso9660;
common = fs/iso9660.c;
@ -1339,6 +1388,8 @@ module = {
module = {
name = elf;
common = kern/elf.c;
extra_dist = kern/elfXX.c;
};
module = {
@ -1652,10 +1703,12 @@ module = {
common = term/serial.c;
x86 = term/ns8250.c;
ieee1275 = term/ieee1275/serial.c;
mips_arc = term/arc/serial.c;
efi = term/efi/serial.c;
enable = terminfomodule;
enable = ieee1275;
enable = mips_arc;
};
module = {
@ -1712,6 +1765,10 @@ module = {
name = functional_test;
common = tests/lib/functional_test.c;
common = tests/lib/test.c;
common = tests/checksums.h;
common = tests/video_checksum.c;
common = tests/fake_input.c;
common = video/capture.c;
};
module = {
@ -1719,6 +1776,26 @@ module = {
common = tests/example_functional_test.c;
};
module = {
name = setjmp_test;
common = tests/setjmp_test.c;
};
module = {
name = videotest_checksum;
common = tests/videotest_checksum.c;
};
module = {
name = gfxterm_menu;
common = tests/gfxterm_menu.c;
};
module = {
name = cmdline_cat_test;
common = tests/cmdline_cat_test.c;
};
module = {
name = bitmap;
common = video/bitmap.c;
@ -1787,6 +1864,12 @@ module = {
enable = powerpc_ieee1275;
};
module = {
name = coreboot_fb;
common = video/i386/coreboot/cbfb.c;
enable = i386_coreboot;
};
module = {
name = sdl;
emu = video/emu/sdl.c;
@ -1853,7 +1936,12 @@ module = {
common = commands/legacycfg.c;
common = lib/legacy_parse.c;
emu = lib/i386/pc/vesa_modes_table.c;
i386_efi = lib/i386/pc/vesa_modes_table.c;
x86_64_efi = lib/i386/pc/vesa_modes_table.c;
enable = i386_pc;
enable = i386_efi;
enable = x86_64_efi;
enable = emu;
};
@ -1981,3 +2069,7 @@ module = {
enable = i386;
};
module = {
name = testspeed;
common = commands/testspeed.c;
};

View file

@ -28,6 +28,81 @@
#define MSG(x) movw $x, %si; call LOCAL(message)
#define ERR(x) movw $x, %si; jmp LOCAL(error_message)
.macro floppy
part_start:
probe_values:
.byte 36, 18, 15, 9, 0
LOCAL(floppy_probe):
/*
* Perform floppy probe.
*/
movw $probe_values - 1, %si
LOCAL(probe_loop):
/* reset floppy controller INT 13h AH=0 */
xorw %ax, %ax
int $0x13
incw %si
movb (%si), %cl
/* if number of sectors is 0, display error and die */
cmpb $0, %cl
jne 1f
/*
* Floppy disk probe failure.
*/
MSG(fd_probe_error_string)
jmp LOCAL(general_error)
/* "Floppy" */
fd_probe_error_string: .asciz "Floppy"
1:
/* perform read */
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
movw %bx, %es
xorw %bx, %bx
movw $0x201, %ax
movb $0, %ch
movb $0, %dh
int $0x13
/* if error, jump to "LOCAL(probe_loop)" */
jc LOCAL(probe_loop)
/* %cl is already the correct value! */
movb $1, %dh
movb $79, %ch
jmp LOCAL(final_init)
.endm
.macro scratch
/* scratch space */
mode:
.byte 0
disk_address_packet:
sectors:
.long 0
heads:
.long 0
cylinders:
.word 0
sector_start:
.byte 0
head_start:
.byte 0
cylinder_start:
.word 0
/* more space... */
.endm
.file "boot.S"
.text
@ -51,6 +126,34 @@ start:
jmp LOCAL(after_BPB)
nop /* do I care about this ??? */
#ifdef HYBRID_BOOT
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
jmp LOCAL(after_BPB)
#else
/*
* This space is for the BIOS parameter block!!!! Don't change
* the first jump, nor start the code anywhere but right after
@ -59,27 +162,14 @@ start:
. = _start + GRUB_BOOT_MACHINE_BPB_START
. = _start + 4
/* scratch space */
mode:
.byte 0
disk_address_packet:
sectors:
.long 0
heads:
.long 0
cylinders:
.word 0
sector_start:
.byte 0
head_start:
.byte 0
cylinder_start:
.word 0
/* more space... */
#endif
#ifdef HYBRID_BOOT
floppy
#else
scratch
#endif
. = _start + GRUB_BOOT_MACHINE_BPB_END
/*
* End of BIOS parameter block.
*/
@ -87,9 +177,11 @@ cylinder_start:
kernel_address:
.word GRUB_BOOT_MACHINE_KERNEL_ADDR
#ifndef HYBRID_BOOT
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
kernel_sector:
.long 1, 0
#endif
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
boot_drive:
@ -410,6 +502,11 @@ LOCAL(message):
* number here.
*/
#ifdef HYBRID_BOOT
. = _start + 0x1b0
kernel_sector:
.long 1, 0
#endif
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic:
.long 0
@ -419,62 +516,17 @@ nt_magic:
* This is where an MBR would go if on a hard disk. The code
* here isn't even referenced unless we're on a floppy. Kinda
* sneaky, huh?
*/
*/
. = _start + GRUB_BOOT_MACHINE_PART_START
part_start:
probe_values:
.byte 36, 18, 15, 9, 0
LOCAL(floppy_probe):
/*
* Perform floppy probe.
*/
movw $probe_values - 1, %si
LOCAL(probe_loop):
/* reset floppy controller INT 13h AH=0 */
xorw %ax, %ax
int $0x13
incw %si
movb (%si), %cl
/* if number of sectors is 0, display error and die */
cmpb $0, %cl
jne 1f
/*
* Floppy disk probe failure.
*/
MSG(fd_probe_error_string)
jmp LOCAL(general_error)
/* "Floppy" */
fd_probe_error_string: .asciz "Floppy"
1:
/* perform read */
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
movw %bx, %es
xorw %bx, %bx
movw $0x201, %ax
movb $0, %ch
movb $0, %dh
int $0x13
/* if error, jump to "LOCAL(probe_loop)" */
jc LOCAL(probe_loop)
/* %cl is already the correct value! */
movb $1, %dh
movb $79, %ch
jmp LOCAL(final_init)
#ifndef HYBRID_BOOT
floppy
#else
scratch
#endif
. = _start + GRUB_BOOT_MACHINE_PART_END
/* the last 2 bytes in the sector 0 contain the signature */
.word GRUB_BOOT_MACHINE_SIGNATURE

View file

@ -93,11 +93,12 @@ LOCAL(read_cdrom):
pushw $CDBLK_LENG
/* Block number. */
incl %esi
pushl %eax
pushl %esi
/* Buffer address. */
pushw $((DATA_ADDR - 0x400)>> 4)
pushw $((DATA_ADDR - 0x200)>> 4)
pushl %eax
pushw $0x10
@ -167,6 +168,6 @@ err_noboot_msg:
err_cdfail_msg:
.ascii "cdrom read fails\0"
. = start + 0x1FF
. = start + 0x7FF
.byte 0

View file

@ -196,6 +196,21 @@ do_check:
argfw:
not $s7, $a2
cmdlinedone:
#endif
#ifdef GRUB_MACHINE_ARC
lui $t0, %hi(_start - 256)
addiu $t0, $t0, %lo(_start - 256)
addiu $t3, $t0, 255
lw $t1, 0($a1)
1:
bne $t0, $t3, 2f
lb $t2, 0($t1)
move $t2, $zero
2:
sb $t2, 0($t0)
addiu $t0, $t0, 1
bnez $t2, 1b
addiu $t1, $t1, 1
#endif
/* Copy the decompressor. */
lui $t1, %hi(base)
@ -253,10 +268,15 @@ cmdlinedone:
lui $t0, %hi(EXT_C(grub_decompress_core))
addiu $t0, $t0, %lo(EXT_C(grub_decompress_core))
#ifdef GRUB_MACHINE_ARC
lui $sp, %hi(_start - 512)
jalr $t0
addiu $sp, $sp, %lo(_start - 512)
#else
lui $sp, %hi(_start - 256)
jalr $t0
addiu $sp, $sp, %lo(_start - 256)
#endif
move $a0, $s1
move $a1, $s6

View file

@ -0,0 +1,73 @@
<chrp-boot>
<description>@PACKAGE@ @VERSION@</description>
<os-name>@PACKAGE@ @VERSION@</os-name>
<boot-script>boot &device;:\boot\grub\powerpc.elf</boot-script>
<icon size=64,64 color-space=3,3,2>
<bitmap>
FF FF FF FF FF FF FF FF FF FF 92 6D 6D 6D 6D 6D 6D 6D 6D 6D DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 92 6D 92 92 92 DB FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF DB 6D 92 DB FF FF FF FF FF DB B6 FF FF 92 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 DB FF FF FF FF FF B6 6D 92 DB FF FF FF FF FF FF FF
FF FF FF FF FF FF 49 92 FF FF B6 B6 24 00 24 00 00 00 00 49 6D DB 6D 92 DB B6 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 6D DB 92 6D 24 49 92 6D 6D FF FF FF 92 6D FF FF FF FF FF FF
FF FF FF FF B6 49 DB FF FF 24 00 00 00 92 92 B6 FF DB DB FF DB B6 FF DB 92 49 DB FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 6D B6 FF 6D B6 6D 6D 92 24 24 00 00 24 6D FF FF 49 DB FF FF FF FF
FF FF FF B6 49 FF DB 49 24 00 49 6D B6 FF B6 92 6D 6D 6D 92 DB DB DB B6 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D DB FF FF FF FF DB B6 B6 B6 FF DB 24 00 00 92 B6 FF 49 FF FF FF FF
FF FF DB 49 FF FF 49 00 00 24 FF FF 6D 49 92 DB FF FF FF DB 92 92 92 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 92 6D 6D B6 DB DB B6 6D 6D FF FF 24 00 00 DB FF 49 FF FF FF
FF FF 49 FF FF 49 00 00 6D DB DB 49 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 B6 24 00 24 DB DB 6D FF FF
FF B6 92 FF B6 00 00 24 FF DB 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 FF 00 00 49 FF 92 B6 FF
FF 6D FF FF 92 00 00 49 FF 6D FF FF FF FF FF FF FF FF FF FF FF FF FF B6 92 92 6D 6D 6D 6D DB FF FF FF FF FF FF B6 92 92 92 92 92 FF FF FF FF FF FF FF FF FF FF FF FF 6D FF 24 00 24 FF FF 6D FF
DB 92 FF DB 00 00 49 FF 92 DB FF FF FF FF FF FF FF FF FF FF FF DB 6D B6 FF FF FF FF FF FF 92 6D FF FF FF FF 6D B6 FF FF FF FF FF B6 B6 FF FF FF FF FF FF FF FF FF FF FF 92 DB 00 00 92 FF 92 DB
92 FF FF B6 00 00 6D FF 6D FF FF FF FF FF FF FF FF FF FF FF DB 6D FF FF FF 92 49 49 49 92 FF FF 49 DB DB 24 DB FF B6 49 49 92 FF FF DB 92 FF FF FF FF FF FF FF FF FF FF 92 FF 00 00 6D FF DB 92
6D FF FF FF 00 00 49 92 DB FF FF FF FF FF FF FF FF FF FF DB 6D FF FF 6D 00 00 00 00 00 00 00 B6 FF 49 00 24 24 49 24 00 00 00 00 6D FF DB 92 FF FF FF FF FF FF FF FF FF DB B6 00 00 92 FF FF 6D
6D FF FF 24 00 00 DB 6D FF FF FF FF FF FF FF FF FF FF DB 6D FF DB 00 00 00 00 00 00 00 00 00 00 B6 FF DB B6 49 92 24 24 00 00 00 00 24 FF DB 92 FF FF FF FF FF FF FF FF FF 92 6D 00 00 DB FF 6D
6D FF FF 24 00 00 FF 6D FF FF FF FF FF FF FF FF FF FF 49 FF B6 00 00 00 00 00 00 00 00 00 00 00 00 92 FF FF 92 DB DB 24 24 00 00 00 00 24 FF 92 DB FF FF FF FF FF FF FF FF 92 92 00 00 FF FF 6D
6D FF FF B6 00 00 92 6D FF FF FF FF FF FF FF FF FF 49 FF DB 00 00 00 00 00 00 00 00 00 00 00 00 00 92 FF FF B6 B6 FF 92 24 00 00 00 00 00 49 FF 6D FF FF FF FF FF FF FF FF 92 24 00 49 FF FF 6D
6D FF FF 00 00 00 DB 6D FF FF FF FF FF FF FF FF 6D DB DB 00 00 00 00 00 00 00 00 00 00 00 00 00 00 92 FF FF DB B6 FF B6 49 00 00 00 00 00 00 6D FF 6D FF FF FF FF FF FF FF 92 92 00 00 DB FF 6D
6D FF FF DB 00 00 B6 6D FF FF FF FF FF FF FF 6D B6 FF 24 00 00 00 00 00 00 00 00 00 00 00 24 B6 DB 6D FF FF FF FF FF 6D 49 24 00 00 00 00 00 00 B6 DB B6 FF FF FF FF FF B6 DB 24 00 92 FF FF 6D
6D FF FF 6D 00 00 24 DB 92 FF FF FF FF FF 92 92 FF 49 00 00 00 00 00 49 B6 FF FF DB B6 DB FF FF FF B6 92 FF FF DB 92 FF FF FF 49 6D 92 24 00 00 00 DB B6 DB FF FF FF FF 6D FF 00 00 00 DB FF 6D
6D FF FF 92 24 00 49 FF 6D B6 FF FF FF 6D 92 FF 49 00 00 49 DB FF FF FF FF FF FF B6 FF FF FF FF FF FF B6 6D 92 92 FF FF FF FF 6D FF FF FF DB 24 00 24 FF 92 B6 FF FF 92 B6 FF 00 00 B6 FF FF 6D
92 FF FF FF 00 00 24 92 FF 92 6D 92 49 B6 DB 24 00 24 DB FF FF FF FF FF DB 92 24 00 FF FF FF FF 6D 6D FF FF FF 6D 6D FF FF B6 DB 6D FF FF FF FF 00 00 24 DB B6 6D 6D B6 DB 00 00 00 6D FF FF 6D
DB 92 FF DB 49 00 00 00 B6 FF FF DB FF 6D 00 00 6D FF FF FF FF FF FF FF 24 92 00 49 FF FF FF FF FF 6D B6 FF FF 6D 6D FF 6D 00 DB DB 92 FF FF FF DB 00 00 00 6D FF FF DB 6D 00 00 24 FF FF 92 DB
FF 49 FF FF 6D 00 00 00 24 49 B6 FF 24 00 00 6D FF FF FF FF FF FF FF 49 92 B6 00 DB FF FF DB DB FF FF B6 FF FF FF FF FF 00 49 DB FF 92 FF FF FF FF 92 00 00 00 24 6D 00 00 00 00 24 DB FF 49 FF
FF 92 B6 FF 92 49 00 00 00 00 00 24 00 00 00 FF FF FF FF FF FF FF 92 6D FF B6 DB FF DB B6 DB B6 B6 FF FF B6 FF FF FF DB 00 B6 DB FF 92 FF FF FF FF FF 24 00 00 00 00 00 00 00 00 B6 FF 92 B6 FF
FF FF 49 FF FF 49 24 00 00 00 00 00 00 00 B6 FF FF FF FF FF FF FF B6 FF FF FF FF FF FF FF FF FF 6D FF FF 6D FF FF FF DB 24 FF FF FF 92 FF FF FF FF FF 6D 00 00 00 00 00 00 00 DB FF FF 6D FF FF
FF FF DB 6D FF FF 6D 49 00 00 00 00 00 24 FF FF FF FF FF FF FF FF FF FF FF FF FF DB 6D 49 24 24 24 FF FF DB FF FF FF FF 24 24 00 00 92 FF FF FF FF FF DB 00 00 00 00 00 00 FF DB FF 6D FF FF FF
FF FF FF 92 B6 FF FF DB 49 24 00 00 00 92 FF FF FF FF FF FF FF FF FF DB FF FF FF 49 49 24 00 24 FF FF FF FF FF FF FF FF 49 6D 00 24 49 FF FF FF FF FF FF 49 00 24 6D 6D B6 FF FF 6D B6 FF FF FF
FF FF FF FF 6D B6 FF FF DB 92 B6 49 00 FF FF FF FF FF FF FF FF FF FF B6 FF FF FF 92 DB 92 00 24 FF FF FF FF FF FF FF FF FF 00 00 6D FF FF FF FF FF FF FF DB 00 6D DB FF FF FF 6D B6 FF FF FF FF
FF FF FF FF FF 92 6D FF FF FF FF B6 49 FF FF FF FF FF FF FF FF FF FF 6D FF FF FF FF B6 92 92 B6 B6 DB FF FF FF FF FF FF FF B6 6D 49 6D FF FF FF FF FF FF FF 92 24 FF FF B6 6D DB FF FF FF FF FF
FF FF FF FF FF FF DB 49 6D B6 FF 6D 92 FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF FF FF FF 92 FF FF FF FF FF FF FF FF 6D DB 92 FF FF FF FF FF FF FF FF 6D 49 6D DB FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF DB 92 49 00 FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 6D FF FF FF FF FF FF FF DB 92 FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF DB 00 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 92 6D B6 FF FF FF FF FF FF 49 DB FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF FF 49 DB 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 6D FF 92 49 92 FF FF FF FF DB 49 DB FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF B6 49 FF FF FF FF FF FF FF FF 6D 92 FF 92 FF FF FF FF FF FF FF FF FF FF B6 6D 49 6D DB FF FF FF FF FF 6D 49 FF FF FF DB 6D 6D 92 92 6D 49 FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF 6D 92 FF FF FF DB FF FF FF FF FF FF FF FF 6D 6D FF FF FF 92 6D FF FF FF FF FF 49 92 B6 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF DB 24 92 FF FF FF FF FF FF FF FF FF FF FF FF FF 49 49 6D DB FF FF DB 6D B6 FF FF FF FF B6 B6 DB 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF 24 B6 FF FF FF FF B6 49 49 24 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF 00 49 FF DB DB FF FF FF B6 92 FF FF FF FF FF FF 92 DB FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF 24 B6 FF FF B6 24 00 6D DB FF 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF 6D DB DB 00 00 24 FF FF FF FF B6 FF FF FF FF FF B6 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF B6 B6 DB B6 6D 49 49 92 FF FF FF B6 6D FF FF FF FF FF FF FF 92 92 FF FF FF FF FF FF FF 49 92 DB 49 FF FF FF FF FF FF FF FF FF 92 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF 92 24 49 49 6D FF 6D 92 FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF DB FF FF FF FF FF FF FF FF B6 FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF B6 DB DB FF FF FF FF FF FF FF DB FF FF FF FF FF FF FF 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF FF 24 92 FF FF FF FF FF FF FF FF FF FF 6D B6 FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF 6D B6 FF FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF B6 92 FF FF FF FF FF FF FF FF FF FF FF DB 6D 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF FF DB 49 FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF 92 6D FF FF FF FF FF 00 24 DB FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF B6 49 FF FF FF FF FF FF 92 6D FF FF FF FF FF FF FF FF FF FF 6D B6 FF FF FF FF FF FF FF FF FF FF FF FF B6 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 FF FF FF FF FF FF FF 49 00 DB FF FF FF FF FF FF FF FF FF 6D 6D B6 DB DB DB 92 49 00 00 00 00 00 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF 49 DB FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF FF FF FF DB 6D 49 49 6D B6 DB FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 FF FF FF FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF DB 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 FF FF FF FF FF FF DB 6D 00 49 FF FF FF FF FF FF FF FF FF FF FF FF DB B6 92 6D 6D 6D 49 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF 49 00 92 FF FF FF FF FF FF FF FF 49 00 00 00 00 00 49 B6 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF FF FF 6D 6D FF B6 B6 FF FF FF FF FF FF 92 92 FF FF 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 FF FF FF FF FF FF DB 00 DB 6D 00 B6 FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 DB FF FF FF FF FF 92 00 FF 24 00 00 49 FF FF FF FF FF FF FF FF FF B6 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 FF FF FF FF FF FF 49 24 24 00 00 6D FF FF FF FF FF FF FF DB FF DB 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 FF FF FF FF FF FF 6D 00 24 24 24 FF FF FF FF FF FF DB B6 DB 49 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 00 B6 00 49 DB FF FF FF DB 24 6D 24 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 B6 6D 00 00 DB FF 6D 00 00 00 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 00 6D FF FF 00 00 DB 49 00 00 00 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 DB FF FF 6D 00 00 92 24 00 00 00 00 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 FF FF 00 6D 00 00 24 00 00 00 00 00 00 24 92 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D DB 00 00 00 00 00 00 00 00 00 00 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 00 24 00 00 6D 00 00 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 92 6D 6D DB B6 92 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
</bitmap>
</icon>
</chrp-boot>

View file

@ -0,0 +1,172 @@
<CHRP-BOOT>
<COMPATIBLE>
MacRISC MacRISC3 MacRISC4
</COMPATIBLE>
<DESCRIPTION>
@PACKAGE@ @VERSION@
</DESCRIPTION>
<OS-BADGE-ICONS>
3434
00000000000000F781FB8181818181FBFAF500000000000000000000000000000000000000F6FAFAFAFA81F9F600000000000000
0000000000F8FBF9F500F95656FCFB5656FBF800000000000000000000000000000000F5FAF9F5F7F600F6F6F9FAF70000000000
000000F5FBFA0056FDFEFEFDFDFAAC81FB56568181560000000000000000000000F9F9F9F7FCFDFEFEFEFFFC81F656FA00000000
0000F5AC2BF7FBFEFEFD2BF6568181F9F7F6F6F8FBF50000000000000000000000FAF700F600F5F7F7F6F7FEFFACF82BFB000000
0000FC2BF5FEFFFFF5F7FC81F70000F7F9FAFAF8000000000000000000000000000056F9F9FAF9F7F7FA812BF7FFFF56F7FA0000
005656F5FEFFAC2BF9FA000000000000000000000000000000000000000000000000000000000000000000FA56FAFEFEF8F9F700
00FB00F7FFFF56F9F800000000000000000000F656FAFA56F50000000000F5F8F9F8F5000000000000000000F9F7FCFFFB00FB00
F8F800ACFFACF6FA000000000000000000F6FA562BF5F5F781FA000000F9FA2B00F556F9F5000000000000000081F8FFFEF6562B
810000FFFFF9FAF500000000000000002B8100F5F9FCACFBF82BFBF6FCFAF6FAFC81F600FA2B000000000000002BF8FEFFF8F5FA
FA00F5FEFFFA8100000000000000002B8100F9FEFFFFFFFFFFFBF6FDFEACFDFEFFFFFFFBF581F600000000000000F9FEFFF700FA
FA00FBFFFEF6F900000000000000F6FB00FCFFFFFFFFFFFFFFFFFCF600FCF7ACFEFFFFFFFDF6810000000000000056F9FFAC00FA
FA00F6FFFFF856000000000000F5FBF5ACFFFFFFFFFFFFFFFFFFFF2B002BF8F5ACFFFFFFFFFDF6FA000000000000F9FCFF560081
FA0081FFFFF8F9000000000000FBF6FBFFFFFFFFFFFFFFFFFFFFFFF800F55600FCFFFFFFFFFF81F8F80000000000F981FFAC0081
FA0000FEFEF8FB0000000000812BFAFFFFFFFFFFFFFEFFFFFDF92BFA0000F6F981ACFEFFFFFFFF56F9F600000000F9FDFF2B0081
FA00FAFFFF81812B000000FAF8F9FFFFFEACFBF80000F500000000F9F900562B0000FCF7F9ACFFFF2BF9F50000F9F6FEFFFB0081
810000FCFFFBF6FB56F7FBF8F9FFFE5600000000F5FAAC000000F82BF6FAFBF800F556F80000F9FFFE2BFAFAFAF8FAFFFEF60081
FAF6F5ACFFFFAC00F856F7ACFFFCF500000000FAFCFFFC00000056AC00F581F92BFEF9FAF6000081FFFFFBF6F62BFFFFACF6F6FA
F6FA00FAFFFFFFACFA56FFFFAC0000000000F6FD2BFEF6F5565600F5F800F60081FEF7F656000000FDFFFFFDFDFFFFFFAC0081F5
0081F52BFDFFFFFFFFFFFFFFF60000000000FBF6F6F5F656F52BF900FA000000FCFAF5F656000000F7FFFFFFFFFFFFFDF7F68100
00F6FB00F8FDFFFFFFFFFF810000000000F6F5000000F52B56F9FC00F7F70000FCF881FCF500000000FEFFFFFFFFAC5600FBF500
000056F900F8ACFDFFFFFFF5000000000000002B0000FDFEFFFE560000F60000F9ACFFFE810000000081FFFEFDFAF800FAF70000
000000FAF9002B56FAFDFC0000000000000000F80000FBF5FEFEF5000000000000ACFFFA2B0000000000FEFB2BF5008156000000
00000000F9FBF600F6FBF800000000000000F7F8000000F9F9F9F82B0000000000F6ACACF70000000000F7FD2BFA812B00000000
0000000000F681FCFBFD0000000000000000FBF6000000000000F52B000000000000F92B810000000000008181F6000000000000
0000000000000000F6FC00000000000000F6FF0000000000000000000000000000000081FBFB2B00000000F7F900000000000000
000000000000000000FC00000000000000FCFAF600000000000000000000000000000056ACF581FBF700000081FB000000000000
0000000000000000FAF90000000000008156F5F8000000000000002BFBFCFBF800000000FD2B000056FB8181FBF8000000000000
0000000000000000AC0000000000F5FBF90000F6000000000000F5AC56F6005681F50000F6ACFCFBF70000000000000000000000
00000000000000F881000000F5FAFDFD00000000000000000000F7FEFA2B0000F581F70000000000810000000000000000000000
000000000000F9FCF500FAFDACFAF5FD00000000000000000000F5ACF5FDFEFA0000F82B00000000810000000000000000000000
000000000000FCF8F9AC81FD000000FD000000000000FAF7000000F50081F9FAF800000000000000FB0000000000000000000000
000000000000FC81F956F5FD000000FD0000000000000000F800F5000000000056000000000000F7FB0000000000000000000000
00000000000000000000F5AC000000ACF800000000000000F5FAF80000000000F50000000000F8ACF50000000000000000000000
00000000000000000000F5AC000000F5AC000000000000000056F9000000000000000000F7ACFCF5000000000000000000000000
00000000000000000000F5FD00000000AC000000000000000000FB0000000000000000F5F6F5FCF6000000000000000000000000
0000000000000000000000FD00000000FBFDF600000000000000F8F900000000000000000000F5FB000000000000000000000000
0000000000000000000000FDF500000000F9ACF800000000000000815600000000F656818181AC56000000000000000000000000
000000000000000000000081F80000000000F9FC0000000000000000F9ACACACFCFBFAFA81FD2B00000000000000000000000000
0000000000000000000000F7FB0000000000FBF70000000000000000000000000000000000FB0000000000000000000000000000
000000000000000000000000ACF500000000F9FD56F5000000000000000000000000000000FB0000000000000000000000000000
000000000000000000000000F8FA0000000000F6FEFEF5000000000000F55681FCACFDACFC560000000000000000000000000000
00000000000000000000000000FBF600000000002BFCFA00F700000000F9FDFDFAFEF90000000000000000000000000000000000
00000000000000000000000000F5FB0000000000F5FEF7ACAC0000000000000000FCF50000000000000000000000000000000000
0000000000000000000000000000F6FA000000002BFF2BFFFFAC00000000000000F7FA0000000000000000000000000000000000
000000000000000000000000000000F65600000000FAFEFFFFAC0000000000F800F6810000000000000000000000000000000000
00000000000000000000000000000000F52B00000000F8FEFBFF5600000000FCFAACF60000000000000000000000000000000000
0000000000000000000000000000000000000000000000F9FCFCFFFB00F8FEFFFDF5000000000000000000000000000000000000
00000000000000000000000000000000000000000000F9FDF7F5FFFD56FFFFFFFD00000000000000000000000000000000000000
00000000000000000000000000000000000000000000810000FBFFFFFBFFFFFFFFACF9F5F5000000000000000000000000000000
0000000000000000000000000000000000000000000000F600FC81FFFEFFFFFFFFFFFE8100000000000000000000000000000000
00000000000000000000000000000000000000000000000000F7F6FDFFFFFFFEFFFFACF500000000000000000000000000000000
000000000000000000000000000000000000000000000000000000F5FC81FC81FAFBF9F500000000000000000000000000000000
00000000000000F781FB8181818181FBFAF500000000000000000000000000000000000000F6FAFAFAFA81F9F600000000000000
0000000000F8FBF9F500F95656FCFB5656FBF800000000000000000000000000000000F5FAF9F5F7F600F6F6F9FAF70000000000
000000F5FBFA0056FDFEFEFDFDFAAC81FB56568181560000000000000000000000F9F9F9F7FCFDFEFEFEFFFC81F656FA00000000
0000F5AC2BF7FBFEFEFD2BF6568181F9F7F6F6F8FBF50000000000000000000000FAF700F600F5F7F7F6F7FEFFACF82BFB000000
0000FC2BF5FEFFFFF5F7FC81F70000F7F9FAFAF8000000000000000000000000000056F9F9FAF9F7F7FA812BF7FFFF56F7FA0000
005656F5FEFFAC2BF9FA000000000000000000000000000000000000000000000000000000000000000000FA56FAFEFEF8F9F700
00FB00F7FFFF56F9F800000000000000000000F656FAFA56F50000000000F5F8F9F8F5000000000000000000F9F7FCFFFB00FB00
F8F800ACFFACF6FA000000000000000000F6FA562BF5F5F781FA000000F9FA2B00F556F9F5000000000000000081F8FFFEF6562B
810000FFFFF9FAF500000000000000002B8100F5F9FCACFBF82BFBF6FCFAF6FAFC81F600FA2B000000000000002BF8FEFFF8F5FA
FA00F5FEFFFA8100000000000000002B8100F9FEFFFFFFFFFFFBF6FDFEACFDFEFFFFFFFBF581F600000000000000F9FEFFF700FA
FA00FBFFFEF6F900000000000000F6FB00FCFFFFFFFFFFFFFFFFFCF600FCF7ACFEFFFFFFFDF6810000000000000056F9FFAC00FA
FA00F6FFFFF856000000000000F5FBF5ACFFFFFFFFFFFFFFFFFFFF2B002BF8F5ACFFFFFFFFFDF6FA000000000000F9FCFF560081
FA0081FFFFF8F9000000000000FBF6FBFFFFFFFFFFFFFFFFFFFFFFF800F55600FCFFFFFFFFFF81F8F80000000000F981FFAC0081
FA0000FEFEF8FB0000000000812BFAFFFFFFFFFFFFFEFFFFFDF92BFA0000F6F981ACFEFFFFFFFF56F9F600000000F9FDFF2B0081
FA00FAFFFF81812B000000FAF8F9FFFFFEACFBF80000F500000000F9F900562B0000FCF7F9ACFFFF2BF9F50000F9F6FEFFFB0081
810000FCFFFBF6FB56F7FBF8F9FFFE5600000000F5FAAC000000F82BF6FAFBF800F556F80000F9FFFE2BFAFAFAF8FAFFFEF60081
FAF6F5ACFFFFAC00F856F7ACFFFCF500000000FAFCFFFC00000056AC00F581F92BFEF9FAF6000081FFFFFBF6F62BFFFFACF6F6FA
F6FA00FAFFFFFFACFA56FFFFAC0000000000F6FD2BFEF6F5565600F5F800F60081FEF7F656000000FDFFFFFDFDFFFFFFAC0081F5
0081F52BFDFFFFFFFFFFFFFFF60000000000FBF6F6F5F656F52BF900FA000000FCFAF5F656000000F7FFFFFFFFFFFFFDF7F68100
00F6FB00F8FDFFFFFFFFFF810000000000F6F5000000F52B56F9FC00F7F70000FCF881FCF500000000FEFFFFFFFFAC5600FBF500
000056F900F8ACFDFFFFFFF5000000000000002B0000FDFEFFFE560000F60000F9ACFFFE810000000081FFFEFDFAF800FAF70000
000000FAF9002B56FAFDFC0000000000000000F80000FBF5FEFEF5000000000000ACFFFA2B0000000000FEFB2BF5008156000000
00000000F9FBF600F6FBF800000000000000F7F8000000F9F9F9F82B0000000000F6ACACF70000000000F7FD2BFA812B00000000
0000000000F681FCFBFD0000000000000000FBF6000000000000F52B000000000000F92B810000000000008181F6000000000000
0000000000000000F6FC00000000000000F6FF0000000000000000000000000000000081FBFB2B00000000F7F900000000000000
000000000000000000FC00000000000000FCFAF600000000000000000000000000000056ACF581FBF700000081FB000000000000
0000000000000000FAF90000000000008156F5F8000000000000002BFBFCFBF800000000FD2B000056FB8181FBF8000000000000
0000000000000000AC0000000000F5FBF90000F6000000000000F5AC56F6005681F50000F6ACFCFBF70000000000000000000000
00000000000000F881000000F5FAFDFD00000000000000000000F7FEFA2B0000F581F70000000000810000000000000000000000
000000000000F9FCF500FAFDACFAF5FD00000000000000000000F5ACF5FDFEFA0000F82B00000000810000000000000000000000
000000000000FCF8F9AC81FD000000FD000000000000FAF7000000F50081F9FAF800000000000000FB0000000000000000000000
000000000000FC81F956F5FD000000FD0000000000000000F800F5000000000056000000000000F7FB0000000000000000000000
00000000000000000000F5AC000000ACF800000000000000F5FAF80000000000F50000000000F8ACF50000000000000000000000
00000000000000000000F5AC000000F5AC000000000000000056F9000000000000000000F7ACFCF5000000000000000000000000
00000000000000000000F5FD00000000AC000000000000000000FB0000000000000000F5F6F5FCF6000000000000000000000000
0000000000000000000000FD00000000FBFDF600000000000000F8F900000000000000000000F5FB000000000000000000000000
0000000000000000000000FDF500000000F9ACF800000000000000815600000000F656818181AC56000000000000000000000000
000000000000000000000081F80000000000F9FC0000000000000000F9ACACACFCFBFAFA81FD2B00000000000000000000000000
0000000000000000000000F7FB0000000000FBF70000000000000000000000000000000000FB0000000000000000000000000000
000000000000000000000000ACF500000000F9FD56F5000000000000000000000000000000FB0000000000000000000000000000
000000000000000000000000F8FA0000000000F6FEFEF5000000000000F55681FCACFDACFC560000000000000000000000000000
00000000000000000000000000FBF600000000002BFCFA00F700000000F9FDFDFAFEF90000000000000000000000000000000000
00000000000000000000000000F5FB0000000000F5FEF7ACAC0000000000000000FCF50000000000000000000000000000000000
0000000000000000000000000000F6FA000000002BFF2BFFFFAC00000000000000F7FA0000000000000000000000000000000000
000000000000000000000000000000F65600000000FAFEFFFFAC0000000000F800F6810000000000000000000000000000000000
00000000000000000000000000000000F52B00000000F8FEFBFF5600000000FCFAACF60000000000000000000000000000000000
0000000000000000000000000000000000000000000000F9FCFCFFFB00F8FEFFFDF5000000000000000000000000000000000000
00000000000000000000000000000000000000000000F9FDF7F5FFFD56FFFFFFFD00000000000000000000000000000000000000
00000000000000000000000000000000000000000000810000FBFFFFFBFFFFFFFFACF9F5F5000000000000000000000000000000
0000000000000000000000000000000000000000000000F600FC81FFFEFFFFFFFFFFFE8100000000000000000000000000000000
00000000000000000000000000000000000000000000000000F7F6FDFFFFFFFEFFFFACF500000000000000000000000000000000
000000000000000000000000000000000000000000000000000000F5FC81FC81FAFBF9F500000000000000000000000000000000
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
</OS-BADGE-ICONS>
<BOOT-SCRIPT>
boot &device;:&partition;,\System\Library\CoreServices\grub.elf
</BOOT-SCRIPT>
</CHRP-BOOT>

View file

@ -28,6 +28,7 @@ pic_base:
call boot_continue
mov %o4, CIF_REG
#ifndef CDBOOT
/* The offsets to these locations are defined by the
* GRUB_BOOT_MACHINE_foo macros in include/grub/sparc/ieee1275/boot.h,
* and grub-setup uses this to patch these next three values as needed.
@ -43,9 +44,19 @@ pic_base:
. = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH
boot_path:
. = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE
boot_path_end:
kernel_byte: .xword (2 << 9)
boot_path_end:
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#else
#define boot_path (_start + 512)
#define boot_path_end (_start + 1024)
#include <grub/offsets.h>
. = _start + 8
kernel_byte: .xword (2 << 9)
kernel_size: .word 512
kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
#endif
prom_finddev_name: .asciz "finddevice"
prom_chosen_path: .asciz "/chosen"
@ -158,8 +169,10 @@ boot_continue:
mov GRUB_NAME_LEN, %o3
GET_ABS(boot_path, %o3)
#ifndef CDBOOT
ldub [%o3], %o1
brnz,pn %o1, bootpath_known
#endif
/* getprop(chosen_node, "bootpath", &buffer, buffer_size) */
GET_ABS(prom_bootpath_name, %o2)
@ -194,12 +207,19 @@ bootpath_known:
GET_ABS(prom_read_name, %o0)
LDUW_ABS(kernel_address, 0x00, %o2)
call prom_call_3_1_o1
#ifdef CDBOOT
LDUW_ABS(kernel_size, 0x00, %o3)
#else
mov 512, %o3
#endif
LDUW_ABS(kernel_address, 0x00, %o2)
jmpl %o2, %o7
#ifdef CDBOOT
mov CIF_REG, %o4
#else
nop
#endif
. = _start + GRUB_BOOT_MACHINE_CODE_END
/* the last 4 bytes in the sector 0 contain the signature */

View file

@ -28,6 +28,7 @@
#include <grub/time.h>
#include <grub/loader.h>
#include <grub/cs5536.h>
#include <grub/disk.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -798,7 +799,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
/* Set ownership of root hub ports to EHCI */
grub_ehci_oper_write32 (e, GRUB_EHCI_CONFIG_FLAG, GRUB_EHCI_CF_EHCI_OWNER);
/* Enable asynchronous list */
/* Enable both lists */
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
GRUB_EHCI_CMD_AS_ENABL
| GRUB_EHCI_CMD_PS_ENABL
@ -942,9 +943,9 @@ grub_ehci_setup_qh (grub_ehci_qh_t qh, grub_usb_transfer_t transfer)
* SplitCompletionMask - AFAIK it is ignored in asynchronous list,
* InterruptScheduleMask - AFAIK it should be zero in async. list */
ep_cap |= GRUB_EHCI_MULT_THREE;
ep_cap |= (transfer->dev->port << GRUB_EHCI_DEVPORT_OFF)
ep_cap |= (transfer->dev->split_hubport << GRUB_EHCI_DEVPORT_OFF)
& GRUB_EHCI_DEVPORT_MASK;
ep_cap |= (transfer->dev->hubaddr << GRUB_EHCI_HUBADDR_OFF)
ep_cap |= (transfer->dev->split_hubaddr << GRUB_EHCI_HUBADDR_OFF)
& GRUB_EHCI_HUBADDR_MASK;
if (transfer->dev->speed == GRUB_USB_SPEED_LOW
&& transfer->type != GRUB_USB_TRANSACTION_TYPE_CONTROL)
@ -1261,16 +1262,6 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
/* XXX: Fix it: Currently we don't do anything to restart EHCI */
return GRUB_USB_ERR_INTERNAL;
/* Check if transfer is not high speed and connected to root hub.
* It should not happened but... */
if ((transfer->dev->speed != GRUB_USB_SPEED_HIGH)
&& !transfer->dev->hubaddr)
{
grub_error (GRUB_USB_ERR_BADDEVICE,
"FULL/LOW speed device on EHCI port!?!");
return GRUB_USB_ERR_BADDEVICE;
}
/* Allocate memory for controller transfer data. */
cdata = grub_malloc (sizeof (*cdata));
if (!cdata)
@ -1887,13 +1878,16 @@ grub_ehci_fini_hw (int noreturn __attribute__ ((unused)))
/* We should disable all EHCI HW to prevent any DMA access etc. */
for (e = ehci; e; e = e->next)
{
/* Disable both lists */
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
~(GRUB_EHCI_CMD_AS_ENABL | GRUB_EHCI_CMD_PS_ENABL)
& grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
/* Check if EHCI is halted and halt it if not */
if (grub_ehci_halt (e) != GRUB_USB_ERR_NONE)
grub_error (GRUB_ERR_TIMEOUT, "restore_hw: EHCI halt timeout");
grub_ehci_halt (e);
/* Reset EHCI */
if (grub_ehci_reset (e) != GRUB_USB_ERR_NONE)
grub_error (GRUB_ERR_TIMEOUT, "restore_hw: EHCI reset timeout");
grub_ehci_reset (e);
}
return GRUB_USB_ERR_NONE;
@ -1916,6 +1910,9 @@ GRUB_MOD_INIT (ehci)
{
COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_td) == 64);
COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_qh) == 96);
grub_stop_disk_firmware ();
grub_boot_time ("Initing EHCI hardware");
grub_ehci_inithw ();
grub_boot_time ("Registering EHCI driver");

View file

@ -28,6 +28,7 @@
#include <grub/time.h>
#include <grub/cs5536.h>
#include <grub/loader.h>
#include <grub/disk.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -1442,6 +1443,9 @@ GRUB_MOD_INIT(ohci)
{
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_td) == 32);
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_ed) == 16);
grub_stop_disk_firmware ();
grub_ohci_inithw ();
grub_usb_controller_dev_register (&usb_controller);
fini_hnd = grub_loader_register_preboot_hook (grub_ohci_fini_hw,

View file

@ -26,6 +26,7 @@
#include <grub/cpu/io.h>
#include <grub/time.h>
#include <grub/cpu/pci.h>
#include <grub/disk.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -44,12 +45,22 @@ typedef enum
GRUB_UHCI_REG_USBLEGSUP = 0xc0
} grub_uhci_reg_t;
enum
{
GRUB_UHCI_DETECT_CHANGED = (1 << 1),
GRUB_UHCI_DETECT_HAVE_DEVICE = 1,
GRUB_UHCI_DETECT_LOW_SPEED = (1 << 8)
};
/* R/WC legacy support bits */
#define GRUB_UHCI_LEGSUP_END_A20GATE (1 << 15)
#define GRUB_UHCI_TRAP_BY_64H_WSTAT (1 << 11)
#define GRUB_UHCI_TRAP_BY_64H_RSTAT (1 << 10)
#define GRUB_UHCI_TRAP_BY_60H_WSTAT (1 << 9)
#define GRUB_UHCI_TRAP_BY_60H_RSTAT (1 << 8)
enum
{
GRUB_UHCI_LEGSUP_END_A20GATE = (1 << 15),
GRUB_UHCI_TRAP_BY_64H_WSTAT = (1 << 11),
GRUB_UHCI_TRAP_BY_64H_RSTAT = (1 << 10),
GRUB_UHCI_TRAP_BY_60H_WSTAT = (1 << 9),
GRUB_UHCI_TRAP_BY_60H_RSTAT = (1 << 8)
};
/* Reset all legacy support - clear all R/WC bits and all R/W bits */
#define GRUB_UHCI_RESET_LEGSUP_SMI ( GRUB_UHCI_LEGSUP_END_A20GATE \
@ -125,7 +136,7 @@ typedef volatile struct grub_uhci_qh *grub_uhci_qh_t;
struct grub_uhci
{
int iobase;
grub_port_t iobase;
volatile grub_uint32_t *framelist_virt;
grub_uint32_t framelist_phys;
struct grub_pci_dma_chunk *framelist_chunk;
@ -213,22 +224,28 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
/* Set bus master - needed for coreboot or broken BIOSes */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr,
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr));
grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| grub_pci_read_word (addr));
/* Determine IO base address. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4);
base = grub_pci_read (addr);
/* Stop if there is no IO space base address defined. */
if (! (base & 1))
if ((base & GRUB_PCI_ADDR_SPACE_MASK) != GRUB_PCI_ADDR_SPACE_IO)
return 0;
if ((base & GRUB_UHCI_IOMASK) == 0)
return 0;
grub_dprintf ("uhci", "base = %x\n", base);
/* Allocate memory for the controller and register it. */
u = grub_zalloc (sizeof (*u));
if (! u)
return 1;
u->iobase = base & GRUB_UHCI_IOMASK;
u->iobase = (base & GRUB_UHCI_IOMASK) + GRUB_MACHINE_PCI_IO_BASE;
/* Reset PIRQ and SMI */
addr = grub_pci_make_address (dev, GRUB_UHCI_REG_USBLEGSUP);
@ -392,6 +409,7 @@ grub_free_queue (struct grub_uhci *u, grub_uhci_qh_t qh, grub_uhci_td_t td,
{
grub_uhci_td_t tdprev;
grub_dprintf ("uhci", "Freeing %p\n", td);
/* Check state of TD and possibly set last_trans */
if (transfer && (td->linkptr & 1))
transfer->last_trans = i;
@ -400,7 +418,10 @@ grub_free_queue (struct grub_uhci *u, grub_uhci_qh_t qh, grub_uhci_td_t td,
/* Unlink the queue. */
tdprev = td;
td = grub_dma_phys2virt (td->linkptr2, u->td_chunk);
if (!td->linkptr2)
td = 0;
else
td = grub_dma_phys2virt (td->linkptr2, u->td_chunk);
/* Free the TD. */
grub_free_td (u, tdprev);
@ -583,10 +604,17 @@ grub_uhci_check_transfer (grub_usb_controller_t dev,
*actual = 0;
errtd = grub_dma_phys2virt (cdata->qh->elinkptr & ~0x0f, u->qh_chunk);
if (cdata->qh->elinkptr & ~0x0f)
errtd = grub_dma_phys2virt (cdata->qh->elinkptr & ~0x0f, u->qh_chunk);
else
errtd = 0;
grub_dprintf ("uhci", ">t status=0x%02x data=0x%02x td=%p\n",
errtd->ctrl_status, errtd->buffer & (~15), errtd);
if (errtd)
{
grub_dprintf ("uhci", ">t status=0x%02x data=0x%02x td=%p, %x\n",
errtd->ctrl_status, errtd->buffer & (~15), errtd,
cdata->qh->elinkptr);
}
/* Check if the transaction completed. */
if (cdata->qh->elinkptr & 1)
@ -788,7 +816,7 @@ grub_uhci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
grub_dprintf ("uhci", "detect=0x%02x port=%d\n", status, port);
/* Connect Status Change bit - it detects change of connection */
if (status & (1 << 1))
if (status & GRUB_UHCI_DETECT_CHANGED)
{
*changed = 1;
/* Reset bit Connect Status Change */
@ -798,9 +826,9 @@ grub_uhci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
else
*changed = 0;
if (! (status & 1))
if (! (status & GRUB_UHCI_DETECT_HAVE_DEVICE))
return GRUB_USB_SPEED_NONE;
else if (status & (1 << 8))
else if (status & GRUB_UHCI_DETECT_LOW_SPEED)
return GRUB_USB_SPEED_LOW;
else
return GRUB_USB_SPEED_FULL;
@ -830,6 +858,8 @@ static struct grub_usb_controller_dev usb_controller =
GRUB_MOD_INIT(uhci)
{
grub_stop_disk_firmware ();
grub_uhci_inithw ();
grub_usb_controller_dev_register (&usb_controller);
grub_dprintf ("uhci", "registered\n");

View file

@ -49,7 +49,7 @@ static grub_usb_controller_dev_t grub_usb_list;
static grub_usb_device_t
grub_usb_hub_add_dev (grub_usb_controller_t controller,
grub_usb_speed_t speed,
int port, int hubaddr)
int split_hubport, int split_hubaddr)
{
grub_usb_device_t dev;
int i;
@ -63,8 +63,8 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
dev->controller = *controller;
dev->speed = speed;
dev->port = port;
dev->hubaddr = hubaddr;
dev->split_hubport = split_hubport;
dev->split_hubaddr = split_hubaddr;
err = grub_usb_device_initialize (dev);
if (err)
@ -108,8 +108,8 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
grub_dprintf ("usb", "Added new usb device: %p, addr=%d\n",
dev, i);
grub_dprintf ("usb", "speed=%d, port=%d, hubaddr=%d\n",
speed, port, hubaddr);
grub_dprintf ("usb", "speed=%d, split_hubport=%d, split_hubaddr=%d\n",
speed, split_hubport, split_hubaddr);
/* Wait "recovery interval", spec. says 2ms */
grub_millisleep (2);
@ -219,7 +219,12 @@ attach_root_port (struct grub_usb_hub *hub, int portno,
grub_boot_time ("Port enabled");
/* Enable the port and create a device. */
dev = grub_usb_hub_add_dev (hub->controller, speed, portno, 0);
/* High speed device needs not transaction translation
and full/low speed device cannot be connected to EHCI root hub
and full/low speed device connected to OHCI/UHCI needs not
transaction translation - e.g. hubport and hubaddr should be
always none (zero) for any device connected to any root hub. */
dev = grub_usb_hub_add_dev (hub->controller, speed, 0, 0);
hub->controller->dev->pending_reset = 0;
npending--;
if (! dev)
@ -593,6 +598,8 @@ poll_nonroot_hub (grub_usb_device_t dev)
{
grub_usb_speed_t speed;
grub_usb_device_t next_dev;
int split_hubport = 0;
int split_hubaddr = 0;
/* Determine the device speed. */
if (status & GRUB_USB_HUB_STATUS_PORT_LOWSPEED)
@ -608,8 +615,37 @@ poll_nonroot_hub (grub_usb_device_t dev)
/* Wait a recovery time after reset, spec. says 10ms */
grub_millisleep (10);
/* Find correct values for SPLIT hubport and hubaddr */
if (speed == GRUB_USB_SPEED_HIGH)
{
/* HIGH speed device needs not transaction translation */
split_hubport = 0;
split_hubaddr = 0;
}
else
/* FULL/LOW device needs hub port and hub address
for transaction translation (if connected to EHCI) */
if (dev->speed == GRUB_USB_SPEED_HIGH)
{
/* This port is the first FULL/LOW speed port
in the chain from root hub. Attached device
should use its port number and hub address */
split_hubport = i;
split_hubaddr = dev->addr;
}
else
{
/* This port is NOT the first FULL/LOW speed port
in the chain from root hub. Attached device
should use values inherited from some parent
HIGH speed hub - if any. */
split_hubport = dev->split_hubport;
split_hubaddr = dev->split_hubaddr;
}
/* Add the device and assign a device address to it. */
next_dev = grub_usb_hub_add_dev (&dev->controller, speed, i, dev->addr);
next_dev = grub_usb_hub_add_dev (&dev->controller, speed,
split_hubport, split_hubaddr);
if (dev->controller.dev->pending_reset)
{
dev->controller.dev->pending_reset = 0;

View file

@ -311,13 +311,13 @@ main (int argc, char **argv)
buf = malloc (len);
if (!buf)
{
printf ("Couldn't malloc buffer\n");
printf (_("error: %s.\n"), _("out of memory"));
fclose (f);
return 2;
}
if (fread (buf, 1, len, f) != len)
{
printf ("Read failed\n");
printf (_("cannot read `%s': %s"), strerror (errno));
free (buf);
fclose (f);
return 2;

View file

@ -24,6 +24,7 @@
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/charset.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -39,9 +40,15 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
struct grub_arg_list *state = ctxt->state;
int dos = 0;
grub_file_t file;
char buf[GRUB_DISK_SECTOR_SIZE];
unsigned char buf[GRUB_DISK_SECTOR_SIZE];
grub_ssize_t size;
int key = GRUB_TERM_NO_KEY;
grub_uint32_t code = 0;
int count = 0;
unsigned char utbuf[GRUB_MAX_UTF8_PER_CODEPOINT + 1];
int utcount = 0;
int is_0d = 0;
int j;
if (state[0].set)
dos = 1;
@ -60,21 +67,65 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
for (i = 0; i < size; i++)
{
unsigned char c = buf[i];
utbuf[utcount++] = buf[i];
if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
grub_printf ("%c", c);
else if (dos && c == '\r' && i + 1 < size && buf[i + 1] == '\n')
{
grub_printf ("\n");
i++;
}
else
if (is_0d && buf[i] != '\n')
{
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
grub_printf ("<%x>", (int) c);
grub_printf ("<%x>", (int) '\r');
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
}
is_0d = 0;
if (!grub_utf8_process (buf[i], &code, &count))
{
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
for (j = 0; j < utcount - 1; j++)
grub_printf ("<%x>", (unsigned int) utbuf[j]);
code = 0;
count = 0;
if (utcount == 1 || !grub_utf8_process (buf[i], &code, &count))
{
grub_printf ("<%x>", (unsigned int) buf[i]);
code = 0;
count = 0;
utcount = 0;
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
continue;
}
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
utcount = 1;
}
if (count)
continue;
if ((code >= 0xa1 || grub_isprint (code)
|| grub_isspace (code)) && code != '\r')
{
grub_printf ("%C", code);
count = 0;
code = 0;
utcount = 0;
continue;
}
if (dos && code == '\r')
{
is_0d = 1;
count = 0;
code = 0;
utcount = 0;
continue;
}
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
for (j = 0; j < utcount; j++)
grub_printf ("<%x>", (unsigned int) utbuf[j]);
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
count = 0;
code = 0;
utcount = 0;
}
do
@ -82,6 +133,18 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
while (key != GRUB_TERM_ESC && key != GRUB_TERM_NO_KEY);
}
if (is_0d)
{
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
grub_printf ("<%x>", (unsigned int) '\r');
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
}
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
for (j = 0; j < utcount; j++)
grub_printf ("<%x>", (unsigned int) utbuf[j]);
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
grub_xputs ("\n");
grub_refresh ();
grub_file_close (file);

View file

@ -50,7 +50,7 @@ static const char *descs[] = {
[0xd] = "assembler",
[0xf] = "serial",
[GRUB_LINUXBIOS_MEMBER_CONSOLE] = "console",
[0x12] = "framebuffer",
[GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER] = "framebuffer",
[0x13] = "GPIO",
[0x15] = "VDAT",
[GRUB_LINUXBIOS_MEMBER_TIMESTAMPS] = "timestamps (`coreboot_boottime' to list)",
@ -77,6 +77,20 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item,
switch (table_item->tag)
{
case GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER:
{
struct grub_linuxbios_table_framebuffer *fb;
fb = (struct grub_linuxbios_table_framebuffer *) (table_item + 1);
grub_printf (": %dx%dx%d pitch=%d lfb=0x%llx %d/%d/%d/%d %d/%d/%d/%d",
fb->width, fb->height,
fb->bpp, fb->pitch, fb->lfb,
fb->red_mask_size, fb->green_mask_size,
fb->blue_mask_size, fb->reserved_mask_size,
fb->red_field_pos, fb->green_field_pos,
fb->blue_field_pos, fb->reserved_field_pos);
break;
}
case GRUB_LINUXBIOS_MEMBER_MAINBOARD:
{
struct grub_linuxbios_mainboard *mb;

View file

@ -132,6 +132,9 @@ map_key_core (int code, int status, int *alt_gr_consumed)
{
*alt_gr_consumed = 0;
if (code >= GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE)
return 0;
if (status & GRUB_TERM_STATUS_RALT)
{
if (status & (GRUB_TERM_STATUS_LSHIFT | GRUB_TERM_STATUS_RSHIFT))
@ -242,7 +245,7 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
goto fail;
}
if (grub_le_to_cpu32 (version) != GRUB_KEYBOARD_LAYOUTS_VERSION)
if (version != grub_cpu_to_le32_compile_time (GRUB_KEYBOARD_LAYOUTS_VERSION))
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid version");
goto fail;

View file

@ -43,8 +43,6 @@ static const struct grub_arg_option options[] =
{0, 0, 0, 0, 0, 0}
};
static const char grub_human_sizes[] = {' ', 'K', 'M', 'G', 'T'};
/* Helper for grub_ls_list_devices. */
static int
grub_ls_print_devices (const char *name, void *data)
@ -143,34 +141,8 @@ print_files_long (const char *filename, const struct grub_dirhook_info *info,
if (! ctx->human)
grub_printf ("%-12llu", (unsigned long long) file->size);
else
{
grub_uint64_t fsize = file->size * 100ULL;
grub_uint64_t fsz = file->size;
int units = 0;
char buf[20];
while (fsz / 1024)
{
fsize = (fsize + 512) / 1024;
fsz /= 1024;
units++;
}
if (units)
{
grub_uint64_t whole, fraction;
whole = grub_divmod64 (fsize, 100, &fraction);
grub_snprintf (buf, sizeof (buf),
"%" PRIuGRUB_UINT64_T
".%02" PRIuGRUB_UINT64_T "%c", whole, fraction,
grub_human_sizes[units]);
grub_printf ("%-12s", buf);
}
else
grub_printf ("%-12llu", (unsigned long long) file->size);
}
grub_printf ("%-12s", grub_get_human_size (file->size,
GRUB_HUMAN_SIZE_SHORT));
grub_file_close (file);
grub_free (pathname);
}

View file

@ -0,0 +1,311 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/device.h>
#include <grub/mm.h>
#include <grub/fs.h>
#include <grub/env.h>
#include <grub/file.h>
GRUB_MOD_LICENSE ("GPLv3+");
static const char *modnames_def[] = {
/* FIXME: autogenerate this. */
#if defined (__i386__) || defined (__x86_64__) || defined (GRUB_MACHINE_MIPS_LOONGSON)
"pata", "ahci", "usbms", "ohci", "uhci", "ehci"
#elif defined (GRUB_MACHINE_MIPS_QEMU_MIPS)
"pata"
#else
#error "Fill this"
#endif
};
static grub_err_t
get_uuid (const char *name, char **uuid, int getnative)
{
grub_device_t dev;
grub_fs_t fs = 0;
*uuid = 0;
dev = grub_device_open (name);
if (!dev)
return grub_errno;
if (!dev->disk)
{
grub_dprintf ("nativedisk", "Skipping non-disk\n");
return 0;
}
switch (dev->disk->dev->id)
{
/* Firmware disks. */
case GRUB_DISK_DEVICE_BIOSDISK_ID:
case GRUB_DISK_DEVICE_OFDISK_ID:
case GRUB_DISK_DEVICE_EFIDISK_ID:
case GRUB_DISK_DEVICE_NAND_ID:
case GRUB_DISK_DEVICE_ARCDISK_ID:
case GRUB_DISK_DEVICE_HOSTDISK_ID:
break;
/* Native disks. */
case GRUB_DISK_DEVICE_ATA_ID:
case GRUB_DISK_DEVICE_SCSI_ID:
if (getnative)
break;
/* Virtual disks. */
case GRUB_DISK_DEVICE_PROCFS_ID:
case GRUB_DISK_DEVICE_HOST_ID:
/* GRUB-only memdisk. Can't match any of firmware devices. */
case GRUB_DISK_DEVICE_MEMDISK_ID:
grub_dprintf ("nativedisk", "Skipping native disk %s\n",
dev->disk->name);
return 0;
/* FIXME: those probably need special handling. */
case GRUB_DISK_DEVICE_LOOPBACK_ID:
case GRUB_DISK_DEVICE_DISKFILTER_ID:
case GRUB_DISK_DEVICE_CRYPTODISK_ID:
break;
}
if (dev)
fs = grub_fs_probe (dev);
if (!fs)
{
grub_device_close (dev);
return grub_errno;
}
if (!fs->uuid || fs->uuid (dev, uuid) || !*uuid)
{
grub_device_close (dev);
if (!grub_errno)
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("%s does not support UUIDs"), fs->name);
return grub_errno;
}
grub_device_close (dev);
return GRUB_ERR_NONE;
}
struct search_ctx
{
char *root_uuid;
char *prefix_uuid;
const char *prefix_path;
int prefix_found, root_found;
};
static int
iterate_device (const char *name, void *data)
{
struct search_ctx *ctx = data;
char *cur_uuid;
if (get_uuid (name, &cur_uuid, 1))
{
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
grub_errno = 0;
grub_print_error ();
return 0;
}
grub_dprintf ("nativedisk", "checking %s: %s\n", name,
cur_uuid);
if (ctx->prefix_uuid && grub_strcasecmp (cur_uuid, ctx->prefix_uuid) == 0)
{
char *prefix;
prefix = grub_xasprintf ("(%s)/%s", name, ctx->prefix_path);
grub_env_set ("prefix", prefix);
grub_free (prefix);
ctx->prefix_found = 1;
}
if (ctx->root_uuid && grub_strcasecmp (cur_uuid, ctx->root_uuid) == 0)
{
grub_env_set ("root", name);
ctx->root_found = 1;
}
return ctx->prefix_found && ctx->root_found;
}
static grub_err_t
grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args_in)
{
char *uuid_root = 0, *uuid_prefix, *prefdev = 0;
const char *prefix = 0;
const char *path_prefix = 0;
int mods_loaded = 0;
grub_dl_t *mods;
const char **args;
int i;
if (argc == 0)
{
argc = ARRAY_SIZE (modnames_def);
args = modnames_def;
}
else
args = (const char **) args_in;
prefix = grub_env_get ("prefix");
if (! prefix)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
if (prefix)
path_prefix = (prefix[0] == '(') ? grub_strchr (prefix, ')') : NULL;
if (path_prefix)
path_prefix++;
else
path_prefix = prefix;
mods = grub_malloc (argc * sizeof (mods[0]));
if (!mods)
return grub_errno;
if (get_uuid (NULL, &uuid_root, 0))
return grub_errno;
prefdev = grub_file_get_device_name (prefix);
if (grub_errno)
{
grub_print_error ();
prefdev = 0;
}
if (get_uuid (prefdev, &uuid_prefix, 0))
{
grub_free (uuid_root);
return grub_errno;
}
grub_dprintf ("nativedisk", "uuid_prefix = %s, uuid_root = %s\n",
uuid_prefix, uuid_root);
for (mods_loaded = 0; mods_loaded < argc; mods_loaded++)
{
char *filename;
grub_dl_t mod;
grub_file_t file = NULL;
grub_ssize_t size;
void *core = 0;
mod = grub_dl_get (args[mods_loaded]);
if (mod)
{
mods[mods_loaded] = 0;
continue;
}
filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM "/%s.mod",
prefix, args[mods_loaded]);
if (! filename)
goto fail;
file = grub_file_open (filename);
grub_free (filename);
if (! file)
goto fail;
size = grub_file_size (file);
core = grub_malloc (size);
if (! core)
{
grub_file_close (file);
goto fail;
}
if (grub_file_read (file, core, size) != (grub_ssize_t) size)
{
grub_file_close (file);
grub_free (core);
goto fail;
}
grub_file_close (file);
mods[mods_loaded] = grub_dl_load_core_noinit (core, size);
if (! mods[mods_loaded])
goto fail;
}
for (i = 0; i < argc; i++)
if (mods[i])
grub_dl_init (mods[i]);
if (uuid_prefix || uuid_root)
{
struct search_ctx ctx;
grub_fs_autoload_hook_t saved_autoload;
/* No need to autoload FS since obviously we already have the necessary fs modules. */
saved_autoload = grub_fs_autoload_hook;
grub_fs_autoload_hook = 0;
ctx.root_uuid = uuid_root;
ctx.prefix_uuid = uuid_prefix;
ctx.prefix_path = path_prefix;
ctx.prefix_found = !uuid_prefix;
ctx.root_found = !uuid_root;
/* FIXME: try to guess the correct values. */
grub_device_iterate (iterate_device, &ctx);
grub_fs_autoload_hook = saved_autoload;
}
grub_free (uuid_root);
grub_free (uuid_prefix);
return GRUB_ERR_NONE;
fail:
grub_free (uuid_root);
grub_free (uuid_prefix);
for (i = 0; i < mods_loaded; i++)
if (mods[i])
{
mods[i]->fini = 0;
grub_dl_unload (mods[i]);
}
return grub_errno;
}
static grub_command_t cmd;
GRUB_MOD_INIT(nativedisk)
{
cmd = grub_register_command ("nativedisk", grub_cmd_nativedisk, N_("[MODULE1 MODULE2 ...]"),
N_("Switch to native disk drivers. If no modules are specified default set (pata,ahci,usbms,ohci,uhci,ehci) is used"));
}
GRUB_MOD_FINI(nativedisk)
{
grub_unregister_command (cmd);
}

View file

@ -179,7 +179,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
}
/* Load modules. */
if (! grub_no_autoload)
if (! grub_no_modules)
{
const char *prefix;
prefix = grub_env_get ("prefix");

View file

@ -83,6 +83,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
grub_env_set (state[0].arg, val);
else
grub_printf ("%s", val);
grub_device_close (dev);
return GRUB_ERR_NONE;
}
if (state[2].set)
@ -94,6 +95,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
grub_env_set (state[0].arg, val);
else
grub_printf ("%s", val);
grub_device_close (dev);
return GRUB_ERR_NONE;
}
fs = grub_fs_probe (dev);
@ -105,6 +107,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
grub_env_set (state[0].arg, fs->name);
else
grub_printf ("%s", fs->name);
grub_device_close (dev);
return GRUB_ERR_NONE;
}
if (state[4].set)
@ -125,6 +128,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
else
grub_printf ("%s", uuid);
grub_free (uuid);
grub_device_close (dev);
return GRUB_ERR_NONE;
}
if (state[5].set)
@ -147,8 +151,10 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
else
grub_printf ("%s", label);
grub_free (label);
grub_device_close (dev);
return GRUB_ERR_NONE;
}
grub_device_close (dev);
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unrecognised target");
}

View file

@ -41,7 +41,8 @@ grub_strtosl (char *arg, char **end, int base)
/* Context for test_parse. */
struct test_parse_ctx
{
int ret, discard, invert;
int invert;
int or, and;
int file_exists;
struct grub_dirhook_info file_info;
char *filename;
@ -51,9 +52,8 @@ struct test_parse_ctx
static void
update_val (int val, struct test_parse_ctx *ctx)
{
if (! ctx->discard)
ctx->ret = ctx->invert ? ! val : val;
ctx->invert = ctx->discard = 0;
ctx->and = ctx->and && (ctx->invert ? ! val : val);
ctx->invert = 0;
}
/* A hook for iterating directories. */
@ -153,8 +153,8 @@ static int
test_parse (char **args, int *argn, int argc)
{
struct test_parse_ctx ctx = {
.ret = 0,
.discard = 0,
.and = 1,
.or = 0,
.invert = 0
};
@ -332,7 +332,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists && ctx.file_info.dir, &ctx);
(*argn) += 2;
return ctx.ret;
return ctx.or || ctx.and;
}
if (grub_strcmp (args[*argn], "-e") == 0)
@ -340,7 +340,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists, &ctx);
(*argn) += 2;
return ctx.ret;
return ctx.or || ctx.and;
}
if (grub_strcmp (args[*argn], "-f") == 0)
@ -349,7 +349,7 @@ test_parse (char **args, int *argn, int argc)
/* FIXME: check for other types. */
update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx);
(*argn) += 2;
return ctx.ret;
return ctx.or || ctx.and;
}
if (grub_strcmp (args[*argn], "-s") == 0)
@ -362,7 +362,7 @@ test_parse (char **args, int *argn, int argc)
grub_file_close (file);
grub_errno = GRUB_ERR_NONE;
(*argn) += 2;
return ctx.ret;
return ctx.or || ctx.and;
}
/* String tests. */
@ -387,7 +387,7 @@ test_parse (char **args, int *argn, int argc)
if (grub_strcmp (args[*argn], ")") == 0)
{
(*argn)++;
return ctx.ret;
return ctx.or || ctx.and;
}
/* Recursively invoke if parenthesis. */
if (grub_strcmp (args[*argn], "(") == 0)
@ -405,15 +405,13 @@ test_parse (char **args, int *argn, int argc)
}
if (grub_strcmp (args[*argn], "-a") == 0)
{
/* If current value is 0 second value is to be discarded. */
ctx.discard = ! ctx.ret;
(*argn)++;
continue;
}
if (grub_strcmp (args[*argn], "-o") == 0)
{
/* If current value is 1 second value is to be discarded. */
ctx.discard = ctx.ret;
ctx.or = ctx.or || ctx.and;
ctx.and = 1;
(*argn)++;
continue;
}
@ -422,7 +420,7 @@ test_parse (char **args, int *argn, int argc)
update_val (args[*argn][0], &ctx);
(*argn)++;
}
return ctx.ret;
return ctx.or || ctx.and;
}
static grub_err_t

View file

@ -0,0 +1,115 @@
/* testspeed.c - Command to test file read speed */
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <grub/mm.h>
#include <grub/file.h>
#include <grub/time.h>
#include <grub/misc.h>
#include <grub/dl.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/normal.h>
GRUB_MOD_LICENSE ("GPLv3+");
#define DEFAULT_BLOCK_SIZE 65536
static const struct grub_arg_option options[] =
{
{"size", 's', 0, N_("Specify size for each read operation"), 0, ARG_TYPE_INT},
{0, 0, 0, 0, 0, 0}
};
static grub_err_t
grub_cmd_testspeed (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = ctxt->state;
grub_uint64_t start;
grub_uint64_t end;
grub_ssize_t block_size;
grub_disk_addr_t total_size;
char *buffer;
grub_file_t file;
grub_uint64_t whole, fraction;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
block_size = (state[0].set) ?
grub_strtoul (state[0].arg, 0, 0) : DEFAULT_BLOCK_SIZE;
if (block_size <= 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid block size"));
buffer = grub_malloc (block_size);
if (buffer == NULL)
return grub_errno;
file = grub_file_open (args[0]);
if (file == NULL)
goto quit;
total_size = 0;
start = grub_get_time_ms ();
while (1)
{
grub_ssize_t size = grub_file_read (file, buffer, block_size);
if (size <= 0)
break;
total_size += size;
}
end = grub_get_time_ms ();
grub_file_close (file);
grub_printf_ (N_("File size: %s\n"),
grub_get_human_size (total_size, GRUB_HUMAN_SIZE_NORMAL));
whole = grub_divmod64 (end - start, 1000, &fraction);
grub_printf_ (N_("Elapsed time: %d.%03d s \n"),
(unsigned) whole,
(unsigned) fraction);
if (end != start)
{
grub_uint64_t speed =
grub_divmod64 (total_size * 100ULL * 1000ULL, end - start, 0);
grub_printf_ (N_("Speed: %s \n"),
grub_get_human_size (speed,
GRUB_HUMAN_SIZE_SPEED));
}
quit:
grub_free (buffer);
return grub_errno;
}
static grub_extcmd_t cmd;
GRUB_MOD_INIT(testspeed)
{
cmd = grub_register_extcmd ("testspeed", grub_cmd_testspeed, 0, N_("[-s SIZE] FILENAME"),
N_("Test file read speed."),
options);
}
GRUB_MOD_FINI(testspeed)
{
grub_unregister_extcmd (cmd);
}

View file

@ -73,9 +73,9 @@ hook (const struct grub_video_mode_info *info, void *hook_arg)
info->blue_field_pos,
info->reserved_field_pos);
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
/* TRANSLATORS: In "packed pixel" mode you write the index of the color
in the palette. Synonyms include "paletted color". */
grub_xputs (_("Packed pixel "));
/* TRANSLATORS: In "paletted color" mode you write the index of the color
in the palette. Synonyms include "packed pixel". */
grub_xputs (_("Paletted "));
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_YUV)
grub_xputs (_("YUV "));
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PLANAR)

View file

@ -49,7 +49,6 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
if (grub_strcmp (cmd->name, "vbetest") == 0)
grub_dl_load ("vbe");
#endif
mode = grub_env_get ("gfxmode");
if (argc)
mode = args[0];
@ -71,10 +70,10 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
grub_font_t fixed;
struct grub_font_glyph *glyph;
grub_video_create_render_target (&text_layer, width, height,
GRUB_VIDEO_MODE_TYPE_RGB
| GRUB_VIDEO_MODE_TYPE_ALPHA);
if (!text_layer)
if (grub_video_create_render_target (&text_layer, width, height,
GRUB_VIDEO_MODE_TYPE_RGB
| GRUB_VIDEO_MODE_TYPE_ALPHA)
|| !text_layer)
goto fail;
grub_video_set_active_render_target (text_layer);
@ -155,26 +154,38 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
for (i = 0; i < 2; i++)
{
color = grub_video_map_rgb (0, 0, 0);
grub_video_fill_rect (color, 0, 0, width, height);
color = grub_video_map_rgb (255, 0, 0);
grub_video_fill_rect (color, 0, 0, 100, 100);
color = grub_video_map_rgb (0, 255, 255);
grub_video_fill_rect (color, 100, 100, 100, 100);
grub_video_set_viewport (x + 150, y + 150,
width - 150 * 2, height - 150 * 2);
color = grub_video_map_rgb (77, 33, 77);
grub_video_fill_rect (color, 0, 0, width, height);
grub_video_swap_buffers ();
}
for (i = 0; i < 5; i++)
{
if (i == 0 || i == 1)
{
color = grub_video_map_rgb (0, 0, 0);
grub_video_fill_rect (color, 0, 0, width, height);
color = grub_video_map_rgb (255, 0, 0);
grub_video_fill_rect (color, 0, 0, 100, 100);
color = grub_video_map_rgb (0, 255, 0);
grub_video_fill_rect (color, 100, 0, 100, 100);
color = grub_video_map_rgb (0, 0, 255);
grub_video_fill_rect (color, 200, 0, 100, 100);
color = grub_video_map_rgb (0, 255, 255);
grub_video_fill_rect (color, 0, 100, 100, 100);
color = grub_video_map_rgb (255, 0, 255);
grub_video_fill_rect (color, 100, 100, 100, 100);
color = grub_video_map_rgb (255, 255, 0);
grub_video_fill_rect (color, 200, 100, 100, 100);
grub_video_set_viewport (x + 150, y + 150,
width - 150 * 2, height - 150 * 2);
color = grub_video_map_rgb (77, 33, 77);
grub_video_fill_rect (color, 0, 0, width, height);
}
color = grub_video_map_rgb (i, 33, 77);
grub_video_fill_rect (color, 0, 0, width, height);
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, 0, 0,

View file

@ -75,6 +75,8 @@ struct grub_ahci_hba_port
enum grub_ahci_hba_port_command
{
GRUB_AHCI_HBA_PORT_CMD_ST = 0x01,
GRUB_AHCI_HBA_PORT_CMD_SPIN_UP = 0x02,
GRUB_AHCI_HBA_PORT_CMD_POWER_ON = 0x04,
GRUB_AHCI_HBA_PORT_CMD_FRE = 0x10,
GRUB_AHCI_HBA_PORT_CMD_CR = 0x8000,
GRUB_AHCI_HBA_PORT_CMD_FR = 0x4000,
@ -136,7 +138,7 @@ struct grub_ahci_device
static grub_err_t
grub_ahci_readwrite_real (struct grub_ahci_device *dev,
struct grub_disk_ata_pass_through_parms *parms,
int spinup);
int spinup, int reset);
enum
@ -162,8 +164,513 @@ enum
static struct grub_ahci_device *grub_ahci_devices;
static int numdevs;
static int
grub_ahci_pciinit (grub_pci_device_t dev,
grub_pci_id_t pciid __attribute__ ((unused)),
void *data __attribute__ ((unused)))
{
grub_pci_address_t addr;
grub_uint32_t class;
grub_uint32_t bar;
unsigned i, nports;
volatile struct grub_ahci_hba *hba;
/* Read class. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class = grub_pci_read (addr);
/* Check if this class ID matches that of a PCI IDE Controller. */
if (class >> 8 != 0x010601)
return 0;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG5);
bar = grub_pci_read (addr);
if ((bar & (GRUB_PCI_ADDR_SPACE_MASK | GRUB_PCI_ADDR_MEM_TYPE_MASK
| GRUB_PCI_ADDR_MEM_PREFETCH))
!= (GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32))
return 0;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word (addr, grub_pci_read_word (addr) |
GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER);
hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK,
sizeof (hba));
grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function);
grub_dprintf ("ahci", "tfd[0]: %x\n",
hba->ports[0].task_file_data);
grub_dprintf ("ahci", "cmd[0]: %x\n",
hba->ports[0].command);
grub_dprintf ("ahci", "st[0]: %x\n",
hba->ports[0].status);
grub_dprintf ("ahci", "err[0]: %x\n",
hba->ports[0].sata_error);
grub_dprintf ("ahci", "tfd[1]: %x\n",
hba->ports[1].task_file_data);
grub_dprintf ("ahci", "cmd[1]: %x\n",
hba->ports[1].command);
grub_dprintf ("ahci", "st[1]: %x\n",
hba->ports[1].status);
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
hba->ports[1].sata_error = hba->ports[1].sata_error;
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
grub_dprintf ("ahci", "BH:%x\n", hba->bios_handoff);
if (! (hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_OS_OWNED))
{
grub_uint64_t endtime;
grub_dprintf ("ahci", "Requesting AHCI ownership\n");
hba->bios_handoff = (hba->bios_handoff & ~GRUB_AHCI_BIOS_HANDOFF_RWC)
| GRUB_AHCI_BIOS_HANDOFF_OS_OWNED;
grub_dprintf ("ahci", "Waiting for BIOS to give up ownership\n");
endtime = grub_get_time_ms () + 1000;
while ((hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_BIOS_OWNED)
&& grub_get_time_ms () < endtime);
if (hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_BIOS_OWNED)
{
grub_dprintf ("ahci", "Forcibly taking ownership\n");
hba->bios_handoff = GRUB_AHCI_BIOS_HANDOFF_OS_OWNED;
hba->bios_handoff |= GRUB_AHCI_BIOS_HANDOFF_OS_OWNERSHIP_CHANGED;
}
else
grub_dprintf ("ahci", "AHCI ownership obtained\n");
}
else
grub_dprintf ("ahci", "AHCI is already in OS mode\n");
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
if (!(hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN))
grub_dprintf ("ahci", "AHCI is in compat mode. Switching\n");
else
grub_dprintf ("ahci", "AHCI is in AHCI mode.\n");
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
/* {
grub_uint64_t endtime;
hba->global_control |= 1;
endtime = grub_get_time_ms () + 1000;
while (hba->global_control & 1)
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't reset AHCI\n");
return 0;
}
}*/
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
for (i = 0; i < 5; i++)
{
hba->global_control |= GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN;
grub_millisleep (1);
if (hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN)
break;
}
if (i == 5)
{
grub_dprintf ("ahci", "Couldn't put AHCI in AHCI mode\n");
return 0;
}
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
for (i = 0; i < 5; i++)
{
hba->global_control |= GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN;
grub_millisleep (1);
if (hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN)
break;
}
if (i == 5)
{
grub_dprintf ("ahci", "Couldn't put AHCI in AHCI mode\n");
return 0;
}
grub_dprintf ("ahci", "err[1]: %x\n",
hba->ports[1].sata_error);
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
nports = (hba->cap & GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1;
grub_dprintf ("ahci", "%d AHCI ports, PI = 0x%x\n", nports,
hba->ports_implemented);
struct grub_ahci_device *adevs[GRUB_AHCI_HBA_CAP_NPORTS_MASK + 1];
struct grub_ahci_device *failed_adevs[GRUB_AHCI_HBA_CAP_NPORTS_MASK + 1];
grub_uint32_t fr_running = 0;
for (i = 0; i < nports; i++)
failed_adevs[i] = 0;
for (i = 0; i < nports; i++)
{
if (!(hba->ports_implemented & (1 << i)))
{
adevs[i] = 0;
continue;
}
adevs[i] = grub_zalloc (sizeof (*adevs[i]));
if (!adevs[i])
return 1;
adevs[i]->hba = hba;
adevs[i]->port = i;
adevs[i]->present = 1;
adevs[i]->num = numdevs++;
}
for (i = 0; i < nports; i++)
if (adevs[i])
{
adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error;
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head));
if (!adevs[i]->command_list_chunk)
{
adevs[i] = 0;
continue;
}
adevs[i]->command_table_chunk = grub_memalign_dma32 (1024,
sizeof (struct grub_ahci_cmd_table));
if (!adevs[i]->command_table_chunk)
{
grub_dma_free (adevs[i]->command_list_chunk);
adevs[i] = 0;
continue;
}
adevs[i]->command_list = grub_dma_get_virt (adevs[i]->command_list_chunk);
adevs[i]->command_table = grub_dma_get_virt (adevs[i]->command_table_chunk);
adevs[i]->command_list->command_table_base
= grub_dma_get_phys (adevs[i]->command_table_chunk);
grub_dprintf ("ahci", "found device ahci%d (port %d), command_table = %p, command_list = %p\n",
adevs[i]->num, adevs[i]->port, grub_dma_get_virt (adevs[i]->command_table_chunk),
grub_dma_get_virt (adevs[i]->command_list_chunk));
adevs[i]->hba->ports[adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
}
grub_uint64_t endtime;
endtime = grub_get_time_ms () + 1000;
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
{
grub_dprintf ("ahci", "couldn't stop FR on port %d\n", i);
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
for (i = 0; i < nports; i++)
if (adevs[i])
adevs[i]->hba->ports[adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
endtime = grub_get_time_ms () + 1000;
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
{
grub_dprintf ("ahci", "couldn't stop CR on port %d\n", i);
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
for (i = 0; i < nports; i++)
if (adevs[i])
{
adevs[i]->hba->ports[adevs[i]->port].inten = 0;
adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0;
// adevs[i]->hba->ports[adevs[i]->port].fbs = 0;
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->rfis = grub_memalign_dma32 (4096,
sizeof (struct grub_ahci_received_fis));
grub_memset ((char *) grub_dma_get_virt (adevs[i]->rfis), 0,
sizeof (struct grub_ahci_received_fis));
grub_memset ((char *) grub_dma_get_virt (adevs[i]->command_list_chunk), 0,
sizeof (struct grub_ahci_cmd_head));
grub_memset ((char *) grub_dma_get_virt (adevs[i]->command_table_chunk), 0,
sizeof (struct grub_ahci_cmd_table));
adevs[i]->hba->ports[adevs[i]->port].fis_base = grub_dma_get_phys (adevs[i]->rfis);
adevs[i]->hba->ports[adevs[i]->port].command_list_base
= grub_dma_get_phys (adevs[i]->command_list_chunk);
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_FRE;
}
endtime = grub_get_time_ms () + 1000;
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
{
grub_dprintf ("ahci", "couldn't start FR on port %d\n", i);
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
for (i = 0; i < nports; i++)
if (adevs[i])
{
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
fr_running |= (1 << i);
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP;
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= 1 << 28;
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
}
/* 10ms should actually be enough. */
endtime = grub_get_time_ms () + 100;
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].status & 7) != 3)
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].status & 7) != 3)
{
grub_dprintf ("ahci", "couldn't detect device on port %d\n", i);
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
for (i = 0; i < nports; i++)
if (adevs[i])
{
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP;
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].sata_error = ~0;
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n",
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
}
for (i = 0; i < nports; i++)
if (adevs[i])
{
grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n",
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command
= (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) | 2 | 4;
/* struct grub_disk_ata_pass_through_parms parms2;
grub_memset (&parms2, 0, sizeof (parms2));
parms2.taskfile.cmd = 8;
grub_ahci_readwrite_real (dev, &parms2, 1, 1);*/
}
endtime = grub_get_time_ms () + 10000;
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88))
{
grub_dprintf ("ahci", "port %d is busy\n", i);
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
for (i = 0; i < nports; i++)
if (adevs[i])
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
endtime = grub_get_time_ms () + 1000;
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
{
grub_dprintf ("ahci", "couldn't start CR on port %d\n", i);
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
for (i = 0; i < nports; i++)
if (failed_adevs[i] && (fr_running & (1 << i)))
failed_adevs[i]->hba->ports[failed_adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
endtime = grub_get_time_ms () + 1000;
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (failed_adevs[i] && (fr_running & (1 << i)) && (failed_adevs[i]->hba->ports[failed_adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (failed_adevs[i])
{
grub_dma_free (failed_adevs[i]->command_list_chunk);
grub_dma_free (failed_adevs[i]->command_table_chunk);
grub_dma_free (failed_adevs[i]->rfis);
}
for (i = 0; i < nports; i++)
if (adevs[i])
{
grub_list_push (GRUB_AS_LIST_P (&grub_ahci_devices),
GRUB_AS_LIST (adevs[i]));
}
return 0;
}
static grub_err_t
grub_ahci_initialize (void)
{
grub_pci_iterate (grub_ahci_pciinit, NULL);
return grub_errno;
}
static grub_err_t
grub_ahci_fini_hw (int noreturn __attribute__ ((unused)))
{
struct grub_ahci_device *dev;
for (dev = grub_ahci_devices; dev; dev = dev->next)
{
grub_uint64_t endtime;
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't stop FR\n");
break;
}
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't stop CR\n");
break;
}
grub_dma_free (dev->command_list_chunk);
grub_dma_free (dev->command_table_chunk);
grub_dma_free (dev->rfis);
dev->command_list_chunk = NULL;
dev->command_table_chunk = NULL;
dev->rfis = NULL;
}
return GRUB_ERR_NONE;
}
static int
init_port (struct grub_ahci_device *dev)
reinit_port (struct grub_ahci_device *dev)
{
struct grub_pci_dma_chunk *command_list;
struct grub_pci_dma_chunk *command_table;
@ -254,194 +761,13 @@ init_port (struct grub_ahci_device *dev)
return 1;
}
static int
grub_ahci_pciinit (grub_pci_device_t dev,
grub_pci_id_t pciid __attribute__ ((unused)),
void *data __attribute__ ((unused)))
{
grub_pci_address_t addr;
grub_uint32_t class;
grub_uint32_t bar;
unsigned i, nports;
volatile struct grub_ahci_hba *hba;
/* Read class. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class = grub_pci_read (addr);
/* Check if this class ID matches that of a PCI IDE Controller. */
if (class >> 8 != 0x010601)
return 0;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG5);
bar = grub_pci_read (addr);
if ((bar & (GRUB_PCI_ADDR_SPACE_MASK | GRUB_PCI_ADDR_MEM_TYPE_MASK
| GRUB_PCI_ADDR_MEM_PREFETCH))
!= (GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32))
return 0;
hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK,
sizeof (hba));
if (! (hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_OS_OWNED))
{
grub_uint64_t endtime;
grub_dprintf ("ahci", "Requesting AHCI ownership\n");
hba->bios_handoff = (hba->bios_handoff & ~GRUB_AHCI_BIOS_HANDOFF_RWC)
| GRUB_AHCI_BIOS_HANDOFF_OS_OWNED;
grub_dprintf ("ahci", "Waiting for BIOS to give up ownership\n");
endtime = grub_get_time_ms () + 1000;
while ((hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_BIOS_OWNED)
&& grub_get_time_ms () < endtime);
if (hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_BIOS_OWNED)
{
grub_dprintf ("ahci", "Forcibly taking ownership\n");
hba->bios_handoff = GRUB_AHCI_BIOS_HANDOFF_OS_OWNED;
hba->bios_handoff |= GRUB_AHCI_BIOS_HANDOFF_OS_OWNERSHIP_CHANGED;
}
else
grub_dprintf ("ahci", "AHCI ownership obtained\n");
}
else
grub_dprintf ("ahci", "AHCI is already in OS mode\n");
if (!(hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN))
grub_dprintf ("ahci", "AHCI is in compat mode. Switching\n");
else
grub_dprintf ("ahci", "AHCI is in AHCI mode.\n");
for (i = 0; i < 5; i++)
{
hba->global_control |= GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN;
grub_millisleep (1);
if (hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN)
break;
}
if (i == 5)
{
grub_dprintf ("ahci", "Couldn't put AHCI in AHCI mode\n");
return 0;
}
/*
{
grub_uint64_t endtime;
hba->global_control |= 1;
endtime = grub_get_time_ms () + 1000;
while (hba->global_control & 1)
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't reset AHCI\n");
return 0;
}
}
for (i = 0; i < 5; i++)
{
hba->global_control |= GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN;
grub_millisleep (1);
if (hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN)
break;
}
if (i == 5)
{
grub_dprintf ("ahci", "Couldn't put AHCI in AHCI mode\n");
return 0;
}
*/
nports = (hba->cap & GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1;
grub_dprintf ("ahci", "%d AHCI ports\n", nports);
for (i = 0; i < nports; i++)
{
struct grub_ahci_device *adev;
grub_uint32_t st;
if (!(hba->ports_implemented & (1 << i)))
continue;
grub_dprintf ("ahci", "status %d:%x\n", i, hba->ports[i].status);
/* FIXME: support hotplugging. */
st = hba->ports[i].status;
if ((st & 0xf) != 0x3 && (st & 0xf) != 0x1)
continue;
adev = grub_malloc (sizeof (*adev));
if (!adev)
return 1;
adev->hba = hba;
adev->port = i;
adev->present = 1;
adev->num = numdevs++;
if (init_port (adev))
{
grub_free (adev);
return 1;
}
grub_list_push (GRUB_AS_LIST_P (&grub_ahci_devices),
GRUB_AS_LIST (adev));
}
return 0;
}
static grub_err_t
grub_ahci_initialize (void)
{
grub_pci_iterate (grub_ahci_pciinit, NULL);
return grub_errno;
}
static grub_err_t
grub_ahci_fini_hw (int noreturn __attribute__ ((unused)))
{
struct grub_ahci_device *dev;
for (dev = grub_ahci_devices; dev; dev = dev->next)
{
grub_uint64_t endtime;
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't stop FR\n");
break;
}
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't stop CR\n");
break;
}
grub_dma_free (dev->command_list_chunk);
grub_dma_free (dev->command_table_chunk);
grub_dma_free (dev->rfis);
dev->command_list_chunk = NULL;
dev->command_table_chunk = NULL;
dev->rfis = NULL;
}
return GRUB_ERR_NONE;
}
static grub_err_t
grub_ahci_restore_hw (void)
{
struct grub_ahci_device **pdev;
for (pdev = &grub_ahci_devices; *pdev; pdev = &((*pdev)->next))
if (init_port (*pdev))
if (reinit_port (*pdev))
{
struct grub_ahci_device *odev;
odev = *pdev;
@ -504,10 +830,54 @@ static const int register_map[11] = { 3 /* Features */,
9 /* LBA48 mid */,
10 /* LBA48 high */ };
static grub_err_t
grub_ahci_reset_port (struct grub_ahci_device *dev, int force)
{
grub_uint64_t endtime;
dev->hba->ports[dev->port].sata_error = dev->hba->ports[dev->port].sata_error;
if (force || (dev->hba->ports[dev->port].command_issue & 1)
|| (dev->hba->ports[dev->port].task_file_data & 0x80))
{
struct grub_disk_ata_pass_through_parms parms2;
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't stop CR");
return grub_error (GRUB_ERR_IO, "couldn't stop CR");
}
dev->hba->ports[dev->port].command |= 8;
while (dev->hba->ports[dev->port].command & 8)
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't set CLO\n");
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
return grub_error (GRUB_ERR_IO, "couldn't set CLO");
}
dev->hba->ports[dev->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
while (!(dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't stop CR");
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
return grub_error (GRUB_ERR_IO, "couldn't stop CR");
}
dev->hba->ports[dev->port].sata_error = dev->hba->ports[dev->port].sata_error;
grub_memset (&parms2, 0, sizeof (parms2));
parms2.taskfile.cmd = 8;
return grub_ahci_readwrite_real (dev, &parms2, 1, 1);
}
return GRUB_ERR_NONE;
}
static grub_err_t
grub_ahci_readwrite_real (struct grub_ahci_device *dev,
struct grub_disk_ata_pass_through_parms *parms,
int spinup)
int spinup, int reset)
{
struct grub_pci_dma_chunk *bufc;
grub_uint64_t endtime;
@ -517,25 +887,15 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
if ((dev->hba->ports[dev->port].task_file_data & 0x80))
{
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't stop CR\n");
break;
}
dev->hba->ports[dev->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
endtime = grub_get_time_ms () + (spinup ? 10000 : 1000);
while (!(dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "couldn't start CR\n");
break;
}
}
if (!reset)
grub_ahci_reset_port (dev, 0);
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
dev->hba->ports[dev->port].task_file_data = 0;
dev->hba->ports[dev->port].command_issue = 0;
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
dev->hba->ports[dev->port].sata_error = dev->hba->ports[dev->port].sata_error;
@ -551,10 +911,9 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
dev->hba->ports[dev->port].command |= 8;
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
grub_dprintf ("ahci", "AHCI tfd = %x, CL=%p\n",
dev->hba->ports[dev->port].task_file_data,
dev->command_list);
/* FIXME: support port multipliers. */
dev->command_list[0].config
= (5 << GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT)
@ -564,17 +923,28 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
| (parms->cmdsize ? GRUB_AHCI_CONFIG_ATAPI : 0)
| (parms->write ? GRUB_AHCI_CONFIG_WRITE : GRUB_AHCI_CONFIG_READ)
| (parms->taskfile.cmd == 8 ? (1 << 8) : 0);
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
dev->command_list[0].transfered = 0;
dev->command_list[0].command_table_base
= grub_dma_get_phys (dev->command_table_chunk);
grub_memset ((char *) dev->command_list[0].unused, 0,
sizeof (dev->command_list[0].unused));
grub_memset ((char *) &dev->command_table[0], 0,
sizeof (dev->command_table[0]));
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
if (parms->cmdsize)
grub_memcpy ((char *) dev->command_table[0].command, parms->cmd,
parms->cmdsize);
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
dev->command_table[0].cfis[0] = GRUB_AHCI_FIS_REG_H2D;
dev->command_table[0].cfis[1] = 0x80;
for (i = 0; i < sizeof (parms->taskfile.raw); i++)
@ -593,8 +963,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
dev->command_table[0].prdt[0].data_base = grub_dma_get_phys (bufc);
dev->command_table[0].prdt[0].unused = 0;
dev->command_table[0].prdt[0].size = (parms->size + (parms->size & 1) - 1)
| GRUB_AHCI_INTERRUPT_ON_COMPLETE;
dev->command_table[0].prdt[0].size = (parms->size - 1);
grub_dprintf ("ahci", "PRDT = %" PRIxGRUB_UINT64_T ", %x, %x (%"
PRIuGRUB_SIZE ")\n",
@ -610,11 +979,19 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
grub_dprintf ("ahci", "AHCI command schedulded\n");
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
grub_dprintf ("ahci", "AHCI inten = %x\n",
dev->hba->ports[dev->port].inten);
grub_dprintf ("ahci", "AHCI intstatus = %x\n",
dev->hba->ports[dev->port].intstatus);
dev->hba->ports[dev->port].inten = 0xffffffff;//(1 << 2) | (1 << 5);
dev->hba->ports[dev->port].intstatus = 0xffffffff;//(1 << 2) | (1 << 5);
grub_dprintf ("ahci", "AHCI inten = %x\n",
dev->hba->ports[dev->port].inten);
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
dev->hba->ports[dev->port].command_issue |= 1;
dev->hba->ports[dev->port].sata_active = 1;
dev->hba->ports[dev->port].command_issue = 1;
grub_dprintf ("ahci", "AHCI sig = %x\n", dev->hba->ports[dev->port].sig);
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
@ -623,11 +1000,15 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
while ((dev->hba->ports[dev->port].command_issue & 1))
if (grub_get_time_ms () > endtime)
{
grub_dprintf ("ahci", "AHCI status <%x %x %x>\n",
grub_dprintf ("ahci", "AHCI status <%x %x %x %x>\n",
dev->hba->ports[dev->port].command_issue,
dev->hba->ports[dev->port].sata_active,
dev->hba->ports[dev->port].intstatus,
dev->hba->ports[dev->port].task_file_data);
dev->hba->ports[dev->port].command_issue = 0;
err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out");
if (!reset)
grub_ahci_reset_port (dev, 1);
break;
}
@ -672,7 +1053,7 @@ grub_ahci_readwrite (grub_ata_t disk,
struct grub_disk_ata_pass_through_parms *parms,
int spinup)
{
return grub_ahci_readwrite_real (disk->data, parms, spinup);
return grub_ahci_readwrite_real (disk->data, parms, spinup, 0);
}
static grub_err_t
@ -713,13 +1094,7 @@ static struct grub_preboot *fini_hnd;
GRUB_MOD_INIT(ahci)
{
/* To prevent two drivers operating on the same disks. */
grub_disk_firmware_is_tainted = 1;
if (grub_disk_firmware_fini)
{
grub_disk_firmware_fini ();
grub_disk_firmware_fini = NULL;
}
grub_stop_disk_firmware ();
/* AHCI initialization. */
grub_ahci_initialize ();

View file

@ -95,7 +95,7 @@ grub_arcdisk_iterate_iter (const char *name,
struct grub_arcdisk_iterate_ctx *ctx = data;
if (!(comp->type == GRUB_ARC_COMPONENT_TYPE_DISK
|| comp->type == GRUB_ARC_COMPONENT_TYPE_DISK
|| comp->type == GRUB_ARC_COMPONENT_TYPE_FLOPPY
|| comp->type == GRUB_ARC_COMPONENT_TYPE_TAPE))
return 0;
return ctx->hook (name, ctx->hook_data);
@ -113,7 +113,11 @@ grub_arcdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
return grub_arc_iterate_devs (grub_arcdisk_iterate_iter, &ctx, 1);
}
#ifdef GRUB_CPU_MIPSEL
#define RAW_SUFFIX "partition(0)"
#else
#define RAW_SUFFIX "partition(10)"
#endif
static grub_err_t
reopen (const char *name, int writable)
@ -153,9 +157,7 @@ reopen (const char *name, int writable)
static grub_err_t
grub_arcdisk_open (const char *name, grub_disk_t disk)
{
char *fullname, *optr;
const char *iptr;
int state = 0;
char *fullname;
grub_err_t err;
grub_arc_err_t r;
struct grub_arc_fileinfo info;
@ -163,35 +165,7 @@ grub_arcdisk_open (const char *name, grub_disk_t disk)
if (grub_memcmp (name, "arc/", 4) != 0)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not arc device");
fullname = grub_malloc (2 * grub_strlen (name) + sizeof (RAW_SUFFIX));
if (!fullname)
return grub_errno;
optr = fullname;
for (iptr = name + 4; *iptr; iptr++)
if (state == 0)
{
if (!grub_isdigit (*iptr))
*optr++ = *iptr;
else
{
*optr++ = '(';
*optr++ = *iptr;
state = 1;
}
}
else
{
if (grub_isdigit (*iptr))
*optr++ = *iptr;
else
{
*optr++ = ')';
state = 0;
}
}
if (state)
*optr++ = ')';
grub_memcpy (optr, RAW_SUFFIX, sizeof (RAW_SUFFIX));
fullname = grub_arc_alt_name_to_norm (name, RAW_SUFFIX);
disk->data = fullname;
grub_dprintf ("arcdisk", "opening %s\n", fullname);

View file

@ -382,6 +382,8 @@ grub_ata_real_open (int id, int bus)
err = grub_ata_identify (ata);
if (err)
{
if (!grub_errno)
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATA device");
grub_free (ata);
return NULL;
}

View file

@ -199,16 +199,8 @@ scan_disk (const char *name, int accept_diskfilter)
scan_depth--;
return 0;
}
if (scan_disk_partition_iter (disk, 0, (void *) name))
{
scan_depth--;
return 1;
}
if (grub_partition_iterate (disk, scan_disk_partition_iter, (void *) name))
{
scan_depth--;
return 1;
}
scan_disk_partition_iter (disk, 0, (void *) name);
grub_partition_iterate (disk, scan_disk_partition_iter, (void *) name);
grub_disk_close (disk);
scan_depth--;
return 0;

View file

@ -329,18 +329,28 @@ name_devices (struct grub_efidisk_data *devices)
{
grub_efi_device_path_t *dp;
grub_efi_block_io_media_t *m;
int is_floppy = 0;
dp = d->last_device_path;
if (! dp)
continue;
m = d->block_io->media;
if (m->logical_partition)
if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_ACPI_DEVICE_PATH_TYPE
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)
== GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE)
{
grub_efi_acpi_device_path_t *acpi
= (grub_efi_acpi_device_path_t *) dp;
/* Floppy EISA ID. */
if (acpi->hid == 0x60441d0 || acpi->hid == 0x70041d0
|| acpi->hid == 0x70141d1)
is_floppy = 1;
}
if (is_floppy)
{
/* Only one partition in a non-media device. Assume that this
is a floppy drive. */
#ifdef DEBUG_NAMES
grub_printf ("adding a floppy by guessing: ");
grub_printf ("adding a floppy: ");
grub_efi_print_device_path (d->device_path);
#endif
add_device (&fd_devices, d);
@ -528,9 +538,9 @@ grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused)))
grub_dprintf ("efidisk", "closing %s\n", disk->name);
}
static grub_err_t
grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
static grub_efi_status_t
grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, char *buf, int wr)
{
/* For now, use the disk io interface rather than the block io's. */
struct grub_efidisk_data *d;
@ -540,14 +550,38 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
d = disk->data;
bio = d->block_io;
while (size > 0)
{
grub_size_t len;
len = 0x500;
if (len > size)
len = size;
status = efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio,
bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) len << disk->log_sector_size,
buf);
size -= len;
buf += len << disk->log_sector_size;
sector += len;
if (status != GRUB_EFI_SUCCESS)
return status;
}
return GRUB_EFI_SUCCESS;
}
static grub_err_t
grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_efi_status_t status;
grub_dprintf ("efidisk",
"reading 0x%lx sectors at the sector 0x%llx from %s\n",
(unsigned long) size, (unsigned long long) sector, disk->name);
status = efi_call_5 (bio->read_blocks, bio, bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) size << disk->log_sector_size,
buf);
status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_READ_ERROR,
N_("failure reading sector 0x%llx from `%s'"),
@ -561,22 +595,14 @@ static grub_err_t
grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
grub_size_t size, const char *buf)
{
/* For now, use the disk io interface rather than the block io's. */
struct grub_efidisk_data *d;
grub_efi_block_io_t *bio;
grub_efi_status_t status;
d = disk->data;
bio = d->block_io;
grub_dprintf ("efidisk",
"writing 0x%lx sectors at the sector 0x%llx to %s\n",
(unsigned long) size, (unsigned long long) sector, disk->name);
status = efi_call_5 (bio->write_blocks, bio, bio->media->media_id,
(grub_efi_uint64_t) sector,
(grub_efi_uintn_t) size << disk->log_sector_size,
(void *) buf);
status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_WRITE_ERROR,
N_("failure writing sector 0x%llx to `%s'"),
@ -597,22 +623,27 @@ static struct grub_disk_dev grub_efidisk_dev =
.next = 0
};
void
grub_efidisk_init (void)
{
enumerate_disks ();
grub_disk_dev_register (&grub_efidisk_dev);
}
void
grub_efidisk_fini (void)
{
free_devices (fd_devices);
free_devices (hd_devices);
free_devices (cd_devices);
fd_devices = 0;
hd_devices = 0;
cd_devices = 0;
grub_disk_dev_unregister (&grub_efidisk_dev);
}
void
grub_efidisk_init (void)
{
grub_disk_firmware_fini = grub_efidisk_fini;
enumerate_disks ();
grub_disk_dev_register (&grub_efidisk_dev);
}
/* Some utility functions to map GRUB devices with EFI devices. */
grub_efi_handle_t
grub_efidisk_get_device_handle (grub_disk_t disk)

View file

@ -31,6 +31,8 @@ static grub_ieee1275_ihandle_t last_ihandle;
struct ofdisk_hash_ent
{
char *devpath;
int is_boot;
int is_cdrom;
/* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */
const char *shortest;
@ -69,17 +71,28 @@ ofdisk_hash_add_real (char *devpath)
struct ofdisk_hash_ent *p;
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
p = grub_malloc(sizeof (*p));
p = grub_zalloc (sizeof (*p));
if (!p)
return NULL;
p->devpath = devpath;
p->next = *head;
p->shortest = 0;
*head = p;
return p;
}
static int
check_string_cdrom (const char *str)
{
const char *ptr = grub_strrchr (str, '/');
if (ptr)
ptr++;
else
ptr = str;
return (grub_strncmp (ptr, "cdrom", 5) == 0);
}
static struct ofdisk_hash_ent *
ofdisk_hash_add (char *devpath, char *curcan)
{
@ -92,6 +105,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
if (!curcan)
{
p->shortest = devpath;
if (check_string_cdrom (devpath))
p->is_cdrom = 1;
return p;
}
@ -101,6 +116,9 @@ ofdisk_hash_add (char *devpath, char *curcan)
else
grub_free (curcan);
if (check_string_cdrom (devpath) || check_string_cdrom (curcan))
pcan->is_cdrom = 1;
if (!pcan)
grub_errno = GRUB_ERR_NONE;
else
@ -267,7 +285,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
}
}
if (grub_strncmp (ent->shortest, "cdrom", 5) == 0)
if (!ent->is_boot && ent->is_cdrom)
continue;
{
@ -491,10 +509,44 @@ static struct grub_disk_dev grub_ofdisk_dev =
.next = 0
};
void
grub_ofdisk_init (void)
static void
insert_bootpath (void)
{
grub_disk_dev_register (&grub_ofdisk_dev);
char *bootpath;
grub_ssize_t bootpath_size;
char *type;
if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
&bootpath_size)
|| bootpath_size <= 0)
{
/* Should never happen. */
grub_printf ("/chosen/bootpath property missing!\n");
return;
}
bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
if (! bootpath)
{
grub_print_error ();
return;
}
grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
(grub_size_t) bootpath_size + 1, 0);
bootpath[bootpath_size] = '\0';
/* Transform an OF device path to a GRUB path. */
type = grub_ieee1275_get_device_type (bootpath);
if (!(type && grub_strcmp (type, "network") == 0))
{
struct ofdisk_hash_ent *op;
char *device = grub_ieee1275_get_devname (bootpath);
op = ofdisk_hash_add (device, NULL);
op->is_boot = 1;
}
grub_free (type);
grub_free (bootpath);
}
void
@ -508,6 +560,16 @@ grub_ofdisk_fini (void)
grub_disk_dev_unregister (&grub_ofdisk_dev);
}
void
grub_ofdisk_init (void)
{
grub_disk_firmware_fini = grub_ofdisk_fini;
insert_bootpath ();
grub_disk_dev_register (&grub_ofdisk_dev);
}
grub_err_t
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
{

View file

@ -530,13 +530,7 @@ static struct grub_ata_dev grub_pata_dev =
GRUB_MOD_INIT(ata_pthru)
{
/* To prevent two drivers operating on the same disks. */
grub_disk_firmware_is_tainted = 1;
if (grub_disk_firmware_fini)
{
grub_disk_firmware_fini ();
grub_disk_firmware_fini = NULL;
}
grub_stop_disk_firmware ();
/* ATA initialization. */
grub_pata_initialize ();

View file

@ -293,7 +293,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
grub_uint32_t last_code;
#if FONT_DEBUG >= 2
grub_printf ("load_font_index(sect_length=%d)\n", sect_length);
grub_dprintf ("font", "load_font_index(sect_length=%d)\n", sect_length);
#endif
/* Sanity check: ensure section length is divisible by the entry size. */
@ -321,7 +321,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 2
grub_printf ("num_chars=%d)\n", font->num_chars);
grub_dprintf ("font", "num_chars=%d)\n", font->num_chars);
#endif
last_code = 0;
@ -365,7 +365,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 5
/* Print the 1st 10 characters. */
if (i < 10)
grub_printf ("c=%d o=%d\n", entry->code, entry->offset);
grub_dprintf ("font", "c=%d o=%d\n", entry->code, entry->offset);
#endif
}
@ -422,7 +422,7 @@ read_section_as_short (struct font_file_section *section,
/* Load a font and add it to the beginning of the global font list.
Returns 0 upon success, nonzero upon failure. */
int
grub_font_t
grub_font_load (const char *filename)
{
grub_file_t file = 0;
@ -431,7 +431,7 @@ grub_font_load (const char *filename)
grub_font_t font = 0;
#if FONT_DEBUG >= 1
grub_printf ("add_font(%s)\n", filename);
grub_dprintf ("font", "add_font(%s)\n", filename);
#endif
if (filename[0] == '(' || filename[0] == '/' || filename[0] == '+')
@ -462,7 +462,7 @@ grub_font_load (const char *filename)
goto fail;
#if FONT_DEBUG >= 3
grub_printf ("file opened\n");
grub_dprintf ("font", "file opened\n");
#endif
/* Read the FILE section. It indicates the file format. */
@ -470,7 +470,7 @@ grub_font_load (const char *filename)
goto fail;
#if FONT_DEBUG >= 3
grub_printf ("opened FILE section\n");
grub_dprintf ("font", "opened FILE section\n");
#endif
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE,
sizeof (FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0)
@ -481,7 +481,7 @@ grub_font_load (const char *filename)
}
#if FONT_DEBUG >= 3
grub_printf ("section name ok\n");
grub_dprintf ("font", "section name ok\n");
#endif
if (section.length != 4)
{
@ -492,14 +492,14 @@ grub_font_load (const char *filename)
}
#if FONT_DEBUG >= 3
grub_printf ("section length ok\n");
grub_dprintf ("font", "section length ok\n");
#endif
/* Check the file format type code. */
if (grub_file_read (file, magic, 4) != 4)
goto fail;
#if FONT_DEBUG >= 3
grub_printf ("read magic ok\n");
grub_dprintf ("font", "read magic ok\n");
#endif
if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0)
@ -510,7 +510,7 @@ grub_font_load (const char *filename)
}
#if FONT_DEBUG >= 3
grub_printf ("compare magic ok\n");
grub_dprintf ("font", "compare magic ok\n");
#endif
/* Allocate the font object. */
@ -522,7 +522,7 @@ grub_font_load (const char *filename)
font->file = file;
#if FONT_DEBUG >= 3
grub_printf ("allocate font ok; loading font info\n");
grub_dprintf ("font", "allocate font ok; loading font info\n");
#endif
/* Load the font information. */
@ -537,7 +537,7 @@ grub_font_load (const char *filename)
}
#if FONT_DEBUG >= 2
grub_printf ("opened section %c%c%c%c ok\n",
grub_dprintf ("font", "opened section %c%c%c%c ok\n",
section.name[0], section.name[1],
section.name[2], section.name[3]);
#endif
@ -621,7 +621,7 @@ grub_font_load (const char *filename)
{
/* Unhandled section type, simply skip past it. */
#if FONT_DEBUG >= 3
grub_printf ("Unhandled section type, skipping.\n");
grub_dprintf ("font", "Unhandled section type, skipping.\n");
#endif
grub_off_t section_end = grub_file_tell (file) + section.length;
if ((int) grub_file_seek (file, section_end) == -1)
@ -636,7 +636,7 @@ grub_font_load (const char *filename)
}
#if FONT_DEBUG >= 1
grub_printf ("Loaded font `%s'.\n"
grub_dprintf ("font", "Loaded font `%s'.\n"
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
font->name,
font->ascent, font->descent,
@ -657,7 +657,7 @@ grub_font_load (const char *filename)
if (register_font (font) != 0)
goto fail;
return 0;
return font;
fail:
if (file)
@ -666,7 +666,7 @@ fail:
font->file = 0;
free_font (font);
return 1;
return 0;
}
/* Read a 16-bit big-endian integer from FILE, convert it to native byte
@ -1064,6 +1064,7 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
return best_glyph;
}
#if 0
static struct grub_font_glyph *
grub_font_dup_glyph (struct grub_font_glyph *glyph)
{
@ -1075,6 +1076,7 @@ grub_font_dup_glyph (struct grub_font_glyph *glyph)
+ (glyph->width * glyph->height + 7) / 8);
return ret;
}
#endif
/* FIXME: suboptimal. */
static void
@ -1202,6 +1204,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
signed above_leftx, above_lefty;
signed below_rightx, below_righty;
signed min_devwidth = 0;
const struct grub_unicode_combining *comb;
if (glyph)
glyph->device_width = main_glyph->device_width;
@ -1222,6 +1225,8 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
below_rightx = ctx.bounds.x + ctx.bounds.width;
below_righty = ctx.bounds.y;
comb = grub_unicode_get_comb (glyph_id);
for (i = 0; i < glyph_id->ncomb; i++)
{
grub_int16_t space = 0;
@ -1232,10 +1237,10 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
continue;
targetx = (ctx.bounds.width - combining_glyphs[i]->width) / 2 + ctx.bounds.x;
/* CGJ is to avoid diacritics reordering. */
if (glyph_id->combining[i].code
if (comb[i].code
== GRUB_UNICODE_COMBINING_GRAPHEME_JOINER)
continue;
switch (glyph_id->combining[i].type)
switch (comb[i].type)
{
case GRUB_UNICODE_COMB_OVERLAY:
do_blit (combining_glyphs[i],
@ -1361,7 +1366,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
break;
case GRUB_UNICODE_COMB_MN:
switch (glyph_id->combining[i].code)
switch (comb[i].code)
{
case GRUB_UNICODE_THAANA_ABAFILI:
case GRUB_UNICODE_THAANA_AABAAFILI:
@ -1410,17 +1415,14 @@ static struct grub_font_glyph *
grub_font_construct_dry_run (grub_font_t hinted_font,
const struct grub_unicode_glyph *glyph_id,
struct grub_video_signed_rect *bounds,
struct grub_font_glyph ***combining_glyphs_out,
struct grub_font_glyph **combining_glyphs,
int *device_width)
{
struct grub_font_glyph *main_glyph = NULL;
struct grub_font_glyph **combining_glyphs;
grub_uint32_t desired_attributes = 0;
unsigned i;
grub_uint32_t base = glyph_id->base;
if (combining_glyphs_out)
*combining_glyphs_out = NULL;
const struct grub_unicode_combining *comb;
if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED)
desired_attributes |= GRUB_FONT_CODE_RIGHT_JOINED;
@ -1428,11 +1430,12 @@ grub_font_construct_dry_run (grub_font_t hinted_font,
if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED)
desired_attributes |= GRUB_FONT_CODE_LEFT_JOINED;
comb = grub_unicode_get_comb (glyph_id);
if (base == 'i' || base == 'j')
{
for (i = 0; i < glyph_id->ncomb; i++)
if (glyph_id->combining[i].type == GRUB_UNICODE_STACK_ABOVE)
if (comb[i].type == GRUB_UNICODE_STACK_ABOVE)
break;
if (i < glyph_id->ncomb && base == 'i')
base = GRUB_UNICODE_DOTLESS_LOWERCASE_I;
@ -1461,8 +1464,6 @@ grub_font_construct_dry_run (grub_font_t hinted_font,
if (!glyph_id->ncomb && !glyph_id->attributes)
return main_glyph;
combining_glyphs = grub_malloc (sizeof (combining_glyphs[0])
* glyph_id->ncomb);
if (glyph_id->ncomb && !combining_glyphs)
{
grub_errno = GRUB_ERR_NONE;
@ -1472,18 +1473,33 @@ grub_font_construct_dry_run (grub_font_t hinted_font,
for (i = 0; i < glyph_id->ncomb; i++)
combining_glyphs[i]
= grub_font_get_glyph_with_fallback (main_glyph->font,
glyph_id->combining[i].code);
comb[i].code);
blit_comb (glyph_id, NULL, bounds, main_glyph, combining_glyphs,
device_width);
if (combining_glyphs_out)
*combining_glyphs_out = combining_glyphs;
else
grub_free (combining_glyphs);
return main_glyph;
}
static struct grub_font_glyph **render_combining_glyphs = 0;
static grub_size_t render_max_comb_glyphs = 0;
static void
ensure_comb_space (const struct grub_unicode_glyph *glyph_id)
{
if (glyph_id->ncomb <= render_max_comb_glyphs)
return;
render_max_comb_glyphs = 2 * glyph_id->ncomb;
if (render_max_comb_glyphs < 8)
render_max_comb_glyphs = 8;
grub_free (render_combining_glyphs);
render_combining_glyphs = grub_malloc (render_max_comb_glyphs
* sizeof (render_combining_glyphs[0]));
if (!render_combining_glyphs)
grub_errno = 0;
}
int
grub_font_get_constructed_device_width (grub_font_t hinted_font,
const struct grub_unicode_glyph
@ -1491,8 +1507,11 @@ grub_font_get_constructed_device_width (grub_font_t hinted_font,
{
int ret;
struct grub_font_glyph *main_glyph;
ensure_comb_space (glyph_id);
main_glyph = grub_font_construct_dry_run (hinted_font, glyph_id, NULL,
NULL, &ret);
render_combining_glyphs, &ret);
if (!main_glyph)
return unknown_glyph->device_width;
return ret;
@ -1504,26 +1523,42 @@ grub_font_construct_glyph (grub_font_t hinted_font,
{
struct grub_font_glyph *main_glyph;
struct grub_video_signed_rect bounds;
struct grub_font_glyph *glyph;
struct grub_font_glyph **combining_glyphs;
static struct grub_font_glyph *glyph = 0;
static grub_size_t max_glyph_size = 0;
ensure_comb_space (glyph_id);
main_glyph = grub_font_construct_dry_run (hinted_font, glyph_id,
&bounds, &combining_glyphs, NULL);
&bounds, render_combining_glyphs,
NULL);
if (!main_glyph)
return grub_font_dup_glyph (unknown_glyph);
return unknown_glyph;
if (!combining_glyphs)
return grub_font_dup_glyph (main_glyph);
if (!render_combining_glyphs && glyph_id->ncomb)
return main_glyph;
glyph =
grub_zalloc (sizeof (*glyph) + (bounds.width * bounds.height + 7) / 8);
if (!glyph_id->ncomb && !glyph_id->attributes)
return main_glyph;
if (max_glyph_size < sizeof (*glyph) + (bounds.width * bounds.height + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT)
{
grub_free (glyph);
max_glyph_size = (sizeof (*glyph) + (bounds.width * bounds.height + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT) * 2;
if (max_glyph_size < 8)
max_glyph_size = 8;
glyph = grub_malloc (max_glyph_size);
}
if (!glyph)
{
grub_errno = GRUB_ERR_NONE;
return grub_font_dup_glyph (main_glyph);
return main_glyph;
}
grub_memset (glyph, 0, sizeof (*glyph)
+ (bounds.width * bounds.height
+ GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT);
glyph->font = main_glyph->font;
glyph->width = bounds.width;
glyph->height = bounds.height;
@ -1542,7 +1577,7 @@ grub_font_construct_glyph (grub_font_t hinted_font,
(glyph->height + glyph->offset_y)
- (main_glyph->height + main_glyph->offset_y));
blit_comb (glyph_id, glyph, NULL, main_glyph, combining_glyphs, NULL);
blit_comb (glyph_id, glyph, NULL, main_glyph, render_combining_glyphs, NULL);
return glyph;
}

View file

@ -32,7 +32,7 @@ loadfont_command (grub_command_t cmd __attribute__ ((unused)),
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
while (argc--)
if (grub_font_load (*args++) != 0)
if (grub_font_load (*args++) == 0)
{
if (!grub_errno)
return grub_error (GRUB_ERR_BAD_FONT, "invalid font");

View file

@ -19,6 +19,7 @@
/* HFS+ is documented at http://developer.apple.com/technotes/tn/tn1150.html */
#define grub_fshelp_node grub_hfsplus_file
#include <grub/err.h>
#include <grub/file.h>
#include <grub/mm.h>
@ -29,6 +30,7 @@
#include <grub/fshelp.h>
#include <grub/hfs.h>
#include <grub/charset.h>
#include <grub/hfsplus.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -36,42 +38,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define GRUB_HFSPLUSX_MAGIC 0x4858
#define GRUB_HFSPLUS_SBLOCK 2
/* A HFS+ extent. */
struct grub_hfsplus_extent
{
/* The first block of a file on disk. */
grub_uint32_t start;
/* The amount of blocks described by this extent. */
grub_uint32_t count;
} __attribute__ ((packed));
/* The descriptor of a fork. */
struct grub_hfsplus_forkdata
{
grub_uint64_t size;
grub_uint32_t clumpsize;
grub_uint32_t blocks;
struct grub_hfsplus_extent extents[8];
} __attribute__ ((packed));
/* The HFS+ Volume Header. */
struct grub_hfsplus_volheader
{
grub_uint16_t magic;
grub_uint16_t version;
grub_uint32_t attributes;
grub_uint8_t unused1[12];
grub_uint32_t utime;
grub_uint8_t unused2[16];
grub_uint32_t blksize;
grub_uint8_t unused3[60];
grub_uint64_t num_serial;
struct grub_hfsplus_forkdata allocations_file;
struct grub_hfsplus_forkdata extents_file;
struct grub_hfsplus_forkdata catalog_file;
struct grub_hfsplus_forkdata attrib_file;
struct grub_hfsplus_forkdata startup_file;
} __attribute__ ((packed));
/* The type of node. */
enum grub_hfsplus_btnode_type
@ -82,16 +48,6 @@ enum grub_hfsplus_btnode_type
GRUB_HFSPLUS_BTNODE_TYPE_MAP = 2,
};
struct grub_hfsplus_btnode
{
grub_uint32_t next;
grub_uint32_t prev;
grub_int8_t type;
grub_uint8_t height;
grub_uint16_t count;
grub_uint16_t unused;
} __attribute__ ((packed));
/* The header of a HFS+ B+ Tree. */
struct grub_hfsplus_btheader
{
@ -111,35 +67,6 @@ struct grub_hfsplus_btheader
grub_uint32_t attributes;
} __attribute__ ((packed));
/* The on disk layout of a catalog key. */
struct grub_hfsplus_catkey
{
grub_uint16_t keylen;
grub_uint32_t parent;
grub_uint16_t namelen;
grub_uint16_t name[30];
} __attribute__ ((packed));
/* The on disk layout of an extent overflow file key. */
struct grub_hfsplus_extkey
{
grub_uint16_t keylen;
grub_uint8_t type;
grub_uint8_t unused;
grub_uint32_t fileid;
grub_uint32_t start;
} __attribute__ ((packed));
struct grub_hfsplus_key
{
union
{
struct grub_hfsplus_extkey extkey;
struct grub_hfsplus_catkey catkey;
grub_uint16_t keylen;
};
} __attribute__ ((packed));
struct grub_hfsplus_catfile
{
grub_uint16_t type;
@ -162,9 +89,13 @@ struct grub_hfsplus_catfile
#define GRUB_HFSPLUS_FILEMODE_SYMLINK 0120000
/* Some pre-defined file IDs. */
#define GRUB_HFSPLUS_FILEID_ROOTDIR 2
#define GRUB_HFSPLUS_FILEID_OVERFLOW 3
#define GRUB_HFSPLUS_FILEID_CATALOG 4
enum
{
GRUB_HFSPLUS_FILEID_ROOTDIR = 2,
GRUB_HFSPLUS_FILEID_OVERFLOW = 3,
GRUB_HFSPLUS_FILEID_CATALOG = 4,
GRUB_HFSPLUS_FILEID_ATTR = 8
};
enum grub_hfsplus_filetype
{
@ -177,98 +108,15 @@ enum grub_hfsplus_filetype
#define GRUB_HFSPLUSX_BINARYCOMPARE 0xBC
#define GRUB_HFSPLUSX_CASEFOLDING 0xCF
/* Internal representation of a catalog key. */
struct grub_hfsplus_catkey_internal
{
grub_uint32_t parent;
const grub_uint16_t *name;
grub_size_t namelen;
};
/* Internal representation of an extent overflow key. */
struct grub_hfsplus_extkey_internal
{
grub_uint32_t fileid;
grub_uint8_t type;
grub_uint32_t start;
};
struct grub_hfsplus_key_internal
{
union
{
struct grub_hfsplus_extkey_internal extkey;
struct grub_hfsplus_catkey_internal catkey;
};
};
struct grub_fshelp_node
{
struct grub_hfsplus_data *data;
struct grub_hfsplus_extent extents[8];
grub_uint64_t size;
grub_uint32_t fileid;
grub_int32_t mtime;
};
struct grub_hfsplus_btree
{
grub_uint32_t root;
grub_size_t nodesize;
/* Catalog file node. */
struct grub_fshelp_node file;
};
/* Information about a "mounted" HFS+ filesystem. */
struct grub_hfsplus_data
{
struct grub_hfsplus_volheader volheader;
grub_disk_t disk;
unsigned int log2blksize;
struct grub_hfsplus_btree catalog_tree;
struct grub_hfsplus_btree extoverflow_tree;
struct grub_fshelp_node dirroot;
struct grub_fshelp_node opened_file;
/* This is the offset into the physical disk for an embedded HFS+
filesystem (one inside a plain HFS wrapper). */
grub_disk_addr_t embedded_offset;
int case_sensitive;
};
static grub_dl_t my_mod;
/* Return the offset of the record with the index INDEX, in the node
NODE which is part of the B+ tree BTREE. */
static inline grub_off_t
grub_hfsplus_btree_recoffset (struct grub_hfsplus_btree *btree,
struct grub_hfsplus_btnode *node, int index)
{
char *cnode = (char *) node;
void *recptr;
recptr = (&cnode[btree->nodesize - index * sizeof (grub_uint16_t) - 2]);
return grub_be_to_cpu16 (grub_get_unaligned16 (recptr));
}
/* Return a pointer to the record with the index INDEX, in the node
NODE which is part of the B+ tree BTREE. */
static inline struct grub_hfsplus_key *
grub_hfsplus_btree_recptr (struct grub_hfsplus_btree *btree,
struct grub_hfsplus_btnode *node, int index)
{
char *cnode = (char *) node;
grub_off_t offset;
offset = grub_hfsplus_btree_recoffset (btree, node, index);
return (struct grub_hfsplus_key *) &cnode[offset];
}
grub_err_t (*grub_hfsplus_open_compressed) (struct grub_fshelp_node *node);
grub_ssize_t (*grub_hfsplus_read_compressed) (struct grub_hfsplus_file *node,
grub_off_t pos,
grub_size_t len,
char *buf);
/* Find the extent that points to FILEBLOCK. If it is not in one of
the 8 extents described by EXTENT, return -1. In that case set
@ -292,14 +140,6 @@ grub_hfsplus_find_block (struct grub_hfsplus_extent *extent,
return 0xffffffffffffffffULL;
}
static grub_err_t
grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
struct grub_hfsplus_key_internal *key,
int (*compare_keys) (struct grub_hfsplus_key *keya,
struct grub_hfsplus_key_internal *keyb),
struct grub_hfsplus_btnode **matchnode,
grub_off_t *keyoffset);
static int grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya,
struct grub_hfsplus_key_internal *keyb);
@ -310,7 +150,8 @@ grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{
struct grub_hfsplus_btnode *nnode = 0;
grub_disk_addr_t blksleft = fileblock;
struct grub_hfsplus_extent *extents = &node->extents[0];
struct grub_hfsplus_extent *extents = node->compressed
? &node->resource_extents[0] : &node->extents[0];
while (1)
{
@ -344,10 +185,11 @@ grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
extoverflow.extkey.fileid = node->fileid;
extoverflow.extkey.type = 0;
extoverflow.extkey.start = fileblock - blksleft;
extoverflow.extkey.type = node->compressed ? 0xff : 0;
if (grub_hfsplus_btree_search (&node->data->extoverflow_tree,
&extoverflow,
grub_hfsplus_cmp_extkey, &nnode, &ptr))
grub_hfsplus_cmp_extkey, &nnode, &ptr)
|| !nnode)
{
grub_error (GRUB_ERR_READ_ERROR,
"no block found for the file id 0x%x and the block offset 0x%x",
@ -373,7 +215,7 @@ grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
/* Read LEN bytes from the file described by DATA starting with byte
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_ssize_t
grub_hfsplus_read_file (grub_fshelp_node_t node,
grub_disk_read_hook_t read_hook, void *read_hook_data,
grub_off_t pos, grub_size_t len, char *buf)
@ -460,15 +302,27 @@ grub_hfsplus_mount (grub_disk_t disk)
/* Make a new node for the catalog tree. */
data->catalog_tree.file.data = data;
data->catalog_tree.file.fileid = GRUB_HFSPLUS_FILEID_CATALOG;
data->catalog_tree.file.compressed = 0;
grub_memcpy (&data->catalog_tree.file.extents,
data->volheader.catalog_file.extents,
sizeof data->volheader.catalog_file.extents);
data->catalog_tree.file.size =
grub_be_to_cpu64 (data->volheader.catalog_file.size);
data->attr_tree.file.data = data;
data->attr_tree.file.fileid = GRUB_HFSPLUS_FILEID_ATTR;
grub_memcpy (&data->attr_tree.file.extents,
data->volheader.attr_file.extents,
sizeof data->volheader.attr_file.extents);
data->attr_tree.file.size =
grub_be_to_cpu64 (data->volheader.attr_file.size);
data->attr_tree.file.compressed = 0;
/* Make a new node for the extent overflow file. */
data->extoverflow_tree.file.data = data;
data->extoverflow_tree.file.fileid = GRUB_HFSPLUS_FILEID_OVERFLOW;
data->extoverflow_tree.file.compressed = 0;
grub_memcpy (&data->extoverflow_tree.file.extents,
data->volheader.extents_file.extents,
sizeof data->volheader.catalog_file.extents);
@ -501,6 +355,20 @@ grub_hfsplus_mount (grub_disk_t disk)
data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0,
sizeof (struct grub_hfsplus_btnode),
sizeof (header), (char *) &header) <= 0)
{
grub_errno = 0;
data->attr_tree.root = 0;
data->attr_tree.nodesize = 0;
}
else
{
data->attr_tree.root = grub_be_to_cpu32 (header.root);
data->attr_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
}
data->dirroot.data = data;
data->dirroot.fileid = GRUB_HFSPLUS_FILEID_ROOTDIR;
@ -586,6 +454,12 @@ grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya,
return 1;
if (extkey_a->type < extkey_b->type)
return -1;
if (extkey_a->type > extkey_b->type)
return +1;
if (extkey_a->type < extkey_b->type)
return -1;
akey = grub_be_to_cpu32 (extkey_a->start);
if (akey > extkey_b->start)
@ -668,7 +542,7 @@ grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
keys using the function COMPARE_KEYS. When a match is found,
return the node in MATCHNODE and a pointer to the data in this node
in KEYOFFSET. MATCHNODE should be freed by the caller. */
static grub_err_t
grub_err_t
grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
struct grub_hfsplus_key_internal *key,
int (*compare_keys) (struct grub_hfsplus_key *keya,
@ -683,6 +557,12 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
grub_uint64_t save_node;
grub_uint64_t node_count = 0;
if (!btree->nodesize)
{
*matchnode = 0;
return 0;
}
node = grub_malloc (btree->nodesize);
if (! node)
return grub_errno;
@ -760,7 +640,7 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
{
*matchnode = 0;
grub_free (node);
return 1;
return 0;
}
}
}
@ -872,11 +752,17 @@ list_nodes (void *record, void *hook_arg)
if (!node)
return 1;
node->data = ctx->dir->data;
node->compressed = 0;
node->cbuf = 0;
node->compress_index = 0;
grub_memcpy (node->extents, fileinfo->data.extents,
sizeof (node->extents));
grub_memcpy (node->resource_extents, fileinfo->resource.extents,
sizeof (node->resource_extents));
node->mtime = grub_be_to_cpu32 (fileinfo->mtime) - 2082844800;
node->size = grub_be_to_cpu64 (fileinfo->data.size);
node->resource_size = grub_be_to_cpu64 (fileinfo->resource.size);
node->fileid = grub_be_to_cpu32 (fileinfo->fileid);
ctx->ret = ctx->hook (filename, type, node, ctx->hook_data);
@ -919,7 +805,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
/* First lookup the first entry. */
if (grub_hfsplus_btree_search (&dir->data->catalog_tree, &intern,
grub_hfsplus_cmp_catkey, &node, &ptr))
grub_hfsplus_cmp_catkey, &node, &ptr)
|| !node)
return 0;
/* Iterate over all entries in this directory. */
@ -950,6 +837,14 @@ grub_hfsplus_open (struct grub_file *file, const char *name)
if (grub_errno)
goto fail;
if (grub_hfsplus_open_compressed)
{
grub_err_t err;
err = grub_hfsplus_open_compressed (fdiro);
if (err)
goto fail;
}
file->size = fdiro->size;
data->opened_file = *fdiro;
grub_free (fdiro);
@ -973,7 +868,13 @@ grub_hfsplus_open (struct grub_file *file, const char *name)
static grub_err_t
grub_hfsplus_close (grub_file_t file)
{
grub_free (file->data);
struct grub_hfsplus_data *data =
(struct grub_hfsplus_data *) file->data;
grub_free (data->opened_file.cbuf);
grub_free (data->opened_file.compress_index);
grub_free (data);
grub_dl_unref (my_mod);
@ -987,6 +888,10 @@ grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len)
struct grub_hfsplus_data *data =
(struct grub_hfsplus_data *) file->data;
if (grub_hfsplus_read_compressed && data->opened_file.compressed)
return grub_hfsplus_read_compressed (&data->opened_file,
file->offset, len, buf);
return grub_hfsplus_read_file (&data->opened_file,
file->read_hook, file->read_hook_data,
file->offset, len, buf);
@ -1076,7 +981,8 @@ grub_hfsplus_label (grub_device_t device, char **label)
/* First lookup the first entry. */
if (grub_hfsplus_btree_search (&data->catalog_tree, &intern,
grub_hfsplus_cmp_catkey_id, &node, &ptr))
grub_hfsplus_cmp_catkey_id, &node, &ptr)
|| !node)
{
grub_free (data);
return 0;

302
grub-core/fs/hfspluscomp.c Normal file
View file

@ -0,0 +1,302 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/* HFS+ is documented at http://developer.apple.com/technotes/tn/tn1150.html */
#include <grub/hfsplus.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/deflate.h>
GRUB_MOD_LICENSE ("GPLv3+");
/* big-endian. */
struct grub_hfsplus_compress_header1
{
grub_uint32_t header_size;
grub_uint32_t end_descriptor_offset;
grub_uint32_t total_compressed_size_including_seek_blocks_and_header2;
grub_uint32_t value_0x32;
grub_uint8_t unused[0xf0];
} __attribute__ ((packed));
/* big-endian. */
struct grub_hfsplus_compress_header2
{
grub_uint32_t total_compressed_size_including_seek_blocks;
} __attribute__ ((packed));
/* little-endian. */
struct grub_hfsplus_compress_header3
{
grub_uint32_t num_chunks;
} __attribute__ ((packed));
/* little-endian. */
struct grub_hfsplus_compress_block_descriptor
{
grub_uint32_t offset;
grub_uint32_t size;
};
struct grub_hfsplus_compress_end_descriptor
{
grub_uint8_t always_the_same[50];
} __attribute__ ((packed));
struct grub_hfsplus_attr_header
{
grub_uint8_t unused[3];
grub_uint8_t type;
grub_uint32_t unknown[1];
grub_uint64_t size;
} __attribute__ ((packed));
struct grub_hfsplus_compress_attr
{
grub_uint32_t magic;
grub_uint32_t type;
grub_uint32_t uncompressed_inline_size;
grub_uint32_t always_0;
} __attribute__ ((packed));
enum
{
HFSPLUS_COMPRESSION_INLINE = 3,
HFSPLUS_COMPRESSION_RESOURCE = 4
};
static int
grub_hfsplus_cmp_attrkey (struct grub_hfsplus_key *keya,
struct grub_hfsplus_key_internal *keyb)
{
struct grub_hfsplus_attrkey *attrkey_a = &keya->attrkey;
struct grub_hfsplus_attrkey_internal *attrkey_b = &keyb->attrkey;
grub_uint32_t aparent = grub_be_to_cpu32 (attrkey_a->cnid);
grub_size_t len;
int diff;
if (aparent > attrkey_b->cnid)
return 1;
if (aparent < attrkey_b->cnid)
return -1;
len = grub_be_to_cpu16 (attrkey_a->namelen);
if (len > attrkey_b->namelen)
len = attrkey_b->namelen;
/* Since it's big-endian memcmp gives the same result as manually comparing
uint16_t but may be faster. */
diff = grub_memcmp (attrkey_a->name, attrkey_b->name,
len * sizeof (attrkey_a->name[0]));
if (diff == 0)
diff = grub_be_to_cpu16 (attrkey_a->namelen) - attrkey_b->namelen;
return diff;
}
#define HFSPLUS_COMPRESS_BLOCK_SIZE 65536
static grub_ssize_t
hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
grub_off_t pos, grub_size_t len, char *buf)
{
char *tmp_buf = 0;
grub_size_t len0 = len;
if (node->compressed == 1)
{
grub_memcpy (buf, node->cbuf + pos, len);
return len;
}
while (len)
{
grub_uint32_t block = pos / HFSPLUS_COMPRESS_BLOCK_SIZE;
grub_size_t curlen = HFSPLUS_COMPRESS_BLOCK_SIZE
- (pos % HFSPLUS_COMPRESS_BLOCK_SIZE);
if (curlen > len)
curlen = len;
if (node->cbuf_block != block)
{
grub_uint32_t sz = grub_le_to_cpu32 (node->compress_index[block].size);
grub_size_t ts;
if (!tmp_buf)
tmp_buf = grub_malloc (HFSPLUS_COMPRESS_BLOCK_SIZE);
if (!tmp_buf)
return -1;
if (grub_hfsplus_read_file (node, 0, 0,
grub_le_to_cpu32 (node->compress_index[block].start) + 0x104,
sz, tmp_buf)
!= (grub_ssize_t) sz)
{
grub_free (tmp_buf);
return -1;
}
ts = HFSPLUS_COMPRESS_BLOCK_SIZE;
if (ts > node->size - (pos & ~(HFSPLUS_COMPRESS_BLOCK_SIZE)))
ts = node->size - (pos & ~(HFSPLUS_COMPRESS_BLOCK_SIZE));
if (grub_zlib_decompress (tmp_buf, sz, 0,
node->cbuf, ts) < 0)
{
grub_free (tmp_buf);
return -1;
}
node->cbuf_block = block;
}
grub_memcpy (buf, node->cbuf + (pos % HFSPLUS_COMPRESS_BLOCK_SIZE),
curlen);
buf += curlen;
pos += curlen;
len -= curlen;
}
grub_free (tmp_buf);
return len0;
}
static grub_err_t
hfsplus_open_compressed_real (struct grub_hfsplus_file *node)
{
grub_err_t err;
struct grub_hfsplus_btnode *attr_node;
grub_off_t attr_off;
struct grub_hfsplus_key_internal key;
struct grub_hfsplus_attr_header *attr_head;
struct grub_hfsplus_compress_attr *cmp_head;
#define c grub_cpu_to_be16_compile_time
const grub_uint16_t compress_attr_name[] =
{
c('c'), c('o'), c('m'), c('.'), c('a'), c('p'), c('p'), c('l'), c('e'),
c('.'), c('d'), c('e'), c('c'), c('m'), c('p'), c('f'), c('s') };
#undef c
if (node->size)
return 0;
key.attrkey.cnid = node->fileid;
key.attrkey.namelen = sizeof (compress_attr_name) / sizeof (compress_attr_name[0]);
key.attrkey.name = compress_attr_name;
err = grub_hfsplus_btree_search (&node->data->attr_tree, &key,
grub_hfsplus_cmp_attrkey,
&attr_node, &attr_off);
if (err || !attr_node)
{
grub_errno = 0;
return 0;
}
attr_head = (struct grub_hfsplus_attr_header *)
((char *) grub_hfsplus_btree_recptr (&node->data->attr_tree,
attr_node, attr_off)
+ sizeof (struct grub_hfsplus_attrkey) + sizeof (compress_attr_name));
if (attr_head->type != 0x10
|| !(attr_head->size & grub_cpu_to_be64_compile_time(~0xfULL)))
{
grub_free (attr_node);
return 0;
}
cmp_head = (struct grub_hfsplus_compress_attr *) (attr_head + 1);
if (cmp_head->magic != grub_cpu_to_be32_compile_time (0x66706d63))
{
grub_free (attr_node);
return 0;
}
node->size = grub_le_to_cpu32 (cmp_head->uncompressed_inline_size);
if (cmp_head->type == grub_cpu_to_le32_compile_time (HFSPLUS_COMPRESSION_RESOURCE))
{
grub_uint32_t index_size;
node->compressed = 2;
if (grub_hfsplus_read_file (node, 0, 0,
0x104, sizeof (index_size),
(char *) &index_size)
!= 4)
{
node->compressed = 0;
grub_free (attr_node);
grub_errno = 0;
return 0;
}
node->compress_index_size = grub_le_to_cpu32 (index_size);
node->compress_index = grub_malloc (node->compress_index_size
* sizeof (node->compress_index[0]));
if (!node->compress_index)
{
node->compressed = 0;
grub_free (attr_node);
return grub_errno;
}
if (grub_hfsplus_read_file (node, 0, 0,
0x104 + sizeof (index_size),
node->compress_index_size
* sizeof (node->compress_index[0]),
(char *) node->compress_index)
!= (grub_ssize_t) (node->compress_index_size
* sizeof (node->compress_index[0])))
{
node->compressed = 0;
grub_free (attr_node);
grub_free (node->compress_index);
grub_errno = 0;
return 0;
}
node->cbuf_block = -1;
node->cbuf = grub_malloc (HFSPLUS_COMPRESS_BLOCK_SIZE);
grub_free (attr_node);
if (!node->cbuf)
{
node->compressed = 0;
grub_free (node->compress_index);
return grub_errno;
}
return 0;
}
if (cmp_head->type != HFSPLUS_COMPRESSION_INLINE)
{
grub_free (attr_node);
return 0;
}
node->cbuf = grub_malloc (node->size);
if (!node->cbuf)
return grub_errno;
if (grub_zlib_decompress ((char *) (cmp_head + 1),
grub_cpu_to_be64 (attr_head->size)
- sizeof (*cmp_head), 0,
node->cbuf, node->size) < 0)
return grub_errno;
node->compressed = 1;
return 0;
}
GRUB_MOD_INIT(hfspluscomp)
{
grub_hfsplus_open_compressed = hfsplus_open_compressed_real;
grub_hfsplus_read_compressed = hfsplus_read_compressed_real;
}
GRUB_MOD_FINI(hfspluscomp)
{
grub_hfsplus_open_compressed = 0;
grub_hfsplus_read_compressed = 0;
}

View file

@ -263,8 +263,8 @@ algo_decrypt (grub_crypto_cipher_handle_t cipher, grub_uint64_t algo,
return grub_gcm_decrypt (cipher, out, in, psize, mac_out, nonce,
15 - l, m);
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "algorithm %"
PRIuGRUB_UINT64_T " is not supported yet", algo);
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "algorithm %lld is not supported yet",
(long long) algo);
}
}

View file

@ -59,7 +59,7 @@ EOF
| grep -v '^#' \
| sed -n \
-e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/ {"\1", \1, 1},/;p;}' \
-e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", \&\1, 0},/;p;}' \
-e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", (void *) \&\1, 0},/;p;}' \
| sort -u
cat <<EOF

View file

@ -355,19 +355,30 @@ grub_mofile_open_lang (struct grub_gettext_context *ctx,
return grub_errno;
err = grub_mofile_open (ctx, mo_file);
grub_free (mo_file);
/* Will try adding .gz as well. */
if (err)
{
char *mo_file_old;
grub_errno = GRUB_ERR_NONE;
mo_file_old = mo_file;
mo_file = grub_xasprintf ("%s.gz", mo_file);
grub_free (mo_file_old);
mo_file = grub_xasprintf ("%s%s/%s.mo.gz", part1, part2, locale);
if (!mo_file)
return grub_errno;
err = grub_mofile_open (ctx, mo_file);
grub_free (mo_file);
}
/* Will try adding .gmo as well. */
if (err)
{
grub_errno = GRUB_ERR_NONE;
mo_file = grub_xasprintf ("%s%s/%s.gmo", part1, part2, locale);
if (!mo_file)
return grub_errno;
err = grub_mofile_open (ctx, mo_file);
grub_free (mo_file);
}
return err;
}

View file

@ -42,7 +42,6 @@ grub_font_draw_string (const char *str, grub_font_t font,
int left_x, int baseline_y)
{
int x;
struct grub_font_glyph *glyph;
grub_uint32_t *logical;
grub_ssize_t logical_len, visual_len;
struct grub_unicode_glyph *visual, *ptr;
@ -60,16 +59,18 @@ grub_font_draw_string (const char *str, grub_font_t font,
for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++)
{
grub_err_t err;
struct grub_font_glyph *glyph;
glyph = grub_font_construct_glyph (font, ptr);
if (!glyph)
return grub_errno;
err = grub_font_draw_glyph (glyph, color, x, baseline_y);
x += glyph->device_width;
grub_free (glyph);
if (err)
return err;
}
for (ptr = visual; ptr < visual + visual_len; ptr++)
grub_unicode_destroy_glyph (ptr);
grub_free (visual);
return GRUB_ERR_NONE;
@ -102,7 +103,7 @@ grub_font_get_string_width (grub_font_t font, const char *str)
&glyph);
width += grub_font_get_constructed_device_width (font, &glyph);
grub_free (glyph.combining);
grub_unicode_destroy_glyph (&glyph);
}
grub_free (logical);

View file

@ -53,6 +53,7 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
{
grub_gfxmenu_view_t view = NULL;
const char *theme_path;
char *full_theme_path = 0;
struct grub_menu_viewer *instance;
grub_err_t err;
struct grub_video_mode_info mode_info;
@ -70,15 +71,27 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
if (err)
return err;
if (!cached_view || grub_strcmp (cached_view->theme_path, theme_path) != 0
if (theme_path[0] != '/' && theme_path[0] != '(')
{
const char *prefix;
prefix = grub_env_get ("prefix");
full_theme_path = grub_xasprintf ("%s/themes/%s",
prefix,
theme_path);
}
if (!cached_view || grub_strcmp (cached_view->theme_path,
full_theme_path ? : theme_path) != 0
|| cached_view->screen.width != mode_info.width
|| cached_view->screen.height != mode_info.height)
{
grub_free (cached_view);
grub_gfxmenu_view_destroy (cached_view);
/* Create the view. */
cached_view = grub_gfxmenu_view_new (theme_path, mode_info.width,
cached_view = grub_gfxmenu_view_new (full_theme_path ? : theme_path,
mode_info.width,
mode_info.height);
}
grub_free (full_theme_path);
if (! cached_view)
{

View file

@ -223,6 +223,25 @@ circprog_set_state (void *vself, int visible, int start,
self->end = end;
}
static int
parse_angle (const char *value)
{
char *ptr;
int angle;
angle = grub_strtol (value, &ptr, 10);
if (grub_errno)
return 0;
while (grub_isspace (*ptr))
ptr++;
if (grub_strcmp (ptr, "deg") == 0
/* Unicode symbol of degrees (a circle, U+b0). Put here in UTF-8 to
avoid potential problem with text file reesncoding */
|| grub_strcmp (ptr, "\xc2\xb0") == 0)
angle = (angle * 64 + 45) / 90;
return angle;
}
static grub_err_t
circprog_set_property (void *vself, const char *name, const char *value)
{
@ -233,7 +252,7 @@ circprog_set_property (void *vself, const char *name, const char *value)
}
else if (grub_strcmp (name, "start_angle") == 0)
{
self->start_angle = grub_strtol (value, 0, 10);
self->start_angle = parse_angle (value);
}
else if (grub_strcmp (name, "ticks_disappear") == 0)
{

View file

@ -83,7 +83,11 @@ list_destroy (void *vself)
self->selected_item_box->destroy (self->selected_item_box);
if (self->icon_manager)
grub_gfxmenu_icon_manager_destroy (self->icon_manager);
if (self->scrollbar_thumb)
self->scrollbar_thumb->destroy (self->scrollbar_thumb);
if (self->scrollbar_frame)
self->scrollbar_frame->destroy (self->scrollbar_frame);
grub_free (self->scrollbar_thumb_pattern);
grub_free (self);
}
@ -541,6 +545,16 @@ list_set_view_info (void *vself,
self->view = view;
}
/* Refresh list variables */
static void
list_refresh_info (void *vself,
grub_gfxmenu_view_t view)
{
list_impl_t self = vself;
if (view->nested)
self->first_shown_index = 0;
}
static struct grub_gui_component_ops list_comp_ops =
{
.destroy = list_destroy,
@ -557,7 +571,8 @@ static struct grub_gui_component_ops list_comp_ops =
static struct grub_gui_list_ops list_ops =
{
.set_view_info = list_set_view_info
.set_view_info = list_set_view_info,
.refresh_list = list_refresh_info
};
grub_gui_component_t

View file

@ -59,6 +59,9 @@ static void
progress_bar_destroy (void *vself)
{
grub_gui_progress_bar_t self = vself;
grub_free (self->theme_dir);
grub_free (self->template);
grub_free (self->id);
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
grub_free (self);
}
@ -185,6 +188,7 @@ draw_text (grub_gui_progress_bar_t self)
int y = ((height - grub_font_get_descent (font)) / 2
+ grub_font_get_ascent (font) / 2);
grub_font_draw_string (text, font, text_color, x, y);
grub_free (text);
}
}

View file

@ -58,6 +58,14 @@ grub_gfxmenu_view_new (const char *theme_path,
if (! view)
return 0;
while (grub_gfxmenu_timeout_notifications)
{
struct grub_gfxmenu_timeout_notify *p;
p = grub_gfxmenu_timeout_notifications;
grub_gfxmenu_timeout_notifications = grub_gfxmenu_timeout_notifications->next;
grub_free (p);
}
view->screen.x = 0;
view->screen.y = 0;
view->screen.width = width;
@ -105,6 +113,13 @@ grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view)
{
if (!view)
return;
while (grub_gfxmenu_timeout_notifications)
{
struct grub_gfxmenu_timeout_notify *p;
p = grub_gfxmenu_timeout_notifications;
grub_gfxmenu_timeout_notifications = grub_gfxmenu_timeout_notifications->next;
grub_free (p);
}
grub_video_bitmap_destroy (view->desktop_image);
if (view->terminal_box)
view->terminal_box->destroy (view->terminal_box);
@ -236,6 +251,27 @@ update_menu_components (grub_gfxmenu_view_t view)
update_menu_visit, view);
}
static void
refresh_menu_visit (grub_gui_component_t component,
void *userdata)
{
grub_gfxmenu_view_t view;
view = userdata;
if (component->ops->is_instance (component, "list"))
{
grub_gui_list_t list = (grub_gui_list_t) component;
list->ops->refresh_list (list, view);
}
}
/* Refresh list information (useful for submenus) */
static void
refresh_menu_components (grub_gfxmenu_view_t view)
{
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
refresh_menu_visit, view);
}
static void
draw_message (grub_gfxmenu_view_t view)
{
@ -294,6 +330,7 @@ grub_gfxmenu_view_draw (grub_gfxmenu_view_t view)
view->screen.x, view->screen.y,
view->screen.width, view->screen.height);
refresh_menu_components (view);
update_menu_components (view);
grub_gfxmenu_view_redraw (view, &view->screen);

View file

@ -0,0 +1,13 @@
=== modified file 'grub-core/gnulib/argp-parse.c'
--- grub-core/gnulib/argp-parse.c 2010-04-02 22:45:01 +0000
+++ grub-core/gnulib/argp-parse.c 2011-04-10 13:25:52 +0000
@@ -935,7 +935,7 @@
void *
__argp_input (const struct argp *argp, const struct argp_state *state)
{
- if (state)
+ if (state && state->pstate)
{
struct group *group;
struct parser *parser = state->pstate;

View file

@ -0,0 +1,231 @@
diff --git a/lib/argp-fmtstream.c b/lib/argp-fmtstream.c
index 7aa317c..02406ff 100644
--- a/lib/argp-fmtstream.c
+++ b/lib/argp-fmtstream.c
@@ -29,9 +29,11 @@
#include <errno.h>
#include <stdarg.h>
#include <ctype.h>
+#include <wchar.h>
#include "argp-fmtstream.h"
#include "argp-namefrob.h"
+#include "mbswidth.h"
#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
@@ -116,6 +118,51 @@ weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
#endif
#endif
+
+/* Return the pointer to the first character that doesn't fit in l columns. */
+static inline const ptrdiff_t
+add_width (const char *ptr, const char *end, size_t l)
+{
+ mbstate_t ps;
+ const char *ptr0 = ptr;
+
+ memset (&ps, 0, sizeof (ps));
+
+ while (ptr < end)
+ {
+ wchar_t wc;
+ size_t s, k;
+
+ s = mbrtowc (&wc, ptr, end - ptr, &ps);
+ if (s == (size_t) -1)
+ break;
+ if (s == (size_t) -2)
+ {
+ if (1 >= l)
+ break;
+ l--;
+ ptr++;
+ continue;
+ }
+
+ if (wc == '\e' && ptr + 3 < end
+ && ptr[1] == '[' && (ptr[2] == '0' || ptr[2] == '1')
+ && ptr[3] == 'm')
+ {
+ ptr += 4;
+ continue;
+ }
+
+ k = wcwidth (wc);
+
+ if (k >= l)
+ break;
+ l -= k;
+ ptr += s;
+ }
+ return ptr - ptr0;
+}
+
/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
void
@@ -168,14 +215,15 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
if (!nl)
{
+ size_t display_width = mbsnwidth (buf, fs->p - buf, MBSW_STOP_AT_NUL);
/* The buffer ends in a partial line. */
- if (fs->point_col + len < fs->rmargin)
+ if (fs->point_col + display_width < fs->rmargin)
{
/* The remaining buffer text is a partial line and fits
within the maximum line width. Advance point for the
characters to be written and stop scanning. */
- fs->point_col += len;
+ fs->point_col += display_width;
break;
}
else
@@ -183,14 +231,18 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
the end of the buffer. */
nl = fs->p;
}
- else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
- {
- /* The buffer contains a full line that fits within the maximum
- line width. Reset point and scan the next line. */
- fs->point_col = 0;
- buf = nl + 1;
- continue;
- }
+ else
+ {
+ size_t display_width = mbsnwidth (buf, nl - buf, MBSW_STOP_AT_NUL);
+ if (display_width < (ssize_t) fs->rmargin)
+ {
+ /* The buffer contains a full line that fits within the maximum
+ line width. Reset point and scan the next line. */
+ fs->point_col = 0;
+ buf = nl + 1;
+ continue;
+ }
+ }
/* This line is too long. */
r = fs->rmargin - 1;
@@ -226,7 +278,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
char *p, *nextline;
int i;
- p = buf + (r + 1 - fs->point_col);
+ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
while (p >= buf && !isblank ((unsigned char) *p))
--p;
nextline = p + 1; /* This will begin the next line. */
@@ -244,7 +296,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
{
/* A single word that is greater than the maximum line width.
Oh well. Put it on an overlong line by itself. */
- p = buf + (r + 1 - fs->point_col);
+ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
/* Find the end of the long word. */
if (p < nl)
do
@@ -278,7 +330,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
&& fs->p > nextline)
{
/* The margin needs more blanks than we removed. */
- if (fs->end - fs->p > fs->wmargin + 1)
+ if (mbsnwidth (fs->p, fs->end - fs->p, MBSW_STOP_AT_NUL)
+ > fs->wmargin + 1)
/* Make some space for them. */
{
size_t mv = fs->p - nextline;
diff --git a/lib/argp-help.c b/lib/argp-help.c
index 354f1e2..2914f47 100644
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -50,6 +50,7 @@
#include "argp.h"
#include "argp-fmtstream.h"
#include "argp-namefrob.h"
+#include "mbswidth.h"
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
@@ -1452,7 +1453,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
/* Manually do line wrapping so that it (probably) won't get wrapped at
any embedded spaces. */
- space (stream, 1 + nl - cp);
+ space (stream, 1 + mbsnwidth (cp, nl - cp, MBSW_STOP_AT_NUL));
__argp_fmtstream_write (stream, cp, nl - cp);
}
diff --git a/lib/mbswidth.c b/lib/mbswidth.c
index 7c2dfce..baa4f27 100644
--- a/lib/mbswidth.c
+++ b/lib/mbswidth.c
@@ -90,6 +90,9 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
p++;
width++;
break;
+ case '\0':
+ if (flags & MBSW_STOP_AT_NUL)
+ return width;
default:
/* If we have a multibyte sequence, scan it up to its end. */
{
@@ -168,6 +171,9 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
{
unsigned char c = (unsigned char) *p++;
+ if (c == 0 && (flags & MBSW_STOP_AT_NUL))
+ return width;
+
if (isprint (c))
{
if (width == INT_MAX)
diff --git a/lib/mbswidth.h b/lib/mbswidth.h
index e9c0b03..d7207c5 100644
--- a/lib/mbswidth.h
+++ b/lib/mbswidth.h
@@ -45,6 +45,9 @@ extern "C" {
control characters and 1 otherwise. */
#define MBSW_REJECT_UNPRINTABLE 2
+/* If this bit is set \0 is treated as the end of string.
+ Otherwise it's treated as a normal one column width character. */
+#define MBSW_STOP_AT_NUL 4
/* Returns the number of screen columns needed for STRING. */
#define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */
diff --git a/modules/argp b/modules/argp
index 125046a..6f14d10 100644
--- a/modules/argp
+++ b/modules/argp
@@ -40,6 +40,7 @@ stdalign
strerror
memchr
memmove
+mbswidth
configure.ac:
gl_ARGP
diff --git a/modules/argp-tests b/modules/argp-tests
index 8f92a4d..0463927 100644
--- a/modules/argp-tests
+++ b/modules/argp-tests
@@ -1,11 +1,13 @@
Files:
tests/test-argp.c
tests/test-argp-2.sh
+tests/test-argp-2-utf.sh
Depends-on:
progname
Makefile.am:
TESTS += test-argp test-argp-2.sh
-check_PROGRAMS += test-argp
+TESTS += test-argp test-argp-2.sh test-argp-2-utf.sh
+check_PROGRAMS += test-argp test-argp-utf8
test_argp_LDADD = $(LDADD) @LIBINTL@

View file

@ -0,0 +1,30 @@
=== modified file 'grub-core/gnulib/regcomp.c'
--- grub-core/gnulib/regcomp.c 2010-09-20 10:35:33 +0000
+++ grub-core/gnulib/regcomp.c 2012-03-10 11:31:42 +0000
@@ -549,13 +549,9 @@ regerror (int errcode, const regex_t *_R
if (BE (errcode < 0
|| errcode >= (int) (sizeof (__re_error_msgid_idx)
/ sizeof (__re_error_msgid_idx[0])), 0))
- /* Only error codes returned by the rest of the code should be passed
- to this routine. If we are given anything else, or if other regex
- code generates an invalid error code, then the program has a bug.
- Dump core so we can fix it. */
- abort ();
-
- msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
+ msg = gettext ("unknown regexp error");
+ else
+ msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
msg_size = strlen (msg) + 1; /* Includes the null. */
@@ -1119,7 +1119,7 @@
}
break;
default:
- abort ();
+ break;
}
if (mb_chars || has_period)

View file

@ -0,0 +1,10 @@
--- /tmp/x.diff 2013-04-11 16:51:42.777873536 +0200
+++ grub-core/gnulib/stdio.in.h 2013-04-11 16:51:49.917873298 +0200
@@ -700,7 +700,6 @@
removed it. */
#undef gets
#if HAVE_RAW_DECL_GETS
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

File diff suppressed because it is too large Load diff

View file

@ -93,26 +93,15 @@ long i00afunc ();
static int stack_dir; /* 1 or -1 once known. */
# define STACK_DIR stack_dir
static void
find_stack_direction (void)
static int
find_stack_direction (int *addr, int depth)
{
static char *addr = NULL; /* Address of first `dummy', once known. */
auto char dummy; /* To get stack address. */
if (addr == NULL)
{ /* Initial entry. */
addr = ADDRESS_FUNCTION (dummy);
find_stack_direction (); /* Recurse once. */
}
else
{
/* Second entry. */
if (ADDRESS_FUNCTION (dummy) > addr)
stack_dir = 1; /* Stack grew upward. */
else
stack_dir = -1; /* Stack grew downward. */
}
int dir, dummy = 0;
if (! addr)
addr = &dummy;
*addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
dir = depth ? find_stack_direction (addr, depth - 1) : 0;
return dir + dummy;
}
# endif /* STACK_DIRECTION == 0 */
@ -155,7 +144,7 @@ alloca (size_t size)
# if STACK_DIRECTION == 0
if (STACK_DIR == 0) /* Unknown growth direction. */
find_stack_direction ();
STACK_DIR = find_stack_direction (NULL, (size & 1) + 20);
# endif
/* Reclaim garbage, defined as all alloca'd storage that
@ -486,4 +475,4 @@ i00afunc (long address)
# endif /* CRAY */
# endif /* no alloca */
#endif /* not GCC version 3 */
#endif /* not GCC 2 */

View file

@ -1,6 +1,6 @@
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation,
Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation,
Inc.
This program is free software; you can redistribute it and/or modify it
@ -14,9 +14,9 @@
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
License along with this program; if not, see
<http://www.gnu.org/licenses/>.
*/
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
means there is a real alloca function. */
@ -44,6 +44,13 @@
# define alloca _alloca
# elif defined __DECC && defined __VMS
# define alloca __ALLOCA
# elif defined __TANDEM && defined _TNS_E_TARGET
# ifdef __cplusplus
extern "C"
# endif
void *_alloca (unsigned short);
# pragma intrinsic (_alloca)
# define alloca _alloca
# else
# include <stddef.h>
# ifdef __cplusplus

View file

@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
Copyright (C) 1996, 1997, 1999, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1996-1997, 1999, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -19,11 +19,11 @@
/* If set by the user program, it should point to string that is the
bug-reporting address for the program. It will be printed by argp_help if
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
messages), embedded in a sentence that says something like `Report bugs to
ADDR.'. */
messages), embedded in a sentence that says something like "Report bugs to
ADDR." */
const char *argp_program_bug_address
/* This variable should be zero-initialized. On most systems, putting it into
BSS is sufficient. Not so on MacOS X 10.3 and 10.4, see
BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
<http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>
<http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00096.html>. */
#if defined __ELF__

View file

@ -1,5 +1,5 @@
/* Default definition for ARGP_ERR_EXIT_STATUS
Copyright (C) 1997, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1997, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.

View file

@ -1,5 +1,5 @@
/* Word-wrapping and line-truncating streams
Copyright (C) 1997-1999, 2001-2003, 2005, 2009-2010 Free Software
Copyright (C) 1997-1999, 2001-2003, 2005, 2009-2013 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This package emulates glibc `line_wrap_stream' semantics for systems that
/* This package emulates glibc 'line_wrap_stream' semantics for systems that
don't have that. */
#ifdef HAVE_CONFIG_H
@ -33,6 +33,7 @@
#include "argp-fmtstream.h"
#include "argp-namefrob.h"
#include "mbswidth.h"
#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
@ -118,37 +119,16 @@ weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
#endif
size_t
__argp_get_display_len (const char *beg, const char *end)
/* Return the pointer to the first character that doesn't fit in l columns. */
static inline const ptrdiff_t
add_width (const char *ptr, const char *end, size_t l)
{
const char *ptr;
size_t r = 0;
mbstate_t ps;
const char *ptr0 = ptr;
memset (&ps, 0, sizeof (ps));
for (ptr = beg; ptr < end && *ptr; )
{
wchar_t wc;
size_t s;
s = mbrtowc (&wc, ptr, end - ptr, &ps);
if (s == (size_t) -1)
break;
r += wcwidth (wc);
ptr += s;
}
return r;
}
static inline char *
add_length (char *ptr, char *end, size_t l)
{
mbstate_t ps;
memset (&ps, 0, sizeof (ps));
while (ptr < end && *ptr)
while (ptr < end)
{
wchar_t wc;
size_t s, k;
@ -156,13 +136,31 @@ add_length (char *ptr, char *end, size_t l)
s = mbrtowc (&wc, ptr, end - ptr, &ps);
if (s == (size_t) -1)
break;
if (s == (size_t) -2)
{
if (1 >= l)
break;
l--;
ptr++;
continue;
}
if (wc == '\e' && ptr + 3 < end
&& ptr[1] == '[' && (ptr[2] == '0' || ptr[2] == '1')
&& ptr[3] == 'm')
{
ptr += 4;
continue;
}
k = wcwidth (wc);
if (k >= l)
break;
l -= k;
ptr += s;
}
return ptr;
return ptr - ptr0;
}
/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
@ -217,15 +215,15 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
if (!nl)
{
size_t display_len = __argp_get_display_len (buf, fs->p);
size_t display_width = mbsnwidth (buf, fs->p - buf, MBSW_STOP_AT_NUL);
/* The buffer ends in a partial line. */
if (fs->point_col + display_len < fs->rmargin)
if (fs->point_col + display_width < fs->rmargin)
{
/* The remaining buffer text is a partial line and fits
within the maximum line width. Advance point for the
characters to be written and stop scanning. */
fs->point_col += display_len;
fs->point_col += display_width;
break;
}
else
@ -235,8 +233,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
}
else
{
size_t display_len = __argp_get_display_len (buf, nl);
if (display_len < (ssize_t) fs->rmargin)
size_t display_width = mbsnwidth (buf, nl - buf, MBSW_STOP_AT_NUL);
if (display_width < (ssize_t) fs->rmargin)
{
/* The buffer contains a full line that fits within the maximum
line width. Reset point and scan the next line. */
@ -280,7 +278,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
char *p, *nextline;
int i;
p = add_length (buf, fs->p, (r + 1 - fs->point_col));
p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
while (p >= buf && !isblank ((unsigned char) *p))
--p;
nextline = p + 1; /* This will begin the next line. */
@ -298,7 +296,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
{
/* A single word that is greater than the maximum line width.
Oh well. Put it on an overlong line by itself. */
p = add_length (buf, fs->p, (r + 1 - fs->point_col));
p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
/* Find the end of the long word. */
if (p < nl)
do
@ -332,7 +330,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
&& fs->p > nextline)
{
/* The margin needs more blanks than we removed. */
if (__argp_get_display_len (fs->p, fs->end) > fs->wmargin + 1)
if (mbsnwidth (fs->p, fs->end - fs->p, MBSW_STOP_AT_NUL)
> fs->wmargin + 1)
/* Make some space for them. */
{
size_t mv = fs->p - nextline;

View file

@ -1,5 +1,5 @@
/* Word-wrapping and line-truncating streams.
Copyright (C) 1997, 2006-2010 Free Software Foundation, Inc.
Copyright (C) 1997, 2006-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This package emulates glibc `line_wrap_stream' semantics for systems that
/* This package emulates glibc 'line_wrap_stream' semantics for systems that
don't have that. If the system does have it, it is just a wrapper for
that. This header file is only used internally while compiling argp, and
shouldn't be installed. */
@ -28,16 +28,16 @@
#include <string.h>
#include <unistd.h>
#ifndef __attribute__
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The __-protected variants of the attributes 'format' and 'printf' are
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
We enable __attribute__ only if these are supported too, because
We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
gnulib and libintl do '#define printf __printf__' when they override
the 'printf' function. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __attribute__(Spec) /* empty */
# endif
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
#else
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
#endif
#if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
@ -128,12 +128,12 @@ extern void argp_fmtstream_free (argp_fmtstream_t __fs);
extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
const char *__fmt, ...)
__attribute__ ((__format__ (printf, 2, 3)));
_GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
const char *__fmt, ...)
__attribute__ ((__format__ (printf, 2, 3)));
_GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
#if _LIBC || !defined __OPTIMIZE__
#if _LIBC
extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
@ -154,7 +154,7 @@ extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
#if _LIBC || !defined __OPTIMIZE__
#if _LIBC
/* Set __FS's left margin to LMARGIN and return the old value. */
extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
size_t __lmargin);
@ -184,7 +184,7 @@ extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
#ifdef __OPTIMIZE__
#if !_LIBC || defined __OPTIMIZE__
/* Inline versions of above routines. */
#if !_LIBC
@ -197,6 +197,10 @@ extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
#define __argp_fmtstream_point argp_fmtstream_point
#define __argp_fmtstream_update _argp_fmtstream_update
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
_GL_INLINE_HEADER_BEGIN
#ifndef ARGP_FS_EI
# define ARGP_FS_EI _GL_INLINE
#endif
#endif
#ifndef ARGP_FS_EI
@ -335,9 +339,6 @@ __argp_fmtstream_point (argp_fmtstream_t __fs)
return __fs->point_col >= 0 ? __fs->point_col : 0;
}
size_t
__argp_get_display_len (const char *beg, const char *end);
#if !_LIBC
#undef __argp_fmtstream_putc
#undef __argp_fmtstream_puts
@ -348,9 +349,10 @@ __argp_get_display_len (const char *beg, const char *end);
#undef __argp_fmtstream_point
#undef __argp_fmtstream_update
#undef __argp_fmtstream_ensure
_GL_INLINE_HEADER_END
#endif
#endif /* __OPTIMIZE__ */
#endif /* !_LIBC || __OPTIMIZE__ */
#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */

View file

@ -1,5 +1,5 @@
/* Real definitions for extern inline functions in argp-fmtstream.h
Copyright (C) 1997, 2003, 2004, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1997, 2003-2004, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -20,7 +20,11 @@
# include <config.h>
#endif
#define ARGP_FS_EI
#ifdef _LIBC
# define ARGP_FS_EI
#else
# define ARGP_FS_EI _GL_EXTERN_INLINE
#endif
#undef __OPTIMIZE__
#define __OPTIMIZE__ 1
#include "argp-fmtstream.h"

View file

@ -1,5 +1,5 @@
/* Hierarchial argument parsing help output
Copyright (C) 1995-2005, 2007, 2009-2010 Free Software Foundation, Inc.
/* Hierarchical argument parsing help output
Copyright (C) 1995-2005, 2007, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -29,6 +29,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <assert.h>
#include <stdarg.h>
#include <ctype.h>
@ -49,6 +50,7 @@
#include "argp.h"
#include "argp-fmtstream.h"
#include "argp-namefrob.h"
#include "mbswidth.h"
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
@ -56,7 +58,7 @@
/* User-selectable (using an environment variable) formatting parameters.
These may be specified in an environment variable called `ARGP_HELP_FMT',
These may be specified in an environment variable called 'ARGP_HELP_FMT',
with a contents like: VAR1=VAL1,VAR2=VAL2,BOOLVAR2,no-BOOLVAR2
Where VALn must be a positive integer. The list of variables is in the
UPARAM_NAMES vector, below. */
@ -73,13 +75,13 @@
#define RMARGIN 79 /* right margin used for wrapping */
/* User-selectable (using an environment variable) formatting parameters.
They must all be of type `int' for the parsing code to work. */
They must all be of type 'int' for the parsing code to work. */
struct uparams
{
/* If true, arguments for an option are shown with both short and long
options, even when a given option has both, e.g. `-x ARG, --longx=ARG'.
options, even when a given option has both, e.g. '-x ARG, --longx=ARG'.
If false, then if an option has both, the argument is only shown with
the long one, e.g., `-x, --longx=ARG', and a message indicating that
the long one, e.g., '-x, --longx=ARG', and a message indicating that
this really means both is printed below the options. */
int dup_args;
@ -111,7 +113,7 @@ static struct uparams uparams = {
struct uparam_name
{
const char *name; /* User name. */
int is_bool; /* Whether it's `boolean'. */
int is_bool; /* Whether it's 'boolean'. */
size_t uparams_offs; /* Location of the (int) field in UPARAMS. */
};
@ -154,7 +156,7 @@ ARGP_HELP_FMT: %s value is less than or equal to %s"),
uparams.valid = 1;
}
/* Read user options from the environment, and fill in UPARAMS appropiately. */
/* Read user options from the environment, and fill in UPARAMS appropriately. */
static void
fill_in_uparams (const struct argp_state *state)
{
@ -259,7 +261,7 @@ fill_in_uparams (const struct argp_state *state)
/* Returns true if OPT is an alias for an earlier option. */
#define oalias(opt) ((opt)->flags & OPTION_ALIAS)
/* Returns true if OPT is an documentation-only entry. */
/* Returns true if OPT is a documentation-only entry. */
#define odoc(opt) ((opt)->flags & OPTION_DOC)
/* Returns true if OPT should not be translated */
@ -277,11 +279,11 @@ fill_in_uparams (const struct argp_state *state)
-xARG, -yARG, --long1=ARG, --long2=ARG Documentation...
Where ARG will be omitted if there's no argument, for this option, or
will be surrounded by "[" and "]" appropiately if the argument is
optional. The documentation string is word-wrapped appropiately, and if
will be surrounded by "[" and "]" appropriately if the argument is
optional. The documentation string is word-wrapped appropriately, and if
the list of options is long enough, it will be started on a separate line.
If there are no short options for a given option, the first long option is
indented slighly in a way that's supposed to make most long options appear
indented slightly in a way that's supposed to make most long options appear
to be in a separate column.
For example, the following output (from ps):
@ -359,7 +361,7 @@ struct hol_entry
/* A pointers into the HOL's short_options field, to the first short option
letter for this entry. The order of the characters following this point
corresponds to the order of options pointed to by OPT, and there are at
most NUM. A short option recorded in a option following OPT is only
most NUM. A short option recorded in an option following OPT is only
valid if it occurs in the right place in SHORT_OPTIONS (otherwise it's
probably been shadowed by some other entry). */
char *short_options;
@ -570,7 +572,9 @@ hol_entry_short_iterate (const struct hol_entry *entry,
}
static inline int
#if __GNUC__ >= 3
__attribute__ ((always_inline))
#endif
hol_entry_long_iterate (const struct hol_entry *entry,
int (*func)(const struct argp_option *opt,
const struct argp_option *real,
@ -711,7 +715,7 @@ hol_cluster_is_child (const struct hol_cluster *cl1,
return cl1 == cl2;
}
/* Given the name of a OPTION_DOC option, modifies NAME to start at the tail
/* Given the name of an OPTION_DOC option, modifies NAME to start at the tail
that should be used for comparisons, and returns true iff it should be
treated as a non-option. */
static int
@ -726,7 +730,7 @@ canon_doc_option (const char **name)
/* Skip initial whitespace. */
while (isspace ((unsigned char) **name))
(*name)++;
/* Decide whether this looks like an option (leading `-') or not. */
/* Decide whether this looks like an option (leading '-') or not. */
non_opt = (**name != '-');
/* Skip until part of name used for sorting. */
while (**name && !isalnum ((unsigned char) **name))
@ -751,9 +755,9 @@ hol_entry_cmp (const struct hol_entry *entry1,
if (entry1->cluster != entry2->cluster)
{
/* The entries are not within the same cluster, so we can't compare them
directly, we have to use the appropiate clustering level too. */
directly, we have to use the appropriate clustering level too. */
if (! entry1->cluster)
/* ENTRY1 is at the `base level', not in a cluster, so we have to
/* ENTRY1 is at the "base level", not in a cluster, so we have to
compare it's group number with that of the base cluster in which
ENTRY2 resides. Note that if they're in the same group, the
clustered option always comes laster. */
@ -783,7 +787,7 @@ hol_entry_cmp (const struct hol_entry *entry1,
doc2 = canon_doc_option (&long2);
if (doc1 != doc2)
/* `documentation' options always follow normal options (or
/* "documentation" options always follow normal options (or
documentation options that *look* like normal options). */
return doc1 - doc2;
else if (!short1 && !short2 && long1 && long2)
@ -889,7 +893,8 @@ hol_append (struct hol *hol, struct hol *more)
/* Fix up the short options pointers from HOL. */
for (e = entries, left = hol->num_entries; left > 0; e++, left--)
e->short_options += (short_options - hol->short_options);
e->short_options =
short_options + (e->short_options - hol->short_options);
/* Now add the short options from MORE, fixing up its entries
too. */
@ -1020,7 +1025,7 @@ filter_doc (const char *doc, int key, const struct argp *argp,
return doc;
}
/* Prints STR as a header line, with the margin lines set appropiately, and
/* Prints STR as a header line, with the margin lines set appropriately, and
notes the fact that groups should be separated with a blank line. ARGP is
the argp that should dictate any user doc filtering to take place. Note
that the previous wrap margin isn't restored, but the left margin is reset
@ -1142,7 +1147,7 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
/* Now, long options. */
if (odoc (real))
/* A `documentation' option. */
/* A "documentation" option. */
{
__argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col);
for (opt = real, num = entry->num; num > 0; opt++, num--)
@ -1436,7 +1441,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
const char *cp = fdoc;
nl = __strchrnul (cp, '\n');
if (*nl != '\0')
/* This is a `multi-level' args doc; advance to the correct position
/* This is a "multi-level" args doc; advance to the correct position
as determined by our state in LEVELS, and update LEVELS. */
{
int i;
@ -1448,7 +1453,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
/* Manually do line wrapping so that it (probably) won't get wrapped at
any embedded spaces. */
space (stream, 1 + __argp_get_display_len (cp, nl));
space (stream, 1 + mbsnwidth (cp, nl - cp, MBSW_STOP_AT_NUL));
__argp_fmtstream_write (stream, cp, nl - cp);
}
@ -1477,9 +1482,9 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
}
/* Print the documentation for ARGP to STREAM; if POST is false, then
everything preceeding a `\v' character in the documentation strings (or
everything preceding a '\v' character in the documentation strings (or
the whole string, for those with none) is printed, otherwise, everything
following the `\v' character (nothing for strings without). Each separate
following the '\v' character (nothing for strings without). Each separate
bit of documentation is separated a blank line, and if PRE_BLANK is true,
then the first is as well. If FIRST_ONLY is true, only the first
occurrence is output. Returns true if anything was output. */
@ -1549,7 +1554,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */
if (post && argp->help_filter)
/* Now see if we have to output a ARGP_KEY_HELP_EXTRA text. */
/* Now see if we have to output an ARGP_KEY_HELP_EXTRA text. */
{
text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input);
if (text)
@ -1576,8 +1581,8 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
}
/* Output a usage message for ARGP to STREAM. If called from
argp_state_help, STATE is the relevent parsing state. FLAGS are from the
set ARGP_HELP_*. NAME is what to use wherever a `program name' is
argp_state_help, STATE is the relevant parsing state. FLAGS are from the
set ARGP_HELP_*. NAME is what to use wherever a "program name" is
needed. */
static void
_help (const struct argp *argp, const struct argp_state *state, FILE *stream,
@ -1618,7 +1623,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
}
if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE))
/* Print a short `Usage:' message. */
/* Print a short "Usage:" message. */
{
int first_pattern = 1, more_patterns;
size_t num_pattern_levels = argp_args_levels (argp);
@ -1678,7 +1683,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
if (flags & ARGP_HELP_SEE)
{
__argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "\
Try `%s --help' or `%s --usage' for more information.\n"),
Try '%s --help' or '%s --usage' for more information.\n"),
name, name);
anything = 1;
}
@ -1721,7 +1726,7 @@ Try `%s --help' or `%s --usage' for more information.\n"),
}
/* Output a usage message for ARGP to STREAM. FLAGS are from the set
ARGP_HELP_*. NAME is what to use wherever a `program name' is needed. */
ARGP_HELP_*. NAME is what to use wherever a "program name" is needed. */
void __argp_help (const struct argp *argp, FILE *stream,
unsigned flags, char *name)
{
@ -1779,7 +1784,7 @@ weak_alias (__argp_state_help, argp_state_help)
#endif
/* If appropriate, print the printf string FMT and following args, preceded
by the program name and `:', to stderr, and followed by a `Try ... --help'
by the program name and ':', to stderr, and followed by a "Try ... --help"
message, then exit (1). */
void
__argp_error (const struct argp_state *state, const char *fmt, ...)
@ -1915,7 +1920,7 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
char const *s = NULL;
putc_unlocked (':', stream);
putc_unlocked (' ', stream);
#if _LIBC || (HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P)
#if _LIBC || (HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P && !defined strerror_r)
s = __strerror_r (errnum, buf, sizeof buf);
#elif HAVE_DECL_STRERROR_R
if (__strerror_r (errnum, buf, sizeof buf) == 0)

View file

@ -1,5 +1,5 @@
/* Name frobnication for compiling argp outside of glibc
Copyright (C) 1997, 2003, 2007, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1997, 2003, 2007, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -100,45 +100,45 @@
#endif
#if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
# define feof_unlocked(x) feof (x)
# endif
#endif
#if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
# define ferror_unlocked(x) ferror (x)
# endif
#endif
#if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
# define fflush_unlocked(x) fflush (x)
# endif
#endif
#if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
# define fgets_unlocked(x,y,z) fgets (x,y,z)
# endif
#endif
#if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
# define fputc_unlocked(x,y) fputc (x,y)
# endif
#endif
#if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
# define fputs_unlocked(x,y) fputs (x,y)
# endif
#endif
#if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
# endif
#endif
#if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
# endif
#endif
#if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED
# define getc_unlocked(x) getc (x)
# endif
#endif
#if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED
# define getchar_unlocked() getchar ()
# endif
#endif
#if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED
# define putc_unlocked(x,y) putc (x,y)
# endif
#endif
#if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED
# define putchar_unlocked(x) putchar (x)
# endif
#endif
#endif /* !_LIBC */
#ifndef __set_errno
#define __set_errno(e) (errno = (e))
# define __set_errno(e) (errno = (e))
#endif
#if defined GNULIB_ARGP_DISABLE_DIRNAME

View file

@ -1,5 +1,5 @@
/* Hierarchial argument parsing, layered over getopt
Copyright (C) 1995-2000, 2002-2004, 2009-2010 Free Software Foundation, Inc.
/* Hierarchical argument parsing, layered over getopt
Copyright (C) 1995-2000, 2002-2004, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -21,6 +21,7 @@
#endif
#include <alloca.h>
#include <stdalign.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@ -42,7 +43,6 @@
#include "argp.h"
#include "argp-namefrob.h"
#define alignof(type) offsetof (struct { char c; type x; }, x)
#define alignto(n, d) ((((n) + (d) - 1) / (d)) * (d))
/* Getopt return values. */
@ -154,8 +154,9 @@ argp_version_parser (int key, char *arg, struct argp_state *state)
else if (argp_program_version)
fprintf (state->out_stream, "%s\n", argp_program_version);
else
__argp_error (state, dgettext (state->root_argp->argp_domain,
"(PROGRAM ERROR) No version known!?"));
__argp_error (state, "%s",
dgettext (state->root_argp->argp_domain,
"(PROGRAM ERROR) No version known!?"));
if (! (state->flags & ARGP_NO_EXIT))
exit (0);
break;
@ -187,7 +188,7 @@ find_long_option (struct option *long_options, const char *name)
}
/* The state of a `group' during parsing. Each group corresponds to a
/* The state of a "group" during parsing. Each group corresponds to a
particular argp structure from the tree of such descending from the top
level argp passed to argp_parse. */
struct group
@ -203,7 +204,7 @@ struct group
particular short options is from. */
char *short_end;
/* The number of non-option args sucessfully handled by this parser. */
/* The number of non-option args successfully handled by this parser. */
unsigned args_processed;
/* This group's parser's parent's group. */
@ -254,7 +255,7 @@ struct parser
struct group *groups;
/* The end of the GROUPS array. */
struct group *egroup;
/* An vector containing storage for the CHILD_INPUTS field in all groups. */
/* A vector containing storage for the CHILD_INPUTS field in all groups. */
void **child_inputs;
/* True if we think using getopt is still useful; if false, then
@ -385,7 +386,7 @@ convert_options (const struct argp *argp,
return group;
}
/* Find the merged set of getopt options, with keys appropiately prefixed. */
/* Find the merged set of getopt options, with keys appropriately prefixed. */
static void
parser_convert (struct parser *parser, const struct argp *argp, int flags)
{
@ -439,7 +440,7 @@ calc_sizes (const struct argp *argp, struct parser_sizes *szs)
int num_opts = 0;
while (!__option_is_end (opt++))
num_opts++;
szs->short_len += num_opts * 3; /* opt + up to 2 `:'s */
szs->short_len += num_opts * 3; /* opt + up to 2 ':'s */
szs->long_len += num_opts;
}
}
@ -781,7 +782,7 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey)
if (parser->state.quoted && parser->state.next < parser->state.quoted)
/* The next argument pointer has been moved to before the quoted
region, so pretend we never saw the quoting `--', and give getopt
region, so pretend we never saw the quoting "--", and give getopt
another chance. If the user hasn't removed it, getopt will just
process it again. */
parser->state.quoted = 0;
@ -813,7 +814,7 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey)
&& strcmp (parser->state.argv[parser->state.next - 1], QUOTE)
== 0)
/* Not only is this the end of the options, but it's a
`quoted' region, which may have args that *look* like
"quoted" region, which may have args that *look* like
options, so we definitely shouldn't try to use getopt past
here, whatever happens. */
parser->state.quoted = parser->state.next;
@ -879,11 +880,11 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
#ifndef _LIBC
if (!(flags & ARGP_PARSE_ARGV0))
{
#ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
if (!program_invocation_name)
program_invocation_name = argv[0];
#endif
#ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
if (!program_invocation_short_name)
program_invocation_short_name = __argp_base_name (argv[0]);
#endif

View file

@ -1,5 +1,5 @@
/* Full and short program names for argp module
Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 2005, 2009-2013 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
@ -24,4 +24,3 @@ char *program_invocation_short_name = 0;
#ifndef HAVE_PROGRAM_INVOCATION_NAME
char *program_invocation_name = 0;
#endif

View file

@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_VERSION.
Copyright (C) 1996, 1997, 1999, 2006, 2009, 2010 Free Software Foundation,
Copyright (C) 1996-1997, 1999, 2006, 2009-2013 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -23,7 +23,7 @@
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
const char *argp_program_version
/* This variable should be zero-initialized. On most systems, putting it into
BSS is sufficient. Not so on MacOS X 10.3 and 10.4, see
BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
<http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>
<http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00096.html>. */
#if defined __ELF__

View file

@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
Copyright (C) 1996, 1997, 1999, 2004, 2009, 2010 Free Software Foundation,
Copyright (C) 1996-1997, 1999, 2004, 2009-2013 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.

View file

@ -1,5 +1,5 @@
/* Real definitions for extern inline functions in argp.h
Copyright (C) 1997, 1998, 2004, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1997-1998, 2004, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -27,7 +27,11 @@
#ifndef __USE_EXTERN_INLINES
# define __USE_EXTERN_INLINES 1
#endif
#define ARGP_EI
#ifdef _LIBC
# define ARGP_EI
#else
# define ARGP_EI _GL_EXTERN_INLINE
#endif
#undef __OPTIMIZE__
#define __OPTIMIZE__ 1
#include "argp.h"

View file

@ -1,5 +1,5 @@
/* Hierarchial argument parsing, layered over getopt.
Copyright (C) 1995-1999, 2003-2010 Free Software Foundation, Inc.
/* Hierarchical argument parsing, layered over getopt.
Copyright (C) 1995-1999, 2003-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -34,16 +34,16 @@
# define __NTH(fct) fct __THROW
#endif
#ifndef __attribute__
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The __-protected variants of the attributes 'format' and 'printf' are
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
We enable __attribute__ only if these are supported too, because
We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
gnulib and libintl do '#define printf __printf__' when they override
the 'printf' function. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __attribute__(Spec) /* empty */
# endif
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
#else
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
#endif
/* GCC 2.95 and later have "__restrict"; C99 compilers have
@ -94,7 +94,7 @@ struct argp_option
/* The doc string for this option. If both NAME and KEY are 0, This string
will be printed outdented from the normal option column, making it
useful as a group header (it will be the first thing printed in its
group); in this usage, it's conventional to end the string with a `:'.
group); in this usage, it's conventional to end the string with a ':'.
Write the initial value as N_("TEXT") if you want xgettext to collect
it into a POT file. */
@ -124,21 +124,21 @@ struct argp_option
/* This option isn't actually an option (and so should be ignored by the
actual option parser), but rather an arbitrary piece of documentation that
should be displayed in much the same manner as the options. If this flag
is set, then the option NAME field is displayed unmodified (e.g., no `--'
is set, then the option NAME field is displayed unmodified (e.g., no '--'
prefix is added) at the left-margin (where a *short* option would normally
be displayed), and the documentation string in the normal place. The NAME
field will be translated using gettext, unless OPTION_NO_TRANS is set (see
below). For purposes of sorting, any leading whitespace and punctuation is
ignored, except that if the first non-whitespace character is not `-', this
ignored, except that if the first non-whitespace character is not '-', this
entry is displayed after all options (and OPTION_DOC entries with a leading
`-') in the same group. */
'-') in the same group. */
#define OPTION_DOC 0x8
/* This option shouldn't be included in `long' usage messages (but is still
/* This option shouldn't be included in "long" usage messages (but is still
included in help messages). This is mainly intended for options that are
completely documented in an argp's ARGS_DOC field, in which case including
the option in the generic usage list would be redundant. For instance,
if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to
if ARGS_DOC is "FOO BAR\n-x BLAH", and the '-x' option's purpose is to
distinguish these two cases, -x should probably be marked
OPTION_NO_USAGE. */
#define OPTION_NO_USAGE 0x10
@ -167,7 +167,7 @@ typedef error_t (*argp_parser_t) (int key, char *arg,
ARGP_ERR_UNKNOWN should be returned if they aren't understood.
The sequence of keys to a parsing function is either (where each
uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key):
uppercased word should be prefixed by 'ARGP_KEY_' and opt is a user key):
INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
@ -238,15 +238,15 @@ struct argp
argp_parser_t parser;
/* A string describing what other arguments are wanted by this program. It
is only used by argp_usage to print the `Usage:' message. If it
is only used by argp_usage to print the "Usage:" message. If it
contains newlines, the strings separated by them are considered
alternative usage patterns, and printed on separate lines (lines after
the first are prefix by ` or: ' instead of `Usage:'). */
the first are prefix by " or: " instead of "Usage:"). */
const char *args_doc;
/* If non-NULL, a string containing extra text to be printed before and
after the options in a long help message (separated by a vertical tab
`\v' character).
'\v' character).
Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if
you want xgettext to collect the two pieces of text into a POT file. */
const char *doc;
@ -265,7 +265,7 @@ struct argp
defines, below, describing which other help text TEXT is. The function
should return either TEXT, if it should be used as-is, a replacement
string, which should be malloced, and will be freed by argp, or NULL,
meaning `print nothing'. The value for TEXT is *after* any translation
meaning "print nothing". The value for TEXT is *after* any translation
has been done, so if any of the replacement text also needs translation,
that should be done by the filter function. INPUT is either the input
supplied to argp_parse, or NULL, if argp_help was called directly. */
@ -278,7 +278,7 @@ struct argp
};
/* Possible KEY arguments to a help filter function. */
#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */
#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceding options. */
#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
@ -304,7 +304,7 @@ struct argp_child
printing a header string, use a value of "". */
const char *header;
/* Where to group the child options relative to the other (`consolidated')
/* Where to group the child options relative to the other ("consolidated")
options in the parent argp; the values are the same as the GROUP field
in argp_option structs, but all child-groupings follow parent options at
a particular group level. If both this field and HEADER are zero, then
@ -337,7 +337,7 @@ struct argp_state
unsigned arg_num;
/* If non-zero, the index in ARGV of the first argument following a special
`--' argument (which prevents anything following being interpreted as an
'--' argument (which prevents anything following being interpreted as an
option). Only set once argument parsing has proceeded past this point. */
int quoted;
@ -399,7 +399,7 @@ struct argp_state
/* Don't exit on errors (they may still result in error messages). */
#define ARGP_NO_EXIT 0x20
/* Use the gnu getopt `long-only' rules for parsing arguments. */
/* Use the gnu getopt "long-only" rules for parsing arguments. */
#define ARGP_LONG_ONLY 0x40
/* Turns off any message-printing/exiting options. */
@ -456,7 +456,7 @@ extern void (*argp_program_version_hook) (FILE *__restrict __stream,
the bug-reporting address for the program. It will be printed by
argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
standard help messages), embedded in a sentence that says something like
`Report bugs to ADDR.'. */
"Report bugs to ADDR." */
extern const char *argp_program_bug_address;
/* The exit status that argp will use when exiting due to a parsing error.
@ -467,7 +467,7 @@ extern error_t argp_err_exit_status;
/* Flags for argp_help. */
#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
#define ARGP_HELP_SEE 0x04 /* a `Try ... for more help' message. */
#define ARGP_HELP_SEE 0x04 /* a "Try ... for more help" message. */
#define ARGP_HELP_LONG 0x08 /* a long help message. */
#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
@ -506,7 +506,7 @@ extern void __argp_help (const struct argp *__restrict __argp,
parsing routine (thus taking an argp_state structure as the first
argument). They may or may not print an error message and exit, depending
on the flags in STATE -- in any case, the caller should be prepared for
them *not* to exit, and should return an appropiate error after calling
them *not* to exit, and should return an appropriate error after calling
them. [argp_usage & argp_error should probably be called argp_state_...,
but they're used often enough that they should be short] */
@ -519,21 +519,21 @@ extern void __argp_state_help (const struct argp_state *__restrict __state,
FILE *__restrict __stream,
unsigned int __flags);
#if _LIBC || !defined __USE_EXTERN_INLINES
#if _LIBC
/* Possibly output the standard usage message for ARGP to stderr and exit. */
extern void argp_usage (const struct argp_state *__state);
extern void __argp_usage (const struct argp_state *__state);
#endif
/* If appropriate, print the printf string FMT and following args, preceded
by the program name and `:', to stderr, and followed by a `Try ... --help'
by the program name and ':', to stderr, and followed by a "Try ... --help"
message, then exit (1). */
extern void argp_error (const struct argp_state *__restrict __state,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
_GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
extern void __argp_error (const struct argp_state *__restrict __state,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
_GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
/* Similar to the standard gnu error-reporting function error(), but will
respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
@ -546,13 +546,13 @@ extern void __argp_error (const struct argp_state *__restrict __state,
extern void argp_failure (const struct argp_state *__restrict __state,
int __status, int __errnum,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
_GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5));
extern void __argp_failure (const struct argp_state *__restrict __state,
int __status, int __errnum,
const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
_GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5));
#if _LIBC || !defined __USE_EXTERN_INLINES
#if _LIBC
/* Returns true if the option OPT is a valid short option. */
extern int _option_is_short (const struct argp_option *__opt) __THROW;
extern int __option_is_short (const struct argp_option *__opt) __THROW;
@ -572,13 +572,17 @@ extern void *__argp_input (const struct argp *__restrict __argp,
const struct argp_state *__restrict __state)
__THROW;
#ifdef __USE_EXTERN_INLINES
#if !_LIBC || defined __USE_EXTERN_INLINES
# if !_LIBC
# define __argp_usage argp_usage
# define __argp_state_help argp_state_help
# define __option_is_short _option_is_short
# define __option_is_end _option_is_end
_GL_INLINE_HEADER_BEGIN
# ifndef ARGP_EI
# define ARGP_EI _GL_INLINE
# endif
# endif
# ifndef ARGP_EI
@ -635,6 +639,7 @@ __NTH (__option_is_end (const struct argp_option *__opt))
# undef __argp_state_help
# undef __option_is_short
# undef __option_is_end
_GL_INLINE_HEADER_END
# endif
#endif /* Use extern inlines. */

View file

@ -1,5 +1,5 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1999, 2002, 2006, 2009-2013 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
@ -12,8 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <config.h>

View file

@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
Copyright (C) 2008, 2010 Free Software Foundation, Inc.
Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify

View file

@ -1,7 +1,7 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
# Copyright (C) 2000-2004, 2006-2010 Free Software Foundation, Inc.
# Copyright (C) 2000-2004, 2006-2013 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
@ -14,8 +14,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# with this program; if not, see <http://www.gnu.org/licenses/>.
#
# The table consists of lines of the form
# ALIAS CANONICAL
@ -30,6 +29,8 @@
# The current list of GNU canonical charset names is as follows.
#
# name MIME? used by which systems
# (darwin = Mac OS X, woe32 = native Windows)
#
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin

View file

@ -1,6 +1,6 @@
/* dirname.c -- return all but the last element in a file name
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@ -25,7 +25,7 @@
/* Return the length of the prefix of FILE that will be used by
dir_name. If FILE is in the working directory, this returns zero
even though `dir_name (FILE)' will return ".". Works properly even
even though 'dir_name (FILE)' will return ".". Works properly even
if there are trailing slashes (by effectively ignoring them). */
size_t
@ -53,9 +53,9 @@ dir_len (char const *file)
}
/* In general, we can't use the builtin `dirname' function if available,
/* In general, we can't use the builtin 'dirname' function if available,
since it has different meanings in different environments.
In some environments the builtin `dirname' modifies its argument.
In some environments the builtin 'dirname' modifies its argument.
Return the leading directories part of FILE, allocated with malloc.
Works properly even if there are trailing slashes (by effectively

View file

@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
Copyright (C) 1998, 2001, 2003-2006, 2009-2010 Free Software Foundation,
Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@ -21,53 +21,25 @@
# include <stdbool.h>
# include <stddef.h>
# include "dosname.h"
# ifndef DIRECTORY_SEPARATOR
# define DIRECTORY_SEPARATOR '/'
# endif
# ifndef ISSLASH
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
# endif
# ifndef FILE_SYSTEM_PREFIX_LEN
# if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
/* This internal macro assumes ASCII, but all hosts that support drive
letters use ASCII. */
# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
<= 'z' - 'a')
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
# else
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
# endif
# endif
# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
# endif
# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
# endif
# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
# else
# define IS_ABSOLUTE_FILE_NAME(F) \
(ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
# endif
# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
# if GNULIB_DIRNAME
char *base_name (char const *file);
char *dir_name (char const *file);
# endif
char *mdir_name (char const *file);
size_t base_len (char const *file);
size_t dir_len (char const *file);
char *last_component (char const *file);
size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
bool strip_trailing_slashes (char *file);

View file

@ -0,0 +1,53 @@
/* File names on MS-DOS/Windows systems.
Copyright (C) 2000-2001, 2004-2006, 2009-2013 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 <http://www.gnu.org/licenses/>.
From Paul Eggert and Jim Meyering. */
#ifndef _DOSNAME_H
#define _DOSNAME_H
#if (defined _WIN32 || defined __WIN32__ || \
defined __MSDOS__ || defined __CYGWIN__ || \
defined __EMX__ || defined __DJGPP__)
/* This internal macro assumes ASCII, but all hosts that support drive
letters use ASCII. */
# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
<= 'z' - 'a')
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
# ifndef __CYGWIN__
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
# endif
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#else
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
# define ISSLASH(C) ((C) == '/')
#endif
#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
#endif
#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
# else
# define IS_ABSOLUTE_FILE_NAME(F) \
(ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
#endif
#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
#endif /* DOSNAME_H_ */

View file

@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
Copyright (C) 2008-2010 Free Software Foundation, Inc.
Copyright (C) 2008-2013 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
@ -13,69 +13,137 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef _GL_ERRNO_H
#ifndef _@GUARD_PREFIX@_ERRNO_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
#ifndef _GL_ERRNO_H
#define _GL_ERRNO_H
#ifndef _@GUARD_PREFIX@_ERRNO_H
#define _@GUARD_PREFIX@_ERRNO_H
/* On native Windows platforms, many macros are not defined. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* POSIX says that EAGAIN and EWOULDBLOCK may have the same value. */
# define EWOULDBLOCK EAGAIN
/* These are the same values as defined by MSVC 10, for interoperability. */
/* Values >= 100 seem safe to use. */
# define ETXTBSY 100
# define GNULIB_defined_ETXTBSY 1
# ifndef ENOMSG
# define ENOMSG 122
# define GNULIB_defined_ENOMSG 1
# endif
# ifndef EIDRM
# define EIDRM 111
# define GNULIB_defined_EIDRM 1
# endif
# ifndef ENOLINK
# define ENOLINK 121
# define GNULIB_defined_ENOLINK 1
# endif
# ifndef EPROTO
# define EPROTO 134
# define GNULIB_defined_EPROTO 1
# endif
# ifndef EBADMSG
# define EBADMSG 104
# define GNULIB_defined_EBADMSG 1
# endif
# ifndef EOVERFLOW
# define EOVERFLOW 132
# define GNULIB_defined_EOVERFLOW 1
# endif
# ifndef ENOTSUP
# define ENOTSUP 129
# define GNULIB_defined_ENOTSUP 1
# endif
# ifndef ENETRESET
# define ENETRESET 117
# define GNULIB_defined_ENETRESET 1
# endif
# ifndef ECONNABORTED
# define ECONNABORTED 106
# define GNULIB_defined_ECONNABORTED 1
# endif
# ifndef ECANCELED
# define ECANCELED 105
# define GNULIB_defined_ECANCELED 1
# endif
# ifndef EOWNERDEAD
# define EOWNERDEAD 133
# define GNULIB_defined_EOWNERDEAD 1
# endif
# ifndef ENOTRECOVERABLE
# define ENOTRECOVERABLE 127
# define GNULIB_defined_ENOTRECOVERABLE 1
# endif
# ifndef EINPROGRESS
# define EINPROGRESS 112
# define EALREADY 103
# define ENOTSOCK 128
# define EDESTADDRREQ 109
# define EMSGSIZE 115
# define EPROTOTYPE 136
# define ENOPROTOOPT 123
# define EPROTONOSUPPORT 135
# define EOPNOTSUPP 130
# define EAFNOSUPPORT 102
# define EADDRINUSE 100
# define EADDRNOTAVAIL 101
# define ENETDOWN 116
# define ENETUNREACH 118
# define ECONNRESET 108
# define ENOBUFS 119
# define EISCONN 113
# define ENOTCONN 126
# define ETIMEDOUT 138
# define ECONNREFUSED 107
# define ELOOP 114
# define EHOSTUNREACH 110
# define EWOULDBLOCK 140
# define GNULIB_defined_ESOCK 1
# endif
# ifndef ETXTBSY
# define ETXTBSY 139
# define ENODATA 120 /* not required by POSIX */
# define ENOSR 124 /* not required by POSIX */
# define ENOSTR 125 /* not required by POSIX */
# define ETIME 137 /* not required by POSIX */
# define EOTHER 131 /* not required by POSIX */
# define GNULIB_defined_ESTREAMS 1
# endif
/* These are intentionally the same values as the WSA* error numbers, defined
in <winsock2.h>. */
# define EINPROGRESS 10036
# define EALREADY 10037
# define ENOTSOCK 10038
# define EDESTADDRREQ 10039
# define EMSGSIZE 10040
# define EPROTOTYPE 10041
# define ENOPROTOOPT 10042
# define EPROTONOSUPPORT 10043
# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */
# define EOPNOTSUPP 10045
# define EPFNOSUPPORT 10046 /* not required by POSIX */
# define EAFNOSUPPORT 10047
# define EADDRINUSE 10048
# define EADDRNOTAVAIL 10049
# define ENETDOWN 10050
# define ENETUNREACH 10051
# define ENETRESET 10052
# define ECONNABORTED 10053
# define ECONNRESET 10054
# define ENOBUFS 10055
# define EISCONN 10056
# define ENOTCONN 10057
# define ESHUTDOWN 10058 /* not required by POSIX */
# define ETOOMANYREFS 10059 /* not required by POSIX */
# define ETIMEDOUT 10060
# define ECONNREFUSED 10061
# define ELOOP 10062
# define EHOSTDOWN 10064 /* not required by POSIX */
# define EHOSTUNREACH 10065
# define EPROCLIM 10067 /* not required by POSIX */
# define EUSERS 10068 /* not required by POSIX */
# define EDQUOT 10069
# define ESTALE 10070
# define EREMOTE 10071 /* not required by POSIX */
# define GNULIB_defined_ESOCK 1
# define GNULIB_defined_EWINSOCK 1
# endif
@ -98,6 +166,7 @@
/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
Likewise, on NonStop Kernel, EDQUOT is not defined.
Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
@ -145,16 +214,66 @@
# define GNULIB_defined_ENOTSUP 1
# endif
# ifndef ENETRESET
# define ENETRESET 2011
# define GNULIB_defined_ENETRESET 1
# endif
# ifndef ECONNABORTED
# define ECONNABORTED 2012
# define GNULIB_defined_ECONNABORTED 1
# endif
# ifndef ESTALE
# define ESTALE 2009
# define GNULIB_defined_ESTALE 1
# endif
# ifndef EDQUOT
# define EDQUOT 2010
# define GNULIB_defined_EDQUOT 1
# endif
# ifndef ECANCELED
# define ECANCELED 2008
# define GNULIB_defined_ECANCELED 1
# endif
/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not
defined. */
#endif /* _GL_ERRNO_H */
#endif /* _GL_ERRNO_H */
# ifndef EOWNERDEAD
# if defined __sun
/* Use the same values as defined for Solaris >= 8, for
interoperability. */
# define EOWNERDEAD 58
# define ENOTRECOVERABLE 59
# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* We have a conflict here: pthreads-win32 defines these values
differently than MSVC 10. It's hairy to decide which one to use. */
# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
/* Use the same values as defined by pthreads-win32, for
interoperability. */
# define EOWNERDEAD 43
# define ENOTRECOVERABLE 44
# else
/* Use the same values as defined by MSVC 10, for
interoperability. */
# define EOWNERDEAD 133
# define ENOTRECOVERABLE 127
# endif
# else
# define EOWNERDEAD 2013
# define ENOTRECOVERABLE 2014
# endif
# define GNULIB_defined_EOWNERDEAD 1
# define GNULIB_defined_ENOTRECOVERABLE 1
# endif
# ifndef EILSEQ
# define EILSEQ 2015
# define GNULIB_defined_EILSEQ 1
# endif
#endif /* _@GUARD_PREFIX@_ERRNO_H */
#endif /* _@GUARD_PREFIX@_ERRNO_H */

View file

@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
Copyright (C) 1990-1998, 2000-2007, 2009-2010 Free Software Foundation, Inc.
Copyright (C) 1990-1998, 2000-2007, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@ -54,7 +54,7 @@
function without parameters instead. */
void (*error_print_progname) (void);
/* This variable is incremented each time `error' is called. */
/* This variable is incremented each time 'error' is called. */
unsigned int error_message_count;
#ifdef _LIBC
@ -65,7 +65,7 @@ unsigned int error_message_count;
# include <limits.h>
# include <libio/libioP.h>
/* In GNU libc we want do not want to use the common name `error' directly.
/* In GNU libc we want do not want to use the common name 'error' directly.
Instead make it a weak alias. */
extern void __error (int status, int errnum, const char *message, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
@ -89,19 +89,25 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
# include <unistd.h>
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* Get declarations of the Win32 API functions. */
/* Get declarations of the native Windows API functions. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
# include "msvc-nothrow.h"
# endif
/* The gnulib override of fcntl is not needed in this file. */
# undef fcntl
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
# if !HAVE_DECL_STRERROR_R
# ifndef HAVE_DECL_STRERROR_R
"this configure-time declaration test was not run"
# endif
# if STRERROR_R_CHAR_P
char *strerror_r ();
# else
int strerror_r ();
# endif
# endif
/* The calling program should define program_name and set it to the
@ -115,13 +121,14 @@ extern char *program_name;
#if !_LIBC
/* Return non-zero if FD is open. */
static inline int
static int
is_open (int fd)
{
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* On Win32: The initial state of unassigned standard file descriptors is
that they are open but point to an INVALID_HANDLE_VALUE. There is no
fcntl, and the gnulib replacement fcntl does not support F_GETFL. */
/* On native Windows: The initial state of unassigned standard file
descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
There is no fcntl, and the gnulib replacement fcntl does not support
F_GETFL. */
return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
# else
# ifndef F_GETFL
@ -132,7 +139,7 @@ is_open (int fd)
}
#endif
static inline void
static void
flush_stdout (void)
{
#if !_LIBC

View file

@ -1,6 +1,6 @@
/* Declaration for error-reporting function
Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008, 2009, 2010 Free Software
Foundation, Inc.
Copyright (C) 1995-1997, 2003, 2006, 2008-2013 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@ -19,39 +19,39 @@
#ifndef _ERROR_H
#define _ERROR_H 1
#ifndef __attribute__
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The __-protected variants of the attributes 'format' and 'printf' are
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
We enable __attribute__ only if these are supported too, because
We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
gnulib and libintl do '#define printf __printf__' when they override
the 'printf' function. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __attribute__(Spec) /* empty */
# endif
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
#else
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Print a message with `fprintf (stderr, FORMAT, ...)';
/* Print a message with 'fprintf (stderr, FORMAT, ...)';
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
extern void error (int __status, int __errnum, const char *__format, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
_GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
extern void error_at_line (int __status, int __errnum, const char *__fname,
unsigned int __lineno, const char *__format, ...)
__attribute__ ((__format__ (__printf__, 5, 6)));
_GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6));
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
extern void (*error_print_progname) (void);
/* This variable is incremented each time `error' is called. */
/* This variable is incremented each time 'error' is called. */
extern unsigned int error_message_count;
/* Sometimes we want to have at most one error per line. This

View file

@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software; you can redistribute it and/or modify
@ -13,8 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef _FLOATPLUS_H
#define _FLOATPLUS_H
@ -141,8 +140,8 @@
#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
/* Verify that SIZEOF_FLT <= sizeof (float) etc. */
typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1];
typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1];
typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1];
typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
#endif /* _FLOATPLUS_H */

33
grub-core/gnulib/float.c Normal file
View file

@ -0,0 +1,33 @@
/* Auxiliary definitions for <float.h>.
Copyright (C) 2011-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
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 <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <float.h>
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
const union gl_long_double_union gl_LDBL_MAX =
{ { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
#elif defined __i386__
const union gl_long_double_union gl_LDBL_MAX =
{ { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
#else
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
typedef int dummy;
#endif

View file

@ -1,6 +1,6 @@
/* A correct <float.h>.
Copyright (C) 2007-2010 Free Software Foundation, Inc.
Copyright (C) 2007-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,19 +15,21 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _GL_FLOAT_H
#ifndef _@GUARD_PREFIX@_FLOAT_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
#ifndef _GL_FLOAT_H
#define _GL_FLOAT_H
#ifndef _@GUARD_PREFIX@_FLOAT_H
#define _@GUARD_PREFIX@_FLOAT_H
/* 'long double' properties. */
#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
/* Number of mantissa units, in base FLT_RADIX. */
# undef LDBL_MANT_DIG
@ -58,5 +60,129 @@
# define LDBL_MAX_10_EXP 4932
#endif
#endif /* _GL_FLOAT_H */
#endif /* _GL_FLOAT_H */
/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
precision in the compiler but 64 bits of precision at runtime. See
<http://lists.gnu.org/archive/html/bug-gnulib/2008-07/msg00063.html>. */
#if defined __i386__ && defined __FreeBSD__
/* Number of mantissa units, in base FLT_RADIX. */
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 64
/* Number of decimal digits that is sufficient for representing a number. */
# undef LDBL_DIG
# define LDBL_DIG 18
/* x-1 where x is the smallest representable number > 1. */
# undef LDBL_EPSILON
# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */
/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP (-16381)
/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */
# undef LDBL_MAX_EXP
# define LDBL_MAX_EXP 16384
/* Minimum positive normalized number. */
# undef LDBL_MIN
# define LDBL_MIN 3.3621031431120935E-4932L /* = 0x1p-16382L */
/* Maximum representable finite number. */
# undef LDBL_MAX
/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
But the largest literal that GCC allows us to write is
0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }.
So, define it like this through a reference to an external variable
const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 };
extern const long double LDBL_MAX;
Unfortunately, this is not a constant expression. */
union gl_long_double_union
{
struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
long double ld;
};
extern const union gl_long_double_union gl_LDBL_MAX;
# define LDBL_MAX (gl_LDBL_MAX.ld)
/* Minimum e such that 10^e is in the range of normalized numbers. */
# undef LDBL_MIN_10_EXP
# define LDBL_MIN_10_EXP (-4931)
/* Maximum e such that 10^e is in the range of representable finite numbers. */
# undef LDBL_MAX_10_EXP
# define LDBL_MAX_10_EXP 4932
#endif
/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
wrong.
On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */
#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP DBL_MIN_EXP
# undef LDBL_MIN_10_EXP
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
# undef LDBL_MIN
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
#endif
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
# undef LDBL_MAX
/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
It is not easy to define:
#define LDBL_MAX 1.79769313486231580793728971405302307166e308L
is too small, whereas
#define LDBL_MAX 1.79769313486231580793728971405302307167e308L
is too large. Apparently a bug in GCC decimal-to-binary conversion.
Also, I can't get values larger than
#define LDBL63 ((long double) (1ULL << 63))
#define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
#define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
#define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
#define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
So, define it like this through a reference to an external variable
const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL };
extern const long double LDBL_MAX;
or through a pointer cast
#define LDBL_MAX \
(*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })
Unfortunately, this is not a constant expression, and the latter expression
does not work well when GCC is optimizing.. */
union gl_long_double_union
{
struct { double hi; double lo; } dd;
long double ld;
};
extern const union gl_long_double_union gl_LDBL_MAX;
# define LDBL_MAX (gl_LDBL_MAX.ld)
#endif
/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON
are wrong. */
#if defined __sgi && (LDBL_MANT_DIG >= 106)
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 106
# if defined __GNUC__
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP DBL_MIN_EXP
# undef LDBL_MIN_10_EXP
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
# undef LDBL_MIN
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
# undef LDBL_EPSILON
# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
# endif
#endif
#if @REPLACE_ITOLD@
/* Pull in a function that fixes the 'int' to 'long double' conversion
of glibc 2.7. */
extern
# ifdef __cplusplus
"C"
# endif
void _Qp_itoq (long double *, int);
static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq;
#endif
#endif /* _@GUARD_PREFIX@_FLOAT_H */
#endif /* _@GUARD_PREFIX@_FLOAT_H */

View file

@ -1,5 +1,4 @@
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
/* Copyright (C) 1991-1993, 1996-2007, 2009-2013 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
@ -12,8 +11,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
@ -43,7 +41,7 @@
(HAVE_WCTYPE_H && HAVE_BTOWC && HAVE_ISWCTYPE \
&& HAVE_WMEMCHR && (HAVE_WMEMCPY || HAVE_WMEMPCPY))
/* For platform which support the ISO C amendement 1 functionality we
/* For platform which support the ISO C amendment 1 functionality we
support user defined character classes. */
#if defined _LIBC || WIDE_CHAR_SUPPORT
# include <wctype.h>
@ -79,7 +77,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
program understand 'configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
@ -93,7 +91,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
# if defined _LIBC || WIDE_CHAR_SUPPORT
/* The GNU C library provides support for user-defined character classes
and the functions from ISO C amendement 1. */
and the functions from ISO C amendment 1. */
# ifdef CHARCLASS_NAME_MAX
# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
# else
@ -120,7 +118,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
# endif
# else
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, 'xdigit'. */
# define IS_CHAR_CLASS(string) \
(STREQ (string, "alpha") || STREQ (string, "upper") \
@ -169,7 +167,6 @@ static int posixly_correct;
# endif
# endif
# define MEMCHR(S, C, N) memchr (S, C, N)
# define STRCOLL(S1, S2) strcoll (S1, S2)
# include "fnmatch_loop.c"
@ -197,7 +194,6 @@ static int posixly_correct;
# endif
# endif
# define MEMCHR(S, C, N) wmemchr (S, C, N)
# define STRCOLL(S1, S2) wcscoll (S1, S2)
# define WIDE_CHAR_VERSION 1
# undef IS_CHAR_CLASS

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
2005, 2007, 2009, 2010 Free Software Foundation, Inc.
/* Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2013 Free
Software Foundation, Inc.
This file is part of the GNU C Library.
@ -14,8 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
@ -32,23 +31,23 @@ extern "C" {
#undef FNM_NOESCAPE
#undef FNM_PERIOD
/* Bits set in the FLAGS argument to `fnmatch'. */
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
/* Bits set in the FLAGS argument to 'fnmatch'. */
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match '/'. */
#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
#define FNM_PERIOD (1 << 2) /* Leading '.' is matched only explicitly. */
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
# define FNM_LEADING_DIR (1 << 3) /* Ignore '/...' after a match. */
# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
#endif
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
/* Value returned by 'fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
/* This value is returned if the implementation does not support
`fnmatch'. Since this is not the case here it will never be
'fnmatch'. Since this is not the case here it will never be
returned but the conformance test suites still require the symbol
to be defined. */
#ifdef _XOPEN_SOURCE

View file

@ -1,5 +1,4 @@
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
/* Copyright (C) 1991-1993, 1996-2006, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@ -13,8 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Match STRING against the file name pattern PATTERN, returning zero if
it matches, nonzero if not. */
@ -201,6 +199,8 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
case L_('['):
{
/* Nonzero if the sense of the character class is inverted. */
const CHAR *p_init = p;
const CHAR *n_init = n;
register bool not;
CHAR cold;
UCHAR fn;
@ -215,7 +215,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
return FNM_NOMATCH;
if (*n == L_('/') && (flags & FNM_FILE_NAME))
/* `/' cannot be matched. */
/* '/' cannot be matched. */
return FNM_NOMATCH;
not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^')));
@ -381,7 +381,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
{
/* We found a table entry. Now see whether the
character we are currently at has the same
equivalance class value. */
equivalence class value. */
int len = weights[idx & 0xffffff];
int32_t idx2;
const UCHAR *np = (const UCHAR *) n;
@ -411,8 +411,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
}
#endif
else if (c == L_('\0'))
/* [ (unterminated) loses. */
return FNM_NOMATCH;
{
/* [ unterminated, treat as normal character. */
p = p_init;
n = n_init;
c = L_('[');
goto normal_match;
}
else
{
bool is_range = false;
@ -630,7 +635,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
UCHAR cend = *p++;
# ifdef WIDE_CHAR_VERSION
/* Search in the `names' array for the characters. */
/* Search in the 'names' array for the characters. */
fcollseq = __collseq_table_lookup (collseq, fn);
if (fcollseq == ~((uint32_t) 0))
/* XXX We don't know anything about the character
@ -833,7 +838,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
#else
/* We use a boring value comparison of the character
values. This is better than comparing using
`strcoll' since the latter would have surprising
'strcoll' since the latter would have surprising
and sometimes fatal consequences. */
UCHAR cend = *p++;
@ -1150,7 +1155,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
case L_('@'):
do
/* I cannot believe it but `strcat' is actually acceptable
/* I cannot believe it but 'strcat' is actually acceptable
here. Match the entire string with the prefix from the
pattern list and the rest of the pattern following the
pattern list. */
@ -1208,7 +1213,6 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
#undef END
#undef MEMPCPY
#undef MEMCHR
#undef STRCOLL
#undef STRLEN
#undef STRCAT
#undef L_

View file

@ -1,6 +1,6 @@
/* getdelim.c --- Implementation of replacement getdelim function.
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, 2008,
2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2013 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
@ -13,18 +13,16 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Ported from glibc by Simon Josefsson. */
#include <config.h>
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
#define _GL_ARG_NONNULL(params)
#include <config.h>
#include <stdio.h>
#include <limits.h>

View file

@ -1,5 +1,5 @@
/* getline.c --- Implementation of replacement getline function.
Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 2005-2007, 2009-2013 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
@ -12,9 +12,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Written by Simon Josefsson. */

View file

@ -2,7 +2,7 @@
NOTE: getopt is part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!
Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2010 Free Software
Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2013 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@ -41,15 +41,15 @@
# include <wchar.h>
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
/* This version of 'getopt' appears to the caller like standard Unix 'getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt_long' works, it permutes the elements of ARGV so that,
As 'getopt_long' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Using `getopt' or setting the environment variable POSIXLY_CORRECT
Using 'getopt' or setting the environment variable POSIXLY_CORRECT
disables permutation.
Then the behavior is completely standard.
@ -58,24 +58,24 @@
#include "getopt_int.h"
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
/* For communication from 'getopt' to the caller.
When 'getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
Also, when 'ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
and for communication between successive calls to 'getopt'.
On entry to `getopt', zero means this is the first call; initialize.
On entry to 'getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
When 'getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
Otherwise, 'optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
/* 1003.2 says this must be 1 before any call. */
@ -137,7 +137,7 @@ extern char *__getopt_nonoption_flags;
The other is elements [last_nonopt,optind), which contains all
the options processed since those non-options were skipped.
`first_nonopt' and `last_nonopt' are relocated so that they describe
'first_nonopt' and 'last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
static void
@ -154,7 +154,7 @@ exchange (char **argv, struct _getopt_data *d)
but it consists of two parts that need to be swapped next. */
#if defined _LIBC && defined USE_NONOPTION_FLAGS
/* First make sure the handling of the `__getopt_nonoption_flags'
/* First make sure the handling of the '__getopt_nonoption_flags'
string can work normally. Our top argument must be in the range
of the string. */
if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
@ -291,48 +291,48 @@ _getopt_initialize (int argc _GL_UNUSED,
If an element of ARGV starts with '-', and is not exactly "-" or "--",
then it is an option element. The characters of this element
(aside from the initial '-') are option characters. If `getopt'
(aside from the initial '-') are option characters. If 'getopt'
is called repeatedly, it returns successively each of the option characters
from each of the option elements.
If `getopt' finds another option character, it returns that character,
updating `optind' and `nextchar' so that the next call to `getopt' can
If 'getopt' finds another option character, it returns that character,
updating 'optind' and 'nextchar' so that the next call to 'getopt' can
resume the scan with the following option character or ARGV-element.
If there are no more option characters, `getopt' returns -1.
Then `optind' is the index in ARGV of the first ARGV-element
If there are no more option characters, 'getopt' returns -1.
Then 'optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
OPTSTRING is a string containing the legitimate option characters.
If an option character is seen that is not listed in OPTSTRING,
return '?' after printing an error message. If you set `opterr' to
return '?' after printing an error message. If you set 'opterr' to
zero, the error message is suppressed but we still return '?'.
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
ARGV-element, is returned in 'optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
it is returned in 'optarg', otherwise 'optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
If OPTSTRING starts with '-' or '+', it requests different methods of
handling the non-option ARGV-elements.
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
Long-named options begin with `--' instead of `-'.
Long-named options begin with '--' instead of '-'.
Their names may be abbreviated as long as the abbreviation is unique
or is an exact match for some defined option. If they have an
argument, it follows the option name in the same ARGV-element, separated
from the option name by a `=', or else the in next ARGV-element.
When `getopt' finds a long-named option, it returns 0 if that option's
`flag' field is nonzero, the value of the option's `val' field
if the `flag' field is zero.
from the option name by a '=', or else the in next ARGV-element.
When 'getopt' finds a long-named option, it returns 0 if that option's
'flag' field is nonzero, the value of the option's 'val' field
if the 'flag' field is zero.
The elements of ARGV aren't really const, because we permute them.
But we pretend they're const in the prototype to be compatible
with other systems.
LONGOPTS is a vector of `struct option' terminated by an
LONGOPTS is a vector of 'struct option' terminated by an
element containing a name which is zero.
LONGIND returns the index in LONGOPT of the long-named option found.
@ -409,7 +409,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
d->__last_nonopt = d->optind;
}
/* The special ARGV-element `--' means premature end of options.
/* The special ARGV-element '--' means premature end of options.
Skip it like a null option,
then exchange with previous non-options as if it were an option,
then skip everything else like a non-option. */
@ -479,23 +479,28 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|| !strchr (optstring, argv[d->optind][1])))))
{
char *nameend;
unsigned int namelen;
const struct option *p;
const struct option *pfound = NULL;
struct option_list
{
const struct option *p;
struct option_list *next;
} *ambig_list = NULL;
int exact = 0;
int ambig = 0;
int indfound = -1;
int option_index;
for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ;
namelen = nameend - d->__nextchar;
/* Test all long options for either exact match
or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
if (!strncmp (p->name, d->__nextchar, namelen))
{
if ((unsigned int) (nameend - d->__nextchar)
== (unsigned int) strlen (p->name))
if (namelen == (unsigned int) strlen (p->name))
{
/* Exact match found. */
pfound = p;
@ -513,35 +518,71 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|| pfound->has_arg != p->has_arg
|| pfound->flag != p->flag
|| pfound->val != p->val)
/* Second or later nonexact match found. */
ambig = 1;
{
/* Second or later nonexact match found. */
struct option_list *newp = malloc (sizeof (*newp));
newp->p = p;
newp->next = ambig_list;
ambig_list = newp;
}
}
if (ambig && !exact)
if (ambig_list != NULL && !exact)
{
if (print_errors)
{
struct option_list first;
first.p = pfound;
first.next = ambig_list;
ambig_list = &first;
#if defined _LIBC && defined USE_IN_LIBIO
char *buf;
char *buf = NULL;
size_t buflen = 0;
if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"),
argv[0], argv[d->optind]) >= 0)
FILE *fp = open_memstream (&buf, &buflen);
if (fp != NULL)
{
_IO_flockfile (stderr);
fprintf (fp,
_("%s: option '%s' is ambiguous; possibilities:"),
argv[0], argv[d->optind]);
int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
do
{
fprintf (fp, " '--%s'", ambig_list->p->name);
ambig_list = ambig_list->next;
}
while (ambig_list != NULL);
__fxprintf (NULL, "%s", buf);
fputc_unlocked ('\n', fp);
((_IO_FILE *) stderr)->_flags2 = old_flags2;
_IO_funlockfile (stderr);
if (__builtin_expect (fclose (fp) != EOF, 1))
{
_IO_flockfile (stderr);
free (buf);
int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
__fxprintf (NULL, "%s", buf);
((_IO_FILE *) stderr)->_flags2 = old_flags2;
_IO_funlockfile (stderr);
free (buf);
}
}
#else
fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
fprintf (stderr,
_("%s: option '%s' is ambiguous; possibilities:"),
argv[0], argv[d->optind]);
do
{
fprintf (stderr, " '--%s'", ambig_list->p->name);
ambig_list = ambig_list->next;
}
while (ambig_list != NULL);
fputc ('\n', stderr);
#endif
}
d->__nextchar += strlen (d->__nextchar);
@ -550,6 +591,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
return '?';
}
while (ambig_list != NULL)
{
struct option_list *pn = ambig_list->next;
free (ambig_list);
ambig_list = pn;
}
if (pfound != NULL)
{
option_index = indfound;
@ -740,7 +788,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
char c = *d->__nextchar++;
const char *temp = strchr (optstring, c);
/* Increment `optind' when we start to process its last character. */
/* Increment 'optind' when we start to process its last character. */
if (*d->__nextchar == '\0')
++d->optind;
@ -791,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
int indfound = 0;
int option_index;
if (longopts == NULL)
goto no_longs;
/* This is an option that requires an argument. */
if (*d->__nextchar != '\0')
{
@ -836,7 +887,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
return c;
}
else
/* We already incremented `d->optind' once;
/* We already incremented 'd->optind' once;
increment it again when taking next ARGV-elt as argument. */
d->optarg = argv[d->optind++];
@ -998,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
}
return pfound->val;
}
d->__nextchar = NULL;
return 'W'; /* Let the application handle it. */
no_longs:
d->__nextchar = NULL;
return 'W'; /* Let the application handle it. */
}
if (temp[1] == ':')
{
@ -1061,7 +1114,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
c = '?';
}
else
/* We already incremented `optind' once;
/* We already incremented 'optind' once;
increment it again when taking next ARGV-elt as argument. */
d->optarg = argv[d->optind++];
d->__nextchar = NULL;
@ -1124,7 +1177,7 @@ __posix_getopt (int argc, char *const *argv, const char *optstring)
#ifdef TEST
/* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */
the above definition of 'getopt'. */
int
main (int argc, char **argv)

View file

@ -1,5 +1,5 @@
/* Declarations for getopt.
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2010 Free Software
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@ -16,11 +16,12 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _GL_GETOPT_H
#ifndef _@GUARD_PREFIX@_GETOPT_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. We must
also inform the replacement unistd.h to not recursively use
@ -31,10 +32,10 @@
# undef _GL_SYSTEM_GETOPT
#endif
#ifndef _GL_GETOPT_H
#ifndef _@GUARD_PREFIX@_GETOPT_H
#ifndef __need_getopt
# define _GL_GETOPT_H 1
# define _@GUARD_PREFIX@_GETOPT_H 1
#endif
/* Standalone applications should #define __GETOPT_PREFIX to an
@ -48,7 +49,9 @@
linkers. */
#if defined __GETOPT_PREFIX && !defined __need_getopt
# if !@HAVE_GETOPT_H@
# define __need_system_stdlib_h
# include <stdlib.h>
# undef __need_system_stdlib_h
# include <stdio.h>
# include <unistd.h>
# endif
@ -81,7 +84,7 @@
getopt_long_only can permute argv; this is required for backward
compatibility (e.g., for LSB 2.0.1).
This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt',
but it caused redefinition warnings if both unistd.h and getopt.h were
included, since unistd.h includes getopt.h having previously defined
__need_getopt.
@ -127,29 +130,29 @@
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
/* For communication from 'getopt' to the caller.
When 'getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
Also, when 'ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
and for communication between successive calls to 'getopt'.
On entry to `getopt', zero means this is the first call; initialize.
On entry to 'getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
When 'getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
Otherwise, 'optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
/* Callers store zero here to inhibit the error message 'getopt' prints
for unrecognized options. */
extern int opterr;
@ -161,25 +164,26 @@ extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
of 'struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
The field 'has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
If the field 'flag' is not NULL, it points to a variable that is set
to the value given in the field 'val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
To have a long-named option do something other than set an 'int' to
a compiled-in constant, such as set a value from 'optarg', set the
option's 'flag' field to zero and its 'val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
one). For long options that have a zero 'flag' field, 'getopt'
returns the contents of the 'val' field. */
# if !GNULIB_defined_struct_option
struct option
{
const char *name;
@ -189,8 +193,10 @@ struct option
int *flag;
int val;
};
# define GNULIB_defined_struct_option 1
# endif
/* Names for the values of the `has_arg' field of `struct option'. */
/* Names for the values of the 'has_arg' field of 'struct option'. */
# define no_argument 0
# define required_argument 1
@ -204,23 +210,23 @@ struct option
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
missing arguments, 'optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
takes an argument, to be placed in 'optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
optional. This behavior is specific to the GNU 'getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
The argument '--' causes premature termination of argument
scanning, explicitly telling 'getopt' that there are no more
options.
If OPTS begins with `-', then non-option arguments are treated as
If OPTS begins with '-', then non-option arguments are treated as
arguments to the option '\1'. This behavior is specific to the GNU
`getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in
'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
the environment, then do not permute arguments. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
@ -245,5 +251,5 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */
#endif /* getopt.h */
#endif /* _@GUARD_PREFIX@_GETOPT_H */
#endif /* _@GUARD_PREFIX@_GETOPT_H */

View file

@ -1,6 +1,6 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
1998, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@ -141,11 +141,11 @@ main (int argc, char **argv)
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
printf ("option c with value '%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
printf ("option d with value '%s'\n", optarg);
break;
case '?':

View file

@ -1,5 +1,5 @@
/* Internal declarations for getopt.
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 Free Software
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@ -40,7 +40,7 @@ extern int _getopt_internal (int ___argc, char **___argv,
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
variable POSIXLY_CORRECT, or using '+' as the first character
of the list of option characters, or by calling getopt.
PERMUTE is the default. We permute the contents of ARGV as we
@ -52,12 +52,12 @@ extern int _getopt_internal (int ___argc, char **___argv,
written to expect options and other ARGV-elements in any order
and that care about the ordering of the two. We describe each
non-option ARGV-element as if it were the argument of an option
with character code 1. Using `-' as the first character of the
with character code 1. Using '-' as the first character of the
list of option characters selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
The special argument '--' forces an end of option-scanning regardless
of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
'--' can cause 'getopt' to return -1 with 'optind' != ARGC. */
enum __ord
{
@ -99,8 +99,8 @@ struct _getopt_data
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first
of them; `last_nonopt' is the index after the last of them. */
been skipped. 'first_nonopt' is the index in ARGV of the first
of them; 'last_nonopt' is the index after the last of them. */
int __first_nonopt;
int __last_nonopt;
@ -108,7 +108,7 @@ struct _getopt_data
#if defined _LIBC && defined USE_NONOPTION_FLAGS
int __nonoption_flags_max_len;
int __nonoption_flags_len;
# endif
#endif
};
/* The initializer is necessary to set OPTIND and OPTERR to their

View file

@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 Free Software
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@ -13,8 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
@ -54,7 +53,7 @@
it now, to make later inclusions of <libintl.h> a NOP. */
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
# include <cstdlib>
# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
# include <libintl.h>
# endif
#endif
@ -93,6 +92,12 @@
#endif
/* Prefer gnulib's setlocale override over libintl's setlocale override. */
#ifdef GNULIB_defined_setlocale
# undef setlocale
# define setlocale rpl_setlocale
#endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code.
@ -178,9 +183,12 @@ npgettext_aux (const char *domain,
#include <string.h>
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
(((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
/* || __STDC_VERSION__ >= 199901L */ )
#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
/* || __STDC_VERSION__ >= 199901L */ )
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
#endif
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h>

View file

@ -1,7 +1,6 @@
/* intprops.h -- properties of integer types
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free Software
Foundation, Inc.
Copyright (C) 2001-2005, 2009-2013 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
@ -18,66 +17,303 @@
/* Written by Paul Eggert. */
#ifndef GL_INTPROPS_H
# define GL_INTPROPS_H
#ifndef _GL_INTPROPS_H
#define _GL_INTPROPS_H
# include <limits.h>
#include <limits.h>
/* Return an integer value, converted to the same type as the integer
expression E after integer type promotion. V is the unconverted value. */
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
/* True if the arithmetic type T is an integer type. bool counts as
an integer. */
# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
/* True if negative values of the signed integer type T use two's
complement, ones' complement, or signed magnitude representation,
respectively. Much GNU code assumes two's complement, but some
people like to be portable to all possible C hosts. */
# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
/* True if the signed integer expression E uses two's complement. */
#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1)
/* True if the arithmetic type T is signed. */
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The maximum and minimum values for the integer type T. These
/* Return 1 if the integer expression E, after integer promotion, has
a signed type. */
#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
/* Minimum and maximum values for integer types and expressions. These
macros have undefined behavior if T is signed and has padding bits.
If this is a problem for you, please let us know how to fix it for
your host. */
# define TYPE_MINIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) 0 \
: TYPE_SIGNED_MAGNITUDE (t) \
? ~ (t) 0 \
: ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
# define TYPE_MAXIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) -1 \
: ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
/* Return zero if T can be determined to be an unsigned type.
Otherwise, return 1.
When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a
tighter bound. Otherwise, it overestimates the true bound by one byte
when applied to unsigned types of size 2, 4, 16, ... bytes.
The symbol signed_type_or_expr__ is private to this header file. */
# if __GNUC__ >= 2
# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
# else
# define signed_type_or_expr__(t) 1
# endif
/* The maximum and minimum values for the integer type T. */
#define TYPE_MINIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) 0 \
: TYPE_SIGNED_MAGNITUDE (t) \
? ~ (t) 0 \
: ~ TYPE_MAXIMUM (t)))
#define TYPE_MAXIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) -1 \
: ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
/* The maximum and minimum values for the type of the expression E,
after integer promotion. E should not have side effects. */
#define _GL_INT_MINIMUM(e) \
(_GL_INT_SIGNED (e) \
? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_CONVERT (e, 0))
#define _GL_INT_MAXIMUM(e) \
(_GL_INT_SIGNED (e) \
? _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_NEGATE_CONVERT (e, 1))
#define _GL_SIGNED_INT_MAXIMUM(e) \
(((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
/* Return 1 if the __typeof__ keyword works. This could be done by
'configure', but for now it's easier to do it by hand. */
#if 2 <= __GNUC__ || 0x5110 <= __SUNPRO_C
# define _GL_HAVE___TYPEOF__ 1
#else
# define _GL_HAVE___TYPEOF__ 0
#endif
/* Return 1 if the integer type or expression T might be signed. Return 0
if it is definitely unsigned. This macro does not evaluate its argument,
and expands to an integer constant expression. */
#if _GL_HAVE___TYPEOF__
# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
#else
# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
#endif
/* Bound on length of the string representing an unsigned integer
value representable in B bits. log10 (2.0) < 146/485. The
smallest value of B where this bound is not tight is 2621. */
#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
/* Bound on length of the string representing an integer type or expression T.
Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485;
add 1 for integer division truncation; add 1 more for a minus sign
if needed. */
# define INT_STRLEN_BOUND(t) \
((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \
+ signed_type_or_expr__ (t) + 1)
Subtract 1 for the sign bit if T is signed, and then add 1 more for
a minus sign if needed.
Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
signed, this macro may overestimate the true bound by one byte when
applied to unsigned types of size 2, 4, 16, ... bytes. */
#define INT_STRLEN_BOUND(t) \
(INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \
- _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ _GL_SIGNED_TYPE_OR_EXPR (t))
/* Bound on buffer size needed to represent an integer type or expression T,
including the terminating null. */
# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
#endif /* GL_INTPROPS_H */
/* Range overflow checks.
The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
operators might not yield numerically correct answers due to
arithmetic overflow. They do not rely on undefined or
implementation-defined behavior. Their implementations are simple
and straightforward, but they are a bit harder to use than the
INT_<op>_OVERFLOW macros described below.
Example usage:
long int i = ...;
long int j = ...;
if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
printf ("multiply would overflow");
else
printf ("product is %ld", i * j);
Restrictions on *_RANGE_OVERFLOW macros:
These macros do not check for all possible numerical problems or
undefined or unspecified behavior: they do not check for division
by zero, for bad shift counts, or for shifting negative numbers.
These macros may evaluate their arguments zero or multiple times,
so the arguments should not have side effects. The arithmetic
arguments (including the MIN and MAX arguments) must be of the same
integer type after the usual arithmetic conversions, and the type
must have minimum value MIN and maximum MAX. Unsigned types should
use a zero MIN of the proper type.
These macros are tuned for constant MIN and MAX. For commutative
operations such as A + B, they are also tuned for constant B. */
/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? (a) < (min) - (b) \
: (max) - (b) < (a))
/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? (max) + (b) < (a) \
: (a) < (min) + (b))
/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
((min) < 0 \
? (a) < - (max) \
: 0 < (a))
/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Avoid && and || as they tickle
bugs in Sun C 5.11 2010/08/13 and other compilers; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? ((a) < 0 \
? (a) < (max) / (b) \
: (b) == -1 \
? 0 \
: (min) / (b) < (a)) \
: (b) == 0 \
? 0 \
: ((a) < 0 \
? (a) < (min) / (b) \
: (max) / (b) < (a)))
/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Do not check for division by zero. */
#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
((min) < 0 && (b) == -1 && (a) < - (max))
/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Do not check for division by zero.
Mathematically, % should never overflow, but on x86-like hosts
INT_MIN % -1 traps, and the C standard permits this, so treat this
as an overflow too. */
#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Here, MIN and MAX are for A only, and B need
not be of the same type as the other arguments. The C standard says that
behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
A is negative then A << B has undefined behavior and A >> B has
implementation-defined behavior, but do not check these other
restrictions. */
#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
((a) < 0 \
? (a) < (min) >> (b) \
: (max) >> (b) < (a))
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
(e.g., A and B) have the same type as MIN and MAX. Instead, they assume
that the result (e.g., A + B) has that type. */
#define _GL_ADD_OVERFLOW(a, b, min, max) \
((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
: (a) < 0 ? (b) <= (a) + (b) \
: (b) < 0 ? (a) <= (a) + (b) \
: (a) + (b) < (b))
#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
: (a) < 0 ? 1 \
: (b) < 0 ? (a) - (b) <= (a) \
: (a) < (b))
#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
(((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
|| INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
: (a) < 0 ? (b) <= (a) + (b) - 1 \
: (b) < 0 && (a) + (b) <= (a))
#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
: (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
: (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
/* Return a nonzero value if A is a mathematical multiple of B, where
A is unsigned, B is negative, and MAX is the maximum value of A's
type. A's type must be the same as (A % B)'s type. Normally (A %
-B == 0) suffices, but things get tricky if -B would overflow. */
#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
(((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
? (a) \
: (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
: (a) % - (b)) \
== 0)
/* Integer overflow checks.
The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
might not yield numerically correct answers due to arithmetic overflow.
They work correctly on all known practical hosts, and do not rely
on undefined behavior due to signed arithmetic overflow.
Example usage:
long int i = ...;
long int j = ...;
if (INT_MULTIPLY_OVERFLOW (i, j))
printf ("multiply would overflow");
else
printf ("product is %ld", i * j);
These macros do not check for all possible numerical problems or
undefined or unspecified behavior: they do not check for division
by zero, for bad shift counts, or for shifting negative numbers.
These macros may evaluate their arguments zero or multiple times, so the
arguments should not have side effects.
These macros are tuned for their last argument being a constant.
Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
A % B, and A << B would overflow, respectively. */
#define INT_ADD_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
#define INT_SUBTRACT_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
#define INT_NEGATE_OVERFLOW(a) \
INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
#define INT_MULTIPLY_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
#define INT_DIVIDE_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
#define INT_REMAINDER_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
_GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
/* Return 1 if the expression A <op> B would overflow,
where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
assuming MIN and MAX are the minimum and maximum for the result type.
Arguments should be free of side effects. */
#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
op_result_overflow (a, b, \
_GL_INT_MINIMUM (0 * (b) + (a)), \
_GL_INT_MAXIMUM (0 * (b) + (a)))
#endif /* _GL_INTPROPS_H */

28
grub-core/gnulib/itold.c Normal file
View file

@ -0,0 +1,28 @@
/* Replacement for 'int' to 'long double' conversion routine.
Copyright (C) 2011-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
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 <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <float.h>
void
_Qp_itoq (long double *result, int a)
{
/* Convert from 'int' to 'double', then from 'double' to 'long double'. */
*result = (double) a;
}

View file

@ -1,5 +1,5 @@
/* Substitute for and wrapper around <langinfo.h>.
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 2009-2013 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
@ -12,27 +12,27 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
/*
* POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
* <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
*/
#ifndef _GL_LANGINFO_H
#ifndef _@GUARD_PREFIX@_LANGINFO_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_LANGINFO_H@
# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
#endif
#ifndef _GL_LANGINFO_H
#define _GL_LANGINFO_H
#ifndef _@GUARD_PREFIX@_LANGINFO_H
#define _@GUARD_PREFIX@_LANGINFO_H
#if !@HAVE_LANGINFO_H@
@ -40,7 +40,10 @@
/* A platform that lacks <langinfo.h>. */
/* Assume that it also lacks <nl_types.h> and the nl_item type. */
# if !GNULIB_defined_nl_item
typedef int nl_item;
# define GNULIB_defined_nl_item 1
# endif
/* nl_langinfo items of the LC_CTYPE category */
# define CODESET 10000
@ -169,5 +172,5 @@ _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
#endif
#endif /* _GL_LANGINFO_H */
#endif /* _GL_LANGINFO_H */
#endif /* _@GUARD_PREFIX@_LANGINFO_H */
#endif /* _@GUARD_PREFIX@_LANGINFO_H */

View file

@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2006, 2008-2010 Free Software Foundation, Inc.
Copyright (C) 2000-2006, 2008-2013 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
@ -13,8 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>. */
@ -30,11 +29,11 @@
#include <stdlib.h>
#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
# define DARWIN7 /* Darwin 7 or newer, i.e. MacOS X 10.3 or newer */
# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
#endif
#if defined _WIN32 || defined __WIN32__
# define WIN32_NATIVE
# define WINDOWS_NATIVE
#endif
#if defined __EMX__
@ -44,7 +43,7 @@
# endif
#endif
#if !defined WIN32_NATIVE
#if !defined WINDOWS_NATIVE
# include <unistd.h>
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
@ -57,7 +56,7 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# endif
#elif defined WIN32_NATIVE
#elif defined WINDOWS_NATIVE
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
@ -83,7 +82,7 @@
#endif
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
/* Win32, Cygwin, OS/2, DOS */
/* Native Windows, Cygwin, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#endif
@ -123,7 +122,7 @@ get_charset_aliases (void)
cp = charset_aliases;
if (cp == NULL)
{
#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__)
const char *dir;
const char *base = "charset.alias";
char *file_name;
@ -228,8 +227,7 @@ get_charset_aliases (void)
{
/* Out of memory. */
res_size = 0;
if (old_res_ptr != NULL)
free (old_res_ptr);
free (old_res_ptr);
break;
}
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
@ -309,7 +307,7 @@ get_charset_aliases (void)
"DECKOREAN" "\0" "EUC-KR" "\0";
# endif
# if defined WIN32_NATIVE || defined __CYGWIN__
# if defined WINDOWS_NATIVE || defined __CYGWIN__
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
@ -361,7 +359,7 @@ locale_charset (void)
const char *codeset;
const char *aliases;
#if !(defined WIN32_NATIVE || defined OS2)
#if !(defined WINDOWS_NATIVE || defined OS2)
# if HAVE_LANGINFO_CODESET
@ -408,10 +406,10 @@ locale_charset (void)
}
}
/* Woe32 has a function returning the locale's codepage as a number:
GetACP(). This encoding is used by Cygwin, unless the user has set
the environment variable CYGWIN=codepage:oem (which very few people
do).
/* The Windows API has a function returning the locale's codepage as a
number: GetACP(). This encoding is used by Cygwin, unless the user
has set the environment variable CYGWIN=codepage:oem (which very few
people do).
Output directed to console windows needs to be converted (to
GetOEMCP() if the console is using a raster font, or to
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
@ -454,12 +452,12 @@ locale_charset (void)
# endif
#elif defined WIN32_NATIVE
#elif defined WINDOWS_NATIVE
static char buf[2 + 10 + 1];
/* Woe32 has a function returning the locale's codepage as a number:
GetACP().
/* The Windows API has a function returning the locale's codepage as a
number: GetACP().
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
@ -544,5 +542,12 @@ locale_charset (void)
if (codeset[0] == '\0')
codeset = "ASCII";
#ifdef DARWIN7
/* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
(the default codeset) does not work when MB_CUR_MAX is 1. */
if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX <= 1)
codeset = "ASCII";
#endif
return codeset;
}

View file

@ -1,5 +1,5 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2003, 2009-2010 Free Software Foundation, Inc.
Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify
@ -13,8 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifndef _LOCALCHARSET_H
#define _LOCALCHARSET_H

View file

@ -0,0 +1,216 @@
/* A POSIX <locale.h>.
Copyright (C) 2007-2013 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 <http://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
#ifdef _GL_ALREADY_INCLUDING_LOCALE_H
/* Special invocation conventions to handle Solaris header files
(through Solaris 10) when combined with gettext's libintl.h. */
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
#else
/* Normal invocation convention. */
#ifndef _@GUARD_PREFIX@_LOCALE_H
#define _GL_ALREADY_INCLUDING_LOCALE_H
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
#undef _GL_ALREADY_INCLUDING_LOCALE_H
#ifndef _@GUARD_PREFIX@_LOCALE_H
#define _@GUARD_PREFIX@_LOCALE_H
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
#if @HAVE_XLOCALE_H@
# include <xlocale.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. */
/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
On systems that don't define it, use the same value as GNU libintl. */
#if !defined LC_MESSAGES
# define LC_MESSAGES 1729
#endif
/* Bionic libc's 'struct lconv' is just a dummy. */
#if @REPLACE_STRUCT_LCONV@
# define lconv rpl_lconv
struct lconv
{
/* All 'char *' are actually 'const char *'. */
/* Members that depend on the LC_NUMERIC category of the locale. See
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
/* Symbol used as decimal point. */
char *decimal_point;
/* Symbol used to separate groups of digits to the left of the decimal
point. */
char *thousands_sep;
/* Definition of the size of groups of digits to the left of the decimal
point. */
char *grouping;
/* Members that depend on the LC_MONETARY category of the locale. See
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
/* Symbol used as decimal point. */
char *mon_decimal_point;
/* Symbol used to separate groups of digits to the left of the decimal
point. */
char *mon_thousands_sep;
/* Definition of the size of groups of digits to the left of the decimal
point. */
char *mon_grouping;
/* Sign used to indicate a value >= 0. */
char *positive_sign;
/* Sign used to indicate a value < 0. */
char *negative_sign;
/* For formatting local currency. */
/* Currency symbol (3 characters) followed by separator (1 character). */
char *currency_symbol;
/* Number of digits after the decimal point. */
char frac_digits;
/* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char p_cs_precedes;
/* For values >= 0: Position of the sign. */
char p_sign_posn;
/* For values >= 0: Placement of spaces between currency symbol, sign, and
number. */
char p_sep_by_space;
/* For values < 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char n_cs_precedes;
/* For values < 0: Position of the sign. */
char n_sign_posn;
/* For values < 0: Placement of spaces between currency symbol, sign, and
number. */
char n_sep_by_space;
/* For formatting international currency. */
/* Currency symbol (3 characters) followed by separator (1 character). */
char *int_curr_symbol;
/* Number of digits after the decimal point. */
char int_frac_digits;
/* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char int_p_cs_precedes;
/* For values >= 0: Position of the sign. */
char int_p_sign_posn;
/* For values >= 0: Placement of spaces between currency symbol, sign, and
number. */
char int_p_sep_by_space;
/* For values < 0: 1 if the currency symbol precedes the number, 0 if it
comes after the number. */
char int_n_cs_precedes;
/* For values < 0: Position of the sign. */
char int_n_sign_posn;
/* For values < 0: Placement of spaces between currency symbol, sign, and
number. */
char int_n_sep_by_space;
};
#endif
#if @GNULIB_LOCALECONV@
# if @REPLACE_LOCALECONV@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef localeconv
# define localeconv rpl_localeconv
# endif
_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void));
_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
# else
_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
# endif
_GL_CXXALIASWARN (localeconv);
#elif @REPLACE_STRUCT_LCONV@
# undef localeconv
# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
#elif defined GNULIB_POSIXCHECK
# undef localeconv
# if HAVE_RAW_DECL_LOCALECONV
_GL_WARN_ON_USE (localeconv,
"localeconv returns too few information on some platforms - "
"use gnulib module localeconv for portability");
# endif
#endif
#if @GNULIB_SETLOCALE@
# if @REPLACE_SETLOCALE@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef setlocale
# define setlocale rpl_setlocale
# define GNULIB_defined_setlocale 1
# endif
_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale));
_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
# else
_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
# endif
_GL_CXXALIASWARN (setlocale);
#elif defined GNULIB_POSIXCHECK
# undef setlocale
# if HAVE_RAW_DECL_SETLOCALE
_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
"use gnulib module setlocale for portability");
# endif
#endif
#if @GNULIB_DUPLOCALE@
# if @REPLACE_DUPLOCALE@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef duplocale
# define duplocale rpl_duplocale
# endif
_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
# else
# if @HAVE_DUPLOCALE@
_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
# endif
# endif
# if @HAVE_DUPLOCALE@
_GL_CXXALIASWARN (duplocale);
# endif
#elif defined GNULIB_POSIXCHECK
# undef duplocale
# if HAVE_RAW_DECL_DUPLOCALE
_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
"use gnulib module duplocale for portability");
# endif
#endif
#endif /* _@GUARD_PREFIX@_LOCALE_H */
#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */
#endif /* _@GUARD_PREFIX@_LOCALE_H */

View file

@ -0,0 +1,103 @@
/* Query locale dependent information for formatting numbers.
Copyright (C) 2012-2013 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 <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <locale.h>
#if HAVE_STRUCT_LCONV_DECIMAL_POINT
/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_*
members. */
struct lconv *
localeconv (void)
{
static struct lconv result;
# undef lconv
# undef localeconv
struct lconv *sys_result = localeconv ();
result.decimal_point = sys_result->decimal_point;
result.thousands_sep = sys_result->thousands_sep;
result.grouping = sys_result->grouping;
result.mon_decimal_point = sys_result->mon_decimal_point;
result.mon_thousands_sep = sys_result->mon_thousands_sep;
result.mon_grouping = sys_result->mon_grouping;
result.positive_sign = sys_result->positive_sign;
result.negative_sign = sys_result->negative_sign;
result.currency_symbol = sys_result->currency_symbol;
result.frac_digits = sys_result->frac_digits;
result.p_cs_precedes = sys_result->p_cs_precedes;
result.p_sign_posn = sys_result->p_sign_posn;
result.p_sep_by_space = sys_result->p_sep_by_space;
result.n_cs_precedes = sys_result->n_cs_precedes;
result.n_sign_posn = sys_result->n_sign_posn;
result.n_sep_by_space = sys_result->n_sep_by_space;
result.int_curr_symbol = sys_result->int_curr_symbol;
result.int_frac_digits = sys_result->int_frac_digits;
result.int_p_cs_precedes = sys_result->p_cs_precedes;
result.int_p_sign_posn = sys_result->p_sign_posn;
result.int_p_sep_by_space = sys_result->p_sep_by_space;
result.int_n_cs_precedes = sys_result->n_cs_precedes;
result.int_n_sign_posn = sys_result->n_sign_posn;
result.int_n_sep_by_space = sys_result->n_sep_by_space;
return &result;
}
#else
/* Override for platforms where 'struct lconv' is a dummy. */
# include <limits.h>
struct lconv *
localeconv (void)
{
static /*const*/ struct lconv result =
{
/* decimal_point */ ".",
/* thousands_sep */ "",
/* grouping */ "",
/* mon_decimal_point */ "",
/* mon_thousands_sep */ "",
/* mon_grouping */ "",
/* positive_sign */ "",
/* negative_sign */ "",
/* currency_symbol */ "",
/* frac_digits */ CHAR_MAX,
/* p_cs_precedes */ CHAR_MAX,
/* p_sign_posn */ CHAR_MAX,
/* p_sep_by_space */ CHAR_MAX,
/* n_cs_precedes */ CHAR_MAX,
/* n_sign_posn */ CHAR_MAX,
/* n_sep_by_space */ CHAR_MAX,
/* int_curr_symbol */ "",
/* int_frac_digits */ CHAR_MAX,
/* int_p_cs_precedes */ CHAR_MAX,
/* int_p_sign_posn */ CHAR_MAX,
/* int_p_sep_by_space */ CHAR_MAX,
/* int_n_cs_precedes */ CHAR_MAX,
/* int_n_sign_posn */ CHAR_MAX,
/* int_n_sep_by_space */ CHAR_MAX
};
return &result;
}
#endif

View file

@ -1,6 +1,6 @@
/* malloc() function that is glibc compatible.
Copyright (C) 1997-1998, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Copyright (C) 1997-1998, 2006-2007, 2009-2013 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
@ -13,11 +13,11 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* written by Jim Meyering and Bruno Haible */
#define _GL_USE_STDLIB_ALLOC 1
#include <config.h>
/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
#ifdef malloc
@ -28,14 +28,10 @@
# define NEED_MALLOC_GNU 1
#endif
/* Specification. */
#include <stdlib.h>
#include <errno.h>
/* Call the system's malloc below. */
#undef malloc
/* Allocate an N-byte block of memory from the heap.
If N is zero, allocate a 1-byte block. */

View file

@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
Copyright (C) 1999-2002, 2005-2010 Free Software Foundation, Inc.
Copyright (C) 1999-2002, 2005-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@ -40,9 +40,6 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
char *pstate = (char *)ps;
if (pstate == NULL)
pstate = internal_state;
if (s == NULL)
{
pwc = NULL;
@ -54,6 +51,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
return (size_t)(-2);
/* Here n > 0. */
if (pstate == NULL)
pstate = internal_state;
{
size_t nstate = pstate[0];
char buf[4];
@ -91,7 +92,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
/* Here m > 0. */
# if __GLIBC__
# if __GLIBC__ || defined __UCLIBC__
/* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
mbtowc (NULL, NULL, 0);
# endif
@ -127,7 +128,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
const char *encoding = locale_charset ();
if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
{
/* Cf. unistr/u8-mblen.c. */
unsigned char c = (unsigned char) p[0];
@ -184,7 +185,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
/* As a reference for this code, you can use the GNU libiconv
implementation. Look for uses of the RET_TOOFEW macro. */
if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
if (STREQ_OPT (encoding,
"EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
{
if (m == 1)
{
@ -207,9 +209,12 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|| STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|| STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
if (STREQ_OPT (encoding,
"EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|| STREQ_OPT (encoding,
"GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|| STREQ_OPT (encoding,
"BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
{
if (m == 1)
{
@ -220,7 +225,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
if (STREQ_OPT (encoding,
"EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
{
if (m == 1)
{
@ -238,7 +244,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
if (STREQ_OPT (encoding,
"GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
{
if (m == 1)
{
@ -271,7 +278,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
{
if (m == 1)
{
@ -321,7 +328,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
size_t
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG
# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG
if (s == NULL)
{
pwc = NULL;
@ -334,7 +341,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
static mbstate_t internal_state;
/* Override mbrtowc's internal state. We can not call mbsinit() on the
/* Override mbrtowc's internal state. We cannot call mbsinit() on the
hidden internal state, but we can call it on our variable. */
if (ps == NULL)
ps = &internal_state;
@ -379,7 +386,16 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
return ret;
}
# else
return mbrtowc (pwc, s, n, ps);
{
# if MBRTOWC_NULL_ARG1_BUG
wchar_t dummy;
if (pwc == NULL)
pwc = &dummy;
# endif
return mbrtowc (pwc, s, n, ps);
}
# endif
}

View file

@ -1,5 +1,5 @@
/* Test for initial conversion state.
Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 2008-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@ -22,6 +22,18 @@
#include "verify.h"
#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
/* On native Windows, 'mbstate_t' is defined as 'int'. */
int
mbsinit (const mbstate_t *ps)
{
return ps == NULL || *ps == 0;
}
#else
/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
and wcrtomb(), wcsrtombs().
We assume that
@ -43,5 +55,7 @@ mbsinit (const mbstate_t *ps)
{
const char *pstate = (const char *)ps;
return pstate[0] == 0;
return pstate == NULL || pstate[0] == 0;
}
#endif

View file

@ -0,0 +1,122 @@
/* Convert string to wide string.
Copyright (C) 2008-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
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 <http://www.gnu.org/licenses/>. */
size_t
mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
{
if (ps == NULL)
ps = &_gl_mbsrtowcs_state;
{
const char *src = *srcp;
if (dest != NULL)
{
wchar_t *destptr = dest;
for (; len > 0; destptr++, len--)
{
size_t src_avail;
size_t ret;
/* An optimized variant of
src_avail = strnlen1 (src, MB_LEN_MAX); */
if (src[0] == '\0')
src_avail = 1;
else if (src[1] == '\0')
src_avail = 2;
else if (src[2] == '\0')
src_avail = 3;
else if (MB_LEN_MAX <= 4 || src[3] == '\0')
src_avail = 4;
else
src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
/* Parse the next multibyte character. */
ret = mbrtowc (destptr, src, src_avail, ps);
if (ret == (size_t)(-2))
/* Encountered a multibyte character that extends past a '\0' byte
or that is longer than MB_LEN_MAX bytes. Cannot happen. */
abort ();
if (ret == (size_t)(-1))
goto bad_input;
if (ret == 0)
{
src = NULL;
/* Here mbsinit (ps). */
break;
}
src += ret;
}
*srcp = src;
return destptr - dest;
}
else
{
/* Ignore dest and len, don't store *srcp at the end, and
don't clobber *ps. */
mbstate_t state = *ps;
size_t totalcount = 0;
for (;; totalcount++)
{
size_t src_avail;
size_t ret;
/* An optimized variant of
src_avail = strnlen1 (src, MB_LEN_MAX); */
if (src[0] == '\0')
src_avail = 1;
else if (src[1] == '\0')
src_avail = 2;
else if (src[2] == '\0')
src_avail = 3;
else if (MB_LEN_MAX <= 4 || src[3] == '\0')
src_avail = 4;
else
src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
/* Parse the next multibyte character. */
ret = mbrtowc (NULL, src, src_avail, &state);
if (ret == (size_t)(-2))
/* Encountered a multibyte character that extends past a '\0' byte
or that is longer than MB_LEN_MAX bytes. Cannot happen. */
abort ();
if (ret == (size_t)(-1))
goto bad_input2;
if (ret == 0)
{
/* Here mbsinit (&state). */
break;
}
src += ret;
}
return totalcount;
}
bad_input:
*srcp = src;
bad_input2:
errno = EILSEQ;
return (size_t)(-1);
}
}

View file

@ -1,5 +1,5 @@
/* Convert string to wide string.
Copyright (C) 2008-2010 Free Software Foundation, Inc.
Copyright (C) 2008-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@ -22,7 +22,7 @@
/* Internal state used by the functions mbsrtowcs() and mbsnrtowcs(). */
mbstate_t _gl_mbsrtowcs_state
/* The state must initially be in the "initial state"; so, zero-initialize it.
On most systems, putting it into BSS is sufficient. Not so on MacOS X 10.3,
On most systems, putting it into BSS is sufficient. Not so on Mac OS X 10.3,
see <http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>.
When it needs an initializer, use 0 or {0} as initializer? 0 only works
when mbstate_t is a scalar type (such as when gnulib defines it, or on

View file

@ -1,5 +1,5 @@
/* Convert string to wide string.
Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 2008-2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@ -29,108 +29,4 @@
extern mbstate_t _gl_mbsrtowcs_state;
size_t
mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
{
if (ps == NULL)
ps = &_gl_mbsrtowcs_state;
{
const char *src = *srcp;
if (dest != NULL)
{
wchar_t *destptr = dest;
for (; len > 0; destptr++, len--)
{
size_t src_avail;
size_t ret;
/* An optimized variant of
src_avail = strnlen1 (src, MB_LEN_MAX); */
if (src[0] == '\0')
src_avail = 1;
else if (src[1] == '\0')
src_avail = 2;
else if (src[2] == '\0')
src_avail = 3;
else if (MB_LEN_MAX <= 4 || src[3] == '\0')
src_avail = 4;
else
src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
/* Parse the next multibyte character. */
ret = mbrtowc (destptr, src, src_avail, ps);
if (ret == (size_t)(-2))
/* Encountered a multibyte character that extends past a '\0' byte
or that is longer than MB_LEN_MAX bytes. Cannot happen. */
abort ();
if (ret == (size_t)(-1))
goto bad_input;
if (ret == 0)
{
src = NULL;
/* Here mbsinit (ps). */
break;
}
src += ret;
}
*srcp = src;
return destptr - dest;
}
else
{
/* Ignore dest and len, don't store *srcp at the end, and
don't clobber *ps. */
mbstate_t state = *ps;
size_t totalcount = 0;
for (;; totalcount++)
{
size_t src_avail;
size_t ret;
/* An optimized variant of
src_avail = strnlen1 (src, MB_LEN_MAX); */
if (src[0] == '\0')
src_avail = 1;
else if (src[1] == '\0')
src_avail = 2;
else if (src[2] == '\0')
src_avail = 3;
else if (MB_LEN_MAX <= 4 || src[3] == '\0')
src_avail = 4;
else
src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
/* Parse the next multibyte character. */
ret = mbrtowc (NULL, src, src_avail, &state);
if (ret == (size_t)(-2))
/* Encountered a multibyte character that extends past a '\0' byte
or that is longer than MB_LEN_MAX bytes. Cannot happen. */
abort ();
if (ret == (size_t)(-1))
goto bad_input2;
if (ret == 0)
{
/* Here mbsinit (&state). */
break;
}
src += ret;
}
return totalcount;
}
bad_input:
*srcp = src;
bad_input2:
errno = EILSEQ;
return (size_t)(-1);
}
}
#include "mbsrtowcs-impl.h"

Some files were not shown because too many files have changed in this diff Show more