Skip to content

Commit

Permalink
all: add 1.21_freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Oct 22, 2023
1 parent 7749b40 commit ba4ec62
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 0 deletions.
60 changes: 60 additions & 0 deletions 1.21_freebsd/runtime/cgo/gcc_freebsd_amd64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//--from
#include <sys/types.h>
#include <errno.h>
#include <sys/signalvar.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
#include "libcgo.h"
#include "libcgo_unix.h"
//--to
#include <sys/types.h>
#include <errno.h>
#include <pthread.h>
#include <string.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));
}
}
4 changes: 4 additions & 0 deletions 1.21_freebsd/runtime/cgo/gcc_freebsd_sigaction.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//--from
//go:build freebsd && amd64
//--to
//go:build ignore
4 changes: 4 additions & 0 deletions 1.21_freebsd/runtime/cgo/gcc_mmap.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//--from
//go:build (linux && (amd64 || arm64 || ppc64le)) || (freebsd && amd64)
//--to
//go:build (linux && (amd64 || arm64 || ppc64le))
26 changes: 26 additions & 0 deletions 1.21_freebsd/runtime/cgo/gcc_setenv.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//--from
void
x_cgo_setenv(char **arg)
{
_cgo_tsan_acquire();
setenv(arg[0], arg[1], 1);
_cgo_tsan_release();
}
//--to
void
x_cgo_setenv(char **arg)
{
}
//--from
void
x_cgo_unsetenv(char **arg)
{
_cgo_tsan_acquire();
unsetenv(arg[0]);
_cgo_tsan_release();
}
//--to
void
x_cgo_unsetenv(char **arg)
{
}
4 changes: 4 additions & 0 deletions 1.21_freebsd/runtime/cgo/mmap.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//--from
//go:build (linux && amd64) || (linux && arm64) || (freebsd && amd64)
//--to
//go:build (linux && amd64) || (linux && arm64)
4 changes: 4 additions & 0 deletions 1.21_freebsd/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 (linux && amd64) || (linux && arm64) || (linux && ppc64le)
15 changes: 15 additions & 0 deletions 1.21_freebsd/runtime/os_freebsd.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//--from
func sysSigaction(sig uint32, new, old *sigactiont) {
//--to
func sysSigaction(sig uint32, new, old *sigactiont) {
return
//--from
func getncpu() int32 {
//--to
func getncpu() int32 {
return 13 // TODO: Add a C file.
//--from
func getPageSize() uintptr {
//--to
func getPageSize() uintptr {
return 16384 // TODO: Enable to change by an argument.
5 changes: 5 additions & 0 deletions 1.21_freebsd/runtime/runtime1.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--append
// Expose the entry point for some special environments.

//go:cgo_export_static _rt0_amd64_freebsd_lib
//go:cgo_export_dynamic _rt0_amd64_freebsd_lib

0 comments on commit ba4ec62

Please sign in to comment.