]> git.saurik.com Git - apple/libc.git/blob - libdarwin/h/bsd.h
Libc-1353.41.1.tar.gz
[apple/libc.git] / libdarwin / h / bsd.h
1 /*
2 * Copyright (c) 2018 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*!
25 * @header
26 * Darwin-specific additions for FreeBSD APIs.
27 */
28 #ifndef __DARWIN_BSD_H
29 #define __DARWIN_BSD_H
30
31 #include <os/base.h>
32 #include <os/api.h>
33 #include <sys/cdefs.h>
34 #include <sys/errno.h>
35 #include <sys/types.h>
36 #include <stdint.h>
37 #include <stdbool.h>
38
39 __BEGIN_DECLS;
40
41 /*!
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.
45 *
46 * @param mib
47 * An array describing the property to manipulate. This is a "management
48 * information base"-style descriptor, as described in sysctl(3).
49 *
50 * @param mib_cnt
51 * The number of items in the MIB array.
52 *
53 * @param buff
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.
56 *
57 * @param buff_len
58 * On successful return, the length of the returned buffer.
59 *
60 * @result
61 * See the sysctl(3) man page for possible return codes.
62 */
63 DARWIN_API_AVAILABLE_20170407
64 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3 OS_NONNULL4
65 errno_t
66 sysctl_get_data_np(int *mib, size_t mib_cnt, void **buff, size_t *buff_len);
67
68 /*!
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.
72 *
73 * @param mibdesc
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").
77 *
78 * @param buff
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.
81 *
82 * @param buff_len
83 * On successful return, the length of the returned buffer.
84 *
85 * @result
86 * See the sysctl(3) man page for possible return codes.
87 */
88 DARWIN_API_AVAILABLE_20170407
89 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3
90 errno_t
91 sysctlbyname_get_data_np(const char *mibdesc, void **buff, size_t *buff_len);
92
93 /*!
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.
97 *
98 * @param which
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.
101 *
102 * @param where
103 * On successful return, the integer value of the given boot-arg.
104 *
105 * @result
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.
109 *
110 * @discussion
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".
113 */
114 DARWIN_API_AVAILABLE_20170407
115 OS_EXPORT OS_WARN_RESULT OS_NONNULL1
116 bool
117 os_parse_boot_arg_int(const char *which, int64_t *where);
118
119 /*!
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.
123 *
124 * @param which
125 * The name of the boot-arg whose value is to be obtained.
126 *
127 * @param where
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.
130 *
131 * @param maxlen
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.
134 *
135 * @result
136 * A Boolean indicating whether the named argument was found.
137 */
138 DARWIN_API_AVAILABLE_20170407
139 OS_EXPORT OS_WARN_RESULT OS_NONNULL1
140 bool
141 os_parse_boot_arg_string(const char *which, char *where, size_t maxlen);
142
143 __END_DECLS;
144
145 #endif // __DARWIN_BSD_H