blob: 9834f24ada62c58649c5b436399030a67bdd2c77 [file] [log] [blame]
Yue Gana6ae3e72016-04-05 09:00:22 +00001// Copyright 2016 The Bazel Authors. All rights reserved.
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
15package com.google.devtools.build.lib.unix;
16
17import com.google.devtools.build.lib.UnixJniLoader;
18
19import java.io.IOException;
20
21/**
22 * Utility methods for access to UNIX system calls not exposed by the Java
23 * SDK. Exception messages are selected to be consistent with those generated
24 * by the java.io package where appropriate--see package javadoc for details.
25 */
26public class NativePosixSystem {
27
28 private NativePosixSystem() {}
29
30 static {
31 if (!"0".equals(System.getProperty("io.bazel.UnixFileSystem"))) {
32 UnixJniLoader.loadJni();
33 }
34 }
35
36 /**
37 * Native wrapper around POSIX sysctlbyname(3) syscall.
38 *
39 * @param name the name for value to get from sysctl
40 * @throws IOException iff the sysctlbyname() syscall failed.
41 */
42 public static native long sysctlbynameGetLong(String name) throws IOException;
43}