1 #![allow(dead_code)] // runtime init functions not used during testing
2 use crate::ffi
::OsString
;
3 use crate::marker
::PhantomData
;
6 /// One-time global initialization.
7 pub unsafe fn init(argc
: isize, argv
: *const *const u8) {
11 /// One-time global cleanup.
12 pub unsafe fn cleanup() {
16 /// Returns the command line arguments
17 pub fn args() -> Args
{
22 iter
: vec
::IntoIter
<OsString
>,
23 _dont_send_or_sync_me
: PhantomData
<*mut ()>,
27 pub fn inner_debug(&self) -> &[OsString
] {
32 impl Iterator
for Args
{
34 fn next(&mut self) -> Option
<OsString
> {
37 fn size_hint(&self) -> (usize, Option
<usize>) {
42 impl ExactSizeIterator
for Args
{
43 fn len(&self) -> usize {
48 impl DoubleEndedIterator
for Args
{
49 fn next_back(&mut self) -> Option
<OsString
> {
56 use crate::ffi
::{CStr, OsString}
;
57 use crate::marker
::PhantomData
;
60 use crate::sys_common
::mutex
::StaticMutex
;
62 static mut ARGC
: isize = 0;
63 static mut ARGV
: *const *const u8 = ptr
::null();
64 static LOCK
: StaticMutex
= StaticMutex
::new();
66 pub unsafe fn init(argc
: isize, argv
: *const *const u8) {
67 let _guard
= LOCK
.lock();
72 pub unsafe fn cleanup() {
73 let _guard
= LOCK
.lock();
78 pub fn args() -> Args
{
79 Args { iter: clone().into_iter(), _dont_send_or_sync_me: PhantomData }
82 fn clone() -> Vec
<OsString
> {
84 let _guard
= LOCK
.lock();
87 let cstr
= CStr
::from_ptr(*ARGV
.offset(i
) as *const libc
::c_char
);
88 use crate::sys
::vxworks
::ext
::ffi
::OsStringExt
;
89 OsStringExt
::from_vec(cstr
.to_bytes().to_vec())