mirror of
https://github.com/golang/go
synced 2024-11-24 11:00:08 -07:00
cmd/cgo: use size_t instead of __SIZE_TYPE__
__SIZE_TYPE__ is a GCC type which has been superseded by size_t -define in stddef.h- since ISO C99. cmd/cgo already uses size_t in many places, but still generates several files using __SIZE_TYPES__, most notably the _cgo_export.h. This change replaces all __SIZE_TYPES__ occurrences with size_t. Updates #36233 Change-Id: Id8a99b5d7763caab9333eab9b585e78249a37415 Reviewed-on: https://go-review.googlesource.com/c/go/+/379474 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
parent
3943d97dc7
commit
90b29e1865
@ -57,18 +57,19 @@ func (p *Package) writeDefs() {
|
|||||||
fflg.Close()
|
fflg.Close()
|
||||||
|
|
||||||
// Write C main file for using gcc to resolve imports.
|
// Write C main file for using gcc to resolve imports.
|
||||||
|
fmt.Fprintf(fm, "#include <stddef.h>\n") // For size_t below.
|
||||||
fmt.Fprintf(fm, "int main() { return 0; }\n")
|
fmt.Fprintf(fm, "int main() { return 0; }\n")
|
||||||
if *importRuntimeCgo {
|
if *importRuntimeCgo {
|
||||||
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*) __attribute__((unused)), void *a __attribute__((unused)), int c __attribute__((unused)), __SIZE_TYPE__ ctxt __attribute__((unused))) { }\n")
|
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*) __attribute__((unused)), void *a __attribute__((unused)), int c __attribute__((unused)), size_t ctxt __attribute__((unused))) { }\n")
|
||||||
fmt.Fprintf(fm, "__SIZE_TYPE__ _cgo_wait_runtime_init_done(void) { return 0; }\n")
|
fmt.Fprintf(fm, "size_t _cgo_wait_runtime_init_done(void) { return 0; }\n")
|
||||||
fmt.Fprintf(fm, "void _cgo_release_context(__SIZE_TYPE__ ctxt __attribute__((unused))) { }\n")
|
fmt.Fprintf(fm, "void _cgo_release_context(size_t ctxt __attribute__((unused))) { }\n")
|
||||||
fmt.Fprintf(fm, "char* _cgo_topofstack(void) { return (char*)0; }\n")
|
fmt.Fprintf(fm, "char* _cgo_topofstack(void) { return (char*)0; }\n")
|
||||||
} else {
|
} else {
|
||||||
// If we're not importing runtime/cgo, we *are* runtime/cgo,
|
// If we're not importing runtime/cgo, we *are* runtime/cgo,
|
||||||
// which provides these functions. We just need a prototype.
|
// which provides these functions. We just need a prototype.
|
||||||
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*), void *a, int c, __SIZE_TYPE__ ctxt);\n")
|
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*), void *a, int c, size_t ctxt);\n")
|
||||||
fmt.Fprintf(fm, "__SIZE_TYPE__ _cgo_wait_runtime_init_done(void);\n")
|
fmt.Fprintf(fm, "size_t _cgo_wait_runtime_init_done(void);\n")
|
||||||
fmt.Fprintf(fm, "void _cgo_release_context(__SIZE_TYPE__);\n")
|
fmt.Fprintf(fm, "void _cgo_release_context(size_t);\n")
|
||||||
}
|
}
|
||||||
fmt.Fprintf(fm, "void _cgo_allocate(void *a __attribute__((unused)), int c __attribute__((unused))) { }\n")
|
fmt.Fprintf(fm, "void _cgo_allocate(void *a __attribute__((unused)), int c __attribute__((unused))) { }\n")
|
||||||
fmt.Fprintf(fm, "void _cgo_panic(void *a __attribute__((unused)), int c __attribute__((unused))) { }\n")
|
fmt.Fprintf(fm, "void _cgo_panic(void *a __attribute__((unused)), int c __attribute__((unused))) { }\n")
|
||||||
@ -886,9 +887,9 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
|
|||||||
fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n")
|
fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n")
|
||||||
fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n")
|
fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n")
|
||||||
|
|
||||||
fmt.Fprintf(fgcc, "extern void crosscall2(void (*fn)(void *), void *, int, __SIZE_TYPE__);\n")
|
fmt.Fprintf(fgcc, "extern void crosscall2(void (*fn)(void *), void *, int, size_t);\n")
|
||||||
fmt.Fprintf(fgcc, "extern __SIZE_TYPE__ _cgo_wait_runtime_init_done(void);\n")
|
fmt.Fprintf(fgcc, "extern size_t _cgo_wait_runtime_init_done(void);\n")
|
||||||
fmt.Fprintf(fgcc, "extern void _cgo_release_context(__SIZE_TYPE__);\n\n")
|
fmt.Fprintf(fgcc, "extern void _cgo_release_context(size_t);\n\n")
|
||||||
fmt.Fprintf(fgcc, "extern char* _cgo_topofstack(void);")
|
fmt.Fprintf(fgcc, "extern char* _cgo_topofstack(void);")
|
||||||
fmt.Fprintf(fgcc, "%s\n", tsanProlog)
|
fmt.Fprintf(fgcc, "%s\n", tsanProlog)
|
||||||
fmt.Fprintf(fgcc, "%s\n", msanProlog)
|
fmt.Fprintf(fgcc, "%s\n", msanProlog)
|
||||||
@ -992,7 +993,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
|
|||||||
fmt.Fprintf(fgcc, "\nCGO_NO_SANITIZE_THREAD")
|
fmt.Fprintf(fgcc, "\nCGO_NO_SANITIZE_THREAD")
|
||||||
fmt.Fprintf(fgcc, "\n%s\n", s)
|
fmt.Fprintf(fgcc, "\n%s\n", s)
|
||||||
fmt.Fprintf(fgcc, "{\n")
|
fmt.Fprintf(fgcc, "{\n")
|
||||||
fmt.Fprintf(fgcc, "\t__SIZE_TYPE__ _cgo_ctxt = _cgo_wait_runtime_init_done();\n")
|
fmt.Fprintf(fgcc, "\tsize_t _cgo_ctxt = _cgo_wait_runtime_init_done();\n")
|
||||||
// The results part of the argument structure must be
|
// The results part of the argument structure must be
|
||||||
// initialized to 0 so the write barriers generated by
|
// initialized to 0 so the write barriers generated by
|
||||||
// the assignments to these fields in Go are safe.
|
// the assignments to these fields in Go are safe.
|
||||||
@ -1561,7 +1562,7 @@ var msanProlog = noMsanProlog
|
|||||||
|
|
||||||
const builtinProlog = `
|
const builtinProlog = `
|
||||||
#line 1 "cgo-builtin-prolog"
|
#line 1 "cgo-builtin-prolog"
|
||||||
#include <stddef.h> /* for ptrdiff_t and size_t below */
|
#include <stddef.h>
|
||||||
|
|
||||||
/* Define intgo when compiling with GCC. */
|
/* Define intgo when compiling with GCC. */
|
||||||
typedef ptrdiff_t intgo;
|
typedef ptrdiff_t intgo;
|
||||||
@ -1845,7 +1846,7 @@ void localCgoCheckResult(Eface val) {
|
|||||||
const builtinExportProlog = `
|
const builtinExportProlog = `
|
||||||
#line 1 "cgo-builtin-export-prolog"
|
#line 1 "cgo-builtin-export-prolog"
|
||||||
|
|
||||||
#include <stddef.h> /* for ptrdiff_t below */
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
||||||
#define GO_CGO_EXPORT_PROLOGUE_H
|
#define GO_CGO_EXPORT_PROLOGUE_H
|
||||||
@ -1891,7 +1892,7 @@ typedef long long GoInt64;
|
|||||||
typedef unsigned long long GoUint64;
|
typedef unsigned long long GoUint64;
|
||||||
typedef GoIntGOINTBITS GoInt;
|
typedef GoIntGOINTBITS GoInt;
|
||||||
typedef GoUintGOINTBITS GoUint;
|
typedef GoUintGOINTBITS GoUint;
|
||||||
typedef __SIZE_TYPE__ GoUintptr;
|
typedef size_t GoUintptr;
|
||||||
typedef float GoFloat32;
|
typedef float GoFloat32;
|
||||||
typedef double GoFloat64;
|
typedef double GoFloat64;
|
||||||
typedef float _Complex GoComplex64;
|
typedef float _Complex GoComplex64;
|
||||||
@ -1941,5 +1942,5 @@ static void GoInit(void) {
|
|||||||
runtime_iscgo = 1;
|
runtime_iscgo = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern __SIZE_TYPE__ _cgo_wait_runtime_init_done(void) __attribute__ ((weak));
|
extern size_t _cgo_wait_runtime_init_done(void) __attribute__ ((weak));
|
||||||
`
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user