1
0
mirror of https://github.com/golang/go synced 2024-11-19 16:04:48 -07:00

runtime/cgo: check for errors from pthread_create

R=rsc, iant, dvyukov
CC=golang-dev
https://golang.org/cl/4643057
This commit is contained in:
Albert Strasheim 2011-06-28 12:04:50 -04:00 committed by Russ Cox
parent 660b22988b
commit a026d0fc76
7 changed files with 47 additions and 8 deletions

View File

@ -222,12 +222,21 @@ addpid(int pid, int force)
// The excthread reads that port and signals
// us if we are waiting on that thread.
pthread_t p;
int err;
excport = mach_reply_port();
pthread_mutex_init(&mu, nil);
pthread_cond_init(&cond, nil);
pthread_create(&p, nil, excthread, nil);
pthread_create(&p, nil, waitthread, (void*)(uintptr)pid);
err = pthread_create(&p, nil, excthread, nil);
if (err != 0) {
fprint(2, "pthread_create failed: %s\n", strerror(err));
abort();
}
err = pthread_create(&p, nil, waitthread, (void*)(uintptr)pid);
if (err != 0) {
fprint(2, "pthread_create failed: %s\n", strerror(err));
abort();
}
first = 0;
}

View File

@ -113,11 +113,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr;
pthread_t p;
size_t size;
int err;
pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size;
pthread_create(&p, &attr, threadentry, ts);
err = pthread_create(&p, &attr, threadentry, ts);
if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(error));
abort();
}
}
static void*

View File

@ -83,11 +83,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr;
pthread_t p;
size_t size;
int err;
pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size;
pthread_create(&p, &attr, threadentry, ts);
err = pthread_create(&p, &attr, threadentry, ts);
if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
abort();
}
}
static void*

View File

@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr;
pthread_t p;
size_t size;
int err;
pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size;
pthread_create(&p, &attr, threadentry, ts);
err = pthread_create(&p, &attr, threadentry, ts);
if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
abort();
}
}
static void*

View File

@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr;
pthread_t p;
size_t size;
int err;
pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size;
pthread_create(&p, &attr, threadentry, ts);
err = pthread_create(&p, &attr, threadentry, ts);
if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
abort();
}
}
static void*

View File

@ -21,6 +21,7 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr;
pthread_t p;
size_t size;
int err;
// Not sure why the memset is necessary here,
// but without it, we get a bogus stack size
@ -30,7 +31,11 @@ libcgo_sys_thread_start(ThreadStart *ts)
size = 0;
pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size;
pthread_create(&p, &attr, threadentry, ts);
err = pthread_create(&p, &attr, threadentry, ts);
if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
abort();
}
}
static void*

View File

@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr;
pthread_t p;
size_t size;
int err;
pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size;
pthread_create(&p, &attr, threadentry, ts);
err = pthread_create(&p, &attr, threadentry, ts);
if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
abort();
}
}
static void*