Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(977)

Delta Between Two Patch Sets: src/cmd/cgo/out.go

Issue 13413047: code review 13413047: cmd/cgo: replace C.malloc with our own wrapper (Closed)
Left Patch Set: diff -r 22365bd87858 https://code.google.com/p/go/ Created 10 years, 6 months ago
Right Patch Set: diff -r 1b195d6fe342 https://code.google.com/p/go/ Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/cgo/main.go ('k') | src/pkg/runtime/cgocall.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "debug/elf" 9 "debug/elf"
10 "debug/macho" 10 "debug/macho"
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 } 1214 }
1215 1215
1216 struct __go_string GoStringN(char *p, int32_t n) { 1216 struct __go_string GoStringN(char *p, int32_t n) {
1217 return __go_byte_array_to_string(p, n); 1217 return __go_byte_array_to_string(p, n);
1218 } 1218 }
1219 1219
1220 Slice GoBytes(char *p, int32_t n) { 1220 Slice GoBytes(char *p, int32_t n) {
1221 struct __go_string s = { (const unsigned char *)p, n }; 1221 struct __go_string s = { (const unsigned char *)p, n };
1222 return __go_string_to_byte_array(s); 1222 return __go_string_to_byte_array(s);
1223 } 1223 }
1224
1225 extern void runtime_throw(const char *):
1226 void *Cmalloc(size_t n) {
1227 void *p = malloc(n);
1228 if(p == NULL)
1229 runtime_throw("runtime: C malloc failed");
1230 return p;
1231 }
1224 ` 1232 `
1225 1233
1226 func (p *Package) gccExportHeaderProlog() string { 1234 func (p *Package) gccExportHeaderProlog() string {
1227 return strings.Replace(gccExportHeaderProlog, "GOINTBITS", fmt.Sprint(8* p.IntSize), -1) 1235 return strings.Replace(gccExportHeaderProlog, "GOINTBITS", fmt.Sprint(8* p.IntSize), -1)
1228 } 1236 }
1229 1237
1230 const gccExportHeaderProlog = ` 1238 const gccExportHeaderProlog = `
1231 typedef signed char GoInt8; 1239 typedef signed char GoInt8;
1232 typedef unsigned char GoUint8; 1240 typedef unsigned char GoUint8;
1233 typedef short GoInt16; 1241 typedef short GoInt16;
1234 typedef unsigned short GoUint16; 1242 typedef unsigned short GoUint16;
1235 typedef int GoInt32; 1243 typedef int GoInt32;
1236 typedef unsigned int GoUint32; 1244 typedef unsigned int GoUint32;
1237 typedef long long GoInt64; 1245 typedef long long GoInt64;
1238 typedef unsigned long long GoUint64; 1246 typedef unsigned long long GoUint64;
1239 typedef GoIntGOINTBITS GoInt; 1247 typedef GoIntGOINTBITS GoInt;
1240 typedef GoUintGOINTBITS GoUint; 1248 typedef GoUintGOINTBITS GoUint;
1241 typedef __SIZE_TYPE__ GoUintptr; 1249 typedef __SIZE_TYPE__ GoUintptr;
1242 typedef float GoFloat32; 1250 typedef float GoFloat32;
1243 typedef double GoFloat64; 1251 typedef double GoFloat64;
1244 typedef __complex float GoComplex64; 1252 typedef __complex float GoComplex64;
1245 typedef __complex double GoComplex128; 1253 typedef __complex double GoComplex128;
1246 1254
1247 typedef struct { char *p; GoInt n; } GoString; 1255 typedef struct { char *p; GoInt n; } GoString;
1248 typedef void *GoMap; 1256 typedef void *GoMap;
1249 typedef void *GoChan; 1257 typedef void *GoChan;
1250 typedef struct { void *t; void *v; } GoInterface; 1258 typedef struct { void *t; void *v; } GoInterface;
1251 typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; 1259 typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
1252 ` 1260 `
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b