numcpus_solaris.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2021 Tobias Klauser
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //go:build solaris
  15. // +build solaris
  16. package numcpus
  17. import "golang.org/x/sys/unix"
  18. // taken from /usr/include/sys/unistd.h
  19. const (
  20. _SC_NPROCESSORS_CONF = 14
  21. _SC_NPROCESSORS_ONLN = 15
  22. _SC_NPROCESSORS_MAX = 516
  23. )
  24. func getConfigured() (int, error) {
  25. n, err := unix.Sysconf(_SC_NPROCESSORS_CONF)
  26. return int(n), err
  27. }
  28. func getKernelMax() (int, error) {
  29. n, err := unix.Sysconf(_SC_NPROCESSORS_MAX)
  30. return int(n), err
  31. }
  32. func getOffline() (int, error) {
  33. return 0, ErrNotSupported
  34. }
  35. func getOnline() (int, error) {
  36. n, err := unix.Sysconf(_SC_NPROCESSORS_ONLN)
  37. return int(n), err
  38. }
  39. func getPossible() (int, error) {
  40. n, err := unix.Sysconf(_SC_NPROCESSORS_CONF)
  41. return int(n), err
  42. }
  43. func getPresent() (int, error) {
  44. n, err := unix.Sysconf(_SC_NPROCESSORS_CONF)
  45. return int(n), err
  46. }