Skip to content

Commit 598939d

Browse files
authored
Merge pull request #1653 from ArniDagur/shadow_reenterant
Add reenterant shadow.h functions
2 parents d6159eb + 6ffc752 commit 598939d

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,26 @@ cfg_if! {
10871087
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3;
10881088

10891089
extern "C" {
1090+
pub fn fgetspent_r(
1091+
fp: *mut ::FILE,
1092+
spbuf: *mut ::spwd,
1093+
buf: *mut ::c_char,
1094+
buflen: ::size_t,
1095+
spbufp: *mut *mut ::spwd,
1096+
) -> ::c_int;
1097+
pub fn sgetspent_r(
1098+
s: *const ::c_char,
1099+
spbuf: *mut ::spwd,
1100+
buf: *mut ::c_char,
1101+
buflen: ::size_t,
1102+
spbufp: *mut *mut ::spwd,
1103+
) -> ::c_int;
1104+
pub fn getspent_r(
1105+
spbuf: *mut ::spwd,
1106+
buf: *mut ::c_char,
1107+
buflen: ::size_t,
1108+
spbufp: *mut *mut ::spwd,
1109+
) -> ::c_int;
10901110
pub fn qsort_r(
10911111
base: *mut ::c_void,
10921112
num: ::size_t,

src/unix/linux_like/linux/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,17 @@ extern "C" {
25872587
pub fn endspent();
25882588
pub fn getspent() -> *mut spwd;
25892589

2590-
pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
2590+
pub fn getspnam(name: *const ::c_char) -> *mut spwd;
2591+
// Only `getspnam_r` is implemented for musl, out of all of the reenterant
2592+
// functions from `shadow.h`.
2593+
// https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
2594+
pub fn getspnam_r(
2595+
name: *const ::c_char,
2596+
spbuf: *mut spwd,
2597+
buf: *mut ::c_char,
2598+
buflen: ::size_t,
2599+
spbufp: *mut *mut spwd,
2600+
) -> ::c_int;
25912601

25922602
pub fn shm_open(
25932603
name: *const c_char,

0 commit comments

Comments
 (0)