blob: 999f52cd75bdbf8a582574272944e12850c6b33b [file] [log] [blame]
khenaidoo5fc5cea2021-08-11 17:39:16 -04001//go:build !linux
2// +build !linux
3
4/*
5 *
6 * Copyright 2018 gRPC authors.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21
22// Package syscall provides functionalities that grpc uses to get low-level
23// operating system stats/info.
24package syscall
25
26import (
27 "net"
28 "sync"
29 "time"
30
31 "google.golang.org/grpc/grpclog"
32)
33
34var once sync.Once
35var logger = grpclog.Component("core")
36
37func log() {
38 once.Do(func() {
39 logger.Info("CPU time info is unavailable on non-linux environments.")
40 })
41}
42
43// GetCPUTime returns the how much CPU time has passed since the start of this
44// process. It always returns 0 under non-linux environments.
45func GetCPUTime() int64 {
46 log()
47 return 0
48}
49
50// Rusage is an empty struct under non-linux environments.
51type Rusage struct{}
52
53// GetRusage is a no-op function under non-linux environments.
54func GetRusage() *Rusage {
55 log()
56 return nil
57}
58
59// CPUTimeDiff returns the differences of user CPU time and system CPU time used
60// between two Rusage structs. It a no-op function for non-linux environments.
61func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
62 log()
63 return 0, 0
64}
65
66// SetTCPUserTimeout is a no-op function under non-linux environments.
67func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
68 log()
69 return nil
70}
71
72// GetTCPUserTimeout is a no-op function under non-linux environments.
73// A negative return value indicates the operation is not supported
74func GetTCPUserTimeout(conn net.Conn) (int, error) {
75 log()
76 return -1, nil
77}