From ff628cced569f634ba9da5e61a87f9854c474c55 Mon Sep 17 00:00:00 2001 From: wangmengc Date: Thu, 28 Sep 2023 08:42:52 +0800 Subject: [PATCH] add errno,savestring,DESCRIBE_PID, NO_PID and RESIZE_MALLOCED_BUFFER macro --- bash-5.1/r_execute_cmd/src/lib.rs | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index d0287334..34d49f81 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -74,6 +74,59 @@ macro_rules! QUIT { } }; } +#[macro_export] +macro_rules! errno { + () => { + *__errno_location() + }; +} + +#[macro_export] +macro_rules! savestring { + ($x:expr) => { + strcpy(malloc((strlen($x as *const c_char) + 1) as usize) as *mut c_char, $x) as *mut c_char + }; +} + +#[macro_export] +macro_rules! DESCRIBE_PID { + ($pid:expr) => { + if interactive != 0 { + describe_pid($pid); + } + }; +} + +#[macro_export] +macro_rules! NO_PID { + () => { + -1 as pid_t + }; +} + +#[macro_export] +macro_rules! RESIZE_MALLOCED_BUFFER { + ($srt:expr,$cind:expr, $room:expr, $csize:expr, $sincr:expr) => { + if $cind + $room >= $csize { + while $cind + $room >= $csize { + $csize += $sincr; + } + $srt = realloc($srt as *mut c_void, $csize as usize) as *mut c_char; + } + }; +} + + + + + + + + + + + + #[no_mangle] -- Gitee