github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/cmd/dist/a.h (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 typedef int bool; 6 7 // The Time unit is unspecified; we just need to 8 // be able to compare whether t1 is older than t2 with t1 < t2. 9 typedef long long Time; 10 11 #define nil ((void*)0) 12 #define nelem(x) (sizeof(x)/sizeof((x)[0])) 13 #ifndef PLAN9 14 #define USED(x) ((void)(x)) 15 #endif 16 17 // A Buf is a byte buffer, like Go's []byte. 18 typedef struct Buf Buf; 19 struct Buf 20 { 21 char *p; 22 int len; 23 int cap; 24 }; 25 26 // A Vec is a string vector, like Go's []string. 27 typedef struct Vec Vec; 28 struct Vec 29 { 30 char **p; 31 int len; 32 int cap; 33 }; 34 35 // Modes for run. 36 enum { 37 CheckExit = 1, 38 }; 39 40 // buf.c 41 bool bequal(Buf *s, Buf *t); 42 void bsubst(Buf *b, char *x, char *y); 43 void bfree(Buf *b); 44 void bgrow(Buf *b, int n); 45 void binit(Buf *b); 46 char* bpathf(Buf *b, char *fmt, ...); 47 char* bprintf(Buf *b, char *fmt, ...); 48 void bwritef(Buf *b, char *fmt, ...); 49 void breset(Buf *b); 50 char* bstr(Buf *b); 51 char* btake(Buf *b); 52 void bwrite(Buf *b, void *v, int n); 53 void bwriteb(Buf *dst, Buf *src); 54 void bwritestr(Buf *b, char *p); 55 void bswap(Buf *b, Buf *b1); 56 void vadd(Vec *v, char *p); 57 void vcopy(Vec *dst, char **src, int n); 58 void vfree(Vec *v); 59 void vgrow(Vec *v, int n); 60 void vinit(Vec *v); 61 void vreset(Vec *v); 62 void vuniq(Vec *v); 63 void splitlines(Vec*, char*); 64 void splitfields(Vec*, char*); 65 66 // build.c 67 extern char *goarch; 68 extern char *gobin; 69 extern char *gochar; 70 extern char *gohostarch; 71 extern char *gohostos; 72 extern char *goos; 73 extern char *goroot; 74 extern char *goroot_final; 75 extern char *goextlinkenabled; 76 extern char *goversion; 77 extern char *workdir; 78 extern char *tooldir; 79 extern char *slash; 80 extern bool rebuildall; 81 82 int find(char*, char**, int); 83 void init(void); 84 void cmdbanner(int, char**); 85 void cmdbootstrap(int, char**); 86 void cmdclean(int, char**); 87 void cmdenv(int, char**); 88 void cmdinstall(int, char**); 89 void cmdversion(int, char**); 90 91 // buildgc.c 92 void gcopnames(char*, char*); 93 void mkenam(char*, char*); 94 95 // buildruntime.c 96 void mkzasm(char*, char*); 97 void mkzgoarch(char*, char*); 98 void mkzgoos(char*, char*); 99 void mkzruntimedefs(char*, char*); 100 void mkzversion(char*, char*); 101 102 // goc2c.c 103 void goc2c(char*, char*); 104 105 // main.c 106 extern int vflag; 107 void usage(void); 108 void xmain(int argc, char **argv); 109 110 // portability layer (plan9.c, unix.c, windows.c) 111 bool contains(char *p, char *sep); 112 void errprintf(char*, ...); 113 void fatal(char *msg, ...); 114 bool hasprefix(char *p, char *prefix); 115 bool hassuffix(char *p, char *suffix); 116 bool isabs(char*); 117 bool isdir(char *p); 118 bool isfile(char *p); 119 char* lastelem(char*); 120 Time mtime(char*); 121 void readfile(Buf*, char*); 122 void run(Buf *b, char *dir, int mode, char *cmd, ...); 123 void runv(Buf *b, char *dir, int mode, Vec *argv); 124 void bgrunv(char *dir, int mode, Vec *argv); 125 void bgwait(void); 126 bool streq(char*, char*); 127 bool cansse2(void); 128 void writefile(Buf*, char*, int); 129 void xatexit(void (*f)(void)); 130 void xexit(int); 131 void xfree(void*); 132 void xgetenv(Buf *b, char *name); 133 void xgetwd(Buf *b); 134 void* xmalloc(int n); 135 void* xmalloc(int); 136 int xmemcmp(void*, void*, int); 137 void xmemmove(void*, void*, int); 138 void xmkdir(char *p); 139 void xmkdirall(char*); 140 Time xmtime(char *p); 141 void xprintf(char*, ...); 142 void xqsort(void*, int, int, int(*)(const void*, const void*)); 143 void xreaddir(Vec *dst, char *dir); 144 void* xrealloc(void*, int); 145 void xrealwd(Buf *b, char *path); 146 void xremove(char *p); 147 void xremoveall(char *p); 148 void xsetenv(char*, char*); 149 int xstrcmp(char*, char*); 150 char* xstrdup(char *p); 151 int xstrlen(char*); 152 char* xstrrchr(char*, int); 153 char* xstrstr(char*, char*); 154 char* xworkdir(void); 155 int xsamefile(char*, char*); 156 char* xgetgoarm(void); 157 int xtryexecfunc(void (*)(void));