1 // This module contains bindings to the native Haiku API. The Haiku API
2 // originates from BeOS, and it was the original way to perform low level
3 // system and IO operations. The POSIX API was in that era was like a
4 // compatibility layer. In current Haiku development, both the POSIX API and
5 // the Haiku API are considered to be co-equal status. However, they are not
6 // integrated like they are on other UNIX platforms, which means that for many
7 // low level concepts there are two versions, like processes (POSIX) and
8 // teams (Haiku), or pthreads and native threads.
9 //
10 // Both the POSIX API and the Haiku API live in libroot.so, the library that is
11 // linked to any binary by default.
12 //
13 // This file follows the Haiku API for Haiku R1 beta 2. It is organized by the
14 // C/C++ header files in which the concepts can be found, while adhering to the
15 // style guide for this crate.
16 
17 // Helper macro to generate u32 constants. The Haiku API uses (non-standard)
18 // multi-character constants (like 'UPDA' or 'MSGM') to represent 32 bit
19 // integer constants.
20 
21 macro_rules! haiku_constant {
22     ($a:tt, $b:tt, $c:tt, $d:tt) => {
23         (($a as u32) << 24) + (($b as u32) << 16) + (($c as u32) << 8) + ($d as u32)
24     };
25 }
26 
27 // support/SupportDefs.h
28 pub type status_t = i32;
29 pub type bigtime_t = i64;
30 pub type nanotime_t = i64;
31 pub type type_code = u32;
32 pub type perform_code = u32;
33 
34 // kernel/OS.h
35 pub type area_id = i32;
36 pub type port_id = i32;
37 pub type sem_id = i32;
38 pub type team_id = i32;
39 pub type thread_id = i32;
40 
41 pub type thread_func = extern "C" fn(*mut ::c_void) -> status_t;
42 
43 // kernel/image.h
44 pub type image_id = i32;
45 
46 e! {
47     // kernel/OS.h
48     pub enum thread_state {
49         B_THREAD_RUNNING = 1,
50         B_THREAD_READY,
51         B_THREAD_RECEIVING,
52         B_THREAD_ASLEEP,
53         B_THREAD_SUSPENDED,
54         B_THREAD_WAITING
55     }
56 
57     // kernel/image.h
58     pub enum image_type {
59         B_APP_IMAGE = 1,
60         B_LIBRARY_IMAGE,
61         B_ADD_ON_IMAGE,
62         B_SYSTEM_IMAGE
63     }
64 }
65 
66 s! {
67     // kernel/OS.h
68     pub struct area_info {
69         pub area: area_id,
70         pub name: [::c_char; B_OS_NAME_LENGTH],
71         pub size: usize,
72         pub lock: u32,
73         pub protection: u32,
74         pub team: team_id,
75         pub ram_size: u32,
76         pub copy_count: u32,
77         pub in_count: u32,
78         pub out_count: u32,
79         pub address: *mut ::c_void
80     }
81 
82     pub struct port_info {
83         pub port: port_id,
84         pub team: team_id,
85         pub name: [::c_char; B_OS_NAME_LENGTH],
86         pub capacity: i32,
87         pub queue_count: i32,
88         pub total_count: i32,
89     }
90 
91     pub struct port_message_info {
92         pub size: ::size_t,
93         pub sender: ::uid_t,
94         pub sender_group: ::gid_t,
95         pub sender_team: ::team_id
96     }
97 
98     pub struct team_info {
99         team: team_id,
100         thread_count: i32,
101         image_count: i32,
102         area_count: i32,
103         debugger_nub_thread: thread_id,
104         debugger_nub_port: port_id,
105         argc: i32,
106         args: [::c_char; 64],
107         uid: ::uid_t,
108         gid: ::gid_t
109     }
110 
111     pub struct sem_info {
112         sem: sem_id,
113         team: team_id,
114         name: [::c_char; B_OS_NAME_LENGTH],
115         count: i32,
116         latest_holder: thread_id
117     }
118 
119     pub struct team_usage_info {
120         user_time: bigtime_t,
121         kernel_time: bigtime_t
122     }
123 
124     pub struct thread_info {
125         pub thread: thread_id,
126         pub team: team_id,
127         pub name: [::c_char; B_OS_NAME_LENGTH],
128         pub state: thread_state,
129         pub priority: i32,
130         pub sem: sem_id,
131         pub user_time: bigtime_t,
132         pub kernel_time: bigtime_t,
133         pub stack_base: *mut ::c_void,
134         pub stack_end: *mut ::c_void
135     }
136 
137     pub struct cpu_info {
138         pub active_time: bigtime_t,
139         pub enabled: bool
140     }
141 
142     pub struct system_info {
143         pub boot_time: bigtime_t,
144         pub cpu_count: u32,
145         pub max_pages: u64,
146         pub used_pages: u64,
147         pub cached_pages: u64,
148         pub block_cache_pages: u64,
149         pub ignored_pages: u64,
150         pub needed_memory: u64,
151         pub free_memory: u64,
152         pub max_swap_pages: u64,
153         pub free_swap_pages: u64,
154         pub page_faults: u32,
155         pub max_sems: u32,
156         pub used_sems: u32,
157         pub max_ports: u32,
158         pub used_ports: u32,
159         pub max_threads: u32,
160         pub used_threads: u32,
161         pub max_teams: u32,
162         pub used_teams: u32,
163         pub kernel_name: [::c_char; B_FILE_NAME_LENGTH],
164         pub kernel_build_date: [::c_char; B_OS_NAME_LENGTH],
165         pub kernel_build_time: [::c_char; B_OS_NAME_LENGTH],
166         pub kernel_version: i64,
167         pub abi: u32
168     }
169 
170     pub struct object_wait_info {
171         pub object: i32,
172         pub type_: u16,
173         pub events: u16
174     }
175 
176     // kernel/fs_attr.h
177     pub struct attr_info {
178         type_: u32,
179         size: ::off_t
180     }
181 
182     // kernel/fs_index.h
183     pub struct index_info {
184         type_: u32,
185         size: ::off_t,
186         modification_time: ::time_t,
187         creation_time: ::time_t,
188         uid: ::uid_t,
189         gid: ::gid_t
190     }
191 
192     //kernel/fs_info.h
193     pub struct fs_info {
194         dev: ::dev_t,
195         root: ::ino_t,
196         flags: u32,
197         block_size: ::off_t,
198         io_size: ::off_t,
199         total_blocks: ::off_t,
200         free_blocks: ::off_t,
201         total_nodes: ::off_t,
202         free_nodes: ::off_t,
203         device_name: [::c_char; 128],
204         volume_name: [::c_char; B_FILE_NAME_LENGTH],
205         fsh_name: [::c_char; B_OS_NAME_LENGTH]
206     }
207 
208     // kernel/image.h
209     pub struct image_info {
210         pub id: image_id,
211         pub image_type: ::c_int,
212         pub sequence: i32,
213         pub init_order: i32,
214         pub init_routine: extern "C" fn(),
215         pub term_routine: extern "C" fn(),
216         pub device: ::dev_t,
217         pub node: ::ino_t,
218         pub name: [::c_char; ::PATH_MAX as usize],
219         pub text: *mut ::c_void,
220         pub data: *mut ::c_void,
221         pub text_size: i32,
222         pub data_size: i32,
223         pub api_version: i32,
224         pub abi: i32
225     }
226 }
227 
228 // kernel/OS.h
229 pub const B_OS_NAME_LENGTH: usize = 32;
230 pub const B_PAGE_SIZE: usize = 4096;
231 pub const B_INFINITE_TIMEOUT: usize = 9223372036854775807;
232 
233 pub const B_RELATIVE_TIMEOUT: u32 = 0x8;
234 pub const B_ABSOLUTE_TIMEOUT: u32 = 0x10;
235 pub const B_TIMEOUT_REAL_TIME_BASE: u32 = 0x40;
236 pub const B_ABSOLUTE_REAL_TIME_TIMEOUT: u32 = B_ABSOLUTE_TIMEOUT | B_TIMEOUT_REAL_TIME_BASE;
237 
238 pub const B_NO_LOCK: u32 = 0;
239 pub const B_LAZY_LOCK: u32 = 1;
240 pub const B_FULL_LOCK: u32 = 2;
241 pub const B_CONTIGUOUS: u32 = 3;
242 pub const B_LOMEM: u32 = 4;
243 pub const B_32_BIT_FULL_LOCK: u32 = 5;
244 pub const B_32_BIT_CONTIGUOUS: u32 = 6;
245 
246 pub const B_ANY_ADDRESS: u32 = 0;
247 pub const B_EXACT_ADDRESS: u32 = 1;
248 pub const B_BASE_ADDRESS: u32 = 2;
249 pub const B_CLONE_ADDRESS: u32 = 3;
250 pub const B_ANY_KERNEL_ADDRESS: u32 = 4;
251 pub const B_RANDOMIZED_ANY_ADDRESS: u32 = 6;
252 pub const B_RANDOMIZED_BASE_ADDRESS: u32 = 7;
253 
254 pub const B_READ_AREA: u32 = 1 << 0;
255 pub const B_WRITE_AREA: u32 = 1 << 1;
256 pub const B_EXECUTE_AREA: u32 = 1 << 2;
257 pub const B_STACK_AREA: u32 = 1 << 3;
258 pub const B_CLONEABLE_AREA: u32 = 1 << 8;
259 
260 pub const B_CAN_INTERRUPT: u32 = 0x01;
261 pub const B_CHECK_PERMISSION: u32 = 0x04;
262 pub const B_KILL_CAN_INTERRUPT: u32 = 0x20;
263 pub const B_DO_NOT_RESCHEDULE: u32 = 0x02;
264 pub const B_RELEASE_ALL: u32 = 0x08;
265 pub const B_RELEASE_IF_WAITING_ONLY: u32 = 0x10;
266 
267 pub const B_CURRENT_TEAM: team_id = 0;
268 pub const B_SYSTEM_TEAM: team_id = 1;
269 
270 pub const B_TEAM_USAGE_SELF: i32 = 0;
271 pub const B_TEAM_USAGE_CHILDREN: i32 = -1;
272 
273 pub const B_IDLE_PRIORITY: i32 = 0;
274 pub const B_LOWEST_ACTIVE_PRIORITY: i32 = 1;
275 pub const B_LOW_PRIORITY: i32 = 5;
276 pub const B_NORMAL_PRIORITY: i32 = 10;
277 pub const B_DISPLAY_PRIORITY: i32 = 15;
278 pub const B_URGENT_DISPLAY_PRIORITY: i32 = 20;
279 pub const B_REAL_TIME_DISPLAY_PRIORITY: i32 = 100;
280 pub const B_URGENT_PRIORITY: i32 = 110;
281 pub const B_REAL_TIME_PRIORITY: i32 = 120;
282 
283 pub const B_SYSTEM_TIMEBASE: i32 = 0;
284 pub const B_FIRST_REAL_TIME_PRIORITY: i32 = B_REAL_TIME_DISPLAY_PRIORITY;
285 
286 pub const B_ONE_SHOT_ABSOLUTE_ALARM: u32 = 1;
287 pub const B_ONE_SHOT_RELATIVE_ALARM: u32 = 2;
288 pub const B_PERIODIC_ALARM: u32 = 3;
289 
290 pub const B_OBJECT_TYPE_FD: u16 = 0;
291 pub const B_OBJECT_TYPE_SEMAPHORE: u16 = 1;
292 pub const B_OBJECT_TYPE_PORT: u16 = 2;
293 pub const B_OBJECT_TYPE_THREAD: u16 = 3;
294 
295 pub const B_EVENT_READ: u16 = 0x0001;
296 pub const B_EVENT_WRITE: u16 = 0x0002;
297 pub const B_EVENT_ERROR: u16 = 0x0004;
298 pub const B_EVENT_PRIORITY_READ: u16 = 0x0008;
299 pub const B_EVENT_PRIORITY_WRITE: u16 = 0x0010;
300 pub const B_EVENT_HIGH_PRIORITY_READ: u16 = 0x0020;
301 pub const B_EVENT_HIGH_PRIORITY_WRITE: u16 = 0x0040;
302 pub const B_EVENT_DISCONNECTED: u16 = 0x0080;
303 pub const B_EVENT_ACQUIRE_SEMAPHORE: u16 = 0x0001;
304 pub const B_EVENT_INVALID: u16 = 0x1000;
305 
306 // kernel/fs_info.h
307 pub const B_FS_IS_READONLY: u32 = 0x00000001;
308 pub const B_FS_IS_REMOVABLE: u32 = 0x00000002;
309 pub const B_FS_IS_PERSISTENT: u32 = 0x00000004;
310 pub const B_FS_IS_SHARED: u32 = 0x00000008;
311 pub const B_FS_HAS_MIME: u32 = 0x00010000;
312 pub const B_FS_HAS_ATTR: u32 = 0x00020000;
313 pub const B_FS_HAS_QUERY: u32 = 0x00040000;
314 pub const B_FS_HAS_SELF_HEALING_LINKS: u32 = 0x00080000;
315 pub const B_FS_HAS_ALIASES: u32 = 0x00100000;
316 pub const B_FS_SUPPORTS_NODE_MONITORING: u32 = 0x00200000;
317 pub const B_FS_SUPPORTS_MONITOR_CHILDREN: u32 = 0x00400000;
318 
319 // kernel/fs_query.h
320 pub const B_LIVE_QUERY: u32 = 0x00000001;
321 pub const B_QUERY_NON_INDEXED: u32 = 0x00000002;
322 
323 // kernel/fs_volume.h
324 pub const B_MOUNT_READ_ONLY: u32 = 1;
325 pub const B_MOUNT_VIRTUAL_DEVICE: u32 = 2;
326 pub const B_FORCE_UNMOUNT: u32 = 1;
327 
328 // kernel/image.h
329 pub const B_FLUSH_DCACHE: u32 = 0x0001;
330 pub const B_FLUSH_ICACHE: u32 = 0x0004;
331 pub const B_INVALIDATE_DCACHE: u32 = 0x0002;
332 pub const B_INVALIDATE_ICACHE: u32 = 0x0008;
333 
334 pub const B_SYMBOL_TYPE_DATA: i32 = 0x1;
335 pub const B_SYMBOL_TYPE_TEXT: i32 = 0x2;
336 pub const B_SYMBOL_TYPE_ANY: i32 = 0x5;
337 
338 // storage/StorageDefs.h
339 pub const B_DEV_NAME_LENGTH: usize = 128;
340 pub const B_FILE_NAME_LENGTH: usize = ::FILENAME_MAX as usize;
341 pub const B_PATH_NAME_LENGTH: usize = ::PATH_MAX as usize;
342 pub const B_ATTR_NAME_LENGTH: usize = B_FILE_NAME_LENGTH - 1;
343 pub const B_MIME_TYPE_LENGTH: usize = B_ATTR_NAME_LENGTH - 15;
344 pub const B_MAX_SYMLINKS: usize = 16;
345 
346 // Haiku open modes in BFile are passed as u32
347 pub const B_READ_ONLY: u32 = ::O_RDONLY as u32;
348 pub const B_WRITE_ONLY: u32 = ::O_WRONLY as u32;
349 pub const B_READ_WRITE: u32 = ::O_RDWR as u32;
350 
351 pub const B_FAIL_IF_EXISTS: u32 = ::O_EXCL as u32;
352 pub const B_CREATE_FILE: u32 = ::O_CREAT as u32;
353 pub const B_ERASE_FILE: u32 = ::O_TRUNC as u32;
354 pub const B_OPEN_AT_END: u32 = ::O_APPEND as u32;
355 
356 pub const B_FILE_NODE: u32 = 0x01;
357 pub const B_SYMLINK_NODE: u32 = 0x02;
358 pub const B_DIRECTORY_NODE: u32 = 0x04;
359 pub const B_ANY_NODE: u32 = 0x07;
360 
361 // support/Errors.h
362 pub const B_GENERAL_ERROR_BASE: status_t = core::i32::MIN;
363 pub const B_OS_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x1000;
364 pub const B_APP_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x2000;
365 pub const B_INTERFACE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x3000;
366 pub const B_MEDIA_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x4000;
367 pub const B_TRANSLATION_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x4800;
368 pub const B_MIDI_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x5000;
369 pub const B_STORAGE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x6000;
370 pub const B_POSIX_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x7000;
371 pub const B_MAIL_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x8000;
372 pub const B_PRINT_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x9000;
373 pub const B_DEVICE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0xa000;
374 pub const B_ERRORS_END: status_t = B_GENERAL_ERROR_BASE + 0xffff;
375 
376 // General errors
377 pub const B_NO_MEMORY: status_t = B_GENERAL_ERROR_BASE + 0;
378 pub const B_IO_ERROR: status_t = B_GENERAL_ERROR_BASE + 1;
379 pub const B_PERMISSION_DENIED: status_t = B_GENERAL_ERROR_BASE + 2;
380 pub const B_BAD_INDEX: status_t = B_GENERAL_ERROR_BASE + 3;
381 pub const B_BAD_TYPE: status_t = B_GENERAL_ERROR_BASE + 4;
382 pub const B_BAD_VALUE: status_t = B_GENERAL_ERROR_BASE + 5;
383 pub const B_MISMATCHED_VALUES: status_t = B_GENERAL_ERROR_BASE + 6;
384 pub const B_NAME_NOT_FOUND: status_t = B_GENERAL_ERROR_BASE + 7;
385 pub const B_NAME_IN_USE: status_t = B_GENERAL_ERROR_BASE + 8;
386 pub const B_TIMED_OUT: status_t = B_GENERAL_ERROR_BASE + 9;
387 pub const B_INTERRUPTED: status_t = B_GENERAL_ERROR_BASE + 10;
388 pub const B_WOULD_BLOCK: status_t = B_GENERAL_ERROR_BASE + 11;
389 pub const B_CANCELED: status_t = B_GENERAL_ERROR_BASE + 12;
390 pub const B_NO_INIT: status_t = B_GENERAL_ERROR_BASE + 13;
391 pub const B_NOT_INITIALIZED: status_t = B_GENERAL_ERROR_BASE + 13;
392 pub const B_BUSY: status_t = B_GENERAL_ERROR_BASE + 14;
393 pub const B_NOT_ALLOWED: status_t = B_GENERAL_ERROR_BASE + 15;
394 pub const B_BAD_DATA: status_t = B_GENERAL_ERROR_BASE + 16;
395 pub const B_DONT_DO_THAT: status_t = B_GENERAL_ERROR_BASE + 17;
396 
397 pub const B_ERROR: status_t = -1;
398 pub const B_OK: status_t = 0;
399 pub const B_NO_ERROR: status_t = 0;
400 
401 // Kernel kit errors
402 pub const B_BAD_SEM_ID: status_t = B_OS_ERROR_BASE + 0;
403 pub const B_NO_MORE_SEMS: status_t = B_OS_ERROR_BASE + 1;
404 
405 pub const B_BAD_THREAD_ID: status_t = B_OS_ERROR_BASE + 0x100;
406 pub const B_NO_MORE_THREADS: status_t = B_OS_ERROR_BASE + 0x101;
407 pub const B_BAD_THREAD_STATE: status_t = B_OS_ERROR_BASE + 0x102;
408 pub const B_BAD_TEAM_ID: status_t = B_OS_ERROR_BASE + 0x103;
409 pub const B_NO_MORE_TEAMS: status_t = B_OS_ERROR_BASE + 0x104;
410 
411 pub const B_BAD_PORT_ID: status_t = B_OS_ERROR_BASE + 0x200;
412 pub const B_NO_MORE_PORTS: status_t = B_OS_ERROR_BASE + 0x201;
413 
414 pub const B_BAD_IMAGE_ID: status_t = B_OS_ERROR_BASE + 0x300;
415 pub const B_BAD_ADDRESS: status_t = B_OS_ERROR_BASE + 0x301;
416 pub const B_NOT_AN_EXECUTABLE: status_t = B_OS_ERROR_BASE + 0x302;
417 pub const B_MISSING_LIBRARY: status_t = B_OS_ERROR_BASE + 0x303;
418 pub const B_MISSING_SYMBOL: status_t = B_OS_ERROR_BASE + 0x304;
419 pub const B_UNKNOWN_EXECUTABLE: status_t = B_OS_ERROR_BASE + 0x305;
420 pub const B_LEGACY_EXECUTABLE: status_t = B_OS_ERROR_BASE + 0x306;
421 
422 pub const B_DEBUGGER_ALREADY_INSTALLED: status_t = B_OS_ERROR_BASE + 0x400;
423 
424 // Application kit errors
425 pub const B_BAD_REPLY: status_t = B_APP_ERROR_BASE + 0;
426 pub const B_DUPLICATE_REPLY: status_t = B_APP_ERROR_BASE + 1;
427 pub const B_MESSAGE_TO_SELF: status_t = B_APP_ERROR_BASE + 2;
428 pub const B_BAD_HANDLER: status_t = B_APP_ERROR_BASE + 3;
429 pub const B_ALREADY_RUNNING: status_t = B_APP_ERROR_BASE + 4;
430 pub const B_LAUNCH_FAILED: status_t = B_APP_ERROR_BASE + 5;
431 pub const B_AMBIGUOUS_APP_LAUNCH: status_t = B_APP_ERROR_BASE + 6;
432 pub const B_UNKNOWN_MIME_TYPE: status_t = B_APP_ERROR_BASE + 7;
433 pub const B_BAD_SCRIPT_SYNTAX: status_t = B_APP_ERROR_BASE + 8;
434 pub const B_LAUNCH_FAILED_NO_RESOLVE_LINK: status_t = B_APP_ERROR_BASE + 9;
435 pub const B_LAUNCH_FAILED_EXECUTABLE: status_t = B_APP_ERROR_BASE + 10;
436 pub const B_LAUNCH_FAILED_APP_NOT_FOUND: status_t = B_APP_ERROR_BASE + 11;
437 pub const B_LAUNCH_FAILED_APP_IN_TRASH: status_t = B_APP_ERROR_BASE + 12;
438 pub const B_LAUNCH_FAILED_NO_PREFERRED_APP: status_t = B_APP_ERROR_BASE + 13;
439 pub const B_LAUNCH_FAILED_FILES_APP_NOT_FOUND: status_t = B_APP_ERROR_BASE + 14;
440 pub const B_BAD_MIME_SNIFFER_RULE: status_t = B_APP_ERROR_BASE + 15;
441 pub const B_NOT_A_MESSAGE: status_t = B_APP_ERROR_BASE + 16;
442 pub const B_SHUTDOWN_CANCELLED: status_t = B_APP_ERROR_BASE + 17;
443 pub const B_SHUTTING_DOWN: status_t = B_APP_ERROR_BASE + 18;
444 
445 // Storage kit errors
446 pub const B_FILE_ERROR: status_t = B_STORAGE_ERROR_BASE + 0;
447 pub const B_FILE_NOT_FOUND: status_t = B_STORAGE_ERROR_BASE + 1;
448 pub const B_FILE_EXISTS: status_t = B_STORAGE_ERROR_BASE + 2;
449 pub const B_ENTRY_NOT_FOUND: status_t = B_STORAGE_ERROR_BASE + 3;
450 pub const B_NAME_TOO_LONG: status_t = B_STORAGE_ERROR_BASE + 4;
451 pub const B_NOT_A_DIRECTORY: status_t = B_STORAGE_ERROR_BASE + 5;
452 pub const B_DIRECTORY_NOT_EMPTY: status_t = B_STORAGE_ERROR_BASE + 6;
453 pub const B_DEVICE_FULL: status_t = B_STORAGE_ERROR_BASE + 7;
454 pub const B_READ_ONLY_DEVICE: status_t = B_STORAGE_ERROR_BASE + 8;
455 pub const B_IS_A_DIRECTORY: status_t = B_STORAGE_ERROR_BASE + 9;
456 pub const B_NO_MORE_FDS: status_t = B_STORAGE_ERROR_BASE + 10;
457 pub const B_CROSS_DEVICE_LINK: status_t = B_STORAGE_ERROR_BASE + 11;
458 pub const B_LINK_LIMIT: status_t = B_STORAGE_ERROR_BASE + 12;
459 pub const B_BUSTED_PIPE: status_t = B_STORAGE_ERROR_BASE + 13;
460 pub const B_UNSUPPORTED: status_t = B_STORAGE_ERROR_BASE + 14;
461 pub const B_PARTITION_TOO_SMALL: status_t = B_STORAGE_ERROR_BASE + 15;
462 pub const B_PARTIAL_READ: status_t = B_STORAGE_ERROR_BASE + 16;
463 pub const B_PARTIAL_WRITE: status_t = B_STORAGE_ERROR_BASE + 17;
464 
465 // Mapped posix errors
466 pub const B_BUFFER_OVERFLOW: status_t = ::EOVERFLOW;
467 pub const B_TOO_MANY_ARGS: status_t = ::E2BIG;
468 pub const B_FILE_TOO_LARGE: status_t = ::EFBIG;
469 pub const B_RESULT_NOT_REPRESENTABLE: status_t = ::ERANGE;
470 pub const B_DEVICE_NOT_FOUND: status_t = ::ENODEV;
471 pub const B_NOT_SUPPORTED: status_t = ::EOPNOTSUPP;
472 
473 // Media kit errors
474 pub const B_STREAM_NOT_FOUND: status_t = B_MEDIA_ERROR_BASE + 0;
475 pub const B_SERVER_NOT_FOUND: status_t = B_MEDIA_ERROR_BASE + 1;
476 pub const B_RESOURCE_NOT_FOUND: status_t = B_MEDIA_ERROR_BASE + 2;
477 pub const B_RESOURCE_UNAVAILABLE: status_t = B_MEDIA_ERROR_BASE + 3;
478 pub const B_BAD_SUBSCRIBER: status_t = B_MEDIA_ERROR_BASE + 4;
479 pub const B_SUBSCRIBER_NOT_ENTERED: status_t = B_MEDIA_ERROR_BASE + 5;
480 pub const B_BUFFER_NOT_AVAILABLE: status_t = B_MEDIA_ERROR_BASE + 6;
481 pub const B_LAST_BUFFER_ERROR: status_t = B_MEDIA_ERROR_BASE + 7;
482 
483 pub const B_MEDIA_SYSTEM_FAILURE: status_t = B_MEDIA_ERROR_BASE + 100;
484 pub const B_MEDIA_BAD_NODE: status_t = B_MEDIA_ERROR_BASE + 101;
485 pub const B_MEDIA_NODE_BUSY: status_t = B_MEDIA_ERROR_BASE + 102;
486 pub const B_MEDIA_BAD_FORMAT: status_t = B_MEDIA_ERROR_BASE + 103;
487 pub const B_MEDIA_BAD_BUFFER: status_t = B_MEDIA_ERROR_BASE + 104;
488 pub const B_MEDIA_TOO_MANY_NODES: status_t = B_MEDIA_ERROR_BASE + 105;
489 pub const B_MEDIA_TOO_MANY_BUFFERS: status_t = B_MEDIA_ERROR_BASE + 106;
490 pub const B_MEDIA_NODE_ALREADY_EXISTS: status_t = B_MEDIA_ERROR_BASE + 107;
491 pub const B_MEDIA_BUFFER_ALREADY_EXISTS: status_t = B_MEDIA_ERROR_BASE + 108;
492 pub const B_MEDIA_CANNOT_SEEK: status_t = B_MEDIA_ERROR_BASE + 109;
493 pub const B_MEDIA_CANNOT_CHANGE_RUN_MODE: status_t = B_MEDIA_ERROR_BASE + 110;
494 pub const B_MEDIA_APP_ALREADY_REGISTERED: status_t = B_MEDIA_ERROR_BASE + 111;
495 pub const B_MEDIA_APP_NOT_REGISTERED: status_t = B_MEDIA_ERROR_BASE + 112;
496 pub const B_MEDIA_CANNOT_RECLAIM_BUFFERS: status_t = B_MEDIA_ERROR_BASE + 113;
497 pub const B_MEDIA_BUFFERS_NOT_RECLAIMED: status_t = B_MEDIA_ERROR_BASE + 114;
498 pub const B_MEDIA_TIME_SOURCE_STOPPED: status_t = B_MEDIA_ERROR_BASE + 115;
499 pub const B_MEDIA_TIME_SOURCE_BUSY: status_t = B_MEDIA_ERROR_BASE + 116;
500 pub const B_MEDIA_BAD_SOURCE: status_t = B_MEDIA_ERROR_BASE + 117;
501 pub const B_MEDIA_BAD_DESTINATION: status_t = B_MEDIA_ERROR_BASE + 118;
502 pub const B_MEDIA_ALREADY_CONNECTED: status_t = B_MEDIA_ERROR_BASE + 119;
503 pub const B_MEDIA_NOT_CONNECTED: status_t = B_MEDIA_ERROR_BASE + 120;
504 pub const B_MEDIA_BAD_CLIP_FORMAT: status_t = B_MEDIA_ERROR_BASE + 121;
505 pub const B_MEDIA_ADDON_FAILED: status_t = B_MEDIA_ERROR_BASE + 122;
506 pub const B_MEDIA_ADDON_DISABLED: status_t = B_MEDIA_ERROR_BASE + 123;
507 pub const B_MEDIA_CHANGE_IN_PROGRESS: status_t = B_MEDIA_ERROR_BASE + 124;
508 pub const B_MEDIA_STALE_CHANGE_COUNT: status_t = B_MEDIA_ERROR_BASE + 125;
509 pub const B_MEDIA_ADDON_RESTRICTED: status_t = B_MEDIA_ERROR_BASE + 126;
510 pub const B_MEDIA_NO_HANDLER: status_t = B_MEDIA_ERROR_BASE + 127;
511 pub const B_MEDIA_DUPLICATE_FORMAT: status_t = B_MEDIA_ERROR_BASE + 128;
512 pub const B_MEDIA_REALTIME_DISABLED: status_t = B_MEDIA_ERROR_BASE + 129;
513 pub const B_MEDIA_REALTIME_UNAVAILABLE: status_t = B_MEDIA_ERROR_BASE + 130;
514 
515 // Mail kit errors
516 pub const B_MAIL_NO_DAEMON: status_t = B_MAIL_ERROR_BASE + 0;
517 pub const B_MAIL_UNKNOWN_USER: status_t = B_MAIL_ERROR_BASE + 1;
518 pub const B_MAIL_WRONG_PASSWORD: status_t = B_MAIL_ERROR_BASE + 2;
519 pub const B_MAIL_UNKNOWN_HOST: status_t = B_MAIL_ERROR_BASE + 3;
520 pub const B_MAIL_ACCESS_ERROR: status_t = B_MAIL_ERROR_BASE + 4;
521 pub const B_MAIL_UNKNOWN_FIELD: status_t = B_MAIL_ERROR_BASE + 5;
522 pub const B_MAIL_NO_RECIPIENT: status_t = B_MAIL_ERROR_BASE + 6;
523 pub const B_MAIL_INVALID_MAIL: status_t = B_MAIL_ERROR_BASE + 7;
524 
525 // Print kit errors
526 pub const B_NO_PRINT_SERVER: status_t = B_PRINT_ERROR_BASE + 0;
527 
528 // Device kit errors
529 pub const B_DEV_INVALID_IOCTL: status_t = B_DEVICE_ERROR_BASE + 0;
530 pub const B_DEV_NO_MEMORY: status_t = B_DEVICE_ERROR_BASE + 1;
531 pub const B_DEV_BAD_DRIVE_NUM: status_t = B_DEVICE_ERROR_BASE + 2;
532 pub const B_DEV_NO_MEDIA: status_t = B_DEVICE_ERROR_BASE + 3;
533 pub const B_DEV_UNREADABLE: status_t = B_DEVICE_ERROR_BASE + 4;
534 pub const B_DEV_FORMAT_ERROR: status_t = B_DEVICE_ERROR_BASE + 5;
535 pub const B_DEV_TIMEOUT: status_t = B_DEVICE_ERROR_BASE + 6;
536 pub const B_DEV_RECALIBRATE_ERROR: status_t = B_DEVICE_ERROR_BASE + 7;
537 pub const B_DEV_SEEK_ERROR: status_t = B_DEVICE_ERROR_BASE + 8;
538 pub const B_DEV_ID_ERROR: status_t = B_DEVICE_ERROR_BASE + 9;
539 pub const B_DEV_READ_ERROR: status_t = B_DEVICE_ERROR_BASE + 10;
540 pub const B_DEV_WRITE_ERROR: status_t = B_DEVICE_ERROR_BASE + 11;
541 pub const B_DEV_NOT_READY: status_t = B_DEVICE_ERROR_BASE + 12;
542 pub const B_DEV_MEDIA_CHANGED: status_t = B_DEVICE_ERROR_BASE + 13;
543 pub const B_DEV_MEDIA_CHANGE_REQUESTED: status_t = B_DEVICE_ERROR_BASE + 14;
544 pub const B_DEV_RESOURCE_CONFLICT: status_t = B_DEVICE_ERROR_BASE + 15;
545 pub const B_DEV_CONFIGURATION_ERROR: status_t = B_DEVICE_ERROR_BASE + 16;
546 pub const B_DEV_DISABLED_BY_USER: status_t = B_DEVICE_ERROR_BASE + 17;
547 pub const B_DEV_DOOR_OPEN: status_t = B_DEVICE_ERROR_BASE + 18;
548 
549 pub const B_DEV_INVALID_PIPE: status_t = B_DEVICE_ERROR_BASE + 19;
550 pub const B_DEV_CRC_ERROR: status_t = B_DEVICE_ERROR_BASE + 20;
551 pub const B_DEV_STALLED: status_t = B_DEVICE_ERROR_BASE + 21;
552 pub const B_DEV_BAD_PID: status_t = B_DEVICE_ERROR_BASE + 22;
553 pub const B_DEV_UNEXPECTED_PID: status_t = B_DEVICE_ERROR_BASE + 23;
554 pub const B_DEV_DATA_OVERRUN: status_t = B_DEVICE_ERROR_BASE + 24;
555 pub const B_DEV_DATA_UNDERRUN: status_t = B_DEVICE_ERROR_BASE + 25;
556 pub const B_DEV_FIFO_OVERRUN: status_t = B_DEVICE_ERROR_BASE + 26;
557 pub const B_DEV_FIFO_UNDERRUN: status_t = B_DEVICE_ERROR_BASE + 27;
558 pub const B_DEV_PENDING: status_t = B_DEVICE_ERROR_BASE + 28;
559 pub const B_DEV_MULTIPLE_ERRORS: status_t = B_DEVICE_ERROR_BASE + 29;
560 pub const B_DEV_TOO_LATE: status_t = B_DEVICE_ERROR_BASE + 30;
561 
562 // translation kit errors
563 pub const B_TRANSLATION_BASE_ERROR: status_t = B_TRANSLATION_ERROR_BASE + 0;
564 pub const B_NO_TRANSLATOR: status_t = B_TRANSLATION_ERROR_BASE + 1;
565 pub const B_ILLEGAL_DATA: status_t = B_TRANSLATION_ERROR_BASE + 2;
566 
567 // support/TypeConstants.h
568 pub const B_AFFINE_TRANSFORM_TYPE: u32 = haiku_constant!('A', 'M', 'T', 'X');
569 pub const B_ALIGNMENT_TYPE: u32 = haiku_constant!('A', 'L', 'G', 'N');
570 pub const B_ANY_TYPE: u32 = haiku_constant!('A', 'N', 'Y', 'T');
571 pub const B_ATOM_TYPE: u32 = haiku_constant!('A', 'T', 'O', 'M');
572 pub const B_ATOMREF_TYPE: u32 = haiku_constant!('A', 'T', 'M', 'R');
573 pub const B_BOOL_TYPE: u32 = haiku_constant!('B', 'O', 'O', 'L');
574 pub const B_CHAR_TYPE: u32 = haiku_constant!('C', 'H', 'A', 'R');
575 pub const B_COLOR_8_BIT_TYPE: u32 = haiku_constant!('C', 'L', 'R', 'B');
576 pub const B_DOUBLE_TYPE: u32 = haiku_constant!('D', 'B', 'L', 'E');
577 pub const B_FLOAT_TYPE: u32 = haiku_constant!('F', 'L', 'O', 'T');
578 pub const B_GRAYSCALE_8_BIT_TYPE: u32 = haiku_constant!('G', 'R', 'Y', 'B');
579 pub const B_INT16_TYPE: u32 = haiku_constant!('S', 'H', 'R', 'T');
580 pub const B_INT32_TYPE: u32 = haiku_constant!('L', 'O', 'N', 'G');
581 pub const B_INT64_TYPE: u32 = haiku_constant!('L', 'L', 'N', 'G');
582 pub const B_INT8_TYPE: u32 = haiku_constant!('B', 'Y', 'T', 'E');
583 pub const B_LARGE_ICON_TYPE: u32 = haiku_constant!('I', 'C', 'O', 'N');
584 pub const B_MEDIA_PARAMETER_GROUP_TYPE: u32 = haiku_constant!('B', 'M', 'C', 'G');
585 pub const B_MEDIA_PARAMETER_TYPE: u32 = haiku_constant!('B', 'M', 'C', 'T');
586 pub const B_MEDIA_PARAMETER_WEB_TYPE: u32 = haiku_constant!('B', 'M', 'C', 'W');
587 pub const B_MESSAGE_TYPE: u32 = haiku_constant!('M', 'S', 'G', 'G');
588 pub const B_MESSENGER_TYPE: u32 = haiku_constant!('M', 'S', 'N', 'G');
589 pub const B_MIME_TYPE: u32 = haiku_constant!('M', 'I', 'M', 'E');
590 pub const B_MINI_ICON_TYPE: u32 = haiku_constant!('M', 'I', 'C', 'N');
591 pub const B_MONOCHROME_1_BIT_TYPE: u32 = haiku_constant!('M', 'N', 'O', 'B');
592 pub const B_OBJECT_TYPE: u32 = haiku_constant!('O', 'P', 'T', 'R');
593 pub const B_OFF_T_TYPE: u32 = haiku_constant!('O', 'F', 'F', 'T');
594 pub const B_PATTERN_TYPE: u32 = haiku_constant!('P', 'A', 'T', 'N');
595 pub const B_POINTER_TYPE: u32 = haiku_constant!('P', 'N', 'T', 'R');
596 pub const B_POINT_TYPE: u32 = haiku_constant!('B', 'P', 'N', 'T');
597 pub const B_PROPERTY_INFO_TYPE: u32 = haiku_constant!('S', 'C', 'T', 'D');
598 pub const B_RAW_TYPE: u32 = haiku_constant!('R', 'A', 'W', 'T');
599 pub const B_RECT_TYPE: u32 = haiku_constant!('R', 'E', 'C', 'T');
600 pub const B_REF_TYPE: u32 = haiku_constant!('R', 'R', 'E', 'F');
601 pub const B_RGB_32_BIT_TYPE: u32 = haiku_constant!('R', 'G', 'B', 'B');
602 pub const B_RGB_COLOR_TYPE: u32 = haiku_constant!('R', 'G', 'B', 'C');
603 pub const B_SIZE_TYPE: u32 = haiku_constant!('S', 'I', 'Z', 'E');
604 pub const B_SIZE_T_TYPE: u32 = haiku_constant!('S', 'I', 'Z', 'T');
605 pub const B_SSIZE_T_TYPE: u32 = haiku_constant!('S', 'S', 'Z', 'T');
606 pub const B_STRING_TYPE: u32 = haiku_constant!('C', 'S', 'T', 'R');
607 pub const B_STRING_LIST_TYPE: u32 = haiku_constant!('S', 'T', 'R', 'L');
608 pub const B_TIME_TYPE: u32 = haiku_constant!('T', 'I', 'M', 'E');
609 pub const B_UINT16_TYPE: u32 = haiku_constant!('U', 'S', 'H', 'T');
610 pub const B_UINT32_TYPE: u32 = haiku_constant!('U', 'L', 'N', 'G');
611 pub const B_UINT64_TYPE: u32 = haiku_constant!('U', 'L', 'L', 'G');
612 pub const B_UINT8_TYPE: u32 = haiku_constant!('U', 'B', 'Y', 'T');
613 pub const B_VECTOR_ICON_TYPE: u32 = haiku_constant!('V', 'I', 'C', 'N');
614 pub const B_XATTR_TYPE: u32 = haiku_constant!('X', 'A', 'T', 'R');
615 pub const B_NETWORK_ADDRESS_TYPE: u32 = haiku_constant!('N', 'W', 'A', 'D');
616 pub const B_MIME_STRING_TYPE: u32 = haiku_constant!('M', 'I', 'M', 'S');
617 pub const B_ASCII_TYPE: u32 = haiku_constant!('T', 'E', 'X', 'T');
618 
619 extern "C" {
620     // kernel/OS.h
create_area( name: *const ::c_char, startAddress: *mut *mut ::c_void, addressSpec: u32, size: usize, lock: u32, protection: u32, ) -> area_id621     pub fn create_area(
622         name: *const ::c_char,
623         startAddress: *mut *mut ::c_void,
624         addressSpec: u32,
625         size: usize,
626         lock: u32,
627         protection: u32,
628     ) -> area_id;
clone_area( name: *const ::c_char, destAddress: *mut *mut ::c_void, addressSpec: u32, protection: u32, source: area_id, ) -> area_id629     pub fn clone_area(
630         name: *const ::c_char,
631         destAddress: *mut *mut ::c_void,
632         addressSpec: u32,
633         protection: u32,
634         source: area_id,
635     ) -> area_id;
find_area(name: *const ::c_char) -> area_id636     pub fn find_area(name: *const ::c_char) -> area_id;
area_for(address: *mut ::c_void) -> area_id637     pub fn area_for(address: *mut ::c_void) -> area_id;
delete_area(id: area_id) -> status_t638     pub fn delete_area(id: area_id) -> status_t;
resize_area(id: area_id, newSize: usize) -> status_t639     pub fn resize_area(id: area_id, newSize: usize) -> status_t;
set_area_protection(id: area_id, newProtection: u32) -> status_t640     pub fn set_area_protection(id: area_id, newProtection: u32) -> status_t;
_get_area_info(id: area_id, areaInfo: *mut area_info, size: usize) -> status_t641     pub fn _get_area_info(id: area_id, areaInfo: *mut area_info, size: usize) -> status_t;
_get_next_area_info( team: team_id, cookie: *mut isize, areaInfo: *mut area_info, size: usize, ) -> status_t642     pub fn _get_next_area_info(
643         team: team_id,
644         cookie: *mut isize,
645         areaInfo: *mut area_info,
646         size: usize,
647     ) -> status_t;
648 
create_port(capacity: i32, name: *const ::c_char) -> port_id649     pub fn create_port(capacity: i32, name: *const ::c_char) -> port_id;
find_port(name: *const ::c_char) -> port_id650     pub fn find_port(name: *const ::c_char) -> port_id;
read_port( port: port_id, code: *mut i32, buffer: *mut ::c_void, bufferSize: ::size_t, ) -> ::ssize_t651     pub fn read_port(
652         port: port_id,
653         code: *mut i32,
654         buffer: *mut ::c_void,
655         bufferSize: ::size_t,
656     ) -> ::ssize_t;
read_port_etc( port: port_id, code: *mut i32, buffer: *mut ::c_void, bufferSize: ::size_t, flags: u32, timeout: bigtime_t, ) -> ::ssize_t657     pub fn read_port_etc(
658         port: port_id,
659         code: *mut i32,
660         buffer: *mut ::c_void,
661         bufferSize: ::size_t,
662         flags: u32,
663         timeout: bigtime_t,
664     ) -> ::ssize_t;
write_port( port: port_id, code: i32, buffer: *const ::c_void, bufferSize: ::size_t, ) -> status_t665     pub fn write_port(
666         port: port_id,
667         code: i32,
668         buffer: *const ::c_void,
669         bufferSize: ::size_t,
670     ) -> status_t;
write_port_etc( port: port_id, code: i32, buffer: *const ::c_void, bufferSize: ::size_t, flags: u32, timeout: bigtime_t, ) -> status_t671     pub fn write_port_etc(
672         port: port_id,
673         code: i32,
674         buffer: *const ::c_void,
675         bufferSize: ::size_t,
676         flags: u32,
677         timeout: bigtime_t,
678     ) -> status_t;
close_port(port: port_id) -> status_t679     pub fn close_port(port: port_id) -> status_t;
delete_port(port: port_id) -> status_t680     pub fn delete_port(port: port_id) -> status_t;
port_buffer_size(port: port_id) -> ::ssize_t681     pub fn port_buffer_size(port: port_id) -> ::ssize_t;
port_buffer_size_etc(port: port_id, flags: u32, timeout: bigtime_t) -> ::ssize_t682     pub fn port_buffer_size_etc(port: port_id, flags: u32, timeout: bigtime_t) -> ::ssize_t;
port_count(port: port_id) -> ::ssize_t683     pub fn port_count(port: port_id) -> ::ssize_t;
set_port_owner(port: port_id, team: team_id) -> status_t684     pub fn set_port_owner(port: port_id, team: team_id) -> status_t;
685 
_get_port_info(port: port_id, buf: *mut port_info, portInfoSize: ::size_t) -> status_t686     pub fn _get_port_info(port: port_id, buf: *mut port_info, portInfoSize: ::size_t) -> status_t;
_get_next_port_info( port: port_id, cookie: *mut i32, portInfo: *mut port_info, portInfoSize: ::size_t, ) -> status_t687     pub fn _get_next_port_info(
688         port: port_id,
689         cookie: *mut i32,
690         portInfo: *mut port_info,
691         portInfoSize: ::size_t,
692     ) -> status_t;
_get_port_message_info_etc( port: port_id, info: *mut port_message_info, infoSize: ::size_t, flags: u32, timeout: bigtime_t, ) -> status_t693     pub fn _get_port_message_info_etc(
694         port: port_id,
695         info: *mut port_message_info,
696         infoSize: ::size_t,
697         flags: u32,
698         timeout: bigtime_t,
699     ) -> status_t;
700 
create_sem(count: i32, name: *const ::c_char) -> sem_id701     pub fn create_sem(count: i32, name: *const ::c_char) -> sem_id;
delete_sem(id: sem_id) -> status_t702     pub fn delete_sem(id: sem_id) -> status_t;
acquire_sem(id: sem_id) -> status_t703     pub fn acquire_sem(id: sem_id) -> status_t;
acquire_sem_etc(id: sem_id, count: i32, flags: u32, timeout: bigtime_t) -> status_t704     pub fn acquire_sem_etc(id: sem_id, count: i32, flags: u32, timeout: bigtime_t) -> status_t;
release_sem(id: sem_id) -> status_t705     pub fn release_sem(id: sem_id) -> status_t;
release_sem_etc(id: sem_id, count: i32, flags: u32) -> status_t706     pub fn release_sem_etc(id: sem_id, count: i32, flags: u32) -> status_t;
switch_sem(semToBeReleased: sem_id, id: sem_id) -> status_t707     pub fn switch_sem(semToBeReleased: sem_id, id: sem_id) -> status_t;
switch_sem_etc( semToBeReleased: sem_id, id: sem_id, count: i32, flags: u32, timeout: bigtime_t, ) -> status_t708     pub fn switch_sem_etc(
709         semToBeReleased: sem_id,
710         id: sem_id,
711         count: i32,
712         flags: u32,
713         timeout: bigtime_t,
714     ) -> status_t;
get_sem_count(id: sem_id, threadCount: *mut i32) -> status_t715     pub fn get_sem_count(id: sem_id, threadCount: *mut i32) -> status_t;
set_sem_owner(id: sem_id, team: team_id) -> status_t716     pub fn set_sem_owner(id: sem_id, team: team_id) -> status_t;
_get_sem_info(id: sem_id, info: *mut sem_info, infoSize: ::size_t) -> status_t717     pub fn _get_sem_info(id: sem_id, info: *mut sem_info, infoSize: ::size_t) -> status_t;
_get_next_sem_info( team: team_id, cookie: *mut i32, info: *mut sem_info, infoSize: ::size_t, ) -> status_t718     pub fn _get_next_sem_info(
719         team: team_id,
720         cookie: *mut i32,
721         info: *mut sem_info,
722         infoSize: ::size_t,
723     ) -> status_t;
724 
kill_team(team: team_id) -> status_t725     pub fn kill_team(team: team_id) -> status_t;
_get_team_info(team: team_id, info: *mut team_info, size: ::size_t) -> status_t726     pub fn _get_team_info(team: team_id, info: *mut team_info, size: ::size_t) -> status_t;
_get_next_team_info(cookie: *mut i32, info: *mut team_info, size: ::size_t) -> status_t727     pub fn _get_next_team_info(cookie: *mut i32, info: *mut team_info, size: ::size_t) -> status_t;
728 
spawn_thread( func: thread_func, name: *const ::c_char, priority: i32, data: *mut ::c_void, ) -> thread_id729     pub fn spawn_thread(
730         func: thread_func,
731         name: *const ::c_char,
732         priority: i32,
733         data: *mut ::c_void,
734     ) -> thread_id;
kill_thread(thread: thread_id) -> status_t735     pub fn kill_thread(thread: thread_id) -> status_t;
resume_thread(thread: thread_id) -> status_t736     pub fn resume_thread(thread: thread_id) -> status_t;
suspend_thread(thread: thread_id) -> status_t737     pub fn suspend_thread(thread: thread_id) -> status_t;
738 
rename_thread(thread: thread_id, newName: *const ::c_char) -> status_t739     pub fn rename_thread(thread: thread_id, newName: *const ::c_char) -> status_t;
set_thread_priority(thread: thread_id, newPriority: i32) -> status_t740     pub fn set_thread_priority(thread: thread_id, newPriority: i32) -> status_t;
exit_thread(status: status_t)741     pub fn exit_thread(status: status_t);
wait_for_thread(thread: thread_id, returnValue: *mut status_t) -> status_t742     pub fn wait_for_thread(thread: thread_id, returnValue: *mut status_t) -> status_t;
on_exit_thread(callback: extern "C" fn(*mut ::c_void), data: *mut ::c_void) -> status_t743     pub fn on_exit_thread(callback: extern "C" fn(*mut ::c_void), data: *mut ::c_void) -> status_t;
744 
find_thread(name: *const ::c_char) -> thread_id745     pub fn find_thread(name: *const ::c_char) -> thread_id;
746 
send_data( thread: thread_id, code: i32, buffer: *const ::c_void, bufferSize: ::size_t, ) -> status_t747     pub fn send_data(
748         thread: thread_id,
749         code: i32,
750         buffer: *const ::c_void,
751         bufferSize: ::size_t,
752     ) -> status_t;
receive_data(sender: *mut thread_id, buffer: *mut ::c_void, bufferSize: ::size_t) -> i32753     pub fn receive_data(sender: *mut thread_id, buffer: *mut ::c_void, bufferSize: ::size_t)
754         -> i32;
has_data(thread: thread_id) -> bool755     pub fn has_data(thread: thread_id) -> bool;
756 
snooze(amount: bigtime_t) -> status_t757     pub fn snooze(amount: bigtime_t) -> status_t;
snooze_etc(amount: bigtime_t, timeBase: ::c_int, flags: u32) -> status_t758     pub fn snooze_etc(amount: bigtime_t, timeBase: ::c_int, flags: u32) -> status_t;
snooze_until(time: bigtime_t, timeBase: ::c_int) -> status_t759     pub fn snooze_until(time: bigtime_t, timeBase: ::c_int) -> status_t;
760 
_get_thread_info(id: thread_id, info: *mut thread_info, size: ::size_t) -> status_t761     pub fn _get_thread_info(id: thread_id, info: *mut thread_info, size: ::size_t) -> status_t;
_get_next_thread_info( team: team_id, cookie: *mut i32, info: *mut thread_info, size: ::size_t, ) -> status_t762     pub fn _get_next_thread_info(
763         team: team_id,
764         cookie: *mut i32,
765         info: *mut thread_info,
766         size: ::size_t,
767     ) -> status_t;
768 
get_pthread_thread_id(thread: ::pthread_t) -> thread_id769     pub fn get_pthread_thread_id(thread: ::pthread_t) -> thread_id;
770 
_get_team_usage_info( team: team_id, who: i32, info: *mut team_usage_info, size: ::size_t, ) -> status_t771     pub fn _get_team_usage_info(
772         team: team_id,
773         who: i32,
774         info: *mut team_usage_info,
775         size: ::size_t,
776     ) -> status_t;
777 
real_time_clock() -> ::c_ulong778     pub fn real_time_clock() -> ::c_ulong;
set_real_time_clock(secsSinceJan1st1970: ::c_ulong)779     pub fn set_real_time_clock(secsSinceJan1st1970: ::c_ulong);
real_time_clock_usecs() -> bigtime_t780     pub fn real_time_clock_usecs() -> bigtime_t;
system_time() -> bigtime_t781     pub fn system_time() -> bigtime_t;
system_time_nsecs() -> nanotime_t782     pub fn system_time_nsecs() -> nanotime_t;
783     // set_timezone() is deprecated and a no-op
784 
set_alarm(when: bigtime_t, flags: u32) -> bigtime_t785     pub fn set_alarm(when: bigtime_t, flags: u32) -> bigtime_t;
debugger(message: *const ::c_char)786     pub fn debugger(message: *const ::c_char);
disable_debugger(state: ::c_int) -> ::c_int787     pub fn disable_debugger(state: ::c_int) -> ::c_int;
788 
789     // TODO: cpuid_info struct and the get_cpuid() function
790 
get_system_info(info: *mut system_info) -> status_t791     pub fn get_system_info(info: *mut system_info) -> status_t;
get_cpu_info(firstCPU: u32, cpuCount: u32, info: *mut cpu_info) -> status_t792     pub fn get_cpu_info(firstCPU: u32, cpuCount: u32, info: *mut cpu_info) -> status_t;
is_computer_on() -> i32793     pub fn is_computer_on() -> i32;
is_computer_on_fire() -> ::c_double794     pub fn is_computer_on_fire() -> ::c_double;
send_signal(threadID: thread_id, signal: ::c_uint) -> ::c_int795     pub fn send_signal(threadID: thread_id, signal: ::c_uint) -> ::c_int;
set_signal_stack(base: *mut ::c_void, size: ::size_t)796     pub fn set_signal_stack(base: *mut ::c_void, size: ::size_t);
797 
wait_for_objects(infos: *mut object_wait_info, numInfos: ::c_int) -> ::ssize_t798     pub fn wait_for_objects(infos: *mut object_wait_info, numInfos: ::c_int) -> ::ssize_t;
wait_for_objects_etc( infos: *mut object_wait_info, numInfos: ::c_int, flags: u32, timeout: bigtime_t, ) -> ::ssize_t799     pub fn wait_for_objects_etc(
800         infos: *mut object_wait_info,
801         numInfos: ::c_int,
802         flags: u32,
803         timeout: bigtime_t,
804     ) -> ::ssize_t;
805 
806     // kernel/fs_attr.h
fs_read_attr( fd: ::c_int, attribute: *const ::c_char, type_: u32, pos: ::off_t, buffer: *mut ::c_void, readBytes: ::size_t, ) -> ::ssize_t807     pub fn fs_read_attr(
808         fd: ::c_int,
809         attribute: *const ::c_char,
810         type_: u32,
811         pos: ::off_t,
812         buffer: *mut ::c_void,
813         readBytes: ::size_t,
814     ) -> ::ssize_t;
fs_write_attr( fd: ::c_int, attribute: *const ::c_char, type_: u32, pos: ::off_t, buffer: *const ::c_void, writeBytes: ::size_t, ) -> ::ssize_t815     pub fn fs_write_attr(
816         fd: ::c_int,
817         attribute: *const ::c_char,
818         type_: u32,
819         pos: ::off_t,
820         buffer: *const ::c_void,
821         writeBytes: ::size_t,
822     ) -> ::ssize_t;
fs_remove_attr(fd: ::c_int, attribute: *const ::c_char) -> ::c_int823     pub fn fs_remove_attr(fd: ::c_int, attribute: *const ::c_char) -> ::c_int;
fs_stat_attr( fd: ::c_int, attribute: *const ::c_char, attrInfo: *mut attr_info, ) -> ::c_int824     pub fn fs_stat_attr(
825         fd: ::c_int,
826         attribute: *const ::c_char,
827         attrInfo: *mut attr_info,
828     ) -> ::c_int;
829 
fs_open_attr( path: *const ::c_char, attribute: *const ::c_char, type_: u32, openMode: ::c_int, ) -> ::c_int830     pub fn fs_open_attr(
831         path: *const ::c_char,
832         attribute: *const ::c_char,
833         type_: u32,
834         openMode: ::c_int,
835     ) -> ::c_int;
fs_fopen_attr( fd: ::c_int, attribute: *const ::c_char, type_: u32, openMode: ::c_int, ) -> ::c_int836     pub fn fs_fopen_attr(
837         fd: ::c_int,
838         attribute: *const ::c_char,
839         type_: u32,
840         openMode: ::c_int,
841     ) -> ::c_int;
fs_close_attr(fd: ::c_int) -> ::c_int842     pub fn fs_close_attr(fd: ::c_int) -> ::c_int;
843 
fs_open_attr_dir(path: *const ::c_char) -> *mut ::DIR844     pub fn fs_open_attr_dir(path: *const ::c_char) -> *mut ::DIR;
fs_lopen_attr_dir(path: *const ::c_char) -> *mut ::DIR845     pub fn fs_lopen_attr_dir(path: *const ::c_char) -> *mut ::DIR;
fs_fopen_attr_dir(fd: ::c_int) -> *mut ::DIR846     pub fn fs_fopen_attr_dir(fd: ::c_int) -> *mut ::DIR;
fs_close_attr_dir(dir: *mut ::DIR) -> ::c_int847     pub fn fs_close_attr_dir(dir: *mut ::DIR) -> ::c_int;
fs_read_attr_dir(dir: *mut ::DIR) -> *mut ::dirent848     pub fn fs_read_attr_dir(dir: *mut ::DIR) -> *mut ::dirent;
fs_rewind_attr_dir(dir: *mut ::DIR)849     pub fn fs_rewind_attr_dir(dir: *mut ::DIR);
850 
851     // kernel/fs_image.h
fs_create_index( device: ::dev_t, name: *const ::c_char, type_: u32, flags: u32, ) -> ::c_int852     pub fn fs_create_index(
853         device: ::dev_t,
854         name: *const ::c_char,
855         type_: u32,
856         flags: u32,
857     ) -> ::c_int;
fs_remove_index(device: ::dev_t, name: *const ::c_char) -> ::c_int858     pub fn fs_remove_index(device: ::dev_t, name: *const ::c_char) -> ::c_int;
fs_stat_index( device: ::dev_t, name: *const ::c_char, indexInfo: *mut index_info, ) -> ::c_int859     pub fn fs_stat_index(
860         device: ::dev_t,
861         name: *const ::c_char,
862         indexInfo: *mut index_info,
863     ) -> ::c_int;
864 
fs_open_index_dir(device: ::dev_t) -> *mut ::DIR865     pub fn fs_open_index_dir(device: ::dev_t) -> *mut ::DIR;
fs_close_index_dir(indexDirectory: *mut ::DIR) -> ::c_int866     pub fn fs_close_index_dir(indexDirectory: *mut ::DIR) -> ::c_int;
fs_read_index_dir(indexDirectory: *mut ::DIR) -> *mut ::dirent867     pub fn fs_read_index_dir(indexDirectory: *mut ::DIR) -> *mut ::dirent;
fs_rewind_index_dir(indexDirectory: *mut ::DIR)868     pub fn fs_rewind_index_dir(indexDirectory: *mut ::DIR);
869 
870     // kernel/fs_info.h
dev_for_path(path: *const ::c_char) -> ::dev_t871     pub fn dev_for_path(path: *const ::c_char) -> ::dev_t;
next_dev(pos: *mut i32) -> ::dev_t872     pub fn next_dev(pos: *mut i32) -> ::dev_t;
fs_stat_dev(dev: ::dev_t, info: *mut fs_info) -> ::c_int873     pub fn fs_stat_dev(dev: ::dev_t, info: *mut fs_info) -> ::c_int;
874 
875     // kernel/fs_query.h
fs_open_query(device: ::dev_t, query: *const ::c_char, flags: u32) -> *mut ::DIR876     pub fn fs_open_query(device: ::dev_t, query: *const ::c_char, flags: u32) -> *mut ::DIR;
fs_open_live_query( device: ::dev_t, query: *const ::c_char, flags: u32, port: port_id, token: i32, ) -> *mut ::DIR877     pub fn fs_open_live_query(
878         device: ::dev_t,
879         query: *const ::c_char,
880         flags: u32,
881         port: port_id,
882         token: i32,
883     ) -> *mut ::DIR;
fs_close_query(d: *mut ::DIR) -> ::c_int884     pub fn fs_close_query(d: *mut ::DIR) -> ::c_int;
fs_read_query(d: *mut ::DIR) -> *mut ::dirent885     pub fn fs_read_query(d: *mut ::DIR) -> *mut ::dirent;
get_path_for_dirent(dent: *mut ::dirent, buf: *mut ::c_char, len: ::size_t) -> status_t886     pub fn get_path_for_dirent(dent: *mut ::dirent, buf: *mut ::c_char, len: ::size_t) -> status_t;
887 
888     // kernel/fs_volume.h
fs_mount_volume( where_: *const ::c_char, device: *const ::c_char, filesystem: *const ::c_char, flags: u32, parameters: *const ::c_char, ) -> ::dev_t889     pub fn fs_mount_volume(
890         where_: *const ::c_char,
891         device: *const ::c_char,
892         filesystem: *const ::c_char,
893         flags: u32,
894         parameters: *const ::c_char,
895     ) -> ::dev_t;
fs_unmount_volume(path: *const ::c_char, flags: u32) -> status_t896     pub fn fs_unmount_volume(path: *const ::c_char, flags: u32) -> status_t;
897 
898     // kernel/image.h
load_image( argc: i32, argv: *mut *const ::c_char, environ: *mut *const ::c_char, ) -> thread_id899     pub fn load_image(
900         argc: i32,
901         argv: *mut *const ::c_char,
902         environ: *mut *const ::c_char,
903     ) -> thread_id;
load_add_on(path: *const ::c_char) -> image_id904     pub fn load_add_on(path: *const ::c_char) -> image_id;
unload_add_on(image: image_id) -> status_t905     pub fn unload_add_on(image: image_id) -> status_t;
get_image_symbol( image: image_id, name: *const ::c_char, symbolType: i32, symbolLocation: *mut *mut ::c_void, ) -> status_t906     pub fn get_image_symbol(
907         image: image_id,
908         name: *const ::c_char,
909         symbolType: i32,
910         symbolLocation: *mut *mut ::c_void,
911     ) -> status_t;
get_nth_image_symbol( image: image_id, n: i32, nameBuffer: *mut ::c_char, nameLength: *mut i32, symbolType: *mut i32, symbolLocation: *mut *mut ::c_void, ) -> status_t912     pub fn get_nth_image_symbol(
913         image: image_id,
914         n: i32,
915         nameBuffer: *mut ::c_char,
916         nameLength: *mut i32,
917         symbolType: *mut i32,
918         symbolLocation: *mut *mut ::c_void,
919     ) -> status_t;
clear_caches(address: *mut ::c_void, length: ::size_t, flags: u32)920     pub fn clear_caches(address: *mut ::c_void, length: ::size_t, flags: u32);
_get_image_info(image: image_id, info: *mut image_info, size: ::size_t) -> status_t921     pub fn _get_image_info(image: image_id, info: *mut image_info, size: ::size_t) -> status_t;
_get_next_image_info( team: team_id, cookie: *mut i32, info: *mut image_info, size: ::size_t, ) -> status_t922     pub fn _get_next_image_info(
923         team: team_id,
924         cookie: *mut i32,
925         info: *mut image_info,
926         size: ::size_t,
927     ) -> status_t;
928 }
929 
930 // The following functions are defined as macros in C/C++
get_area_info(id: area_id, info: *mut area_info) -> status_t931 pub unsafe fn get_area_info(id: area_id, info: *mut area_info) -> status_t {
932     _get_area_info(id, info, core::mem::size_of::<area_info>() as usize)
933 }
934 
get_next_area_info( team: team_id, cookie: *mut isize, info: *mut area_info, ) -> status_t935 pub unsafe fn get_next_area_info(
936     team: team_id,
937     cookie: *mut isize,
938     info: *mut area_info,
939 ) -> status_t {
940     _get_next_area_info(
941         team,
942         cookie,
943         info,
944         core::mem::size_of::<area_info>() as usize,
945     )
946 }
947 
get_port_info(port: port_id, buf: *mut port_info) -> status_t948 pub unsafe fn get_port_info(port: port_id, buf: *mut port_info) -> status_t {
949     _get_port_info(port, buf, core::mem::size_of::<port_info>() as ::size_t)
950 }
951 
get_next_port_info( port: port_id, cookie: *mut i32, portInfo: *mut port_info, ) -> status_t952 pub unsafe fn get_next_port_info(
953     port: port_id,
954     cookie: *mut i32,
955     portInfo: *mut port_info,
956 ) -> status_t {
957     _get_next_port_info(
958         port,
959         cookie,
960         portInfo,
961         core::mem::size_of::<port_info>() as ::size_t,
962     )
963 }
964 
get_port_message_info_etc( port: port_id, info: *mut port_message_info, flags: u32, timeout: bigtime_t, ) -> status_t965 pub unsafe fn get_port_message_info_etc(
966     port: port_id,
967     info: *mut port_message_info,
968     flags: u32,
969     timeout: bigtime_t,
970 ) -> status_t {
971     _get_port_message_info_etc(
972         port,
973         info,
974         core::mem::size_of::<port_message_info>() as ::size_t,
975         flags,
976         timeout,
977     )
978 }
979 
get_sem_info(id: sem_id, info: *mut sem_info) -> status_t980 pub unsafe fn get_sem_info(id: sem_id, info: *mut sem_info) -> status_t {
981     _get_sem_info(id, info, core::mem::size_of::<sem_info>() as ::size_t)
982 }
983 
get_next_sem_info(team: team_id, cookie: *mut i32, info: *mut sem_info) -> status_t984 pub unsafe fn get_next_sem_info(team: team_id, cookie: *mut i32, info: *mut sem_info) -> status_t {
985     _get_next_sem_info(
986         team,
987         cookie,
988         info,
989         core::mem::size_of::<sem_info>() as ::size_t,
990     )
991 }
992 
get_team_info(team: team_id, info: *mut team_info) -> status_t993 pub unsafe fn get_team_info(team: team_id, info: *mut team_info) -> status_t {
994     _get_team_info(team, info, core::mem::size_of::<team_info>() as ::size_t)
995 }
996 
get_next_team_info(cookie: *mut i32, info: *mut team_info) -> status_t997 pub unsafe fn get_next_team_info(cookie: *mut i32, info: *mut team_info) -> status_t {
998     _get_next_team_info(cookie, info, core::mem::size_of::<team_info>() as ::size_t)
999 }
1000 
get_team_usage_info(team: team_id, who: i32, info: *mut team_usage_info) -> status_t1001 pub unsafe fn get_team_usage_info(team: team_id, who: i32, info: *mut team_usage_info) -> status_t {
1002     _get_team_usage_info(
1003         team,
1004         who,
1005         info,
1006         core::mem::size_of::<team_usage_info>() as ::size_t,
1007     )
1008 }
1009 
get_thread_info(id: thread_id, info: *mut thread_info) -> status_t1010 pub unsafe fn get_thread_info(id: thread_id, info: *mut thread_info) -> status_t {
1011     _get_thread_info(id, info, core::mem::size_of::<thread_info>() as ::size_t)
1012 }
1013 
get_next_thread_info( team: team_id, cookie: *mut i32, info: *mut thread_info, ) -> status_t1014 pub unsafe fn get_next_thread_info(
1015     team: team_id,
1016     cookie: *mut i32,
1017     info: *mut thread_info,
1018 ) -> status_t {
1019     _get_next_thread_info(
1020         team,
1021         cookie,
1022         info,
1023         core::mem::size_of::<thread_info>() as ::size_t,
1024     )
1025 }
1026 
1027 // kernel/image.h
get_image_info(image: image_id, info: *mut image_info) -> status_t1028 pub unsafe fn get_image_info(image: image_id, info: *mut image_info) -> status_t {
1029     _get_image_info(image, info, core::mem::size_of::<image_info>() as ::size_t)
1030 }
1031 
get_next_image_info( team: team_id, cookie: *mut i32, info: *mut image_info, ) -> status_t1032 pub unsafe fn get_next_image_info(
1033     team: team_id,
1034     cookie: *mut i32,
1035     info: *mut image_info,
1036 ) -> status_t {
1037     _get_next_image_info(
1038         team,
1039         cookie,
1040         info,
1041         core::mem::size_of::<image_info>() as ::size_t,
1042     )
1043 }
1044