This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gccgo] Fix declaration/definition mismatch


This patch should fix a declaration/definition mismatch for __go_alloc
and mlookup that reportedly occurs on some systems.  It also ensures
that %zu is used with a value of type size_t, by adding a cast.  I
also took out the type hiding in runtime.h; it isn't useful in the
libgo context, where code is permitted to call libc functions.
Committed to gccgo branch.

This should fix issue 356 in the Go issue tracker.

Ian

Index: libgo/runtime/go-refcount-flush.c
===================================================================
--- libgo/runtime/go-refcount-flush.c	(revision 154387)
+++ libgo/runtime/go-refcount-flush.c	(working copy)
@@ -9,6 +9,8 @@
 
 #include "go-alloc.h"
 #include "go-refcount.h"
+#include "runtime.h"
+#include "malloc.h"
 
 /* The head of the list of reference count queues.  This variable is
    maintained by the code generated by the compiler.  It exists in
Index: libgo/runtime/go-alloc.h
===================================================================
--- libgo/runtime/go-alloc.h	(revision 154387)
+++ libgo/runtime/go-alloc.h	(working copy)
@@ -7,6 +7,5 @@
 #include <stddef.h>
 #include <stdint.h>
 
-extern void *__go_alloc (size_t);
+extern void *__go_alloc (unsigned int __attribute__ ((mode (pointer))));
 extern void __go_free (void *);
-extern int32_t mlookup (void *, unsigned char **, uintptr_t *, uint32_t **);
Index: libgo/runtime/malloc.c
===================================================================
--- libgo/runtime/malloc.c	(revision 155449)
+++ libgo/runtime/malloc.c	(working copy)
@@ -315,7 +315,7 @@ stackalloc(uint32 n)
 		if(stacks.size == 0)
 			FixAlloc_Init(&stacks, n, SysAlloc, nil, nil);
 		if(stacks.size != n) {
-			printf("stackalloc: in malloc, size=%zu want %d", stacks.size, n);
+			printf("stackalloc: in malloc, size=%zu want %d", (size_t)stacks.size, n);
 			throw("stackalloc");
 		}
 		v = FixAlloc_Alloc(&stacks);
Index: libgo/runtime/runtime.h
===================================================================
--- libgo/runtime/runtime.h	(revision 155449)
+++ libgo/runtime/runtime.h	(working copy)
@@ -33,17 +33,6 @@ typedef float        float32 __attribute
 typedef double       float64 __attribute__ ((mode (DF)));
 typedef unsigned int uintptr __attribute__ ((mode (pointer)));
 
-/* Copying the 6g runtime.h, remove the C types.  We leave char,
-   though, since we need it to call some library routines.  */
-
-#define	unsigned		XXunsigned / / /
-#define	signed			XXsigned / / /
-#define	short			XXshort / / /
-#define	int			XXint / / /
-#define	long			XXlong / / /
-#define	float			XXfloat / / /
-#define	double			XXdouble / / /
-
 /* Defined types.  */
 
 typedef	uint8			bool;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]