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>
42 * @function sysctl_get_data_np
43 * A convenience routine for getting a sysctl(3) property whose size is not
44 * known at compile-time.
47 * An array describing the property to manipulate. This is a "management
48 * information base"-style descriptor, as described in sysctl(3).
51 * The number of items in the MIB array.
54 * On successful return, a pointer to a newly-allocated buffer. The caller is
55 * responsible for free(3)ing this buffer when it is no longer needed.
58 * On successful return, the length of the returned buffer.
61 * See the sysctl(3) man page for possible return codes.
63 DARWIN_API_AVAILABLE_20170407
64 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3 OS_NONNULL4
66 sysctl_get_data_np(int *mib
, size_t mib_cnt
, void **buff
, size_t *buff_len
);
69 * @function sysctlbyname_get_data_np
70 * A convenience routine for getting a sysctl(3) property whose size is not
71 * known at compile-time.
74 * An ASCII representation of the MIB vector describing the property to
75 * manipulate. Each element of the vector described is separated by a '.'
76 * character (e.g. "kern.ostype").
79 * On successful return, a pointer to a newly-allocated buffer. The caller is
80 * responsible for free(3)ing this buffer when it is no longer needed.
83 * On successful return, the length of the returned buffer.
86 * See the sysctl(3) man page for possible return codes.
88 DARWIN_API_AVAILABLE_20170407
89 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3
91 sysctlbyname_get_data_np(const char *mibdesc
, void **buff
, size_t *buff_len
);
94 * @function os_parse_boot_arg_int
95 * A routine for extracting a boot-arg as an integer value that is semantically
96 * similar to the PE_parse_boot_argn() kernel routine.
99 * The name of the boot-arg whose value is to be obtained. The caller may pass
100 * NULL to simply check for the existence of a boot-arg.
103 * On successful return, the integer value of the given boot-arg.
106 * A Boolean indicating whether the named argument was found. If the discovered
107 * argument value was not convertible to an integer according to the contract
108 * in strtoll(3), the implementation will return false.
111 * Boot-args are expressed with an '=' sign as a separator between the name and
112 * value of an argument, e.g. "cs_enforcement_disable=1".
114 DARWIN_API_AVAILABLE_20170407
115 OS_EXPORT OS_WARN_RESULT OS_NONNULL1
117 os_parse_boot_arg_int(const char *which
, int64_t *where
);
120 * @function os_parse_boot_arg_string
121 * A routine for extracting a boot-arg's string value that is semantically
122 * similar to the PE_parse_boot_argn() kernel routine.
125 * The name of the boot-arg whose value is to be obtained.
128 * The buffer in which to place the extracted value on successful return. The
129 * caller may pass NULL to simply check for the existence of a boot-arg.
132 * The length of the {@link where} buffer. May be zero if the caller only wishes
133 * to check for the existence of a boot-arg.
136 * A Boolean indicating whether the named argument was found.
138 DARWIN_API_AVAILABLE_20170407
139 OS_EXPORT OS_WARN_RESULT OS_NONNULL1
141 os_parse_boot_arg_string(const char *which
, char *where
, size_t maxlen
);
145 #endif // __DARWIN_BSD_H