Skip to content

Commit 2b57a11

Browse files
Add cgo2c program to translate mixed Go/C code into C. This
lets us use a single source file for both 6c and gcc, handling the incompatible handling of return values. R=rsc DELTA=649 (613 added, 35 deleted, 1 changed) OCL=22682 CL=22730
1 parent 58b280d commit 2b57a11

File tree

5 files changed

+619
-36
lines changed

5 files changed

+619
-36
lines changed

src/runtime/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ LIBOFILES=\
2424
array.$O\
2525
mem.$O\
2626
malloc.$O\
27+
malloc_go.$O\
2728
mcache.$O\
2829
mcentral.$O\
2930
mfixalloc.$O\
@@ -57,14 +58,21 @@ nuke:
5758
rm -f *.$(O) *.a $(GOROOT)/lib/$(LIB)
5859

5960
clean:
60-
rm -f *.$(O) *.a runtime.acid
61+
rm -f *.$(O) *.a runtime.acid cgo2c
6162

6263
%.$O: %.c
6364
$(CC) -wF $<
6465

6566
sys_file.$O: sys_file.c sys_types.h $(OS_H)
6667
$(CC) -wF -D$(GOARCH)_$(GOOS) $<
6768

69+
cgo2c: cgo2c.c
70+
quietgcc -o $@ $<
71+
72+
%.c: %.cgo cgo2c
73+
./cgo2c < $< > $@.tmp
74+
mv -f $@.tmp $@
75+
6876
%.$O: %.s
6977
$(AS) $<
7078

0 commit comments

Comments
 (0)