mirror of
https://https.git.savannah.gnu.org/git/gettext.git
synced 2026-01-26 07:37:57 +00:00
Fix link errors related to C99-style extern inline.
After recent C99-style extern inline changes in gnulib, functions defined in xsize.h are now declared as "extern inline". That means the libraries using those functions need to be linked to xsize.o.
This commit is contained in:
parent
2d9a54eef9
commit
eb1ef102cc
@ -1,3 +1,9 @@
|
||||
2013-01-17 Daiki Ueno <ueno@gnu.org>
|
||||
|
||||
Fix link errors related to C99-style extern inline.
|
||||
Reported by Sam Thursfield <sam.thursfield@codethink.co.uk>.
|
||||
* autogen.sh (GNULIB_MODULES_LIBASPRINTF): Add xsize.
|
||||
|
||||
2012-12-25 Daiki Ueno <ueno@gnu.org>
|
||||
|
||||
* gettext-0.18.2 released.
|
||||
|
||||
@ -109,7 +109,7 @@ if ! $skip_gnulib; then
|
||||
alloca
|
||||
errno
|
||||
verify
|
||||
extern-inline
|
||||
xsize
|
||||
'
|
||||
GNULIB_MODULES_LIBASPRINTF_OTHER='
|
||||
'
|
||||
|
||||
@ -1,3 +1,13 @@
|
||||
2013-01-17 Daiki Ueno <ueno@gnu.org>
|
||||
|
||||
Fix link errors related to C99-style extern inline.
|
||||
Reported by Sam Thursfield <sam.thursfield@codethink.co.uk>.
|
||||
* Makefile.in (SOURCES): Add xsize.c.
|
||||
(OBJECTS): Add xsize.$lo.
|
||||
(xsize.lo): New rule.
|
||||
(printf.$lo): Add xsize.c to dependencies.
|
||||
* xsize.c: New file, imported from gnulib.
|
||||
|
||||
2012-12-25 Daiki Ueno <ueno@gnu.org>
|
||||
|
||||
* gettext-0.18.2 released.
|
||||
|
||||
@ -158,6 +158,7 @@ SOURCES = \
|
||||
printf.c \
|
||||
setlocale.c \
|
||||
version.c \
|
||||
xsize.c \
|
||||
osdep.c \
|
||||
os2compat.c \
|
||||
intl-exports.c \
|
||||
@ -190,6 +191,7 @@ OBJECTS = \
|
||||
printf.$lo \
|
||||
setlocale.$lo \
|
||||
version.$lo \
|
||||
xsize.$lo \
|
||||
osdep.$lo \
|
||||
intl-compat.$lo
|
||||
OBJECTS_RES_yes = libintl.res.$lo
|
||||
@ -298,6 +300,8 @@ setlocale.lo: $(srcdir)/setlocale.c
|
||||
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/setlocale.c
|
||||
version.lo: $(srcdir)/version.c
|
||||
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/version.c
|
||||
xsize.lo: $(srcdir)/xsize.c
|
||||
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/xsize.c
|
||||
osdep.lo: $(srcdir)/osdep.c
|
||||
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/osdep.c
|
||||
intl-compat.lo: $(srcdir)/intl-compat.c
|
||||
@ -585,7 +589,7 @@ dcigettext.$lo: $(srcdir)/eval-plural.h
|
||||
localcharset.$lo: $(srcdir)/localcharset.h
|
||||
bindtextdom.$lo dcigettext.$lo finddomain.$lo loadmsgcat.$lo localealias.$lo lock.$lo log.$lo: $(srcdir)/lock.h
|
||||
localealias.$lo localcharset.$lo relocatable.$lo: $(srcdir)/relocatable.h
|
||||
printf.$lo: $(srcdir)/printf-args.h $(srcdir)/printf-args.c $(srcdir)/printf-parse.h $(srcdir)/wprintf-parse.h $(srcdir)/xsize.h $(srcdir)/printf-parse.c $(srcdir)/vasnprintf.h $(srcdir)/vasnwprintf.h $(srcdir)/vasnprintf.c
|
||||
printf.$lo: $(srcdir)/printf-args.h $(srcdir)/printf-args.c $(srcdir)/printf-parse.h $(srcdir)/wprintf-parse.h $(srcdir)/xsize.h $(srcdir)/xsize.c $(srcdir)/printf-parse.c $(srcdir)/vasnprintf.h $(srcdir)/vasnwprintf.h $(srcdir)/vasnprintf.c
|
||||
|
||||
# A bison-2.1 generated plural.c includes <libintl.h> if ENABLE_NLS.
|
||||
PLURAL_DEPS_yes = libintl.h
|
||||
|
||||
3
gettext-runtime/intl/xsize.c
Normal file
3
gettext-runtime/intl/xsize.c
Normal file
@ -0,0 +1,3 @@
|
||||
#include <config.h>
|
||||
#define XSIZE_INLINE _GL_EXTERN_INLINE
|
||||
#include "xsize.h"
|
||||
@ -1,3 +1,12 @@
|
||||
2013-01-17 Daiki Ueno <ueno@gnu.org>
|
||||
|
||||
Fix link errors related to C99-style extern inline.
|
||||
Reported by Sam Thursfield <sam.thursfield@codethink.co.uk>.
|
||||
* Makefile.am (libasprintf_la_SOURCES): Add xsize.h and xsize.c.
|
||||
(lib_asprintf_EXTRASOURCES): Remove xsize.h.
|
||||
* xsize.h: Remove, replacing with the one from gnulib when
|
||||
bootstrapping.
|
||||
|
||||
2012-12-25 Daiki Ueno <ueno@gnu.org>
|
||||
|
||||
* gettext-0.18.2 released.
|
||||
|
||||
@ -49,13 +49,13 @@ lib_LTLIBRARIES = libasprintf.la
|
||||
noinst_LTLIBRARIES =
|
||||
|
||||
libasprintf_la_SOURCES = \
|
||||
xsize.h xsize.c \
|
||||
lib-asprintf.h lib-asprintf.c \
|
||||
autosprintf.h autosprintf.cc
|
||||
|
||||
# Sources used only on platforms lacking vasprintf().
|
||||
lib_asprintf_EXTRASOURCES = \
|
||||
verify.h \
|
||||
xsize.h \
|
||||
printf-args.h printf-args.c \
|
||||
printf-parse.h printf-parse.c \
|
||||
vasnprintf.h vasnprintf.c asnprintf.c \
|
||||
|
||||
@ -1,114 +0,0 @@
|
||||
/* xsize.h -- Checked size_t computations.
|
||||
|
||||
Copyright (C) 2003, 2008-2012 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
|
||||
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _XSIZE_H
|
||||
#define _XSIZE_H
|
||||
|
||||
/* Get size_t. */
|
||||
#include <stddef.h>
|
||||
|
||||
/* Get SIZE_MAX. */
|
||||
#include <limits.h>
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef XSIZE_INLINE
|
||||
# define XSIZE_INLINE _GL_INLINE
|
||||
#endif
|
||||
|
||||
/* The size of memory objects is often computed through expressions of
|
||||
type size_t. Example:
|
||||
void* p = malloc (header_size + n * element_size).
|
||||
These computations can lead to overflow. When this happens, malloc()
|
||||
returns a piece of memory that is way too small, and the program then
|
||||
crashes while attempting to fill the memory.
|
||||
To avoid this, the functions and macros in this file check for overflow.
|
||||
The convention is that SIZE_MAX represents overflow.
|
||||
malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
|
||||
implementation that uses mmap --, it's recommended to use size_overflow_p()
|
||||
or size_in_bounds_p() before invoking malloc().
|
||||
The example thus becomes:
|
||||
size_t size = xsum (header_size, xtimes (n, element_size));
|
||||
void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
|
||||
*/
|
||||
|
||||
/* Convert an arbitrary value >= 0 to type size_t. */
|
||||
#define xcast_size_t(N) \
|
||||
((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
|
||||
|
||||
/* Sum of two sizes, with overflow check. */
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
xsum (size_t size1, size_t size2)
|
||||
{
|
||||
size_t sum = size1 + size2;
|
||||
return (sum >= size1 ? sum : SIZE_MAX);
|
||||
}
|
||||
|
||||
/* Sum of three sizes, with overflow check. */
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
xsum3 (size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
return xsum (xsum (size1, size2), size3);
|
||||
}
|
||||
|
||||
/* Sum of four sizes, with overflow check. */
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
|
||||
{
|
||||
return xsum (xsum (xsum (size1, size2), size3), size4);
|
||||
}
|
||||
|
||||
/* Maximum of two sizes, with overflow check. */
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
xmax (size_t size1, size_t size2)
|
||||
{
|
||||
/* No explicit check is needed here, because for any n:
|
||||
max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */
|
||||
return (size1 >= size2 ? size1 : size2);
|
||||
}
|
||||
|
||||
/* Multiplication of a count with an element size, with overflow check.
|
||||
The count must be >= 0 and the element size must be > 0.
|
||||
This is a macro, not a function, so that it works correctly even
|
||||
when N is of a wider type and N > SIZE_MAX. */
|
||||
#define xtimes(N, ELSIZE) \
|
||||
((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
|
||||
|
||||
/* Check for overflow. */
|
||||
#define size_overflow_p(SIZE) \
|
||||
((SIZE) == SIZE_MAX)
|
||||
/* Check against overflow. */
|
||||
#define size_in_bounds_p(SIZE) \
|
||||
((SIZE) != SIZE_MAX)
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
|
||||
#endif /* _XSIZE_H */
|
||||
Loading…
x
Reference in New Issue
Block a user