summaryrefslogtreecommitdiffstats
path: root/vendor/libc/src/unix/solarish/compat.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /vendor/libc/src/unix/solarish/compat.rs
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/libc/src/unix/solarish/compat.rs')
-rw-r--r--vendor/libc/src/unix/solarish/compat.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/libc/src/unix/solarish/compat.rs b/vendor/libc/src/unix/solarish/compat.rs
index 4a232f0d8..cbf955a31 100644
--- a/vendor/libc/src/unix/solarish/compat.rs
+++ b/vendor/libc/src/unix/solarish/compat.rs
@@ -1,6 +1,7 @@
// Common functions that are unfortunately missing on illumos and
// Solaris, but often needed by other crates.
+use core::cmp::min;
use unix::solarish::*;
const PTEM: &[u8] = b"ptem\0";
@@ -169,3 +170,51 @@ pub unsafe fn forkpty(
0
}
+
+pub unsafe fn getpwent_r(
+ pwd: *mut passwd,
+ buf: *mut ::c_char,
+ buflen: ::size_t,
+ result: *mut *mut passwd,
+) -> ::c_int {
+ let old_errno = *::___errno();
+ *::___errno() = 0;
+ *result = native_getpwent_r(
+ pwd,
+ buf,
+ min(buflen, ::c_int::max_value() as ::size_t) as ::c_int,
+ );
+
+ let ret = if (*result).is_null() {
+ *::___errno()
+ } else {
+ 0
+ };
+ *::___errno() = old_errno;
+
+ ret
+}
+
+pub unsafe fn getgrent_r(
+ grp: *mut ::group,
+ buf: *mut ::c_char,
+ buflen: ::size_t,
+ result: *mut *mut ::group,
+) -> ::c_int {
+ let old_errno = *::___errno();
+ *::___errno() = 0;
+ *result = native_getgrent_r(
+ grp,
+ buf,
+ min(buflen, ::c_int::max_value() as ::size_t) as ::c_int,
+ );
+
+ let ret = if (*result).is_null() {
+ *::___errno()
+ } else {
+ 0
+ };
+ *::___errno() = old_errno;
+
+ ret
+}