LEFT | RIGHT |
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 Loading... |
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 ` |
LEFT | RIGHT |