obstack: Fix portability issues
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1, SunOS 5.10, and possibly others do not have exit.h and exitfail.h. Remove the use of these in obstack.c. The __block variable was renamed to block to avoid a gcc error: compat/obstack.h:190: error: __block attribute can be specified on variables only Initial-patch-by: David Aguilar <davvid@gmail.com> Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com> Signed-off-by: Fredrik Kuivinen <frekui@gmail.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Fredrik Kuivinen committed
Aug 28, 2011 at 22:08 UTC
d190a0875ff0f33d60a4d7265f2098b35d162f68
3 files changed
+6
-36
compat/obstack.c
+4
-31
@@ -18,17 +18,9 @@
18
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
Boston, MA 02110-1301, USA. */
20
21
-
22
-#ifdef HAVE_CONFIG_H
23
-# include <config.h>
24
-#endif
25
-
26
-#ifdef _LIBC
27
-# include <obstack.h>
28
-# include <shlib-compat.h>
29
-#else
30
-# include "obstack.h"
31
-#endif
21
+#include "git-compat-util.h"
22
+#include <gettext.h>
23
+#include "obstack.h"
24
25
/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
26
incremented whenever callers compiled using an old obstack.h can no
@@ -103,15 +95,6 @@ enum
95
static void print_and_abort (void);
96
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
97
106
-/* Exit value used when `print_and_abort' is used. */
107
-# include <stdlib.h>
108
-# ifdef _LIBC
109
-int obstack_exit_failure = EXIT_FAILURE;
110
-# else
111
-# include "exitfail.h"
112
-# define obstack_exit_failure exit_failure
113
-# endif
114
-
98
# ifdef _LIBC
99
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
100
/* A looong time ago (before 1994, anyway; we're not sure) this global variable
@@ -400,16 +383,6 @@ _obstack_memory_used (struct obstack *h)
383
return nbytes;
384
}
385
403
-/* Define the error handler. */
404
-# ifdef _LIBC
405
-# include <libintl.h>
406
-# else
407
-# include "gettext.h"
408
-# endif
409
-# ifndef _
410
-# define _(msgid) gettext (msgid)
411
-# endif
412
-
386
# ifdef _LIBC
387
# include <libio/iolibio.h>
388
# endif
@@ -435,7 +408,7 @@ print_and_abort (void)
408
# else
409
fprintf (stderr, "%s\n", _("memory exhausted"));
410
# endif
438
- exit (obstack_exit_failure);
411
+ exit (1);
412
}
413
414
#endif /* !ELIDE_CODE */
compat/obstack.h
+1
-4
@@ -187,7 +187,7 @@ extern int _obstack_begin_1 (struct obstack *, int, int,
187
void (*) (void *, void *), void *);
188
extern int _obstack_memory_used (struct obstack *);
189
190
-void obstack_free (struct obstack *__obstack, void *__block);
190
+void obstack_free (struct obstack *, void *);
191
192
193
/* Error handler called when `obstack_chunk_alloc' failed to allocate
@@ -195,9 +195,6 @@ void obstack_free (struct obstack *__obstack, void *__block);
195
should either abort gracefully or use longjump - but shouldn't
196
return. The default action is to print a message and abort. */
197
extern void (*obstack_alloc_failed_handler) (void);
198
-
199
-/* Exit value used when `print_and_abort' is used. */
200
-extern int obstack_exit_failure;
198
199
/* Pointer to beginning of object being allocated or to be allocated next.
200
Note that this might not be the final address of the object
kwset.c
+1
-1
@@ -37,7 +37,7 @@
37
#include "cache.h"
38
39
#include "kwset.h"
40
-#include "obstack.h"
40
+#include "compat/obstack.h"
41
42
#define NCHAR (UCHAR_MAX + 1)
43
#define obstack_chunk_alloc xmalloc