github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/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 *defaultcc;
    78  extern char *defaultcxxtarget;
    79  extern char *defaultcctarget;
    80  extern char *workdir;
    81  extern char *tooldir;
    82  extern char *slash;
    83  extern bool rebuildall;
    84  extern bool defaultclang;
    85  
    86  int	find(char*, char**, int);
    87  void	init(void);
    88  void	cmdbanner(int, char**);
    89  void	cmdbootstrap(int, char**);
    90  void	cmdclean(int, char**);
    91  void	cmdenv(int, char**);
    92  void	cmdinstall(int, char**);
    93  void	cmdversion(int, char**);
    94  
    95  // buildgc.c
    96  void	gcopnames(char*, char*);
    97  void	mkanames(char*, char*);
    98  
    99  // buildruntime.c
   100  void	mkzasm(char*, char*);
   101  void	mkzsys(char*, char*);
   102  void	mkzgoarch(char*, char*);
   103  void	mkzgoos(char*, char*);
   104  void	mkzruntimedefs(char*, char*);
   105  void	mkzversion(char*, char*);
   106  void	mkzexperiment(char*, char*);
   107  
   108  // buildgo.c
   109  void	mkzdefaultcc(char*, char*);
   110  
   111  // main.c
   112  extern int vflag;
   113  extern int sflag;
   114  void	usage(void);
   115  void	xmain(int argc, char **argv);
   116  
   117  // portability layer (plan9.c, unix.c, windows.c)
   118  bool	contains(char *p, char *sep);
   119  void	errprintf(char*, ...);
   120  void	fatal(char *msg, ...);
   121  bool	hasprefix(char *p, char *prefix);
   122  bool	hassuffix(char *p, char *suffix);
   123  bool	isabs(char*);
   124  bool	isdir(char *p);
   125  bool	isfile(char *p);
   126  char*	lastelem(char*);
   127  Time	mtime(char*);
   128  void	readfile(Buf*, char*);
   129  void	copyfile(char*, char*, int);
   130  void	run(Buf *b, char *dir, int mode, char *cmd, ...);
   131  void	runv(Buf *b, char *dir, int mode, Vec *argv);
   132  void	bgrunv(char *dir, int mode, Vec *argv);
   133  void	bgwait(void);
   134  bool	streq(char*, char*);
   135  bool	cansse2(void);
   136  void	writefile(Buf*, char*, int);
   137  void	xatexit(void (*f)(void));
   138  void	xexit(int);
   139  void	xfree(void*);
   140  void	xgetenv(Buf *b, char *name);
   141  void	xgetwd(Buf *b);
   142  void*	xmalloc(int n);
   143  void*	xmalloc(int);
   144  int	xmemcmp(void*, void*, int);
   145  void	xmemmove(void*, void*, int);
   146  void	xmkdir(char *p);
   147  void	xmkdirall(char*);
   148  Time	xmtime(char *p);
   149  void	xprintf(char*, ...);
   150  void	xqsort(void*, int, int, int(*)(const void*, const void*));
   151  void	xreaddir(Vec *dst, char *dir);
   152  void*	xrealloc(void*, int);
   153  void	xrealwd(Buf *b, char *path);
   154  void	xremove(char *p);
   155  void	xremoveall(char *p);
   156  void	xsetenv(char*, char*);
   157  int	xstrcmp(char*, char*);
   158  char*	xstrdup(char *p);
   159  int	xstrlen(char*);
   160  char*	xstrrchr(char*, int);
   161  char*	xstrstr(char*, char*);
   162  char*	xworkdir(void);
   163  int	xsamefile(char*, char*);
   164  char*	xgetgoarm(void);
   165  int	xtryexecfunc(void (*)(void));