]> Cypherpunks.ru repositories - gostls13.git/blobdiff - misc/cgo/test/cthread_unix.c
runtime/cgo: store M for C-created thread in pthread key
[gostls13.git] / misc / cgo / test / cthread_unix.c
index b6ec39816b6c4af0110f2c9155b4e64592523292..d0da643158e5f45776ec1296b8f76325942401e4 100644 (file)
@@ -32,3 +32,27 @@ doAdd(int max, int nthread)
        for(i=0; i<nthread; i++)
                pthread_join(thread_id[i], 0);          
 }
+
+static void*
+goDummyCallbackThread(void* p)
+{
+       int i, max;
+
+       max = *(int*)p;
+       for(i=0; i<max; i++)
+               goDummy();
+       return NULL;
+}
+
+int
+callGoInCThread(int max)
+{
+       pthread_t thread;
+
+       if (pthread_create(&thread, NULL, goDummyCallbackThread, (void*)(&max)) != 0)
+               return -1;
+       if (pthread_join(thread, NULL) != 0)
+               return -1;
+
+       return max;
+}