diff --git a/cbindgen b/cbindgen index d14295f3ca588f1d1752ea0a579f0597dd2ce248..95821b3bbe857354e3fb1efa96ed5252ecc3ec3e 160000 --- a/cbindgen +++ b/cbindgen @@ -1 +1 @@ -Subproject commit d14295f3ca588f1d1752ea0a579f0597dd2ce248 +Subproject commit 95821b3bbe857354e3fb1efa96ed5252ecc3ec3e diff --git a/include/bits/signal.h b/include/bits/signal.h deleted file mode 100644 index 8a6a8345d28293871d9ac917575b70545a6659e7..0000000000000000000000000000000000000000 --- a/include/bits/signal.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _BITS_SIGNAL_H -#define _BITS_SIGNAL_H - -typedef struct sigaction { - void (*sa_handler)(uintptr_t); - sigset_t sa_mask; - uintptr_t sa_flags; -}; - -#endif diff --git a/src/fcntl/src/lib.rs b/src/fcntl/src/lib.rs index dc29bb99b41b83c63c245292c050460386d4786d..0c0fa43ce2e5f667bd9b4c3baa89fe8a037a9638 100644 --- a/src/fcntl/src/lib.rs +++ b/src/fcntl/src/lib.rs @@ -6,61 +6,15 @@ extern crate platform; use platform::types::*; +pub use sys::*; + #[cfg(target_os = "linux")] -pub const O_RDONLY: c_int = 0x0000; -#[cfg(target_os = "linux")] -pub const O_WRONLY: c_int = 0x0001; -#[cfg(target_os = "linux")] -pub const O_RDWR: c_int = 0x0002; -#[cfg(target_os = "linux")] -pub const O_CREAT: c_int = 0x0040; -#[cfg(target_os = "linux")] -pub const O_TRUNC: c_int = 0x0200; -#[cfg(target_os = "linux")] -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; -#[cfg(target_os = "linux")] -pub const O_APPEND: c_int = 0o2000; -#[cfg(target_os = "linux")] -pub const O_CLOEXEC: c_int = 0o2_000_000; -#[cfg(target_os = "linux")] -pub const O_EXCL: c_int = 0o200; +#[path = "linux.rs"] +pub mod sys; #[cfg(target_os = "redox")] -pub const O_RDONLY: c_int = 0x0001_0000; -#[cfg(target_os = "redox")] -pub const O_WRONLY: c_int = 0x0002_0000; -#[cfg(target_os = "redox")] -pub const O_RDWR: c_int = 0x0003_0000; -#[cfg(target_os = "redox")] -pub const O_NONBLOCK: c_int = 0x0004_0000; -#[cfg(target_os = "redox")] -pub const O_APPEND: c_int = 0x0008_0000; -#[cfg(target_os = "redox")] -pub const O_SHLOCK: c_int = 0x0010_0000; -#[cfg(target_os = "redox")] -pub const O_EXLOCK: c_int = 0x0020_0000; -#[cfg(target_os = "redox")] -pub const O_ASYNC: c_int = 0x0040_0000; -#[cfg(target_os = "redox")] -pub const O_FSYNC: c_int = 0x0080_0000; -#[cfg(target_os = "redox")] -pub const O_CLOEXEC: c_int = 0x0100_0000; -#[cfg(target_os = "redox")] -pub const O_CREAT: c_int = 0x0200_0000; -#[cfg(target_os = "redox")] -pub const O_TRUNC: c_int = 0x0400_0000; -#[cfg(target_os = "redox")] -pub const O_EXCL: c_int = 0x0800_0000; -#[cfg(target_os = "redox")] -pub const O_DIRECTORY: c_int = 0x1000_0000; -#[cfg(target_os = "redox")] -pub const O_STAT: c_int = 0x2000_0000; -#[cfg(target_os = "redox")] -pub const O_SYMLINK: c_int = 0x4000_0000; -#[cfg(target_os = "redox")] -pub const O_NOFOLLOW: c_int = 0x8000_0000; -#[cfg(target_os = "redox")] -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; +#[path = "redox.rs"] +pub mod sys; pub const F_DUPFD: c_int = 0; pub const F_GETFD: c_int = 1; diff --git a/src/fcntl/src/linux.rs b/src/fcntl/src/linux.rs new file mode 100644 index 0000000000000000000000000000000000000000..ce9499aab713cf36142986d781e8d9ef4b4cc076 --- /dev/null +++ b/src/fcntl/src/linux.rs @@ -0,0 +1,11 @@ +use platform::types::*; + +pub const O_RDONLY: c_int = 0x0000; +pub const O_WRONLY: c_int = 0x0001; +pub const O_RDWR: c_int = 0x0002; +pub const O_CREAT: c_int = 0x0040; +pub const O_TRUNC: c_int = 0x0200; +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; +pub const O_APPEND: c_int = 0o2000; +pub const O_CLOEXEC: c_int = 0o2_000_000; +pub const O_EXCL: c_int = 0o200; diff --git a/src/fcntl/src/redox.rs b/src/fcntl/src/redox.rs new file mode 100644 index 0000000000000000000000000000000000000000..1ea3ca45de4191d7fda1467bff0fcc56f4084e61 --- /dev/null +++ b/src/fcntl/src/redox.rs @@ -0,0 +1,20 @@ +use platform::types::*; + +pub const O_RDONLY: c_int = 0x0001_0000; +pub const O_WRONLY: c_int = 0x0002_0000; +pub const O_RDWR: c_int = 0x0003_0000; +pub const O_NONBLOCK: c_int = 0x0004_0000; +pub const O_APPEND: c_int = 0x0008_0000; +pub const O_SHLOCK: c_int = 0x0010_0000; +pub const O_EXLOCK: c_int = 0x0020_0000; +pub const O_ASYNC: c_int = 0x0040_0000; +pub const O_FSYNC: c_int = 0x0080_0000; +pub const O_CLOEXEC: c_int = 0x0100_0000; +pub const O_CREAT: c_int = 0x0200_0000; +pub const O_TRUNC: c_int = 0x0400_0000; +pub const O_EXCL: c_int = 0x0800_0000; +pub const O_DIRECTORY: c_int = 0x1000_0000; +pub const O_STAT: c_int = 0x2000_0000; +pub const O_SYMLINK: c_int = 0x4000_0000; +pub const O_NOFOLLOW: c_int = 0x8000_0000; +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; diff --git a/src/signal/cbindgen.toml b/src/signal/cbindgen.toml index 87d334c40d12e68bdceec1285de9963da56b69b9..c69f579e82cf28e2f67f04a6c25e8cbbf104f183 100644 --- a/src/signal/cbindgen.toml +++ b/src/signal/cbindgen.toml @@ -1,6 +1,6 @@ sys_includes = ["sys/types.h"] include_guard = "_SIGNAL_H" -trailer = "#include <bits/signal.h>" +style = "Tag" language = "C" [defines] diff --git a/src/signal/src/lib.rs b/src/signal/src/lib.rs index 9a4e781785290bb3e9aa6ff661530b61b230ae70..052cb13770eb2790ff5d12953652e06ddb42b2fc 100644 --- a/src/signal/src/lib.rs +++ b/src/signal/src/lib.rs @@ -4,183 +4,17 @@ extern crate platform; -use platform::types::*; - -#[cfg(target_os = "linux")] -#[repr(C)] -pub struct sigset_t { - pub bits: [u64; 16], -} - -#[cfg(target_os = "linux")] -pub const SIGHUP: usize = 1; -#[cfg(target_os = "linux")] -pub const SIGINT: usize = 2; -#[cfg(target_os = "linux")] -pub const SIGQUIT: usize = 3; -#[cfg(target_os = "linux")] -pub const SIGILL: usize = 4; -#[cfg(target_os = "linux")] -pub const SIGTRAP: usize = 5; -#[cfg(target_os = "linux")] -pub const SIGABRT: usize = 6; -#[cfg(target_os = "linux")] -pub const SIGIOT: usize = SIGABRT; -#[cfg(target_os = "linux")] -pub const SIGBUS: usize = 7; -#[cfg(target_os = "linux")] -pub const SIGFPE: usize = 8; -#[cfg(target_os = "linux")] -pub const SIGKILL: usize = 9; -#[cfg(target_os = "linux")] -pub const SIGUSR1: usize = 10; -#[cfg(target_os = "linux")] -pub const SIGSEGV: usize = 11; -#[cfg(target_os = "linux")] -pub const SIGUSR2: usize = 12; -#[cfg(target_os = "linux")] -pub const SIGPIPE: usize = 13; -#[cfg(target_os = "linux")] -pub const SIGALRM: usize = 14; -#[cfg(target_os = "linux")] -pub const SIGTERM: usize = 15; -#[cfg(target_os = "linux")] -pub const SIGSTKFLT: usize = 16; -#[cfg(target_os = "linux")] -pub const SIGCHLD: usize = 17; -#[cfg(target_os = "linux")] -pub const SIGCONT: usize = 18; -#[cfg(target_os = "linux")] -pub const SIGSTOP: usize = 19; -#[cfg(target_os = "linux")] -pub const SIGTSTP: usize = 20; -#[cfg(target_os = "linux")] -pub const SIGTTIN: usize = 21; -#[cfg(target_os = "linux")] -pub const SIGTTOU: usize = 22; -#[cfg(target_os = "linux")] -pub const SIGURG: usize = 23; -#[cfg(target_os = "linux")] -pub const SIGXCPU: usize = 24; -#[cfg(target_os = "linux")] -pub const SIGXFSZ: usize = 25; -#[cfg(target_os = "linux")] -pub const SIGVTALRM: usize = 26; -#[cfg(target_os = "linux")] -pub const SIGPROF: usize = 27; -#[cfg(target_os = "linux")] -pub const SIGWINCH: usize = 28; -#[cfg(target_os = "linux")] -pub const SIGIO: usize = 29; -#[cfg(target_os = "linux")] -pub const SIGPOLL: usize = 29; -#[cfg(target_os = "linux")] -pub const SIGPWR: usize = 30; -#[cfg(target_os = "linux")] -pub const SIGSYS: usize = 31; -#[cfg(target_os = "linux")] -pub const SIGUNUSED: usize = SIGSYS; - -#[cfg(target_os = "linux")] -pub const SA_NOCLDSTOP: usize = 1; -#[cfg(target_os = "linux")] -pub const SA_NOCLDWAIT: usize = 2; -#[cfg(target_os = "linux")] -pub const SA_SIGINFO: usize = 4; -#[cfg(target_os = "linux")] -pub const SA_ONSTACK: usize = 0x08000000; #[cfg(target_os = "linux")] -pub const SA_RESTART: usize = 0x10000000; -#[cfg(target_os = "linux")] -pub const SA_NODEFER: usize = 0x40000000; -#[cfg(target_os = "linux")] -pub const SA_RESETHAND: usize = 0x80000000; -#[cfg(target_os = "linux")] -pub const SA_RESTORER: usize = 0x04000000; +#[path = "linux.rs"] +pub mod sys; #[cfg(target_os = "redox")] -#[repr(C)] -pub struct sigset_t { - pub bits: [u64; 2], -} +#[path = "redox.rs"] +pub mod sys; -#[cfg(target_os = "redox")] -pub const SIGHUP: usize = 1; -#[cfg(target_os = "redox")] -pub const SIGINT: usize = 2; -#[cfg(target_os = "redox")] -pub const SIGQUIT: usize = 3; -#[cfg(target_os = "redox")] -pub const SIGILL: usize = 4; -#[cfg(target_os = "redox")] -pub const SIGTRAP: usize = 5; -#[cfg(target_os = "redox")] -pub const SIGBUS: usize = 7; -#[cfg(target_os = "redox")] -pub const SIGFPE: usize = 8; -#[cfg(target_os = "redox")] -pub const SIGKILL: usize = 9; -#[cfg(target_os = "redox")] -pub const SIGUSR1: usize = 10; -#[cfg(target_os = "redox")] -pub const SIGSEGV: usize = 11; -#[cfg(target_os = "redox")] -pub const SIGUSR2: usize = 12; -#[cfg(target_os = "redox")] -pub const SIGPIPE: usize = 13; -#[cfg(target_os = "redox")] -pub const SIGALRM: usize = 14; -#[cfg(target_os = "redox")] -pub const SIGTERM: usize = 15; -#[cfg(target_os = "redox")] -pub const SIGSTKFLT: usize = 16; -#[cfg(target_os = "redox")] -pub const SIGCHLD: usize = 17; -#[cfg(target_os = "redox")] -pub const SIGCONT: usize = 18; -#[cfg(target_os = "redox")] -pub const SIGSTOP: usize = 19; -#[cfg(target_os = "redox")] -pub const SIGTSTP: usize = 20; -#[cfg(target_os = "redox")] -pub const SIGTTIN: usize = 21; -#[cfg(target_os = "redox")] -pub const SIGTTOU: usize = 22; -#[cfg(target_os = "redox")] -pub const SIGURG: usize = 23; -#[cfg(target_os = "redox")] -pub const SIGXCPU: usize = 24; -#[cfg(target_os = "redox")] -pub const SIGXFSZ: usize = 25; -#[cfg(target_os = "redox")] -pub const SIGVTALRM: usize = 26; -#[cfg(target_os = "redox")] -pub const SIGPROF: usize = 27; -#[cfg(target_os = "redox")] -pub const SIGWINCH: usize = 28; -#[cfg(target_os = "redox")] -pub const SIGIO: usize = 29; -#[cfg(target_os = "redox")] -pub const SIGPWR: usize = 30; -#[cfg(target_os = "redox")] -pub const SIGSYS: usize = 31; +pub use sys::*; -#[cfg(target_os = "redox")] -pub const SA_NOCLDSTOP: usize = 0x00000001; -#[cfg(target_os = "redox")] -pub const SA_NOCLDWAIT: usize = 0x00000002; -#[cfg(target_os = "redox")] -pub const SA_SIGINFO: usize = 0x00000004; -#[cfg(target_os = "redox")] -pub const SA_RESTORER: usize = 0x04000000; -#[cfg(target_os = "redox")] -pub const SA_ONSTACK: usize = 0x08000000; -#[cfg(target_os = "redox")] -pub const SA_RESTART: usize = 0x10000000; -#[cfg(target_os = "redox")] -pub const SA_NODEFER: usize = 0x40000000; -#[cfg(target_os = "redox")] -pub const SA_RESETHAND: usize = 0x80000000; +use platform::types::*; #[repr(C)] pub struct sigaction { @@ -189,6 +23,8 @@ pub struct sigaction { pub sa_flags: usize, } +pub type sigset_t = sys_sigset_t; + #[no_mangle] pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int { unimplemented!(); diff --git a/src/signal/src/linux.rs b/src/signal/src/linux.rs new file mode 100644 index 0000000000000000000000000000000000000000..628e81339038ddd8b29deba55c59664224f86db1 --- /dev/null +++ b/src/signal/src/linux.rs @@ -0,0 +1,48 @@ +#[repr(C)] +pub struct sys_sigset_t { + pub bits: [u64; 16], +} + +pub const SIGHUP: usize = 1; +pub const SIGINT: usize = 2; +pub const SIGQUIT: usize = 3; +pub const SIGILL: usize = 4; +pub const SIGTRAP: usize = 5; +pub const SIGABRT: usize = 6; +pub const SIGIOT: usize = SIGABRT; +pub const SIGBUS: usize = 7; +pub const SIGFPE: usize = 8; +pub const SIGKILL: usize = 9; +pub const SIGUSR1: usize = 10; +pub const SIGSEGV: usize = 11; +pub const SIGUSR2: usize = 12; +pub const SIGPIPE: usize = 13; +pub const SIGALRM: usize = 14; +pub const SIGTERM: usize = 15; +pub const SIGSTKFLT: usize = 16; +pub const SIGCHLD: usize = 17; +pub const SIGCONT: usize = 18; +pub const SIGSTOP: usize = 19; +pub const SIGTSTP: usize = 20; +pub const SIGTTIN: usize = 21; +pub const SIGTTOU: usize = 22; +pub const SIGURG: usize = 23; +pub const SIGXCPU: usize = 24; +pub const SIGXFSZ: usize = 25; +pub const SIGVTALRM: usize = 26; +pub const SIGPROF: usize = 27; +pub const SIGWINCH: usize = 28; +pub const SIGIO: usize = 29; +pub const SIGPOLL: usize = 29; +pub const SIGPWR: usize = 30; +pub const SIGSYS: usize = 31; +pub const SIGUNUSED: usize = SIGSYS; + +pub const SA_NOCLDSTOP: usize = 1; +pub const SA_NOCLDWAIT: usize = 2; +pub const SA_SIGINFO: usize = 4; +pub const SA_ONSTACK: usize = 0x08000000; +pub const SA_RESTART: usize = 0x10000000; +pub const SA_NODEFER: usize = 0x40000000; +pub const SA_RESETHAND: usize = 0x80000000; +pub const SA_RESTORER: usize = 0x04000000; diff --git a/src/signal/src/redox.rs b/src/signal/src/redox.rs new file mode 100644 index 0000000000000000000000000000000000000000..b5108b5a62a249a9e8ace1a4b4100c87728b59ce --- /dev/null +++ b/src/signal/src/redox.rs @@ -0,0 +1,44 @@ +#[repr(C)] +pub struct sys_sigset_t { + pub bits: [u64; 2], +} + +pub const SIGHUP: usize = 1; +pub const SIGINT: usize = 2; +pub const SIGQUIT: usize = 3; +pub const SIGILL: usize = 4; +pub const SIGTRAP: usize = 5; +pub const SIGBUS: usize = 7; +pub const SIGFPE: usize = 8; +pub const SIGKILL: usize = 9; +pub const SIGUSR1: usize = 10; +pub const SIGSEGV: usize = 11; +pub const SIGUSR2: usize = 12; +pub const SIGPIPE: usize = 13; +pub const SIGALRM: usize = 14; +pub const SIGTERM: usize = 15; +pub const SIGSTKFLT: usize = 16; +pub const SIGCHLD: usize = 17; +pub const SIGCONT: usize = 18; +pub const SIGSTOP: usize = 19; +pub const SIGTSTP: usize = 20; +pub const SIGTTIN: usize = 21; +pub const SIGTTOU: usize = 22; +pub const SIGURG: usize = 23; +pub const SIGXCPU: usize = 24; +pub const SIGXFSZ: usize = 25; +pub const SIGVTALRM: usize = 26; +pub const SIGPROF: usize = 27; +pub const SIGWINCH: usize = 28; +pub const SIGIO: usize = 29; +pub const SIGPWR: usize = 30; +pub const SIGSYS: usize = 31; + +pub const SA_NOCLDSTOP: usize = 0x00000001; +pub const SA_NOCLDWAIT: usize = 0x00000002; +pub const SA_SIGINFO: usize = 0x00000004; +pub const SA_RESTORER: usize = 0x04000000; +pub const SA_ONSTACK: usize = 0x08000000; +pub const SA_RESTART: usize = 0x10000000; +pub const SA_NODEFER: usize = 0x40000000; +pub const SA_RESETHAND: usize = 0x80000000; diff --git a/src/string/src/lib.rs b/src/string/src/lib.rs index 5b5c15832b983c7fa1f02e777d8b6740a86b0655..3fd95d0014e64c2edf6369ee6dfe879a2e06381c 100644 --- a/src/string/src/lib.rs +++ b/src/string/src/lib.rs @@ -250,8 +250,13 @@ pub unsafe extern "C" fn strncpy(s1: *mut c_char, s2: *const c_char, n: usize) - } #[no_mangle] -pub extern "C" fn strpbrk(s1: *const c_char, s2: *const c_char) -> *mut c_char { - unimplemented!(); +pub unsafe extern "C" fn strpbrk(s1: *const c_char, s2: *const c_char) -> *mut c_char { + let p = s1.offset(strcspn(s1, s2) as isize); + if *p != 0 { + p as *mut c_char + } else { + ptr::null_mut() + } } #[no_mangle] @@ -299,8 +304,22 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong } #[no_mangle] -pub extern "C" fn strstr(s1: *const c_char, s2: *const c_char) -> *mut c_char { - unimplemented!(); +pub unsafe extern "C" fn strstr(s1: *const c_char, s2: *const c_char) -> *mut c_char { + let mut i = 0; + while *s1.offset(i) != 0 { + let mut j = 0; + while *s2.offset(j) != 0 && *s1.offset(j + i) != 0 { + if *s2.offset(j) != *s1.offset(j + i) { + break; + } + j += 1; + if *s2.offset(j) == 0 { + return s1.offset(i) as *mut c_char; + } + } + i += 1; + } + ptr::null_mut() } #[no_mangle] diff --git a/src/wait/cbindgen.toml b/src/wait/cbindgen.toml index 186d5f9573063eb9d2b1e625681131b372d77d41..528282cf3a32bcf628c85e18edff603ce6b2f962 100644 --- a/src/wait/cbindgen.toml +++ b/src/wait/cbindgen.toml @@ -1,5 +1,6 @@ sys_includes = ["sys/types.h", "sys/resource.h"] include_guard = "_SYS_WAIT_H" +style = "Tag" language = "C" [enum] diff --git a/tests/Makefile b/tests/Makefile index 43b5512399d92ed67b19a414fcc1c3de0b8b9519..f5e47bb4e4f3b536975b95addf32e704bbe66817 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -31,6 +31,8 @@ EXPECT_BINS=\ string/strchr \ string/strrchr \ string/strspn \ + string/strstr \ + string/strpbrk \ unlink \ write diff --git a/tests/expected/string/strpbrk.stderr b/tests/expected/string/strpbrk.stderr new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/expected/string/strpbrk.stdout b/tests/expected/string/strpbrk.stdout new file mode 100644 index 0000000000000000000000000000000000000000..7a6bc8b0891622c15710c10ff02546f8d6431179 --- /dev/null +++ b/tests/expected/string/strpbrk.stdout @@ -0,0 +1,3 @@ +The quick drawn fix jumps over the lazy bug +lazy bug +NULL diff --git a/tests/expected/string/strstr.stderr b/tests/expected/string/strstr.stderr new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/expected/string/strstr.stdout b/tests/expected/string/strstr.stdout new file mode 100644 index 0000000000000000000000000000000000000000..e978edff7f142deb5af595baa3d297e01180e911 --- /dev/null +++ b/tests/expected/string/strstr.stdout @@ -0,0 +1,3 @@ +rust +libc we trust +NULL diff --git a/tests/string/strpbrk.c b/tests/string/strpbrk.c new file mode 100644 index 0000000000000000000000000000000000000000..dc0ebf7c534c1a92ea997a7aa212f8227c2cfc5d --- /dev/null +++ b/tests/string/strpbrk.c @@ -0,0 +1,20 @@ +#include <string.h> +#include <stdio.h> + +int main(int argc, char* argv[]) { + char* source = "The quick drawn fix jumps over the lazy bug"; + + // should be "The quick drawn fix jumps over the lazy bug" + char* res1 = strpbrk(source, "From The Very Beginning"); + printf("%s\n", (res1) ? res1 : "NULL"); + + // should be "lazy bug" + char* res2 = strpbrk(source, "lzbg"); + printf("%s\n", (res2) ? res2 : "NULL"); + + // should be "NULL" + char* res3 = strpbrk(source, "404"); + printf("%s\n", (res3) ? res3 : "NULL"); + + return 0; +} diff --git a/tests/string/strstr.c b/tests/string/strstr.c new file mode 100644 index 0000000000000000000000000000000000000000..6a074d18d83ca3c3fec9aa676866f171c84335de --- /dev/null +++ b/tests/string/strstr.c @@ -0,0 +1,18 @@ +#include <string.h> +#include <stdio.h> + +int main(int argc, char* argv[]) { + // should be "rust" + char* res1 = strstr("In relibc we trust", "rust"); + printf("%s\n", (res1) ? res1 : "NULL"); + + // should be "libc we trust" + char* res2 = strstr("In relibc we trust", "libc"); + printf("%s\n", (res2) ? res2 : "NULL"); + + // should be "NULL" + char* res3 = strstr("In relibc we trust", "bugs"); + printf("%s\n", (res3) ? res3 : "NULL"); + + return 0; +}