2006-06-14 Yoshinori K. Okuji <okuji@enbug.org>
* util/misc.c: Include config.h. [!HAVE_MEMALIGN]: Do not include malloc.h. (grub_memalign): Use posix_memalign, if present. Then, use memalign, if present. Otherwise, emit an error. * util/grub-emu.c: Do not include malloc.h. * include/grub/util/misc.h: Include unistd.h. This is required for FreeBSD, because off_t is defined in unistd.h. Reported by Harley D. Eades III <hde@foobar-qux.org>. * configure.ac (AC_GNU_SOURCE): Added. (AC_CHECK_FUNCS): Check posix_memalign and memalign for the host type.
This commit is contained in:
parent
fd39d4da42
commit
4889bdeca3
8 changed files with 165 additions and 6 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
2006-06-14 Yoshinori K. Okuji <okuji@enbug.org>
|
||||||
|
|
||||||
|
* util/misc.c: Include config.h.
|
||||||
|
[!HAVE_MEMALIGN]: Do not include malloc.h.
|
||||||
|
(grub_memalign): Use posix_memalign, if present. Then, use
|
||||||
|
memalign, if present. Otherwise, emit an error.
|
||||||
|
|
||||||
|
* util/grub-emu.c: Do not include malloc.h.
|
||||||
|
|
||||||
|
* include/grub/util/misc.h: Include unistd.h. This is required for
|
||||||
|
FreeBSD, because off_t is defined in unistd.h. Reported by Harley
|
||||||
|
D. Eades III <hde@foobar-qux.org>.
|
||||||
|
|
||||||
|
* configure.ac (AC_GNU_SOURCE): Added.
|
||||||
|
(AC_CHECK_FUNCS): Check posix_memalign and memalign for the host
|
||||||
|
type.
|
||||||
|
|
||||||
2006-06-09 Yoshinori K. Okuji <okuji@enbug.org>
|
2006-06-09 Yoshinori K. Okuji <okuji@enbug.org>
|
||||||
|
|
||||||
* loader/i386/pc/linux.c (grub_rescue_cmd_initrd): Make sure that
|
* loader/i386/pc/linux.c (grub_rescue_cmd_initrd): Make sure that
|
||||||
|
|
3
THANKS
3
THANKS
|
@ -7,9 +7,10 @@ time and energy in helping to track down bugs, add new features, and
|
||||||
generally assist in the GRUB 2 maintainership process:
|
generally assist in the GRUB 2 maintainership process:
|
||||||
|
|
||||||
Guillem Jover <guillem@hadrons.org>
|
Guillem Jover <guillem@hadrons.org>
|
||||||
|
Harley D. Eades III <hde@foobar-qux.org>
|
||||||
|
Hollis Blanchard <hollis@penguinppc.org>
|
||||||
Jeroen Dekkers <jeroen@dekkers.cx>
|
Jeroen Dekkers <jeroen@dekkers.cx>
|
||||||
Johan Rydberg <jrydberg@night.trouble.net>
|
Johan Rydberg <jrydberg@night.trouble.net>
|
||||||
Hollis Blanchard <hollis@penguinppc.org>
|
|
||||||
Marco Gerards <metgerards@student.han.nl>
|
Marco Gerards <metgerards@student.han.nl>
|
||||||
NIIBE Yutaka <gniibe@m17n.org>
|
NIIBE Yutaka <gniibe@m17n.org>
|
||||||
Omniflux <omniflux@omniflux.com>
|
Omniflux <omniflux@omniflux.com>
|
||||||
|
|
11
config.h.in
11
config.h.in
|
@ -31,6 +31,9 @@
|
||||||
/* Define to 1 if you have the <lzo/lzo1x.h> header file. */
|
/* Define to 1 if you have the <lzo/lzo1x.h> header file. */
|
||||||
#undef HAVE_LZO_LZO1X_H
|
#undef HAVE_LZO_LZO1X_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memalign' function. */
|
||||||
|
#undef HAVE_MEMALIGN
|
||||||
|
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
@ -40,6 +43,9 @@
|
||||||
/* Define to 1 if you have the <ncurses.h> header file. */
|
/* Define to 1 if you have the <ncurses.h> header file. */
|
||||||
#undef HAVE_NCURSES_H
|
#undef HAVE_NCURSES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `posix_memalign' function. */
|
||||||
|
#undef HAVE_POSIX_MEMALIGN
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdint.h> header file. */
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
#undef HAVE_STDINT_H
|
#undef HAVE_STDINT_H
|
||||||
|
|
||||||
|
@ -101,5 +107,10 @@
|
||||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
#undef _FILE_OFFSET_BITS
|
#undef _FILE_OFFSET_BITS
|
||||||
|
|
||||||
|
/* Enable GNU extensions on systems that have them. */
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# undef _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define for large files, on AIX-style hosts. */
|
/* Define for large files, on AIX-style hosts. */
|
||||||
#undef _LARGE_FILES
|
#undef _LARGE_FILES
|
||||||
|
|
111
configure
vendored
111
configure
vendored
|
@ -2710,6 +2710,12 @@ echo "$as_me: error: GCC is required" >&2;}
|
||||||
{ (exit 1); exit 1; }; }
|
{ (exit 1); exit 1; }; }
|
||||||
|
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define _GNU_SOURCE 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check whether --enable-largefile or --disable-largefile was given.
|
# Check whether --enable-largefile or --disable-largefile was given.
|
||||||
if test "${enable_largefile+set}" = set; then
|
if test "${enable_largefile+set}" = set; then
|
||||||
enableval="$enable_largefile"
|
enableval="$enable_largefile"
|
||||||
|
@ -5392,6 +5398,111 @@ fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Check for functions.
|
||||||
|
|
||||||
|
|
||||||
|
for ac_func in posix_memalign memalign
|
||||||
|
do
|
||||||
|
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
|
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||||
|
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
|
||||||
|
if eval "test \"\${$as_ac_var+set}\" = set"; then
|
||||||
|
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||||
|
else
|
||||||
|
cat >conftest.$ac_ext <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
|
||||||
|
For example, HP-UX 11i <limits.h> declares gettimeofday. */
|
||||||
|
#define $ac_func innocuous_$ac_func
|
||||||
|
|
||||||
|
/* System header to define __stub macros and hopefully few prototypes,
|
||||||
|
which can conflict with char $ac_func (); below.
|
||||||
|
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
|
||||||
|
<limits.h> exists even on freestanding compilers. */
|
||||||
|
|
||||||
|
#ifdef __STDC__
|
||||||
|
# include <limits.h>
|
||||||
|
#else
|
||||||
|
# include <assert.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef $ac_func
|
||||||
|
|
||||||
|
/* Override any gcc2 internal prototype to avoid an error. */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
/* We use char because int might match the return type of a gcc2
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
char $ac_func ();
|
||||||
|
/* The GNU C library defines this for functions which it implements
|
||||||
|
to always fail with ENOSYS. Some functions are actually named
|
||||||
|
something starting with __ and the normal name is an alias. */
|
||||||
|
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
|
||||||
|
choke me
|
||||||
|
#else
|
||||||
|
char (*f) () = $ac_func;
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
return f != $ac_func;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||||
|
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||||
|
(eval $ac_link) 2>conftest.er1
|
||||||
|
ac_status=$?
|
||||||
|
grep -v '^ *+' conftest.er1 >conftest.err
|
||||||
|
rm -f conftest.er1
|
||||||
|
cat conftest.err >&5
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); } &&
|
||||||
|
{ ac_try='test -z "$ac_c_werror_flag"
|
||||||
|
|| test ! -s conftest.err'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; } &&
|
||||||
|
{ ac_try='test -s conftest$ac_exeext'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
eval "$as_ac_var=yes"
|
||||||
|
else
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
eval "$as_ac_var=no"
|
||||||
|
fi
|
||||||
|
rm -f conftest.err conftest.$ac_objext \
|
||||||
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
|
||||||
|
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
|
||||||
|
if test `eval echo '${'$as_ac_var'}'` = yes; then
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for target programs.
|
# Check for target programs.
|
||||||
#
|
#
|
||||||
|
|
|
@ -114,6 +114,7 @@ AC_PROG_CC
|
||||||
# Must be GCC.
|
# Must be GCC.
|
||||||
test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
|
test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
|
||||||
|
|
||||||
|
AC_GNU_SOURCE
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
|
|
||||||
# Identify characteristics of the host architecture.
|
# Identify characteristics of the host architecture.
|
||||||
|
@ -152,6 +153,9 @@ AC_SUBST(LIBCURSES)
|
||||||
# Check for headers.
|
# Check for headers.
|
||||||
AC_CHECK_HEADERS(ncurses/curses.h ncurses.h curses.h)
|
AC_CHECK_HEADERS(ncurses/curses.h ncurses.h curses.h)
|
||||||
|
|
||||||
|
# Check for functions.
|
||||||
|
AC_CHECK_FUNCS(posix_memalign memalign)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for target programs.
|
# Check for target programs.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 2002,2003,2005 Free Software Foundation, Inc.
|
* Copyright (C) 2002,2003,2005,2006 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* GRUB is free software; you can redistribute it and/or modify
|
* GRUB is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
extern char *progname;
|
extern char *progname;
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
21
util/misc.c
21
util/misc.c
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 2002,2003,2005 Free Software Foundation, Inc.
|
* Copyright (C) 2002,2003,2005,2006 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* GRUB is free software; you can redistribute it and/or modify
|
* GRUB is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -24,7 +26,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
|
@ -32,6 +33,12 @@
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/machine/time.h>
|
#include <grub/machine/time.h>
|
||||||
|
|
||||||
|
/* Include malloc.h, only if memalign is available. It is known that
|
||||||
|
memalign is declared in malloc.h in all systems, if present. */
|
||||||
|
#ifdef HAVE_MEMALIGN
|
||||||
|
# include <malloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
char *progname = 0;
|
char *progname = 0;
|
||||||
int verbosity = 0;
|
int verbosity = 0;
|
||||||
|
|
||||||
|
@ -228,8 +235,16 @@ void *
|
||||||
grub_memalign (grub_size_t align, grub_size_t size)
|
grub_memalign (grub_size_t align, grub_size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
|
#if defined(HAVE_POSIX_MEMALIGN)
|
||||||
|
if (posix_memalign (&p, align, size) != 0)
|
||||||
|
p = 0;
|
||||||
|
#elif defined(HAVE_MEMALIGN)
|
||||||
p = memalign (align, size);
|
p = memalign (align, size);
|
||||||
|
#else
|
||||||
|
grub_util_error ("grub_memalign is not supported");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (! p)
|
if (! p)
|
||||||
grub_util_error ("out of memory");
|
grub_util_error ("out of memory");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue