Commit 1f2445d2 authored by Russ Cox's avatar Russ Cox

gc: delete old unsafe functions

Also update build to be able to run mkbuiltin again.
The export form has changed a little, so builtin.c has
more diffs than unsafe.go.

In CL 5650069, I just edited the documentation, a rarely
successful method of change.

R=ken2
CC=golang-dev
https://golang.org/cl/5662043
parent 0a2ffb26
......@@ -1212,6 +1212,7 @@ cmdenv(int argc, char **argv)
xprintf(format, "GOBIN", gobin);
xprintf(format, "GOARCH", goarch);
xprintf(format, "GOOS", goos);
xprintf(format, "GOCHAR", gochar);
if(pflag) {
sep = ":";
if(streq(gohostos, "windows"))
......
This diff is collapsed.
......@@ -10,21 +10,22 @@
set -e
eval $(go tool make --no-print-directory -f ../../Make.inc go-env)
if [ -z "$GC" ]; then
echo 'missing $GC - gomake failed?' 1>&2
eval $(go tool dist env)
if [ -z "$GOCHAR" ]; then
echo 'missing $GOCHAR - go tool dist failed?' 1>&2
exit 1
fi
go tool make mkbuiltin1
GC=${GOCHAR}g
gcc -o mkbuiltin1 mkbuiltin1.c
rm -f _builtin.c
for i in runtime unsafe
do
go tool $GC -A $i.go
O=$O ./mkbuiltin1 $i >>_builtin.c
O=$GOCHAR ./mkbuiltin1 $i >>_builtin.c
done
# If _builtin.c has changed vs builtin.c.boot,
# check in the new change.
cmp -s _builtin.c builtin.c || cp _builtin.c builtin.c
rm _builtin.c
rm _builtin.c mkbuiltin1 unsafe.$GOCHAR runtime.$GOCHAR
......@@ -6,13 +6,17 @@
// Compile .go file, import data from .6 file, and generate C string version.
#include <u.h>
#include <libc.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
void esc(char*);
void fatal(char*, ...);
void
int
main(int argc, char **argv)
{
char *name;
......@@ -21,7 +25,7 @@ main(int argc, char **argv)
if(argc != 2) {
fprintf(stderr, "usage: mkbuiltin1 sys\n");
sysfatal("in file $1.6 s/PACKAGE/$1/\n");
fatal("in file $1.6 s/PACKAGE/$1/");
}
name = argv[1];
......@@ -29,14 +33,14 @@ main(int argc, char **argv)
snprintf(buf, sizeof(buf), "%s.%s", name, getenv("O"));
if((fin = fopen(buf, "r")) == NULL) {
sysfatal("open %s: %r\n", buf);
fatal("open %s: %s", buf, strerror(errno));
}
// look for $$ that introduces imports
while(fgets(buf, sizeof buf, fin) != NULL)
if(strstr(buf, "$$"))
goto begin;
sysfatal("did not find beginning of imports\n");
fatal("did not find beginning of imports");
begin:
printf("char *%simport =\n", name);
......@@ -68,11 +72,11 @@ begin:
esc(p);
printf("\\n\"\n");
}
sysfatal("did not find end of imports\n");
fatal("did not find end of imports");
end:
printf("\t\"$$\\n\";\n");
exits(0);
return 0;
}
void
......@@ -84,3 +88,15 @@ esc(char *p)
putchar(*p);
}
}
void
fatal(char *msg, ...)
{
va_list arg;
va_start(arg, msg);
fprintf(stderr, "fatal: ");
vfprintf(stderr, msg, arg);
fprintf(stderr, "\n");
exit(2);
}
......@@ -16,9 +16,3 @@ type Pointer uintptr // not really; filled in by compiler
func Offsetof(any) uintptr
func Sizeof(any) uintptr
func Alignof(any) uintptr
func Typeof(i interface{}) (typ interface{})
func Reflect(i interface{}) (typ interface{}, addr Pointer)
func Unreflect(typ interface{}, addr Pointer) (ret interface{})
func New(typ interface{}) Pointer
func NewArray(typ interface{}, n int) Pointer
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment