On Sat, Aug 27, 2011 at 02:21:40AM -0400, Brian Gernhardt wrote: > Some of the errors look like things I could track down, but some just confuse me. If anyone else could take a look into this, it would be much appreciated. > > ~~ Brian G. > > gcc -o compat/obstack.o -c -MF compat/.depend/obstack.o.d -MMD -MP -Wall -Wdeclaration-after-statement -Werror -Wno-deprecated-declarations -I. -DUSE_ST_TIMESPEC -DSHA1_HEADER='"block-sha1/sha1.h"' -DNO_MEMMEM compat/obstack.c > In file included from compat/obstack.c:30: > compat/obstack.h:190: error: __block attribute can be specified on variables only > compat/obstack.c:70: error: expected specifier-qualifier-list before ‘uintmax_t’ > compat/obstack.c:111:24: error: exitfail.h: No such file or directory > cc1: warnings being treated as errors > compat/obstack.c: In function ‘print_and_abort’: > compat/obstack.c:436: warning: implicit declaration of function ‘gettext’ > compat/obstack.c:436: warning: incompatible implicit declaration of built-in function ‘gettext’ > compat/obstack.c:438: error: ‘exit_failure’ undeclared (first use in this function) > compat/obstack.c:438: error: (Each undeclared identifier is reported only once > compat/obstack.c:438: error: for each function it appears in.) > compat/obstack.c:439: warning: ‘noreturn’ function does return > make: *** [compat/obstack.o] Error 1 > > $ gcc --version > i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) I ran into the same thing. This fixes it for me, but we might want to rearrange the #includes a bit. I think this needs more work.. including compat/obstack.h from kwset.c seems wrong. Should we just include obstack.h in git-compat-util instead? I suspect that more exotic platforms may have problems with obstack.h as well. This probably needs some testing on SunOS, AIX, IRIX, etc. -- 8< -- Subject: [RFC PATCH] obstack: Fix portability issues i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 and possibly others do not have exit.h, exitfail.h, or obstack.h. Add compat versions of these headers as well as exitfail.c from glibc. The ELIDE_CODE check in obstack.c is not sufficient so add a separate NEEDS_OBSTACK variable to allow platforms to opt into using the compatibility versions of these files. The __block variable was renamed to __blk to avoid a gcc error: compat/obstack.h:190: error: __block attribute can be specified on variables only Signed-off-by: David Aguilar <davvid@xxxxxxxxx> Reported-by: Brian Gernhardt <brian@xxxxxxxxxxxxxxxxxxxxx> --- Makefile | 11 +++++++++++ compat/exit.h | 32 ++++++++++++++++++++++++++++++++ compat/exitfail.c | 24 ++++++++++++++++++++++++ compat/exitfail.h | 20 ++++++++++++++++++++ compat/obstack.c | 19 +++---------------- compat/obstack.h | 2 +- kwset.c | 3 ++- 7 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 compat/exit.h create mode 100644 compat/exitfail.c create mode 100644 compat/exitfail.h diff --git a/Makefile b/Makefile index 30f3812..87ad4a2 100644 --- a/Makefile +++ b/Makefile @@ -517,6 +517,8 @@ LIB_H += compat/bswap.h LIB_H += compat/cygwin.h LIB_H += compat/mingw.h LIB_H += compat/obstack.h +LIB_H += compat/exitfail.h +LIB_H += compat/exit.h LIB_H += compat/win32/pthread.h LIB_H += compat/win32/syslog.h LIB_H += compat/win32/sys/poll.h @@ -599,6 +601,7 @@ LIB_OBJS += cache-tree.o LIB_OBJS += color.o LIB_OBJS += combine-diff.o LIB_OBJS += commit.o +LIB_OBJS += compat/exitfail.o LIB_OBJS += compat/obstack.o LIB_OBJS += config.o LIB_OBJS += connect.o @@ -872,6 +875,8 @@ ifeq ($(uname_S),Darwin) NEEDS_CRYPTO_WITH_SSL = YesPlease NEEDS_SSL_WITH_CRYPTO = YesPlease NEEDS_LIBICONV = YesPlease + NEEDS_OBSTACK = YesPlease + NEEDS_EXITFAIL = YesPlease ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2) OLD_ICONV = UnfortunatelyYes endif @@ -1416,6 +1421,12 @@ endif ifdef NEEDS_RESOLV EXTLIBS += -lresolv endif +ifdef NEEDS_OBSTACK + BASIC_CFLAGS += -DNEEDS_OBSTACK +endif +ifdef NEEDS_EXITFAIL + BASIC_CFLAGS += -DNEEDS_EXITFAIL +endif ifdef NO_D_TYPE_IN_DIRENT BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT endif diff --git a/compat/exit.h b/compat/exit.h new file mode 100644 index 0000000..9dbfb7c --- /dev/null +++ b/compat/exit.h @@ -0,0 +1,32 @@ +/* exit() function. + Copyright (C) 1995, 2001 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 2, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _EXIT_H +#define _EXIT_H + +/* Get exit() declaration. */ +#include <stdlib.h> + +/* Some systems do not define EXIT_*, even with STDC_HEADERS. */ +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + +#endif /* _EXIT_H */ diff --git a/compat/exitfail.c b/compat/exitfail.c new file mode 100644 index 0000000..a2dd5dd --- /dev/null +++ b/compat/exitfail.c @@ -0,0 +1,24 @@ +/* Failure exit status + + Copyright (C) 2002, 2003 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 2, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifdef NEEDS_EXITFAIL +#include "exitfail.h" +#include "exit.h" + +int volatile exit_failure = EXIT_FAILURE; +#endif diff --git a/compat/exitfail.h b/compat/exitfail.h new file mode 100644 index 0000000..e46cf9c --- /dev/null +++ b/compat/exitfail.h @@ -0,0 +1,20 @@ +/* Failure exit status + + Copyright (C) 2002 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 2, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +extern int volatile exit_failure; diff --git a/compat/obstack.c b/compat/obstack.c index 75440d9..825658c 100644 --- a/compat/obstack.c +++ b/compat/obstack.c @@ -18,15 +18,12 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - #ifdef _LIBC # include <obstack.h> # include <shlib-compat.h> #else +# include <gettext.h> +# include "git-compat-util.h" # include "obstack.h" #endif @@ -54,7 +51,7 @@ #include <stddef.h> -#ifndef ELIDE_CODE +#if !defined ELIDE_CODE || defined NEEDS_OBSTACK # if HAVE_INTTYPES_H @@ -400,16 +397,6 @@ _obstack_memory_used (struct obstack *h) return nbytes; } -/* Define the error handler. */ -# ifdef _LIBC -# include <libintl.h> -# else -# include "gettext.h" -# endif -# ifndef _ -# define _(msgid) gettext (msgid) -# endif - # ifdef _LIBC # include <libio/iolibio.h> # endif diff --git a/compat/obstack.h b/compat/obstack.h index 449070e..5636b91 100644 --- a/compat/obstack.h +++ b/compat/obstack.h @@ -187,7 +187,7 @@ extern int _obstack_begin_1 (struct obstack *, int, int, void (*) (void *, void *), void *); extern int _obstack_memory_used (struct obstack *); -void obstack_free (struct obstack *__obstack, void *__block); +void obstack_free (struct obstack *__obstack, void *__blk); /* Error handler called when `obstack_chunk_alloc' failed to allocate diff --git a/kwset.c b/kwset.c index fd4515a..d01c562 100644 --- a/kwset.c +++ b/kwset.c @@ -37,7 +37,8 @@ #include "cache.h" #include "kwset.h" -#include "obstack.h" +#include "git-compat-util.h" +#include "compat/obstack.h" #define NCHAR (UCHAR_MAX + 1) #define obstack_chunk_alloc xmalloc -- 1.7.6.476.g57292 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html