Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding reboot to netbsd/openbsd. #3426

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ fn test_openbsd(target: &str) {
"util.h",
"ufs/ufs/quota.h",
"pthread_np.h",
"sys/reboot.h",
"sys/syscall.h",
"sys/shm.h",
"sys/param.h",
Expand Down Expand Up @@ -1110,6 +1111,7 @@ fn test_netbsd(target: &str) {
"netinet/dccp.h",
"sys/event.h",
"sys/quota.h",
"sys/reboot.h",
"sys/shm.h",
"iconv.h",
}
Expand Down
14 changes: 14 additions & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,19 @@ Q_SETQUOTA
Q_SYNC
RADIXCHAR
RAND_MAX
RB_ASKNAME
RB_AUTOBOOT
RB_DUMP
RB_HALT
RB_INITNAME
RB_KDB
RB_MINIROOT
RB_NOSYNC
RB_POWERDOWN
RB_RDONLY
RB_SINGLE
RB_STRING
RB_USERCONF
REG_ASSERT
REG_ATOI
REG_BACKR
Expand Down Expand Up @@ -1466,6 +1479,7 @@ readdir_r
readlinkat
reallocarr
reallocarray
reboot
recvmmsg
recvmsg
regcomp
Expand Down
15 changes: 15 additions & 0 deletions libc-test/semver/openbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,20 @@ Q_SETQUOTA
Q_SYNC
RADIXCHAR
RAND_MAX
RB_ASKNAME
RB_AUTOBOOT
RB_CONFIG
RB_DUMP
RB_GOODRANDOM
RB_HALT
RB_KDB
RB_INITNAME
RB_POWERDOWN
RB_RESET
RB_SERCONS
RB_TIMEBAD
RB_UNHIBERNATE
RB_USERREQ
REG_ASSERT
REG_ATOI
REG_BACKR
Expand Down Expand Up @@ -1174,6 +1188,7 @@ rand
readdir_r
readlinkat
reallocarray
reboot
recvmsg
regcomp
regerror
Expand Down
4 changes: 4 additions & 0 deletions src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ pub const TIOCM_RI: ::c_int = TIOCM_RNG;

pub const TIMER_ABSTIME: ::c_int = 1;

// sys/reboot.h

pub const RB_AUTOBOOT: ::c_int = 0;

#[link(name = "util")]
extern "C" {
pub fn setgrent();
Expand Down
16 changes: 16 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2434,6 +2434,20 @@ pub const GRND_NONBLOCK: ::c_uint = 0x1;
pub const GRND_RANDOM: ::c_uint = 0x2;
pub const GRND_INSECURE: ::c_uint = 0x4;

// sys/reboot.h
pub const RB_ASKNAME: ::c_int = 0x000000001;
pub const RB_SINGLE: ::c_int = 0x000000002;
pub const RB_NOSYNC: ::c_int = 0x000000004;
pub const RB_HALT: ::c_int = 0x000000008;
pub const RB_INITNAME: ::c_int = 0x000000010;
pub const RB_KDB: ::c_int = 0x000000040;
pub const RB_RDONLY: ::c_int = 0x000000080;
pub const RB_DUMP: ::c_int = 0x000000100;
pub const RB_MINIROOT: ::c_int = 0x000000200;
pub const RB_STRING: ::c_int = 0x000000400;
pub const RB_POWERDOWN: ::c_int = RB_HALT | 0x000000800;
pub const RB_USERCONF: ::c_int = 0x000001000;

cfg_if! {

if #[cfg(libc_const_extern_fn)] {
Expand Down Expand Up @@ -2984,6 +2998,8 @@ extern "C" {
newfd: ::c_int,
) -> ::c_int;
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;

pub fn reboot(mode: ::c_int, bootstr: *mut ::c_char) -> ::c_int;
}

#[link(name = "rt")]
Expand Down
21 changes: 21 additions & 0 deletions src/unix/bsd/netbsdlike/openbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,25 @@ pub const LC_ALL_MASK: ::c_int = (1 << _LC_LAST) - 2;

pub const LC_GLOBAL_LOCALE: ::locale_t = -1isize as ::locale_t;

// sys/reboot.h
pub const RB_ASKNAME: ::c_int = 0x00001;
pub const RB_SINGLE: ::c_int = 0x00002;
pub const RB_NOSYNC: ::c_int = 0x00004;
pub const RB_HALT: ::c_int = 0x00008;
pub const RB_INITNAME: ::c_int = 0x00010;
pub const RB_KDB: ::c_int = 0x00040;
pub const RB_RDONLY: ::c_int = 0x00080;
pub const RB_DUMP: ::c_int = 0x00100;
pub const RB_MINIROOT: ::c_int = 0x00200;
pub const RB_CONFIG: ::c_int = 0x00400;
pub const RB_TIMEBAD: ::c_int = 0x00800;
pub const RB_POWERDOWN: ::c_int = 0x01000;
pub const RB_SERCONS: ::c_int = 0x02000;
pub const RB_USERREQ: ::c_int = 0x04000;
pub const RB_RESET: ::c_int = 0x08000;
pub const RB_GOODRANDOM: ::c_int = 0x10000;
pub const RB_UNHIBERNATE: ::c_int = 0x20000;

const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
Expand Down Expand Up @@ -2057,6 +2076,8 @@ extern "C" {
) -> ::c_int;

pub fn mimmutable(addr: *mut ::c_void, len: ::size_t) -> ::c_int;

pub fn reboot(mode: ::c_int) -> ::c_int;
}

#[link(name = "execinfo")]
Expand Down