All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: Brian Gernhardt <brian@gernhardtsoftware.com>
Cc: Git List <git@vger.kernel.org>, Fredrik Kuivinen <frekui@gmail.com>
Subject: Re: obstack fails to compile on OS X 10.7
Date: Sat, 27 Aug 2011 03:14:43 -0700	[thread overview]
Message-ID: <20110827101418.GA8074@gmail.com> (raw)
In-Reply-To: <4A1A024F-C5D5-4E5F-8474-DA3D87412C8A@gernhardtsoftware.com>

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@gmail.com>
Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
 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;
 }
 \f
-/* 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);
 
 \f
 /* 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

  reply	other threads:[~2011-08-27 10:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-27  6:21 obstack fails to compile on OS X 10.7 Brian Gernhardt
2011-08-27 10:14 ` David Aguilar [this message]
2011-08-28  3:57   ` Brian Gernhardt
2011-08-28 20:08   ` Fredrik Kuivinen
2011-08-29  3:18     ` David Aguilar
2011-08-29  6:07       ` Junio C Hamano
2011-09-01 17:30     ` Ramsay Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110827101418.GA8074@gmail.com \
    --to=davvid@gmail.com \
    --cc=brian@gernhardtsoftware.com \
    --cc=frekui@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.