Skip to content

Commit

Permalink
Update gnulib files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jas4711 committed Jun 18, 2009
1 parent 1fd7d3a commit a8ef093
Show file tree
Hide file tree
Showing 21 changed files with 273 additions and 51 deletions.
13 changes: 12 additions & 1 deletion gl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ EXTRA_libgnu_la_SOURCES += getline.c

## end gnulib module getline

## begin gnulib module getpagesize


EXTRA_DIST += getpagesize.c

EXTRA_libgnu_la_SOURCES += getpagesize.c

## end gnulib module getpagesize

## begin gnulib module getpass-gnu


Expand Down Expand Up @@ -361,7 +370,7 @@ EXTRA_DIST += $(top_srcdir)/maint.mk
## begin gnulib module memchr


EXTRA_DIST += memchr.c
EXTRA_DIST += memchr.c memchr.valgrind

EXTRA_libgnu_la_SOURCES += memchr.c

Expand Down Expand Up @@ -816,6 +825,7 @@ string.h: string.in.h
-e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \
-e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \
-e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \
-e 's|@''GNULIB_MEMCHR''@|$(GNULIB_MEMCHR)|g' \
-e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
-e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
-e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
Expand Down Expand Up @@ -852,6 +862,7 @@ string.h: string.in.h
-e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
Expand Down
7 changes: 6 additions & 1 deletion gl/errno.in.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
Copyright (C) 2008 Free Software Foundation, Inc.
Copyright (C) 2008-2009 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
Expand Down Expand Up @@ -145,6 +145,11 @@
# define GNULIB_defined_ENOTSUP 1
# endif

# ifndef ESTALE
# define ESTALE 2009
# define GNULIB_defined_ESTALE 1
# endif

# ifndef ECANCELED
# define ECANCELED 2008
# define GNULIB_defined_ECANCELED 1
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion gl/m4/errno_h.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# errno_h.m4 serial 5
# errno_h.m4 serial 6
dnl Copyright (C) 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -34,6 +34,9 @@ booboo
#if !defined ENOTSUP
booboo
#endif
#if !defined ESTALE
booboo
#endif
#if !defined ECANCELED
booboo
#endif
Expand Down
11 changes: 5 additions & 6 deletions gl/m4/gnulib-comp.m4
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ AC_SUBST([LTALLOCA])
gl_STDIO_MODULE_INDICATOR([getdelim])
gl_FUNC_GETLINE
gl_STDIO_MODULE_INDICATOR([getline])
gl_FUNC_GETPAGESIZE
gl_UNISTD_MODULE_INDICATOR([getpagesize])
gl_FUNC_GETPASS_GNU
AC_SUBST([LIBINTL])
AC_SUBST([LTLIBINTL])
Expand All @@ -114,6 +116,7 @@ AC_SUBST([LTALLOCA])
gl_FUNC_LSEEK
gl_UNISTD_MODULE_INDICATOR([lseek])
gl_FUNC_MEMCHR
gl_STRING_MODULE_INDICATOR([memchr])
gl_MINMAX
gl_MULTIARCH
gl_HEADER_NETDB
Expand Down Expand Up @@ -221,8 +224,6 @@ AC_SUBST([LTALLOCA])
gl_COMMON
gl_source_base='gl/tests'
gl_FUNC_UNGETC_WORKS
gl_FUNC_GETPAGESIZE
gl_UNISTD_MODULE_INDICATOR([getpagesize])
gl_FUNC_GETTIMEOFDAY
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
Expand All @@ -231,9 +232,6 @@ AC_SUBST([LTALLOCA])
fi
gl_SYS_IOCTL_MODULE_INDICATOR([ioctl])
gl_MODULE_INDICATOR([ioctl])
gl_FUNC_MMAP_ANON
AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
gt_TYPE_WCHAR_T
gt_TYPE_WINT_T
Expand Down Expand Up @@ -369,6 +367,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/getaddrinfo.c
lib/getdelim.c
lib/getline.c
lib/getpagesize.c
lib/getpass.c
lib/getpass.h
lib/gettext.h
Expand All @@ -378,6 +377,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/listen.c
lib/lseek.c
lib/memchr.c
lib/memchr.valgrind
lib/minmax.h
lib/netdb.in.h
lib/netinet_in.in.h
Expand Down Expand Up @@ -541,7 +541,6 @@ AC_DEFUN([gl_FILE_LIST], [
tests/test-wchar.c
tests/zerosize-ptr.h
tests=lib/dummy.c
tests=lib/getpagesize.c
tests=lib/gettimeofday.c
tests=lib/ioctl.c
tests=lib/sys_ioctl.in.h
Expand Down
72 changes: 70 additions & 2 deletions gl/m4/memchr.m4
Original file line number Diff line number Diff line change
@@ -1,14 +1,82 @@
# memchr.m4 serial 5
# memchr.m4 serial 7
dnl Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

AC_DEFUN([gl_FUNC_MEMCHR],
AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
[
dnl Check for prerequisites for memory fence checks.
gl_FUNC_MMAP_ANON
AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
dnl These days, we assume memchr is present. But just in case...
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
AC_REPLACE_FUNCS([memchr])
if test $ac_cv_func_memchr = no; then
gl_PREREQ_MEMCHR
REPLACE_MEMCHR=1
fi
if test $ac_cv_func_memchr = yes; then
# Detect platform-specific bugs in some versions of glibc:
# memchr should not dereference anything with length 0
# http://bugzilla.redhat.com/499689
# memchr should not dereference overestimated length after a match
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
# http://sourceware.org/bugzilla/show_bug.cgi?id=10162
# Assume that memchr works on platforms that lack mprotect.
AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <string.h>
#if HAVE_SYS_MMAN_H
# include <fcntl.h>
# include <unistd.h>
# include <sys/types.h>
# include <sys/mman.h>
# ifndef MAP_FILE
# define MAP_FILE 0
# endif
#endif
]], [[
char *fence = NULL;
#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
# if HAVE_MAP_ANONYMOUS
const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
const int fd = -1;
# else /* !HAVE_MAP_ANONYMOUS */
const int flags = MAP_FILE | MAP_PRIVATE;
int fd = open ("/dev/zero", O_RDONLY, 0666);
if (fd >= 0)
# endif
{
int pagesize = getpagesize ();
char *two_pages =
(char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
flags, fd, 0);
if (two_pages != (char *)(-1)
&& mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
fence = two_pages + pagesize;
}
#endif
if (fence)
{
if (memchr (fence, 0, 0))
return 1;
strcpy (fence - 9, "12345678");
if (memchr (fence - 9, 0, 79) != fence - 1)
return 2;
}
return 0;
]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
[dnl Be pessimistic for now.
gl_cv_func_memchr_works="guessing no"])])
if test "$gl_cv_func_memchr_works" != yes; then
gl_PREREQ_MEMCHR
REPLACE_MEMCHR=1
AC_LIBOBJ([memchr])
fi
fi
])

