Skip to content

Commit

Permalink
1.20_linux: remove signal.h usages for linux/amd64
Browse files Browse the repository at this point in the history
Closes #24
  • Loading branch information
hajimehoshi committed Aug 6, 2023
1 parent 614990c commit 833ca3e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
59 changes: 59 additions & 0 deletions 1.20_linux/runtime/cgo/gcc_linux_amd64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//--from
#include <pthread.h>
#include <errno.h>
#include <string.h> // strerror
#include <signal.h>
#include <stdlib.h>
#include "libcgo.h"
#include "libcgo_unix.h"
//--to
#include <pthread.h>
#include <errno.h>
#include <string.h> // strerror
#include <stdlib.h>
#include "libcgo.h"
#include "libcgo_unix.h"
//--from
void
_cgo_sys_thread_start(ThreadStart *ts)
{
pthread_attr_t attr;
sigset_t ign, oset;
pthread_t p;
size_t size;
int err;

sigfillset(&ign);
pthread_sigmask(SIG_SETMASK, &ign, &oset);

pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
ts->g->stackhi = size;
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);

pthread_sigmask(SIG_SETMASK, &oset, nil);

if (err != 0) {
fatalf("pthread_create failed: %s", strerror(err));
}
}
//--to
void
_cgo_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);
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
ts->g->stackhi = size;
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);

if (err != 0) {
fatalf("pthread_create failed: %s", strerror(err));
}
}
5 changes: 5 additions & 0 deletions 1.20_linux/runtime/cgo/gcc_sigaction.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--from
// +build linux,amd64 linux,arm64 linux,ppc64le
//--to
// TODO
// +build linux,arm64 linux,ppc64le
4 changes: 4 additions & 0 deletions 1.20_linux/runtime/cgo/sigaction.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//--from
//go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le)
//--to
//go:build (freebsd && amd64) || (linux && arm64) || (linux && ppc64le)

0 comments on commit 833ca3e

Please sign in to comment.