Merge branch 'fixes' into 'master'
Fixes for forkpty and dprintf tests See merge request redox-os/relibc!494
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! pthread.h implementation for Redox, following https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html
|
||||
|
||||
use core::cell::Cell;
|
||||
use core::{cell::Cell, ptr::NonNull};
|
||||
|
||||
use crate::{
|
||||
header::{sched::*, time::timespec},
|
||||
@@ -188,7 +188,11 @@ pub unsafe extern "C" fn pthread_self() -> pthread_t {
|
||||
pub unsafe extern "C" fn pthread_setcancelstate(state: c_int, oldstate: *mut c_int) -> c_int {
|
||||
match pthread::set_cancel_state(state) {
|
||||
Ok(old) => {
|
||||
oldstate.write(old);
|
||||
// POSIX doesn't imply oldstate can be NULL anywhere, but a lot of C code probably
|
||||
// relies on it...
|
||||
if let Some(oldstate) = NonNull::new(oldstate) {
|
||||
oldstate.write(old);
|
||||
}
|
||||
0
|
||||
}
|
||||
Err(pthread::Errno(error)) => error,
|
||||
@@ -198,7 +202,11 @@ pub unsafe extern "C" fn pthread_setcancelstate(state: c_int, oldstate: *mut c_i
|
||||
pub unsafe extern "C" fn pthread_setcanceltype(ty: c_int, oldty: *mut c_int) -> c_int {
|
||||
match pthread::set_cancel_type(ty) {
|
||||
Ok(old) => {
|
||||
oldty.write(old);
|
||||
// POSIX doesn't imply oldty can be NULL anywhere, but a lot of C code probably relies
|
||||
// on it...
|
||||
if let Some(oldty) = NonNull::new(oldty) {
|
||||
oldty.write(old);
|
||||
}
|
||||
0
|
||||
}
|
||||
Err(pthread::Errno(error)) => error,
|
||||
|
||||
+1
-1
@@ -25,7 +25,6 @@ EXPECT_NAMES=\
|
||||
math \
|
||||
netdb/getaddrinfo \
|
||||
ptrace \
|
||||
pty/forkpty \
|
||||
regex \
|
||||
select \
|
||||
setjmp \
|
||||
@@ -158,6 +157,7 @@ DYNAMIC_ONLY_NAMES=\
|
||||
NAMES=\
|
||||
$(EXPECT_NAMES) \
|
||||
dirent/main \
|
||||
pty/forkpty \
|
||||
pwd \
|
||||
sa_restart \
|
||||
sigchld \
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd = open("/dev/stdout", O_WRONLY, 0222);
|
||||
ERROR_IF(open, fd, < 0);
|
||||
|
||||
int main(void) {
|
||||
const char *msg = "Hello, %s";
|
||||
|
||||
int fd = dup(STDOUT_FILENO);
|
||||
ERROR_IF(dup, fd, == -1);
|
||||
|
||||
int result = dprintf(fd, msg, "world");
|
||||
ERROR_IF(dprintf, result, != sizeof("Hello, world") - 1);
|
||||
UNEXP_IF(dprintf, result, < 0);
|
||||
@@ -21,4 +20,4 @@ int main(void)
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user