diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-08-28 20:39:32 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-08-28 20:39:32 +0000 |
commit | 32b1d51f16fe56b34e979fcfba4bc74dbd3592a9 (patch) | |
tree | cd54b1786061eb18e64ce26e6392df3096b5ba35 /libgo/runtime | |
parent | c980510a5ab79614fcbaf5f411b1273dc9a8c7ca (diff) |
runtime: move osinit to Go
This is a step toward updating libgo to 1.13. This adds the 1.13
version of the osinit function to Go code, and removes the
corresponding code from the C runtime. This should simplify future updates.
Some additional 1.13 code was brought in to simplify this change.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191717
From-SVN: r275010
Diffstat (limited to 'libgo/runtime')
-rw-r--r-- | libgo/runtime/getncpu-aix.c | 15 | ||||
-rw-r--r-- | libgo/runtime/getncpu-bsd.c | 24 | ||||
-rw-r--r-- | libgo/runtime/getncpu-hurd.c | 16 | ||||
-rw-r--r-- | libgo/runtime/getncpu-irix.c | 16 | ||||
-rw-r--r-- | libgo/runtime/getncpu-linux.c | 36 | ||||
-rw-r--r-- | libgo/runtime/getncpu-none.c | 12 | ||||
-rw-r--r-- | libgo/runtime/getncpu-solaris.c | 16 | ||||
-rw-r--r-- | libgo/runtime/go-libmain.c | 3 | ||||
-rw-r--r-- | libgo/runtime/go-main.c | 3 | ||||
-rw-r--r-- | libgo/runtime/runtime.h | 8 |
10 files changed, 4 insertions, 145 deletions
diff --git a/libgo/runtime/getncpu-aix.c b/libgo/runtime/getncpu-aix.c deleted file mode 100644 index 064eed8570c..00000000000 --- a/libgo/runtime/getncpu-aix.c +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 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. - -#include <sys/types.h> -#include <sys/systemcfg.h> - -#include "runtime.h" -#include "defs.h" - -int32_t -getproccount(void) -{ - return _system_configuration.ncpus; -} diff --git a/libgo/runtime/getncpu-bsd.c b/libgo/runtime/getncpu-bsd.c deleted file mode 100644 index 00a81d1ddae..00000000000 --- a/libgo/runtime/getncpu-bsd.c +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 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. - -#include <sys/types.h> -#include <sys/sysctl.h> - -#include "runtime.h" -#include "defs.h" - -int32 -getproccount(void) -{ - int mib[2], out; - size_t len; - - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - len = sizeof(out); - if(sysctl(mib, 2, &out, &len, NULL, 0) >= 0) - return (int32)out; - else - return 0; -} diff --git a/libgo/runtime/getncpu-hurd.c b/libgo/runtime/getncpu-hurd.c deleted file mode 100644 index 5d5d7025dfe..00000000000 --- a/libgo/runtime/getncpu-hurd.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 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. - -#include <unistd.h> - -#include "runtime.h" -#include "defs.h" - -int32 -getproccount(void) -{ - int32 n; - n = (int32)sysconf(_SC_NPROCESSORS_ONLN); - return n > 1 ? n : 1; -} diff --git a/libgo/runtime/getncpu-irix.c b/libgo/runtime/getncpu-irix.c deleted file mode 100644 index a65ca63d2ae..00000000000 --- a/libgo/runtime/getncpu-irix.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 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. - -#include <unistd.h> - -#include "runtime.h" -#include "defs.h" - -int32 -getproccount(void) -{ - int32 n; - n = (int32)sysconf(_SC_NPROC_ONLN); - return n > 1 ? n : 1; -} diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c deleted file mode 100644 index de6606ff47c..00000000000 --- a/libgo/runtime/getncpu-linux.c +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 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. - -#include <features.h> -#include <sched.h> - -// CPU_COUNT is only provided by glibc 2.6 or higher -#ifndef CPU_COUNT -#define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int)) -static int _CPU_COUNT(unsigned int *set, size_t len) { - int cnt; - - cnt = 0; - while (len--) - cnt += __builtin_popcount(*set++); - return cnt; -} -#endif - -#include "runtime.h" -#include "defs.h" - -int32 -getproccount(void) -{ - cpu_set_t set; - int32 r, cnt; - - cnt = 0; - r = sched_getaffinity(0, sizeof(set), &set); - if(r == 0) - cnt += CPU_COUNT(&set); - - return cnt ? cnt : 1; -} diff --git a/libgo/runtime/getncpu-none.c b/libgo/runtime/getncpu-none.c deleted file mode 100644 index ba6fd4e689d..00000000000 --- a/libgo/runtime/getncpu-none.c +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 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. - -#include "runtime.h" -#include "defs.h" - -int32 -getproccount(void) -{ - return 0; -} diff --git a/libgo/runtime/getncpu-solaris.c b/libgo/runtime/getncpu-solaris.c deleted file mode 100644 index 5d5d7025dfe..00000000000 --- a/libgo/runtime/getncpu-solaris.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 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. - -#include <unistd.h> - -#include "runtime.h" -#include "defs.h" - -int32 -getproccount(void) -{ - int32 n; - n = (int32)sysconf(_SC_NPROCESSORS_ONLN); - return n > 1 ? n : 1; -} diff --git a/libgo/runtime/go-libmain.c b/libgo/runtime/go-libmain.c index f3795690e04..10b202bf8f8 100644 --- a/libgo/runtime/go-libmain.c +++ b/libgo/runtime/go-libmain.c @@ -228,8 +228,7 @@ gostart (void *arg) runtime_ginit (); runtime_check (); runtime_args (a->argc, (byte **) a->argv); - setncpu (getproccount ()); - setpagesize (getpagesize ()); + runtime_osinit (); runtime_schedinit (); __go_go ((uintptr)(runtime_main), NULL); runtime_mstart (runtime_m ()); diff --git a/libgo/runtime/go-main.c b/libgo/runtime/go-main.c index 51ce15fdbc1..dcf763af8c8 100644 --- a/libgo/runtime/go-main.c +++ b/libgo/runtime/go-main.c @@ -52,8 +52,7 @@ main (int argc, char **argv) runtime_cpuinit (); runtime_check (); runtime_args (argc, (byte **) argv); - setncpu (getproccount ()); - setpagesize (getpagesize ()); + runtime_osinit (); runtime_schedinit (); __go_go ((uintptr)(runtime_main), NULL); runtime_mstart (runtime_m ()); diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 6da7bdf497f..4102f5da0a0 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -211,6 +211,8 @@ void runtime_gogo(G*) struct __go_func_type; void runtime_args(int32, byte**) __asm__ (GOSYM_PREFIX "runtime.args"); +void runtime_osinit(void) + __asm__ (GOSYM_PREFIX "runtime.osinit"); void runtime_alginit(void) __asm__ (GOSYM_PREFIX "runtime.alginit"); void runtime_goargs(void) @@ -429,8 +431,6 @@ extern void __go_syminfo_fnname_callback(void*, uintptr_t, const char*, extern void runtime_main(void*) __asm__(GOSYM_PREFIX "runtime.main"); -int32 getproccount(void); - #define PREFETCH(p) __builtin_prefetch(p) void runtime_badsignal(int); @@ -456,12 +456,8 @@ extern void setSupportAES(bool) __asm__ (GOSYM_PREFIX "runtime.setSupportAES"); extern void typedmemmove(const Type *, void *, const void *) __asm__ (GOSYM_PREFIX "runtime.typedmemmove"); -extern void setncpu(int32) - __asm__(GOSYM_PREFIX "runtime.setncpu"); extern Sched* runtime_getsched(void) __asm__ (GOSYM_PREFIX "runtime.getsched"); -extern void setpagesize(uintptr_t) - __asm__(GOSYM_PREFIX "runtime.setpagesize"); struct funcfileline_return { |