...

Source file src/github.com/tklauser/numcpus/numcpus_solaris.go

Documentation: github.com/tklauser/numcpus

     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  
    15  //go:build solaris
    16  // +build solaris
    17  
    18  package numcpus
    19  
    20  import "golang.org/x/sys/unix"
    21  
    22  // taken from /usr/include/sys/unistd.h
    23  const (
    24  	_SC_NPROCESSORS_CONF = 14
    25  	_SC_NPROCESSORS_ONLN = 15
    26  	_SC_NPROCESSORS_MAX  = 516
    27  )
    28  
    29  func getConfigured() (int, error) {
    30  	n, err := unix.Sysconf(_SC_NPROCESSORS_CONF)
    31  	return int(n), err
    32  }
    33  
    34  func getKernelMax() (int, error) {
    35  	n, err := unix.Sysconf(_SC_NPROCESSORS_MAX)
    36  	return int(n), err
    37  }
    38  
    39  func getOffline() (int, error) {
    40  	return 0, ErrNotSupported
    41  }
    42  
    43  func getOnline() (int, error) {
    44  	n, err := unix.Sysconf(_SC_NPROCESSORS_ONLN)
    45  	return int(n), err
    46  }
    47  
    48  func getPossible() (int, error) {
    49  	n, err := unix.Sysconf(_SC_NPROCESSORS_CONF)
    50  	return int(n), err
    51  }
    52  
    53  func getPresent() (int, error) {
    54  	n, err := unix.Sysconf(_SC_NPROCESSORS_CONF)
    55  	return int(n), err
    56  }
    57  

View as plain text