2 * Copyright (c) 2018 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 * Darwin-specific additions for FreeBSD APIs.
28 #ifndef __DARWIN_BSD_H
29 #define __DARWIN_BSD_H
33 #include <sys/cdefs.h>
34 #include <sys/errno.h>
35 #include <sys/types.h>
46 * @function sysctl_get_data_np
47 * A convenience routine for getting a sysctl(3) property whose size is not
48 * known at compile-time.
51 * An array describing the property to manipulate. This is a "management
52 * information base"-style descriptor, as described in sysctl(3).
55 * The number of items in the MIB array.
58 * On successful return, a pointer to a newly-allocated buffer. The caller is
59 * responsible for free(3)ing this buffer when it is no longer needed.
62 * On successful return, the length of the returned buffer.
65 * See the sysctl(3) man page for possible return codes.
67 DARWIN_API_AVAILABLE_20170407
68 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3 OS_NONNULL4
70 sysctl_get_data_np(int *mib
, size_t mib_cnt
, void **buff
, size_t *buff_len
);
73 * @function sysctlbyname_get_data_np
74 * A convenience routine for getting a sysctl(3) property whose size is not
75 * known at compile-time.
78 * An ASCII representation of the MIB vector describing the property to
79 * manipulate. Each element of the vector described is separated by a '.'
80 * character (e.g. "kern.ostype").
83 * On successful return, a pointer to a newly-allocated buffer. The caller is
84 * responsible for free(3)ing this buffer when it is no longer needed.
87 * On successful return, the length of the returned buffer.
90 * See the sysctl(3) man page for possible return codes.
92 DARWIN_API_AVAILABLE_20170407
93 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3
95 sysctlbyname_get_data_np(const char *mibdesc
, void **buff
, size_t *buff_len
);
98 * @function os_parse_boot_arg_int
99 * A routine for extracting a boot-arg as an integer value that is semantically
100 * similar to the PE_parse_boot_argn() kernel routine.
103 * The name of the boot-arg whose value is to be obtained.
106 * On successful return, the integer value of the given boot-arg. The caller
107 * may pass NULL to simply check for the existence of a boot-arg.
110 * A Boolean indicating whether the named argument was found. If the discovered
111 * argument value was not convertible to an integer according to the contract
112 * in strtoll(3), the implementation will return false.
115 * Boot-args are expressed with an '=' sign as a separator between the name and
116 * value of an argument, e.g. "cs_enforcement_disable=1".
118 DARWIN_API_AVAILABLE_20170407
119 OS_EXPORT OS_WARN_RESULT OS_NONNULL1
121 os_parse_boot_arg_int(const char *which
, int64_t *where
);
124 * @function os_parse_boot_arg_string
125 * A routine for extracting a boot-arg's string value that is semantically
126 * similar to the PE_parse_boot_argn() kernel routine.
129 * The name of the boot-arg whose value is to be obtained.
132 * The buffer in which to place the extracted value on successful return. The
133 * caller may pass NULL to simply check for the existence of a boot-arg.
136 * The length of the {@link where} buffer. May be zero if the caller only wishes
137 * to check for the existence of a boot-arg.
140 * A Boolean indicating whether the named argument was found.
142 DARWIN_API_AVAILABLE_20170407
143 OS_EXPORT OS_WARN_RESULT OS_NONNULL1
145 os_parse_boot_arg_string(const char *which
, char *where
, size_t maxlen
);
149 #endif // __DARWIN_BSD_H