Expand Down
6 changes: 4 additions & 2 deletions gl/m4/string_h.m4
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Configure a GNU-like replacement for <string.h>.

# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
# Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# serial 6
# serial 7

# Written by Paul Eggert.

Expand All @@ -32,6 +32,7 @@ AC_DEFUN([gl_STRING_MODULE_INDICATOR],

AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
[
GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR])
GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM])
GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY])
GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR])
Expand Down Expand Up @@ -83,6 +84,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
Expand Down
14 changes: 14 additions & 0 deletions gl/memchr.valgrind
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Suppress a valgrind message about use of uninitialized memory in memchr().
# POSIX states that when the character is found, memchr must not read extra
# bytes in an overestimated length (for example, where memchr is used to
# implement strnlen). However, we use a safe word read to provide a speedup.
{
memchr-value4
Memcheck:Value4
fun:rpl_memchr
}
{
memchr-value8
Memcheck:Value8
fun:rpl_memchr
}
8 changes: 7 additions & 1 deletion gl/strerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,13 @@ rpl_strerror (int n)
break;
# endif

# if GNULIB_defined_
# if GNULIB_defined_ESTALE
case ESTALE:
msg = "Stale NFS file handle";
break;
# endif

# if GNULIB_defined_ECANCELED
case ECANCELED:
msg = "Operation canceled";
break;
Expand Down
17 changes: 16 additions & 1 deletion gl/string.in.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* A GNU-like <string.h>.
Copyright (C) 1995-1996, 2001-2008 Free Software Foundation, Inc.
Copyright (C) 1995-1996, 2001-2009 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
Expand Down Expand Up @@ -49,6 +49,21 @@ extern "C" {
#endif


/* Return the first instance of C within N bytes of S, or NULL. */
#if @GNULIB_MEMCHR@
# if @REPLACE_MEMCHR@
# define memchr rpl_memchr
extern void *memchr (void const *__s, int __c, size_t __n)
__attribute__ ((__pure__));
# endif
#elif defined GNULIB_POSIXCHECK
# undef memchr
# define memchr(s,c,n) \
(GL_LINK_WARNING ("memchr has platform-specific bugs - " \
"use gnulib module memchr for portability" ), \
memchr (s, c, n))
#endif

/* Return the first occurrence of NEEDLE in HAYSTACK. */
#if @GNULIB_MEMMEM@
# if @REPLACE_MEMMEM@
Expand Down
9 changes: 0 additions & 9 deletions gl/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@ EXTRA_DIST += test-getline.c

## end gnulib module getline-tests

## begin gnulib module getpagesize


EXTRA_DIST += getpagesize.c

EXTRA_libtests_a_SOURCES += getpagesize.c

## end gnulib module getpagesize

## begin gnulib module gettimeofday


Expand Down
13 changes: 12 additions & 1 deletion lib/gl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ EXTRA_liblgnu_la_SOURCES += fseeko.c

## end gnulib module fseeko

## begin gnulib module getpagesize


EXTRA_DIST += getpagesize.c

EXTRA_liblgnu_la_SOURCES += getpagesize.c

## end gnulib module getpagesize

## begin gnulib module gettext

# This is for those projects which use "gettextize --intl" to put a source-code
Expand Down Expand Up @@ -200,7 +209,7 @@ EXTRA_liblgnu_la_SOURCES += lseek.c
## begin gnulib module memchr


EXTRA_DIST += memchr.c
EXTRA_DIST += memchr.c memchr.valgrind

EXTRA_liblgnu_la_SOURCES += memchr.c

Expand Down Expand Up @@ -543,6 +552,7 @@ string.h: string.in.h
-e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \
-e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \
-e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \
-e 's|@''GNULIB_MEMCHR''@|$(GNULIB_MEMCHR)|g' \
-e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
-e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
-e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
Expand Down Expand Up @@ -579,6 +589,7 @@ string.h: string.in.h
-e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
Expand Down
7 changes: 6 additions & 1 deletion lib/gl/errno.in.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
Copyright (C) 2008 Free Software Foundation, Inc.
Copyright (C) 2008-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -145,6 +145,11 @@
# define GNULIB_defined_ENOTSUP 1
# endif

# ifndef ESTALE
# define ESTALE 2009
# define GNULIB_defined_ESTALE 1
# endif

# ifndef ECANCELED
# define ECANCELED 2008
# define GNULIB_defined_ECANCELED 1
Expand Down
Loading

0 comments on commit a8ef093

Please sign in to comment.