include ../../Make.inc
-TARG=runtime
-
-# Set SIZE to 32 or 64.
-SIZE_386=32
-SIZE_amd64=64
-SIZE_arm=32
-SIZE=$(SIZE_$(GOARCH))
+# Go tool will do this for package runtime.
+CFLAGS+=-DGOOS_$(GOOS) -DGOARCH_$(GOARCH)
-CFLAGS_windows=-D__WINDOWS__
-CFLAGS=-I$(GOOS) -I$(GOARCH) -I$(GOOS)/$(GOARCH) -FVw $(CFLAGS_$(GOARCH)) $(CFLAGS_$(GOOS))
+TARG=runtime
GOFILES=\
debug.go\
lock_sema.$O\
OFILES_windows=\
- callback.$O\
+ callback_windows_$(GOARCH).$O\
lock_sema.$O\
- syscall.$O\
+ syscall_windows.$O\
# 386-specific object files
OFILES_386=\
- vlop.$O\
- vlrt.$O\
+ vlop_386.$O\
+ vlrt_386.$O\
# arm-specific object files
OFILES_arm=\
- memset.$O\
- softfloat.$O\
- vlop.$O\
- vlrt.$O\
+ memset_arm.$O\
+ softfloat_arm.$O\
+ vlop_arm.$O\
+ vlrt_arm.$O\
OFILES=\
alg.$O\
- asm.$O\
- atomic.$O\
+ asm_$(GOARCH).$O\
+ atomic_$(GOARCH).$O\
cgocall.$O\
chan.$O\
- closure.$O\
+ closure_$(GOARCH).$O\
complex.$O\
cpuprof.$O\
float.$O\
malloc.$O\
mcache.$O\
mcentral.$O\
- mem.$O\
- memmove.$O\
+ mem_$(GOOS).$O\
+ memmove_$(GOARCH).$O\
mfinal.$O\
mfixalloc.$O\
mgc0.$O\
msize.$O\
print.$O\
proc.$O\
- rt0.$O\
+ rt0_$(GOOS)_$(GOARCH).$O\
rune.$O\
runtime.$O\
runtime1.$O\
sema.$O\
- signal.$O\
+ signal_$(GOOS)_$(GOARCH).$O\
sigqueue.$O\
slice.$O\
string.$O\
symtab.$O\
- sys.$O\
- thread.$O\
+ sys_$(GOOS)_$(GOARCH).$O\
+ thread_$(GOOS).$O\
time.$O\
- traceback.$O\
+ traceback_$(GOARCH).$O\
$(OFILES_$(GOARCH))\
$(OFILES_$(GOOS))\
+AUTOHFILES=\
+ arch_GOARCH.h\
+ os_GOOS.h\
+ signals_GOOS.h\
+ defs_GOOS_GOARCH.h\
+
HFILES=\
cgocall.h\
runtime.h\
hashmap.h\
malloc.h\
stack.h\
- $(GOARCH)/asm.h\
- $(GOOS)/os.h\
- $(GOOS)/signals.h\
- $(GOOS)/$(GOARCH)/defs.h\
+ $(AUTOHFILES)\
GOFILES+=$(GOFILES_$(GOOS))
clean: clean-local
clean-local:
- rm -f goc2c mkversion version.go */asm.h runtime.acid.* runtime_defs.go $$(ls *.goc | sed 's/goc$$/c/')
+ rm -f goc2c mkversion version.go runtime.acid.* runtime_defs.go $$(ls *.goc | sed 's/goc$$/c/') $(AUTOHFILES)
-$(GOARCH)/asm.h: mkasmh.sh runtime.acid.$(GOARCH)
+asm_$(GOARCH).h: mkasmh.sh runtime.acid.$(GOARCH)
./mkasmh.sh >$@.x
mv -f $@.x $@
./goc2c "`pwd`/$<" > $@.tmp
mv -f $@.tmp $@
-%.$O: $(GOARCH)/%.c $(HFILES)
- $(CC) $(CFLAGS) $<
-
-%.$O: $(GOOS)/%.c $(HFILES)
- $(CC) $(CFLAGS) $<
-
-%.$O: $(GOOS)/$(GOARCH)/%.c $(HFILES)
- $(CC) $(CFLAGS) $<
-
-%.$O: $(GOARCH)/%.s $(GOARCH)/asm.h
- $(AS) $<
-
-%.$O: $(GOOS)/$(GOARCH)/%.s $(GOARCH)/asm.h
- $(AS) $<
+%.$O: asm_$(GOARCH).h
# for discovering offsets inside structs when debugging
runtime.acid.$(GOARCH): runtime.h proc.c
$(CC) $(CFLAGS) $<
endif
-runtime_defs.go: proc.c iface.c hashmap.c chan.c
- CC="$(CC)" CFLAGS="$(CFLAGS)" ./mkgodefs.sh $^ > $@.x
+runtime_defs.go: proc.c iface.c hashmap.c chan.c $(HFILES)
+ CC="$(CC)" CFLAGS="$(CFLAGS)" ./mkgodefs.sh proc.c iface.c hashmap.c chan.c > $@.x
mv -f $@.x $@
+
+arch_GOARCH.h: arch_$(GOARCH).h
+ cp $^ $@
+
+defs_GOOS_GOARCH.h: defs_$(GOOS)_$(GOARCH).h
+ cp $^ $@
+
+os_GOOS.h: os_$(GOOS).h
+ cp $^ $@
+
+signals_GOOS.h: signals_$(GOOS).h
+ cp $^ $@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "386/asm.h"
+#include "asm_386.h"
TEXT _rt0_386(SB),7,$0
// Linux, Windows start the FPU in extended double precision.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "amd64/asm.h"
+#include "asm_amd64.h"
TEXT _rt0_amd64(SB),7,$-8
// copy arguments forward on an even stack
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "arm/asm.h"
+#include "asm_arm.h"
// using frame size $-4 means do not save LR on stack.
TEXT _rt0_arm(SB),7,$-4
#include "runtime.h"
#include "type.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
// Will keep all callbacks in a linked list, so they don't get garbage collected.
typedef struct Callback Callback;
#include "runtime.h"
#include "type.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
// Will keep all callbacks in a linked list, so they don't get garbage collected.
typedef struct Callback Callback;
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "stack.h"
#include "cgocall.h"
// in the situation when normally the goroutine "owns" handoff.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
enum
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "type.h"
#include "malloc.h"
package runtime
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "stack.h"
#include "malloc.h"
-#include "defs.h"
+#include "defs_GOOS_GOARCH.h"
#include "type.h"
MHeap runtime·mheap;
// See malloc.h for an overview.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
void*
// so that it is faster to move those lists between MCaches and MCentrals.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
static bool MCentral_Grow(MCentral *c);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
-#include "defs.h"
-#include "os.h"
+#include "arch_GOARCH.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "malloc.h"
void*
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
-#include "defs.h"
-#include "os.h"
+#include "arch_GOARCH.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "malloc.h"
void*
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
-#include "defs.h"
-#include "os.h"
+#include "arch_GOARCH.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "malloc.h"
enum
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
-#include "defs.h"
-#include "os.h"
+#include "arch_GOARCH.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "malloc.h"
enum
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
-#include "defs.h"
-#include "os.h"
+#include "arch_GOARCH.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "malloc.h"
enum
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
-#include "os.h"
+#include "os_GOOS.h"
extern byte end[];
static byte *bloc = { end };
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
-#include "os.h"
-#include "defs.h"
+#include "arch_GOARCH.h"
+#include "os_GOOS.h"
+#include "defs_GOOS_GOARCH.h"
#include "malloc.h"
enum {
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
enum { debug = 0 };
// See malloc.h for overview.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
// Initialize f to allocate objects of the given size,
// Garbage collector.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
#include "stack.h"
// and heapmap(i) == span for all s->start <= i < s->start+s->npages.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
static MSpan *MHeap_AllocLocked(MHeap*, uintptr, int32);
package runtime
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
-#include "defs.h"
+#include "defs_GOOS_GOARCH.h"
#include "type.h"
// NOTE(rsc): Everything here could use cas if contention became an issue.
// TODO(rsc): Compute max waste for any given size.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
int32 runtime·class_to_size[NumSizeClasses];
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
-#include "defs.h"
+#include "arch_GOARCH.h"
+#include "defs_GOOS_GOARCH.h"
#include "malloc.h"
-#include "os.h"
+#include "os_GOOS.h"
#include "stack.h"
bool runtime·iscgo;
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "amd64/asm.h"
+#include "asm_amd64.h"
TEXT _rt0_amd64_windows(SB),7,$-8
MOVQ $_rt0_amd64(SB), AX
uint32 waitsemacount;
uint32 waitsemalock;
-#ifdef __WINDOWS__
+#ifdef GOOS_windows
void* thread; // thread handle
#endif
uintptr end[];
uintptr err; // error number
};
-#ifdef __WINDOWS__
+#ifdef GOOS_windows
enum {
Windows = 1
};
package runtime
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
typedef struct Sema Sema;
struct Sema
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
-#include "signals.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
+#include "signals_GOOS.h"
void
runtime·dumpregs(Regs32 *r)
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
-#include "signals.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
+#include "signals_GOOS.h"
void
runtime·dumpregs(Regs64 *r)
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
extern void runtime·sigtramp(void);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
extern void runtime·sigtramp(void);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
void
runtime·dumpregs(Sigcontext *r)
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
void
runtime·dumpregs(Sigcontext *r)
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
void
runtime·dumpregs(Sigcontext *r)
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
extern void runtime·sigtramp(void);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
extern void runtime·sigtramp(void);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
extern void runtime·sigtramp(void);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "signals.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "signals_GOOS.h"
+#include "os_GOOS.h"
extern void runtime·sigtramp(void);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
void
runtime·dumpregs(Context *r)
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
extern void *runtime·sigtramp;
package runtime
#include "runtime.h"
-#include "defs.h"
+#include "defs_GOOS_GOARCH.h"
static struct {
Note;
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "type.h"
#include "malloc.h"
// to each stack below the usual guard area for OS-specific
// purposes like signal handling. Used on Windows because
// it does not use a separate stack.
-#ifdef __WINDOWS__
+#ifdef GOOS_windows
StackSystem = 512 * sizeof(uintptr),
#else
StackSystem = 0,
package runtime
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
String runtime·emptystring;
// and figure out exactly what we want.
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
-#include "arch.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
+#include "arch_GOARCH.h"
extern byte pclntab[], epclntab[], symtab[], esymtab[];
// See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228
// or /usr/include/sys/syscall.h (on a Mac) for system call numbers.
-#include "386/asm.h"
+#include "asm_386.h"
TEXT runtime·notok(SB),7,$0
MOVL $0xf1, 0xf1
// The high 8 bits specify the kind of system call: 1=Mach, 2=BSD, 3=Machine-Dependent.
//
-#include "amd64/asm.h"
+#include "asm_amd64.h"
// Exit the entire program (like C exit)
TEXT runtime·exit(SB),7,$0
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
-#include "386/asm.h"
+#include "asm_386.h"
TEXT runtime·sys_umtx_op(SB),7,$-4
MOVL $454, AX
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
-#include "amd64/asm.h"
+#include "asm_amd64.h"
TEXT runtime·sys_umtx_op(SB),7,$0
MOVQ 8(SP), DI
// System calls and other sys.stuff for 386, Linux
//
-#include "386/asm.h"
+#include "asm_386.h"
TEXT runtime·exit(SB),7,$0
MOVL $252, AX // syscall number
// System calls and other sys.stuff for AMD64, Linux
//
-#include "amd64/asm.h"
+#include "asm_amd64.h"
TEXT runtime·exit(SB),7,$0-8
MOVL 8(SP), DI
// System calls and other sys.stuff for arm, Linux
//
-#include "arm/asm.h"
+#include "asm_arm.h"
// OABI
//#define SYS_BASE 0x00900000
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
-#include "386/asm.h"
+#include "asm_386.h"
// Exit the entire program (like C exit)
TEXT runtime·exit(SB),7,$-4
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
-#include "amd64/asm.h"
+#include "asm_amd64.h"
// int64 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
TEXT runtime·rfork_thread(SB),7,$0
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
-#include "386/asm.h"
+#include "asm_386.h"
// Exit the entire program (like C exit)
TEXT runtime·exit(SB),7,$-4
// /usr/src/sys/kern/syscalls.master for syscall numbers.
//
-#include "amd64/asm.h"
+#include "asm_amd64.h"
// int64 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
TEXT runtime·rfork_thread(SB),7,$0
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "defs.h"
-#include "386/asm.h"
+#include "defs_GOOS_GOARCH.h"
+#include "asm_386.h"
// setldt(int entry, int address, int limit)
TEXT runtime·setldt(SB),7,$0
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "386/asm.h"
+#include "asm_386.h"
// void runtime·asmstdcall(void *c);
TEXT runtime·asmstdcall(SB),7,$0
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "amd64/asm.h"
+#include "asm_amd64.h"
// maxargs should be divisible by 2, as Windows stack
// must be kept 16-byte aligned on syscall entry.
package syscall
#include "runtime.h"
-#include "os.h"
+#include "os_GOOS.h"
#include "cgocall.h"
func loadlibrary(filename *uint16) (handle uintptr, err uintptr) {
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "stack.h"
extern SigTab runtime·sigtab[];
// license that can be found in the LICENSE file.`
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "stack.h"
extern SigTab runtime·sigtab[];
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "stack.h"
extern SigTab runtime·sigtab[];
// license that can be found in the LICENSE file.`
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "stack.h"
enum
// license that can be found in the LICENSE file.`
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#include "stack.h"
enum
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "os.h"
-#include "arch.h"
+#include "os_GOOS.h"
+#include "arch_GOARCH.h"
int8 *goos = "plan9";
#include "runtime.h"
#include "type.h"
-#include "defs.h"
-#include "os.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
#pragma dynimport runtime·CloseHandle CloseHandle "kernel32.dll"
#pragma dynimport runtime·CreateEvent CreateEventA "kernel32.dll"
package time
#include "runtime.h"
-#include "defs.h"
-#include "os.h"
-#include "arch.h"
+#include "defs_GOOS_GOARCH.h"
+#include "os_GOOS.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
static Timers timers;
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
static uintptr isclosureentry(uintptr);
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "arch.h"
+#include "arch_GOARCH.h"
#include "malloc.h"
void runtime·deferproc(void);