diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab47334..3bfd6ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - go: ['1.18.10', '1.19.12', '1.20.7', '1.21.0'] + go: ['1.19.12', '1.20.7', '1.21.0'] name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} defaults: @@ -56,7 +56,7 @@ jobs: GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v time" - name: Test (amd64) - if: ${{ !startsWith(matrix.go, '1.18.') && (runner.os == 'Linux' || !startsWith(matrix.go, '1.21.')) }} + if: ${{ runner.os == 'Linux' || !startsWith(matrix.go, '1.21.') }} run: | go run test.go -args="-test.run=^Test -test.v fmt" go run test.go -args="-test.run=^Test -test.v internal/abi" diff --git a/1.18_linux/internal/testenv/testenv.go.patch b/1.18_linux/internal/testenv/testenv.go.patch deleted file mode 100644 index 0342d0d..0000000 --- a/1.18_linux/internal/testenv/testenv.go.patch +++ /dev/null @@ -1,31 +0,0 @@ -//--from -func HasGoBuild() bool { - if os.Getenv("GO_GCFLAGS") != "" { - // It's too much work to require every caller of the go command - // to pass along "-gcflags="+os.Getenv("GO_GCFLAGS"). - // For now, if $GO_GCFLAGS is set, report that we simply can't - // run go build. - return false - } - switch runtime.GOOS { - case "android", "js", "ios": - return false - } - return true -} -//--to -func HasGoBuild() bool { - return false -} -//--from -func HasExec() bool { - switch runtime.GOOS { - case "js", "ios": - return false - } - return true -} -//--to -func HasExec() bool { - return false -} diff --git a/1.18_linux/internal/testenv/testenv_notunix.go.patch b/1.18_linux/internal/testenv/testenv_notunix.go.patch deleted file mode 100644 index 541a4dd..0000000 --- a/1.18_linux/internal/testenv/testenv_notunix.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build windows || plan9 || (js && wasm) -//--to -//go:build windows || plan9 || (js && wasm) || linux diff --git a/1.18_linux/internal/testenv/testenv_unix.go.patch b/1.18_linux/internal/testenv/testenv_unix.go.patch deleted file mode 100644 index e861970..0000000 --- a/1.18_linux/internal/testenv/testenv_unix.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -//--to -//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris diff --git a/1.18_linux/math/big/link_test.go.patch b/1.18_linux/math/big/link_test.go.patch deleted file mode 100644 index 28f7eed..0000000 --- a/1.18_linux/math/big/link_test.go.patch +++ /dev/null @@ -1,64 +0,0 @@ -//--from -import ( - "bytes" - "internal/testenv" - "os" - "os/exec" - "path/filepath" - "testing" -) -//--to -import ( - "testing" -) -//--from -func TestLinkerGC(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - t.Parallel() - tmp := t.TempDir() - goBin := testenv.GoToolPath(t) - goFile := filepath.Join(tmp, "x.go") - file := []byte(`package main -import _ "math/big" -func main() {} -`) - if err := os.WriteFile(goFile, file, 0644); err != nil { - t.Fatal(err) - } - cmd := exec.Command(goBin, "build", "-o", "x.exe", "x.go") - cmd.Dir = tmp - if out, err := cmd.CombinedOutput(); err != nil { - t.Fatalf("compile: %v, %s", err, out) - } - - cmd = exec.Command(goBin, "tool", "nm", "x.exe") - cmd.Dir = tmp - nm, err := cmd.CombinedOutput() - if err != nil { - t.Fatalf("nm: %v, %s", err, nm) - } - const want = "runtime.main" - if !bytes.Contains(nm, []byte(want)) { - // Test the test. - t.Errorf("expected symbol %q not found", want) - } - bad := []string{ - "math/big.(*Float)", - "math/big.(*Rat)", - "math/big.(*Int)", - } - for _, sym := range bad { - if bytes.Contains(nm, []byte(sym)) { - t.Errorf("unexpected symbol %q found", sym) - } - } - if t.Failed() { - t.Logf("Got: %s", nm) - } -} -//--to -func TestLinkerGC(t *testing.T) { - t.Skip("go tools are not supported in this environment") -} diff --git a/1.18_linux/runtime/callers_test.go.patch b/1.18_linux/runtime/callers_test.go.patch deleted file mode 100644 index 38a06aa..0000000 --- a/1.18_linux/runtime/callers_test.go.patch +++ /dev/null @@ -1,89 +0,0 @@ -//--from -func TestCallersNilPointerPanic(t *testing.T) { - // Make sure we don't have any extra frames on the stack (due to - // open-coded defer processing) - want := []string{"runtime.Callers", "runtime_test.TestCallersNilPointerPanic.func1", - "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic", - "runtime_test.TestCallersNilPointerPanic"} - - defer func() { - if r := recover(); r == nil { - t.Fatal("did not panic") - } - pcs := make([]uintptr, 20) - pcs = pcs[:runtime.Callers(0, pcs)] - testCallersEqual(t, pcs, want) - }() - var p *int - if *p == 3 { - t.Fatal("did not see nil pointer panic") - } -} -//--to -func TestCallersNilPointerPanic(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} -//--from -func TestCallersDeferNilFuncPanic(t *testing.T) { - // Make sure we don't have any extra frames on the stack. We cut off the check - // at runtime.sigpanic, because non-open-coded defers (which may be used in - // non-opt or race checker mode) include an extra 'deferreturn' frame (which is - // where the nil pointer deref happens). - state := 1 - want := []string{"runtime.Callers", "runtime_test.TestCallersDeferNilFuncPanic.func1", - "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic"} - - defer func() { - if r := recover(); r == nil { - t.Fatal("did not panic") - } - pcs := make([]uintptr, 20) - pcs = pcs[:runtime.Callers(0, pcs)] - testCallersEqual(t, pcs, want) - if state == 1 { - t.Fatal("nil defer func panicked at defer time rather than function exit time") - } - - }() - var f func() - defer f() - // Use the value of 'state' to make sure nil defer func f causes panic at - // function exit, rather than at the defer statement. - state = 2 -} - -//--to -func TestCallersDeferNilFuncPanic(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} -//--from -func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { - state := 1 - want := []string{"runtime.Callers", "runtime_test.TestCallersDeferNilFuncPanicWithLoop.func1", - "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic", "runtime.deferreturn", "runtime_test.TestCallersDeferNilFuncPanicWithLoop"} - - defer func() { - if r := recover(); r == nil { - t.Fatal("did not panic") - } - pcs := make([]uintptr, 20) - pcs = pcs[:runtime.Callers(0, pcs)] - testCallersEqual(t, pcs, want) - if state == 1 { - t.Fatal("nil defer func panicked at defer time rather than function exit time") - } - - }() - - for i := 0; i < 1; i++ { - var f func() - defer f() - } - // Use the value of 'state' to make sure nil defer func f causes panic at - // function exit, rather than at the defer statement. - state = 2 -} -//--to -func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} diff --git a/1.18_linux/runtime/cgo/cgo.go.patch b/1.18_linux/runtime/cgo/cgo.go.patch deleted file mode 100644 index c074e66..0000000 --- a/1.18_linux/runtime/cgo/cgo.go.patch +++ /dev/null @@ -1,9 +0,0 @@ -//--from -*/ -import "C" -//--to -#cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all -#cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup -#cgo nintendosdk CFLAGS: -D_USE_PTHREAD_AFFINITY_NP -*/ -import "C" diff --git a/1.18_linux/runtime/cgo/gcc_libinit.c.patch b/1.18_linux/runtime/cgo/gcc_libinit.c.patch deleted file mode 100644 index e5db3c9..0000000 --- a/1.18_linux/runtime/cgo/gcc_libinit.c.patch +++ /dev/null @@ -1,31 +0,0 @@ -//--from -#include -//--to -#ifndef _GNU_SOURCE - #define _GNU_SOURCE -#endif -#include -//--from - err = pthread_create(thread, attr, pfn, arg); - if (err == 0) { - pthread_detach(*thread); - return 0; - } -//--to - err = pthread_create(thread, attr, pfn, arg); - if (err == 0) { - pthread_detach(*thread); -#ifdef _USE_PTHREAD_AFFINITY_NP - extern int32_t hitsumabushi_getproccount(); - int32_t numcpu = hitsumabushi_getproccount(); - cpu_set_t *cpu_set = CPU_ALLOC(numcpu); - size_t size = CPU_ALLOC_SIZE(numcpu); - CPU_ZERO_S(size, cpu_set); - for (int i = 0; i < numcpu; i++) { - CPU_SET_S(i, size, cpu_set); - } - pthread_setaffinity_np(*thread, size, cpu_set); - CPU_FREE(cpu_set); -#endif - return 0; - } diff --git a/1.18_linux/runtime/cgo/gcc_linux_arm64.c.patch b/1.18_linux/runtime/cgo/gcc_linux_arm64.c.patch deleted file mode 100644 index 2759c9e..0000000 --- a/1.18_linux/runtime/cgo/gcc_linux_arm64.c.patch +++ /dev/null @@ -1,527 +0,0 @@ -//--from -#include -#include -#include -#include -#include -#include "libcgo.h" -#include "libcgo_unix.h" -//--to -#include -#include -#include -#include -#include -#include "libcgo.h" -#include "libcgo_unix.h" - -#include -#include // for usleep - -// This will be replaced at overlay.go later. -#define clock_gettime clock_gettime -// This will be replaced at overlay.go later. -#undef user_futex -//--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); - - // Not sure why the memset is necessary here, - // but without it, we get a bogus stack size - // out of pthread_attr_getstacksize. C'est la Linux. - memset(&attr, 0, sizeof attr); - pthread_attr_init(&attr); - size = 0; - 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; - sigset_t ign, oset; - pthread_t p; - size_t size; - int err; - - sigfillset(&ign); - pthread_sigmask(SIG_SETMASK, &ign, &oset); - - // Not sure why the memset is necessary here, - // but without it, we get a bogus stack size - // out of pthread_attr_getstacksize. C'est la Linux. - memset(&attr, 0, sizeof attr); - pthread_attr_init(&attr); - size = 0; - pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments - 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)); - } -} -//--from -void -x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) -{ - pthread_attr_t *attr; - size_t size; - - /* The memory sanitizer distributed with versions of clang - before 3.8 has a bug: if you call mmap before malloc, mmap - may return an address that is later overwritten by the msan - library. Avoid this problem by forcing a call to malloc - here, before we ever call malloc. - - This is only required for the memory sanitizer, so it's - unfortunate that we always run it. It should be possible - to remove this when we no longer care about versions of - clang before 3.8. The test for this is - misc/cgo/testsanitizers. - - GCC works hard to eliminate a seemingly unnecessary call to - malloc, so we actually use the memory we allocate. */ - - setg_gcc = setg; - attr = (pthread_attr_t*)malloc(sizeof *attr); - if (attr == NULL) { - fatalf("malloc failed: %s", strerror(errno)); - } - pthread_attr_init(attr); - pthread_attr_getstacksize(attr, &size); - g->stacklo = (uintptr)&size - size + 4096; - pthread_attr_destroy(attr); - free(attr); - - if (x_cgo_inittls) { - x_cgo_inittls(tlsg, tlsbase); - } -} -//--to -void -x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) -{ - pthread_attr_t *attr; - size_t size; - - /* The memory sanitizer distributed with versions of clang - before 3.8 has a bug: if you call mmap before malloc, mmap - may return an address that is later overwritten by the msan - library. Avoid this problem by forcing a call to malloc - here, before we ever call malloc. - - This is only required for the memory sanitizer, so it's - unfortunate that we always run it. It should be possible - to remove this when we no longer care about versions of - clang before 3.8. The test for this is - misc/cgo/testsanitizers. - - GCC works hard to eliminate a seemingly unnecessary call to - malloc, so we actually use the memory we allocate. */ - - setg_gcc = setg; - attr = (pthread_attr_t*)malloc(sizeof *attr); - if (attr == NULL) { - fatalf("malloc failed: %s", strerror(errno)); - } - pthread_attr_init(attr); - pthread_attr_setstacksize(attr, 16 * 4096); // Hack for some special environments - pthread_attr_getstacksize(attr, &size); - g->stacklo = (uintptr)&size - size + 4096; - pthread_attr_destroy(attr); - free(attr); - - if (x_cgo_inittls) { - x_cgo_inittls(tlsg, tlsbase); - } -} -//--append -// Define C functions and system calls for Cgo. - -typedef unsigned int gid_t; - -void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { - abort(); - return NULL; -} - -int munmap(void *addr, size_t length) { - abort(); - return 0; -} - -int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset) { - // Do nothing. - return 0; -} - -int setegid(gid_t gid) { - // Do nothing. - return 0; -} - -int seteuid(uid_t gid) { - // Do nothing. - return 0; -} - -int setgid(gid_t gid) { - // Do nothing. - return 0; -} - -int setgroups(size_t size, const gid_t *list) { - // Do nothing. - return 0; -} - -int setregid(gid_t rgid, gid_t egid) { - // Do nothing. - return 0; -} - -int setreuid(uid_t ruid, uid_t euid) { - // Do nothing. - return 0; -} - -int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { - // Do nothing. - return 0; -} - -int setresuid(uid_t ruid, uid_t euid, uid_t suid) { - // Do nothing. - return 0; -} - -int setuid(uid_t gid) { - // Do nothing. - return 0; -} - -int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { - // Do nothing. - return 0; -} - -int sigaddset(sigset_t *set, int signum) { - // Do nothing. - return 0; -} - -int sigemptyset(sigset_t *set) { - // Do nothing. - return 0; -} - -int sigfillset(sigset_t *set) { - // Do nothing. - return 0; -} - -int sigismember(const sigset_t *set, int signum) { - // Do nothing. - return 0; -} - -static const int kFDOffset = 100; - -typedef struct { - const void* content; - size_t content_size; - size_t current; - int32_t fd; -} pseudo_file; - -// TODO: Do we need to protect this by mutex? -static pseudo_file pseudo_files[100]; - -static pthread_mutex_t* pseudo_file_mutex() { - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - return &mutex; -} - -static int32_t open_pseudo_file(const void* content, size_t content_size) { - pthread_mutex_lock(pseudo_file_mutex()); - - int index = 0; - int found = 0; - for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { - if (pseudo_files[i].fd == 0) { - index = i; - found = 1; - break; - } - } - if (!found) { - // Too many pseudo files are opened. - pthread_mutex_unlock(pseudo_file_mutex()); - return -1; - } - int32_t fd = index + kFDOffset; - pseudo_files[index].content = content; - pseudo_files[index].content_size = content_size; - pseudo_files[index].current = 0; - pseudo_files[index].fd = fd; - - pthread_mutex_unlock(pseudo_file_mutex()); - return fd; -} - -static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { - pthread_mutex_lock(pseudo_file_mutex()); - - int32_t index = fd - kFDOffset; - pseudo_file *file = &pseudo_files[index]; - size_t rest = file->content_size - file->current; - if (rest < n) { - n = rest; - } - memcpy(p, file->content + file->current, n); - pseudo_files[index].current += n; - - pthread_mutex_unlock(pseudo_file_mutex()); - return n; -} - -static void close_pseudo_file(int32_t fd) { - pthread_mutex_lock(pseudo_file_mutex()); - - int32_t index = fd - kFDOffset; - pseudo_files[index].content = NULL; - pseudo_files[index].content_size = 0; - pseudo_files[index].current = 0; - pseudo_files[index].fd = 0; - - pthread_mutex_unlock(pseudo_file_mutex()); -} - -#ifndef user_futex -static const int kPseudoFutexWait = 0; -static const int kPseudoFutexWake = 1; - -static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; - - struct timespec abstime; - if (reltime) { - // We are not sure CLOCK_REALTIME is correct or not here. - // However, this time limit is actually not used as the condition variable is shared by - // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. - clock_gettime(CLOCK_REALTIME, &abstime); - abstime.tv_sec += reltime->tv_sec; - abstime.tv_nsec += reltime->tv_nsec; - if (1000000000 <= abstime.tv_nsec) { - abstime.tv_sec += 1; - abstime.tv_nsec -= 1000000000; - } - } - - int ret = pthread_mutex_lock(&mutex); - if (ret) { - fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); - abort(); - } - - switch (mode) { - case kPseudoFutexWait: - if (reltime) { - uint32_t v = 0; - __atomic_load(uaddr, &v, __ATOMIC_RELAXED); - if (v == val) { - int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); - if (ret && ret != ETIMEDOUT) { - fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); - abort(); - } - } - } else { - uint32_t v = 0; - __atomic_load(uaddr, &v, __ATOMIC_RELAXED); - if (v == val) { - int ret = pthread_cond_wait(&cond, &mutex); - if (ret) { - fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); - abort(); - } - } - } - break; - case kPseudoFutexWake: - if (val != 1) { - fprintf(stderr, "val for waking must be 1 but %d\n", val); - abort(); - } - // TODO: broadcasting is not efficient. Use a mutex for each uaddr. - int ret = pthread_cond_broadcast(&cond); - if (ret) { - fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); - abort(); - } - break; - } - - ret = pthread_mutex_unlock(&mutex); - if (ret) { - fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); - abort(); - } -} -#endif - -int32_t hitsumabushi_closefd(int32_t fd) { - if (fd >= kFDOffset) { - close_pseudo_file(fd); - return 0; - } - fprintf(stderr, "syscall close(%d) is not implemented\n", fd); - return 0; -} - -int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, - const struct timespec *timeout, - uint32_t *uaddr2, uint32_t val3) { -#ifdef user_futex - return user_futex(uaddr, futex_op, val, timeout, uaddr2, val3); -#else - enum { - kFutexWaitPrivate = 128, - kFutexWakePrivate = 129, - }; - - switch (futex_op) { - case kFutexWaitPrivate: - pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); - break; - case kFutexWakePrivate: - pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); - break; - } - - // This function should return the number of awaken threads, but now it is impossible. - // Just return 0. - return 0; -#endif -} - -uint32_t hitsumabushi_gettid() { - uint64_t tid64 = (uint64_t)(pthread_self()); - uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); - return tid; -} - -uintptr_t hitsumabushi_calloc(size_t num, size_t size) { - void *ptr = calloc(num, size); - return (uintptr_t)ptr; -} - -int64_t hitsumabushi_nanotime1() { - struct timespec tp; - clock_gettime(CLOCK_MONOTONIC, &tp); - return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; -} - -int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { - if (strcmp(name, "/proc/self/auxv") == 0) { - static const char auxv[] = - "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) - "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page - "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes - "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes - return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); - } - if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { - static const char hpage_pmd_size[] = - "\x30\x5c"; // '0', '\n' - return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); - } - fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); - const static int kENOENT = 0x2; - return kENOENT; -} - -int32_t hitsumabushi_osyield() { - return sched_yield(); -} - -extern int32_t hitsumabushi_getproccount(); - -int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { - int32_t numcpu = hitsumabushi_getproccount(); - for (int32_t i = 0; i < numcpu; i += 8) - ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); - // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html - // > On success, the raw sched_getaffinity() system call returns the - // > number of bytes placed copied into the mask buffer; - return (numcpu + 7) / 8; -} - -int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { - if (fd >= kFDOffset) { - return read_pseudo_file(fd, p, n); - } - fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); - const static int kEBADF = 0x9; - return kEBADF; -} - -void hitsumabushi_usleep(useconds_t usec) { - usleep(usec); -} - -void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { - struct timespec tp; - clock_gettime(CLOCK_REALTIME, &tp); - *sec = tp.tv_sec; - *nsec = tp.tv_nsec; -} - -int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { - static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; - int32_t ret = 0; - pthread_mutex_lock(&m); - switch (fd) { - case 1: - ret = fwrite(p, 1, n, stdout); - fflush(stdout); - break; - case 2: - ret = fwrite(p, 1, n, stderr); - fflush(stderr); - break; - default: - fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); - break; - } - pthread_mutex_unlock(&m); - return ret; -} - -void hitsumabushi_exit(int32_t code) { - exit(code); -} diff --git a/1.18_linux/runtime/cgo/hitsumabushi_cpu_linux.c b/1.18_linux/runtime/cgo/hitsumabushi_cpu_linux.c deleted file mode 100644 index c30445d..0000000 --- a/1.18_linux/runtime/cgo/hitsumabushi_cpu_linux.c +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors - -#include - -int32_t hitsumabushi_getproccount() { - return 1; -} diff --git a/1.18_linux/runtime/crash_test.go.patch b/1.18_linux/runtime/crash_test.go.patch deleted file mode 100644 index 719e676..0000000 --- a/1.18_linux/runtime/crash_test.go.patch +++ /dev/null @@ -1,132 +0,0 @@ -//--from -import ( - "bytes" - "errors" - "flag" - "fmt" - "internal/testenv" - "os" - "os/exec" - "path/filepath" - "regexp" - "runtime" - "strings" - "sync" - "testing" -) -//--to -import ( - "bytes" - "flag" - "internal/testenv" - "os" - "os/exec" - "regexp" - "runtime" - "strings" - "sync" - "testing" -) -//--from -func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { - if *flagQuick { - t.Skip("-quick") - } - testenv.MustHaveGoBuild(t) - - testprog.Lock() - if testprog.dir == "" { - dir, err := os.MkdirTemp("", "go-build") - if err != nil { - t.Fatalf("failed to create temp directory: %v", err) - } - testprog.dir = dir - toRemove = append(toRemove, dir) - } - - if testprog.target == nil { - testprog.target = make(map[string]*buildexe) - } - name := binary - if len(flags) > 0 { - name += "_" + strings.Join(flags, "_") - } - target, ok := testprog.target[name] - if !ok { - target = &buildexe{} - testprog.target[name] = target - } - - dir := testprog.dir - - // Unlock testprog while actually building, so that other - // tests can look up executables that were already built. - testprog.Unlock() - - target.once.Do(func() { - // Only do two "go build"'s at a time, - // to keep load from getting too high. - serializeBuild <- true - defer func() { <-serializeBuild }() - - // Don't get confused if testenv.GoToolPath calls t.Skip. - target.err = errors.New("building test called t.Skip") - - exe := filepath.Join(dir, name+".exe") - - t.Logf("running go build -o %s %s", exe, strings.Join(flags, " ")) - cmd := exec.Command(testenv.GoToolPath(t), append([]string{"build", "-o", exe}, flags...)...) - cmd.Dir = "testdata/" + binary - out, err := testenv.CleanCmdEnv(cmd).CombinedOutput() - if err != nil { - target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out) - } else { - target.exe = exe - target.err = nil - } - }) - - return target.exe, target.err -} -//--to -func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { - t.Skip("buildTestProg is not supported in this environment") - return "", nil -} -//--from -func TestPanicInlined(t *testing.T) { - defer func() { - r := recover() - if r == nil { - t.Fatalf("recover failed") - } - buf := make([]byte, 2048) - n := runtime.Stack(buf, false) - buf = buf[:n] - if !bytes.Contains(buf, []byte("(*point).negate(")) { - t.Fatalf("expecting stack trace to contain call to (*point).negate()") - } - }() - - pt := new(point) - pt.negate() -} -//--to -func TestPanicInlined(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") - defer func() { - r := recover() - if r == nil { - t.Fatalf("recover failed") - } - buf := make([]byte, 2048) - n := runtime.Stack(buf, false) - buf = buf[:n] - if !bytes.Contains(buf, []byte("(*point).negate(")) { - t.Fatalf("expecting stack trace to contain call to (*point).negate()") - } - }() - - pt := new(point) - pt.negate() -} diff --git a/1.18_linux/runtime/crash_unix_test.go.patch b/1.18_linux/runtime/crash_unix_test.go.patch deleted file mode 100644 index e861970..0000000 --- a/1.18_linux/runtime/crash_unix_test.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -//--to -//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris diff --git a/1.18_linux/runtime/debug/heapdump_test.go.patch b/1.18_linux/runtime/debug/heapdump_test.go.patch deleted file mode 100644 index a4f7d9c..0000000 --- a/1.18_linux/runtime/debug/heapdump_test.go.patch +++ /dev/null @@ -1,68 +0,0 @@ -//--from -import ( - "os" - "runtime" - . "runtime/debug" - "testing" -) -//--to -import ( - "testing" -) -//--from -func TestWriteHeapDumpNonempty(t *testing.T) { - if runtime.GOOS == "js" { - t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) - } - f, err := os.CreateTemp("", "heapdumptest") - if err != nil { - t.Fatalf("TempFile failed: %v", err) - } - defer os.Remove(f.Name()) - defer f.Close() - WriteHeapDump(f.Fd()) - fi, err := f.Stat() - if err != nil { - t.Fatalf("Stat failed: %v", err) - } - const minSize = 1 - if size := fi.Size(); size < minSize { - t.Fatalf("Heap dump size %d bytes, expected at least %d bytes", size, minSize) - } -} -//--to -func TestWriteHeapDumpNonempty(t *testing.T) { - t.Skip("file is not supported in this environment") -} -//--from -func TestWriteHeapDumpFinalizers(t *testing.T) { - if runtime.GOOS == "js" { - t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) - } - f, err := os.CreateTemp("", "heapdumptest") - if err != nil { - t.Fatalf("TempFile failed: %v", err) - } - defer os.Remove(f.Name()) - defer f.Close() - - // bug 9172: WriteHeapDump couldn't handle more than one finalizer - println("allocating objects") - x := &Obj{} - runtime.SetFinalizer(x, objfin) - y := &Obj{} - runtime.SetFinalizer(y, objfin) - - // Trigger collection of x and y, queueing of their finalizers. - println("starting gc") - runtime.GC() - - // Make sure WriteHeapDump doesn't fail with multiple queued finalizers. - println("starting dump") - WriteHeapDump(f.Fd()) - println("done dump") -} -//--to -func TestWriteHeapDumpFinalizers(t *testing.T) { - t.Skip("file is not supported in this environment") -} diff --git a/1.18_linux/runtime/debug/panic_test.go.patch b/1.18_linux/runtime/debug/panic_test.go.patch deleted file mode 100644 index 19d979e..0000000 --- a/1.18_linux/runtime/debug/panic_test.go.patch +++ /dev/null @@ -1,55 +0,0 @@ -//--from -import ( - "runtime" - "runtime/debug" - "syscall" - "testing" - "unsafe" -) -//--to -import ( - "testing" -) -//--from -func TestPanicOnFault(t *testing.T) { - if runtime.GOARCH == "s390x" { - t.Skip("s390x fault addresses are missing the low order bits") - } - if runtime.GOOS == "ios" { - t.Skip("iOS doesn't provide fault addresses") - } - if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm" { - t.Skip("netbsd-arm doesn't provide fault address (golang.org/issue/45026)") - } - m, err := syscall.Mmap(-1, 0, 0x1000, syscall.PROT_READ /* Note: no PROT_WRITE */, syscall.MAP_SHARED|syscall.MAP_ANON) - if err != nil { - t.Fatalf("can't map anonymous memory: %s", err) - } - defer syscall.Munmap(m) - old := debug.SetPanicOnFault(true) - defer debug.SetPanicOnFault(old) - const lowBits = 0x3e7 - defer func() { - r := recover() - if r == nil { - t.Fatalf("write did not fault") - } - type addressable interface { - Addr() uintptr - } - a, ok := r.(addressable) - if !ok { - t.Fatalf("fault does not contain address") - } - want := uintptr(unsafe.Pointer(&m[lowBits])) - got := a.Addr() - if got != want { - t.Fatalf("fault address %x, want %x", got, want) - } - }() - m[lowBits] = 1 // will fault -} -//--to -func TestPanicOnFault(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} diff --git a/1.18_linux/runtime/debug_test.go.patch b/1.18_linux/runtime/debug_test.go.patch deleted file mode 100644 index a6a8522..0000000 --- a/1.18_linux/runtime/debug_test.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build (amd64 || arm64) && linux && !race -//--to -//go:build ignore diff --git a/1.18_linux/runtime/export_linux_test.go.patch b/1.18_linux/runtime/export_linux_test.go.patch deleted file mode 100644 index 8cb1f4c..0000000 --- a/1.18_linux/runtime/export_linux_test.go.patch +++ /dev/null @@ -1,8 +0,0 @@ -//--from -import "unsafe" -//--to -//--from -func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 { - return epollctl(epfd, op, fd, (*epollevent)(ev)) -} -//--to diff --git a/1.18_linux/runtime/export_unix_test.go.patch b/1.18_linux/runtime/export_unix_test.go.patch deleted file mode 100644 index e861970..0000000 --- a/1.18_linux/runtime/export_unix_test.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -//--to -//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris diff --git a/1.18_linux/runtime/mem_linux.go b/1.18_linux/runtime/mem_linux.go deleted file mode 100644 index 523a09f..0000000 --- a/1.18_linux/runtime/mem_linux.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This implementation is the most fundamental and minimal allocations like Wasm. -// Malloced memory regions are never freed. - -package runtime - -import ( - "internal/abi" - "unsafe" -) - -// Don't split the stack as this function may be invoked without a valid G, -// which prevents us from allocating more stack. -//go:nosplit -func sysAlloc(n uintptr, sysStat *sysMemStat) unsafe.Pointer { - p := sysReserve(nil, n) - sysMap(p, n, sysStat) - return p -} - -func sysUnused(v unsafe.Pointer, n uintptr) { -} - -func sysUsed(v unsafe.Pointer, n uintptr) { -} - -func sysHugePage(v unsafe.Pointer, n uintptr) { -} - -// Don't split the stack as this function may be invoked without a valid G, -// which prevents us from allocating more stack. -//go:nosplit -func sysFree(v unsafe.Pointer, n uintptr, sysStat *sysMemStat) { - sysStat.add(-int64(n)) -} - -func sysFault(v unsafe.Pointer, n uintptr) { -} - -func sysReserve(v unsafe.Pointer, n uintptr) unsafe.Pointer { - if v != nil { - return nil - } - ptr := calloc(n, 1) - return unsafe.Pointer(ptr) -} - -//go:nosplit -//go:cgo_unsafe_args -func calloc(n uintptr, size uintptr) (ret uintptr) { - libcCall(unsafe.Pointer(abi.FuncPCABI0(calloc_trampoline)), unsafe.Pointer(&n)) - return -} -func calloc_trampoline(n uintptr, size uintptr) uintptr - -func sysMap(v unsafe.Pointer, n uintptr, sysStat *sysMemStat) { - sysStat.add(int64(n)) -} diff --git a/1.18_linux/runtime/nbpipe_pipe2.go.patch b/1.18_linux/runtime/nbpipe_pipe2.go.patch deleted file mode 100644 index 5549d59..0000000 --- a/1.18_linux/runtime/nbpipe_pipe2.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris -//--to -//go:build dragonfly || freebsd || netbsd || openbsd || solaris diff --git a/1.18_linux/runtime/nbpipe_test.go.patch b/1.18_linux/runtime/nbpipe_test.go.patch deleted file mode 100644 index e861970..0000000 --- a/1.18_linux/runtime/nbpipe_test.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -//--to -//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris diff --git a/1.18_linux/runtime/netpoll_epoll.go.patch b/1.18_linux/runtime/netpoll_epoll.go.patch deleted file mode 100644 index b294f41..0000000 --- a/1.18_linux/runtime/netpoll_epoll.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build linux -//--to -//go:build ignore diff --git a/1.18_linux/runtime/netpoll_fake.go.patch b/1.18_linux/runtime/netpoll_fake.go.patch deleted file mode 100644 index 1e22240..0000000 --- a/1.18_linux/runtime/netpoll_fake.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build js && wasm -//--to -//go:build linux diff --git a/1.18_linux/runtime/norace_linux_test.go.patch b/1.18_linux/runtime/norace_linux_test.go.patch deleted file mode 100644 index f6d2509..0000000 --- a/1.18_linux/runtime/norace_linux_test.go.patch +++ /dev/null @@ -1,33 +0,0 @@ -//--from -import ( - "internal/abi" - "runtime" - "testing" - "time" - "unsafe" -) -//--to -import ( - "testing" -) -//--from -func TestNewOSProc0(t *testing.T) { - runtime.NewOSProc0(0x800000, unsafe.Pointer(abi.FuncPCABIInternal(newOSProcCreated))) - check := time.NewTicker(100 * time.Millisecond) - defer check.Stop() - end := time.After(5 * time.Second) - for { - select { - case <-check.C: - if newOSProcDone { - return - } - case <-end: - t.Fatalf("couldn't create new OS process") - } - } -} -//--to -func TestNewOSProc0(t *testing.T) { - t.Skip("newosproc0 is not supported in this environment") -} diff --git a/1.18_linux/runtime/os_linux.go.patch b/1.18_linux/runtime/os_linux.go.patch deleted file mode 100644 index 27d4f19..0000000 --- a/1.18_linux/runtime/os_linux.go.patch +++ /dev/null @@ -1,272 +0,0 @@ -//--from -import ( - "internal/abi" - "internal/goarch" - "runtime/internal/atomic" - "runtime/internal/syscall" - "unsafe" -) -//--to -import ( - "internal/abi" - "runtime/internal/atomic" - "runtime/internal/syscall" - "unsafe" -) -//--from -//go:noescape -func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 -//--to -//go:nosplit -//go:cgo_unsafe_args -func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { - ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) - return ret -} -func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 -//--from -func sysargs(argc int32, argv **byte) { - n := argc + 1 - - // skip over argv, envp to get to auxv - for argv_index(argv, n) != nil { - n++ - } - - // skip NULL separator - n++ - - // now argv+n is auxv - auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) - if sysauxv(auxv[:]) != 0 { - return - } - // In some situations we don't get a loader-provided - // auxv, such as when loaded as a library on Android. - // Fall back to /proc/self/auxv. - fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) - if fd < 0 { - // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to - // try using mincore to detect the physical page size. - // mincore should return EINVAL when address is not a multiple of system page size. - const size = 256 << 10 // size of memory region to allocate - p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) - if err != 0 { - return - } - var n uintptr - for n = 4 << 10; n < size; n <<= 1 { - err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) - if err == 0 { - physPageSize = n - break - } - } - if physPageSize == 0 { - physPageSize = size - } - munmap(p, size) - return - } - var buf [128]uintptr - n = read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) - closefd(fd) - if n < 0 { - return - } - // Make sure buf is terminated, even if we didn't read - // the whole file. - buf[len(buf)-2] = _AT_NULL - sysauxv(buf[:]) -} -//--to -func sysargs(argc int32, argv **byte) { - // argc/argv is not reliable on some machines. - // Skip analysing them. - - // In some situations we don't get a loader-provided - // auxv, such as when loaded as a library on Android. - // Fall back to /proc/self/auxv. - fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) - if fd < 0 { - // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to - // try using mincore to detect the physical page size. - // mincore should return EINVAL when address is not a multiple of system page size. - const size = 256 << 10 // size of memory region to allocate - p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) - if err != 0 { - return - } - var n uintptr - for n = 4 << 10; n < size; n <<= 1 { - err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) - if err == 0 { - physPageSize = n - break - } - } - if physPageSize == 0 { - physPageSize = size - } - munmap(p, size) - return - } - var buf [128]uintptr - n := read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) - closefd(fd) - if n < 0 { - return - } - // Make sure buf is terminated, even if we didn't read - // the whole file. - buf[len(buf)-2] = _AT_NULL - sysauxv(buf[:]) -} -//--from -func getRandomData(r []byte) { - if startupRandomData != nil { - n := copy(r, startupRandomData) - extendRandom(r, n) - return - } - fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) - n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) - closefd(fd) - extendRandom(r, int(n)) -} -//--to -// Use getRandomData in os_plan9.go. - -//go:nosplit -func getRandomData(r []byte) { - // inspired by wyrand see hash32.go for detail - t := nanotime() - v := getg().m.procid ^ uint64(t) - - for len(r) > 0 { - v ^= 0xa0761d6478bd642f - v *= 0xe7037ed1a0b428db - size := 8 - if len(r) < 8 { - size = len(r) - } - for i := 0; i < size; i++ { - r[i] = byte(v >> (8 * i)) - } - r = r[size:] - v = v>>32 | v<<32 - } -} -//--from -func gettid() uint32 -//--to -//go:nosplit -//go:cgo_unsafe_args -func gettid() (tid uint32) { - libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) - return -} -func gettid_trampoline() uint32 -//--from -//go:noescape -func sigaltstack(new, old *stackt) -//--to -func sigaltstack(new, old *stackt) { - // Do nothing. -} -//--from -func sigprocmask(how int32, new, old *sigset) { - rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) -} -//--to -func sigprocmask(how int32, new, old *sigset) { - // Do nothing. - // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) -} -//--from -func raise(sig uint32) -//--to -func raise(sig uint32) { - // Do nothing -} -//--from -func raiseproc(sig uint32) -//--to -func raiseproc(sig uint32) { - // Do nothing -} -//--from -//go:noescape -func sched_getaffinity(pid, len uintptr, buf *byte) int32 -//--to -//go:nosplit -//go:cgo_unsafe_args -func sched_getaffinity(pid, len uintptr, buf *byte) int32 { - return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) -} -func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 -//--from -func osyield() -//--to -//go:nosplit -//go:cgo_unsafe_args -func osyield() { - libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) -} -func osyield_trampoline() -//--from -func signalM(mp *m, sig int) { - tgkill(getpid(), int(mp.procid), sig) -} -//--to -func signalM(mp *m, sig int) { - // Do nothiing. -} -//--append -//go:linkname hitsumabushi_calloc hitsumabushi_calloc -//go:cgo_import_static hitsumabushi_calloc -var hitsumabushi_calloc byte - -//go:linkname hitsumabushi_closefd hitsumabushi_closefd -//go:cgo_import_static hitsumabushi_closefd -var hitsumabushi_closefd byte - -//go:linkname hitsumabushi_exit hitsumabushi_exit -//go:cgo_import_static hitsumabushi_exit -var hitsumabushi_exit byte - -//go:linkname hitsumabushi_gettid hitsumabushi_gettid -//go:cgo_import_static hitsumabushi_gettid -var hitsumabushi_gettid byte - -//go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 -//go:cgo_import_static hitsumabushi_nanotime1 -var hitsumabushi_nanotime1 byte - -//go:linkname hitsumabushi_open hitsumabushi_open -//go:cgo_import_static hitsumabushi_open -var hitsumabushi_open byte - -//go:linkname hitsumabushi_osyield hitsumabushi_osyield -//go:cgo_import_static hitsumabushi_osyield -var hitsumabushi_osyield byte - -//go:linkname hitsumabushi_read hitsumabushi_read -//go:cgo_import_static hitsumabushi_read -var hitsumabushi_read byte - -//go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity -//go:cgo_import_static hitsumabushi_sched_getaffinity -var hitsumabushi_sched_getaffinity byte - -//go:linkname hitsumabushi_usleep hitsumabushi_usleep -//go:cgo_import_static hitsumabushi_usleep -var hitsumabushi_usleep byte - -//go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 -//go:cgo_import_static hitsumabushi_walltime1 -var hitsumabushi_walltime1 byte - -//go:linkname hitsumabushi_write1 hitsumabushi_write1 -//go:cgo_import_static hitsumabushi_write1 -var hitsumabushi_write1 byte diff --git a/1.18_linux/runtime/proc_test.go.patch b/1.18_linux/runtime/proc_test.go.patch deleted file mode 100644 index 478b6b3..0000000 --- a/1.18_linux/runtime/proc_test.go.patch +++ /dev/null @@ -1,14 +0,0 @@ -//--from -func TestGoroutineParallelism2(t *testing.T) { - //testGoroutineParallelism2(t, false, false) - testGoroutineParallelism2(t, true, false) - testGoroutineParallelism2(t, false, true) - testGoroutineParallelism2(t, true, true) -} -//--to -func TestGoroutineParallelism2(t *testing.T) { - //testGoroutineParallelism2(t, false, false) - testGoroutineParallelism2(t, true, false) - //testGoroutineParallelism2(t, false, true) - //testGoroutineParallelism2(t, true, true) -} diff --git a/1.18_linux/runtime/runtime1.go.patch b/1.18_linux/runtime/runtime1.go.patch deleted file mode 100644 index 1f92b66..0000000 --- a/1.18_linux/runtime/runtime1.go.patch +++ /dev/null @@ -1,19 +0,0 @@ -//--from -func argv_index(argv **byte, i int32) *byte { - return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) -} -//--to -func argv_index(argv **byte, i int32) *byte { - return nil -} -//--from -func args(c int32, v **byte) { - argc = c - argv = v - sysargs(c, v) -} -//--to -func args(c int32, v **byte) { - // In the original code, physPageSize is determined at sysargs. - // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. -} diff --git a/1.18_linux/runtime/runtime_linux_test.go.patch b/1.18_linux/runtime/runtime_linux_test.go.patch deleted file mode 100644 index 0813196..0000000 --- a/1.18_linux/runtime/runtime_linux_test.go.patch +++ /dev/null @@ -1,27 +0,0 @@ -//--from -func TestMincoreErrorSign(t *testing.T) { - var dst byte - v := Mincore(Add(unsafe.Pointer(new(int32)), 1), 1, &dst) - - const EINVAL = 0x16 - if v != -EINVAL { - t.Errorf("mincore = %v, want %v", v, -EINVAL) - } -} -//--to -func TestMincoreErrorSign(t *testing.T) { - t.Skip("mincore is not supported in this environment") -} -//--from -func TestEpollctlErrorSign(t *testing.T) { - v := Epollctl(-1, 1, -1, unsafe.Pointer(&EpollEvent{})) - - const EBADF = 0x09 - if v != -EBADF { - t.Errorf("epollctl = %v, want %v", v, -EBADF) - } -} -//--to -func TestEpollctlErrorSign(t *testing.T) { - t.Skip("Epollctl is not supported in this environment") -} diff --git a/1.18_linux/runtime/runtime_mmap_test.go.patch b/1.18_linux/runtime/runtime_mmap_test.go.patch deleted file mode 100644 index e861970..0000000 --- a/1.18_linux/runtime/runtime_mmap_test.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -//--to -//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris diff --git a/1.18_linux/runtime/runtime_test.go.patch b/1.18_linux/runtime/runtime_test.go.patch deleted file mode 100644 index 06ef58a..0000000 --- a/1.18_linux/runtime/runtime_test.go.patch +++ /dev/null @@ -1,23 +0,0 @@ -//--from -func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { - if GOOS == "js" { - t.Skip("js does not support catching faults") - } - - defer func() { - if err := recover(); err != nil { - *nfault++ - } - }() - - // The read should fault, except that sometimes we hit - // addresses that have had C or kernel pages mapped there - // readable by user code. So just log the content. - // If no addresses fault, we'll fail the test. - v := *(*byte)(unsafe.Pointer(addr)) - t.Logf("addr %#x: %#x\n", addr, v) -} -//--to -func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { - t.Skip("catching faults is not supported in this environment") -} diff --git a/1.18_linux/runtime/runtime_unix_test.go.patch b/1.18_linux/runtime/runtime_unix_test.go.patch deleted file mode 100644 index ed286ca..0000000 --- a/1.18_linux/runtime/runtime_unix_test.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 -//--to -//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 diff --git a/1.18_linux/runtime/stack_test.go.patch b/1.18_linux/runtime/stack_test.go.patch deleted file mode 100644 index 18aebda..0000000 --- a/1.18_linux/runtime/stack_test.go.patch +++ /dev/null @@ -1,59 +0,0 @@ -//--from -func TestDeferLeafSigpanic(t *testing.T) { - // Push a defer that will walk the stack. - defer func() { - if err := recover(); err == nil { - t.Fatal("expected panic from nil pointer") - } - GC() - }() - // Call a leaf function. We must set up the exact call stack: - // - // defering function -> leaf function -> sigpanic - // - // On LR machines, the leaf function will have the same SP as - // the SP pushed for the defer frame. - testDeferLeafSigpanic1() -} -//--to -func TestDeferLeafSigpanic(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} -//--from -func TestStackWrapperStackPanic(t *testing.T) { - t.Run("sigpanic", func(t *testing.T) { - // nil calls to interface methods cause a sigpanic. - testStackWrapperPanic(t, func() { I.M(nil) }, "runtime_test.I.M") - }) - t.Run("panicwrap", func(t *testing.T) { - // Nil calls to value method wrappers call panicwrap. - wrapper := (*structWithMethod).nop - testStackWrapperPanic(t, func() { wrapper(nil) }, "runtime_test.(*structWithMethod).nop") - }) -} -//--to -func TestStackWrapperStackPanic(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} -//--from -func TestTracebackInlineExcluded(t *testing.T) { - defer func() { - recover() - buf := make([]byte, 4<<10) - stk := string(buf[:Stack(buf, false)]) - - t.Log(stk) - - if not := "tracebackExcluded"; strings.Contains(stk, not) { - t.Errorf("found but did not expect %q", not) - } - if want := "tracebackNotExcluded"; !strings.Contains(stk, want) { - t.Errorf("expected %q in stack", want) - } - }() - tracebackExcluded() -} -//--to -func TestTracebackInlineExcluded(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} diff --git a/1.18_linux/runtime/stubs2.go.patch b/1.18_linux/runtime/stubs2.go.patch deleted file mode 100644 index 746a0c0..0000000 --- a/1.18_linux/runtime/stubs2.go.patch +++ /dev/null @@ -1,78 +0,0 @@ -//--from -import ( - "runtime/internal/atomic" - "unsafe" -) -//--to -import ( - "internal/abi" - "runtime/internal/atomic" - "unsafe" -) -//--from -func read(fd int32, p unsafe.Pointer, n int32) int32 -//--to -//go:nosplit -//go:cgo_unsafe_args -func read(fd int32, p unsafe.Pointer, n int32) int32 { - return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) -} -func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 -//--from -func closefd(fd int32) int32 -//--to -//go:nosplit -//go:cgo_unsafe_args -func closefd(fd int32) int32 { - return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) -} -func closefd_trampoline(fd int32) int32 -//--from -func exit(code int32) -//--to -//go:nosplit -//go:cgo_unsafe_args -func exit(code int32) { - libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) -} -func exit_trampoline(code int32) -//--from -func usleep(usec uint32) -//--to -//go:nosplit -//go:cgo_unsafe_args -func usleep(usec uint32) { - libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) -} -func usleep_trampoline(usec uint32) -//--from -//go:nosplit -func usleep_no_g(usec uint32) { - usleep(usec) -} -//--to -//go:nosplit -//go:cgo_unsafe_args -func usleep_no_g(usec uint32) { - asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) -} -//--from -//go:noescape -func write1(fd uintptr, p unsafe.Pointer, n int32) int32 -//--to -//go:nosplit -//go:cgo_unsafe_args -func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { - return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) -} -func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 -//--from -//go:noescape -func open(name *byte, mode, perm int32) int32 -//--to -//go:nosplit -//go:cgo_unsafe_args -func open(name *byte, mode, perm int32) int32 { - return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) -} -func open_trampoline(name *byte, mode, perm int32) int32 diff --git a/1.18_linux/runtime/stubs3.go.patch b/1.18_linux/runtime/stubs3.go.patch deleted file mode 100644 index 8bdc673..0000000 --- a/1.18_linux/runtime/stubs3.go.patch +++ /dev/null @@ -1,19 +0,0 @@ -//--from -package runtime -//--to -package runtime - -import ( - "internal/abi" - "unsafe" -) -//--from -func nanotime1() int64 -//--to -//go:nosplit -//go:cgo_unsafe_args -func nanotime1() (now int64) { - libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) - return -} -func nanotime1_trampoline() int64 diff --git a/1.18_linux/runtime/sys_libc.go.patch b/1.18_linux/runtime/sys_libc.go.patch deleted file mode 100644 index 035277e..0000000 --- a/1.18_linux/runtime/sys_libc.go.patch +++ /dev/null @@ -1,4 +0,0 @@ -//--from -//go:build darwin || (openbsd && !mips64) -//--to -//go:build darwin || (openbsd && !mips64) || linux diff --git a/1.18_linux/runtime/sys_linux_arm64.s.patch b/1.18_linux/runtime/sys_linux_arm64.s.patch deleted file mode 100644 index ffc9a58..0000000 --- a/1.18_linux/runtime/sys_linux_arm64.s.patch +++ /dev/null @@ -1,462 +0,0 @@ -//--from -#define SYS_exit 93 -#define SYS_read 63 -#define SYS_write 64 -#define SYS_openat 56 -#define SYS_close 57 -#define SYS_pipe2 59 -#define SYS_fcntl 25 -#define SYS_nanosleep 101 -#define SYS_mmap 222 -#define SYS_munmap 215 -#define SYS_setitimer 103 -#define SYS_clone 220 -#define SYS_sched_yield 124 -#define SYS_rt_sigreturn 139 -#define SYS_rt_sigaction 134 -#define SYS_rt_sigprocmask 135 -#define SYS_sigaltstack 132 -#define SYS_madvise 233 -#define SYS_mincore 232 -#define SYS_getpid 172 -#define SYS_gettid 178 -#define SYS_kill 129 -#define SYS_tgkill 131 -#define SYS_futex 98 -#define SYS_sched_getaffinity 123 -#define SYS_exit_group 94 -#define SYS_epoll_create1 20 -#define SYS_epoll_ctl 21 -#define SYS_epoll_pwait 22 -#define SYS_clock_gettime 113 -#define SYS_faccessat 48 -#define SYS_socket 198 -#define SYS_connect 203 -#define SYS_brk 214 -//--to -#define SYS_exit 2147483647 -#define SYS_read 2147483647 -#define SYS_write 2147483647 -#define SYS_openat 2147483647 -#define SYS_close 2147483647 -#define SYS_pipe2 2147483647 -#define SYS_fcntl 2147483647 -#define SYS_nanosleep 2147483647 -#define SYS_mmap 2147483647 -#define SYS_munmap 2147483647 -#define SYS_setitimer 2147483647 -#define SYS_clone 2147483647 -#define SYS_sched_yield 2147483647 -#define SYS_rt_sigreturn 2147483647 -#define SYS_rt_sigaction 2147483647 -#define SYS_rt_sigprocmask 2147483647 -#define SYS_sigaltstack 2147483647 -#define SYS_madvise 2147483647 -#define SYS_mincore 2147483647 -#define SYS_getpid 2147483647 -#define SYS_gettid 2147483647 -#define SYS_kill 2147483647 -#define SYS_tgkill 2147483647 -#define SYS_futex 2147483647 -#define SYS_sched_getaffinity 2147483647 -#define SYS_exit_group 2147483647 -#define SYS_epoll_create1 2147483647 -#define SYS_epoll_ctl 2147483647 -#define SYS_epoll_pwait 2147483647 -#define SYS_clock_gettime 2147483647 -#define SYS_faccessat 2147483647 -#define SYS_socket 2147483647 -#define SYS_connect 2147483647 -#define SYS_brk 2147483647 -//--from -TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 - MOVW code+0(FP), R0 - MOVD $SYS_exit_group, R8 - SVC - RET -//--to -TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 - MOVW 0(R0), R0 - BL hitsumabushi_exit(SB) - RET -//--from -TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 - MOVD $AT_FDCWD, R0 - MOVD name+0(FP), R1 - MOVW mode+8(FP), R2 - MOVW perm+12(FP), R3 - MOVD $SYS_openat, R8 - SVC - CMN $4095, R0 - BCC done - MOVW $-1, R0 -done: - MOVW R0, ret+16(FP) - RET -//--to -TEXT runtime·open_trampoline(SB),NOSPLIT,$0 - MOVW 8(R0), R1 - MOVW 12(R0), R2 - MOVD 0(R0), R0 - BL hitsumabushi_open(SB) - RET -//--from -TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 - MOVW fd+0(FP), R0 - MOVD $SYS_close, R8 - SVC - CMN $4095, R0 - BCC done - MOVW $-1, R0 -done: - MOVW R0, ret+8(FP) - RET -//--to -TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 - MOVW 0(R0), R0 - BL hitsumabushi_closefd(SB) - RET -//--from -TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 - MOVD fd+0(FP), R0 - MOVD p+8(FP), R1 - MOVW n+16(FP), R2 - MOVD $SYS_write, R8 - SVC - MOVW R0, ret+24(FP) - RET -//--to -TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 - MOVD 8(R0), R1 - MOVW 16(R0), R2 - MOVD 0(R0), R0 - BL hitsumabushi_write1(SB) - RET -//--from -TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 - MOVW fd+0(FP), R0 - MOVD p+8(FP), R1 - MOVW n+16(FP), R2 - MOVD $SYS_read, R8 - SVC - MOVW R0, ret+24(FP) - RET -//--to -TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 - MOVD 8(R0), R1 - MOVW 16(R0), R2 - MOVW 0(R0), R0 - BL hitsumabushi_read(SB) - RET -//--from -TEXT runtime·usleep(SB),NOSPLIT,$24-4 - MOVWU usec+0(FP), R3 - MOVD R3, R5 - MOVW $1000000, R4 - UDIV R4, R3 - MOVD R3, 8(RSP) - MUL R3, R4 - SUB R4, R5 - MOVW $1000, R4 - MUL R4, R5 - MOVD R5, 16(RSP) - - // nanosleep(&ts, 0) - ADD $8, RSP, R0 - MOVD $0, R1 - MOVD $SYS_nanosleep, R8 - SVC - RET -//--to -TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 - MOVW 0(R0), R0 - BL hitsumabushi_usleep(SB) - RET -//--from -TEXT runtime·gettid(SB),NOSPLIT,$0-4 - MOVD $SYS_gettid, R8 - SVC - MOVW R0, ret+0(FP) - RET -//--to -TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 - MOVD R0, R19 // R19 is callee-save - BL hitsumabushi_gettid(SB) - MOVW R0, 0(R19) // return value - RET -//--from -TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 - MOVD $SYS_getpid, R8 - SVC - MOVW R0, R19 - MOVD $SYS_gettid, R8 - SVC - MOVW R0, R1 // arg 2 tid - MOVW R19, R0 // arg 1 pid - MOVW sig+0(FP), R2 // arg 3 - MOVD $SYS_tgkill, R8 - SVC - RET -//--to -//--from -TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 - MOVD $SYS_getpid, R8 - SVC - MOVW R0, R0 // arg 1 pid - MOVW sig+0(FP), R1 // arg 2 - MOVD $SYS_kill, R8 - SVC - RET -//--to -//--from -TEXT runtime·walltime(SB),NOSPLIT,$24-12 - MOVD RSP, R20 // R20 is unchanged by C code - MOVD RSP, R1 - - MOVD g_m(g), R21 // R21 = m - - // Set vdsoPC and vdsoSP for SIGPROF traceback. - // Save the old values on stack and restore them on exit, - // so this function is reentrant. - MOVD m_vdsoPC(R21), R2 - MOVD m_vdsoSP(R21), R3 - MOVD R2, 8(RSP) - MOVD R3, 16(RSP) - - MOVD $ret-8(FP), R2 // caller's SP - MOVD LR, m_vdsoPC(R21) - MOVD R2, m_vdsoSP(R21) - - MOVD m_curg(R21), R0 - CMP g, R0 - BNE noswitch - - MOVD m_g0(R21), R3 - MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack - -noswitch: - SUB $16, R1 - BIC $15, R1 // Align for C code - MOVD R1, RSP - - MOVW $CLOCK_REALTIME, R0 - MOVD runtime·vdsoClockgettimeSym(SB), R2 - CBZ R2, fallback - - // Store g on gsignal's stack, so if we receive a signal - // during VDSO code we can find the g. - // If we don't have a signal stack, we won't receive signal, - // so don't bother saving g. - // When using cgo, we already saved g on TLS, also don't save - // g here. - // Also don't save g if we are already on the signal stack. - // We won't get a nested signal. - MOVBU runtime·iscgo(SB), R22 - CBNZ R22, nosaveg - MOVD m_gsignal(R21), R22 // g.m.gsignal - CBZ R22, nosaveg - CMP g, R22 - BEQ nosaveg - MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo - MOVD g, (R22) - - BL (R2) - - MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code - - B finish - -nosaveg: - BL (R2) - B finish - -fallback: - MOVD $SYS_clock_gettime, R8 - SVC - -finish: - MOVD 0(RSP), R3 // sec - MOVD 8(RSP), R5 // nsec - - MOVD R20, RSP // restore SP - // Restore vdsoPC, vdsoSP - // We don't worry about being signaled between the two stores. - // If we are not in a signal handler, we'll restore vdsoSP to 0, - // and no one will care about vdsoPC. If we are in a signal handler, - // we cannot receive another signal. - MOVD 16(RSP), R1 - MOVD R1, m_vdsoSP(R21) - MOVD 8(RSP), R1 - MOVD R1, m_vdsoPC(R21) - - MOVD R3, sec+0(FP) - MOVW R5, nsec+8(FP) - RET -//--to -TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 - MOVD 8(R0), R1 - MOVD 0(R0), R0 - BL hitsumabushi_walltime1(SB) - RET -//--from -TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 - MOVD RSP, R20 // R20 is unchanged by C code - MOVD RSP, R1 - - MOVD g_m(g), R21 // R21 = m - - // Set vdsoPC and vdsoSP for SIGPROF traceback. - // Save the old values on stack and restore them on exit, - // so this function is reentrant. - MOVD m_vdsoPC(R21), R2 - MOVD m_vdsoSP(R21), R3 - MOVD R2, 8(RSP) - MOVD R3, 16(RSP) - - MOVD $ret-8(FP), R2 // caller's SP - MOVD LR, m_vdsoPC(R21) - MOVD R2, m_vdsoSP(R21) - - MOVD m_curg(R21), R0 - CMP g, R0 - BNE noswitch - - MOVD m_g0(R21), R3 - MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack - -noswitch: - SUB $32, R1 - BIC $15, R1 - MOVD R1, RSP - - MOVW $CLOCK_MONOTONIC, R0 - MOVD runtime·vdsoClockgettimeSym(SB), R2 - CBZ R2, fallback - - // Store g on gsignal's stack, so if we receive a signal - // during VDSO code we can find the g. - // If we don't have a signal stack, we won't receive signal, - // so don't bother saving g. - // When using cgo, we already saved g on TLS, also don't save - // g here. - // Also don't save g if we are already on the signal stack. - // We won't get a nested signal. - MOVBU runtime·iscgo(SB), R22 - CBNZ R22, nosaveg - MOVD m_gsignal(R21), R22 // g.m.gsignal - CBZ R22, nosaveg - CMP g, R22 - BEQ nosaveg - MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo - MOVD g, (R22) - - BL (R2) - - MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code - - B finish - -nosaveg: - BL (R2) - B finish - -fallback: - MOVD $SYS_clock_gettime, R8 - SVC - -finish: - MOVD 0(RSP), R3 // sec - MOVD 8(RSP), R5 // nsec - - MOVD R20, RSP // restore SP - // Restore vdsoPC, vdsoSP - // We don't worry about being signaled between the two stores. - // If we are not in a signal handler, we'll restore vdsoSP to 0, - // and no one will care about vdsoPC. If we are in a signal handler, - // we cannot receive another signal. - MOVD 16(RSP), R1 - MOVD R1, m_vdsoSP(R21) - MOVD 8(RSP), R1 - MOVD R1, m_vdsoPC(R21) - - // sec is in R3, nsec in R5 - // return nsec in R3 - MOVD $1000000000, R4 - MUL R4, R3 - ADD R5, R3 - MOVD R3, ret+0(FP) - RET -//--to -TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 - MOVD R0, R19 // R19 is callee-save - BL hitsumabushi_nanotime1(SB) - MOVD R0, 0(R19) // return value - RET -//--from -TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 - MOVD addr+0(FP), R0 - MOVW op+8(FP), R1 - MOVW val+12(FP), R2 - MOVD ts+16(FP), R3 - MOVD addr2+24(FP), R4 - MOVW val3+32(FP), R5 - MOVD $SYS_futex, R8 - SVC - MOVW R0, ret+40(FP) - RET -//--to -TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 - MOVW 8(R0), R1 - MOVW 12(R0), R2 - MOVD 16(R0), R3 - MOVD 24(R0), R4 - MOVW 32(R0), R5 - MOVD 0(R0), R0 - BL hitsumabushi_futex(SB) - RET -//--from -TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 - MOVD new+0(FP), R0 - MOVD old+8(FP), R1 - MOVD $SYS_sigaltstack, R8 - SVC - CMN $4095, R0 - BCC ok - MOVD $0, R0 - MOVD R0, (R0) // crash -ok: - RET -//--to -//--from -TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 - MOVD $SYS_sched_yield, R8 - SVC - RET -//--to -TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 - BL hitsumabushi_osyield(SB) - RET -//--from -TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 - MOVD pid+0(FP), R0 - MOVD len+8(FP), R1 - MOVD buf+16(FP), R2 - MOVD $SYS_sched_getaffinity, R8 - SVC - MOVW R0, ret+24(FP) - RET -//--to -TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 - MOVD 8(R0), R1 - MOVD 16(R0), R2 - MOVD 0(R0), R0 - BL hitsumabushi_sched_getaffinity(SB) - RET -//--append -TEXT runtime·calloc_trampoline(SB),NOSPLIT,$0 - MOVD R0, R19 // R19 is callee-save - MOVD 8(R0), R1 - MOVD 0(R0), R0 - BL hitsumabushi_calloc(SB) - MOVD R0, 16(R19) // return value - RET diff --git a/1.18_linux/runtime/timestub2.go.patch b/1.18_linux/runtime/timestub2.go.patch deleted file mode 100644 index 9636b49..0000000 --- a/1.18_linux/runtime/timestub2.go.patch +++ /dev/null @@ -1,22 +0,0 @@ -//--from -package runtime -//--to -package runtime - -import ( - "internal/abi" - "unsafe" -) -//--from -func walltime() (sec int64, nsec int32) -//--to -func walltime() (sec int64, nsec int32) { - walltime1(&sec, &nsec) - return -} -//go:nosplit -//go:cgo_unsafe_args -func walltime1(sec *int64, nsec *int32) { - libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) -} -func walltime1_trampoline(sec *int64, nsec *int32) diff --git a/1.18_linux/strconv/fp_test.go.patch b/1.18_linux/strconv/fp_test.go.patch deleted file mode 100644 index 6b1010a..0000000 --- a/1.18_linux/strconv/fp_test.go.patch +++ /dev/null @@ -1,68 +0,0 @@ -//--from -import ( - "bufio" - "fmt" - "os" - "strconv" - "strings" - "testing" -) -//--to -import ( - "strconv" - "strings" - "testing" -) -//--from -func TestFp(t *testing.T) { - f, err := os.Open("testdata/testfp.txt") - if err != nil { - t.Fatal("testfp: open testdata/testfp.txt:", err) - } - defer f.Close() - - s := bufio.NewScanner(f) - - for lineno := 1; s.Scan(); lineno++ { - line := s.Text() - if len(line) == 0 || line[0] == '#' { - continue - } - a := strings.Split(line, " ") - if len(a) != 4 { - t.Error("testdata/testfp.txt:", lineno, ": wrong field count") - continue - } - var s string - var v float64 - switch a[0] { - case "float64": - var ok bool - v, ok = myatof64(a[2]) - if !ok { - t.Error("testdata/testfp.txt:", lineno, ": cannot atof64 ", a[2]) - continue - } - s = fmt.Sprintf(a[1], v) - case "float32": - v1, ok := myatof32(a[2]) - if !ok { - t.Error("testdata/testfp.txt:", lineno, ": cannot atof32 ", a[2]) - continue - } - s = fmt.Sprintf(a[1], v1) - v = float64(v1) - } - if s != a[3] { - t.Error("testdata/testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ", - "want ", a[3], " got ", s) - } - } - if s.Err() != nil { - t.Fatal("testfp: read testdata/testfp.txt: ", s.Err()) - } -} -//--to -func TestFp(t *testing.T) { - t.Skip("file is not supported in this environment") -} diff --git a/1.18_linux/sync/atomic/atomic_test.go.patch b/1.18_linux/sync/atomic/atomic_test.go.patch deleted file mode 100644 index 2c549be..0000000 --- a/1.18_linux/sync/atomic/atomic_test.go.patch +++ /dev/null @@ -1,142 +0,0 @@ -//--from -func TestStoreLoadSeqCst32(t *testing.T) { - if runtime.NumCPU() == 1 { - t.Skipf("Skipping test on %v processor machine", runtime.NumCPU()) - } - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) - N := int32(1e3) - if testing.Short() { - N = int32(1e2) - } - c := make(chan bool, 2) - X := [2]int32{} - ack := [2][3]int32{{-1, -1, -1}, {-1, -1, -1}} - for p := 0; p < 2; p++ { - go func(me int) { - he := 1 - me - for i := int32(1); i < N; i++ { - StoreInt32(&X[me], i) - my := LoadInt32(&X[he]) - StoreInt32(&ack[me][i%3], my) - for w := 1; LoadInt32(&ack[he][i%3]) == -1; w++ { - if w%1000 == 0 { - runtime.Gosched() - } - } - his := LoadInt32(&ack[he][i%3]) - if (my != i && my != i-1) || (his != i && his != i-1) { - t.Errorf("invalid values: %d/%d (%d)", my, his, i) - break - } - if my != i && his != i { - t.Errorf("store/load are not sequentially consistent: %d/%d (%d)", my, his, i) - break - } - StoreInt32(&ack[me][(i-1)%3], -1) - } - c <- true - }(p) - } - <-c - <-c -} -//--to -func TestStoreLoadSeqCst32(t *testing.T) { - t.Skip("didn't work on QEMU. see golang/go#50188") -} -//--from -func TestStoreLoadSeqCst64(t *testing.T) { - if runtime.NumCPU() == 1 { - t.Skipf("Skipping test on %v processor machine", runtime.NumCPU()) - } - if test64err != nil { - t.Skipf("Skipping 64-bit tests: %v", test64err) - } - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) - N := int64(1e3) - if testing.Short() { - N = int64(1e2) - } - c := make(chan bool, 2) - X := [2]int64{} - ack := [2][3]int64{{-1, -1, -1}, {-1, -1, -1}} - for p := 0; p < 2; p++ { - go func(me int) { - he := 1 - me - for i := int64(1); i < N; i++ { - StoreInt64(&X[me], i) - my := LoadInt64(&X[he]) - StoreInt64(&ack[me][i%3], my) - for w := 1; LoadInt64(&ack[he][i%3]) == -1; w++ { - if w%1000 == 0 { - runtime.Gosched() - } - } - his := LoadInt64(&ack[he][i%3]) - if (my != i && my != i-1) || (his != i && his != i-1) { - t.Errorf("invalid values: %d/%d (%d)", my, his, i) - break - } - if my != i && his != i { - t.Errorf("store/load are not sequentially consistent: %d/%d (%d)", my, his, i) - break - } - StoreInt64(&ack[me][(i-1)%3], -1) - } - c <- true - }(p) - } - <-c - <-c -} -//--to -func TestStoreLoadSeqCst64(t *testing.T) { - t.Skip("didn't work on QEMU. see golang/go#50188") -} -//--from -func TestNilDeref(t *testing.T) { - funcs := [...]func(){ - func() { CompareAndSwapInt32(nil, 0, 0) }, - func() { CompareAndSwapInt64(nil, 0, 0) }, - func() { CompareAndSwapUint32(nil, 0, 0) }, - func() { CompareAndSwapUint64(nil, 0, 0) }, - func() { CompareAndSwapUintptr(nil, 0, 0) }, - func() { CompareAndSwapPointer(nil, nil, nil) }, - func() { SwapInt32(nil, 0) }, - func() { SwapUint32(nil, 0) }, - func() { SwapInt64(nil, 0) }, - func() { SwapUint64(nil, 0) }, - func() { SwapUintptr(nil, 0) }, - func() { SwapPointer(nil, nil) }, - func() { AddInt32(nil, 0) }, - func() { AddUint32(nil, 0) }, - func() { AddInt64(nil, 0) }, - func() { AddUint64(nil, 0) }, - func() { AddUintptr(nil, 0) }, - func() { LoadInt32(nil) }, - func() { LoadInt64(nil) }, - func() { LoadUint32(nil) }, - func() { LoadUint64(nil) }, - func() { LoadUintptr(nil) }, - func() { LoadPointer(nil) }, - func() { StoreInt32(nil, 0) }, - func() { StoreInt64(nil, 0) }, - func() { StoreUint32(nil, 0) }, - func() { StoreUint64(nil, 0) }, - func() { StoreUintptr(nil, 0) }, - func() { StorePointer(nil, nil) }, - } - for _, f := range funcs { - func() { - defer func() { - runtime.GC() - recover() - }() - f() - }() - } -} -//--to -func TestNilDeref(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} diff --git a/1.18_linux/syscall/asm_linux_arm64.s.patch b/1.18_linux/syscall/asm_linux_arm64.s.patch deleted file mode 100644 index ae2002f..0000000 --- a/1.18_linux/syscall/asm_linux_arm64.s.patch +++ /dev/null @@ -1,102 +0,0 @@ -//--from -TEXT ·Syscall(SB),NOSPLIT,$0-56 - BL runtime·entersyscall(SB) - MOVD a1+8(FP), R0 - MOVD a2+16(FP), R1 - MOVD a3+24(FP), R2 - MOVD $0, R3 - MOVD $0, R4 - MOVD $0, R5 - MOVD trap+0(FP), R8 // syscall entry - SVC - CMN $4095, R0 - BCC ok - MOVD $-1, R4 - MOVD R4, r1+32(FP) // r1 - MOVD ZR, r2+40(FP) // r2 - NEG R0, R0 - MOVD R0, err+48(FP) // errno - BL runtime·exitsyscall(SB) - RET -ok: - MOVD R0, r1+32(FP) // r1 - MOVD R1, r2+40(FP) // r2 - MOVD ZR, err+48(FP) // errno - BL runtime·exitsyscall(SB) - RET -//--to -//--from -TEXT ·Syscall6(SB),NOSPLIT,$0-80 - BL runtime·entersyscall(SB) - MOVD a1+8(FP), R0 - MOVD a2+16(FP), R1 - MOVD a3+24(FP), R2 - MOVD a4+32(FP), R3 - MOVD a5+40(FP), R4 - MOVD a6+48(FP), R5 - MOVD trap+0(FP), R8 // syscall entry - SVC - CMN $4095, R0 - BCC ok - MOVD $-1, R4 - MOVD R4, r1+56(FP) // r1 - MOVD ZR, r2+64(FP) // r2 - NEG R0, R0 - MOVD R0, err+72(FP) // errno - BL runtime·exitsyscall(SB) - RET -ok: - MOVD R0, r1+56(FP) // r1 - MOVD R1, r2+64(FP) // r2 - MOVD ZR, err+72(FP) // errno - BL runtime·exitsyscall(SB) - RET -//--to -//--from -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - MOVD a1+8(FP), R0 - MOVD a2+16(FP), R1 - MOVD a3+24(FP), R2 - MOVD $0, R3 - MOVD $0, R4 - MOVD $0, R5 - MOVD trap+0(FP), R8 // syscall entry - SVC - CMN $4095, R0 - BCC ok - MOVD $-1, R4 - MOVD R4, r1+32(FP) // r1 - MOVD ZR, r2+40(FP) // r2 - NEG R0, R0 - MOVD R0, err+48(FP) // errno - RET -ok: - MOVD R0, r1+32(FP) // r1 - MOVD R1, r2+40(FP) // r2 - MOVD ZR, err+48(FP) // errno - RET -//--to -//--from -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - MOVD a1+8(FP), R0 - MOVD a2+16(FP), R1 - MOVD a3+24(FP), R2 - MOVD a4+32(FP), R3 - MOVD a5+40(FP), R4 - MOVD a6+48(FP), R5 - MOVD trap+0(FP), R8 // syscall entry - SVC - CMN $4095, R0 - BCC ok - MOVD $-1, R4 - MOVD R4, r1+56(FP) // r1 - MOVD ZR, r2+64(FP) // r2 - NEG R0, R0 - MOVD R0, err+72(FP) // errno - RET -ok: - MOVD R0, r1+56(FP) // r1 - MOVD R1, r2+64(FP) // r2 - MOVD ZR, err+72(FP) // errno - RET -//--to diff --git a/1.18_linux/syscall/syscall_unix.go.patch b/1.18_linux/syscall/syscall_unix.go.patch deleted file mode 100644 index e2cc2c0..0000000 --- a/1.18_linux/syscall/syscall_unix.go.patch +++ /dev/null @@ -1,63 +0,0 @@ -//--from -func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) -//--to -func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - switch trap { - case SYS_FCNTL: - if a1 == uintptr(Stdin) || a1 == uintptr(Stdout) || a1 == uintptr(Stderr) { - if a2 == F_GETFL { - return 0, 0, 0 - } - } - println("unexpected fcntl:", a1, a2, a3) - case SYS_READ: - if a1 == uintptr(Stdin) { - if a3 == 0 { - return 0, 0, 0 - } - // TODO: Implement this - } - case SYS_WRITE: - if a1 == uintptr(Stdout) || a1 == uintptr(Stderr) { - if a3 == 0 { - return 0, 0, 0 - } - r := write1(a1, unsafe.Pointer(a2), int32(a3)) - return uintptr(r), 0, 0 - } - } - println("not implemented syscall at runtime.Syscall", trap) - panic("syscall.Syscall") - return 0, 0, ENOSYS -} - -//go:linkname write1 runtime.write1 -func write1(fd uintptr, p unsafe.Pointer, n int32) int32 -//--from -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) -//--to -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - switch trap { - case SYS_FSTATAT: - return 0, 0, ENOENT - } - println("not implemented syscall at runtime.Syscall6", trap) - panic("syscall.Syscall6") - return 0, 0, ENOSYS -} -//--from -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) -//--to -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - println("not implemented syscall at RawSyscall", trap) - panic("syscall.RawSyscall") - return 0, 0, ENOSYS -} -//--from -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) -//--to -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - println("not implemented syscall at RawSyscall6", trap) - panic("syscall.RawSyscall6") - return 0, 0, ENOSYS -} diff --git a/1.18_linux/testing/run_example.go b/1.18_linux/testing/run_example.go deleted file mode 100644 index 24d58dd..0000000 --- a/1.18_linux/testing/run_example.go +++ /dev/null @@ -1,7 +0,0 @@ -package testing - -func runExample(eg InternalExample) (ok bool) { - // Do nothing. - // TODO: Implement os.Pipe2 and use this here. - return true -} diff --git a/1.18_linux/time/format_test.go.patch b/1.18_linux/time/format_test.go.patch deleted file mode 100644 index 4864287..0000000 --- a/1.18_linux/time/format_test.go.patch +++ /dev/null @@ -1,71 +0,0 @@ -//--from -func TestParseInLocation(t *testing.T) { - - baghdad, err := LoadLocation("Asia/Baghdad") - if err != nil { - t.Fatal(err) - } - - var t1, t2 Time - - t1, err = ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", baghdad) - if err != nil { - t.Fatal(err) - } - - _, offset := t1.Zone() - - // A zero offset means that ParseInLocation did not recognize the - // 'AST' abbreviation as matching the current location (Baghdad, - // where we'd expect a +03 hrs offset); likely because we're using - // a recent tzdata release (2017a or newer). - // If it happens, skip the Baghdad test. - if offset != 0 { - t2 = Date(2013, February, 1, 00, 00, 00, 0, baghdad) - if t1 != t2 { - t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad) = %v, want %v", t1, t2) - } - if offset != 3*60*60 { - t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad).Zone = _, %d, want _, %d", offset, 3*60*60) - } - } - - blancSablon, err := LoadLocation("America/Blanc-Sablon") - if err != nil { - t.Fatal(err) - } - - // In this case 'AST' means 'Atlantic Standard Time', and we - // expect the abbreviation to correctly match the american - // location. - t1, err = ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", blancSablon) - if err != nil { - t.Fatal(err) - } - t2 = Date(2013, February, 1, 00, 00, 00, 0, blancSablon) - if t1 != t2 { - t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon) = %v, want %v", t1, t2) - } - _, offset = t1.Zone() - if offset != -4*60*60 { - t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon).Zone = _, %d, want _, %d", offset, -4*60*60) - } -} -//--to -func TestParseInLocation(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestLoadLocationZipFile(t *testing.T) { - ForceZipFileForTesting(true) - defer ForceZipFileForTesting(false) - - _, err := LoadLocation("Australia/Sydney") - if err != nil { - t.Fatal(err) - } -} -//--to -func TestLoadLocationZipFile(t *testing.T) { - t.Skip("location is not supported in this environment") -} diff --git a/1.18_linux/time/internal_test.go.patch b/1.18_linux/time/internal_test.go.patch deleted file mode 100644 index 00883b6..0000000 --- a/1.18_linux/time/internal_test.go.patch +++ /dev/null @@ -1,17 +0,0 @@ -//--from -func initTestingZone() { - z, err := loadLocation("America/Los_Angeles", zoneSources[len(zoneSources)-1:]) - if err != nil { - panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") - } - z.name = "Local" - localLoc = *z -} -//--to -func initTestingZone() { - // Data from the playground. - // https://go.dev/play/p/VGXU57KZZ-x - // name is replaced with "Local". - // cachStart, cacheEnd, and cacheZone are removed. - localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} -} diff --git a/1.18_linux/time/sleep_test.go.patch b/1.18_linux/time/sleep_test.go.patch deleted file mode 100644 index cc48e55..0000000 --- a/1.18_linux/time/sleep_test.go.patch +++ /dev/null @@ -1,44 +0,0 @@ -//--from -func TestSleep(t *testing.T) { - const delay = 100 * Millisecond - go func() { - Sleep(delay / 2) - Interrupt() - }() - start := Now() - Sleep(delay) - delayadj := delay - if runtime.GOOS == "windows" { - delayadj -= windowsInaccuracy - } - duration := Now().Sub(start) - if duration < delayadj { - t.Fatalf("Sleep(%s) slept for only %s", delay, duration) - } -} -//--to -func TestSleep(t *testing.T) { - t.Skip("Interrupt (syscall.Kill) is not supported in this environment") -} -//--from -func TestIssue5745(t *testing.T) { - ticker := NewTicker(Hour) - defer func() { - // would deadlock here before the fix due to - // lock taken before the segfault. - ticker.Stop() - - if r := recover(); r == nil { - t.Error("Expected panic, but none happened.") - } - }() - - // cause a panic due to a segfault - var timer *Timer - timer.Stop() - t.Error("Should be unreachable.") -} -//--to -func TestIssue5745(t *testing.T) { - t.Skip("handling nil pointer access is not supported in this environment") -} diff --git a/1.18_linux/time/time_test.go.patch b/1.18_linux/time/time_test.go.patch deleted file mode 100644 index 5d704f0..0000000 --- a/1.18_linux/time/time_test.go.patch +++ /dev/null @@ -1,143 +0,0 @@ -//--from -func TestLoadFixed(t *testing.T) { - // Issue 4064: handle locations without any zone transitions. - loc, err := LoadLocation("Etc/GMT+1") - if err != nil { - t.Fatal(err) - } - - // The tzdata name Etc/GMT+1 uses "east is negative", - // but Go and most other systems use "east is positive". - // So GMT+1 corresponds to -3600 in the Go zone, not +3600. - name, offset := Now().In(loc).Zone() - // The zone abbreviation is "-01" since tzdata-2016g, and "GMT+1" - // on earlier versions; we accept both. (Issue #17276). - if !(name == "GMT+1" || name == "-01") || offset != -1*60*60 { - t.Errorf("Now().In(loc).Zone() = %q, %d, want %q or %q, %d", - name, offset, "GMT+1", "-01", -1*60*60) - } -} -//--to -func TestLoadFixed(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestTimeIsDST(t *testing.T) { - ForceZipFileForTesting(true) - defer ForceZipFileForTesting(false) - - tzWithDST, err := LoadLocation("Australia/Sydney") - if err != nil { - t.Fatalf("could not load tz 'Australia/Sydney': %v", err) - } - tzWithoutDST, err := LoadLocation("Australia/Brisbane") - if err != nil { - t.Fatalf("could not load tz 'Australia/Brisbane': %v", err) - } - tzFixed := FixedZone("FIXED_TIME", 12345) - - tests := [...]struct { - time Time - want bool - }{ - 0: {Date(2009, 1, 1, 12, 0, 0, 0, UTC), false}, - 1: {Date(2009, 6, 1, 12, 0, 0, 0, UTC), false}, - 2: {Date(2009, 1, 1, 12, 0, 0, 0, tzWithDST), true}, - 3: {Date(2009, 6, 1, 12, 0, 0, 0, tzWithDST), false}, - 4: {Date(2009, 1, 1, 12, 0, 0, 0, tzWithoutDST), false}, - 5: {Date(2009, 6, 1, 12, 0, 0, 0, tzWithoutDST), false}, - 6: {Date(2009, 1, 1, 12, 0, 0, 0, tzFixed), false}, - 7: {Date(2009, 6, 1, 12, 0, 0, 0, tzFixed), false}, - } - - for i, tt := range tests { - got := tt.time.IsDST() - if got != tt.want { - t.Errorf("#%d:: (%#v).IsDST()=%t, want %t", i, tt.time.Format(RFC3339), got, tt.want) - } - } -} -//--to -func TestTimeIsDST(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestTimeWithZoneTransition(t *testing.T) { - ForceZipFileForTesting(true) - defer ForceZipFileForTesting(false) - - loc, err := LoadLocation("Asia/Shanghai") - if err != nil { - t.Fatal(err) - } - - tests := [...]struct { - give Time - want Time - }{ - // 14 Apr 1991 - Daylight Saving Time Started - // When time of "Asia/Shanghai" was about to reach - // Sunday, 14 April 1991, 02:00:00 clocks were turned forward 1 hour to - // Sunday, 14 April 1991, 03:00:00 local daylight time instead. - // The UTC time was 13 April 1991, 18:00:00 - 0: {Date(1991, April, 13, 17, 50, 0, 0, loc), Date(1991, April, 13, 9, 50, 0, 0, UTC)}, - 1: {Date(1991, April, 13, 18, 0, 0, 0, loc), Date(1991, April, 13, 10, 0, 0, 0, UTC)}, - 2: {Date(1991, April, 14, 1, 50, 0, 0, loc), Date(1991, April, 13, 17, 50, 0, 0, UTC)}, - 3: {Date(1991, April, 14, 3, 0, 0, 0, loc), Date(1991, April, 13, 18, 0, 0, 0, UTC)}, - - // 15 Sep 1991 - Daylight Saving Time Ended - // When local daylight time of "Asia/Shanghai" was about to reach - // Sunday, 15 September 1991, 02:00:00 clocks were turned backward 1 hour to - // Sunday, 15 September 1991, 01:00:00 local standard time instead. - // The UTC time was 14 September 1991, 17:00:00 - 4: {Date(1991, September, 14, 16, 50, 0, 0, loc), Date(1991, September, 14, 7, 50, 0, 0, UTC)}, - 5: {Date(1991, September, 14, 17, 0, 0, 0, loc), Date(1991, September, 14, 8, 0, 0, 0, UTC)}, - 6: {Date(1991, September, 15, 0, 50, 0, 0, loc), Date(1991, September, 14, 15, 50, 0, 0, UTC)}, - 7: {Date(1991, September, 15, 2, 00, 0, 0, loc), Date(1991, September, 14, 18, 00, 0, 0, UTC)}, - } - - for i, tt := range tests { - if !tt.give.Equal(tt.want) { - t.Errorf("#%d:: %#v is not equal to %#v", i, tt.give.Format(RFC3339), tt.want.Format(RFC3339)) - } - } -} -//--to -func TestTimeWithZoneTransition(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestMarshalBinaryVersion2(t *testing.T) { - t0, err := Parse(RFC3339, "1880-01-01T00:00:00Z") - if err != nil { - t.Errorf("Failed to parse time, error = %v", err) - } - loc, err := LoadLocation("US/Eastern") - if err != nil { - t.Errorf("Failed to load location, error = %v", err) - } - t1 := t0.In(loc) - b, err := t1.MarshalBinary() - if err != nil { - t.Errorf("Failed to Marshal, error = %v", err) - } - - t2 := Time{} - err = t2.UnmarshalBinary(b) - if err != nil { - t.Errorf("Failed to Unmarshal, error = %v", err) - } - - if !(t0.Equal(t1) && t1.Equal(t2)) { - if !t0.Equal(t1) { - t.Errorf("The result t1: %+v after Marshal is not matched original t0: %+v", t1, t0) - } - if !t1.Equal(t2) { - t.Errorf("The result t2: %+v after Unmarshal is not matched original t1: %+v", t2, t1) - } - } -} -//--to -func TestMarshalBinaryVersion2(t *testing.T) { - t.Skip("location is not supported in this environment") -} diff --git a/1.18_linux/time/tzdata_test.go.patch b/1.18_linux/time/tzdata_test.go.patch deleted file mode 100644 index 0bc353f..0000000 --- a/1.18_linux/time/tzdata_test.go.patch +++ /dev/null @@ -1,63 +0,0 @@ -//--from -import ( - "reflect" - "testing" - "time" - _ "time/tzdata" -) -//--to -import ( - "reflect" - "testing" - _ "time/tzdata" -) -//--from -func TestEmbeddedTZData(t *testing.T) { - time.ForceZipFileForTesting(true) - defer time.ForceZipFileForTesting(false) - - for _, zone := range zones { - ref, err := time.LoadLocation(zone) - if err != nil { - t.Errorf("LoadLocation(%q): %v", zone, err) - continue - } - - embedded, err := time.LoadFromEmbeddedTZData(zone) - if err != nil { - t.Errorf("LoadFromEmbeddedTZData(%q): %v", zone, err) - continue - } - sample, err := time.LoadLocationFromTZData(zone, []byte(embedded)) - if err != nil { - t.Errorf("LoadLocationFromTZData failed for %q: %v", zone, err) - continue - } - - // Compare the name and zone fields of ref and sample. - // The tx field changes faster as tzdata is updated. - // The cache fields are expected to differ. - v1 := reflect.ValueOf(ref).Elem() - v2 := reflect.ValueOf(sample).Elem() - typ := v1.Type() - nf := typ.NumField() - found := 0 - for i := 0; i < nf; i++ { - ft := typ.Field(i) - if ft.Name != "name" && ft.Name != "zone" { - continue - } - found++ - if !equal(t, v1.Field(i), v2.Field(i)) { - t.Errorf("zone %s: system and embedded tzdata field %s differs", zone, ft.Name) - } - } - if found != 2 { - t.Errorf("test must be updated for change to time.Location struct") - } - } -} -//--to -func TestEmbeddedTZData(t *testing.T) { - t.Skip("location is not supported in this environment") -} diff --git a/1.18_linux/time/zoneinfo_test.go.patch b/1.18_linux/time/zoneinfo_test.go.patch deleted file mode 100644 index d7e8c7b..0000000 --- a/1.18_linux/time/zoneinfo_test.go.patch +++ /dev/null @@ -1,188 +0,0 @@ -//--from -import ( - "errors" - "fmt" - "os" - "reflect" - "testing" - "time" -) -//--to -import ( - "fmt" - "testing" - "time" -) -//--from -func TestEnvVarUsage(t *testing.T) { - time.ResetZoneinfoForTesting() - - const testZoneinfo = "foo.zip" - const env = "ZONEINFO" - - t.Setenv(env, testZoneinfo) - - // Result isn't important, we're testing the side effect of this command - time.LoadLocation("Asia/Jerusalem") - defer time.ResetZoneinfoForTesting() - - if zoneinfo := time.ZoneinfoForTesting(); testZoneinfo != *zoneinfo { - t.Errorf("zoneinfo does not match env variable: got %q want %q", *zoneinfo, testZoneinfo) - } -} -//--to -func TestEnvVarUsage(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestBadLocationErrMsg(t *testing.T) { - time.ResetZoneinfoForTesting() - loc := "Asia/SomethingNotExist" - want := errors.New("unknown time zone " + loc) - _, err := time.LoadLocation(loc) - if err.Error() != want.Error() { - t.Errorf("LoadLocation(%q) error = %v; want %v", loc, err, want) - } -} -//--to -func TestBadLocationErrMsg(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestVersion3(t *testing.T) { - time.ForceZipFileForTesting(true) - defer time.ForceZipFileForTesting(false) - _, err := time.LoadLocation("Asia/Jerusalem") - if err != nil { - t.Fatal(err) - } -} -//--to -func TestVersion3(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestFirstZone(t *testing.T) { - time.ForceZipFileForTesting(true) - defer time.ForceZipFileForTesting(false) - - const format = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)" - var tests = []struct { - zone string - unix int64 - want1 string - want2 string - }{ - { - "PST8PDT", - -1633269601, - "Sun, 31 Mar 1918 01:59:59 -0800 (PST)", - "Sun, 31 Mar 1918 03:00:00 -0700 (PDT)", - }, - { - "Pacific/Fakaofo", - 1325242799, - "Thu, 29 Dec 2011 23:59:59 -1100 (-11)", - "Sat, 31 Dec 2011 00:00:00 +1300 (+13)", - }, - } - - for _, test := range tests { - z, err := time.LoadLocation(test.zone) - if err != nil { - t.Fatal(err) - } - s := time.Unix(test.unix, 0).In(z).Format(format) - if s != test.want1 { - t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want1) - } - s = time.Unix(test.unix+1, 0).In(z).Format(format) - if s != test.want2 { - t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want2) - } - } -} -//--to -func TestFirstZone(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestLoadLocationFromTZData(t *testing.T) { - time.ForceZipFileForTesting(true) - defer time.ForceZipFileForTesting(false) - - const locationName = "Asia/Jerusalem" - reference, err := time.LoadLocation(locationName) - if err != nil { - t.Fatal(err) - } - - tzinfo, err := time.LoadTzinfo(locationName, time.OrigZoneSources[len(time.OrigZoneSources)-1]) - if err != nil { - t.Fatal(err) - } - sample, err := time.LoadLocationFromTZData(locationName, tzinfo) - if err != nil { - t.Fatal(err) - } - - if !reflect.DeepEqual(reference, sample) { - t.Errorf("return values of LoadLocationFromTZData and LoadLocation don't match") - } -} -//--to -func TestLoadLocationFromTZData(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestEarlyLocation(t *testing.T) { - time.ForceZipFileForTesting(true) - defer time.ForceZipFileForTesting(false) - - const locName = "America/New_York" - loc, err := time.LoadLocation(locName) - if err != nil { - t.Fatal(err) - } - - d := time.Date(1900, time.January, 1, 0, 0, 0, 0, loc) - tzName, tzOffset := d.Zone() - if want := "EST"; tzName != want { - t.Errorf("Zone name == %s, want %s", tzName, want) - } - if want := -18000; tzOffset != want { - t.Errorf("Zone offset == %d, want %d", tzOffset, want) - } -} -//--to -func TestEarlyLocation(t *testing.T) { - t.Skip("location is not supported in this environment") -} -//--from -func TestLoadLocationFromTZDataSlim(t *testing.T) { - for _, test := range slimTests { - tzData, err := os.ReadFile("testdata/" + test.fileName) - if err != nil { - t.Error(err) - continue - } - reference, err := time.LoadLocationFromTZData(test.zoneName, tzData) - if err != nil { - t.Error(err) - continue - } - - d := test.date(reference) - tzName, tzOffset := d.Zone() - if tzName != test.wantName { - t.Errorf("Zone name == %s, want %s", tzName, test.wantName) - } - if tzOffset != test.wantOffset { - t.Errorf("Zone offset == %d, want %d", tzOffset, test.wantOffset) - } - } -} -//--to -func TestLoadLocationFromTZDataSlim(t *testing.T) { - t.Skip("location is not supported in this environment") -} diff --git a/1.18_linux/time/zoneinfo_unix.go.patch b/1.18_linux/time/zoneinfo_unix.go.patch deleted file mode 100644 index 5ec6953..0000000 --- a/1.18_linux/time/zoneinfo_unix.go.patch +++ /dev/null @@ -1,56 +0,0 @@ -//--from -import ( - "runtime" - "syscall" -) -//--to -import ( - "runtime" -) -//--from -func initLocal() { - // consult $TZ to find the time zone to use. - // no $TZ means use the system default /etc/localtime. - // $TZ="" means use UTC. - // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed - // by foo will be used to initialize timezone; otherwise, file - // /usr/share/zoneinfo/foo will be used. - - tz, ok := syscall.Getenv("TZ") - switch { - case !ok: - z, err := loadLocation("localtime", []string{"/etc"}) - if err == nil { - localLoc = *z - localLoc.name = "Local" - return - } - case tz != "": - if tz[0] == ':' { - tz = tz[1:] - } - if tz != "" && tz[0] == '/' { - if z, err := loadLocation(tz, []string{""}); err == nil { - localLoc = *z - if tz == "/etc/localtime" { - localLoc.name = "Local" - } else { - localLoc.name = tz - } - return - } - } else if tz != "" && tz != "UTC" { - if z, err := loadLocation(tz, zoneSources); err == nil { - localLoc = *z - return - } - } - } - - // Fall back to UTC. - localLoc.name = "UTC" -} -//--to -func initLocal() { - localLoc.name = "UTC" -} diff --git a/1.18_linux/time/zoneinfo_unix_test.go.patch b/1.18_linux/time/zoneinfo_unix_test.go.patch deleted file mode 100644 index bb2764a..0000000 --- a/1.18_linux/time/zoneinfo_unix_test.go.patch +++ /dev/null @@ -1,91 +0,0 @@ -//--from -import ( - "os" - "testing" - "time" -) -//--to -import ( - "testing" -) -//--from -func TestEnvTZUsage(t *testing.T) { - const env = "TZ" - tz, ok := os.LookupEnv(env) - if !ok { - defer os.Unsetenv(env) - } else { - defer os.Setenv(env, tz) - } - defer time.ForceUSPacificForTesting() - - localZoneName := "Local" - // The file may not exist. - if _, err := os.Stat("/etc/localtime"); os.IsNotExist(err) { - localZoneName = "UTC" - } - - cases := []struct { - nilFlag bool - tz string - local string - }{ - // no $TZ means use the system default /etc/localtime. - {true, "", localZoneName}, - // $TZ="" means use UTC. - {false, "", "UTC"}, - {false, ":", "UTC"}, - {false, "Asia/Shanghai", "Asia/Shanghai"}, - {false, ":Asia/Shanghai", "Asia/Shanghai"}, - {false, "/etc/localtime", localZoneName}, - {false, ":/etc/localtime", localZoneName}, - } - - for _, c := range cases { - time.ResetLocalOnceForTest() - if c.nilFlag { - os.Unsetenv(env) - } else { - os.Setenv(env, c.tz) - } - if time.Local.String() != c.local { - t.Errorf("invalid Local location name for %q: got %q want %q", c.tz, time.Local, c.local) - } - } - - time.ResetLocalOnceForTest() - // The file may not exist on Solaris 2 and IRIX 6. - path := "/usr/share/zoneinfo/Asia/Shanghai" - os.Setenv(env, path) - if _, err := os.Stat(path); os.IsNotExist(err) { - if time.Local.String() != "UTC" { - t.Errorf(`invalid path should fallback to UTC: got %q want "UTC"`, time.Local) - } - return - } - if time.Local.String() != path { - t.Errorf(`custom path should lead to path itself: got %q want %q`, time.Local, path) - } - - timeInUTC := time.Date(2009, 1, 1, 12, 0, 0, 0, time.UTC) - sameTimeInShanghai := time.Date(2009, 1, 1, 20, 0, 0, 0, time.Local) - if !timeInUTC.Equal(sameTimeInShanghai) { - t.Errorf("invalid timezone: got %q want %q", timeInUTC, sameTimeInShanghai) - } - - time.ResetLocalOnceForTest() - os.Setenv(env, ":"+path) - if time.Local.String() != path { - t.Errorf(`custom path should lead to path itself: got %q want %q`, time.Local, path) - } - - time.ResetLocalOnceForTest() - os.Setenv(env, path[:len(path)-1]) - if time.Local.String() != "UTC" { - t.Errorf(`invalid path should fallback to UTC: got %q want "UTC"`, time.Local) - } -} -//--to -func TestEnvTZUsage(t *testing.T) { - t.Skip("location is not supported in this environment") -} diff --git a/README.md b/README.md index 4233d81..b315084 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Hitsumabushi aims to make Go programs work on almost everywhere by overwriting s Now the generated JSON works only for Linux/Arm64 and Windows/Amd64 so far. For GOOS=windows, Hitsumabushi replaces some functions that don't work on some special Windows-like systems. -Go version: 1.18-1.19 (Linux), 1.19 (Windows) +Go version: 1.19-1.21 (Linux), 1.19-1.20 (Windows) ## Example diff --git a/overlay.go b/overlay.go index f65d4bc..a2f928e 100644 --- a/overlay.go +++ b/overlay.go @@ -30,15 +30,13 @@ type replaceString struct { } type config struct { - testPkgs []string - overlayDir string - os string - args []string - pageSize int - clockGettimeName string - futexName string - replaceDLLs []replaceString - overlay []replaceString + testPkgs []string + overlayDir string + os string + args []string + pageSize int + replaceDLLs []replaceString + overlay []replaceString } // TestPkg represents a package for testing. @@ -64,30 +62,6 @@ func Args(args ...string) Option { } } -// ReplaceClockGettime replaces the C function `clock_gettime` with the given name. -// If name is an empty string, the function is not replaced. -// This is useful for special environments where `clock_gettime` doesn't work correctly. -// -// ReplaceClockGettime works only for Linux. -// For Go 1.19 and newer, use Overlay and ClockFilePath. -func ReplaceClockGettime(name string) Option { - return func(cfg *config) { - cfg.clockGettimeName = name - } -} - -// ReplaceFutex replaces the system call `futex` with the given name. -// If name is an empty string, a pseudo futex implementation is used. -// This is useful for special environments where the pseudo `futex` doesn't work correctly. -// -// ReplaceFutex works only for Linux. -// For Go 1.19 and newer, use Overlay and FutexFilePath. -func ReplaceFutex(name string) Option { - return func(cfg *config) { - cfg.futexName = name - } -} - // GOOS specifies GOOS to generate the JSON. // The default value is runtime.GOOS. func GOOS(os string) Option { @@ -321,26 +295,6 @@ func goargs() { } } - // Replace clock_gettime. - if cfg.clockGettimeName != "" { - old := "#define clock_gettime clock_gettime" - new := fmt.Sprintf(`void %[1]s(clockid_t, struct timespec *); -#define clock_gettime %[1]s`, cfg.clockGettimeName) - if err := replace(tmpDir, replaces, "runtime/cgo", "gcc_linux_arm64.c", old, new, cfg.os); err != nil { - return nil, err - } - } - - // Replace futex. - if cfg.futexName != "" { - old := "#undef user_futex" - new := fmt.Sprintf(`int32_t %[1]s(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3); -#define user_futex %[1]s`, cfg.futexName) - if err := replace(tmpDir, replaces, "runtime/cgo", "gcc_linux_arm64.c", old, new, cfg.os); err != nil { - return nil, err - } - } - case "windows": // Replace the arguments. {