Skip to content

Commit 5239829

Browse files
committed
Merge branch 'dscho/gcc-8-gfw'
This backports several patch series from Git for Windows' `master` to make things compile with GCC v8.x, as that will soon be the default for Git for Windows (and is already the current setup on this developer's machine).
2 parents d68d6c8 + 32c18f9 commit 5239829

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

compat/obstack.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0);
112112

113113
# define CALL_CHUNKFUN(h, size) \
114114
(((h) -> use_extra_arg) \
115-
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
116-
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
115+
? (*(h)->chunkfun.extra) ((h)->extra_arg, (size)) \
116+
: (*(h)->chunkfun.plain) ((size)))
117117

118118
# define CALL_FREEFUN(h, old_chunk) \
119119
do { \
120120
if ((h) -> use_extra_arg) \
121-
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
121+
(*(h)->freefun.extra) ((h)->extra_arg, (old_chunk)); \
122122
else \
123-
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
123+
(*(h)->freefun.plain) ((old_chunk)); \
124124
} while (0)
125125

126126

@@ -159,8 +159,8 @@ _obstack_begin (struct obstack *h,
159159
size = 4096 - extra;
160160
}
161161

162-
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
163-
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
162+
h->chunkfun.plain = chunkfun;
163+
h->freefun.plain = freefun;
164164
h->chunk_size = size;
165165
h->alignment_mask = alignment - 1;
166166
h->use_extra_arg = 0;
@@ -206,8 +206,9 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
206206
size = 4096 - extra;
207207
}
208208

209-
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
210-
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
209+
h->chunkfun.extra = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
210+
h->freefun.extra = (void (*) (void *, struct _obstack_chunk *)) freefun;
211+
211212
h->chunk_size = size;
212213
h->alignment_mask = alignment - 1;
213214
h->extra_arg = arg;

compat/obstack.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,15 @@ struct obstack /* control current object in current chunk */
160160
void *tempptr;
161161
} temp; /* Temporary for some macros. */
162162
int alignment_mask; /* Mask of alignment for each object. */
163-
/* These prototypes vary based on `use_extra_arg', and we use
164-
casts to the prototypeless function type in all assignments,
165-
but having prototypes here quiets -Wstrict-prototypes. */
166-
struct _obstack_chunk *(*chunkfun) (void *, long);
167-
void (*freefun) (void *, struct _obstack_chunk *);
163+
/* These prototypes vary based on `use_extra_arg'. */
164+
union {
165+
void *(*plain) (long);
166+
struct _obstack_chunk *(*extra) (void *, long);
167+
} chunkfun;
168+
union {
169+
void (*plain) (void *);
170+
void (*extra) (void *, struct _obstack_chunk *);
171+
} freefun;
168172
void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
169173
unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
170174
unsigned maybe_empty_object:1;/* There is a possibility that the current
@@ -235,10 +239,10 @@ extern void (*obstack_alloc_failed_handler) (void);
235239
(void (*) (void *, void *)) (freefun), (arg))
236240

237241
#define obstack_chunkfun(h, newchunkfun) \
238-
((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
242+
((h)->chunkfun.extra = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
239243

240244
#define obstack_freefun(h, newfreefun) \
241-
((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
245+
((h)->freefun.extra = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
242246

243247
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar))
244248

compat/poll/poll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ win32_compute_revents (HANDLE h, int *p_sought)
149149
case FILE_TYPE_PIPE:
150150
if (!once_only)
151151
{
152-
NtQueryInformationFile = (PNtQueryInformationFile)
152+
NtQueryInformationFile = (PNtQueryInformationFile)(void (*)(void))
153153
GetProcAddress (GetModuleHandleA ("ntdll.dll"),
154154
"NtQueryInformationFile");
155155
once_only = TRUE;

compat/win32/exit-process.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ static int exit_process(HANDLE process, int exit_code)
130130
HINSTANCE kernel32 = GetModuleHandleA("kernel32");
131131
if (!kernel32)
132132
die("BUG: cannot find kernel32");
133-
exit_process_address = (LPTHREAD_START_ROUTINE)
133+
exit_process_address =
134+
(LPTHREAD_START_ROUTINE)(void (*)(void))
134135
GetProcAddress(kernel32, "ExitProcess");
135136
initialized = 1;
136137
}

kwset.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@
3838
#include "compat/obstack.h"
3939

4040
#define NCHAR (UCHAR_MAX + 1)
41-
#define obstack_chunk_alloc xmalloc
41+
/* adapter for `xmalloc()`, which takes `size_t`, not `long` */
42+
static void *obstack_chunk_alloc(long size)
43+
{
44+
if (size < 0)
45+
BUG("Cannot allocate a negative amount: %ld", size);
46+
return xmalloc(size);
47+
}
4248
#define obstack_chunk_free free
4349

4450
#define U(c) ((unsigned char) (c))

0 commit comments

Comments
 (0)