* move memory code into $GOOS-specific directory.
* allow printing of static strings < 256 bytes.
(dynamic strings will bump maxstring as they are allocated.)
* use cgo2c for runtime.mal.
R=r, dho
CC=golang-dev
https://golang.org/cl/186143
reflect.$O\
rune.$O\
runtime.$O\
+ runtime1.$O\
rt0.$O\
sema.$O\
signal.$O\
thread.$O\
traceback.$O\
$(OFILES_$(GOARCH))\
+ $(OFILES_$(GOOS))\
HFILES=\
cgocall.h\
$(GOOS)/signals.h\
$(GOOS)/$(GOARCH)/defs.h\
+GOFILES+=$(GOFILES_$(GOOS))
+
include ../../Make.pkg
clean: clean-local
--- /dev/null
+#include "runtime.h"
+#include "defs.h"
+#include "os.h"
+#include "malloc.h"
+
+void*
+SysAlloc(uintptr n)
+{
+ mstats.sys += n;
+ return runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
+}
+
+void
+SysUnused(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+ // TODO(rsc): call madvise MADV_DONTNEED
+}
+
+void
+SysFree(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+ // TODO(rsc): call munmap
+}
+
--- /dev/null
+#include "runtime.h"
+#include "defs.h"
+#include "os.h"
+#include "malloc.h"
+
+void*
+SysAlloc(uintptr n)
+{
+ mstats.sys += n;
+ return runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
+}
+
+void
+SysUnused(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+ // TODO(rsc): call madvise MADV_DONTNEED
+}
+
+void
+SysFree(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+ // TODO(rsc): call munmap
+}
+
--- /dev/null
+#include "runtime.h"
+#include "defs.h"
+#include "os.h"
+#include "malloc.h"
+
+void*
+SysAlloc(uintptr n)
+{
+ void *p;
+
+ mstats.sys += n;
+ p = runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
+ if(p < (void*)4096) {
+ if(p == (void*)EACCES) {
+ printf("mmap: access denied\n");
+ printf("If you're running SELinux, enable execmem for this process.\n");
+ } else {
+ printf("mmap: errno=%p\n", p);
+ }
+ exit(2);
+ }
+ return p;
+}
+
+void
+SysUnused(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+ // TODO(rsc): call madvise MADV_DONTNEED
+}
+
+void
+SysFree(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+ // TODO(rsc): call munmap
+}
+
free(malloc(1));
}
-void*
-SysAlloc(uintptr n)
-{
- void *p;
-
- mstats.sys += n;
- p = runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
- if(p < (void*)4096) {
- if(p == (void*)EACCES) {
- printf("mmap: access denied\n");
- printf("If you're running SELinux, enable execmem for this process.\n");
- } else {
- printf("mmap: errno=%p\n", p);
- }
- exit(2);
- }
- return p;
-}
-
-void
-SysUnused(void *v, uintptr n)
-{
- USED(v);
- USED(n);
- // TODO(rsc): call madvise MADV_DONTNEED
-}
-
-void
-SysFree(void *v, uintptr n)
-{
- USED(v);
- USED(n);
- // TODO(rsc): call munmap
-}
-
// Runtime stubs.
void*
int32 mlookup(void *v, byte **base, uintptr *size, uint32 **ref);
void gc(int32 force);
+void* SysAlloc(uintptr);
+void SysUnused(void*, uintptr);
+void SysFree(void*, uintptr);
+
enum
{
RefcountOverhead = 4, // one uint32 per object
+++ /dev/null
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "runtime.h"
-#include "defs.h"
-
-// Stubs for memory management.
-// In a separate file so they can be overridden during testing of gc.
-
-enum
-{
- NHUNK = 20<<20,
-};
-
-void
-runtimeĀ·mal(uint32 n, uint8 *ret)
-{
- ret = mal(n);
- FLUSH(&ret);
-}
--- /dev/null
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "runtime.h"
+#include "os.h"
+#include "defs.h"
+#include "malloc.h"
+
+void*
+SysAlloc(uintptr n)
+{
+ return stdcall(VirtualAlloc, nil, n, 0x3000, 0x40);
+}
+
+void
+SysUnused(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+}
+
+void
+SysFree(void *v, uintptr n)
+{
+ USED(v);
+ USED(n);
+}
+
void *stdcall(void *fn, ...);
void *stdcall_raw(void *fn, ...);
+extern void *VirtualAlloc;
+
#define goargs mingw_goargs
void mingw_goargs(void);
void *GetStdHandle;
void *SetEvent;
void *WriteFile;
+void *VirtualAlloc;
static void *CreateEvent;
static void *CreateThread;
static void *GetModuleHandle;
static void *GetProcAddress;
static void *LoadLibraryEx;
-static void *VirtualAlloc;
static void *WaitForSingleObject;
static void*
return written;
}
-uint8*
-runtime_mmap(byte *addr, uint32 len, int32 prot,
- int32 flags, int32 fd, uint32 off)
-{
- USED(prot, flags, fd, off);
- return stdcall(VirtualAlloc, addr, len, 0x3000, 0x40);
-}
-
void*
get_symdat_addr(void)
{
--- /dev/null
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package runtime
+#include "runtime.h"
+
+func mal(n uint32) (ret *uint8) {
+ ret = mal(n);
+}
+
return l;
}
-int32 maxstring;
+int32 maxstring = 256;
String
gostringsize(int32 l)