Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tarun Aditya Thurlapati
relibc
Commits
1a0edd8e
Verified
Commit
1a0edd8e
authored
Dec 23, 2020
by
Jeremy Soller
Browse files
Add program_invocation_short_name
parent
2f3987dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/bits/errno.h
View file @
1a0edd8e
...
@@ -9,6 +9,7 @@ extern "C" {
...
@@ -9,6 +9,7 @@ extern "C" {
#define errno (*__errno_location())
#define errno (*__errno_location())
#define program_invocation_name (*__program_invocation_name())
#define program_invocation_name (*__program_invocation_name())
#define program_invocation_short_name (*__program_invocation_short_name())
#ifdef __cplusplus
#ifdef __cplusplus
}
// extern "C"
}
// extern "C"
...
...
src/header/errno/mod.rs
View file @
1a0edd8e
...
@@ -18,6 +18,23 @@ pub unsafe extern "C" fn __program_invocation_name() -> *mut *mut c_char {
...
@@ -18,6 +18,23 @@ pub unsafe extern "C" fn __program_invocation_name() -> *mut *mut c_char {
&
mut
platform
::
inner_argv
[
0
]
&
mut
platform
::
inner_argv
[
0
]
}
}
#[no_mangle]
pub
unsafe
extern
"C"
fn
__program_invocation_short_name
()
->
*
mut
*
mut
c_char
{
let
mut
ptr
=
platform
::
inner_argv
[
0
];
let
mut
slash_ptr
=
ptr
;
loop
{
let
b
=
*
ptr
as
u8
;
if
b
==
0
{
return
&
mut
slash_ptr
;
}
else
{
ptr
=
ptr
.add
(
1
);
if
b
==
b'/'
{
slash_ptr
=
ptr
;
}
}
}
}
pub
const
EPERM
:
c_int
=
1
;
/* Operation not permitted */
pub
const
EPERM
:
c_int
=
1
;
/* Operation not permitted */
pub
const
ENOENT
:
c_int
=
2
;
/* No such file or directory */
pub
const
ENOENT
:
c_int
=
2
;
/* No such file or directory */
pub
const
ESRCH
:
c_int
=
3
;
/* No such process */
pub
const
ESRCH
:
c_int
=
3
;
/* No such process */
...
...
tests/errno.c
View file @
1a0edd8e
...
@@ -5,9 +5,11 @@
...
@@ -5,9 +5,11 @@
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
puts
(
argv
[
0
]);
puts
(
argv
[
0
]);
puts
(
program_invocation_name
);
puts
(
program_invocation_name
);
puts
(
program_invocation_short_name
);
program_invocation_name
=
"yes, you can change this"
;
program_invocation_name
=
"yes, you can change this"
;
puts
(
argv
[
0
]);
puts
(
argv
[
0
]);
puts
(
program_invocation_name
);
puts
(
program_invocation_name
);
puts
(
program_invocation_short_name
);
}
}
tests/expected/bins_dynamic/errno.stdout
View file @
1a0edd8e
bins_dynamic/errno
bins_dynamic/errno
bins_dynamic/errno
bins_dynamic/errno
errno
yes, you can change this
yes, you can change this
yes, you can change this
yes, you can change this
yes, you can change this
tests/expected/bins_static/errno.stdout
View file @
1a0edd8e
bins_static/errno
bins_static/errno
bins_static/errno
bins_static/errno
errno
yes, you can change this
yes, you can change this
yes, you can change this
yes, you can change this
yes, you can change this
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment