]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/cgo: runtime changes for new cgo
authorRuss Cox <rsc@golang.org>
Wed, 8 Dec 2010 18:53:30 +0000 (13:53 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 8 Dec 2010 18:53:30 +0000 (13:53 -0500)
Formerly known as libcgo.
Almost no code here is changing; the diffs
are shown relative to the originals in libcgo.

R=r
CC=golang-dev
https://golang.org/cl/3420043

src/pkg/Makefile
src/pkg/runtime/cgocall.c
src/pkg/runtime/darwin/thread.c
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h

index 48649846b8298d9d045d3d1f3c7c1aec8e985bd9..22da9f98c511692a4eb266ba13b81fea856532b9 100644 (file)
@@ -109,6 +109,7 @@ DIRS=\
        rpc\
        rpc/jsonrpc\
        runtime\
+       runtime/cgo\
        runtime/pprof\
        scanner\
        smtp\
@@ -152,6 +153,7 @@ NOTEST=\
        image/jpeg\
        net/dict\
        rand\
+       runtime/cgo\
        runtime/pprof\
        syscall\
        testing\
@@ -247,3 +249,4 @@ deps:
 -include Make.deps
 
 ../cmd/cgo.install: ../libcgo.install
+runtime/cgo.install: ../cmd/cgo.install
index b2852be8deefbe61aa1288fe93144a26afde3a06..80ae97e7af7d86a597ac63753e9087f28e00ab34 100644 (file)
@@ -15,9 +15,12 @@ runtime·cgocall(void (*fn)(void*), void *arg)
 {
        G *oldlock;
 
-       if(initcgo == nil)
+       if(!runtime·iscgo)
                runtime·throw("cgocall unavailable");
 
+       if(fn == 0)
+               runtime·throw("cgocall nil");
+
        ncgocall++;
 
        /*
@@ -94,7 +97,7 @@ void (*_cgo_free)(void*);
 void*
 runtime·cmalloc(uintptr n)
 {
-       struct {
+       struct {
                uint64 n;
                void *ret;
        } a;
index 58aa9da34a67dbee70e984d5fb09f8845d575e2a..185f0ce963c8ca801c9e392f2d6bf4a9b86c419d 100644 (file)
@@ -144,8 +144,7 @@ runtime·osinit(void)
        // Register our thread-creation callback (see {amd64,386}/sys.s)
        // but only if we're not using cgo.  If we are using cgo we need
        // to let the C pthread libary install its own thread-creation callback.
-       extern void (*libcgo_thread_start)(void*);
-       if(libcgo_thread_start == nil)
+       if(!runtime·iscgo)
                runtime·bsdthread_register();
 }
 
index ff8673a314d7f1a396734987b426e9cf35fb63f0..3d5ee24c492341a7c120e018f6e2a4ded53235a9 100644 (file)
@@ -8,6 +8,8 @@
 #include "malloc.h"
 #include "os.h"
 
+bool   runtime·iscgo;
+
 static void unwindstack(G*, byte*);
 
 typedef struct Sched Sched;
@@ -426,8 +428,11 @@ matchmg(void)
                        runtime·allm = m;
                        m->id = runtime·sched.mcount++;
 
-                       if(libcgo_thread_start != nil) {
+                       if(runtime·iscgo) {
                                CgoThreadStart ts;
+
+                               if(libcgo_thread_start == nil)
+                                       runtime·throw("libcgo_thread_start missing");
                                // pthread_create will make us a stack.
                                m->g0 = runtime·malg(-1);
                                ts.m = m;
index 3f6fb77f971fd773162233263d19d5e2c321a0f3..ececacc82d8e3c093042f4df6565e9b99d409afd 100644 (file)
@@ -361,6 +361,7 @@ extern      int32   runtime·panicking;
 extern int32   runtime·fd;    // usually 1; set to 2 when panicking
 extern int32   runtime·gcwaiting;             // gc is waiting to run
 int8*  runtime·goos;
+extern bool    runtime·iscgo;
 
 /*
  * common functions and data