Also replace __UNIX__ with R2__UNIX__

This commit is contained in:
pancake 2022-12-10 19:25:57 +01:00 committed by pancake
parent 97a6439055
commit b8e6b52aac
62 changed files with 179 additions and 179 deletions

View File

@ -8,7 +8,7 @@
static RCore *core = NULL;
#if __UNIX__
#if R2__UNIX__
// XXX check if its already opened
static RCoreFile *openself(void) {

View File

@ -95,7 +95,7 @@ static void path_left_free_kv(HtPPKv *kv) {
}
static bool r2r_chdir(const char *argv0) {
#if __UNIX__
#if R2__UNIX__
if (r_file_is_directory ("db")) {
return true;
}
@ -1101,7 +1101,7 @@ static void replace_cmd_kv_file(const char *path, ut64 line_begin, ut64 line_end
return;
}
if (r_file_dump (path, (const ut8 *)newc, -1, false)) {
#if __UNIX__ && !(__wasi__ || __EMSCRIPTEN__)
#if R2__UNIX__ && !(__wasi__ || __EMSCRIPTEN__)
sync ();
#endif
} else {

View File

@ -1250,7 +1250,7 @@ static bool require_check(const char *require) {
res &= r_file_exists ("/usr/bin/as");
}
if (strstr (require, "unix")) {
#if __UNIX__
#if R2__UNIX__
res &= true;
#else
res = false;

View File

@ -3,7 +3,7 @@ include ../../../mk/platform.mk
ifeq ($(WITHPIC),1)
CFLAGS+=-I../../include -I../arch/ -I../arch/include -Wall ${PIC_CFLAGS} ${LDFLAGS_LIB}
CFLAGS+=-D__UNIX__
CFLAGS+=-DR2__UNIX__
all: ${ALL_TARGETS}

View File

@ -160,7 +160,7 @@ static char *swift_demangle_cmd(const char *s) {
}
static char *swift_demangle_lib(const char *s) {
#if __UNIX__
#if R2__UNIX__
static R_TH_LOCAL bool haveSwiftCore = false;
static R_TH_LOCAL char *(*swift_demangle)(const char *sym, int symlen, void *out, int *outlen, int flags, int unk) = NULL;
if (!haveSwiftCore) {

View File

@ -3,7 +3,7 @@ include ../../../mk/platform.mk
ifeq ($(WITHPIC),1)
CFLAGS+=-I../../include -I../arch/ -I../arch/include -Wall ${PIC_CFLAGS} ${LDFLAGS_LIB}
CFLAGS+=-D__UNIX__
CFLAGS+=-DR2__UNIX__
all: ${ALL_TARGETS}

View File

@ -102,35 +102,35 @@ TH_LIBS=
endif
ifeq (${OSTYPE},bsd)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=
TH_LIBS=-lpthread
endif
ifeq (${OSTYPE},qnx)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=
TH_LIBS=
endif
ifeq (${OSTYPE},gnulinux)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=
TH_LIBS=-lpthread
endif
ifeq (${OSTYPE},haiku)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=
TH_LIBS=
endif
ifeq (${OSTYPE},darwin)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=dylib
EXT_EXE=
@ -143,21 +143,21 @@ TH_LIBS=-lpthread
endif
endif
ifeq (${OSTYPE},android)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=
TH_LIBS=
endif
ifeq (${OSTYPE},solaris)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=
TH_LIBS=
endif
ifeq (${OSTYPE},serenityos)
CFLAGS+=-D__UNIX__=1
CFLAGS+=-DR2__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=

View File

@ -340,7 +340,7 @@ R_API void r_cons_context_break_push(RConsContext *context, RConsBreak cb, void
return;
}
if (r_stack_is_empty (context->break_stack)) {
#if __UNIX__
#if R2__UNIX__
if (!C->unbreakable) {
if (sig && r_cons_context_is_main ()) {
r_sys_signal (SIGINT, __break_signal);
@ -371,7 +371,7 @@ R_API void r_cons_context_break_pop(RConsContext *context, bool sig) {
break_stack_free (b);
} else {
//there is not more elements in the stack
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
if (sig && r_cons_context_is_main ()) {
if (!C->unbreakable) {
r_sys_signal (SIGINT, SIG_IGN);
@ -461,7 +461,7 @@ R_API int r_cons_get_cur_line(void) {
}
curline = info.dwCursorPosition.Y - info.srWindow.Top;
#endif
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
char buf[8];
struct termios save,raw;
// flush the Arrow keys escape keys which was messing up the output
@ -493,7 +493,7 @@ R_API void r_cons_break_timeout(int timeout) {
R_API void r_cons_break_end(void) {
C->breaked = false;
I->timeout = 0;
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
if (!C->unbreakable) {
r_sys_signal (SIGINT, SIG_IGN);
}
@ -539,7 +539,7 @@ static BOOL __w32_control(DWORD type) {
}
return false;
}
#elif __UNIX__
#elif R2__UNIX__
volatile sig_atomic_t sigwinchFlag;
static void resize(int sig) {
sigwinchFlag = 1;
@ -667,7 +667,7 @@ R_API RCons *r_cons_new(void) {
#endif
#if EMSCRIPTEN || __wasi__
/* do nothing here :? */
#elif __UNIX__
#elif R2__UNIX__
tcgetattr (0, &I->term_buf);
memcpy (&I->term_raw, &I->term_buf, sizeof (I->term_raw));
I->term_raw.c_iflag &= ~(BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
@ -1476,7 +1476,7 @@ R_API bool r_cons_is_windows(void) {
R_API bool r_cons_is_tty(void) {
#if EMSCRIPTEN || __wasi__
return false;
#elif __UNIX__
#elif R2__UNIX__
struct winsize win = {0};
const char *tty;
struct stat sb;
@ -1608,7 +1608,7 @@ R_API int r_cons_get_size(int *rows) {
#elif EMSCRIPTEN || __wasi__
I->columns = 80;
I->rows = 23;
#elif __UNIX__
#elif R2__UNIX__
struct winsize win = {0};
if (isatty (0) && !ioctl (0, TIOCGWINSZ, &win)) {
if ((!win.ws_col) || (!win.ws_row)) {
@ -1777,7 +1777,7 @@ R_API void r_cons_set_raw(bool is_raw) {
}
#if EMSCRIPTEN || __wasi__
/* do nothing here */
#elif __UNIX__
#elif R2__UNIX__
// enforce echo off
if (is_raw) {
I->term_raw.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
@ -1845,7 +1845,7 @@ smcup: disable terminal scrolling (fullscreen mode)
rmcup: enable terminal scrolling (normal mode)
#endif
R_API bool r_cons_set_cup(bool enable) {
#if __UNIX__
#if R2__UNIX__
const char *code = enable
? "\x1b[?1049h" "\x1b" "7\x1b[?47h"
: "\x1b[?1049l" "\x1b[?47l" "\x1b" "8";

View File

@ -3,7 +3,7 @@
// Copypasta from http://www.linuxquestions.org/questions/programming-9/get-cursor-position-in-c-947833/
#include <r_cons.h>
#if __UNIX__
#if R2__UNIX__
#include <stdio.h>
#include <fcntl.h>
#if HAVE_PTY

View File

@ -2,7 +2,7 @@
#include <r_cons.h>
#include <string.h>
#if __UNIX__
#if R2__UNIX__
#include <errno.h>
#endif
@ -14,7 +14,7 @@ static int readbuffer_length = 0;
static bool bufactive = true;
#if 0
//__UNIX__
//R2__UNIX__
#include <poll.h>
static int __is_fd_ready(int fd) {
fd_set rfds;
@ -33,7 +33,7 @@ static int __is_fd_ready(int fd) {
#endif
R_API int r_cons_controlz(int ch) {
#if __UNIX__
#if R2__UNIX__
if (ch == 0x1a) {
r_cons_show_cursor (true);
r_cons_enable_mouse (false);
@ -557,7 +557,7 @@ static int __cons_readchar_w32(ut32 usec) {
#endif
R_API int r_cons_readchar_timeout(ut32 usec) {
#if __UNIX__
#if R2__UNIX__
struct timeval tv;
fd_set fdset, errset;
FD_ZERO (&fdset);
@ -697,7 +697,7 @@ R_API char *r_cons_password(const char *msg) {
printf ("\r%s", msg);
fflush (stdout);
r_cons_set_raw (1);
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
RCons *a = r_cons_singleton ();
a->term_raw.c_lflag &= ~(ECHO | ECHONL);
// // required to make therm/iterm show the key
@ -728,7 +728,7 @@ R_API char *r_cons_password(const char *msg) {
buf[i] = 0;
r_cons_set_raw (0);
printf ("\n");
#if __UNIX__
#if R2__UNIX__
r_sys_signal (SIGTSTP, SIG_DFL);
#endif
return buf;

View File

@ -3916,7 +3916,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("cmd.cprompt", "", "column visual prompt commands");
SETPREF ("cmd.gprompt", "", "graph visual prompt commands");
SETPREF ("cmd.hit", "", "run when a search hit is found");
#if __UNIX__
#if R2__UNIX__
SETPREF ("cmd.usr1", "", "run when SIGUSR1 signal is received");
SETPREF ("cmd.usr2", "", "run when SIGUSR2 signal is received");
#endif

View File

@ -3,7 +3,7 @@
#define INTERACTIVE_MAX_REP 1024
#include <r_core.h>
#if __UNIX__
#if R2__UNIX__
#include <sys/utsname.h>
#ifndef __wasi__
#include <pwd.h>
@ -3338,7 +3338,7 @@ err_r_w32_cmd_pipe:
#endif
R_API int r_core_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd) {
#if __UNIX__ && !__wasi__ && HAVE_FORK
#if R2__UNIX__ && !__wasi__ && HAVE_FORK
int stdout_fd, fds[2];
int child;
#endif
@ -3369,7 +3369,7 @@ R_API int r_core_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd) {
}
#if !HAVE_FORK
// nothing
#elif __UNIX__
#elif R2__UNIX__
r_str_trim_head (radare_cmd);
r_str_trim_head (shell_cmd);
@ -5778,7 +5778,7 @@ R_API int r_core_cmd_lines(RCore *core, const char *lines) {
}
size_t line_count = r_str_char_count(lines, '\n');
#if __UNIX__
#if R2__UNIX__
const bool istty = r_cons_is_tty ();
#else
const bool istty = true;

View File

@ -7656,7 +7656,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
envp[i] = arg;
}
envp[i] = 0;
#if __UNIX__
#if R2__UNIX__
if (strstr (input, "$env")) {
extern char **environ;
cmd_debug_stack_init (core, argc, argv, environ);

View File

@ -4,7 +4,7 @@
#include <r_core.h>
#include <config.h>
#if __UNIX__
#if R2__UNIX__
#include <signal.h>
#endif
@ -2995,7 +2995,7 @@ static bool cbcore(void *user, int type, const char *origin, const char *msg) {
return false;
}
#if __UNIX__
#if R2__UNIX__
static R_TH_LOCAL RCore *Gcore = NULL;
static void cmdusr1(int p) {
@ -3016,7 +3016,7 @@ static void cmdusr2(int p) {
#endif
R_API bool r_core_init(RCore *core) {
#if __UNIX__
#if R2__UNIX__
Gcore = core;
r_sys_signal (SIGUSR1, cmdusr1);
r_sys_signal (SIGUSR2, cmdusr2);

View File

@ -213,7 +213,7 @@ static char *rtr_dir_files(const char *path) {
return r_str_append (ptr, "</body></html>\n");
}
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
static void dietime(int sig) {
eprintf ("It's Time To Die!\n");
exit (0);
@ -223,7 +223,7 @@ static void dietime(int sig) {
static void activateDieTime(RCore *core) {
int dt = r_config_get_i (core->config, "http.dietime");
if (dt > 0) {
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
r_sys_signal (SIGALRM, dietime);
alarm (dt);
#else
@ -904,7 +904,7 @@ R_API void r_core_rtr_event(RCore *core, const char *input) {
}
if (!strcmp (input, "errmsg")) {
// TODO: support udp, tcp, rap, ...
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
char *f = r_file_temp ("errmsg");
r_cons_printf ("%s\n", f);
r_file_rm (f);

View File

@ -71,7 +71,7 @@ TODO:
break;
case 'i':
{
#if __UNIX__
#if R2__UNIX__
#define COLORFLAGS (core->print->flags & R_PRINT_FLAGS_COLOR)
#else
#define COLORFLAGS 0
@ -111,7 +111,7 @@ TODO:
eprintf ("Press <enter> to return to Visual mode.\n");
do {
char buf[1024];
#if __UNIX__
#if R2__UNIX__
r_line_set_prompt (Color_RESET":> ");
#else
r_line_set_prompt (":> ");

View File

@ -24,7 +24,7 @@ bool linux_generate_corefile(RDebug *dbg, RBuffer *dest);
#include "native/bt.c"
#if __UNIX__
#if R2__UNIX__
# include <errno.h>
# if !defined (__HAIKU__) && !defined (__sun)
# include <sys/ptrace.h>

View File

@ -3,7 +3,7 @@ include ../../../mk/platform.mk
ifeq ($(WITHPIC),1)
CFLAGS+=-I../../include -I../arch/ -I../arch/include -Wall ${PIC_CFLAGS} ${LDFLAGS_LIB}
CFLAGS+=-D__UNIX__
CFLAGS+=-DR2__UNIX__
all: ${ALL_TARGETS}

View File

@ -28,7 +28,7 @@ extern "C" {
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#if __UNIX__
#if R2__UNIX__
#ifndef __wasi__
#include <termios.h>
#include <sys/wait.h>
@ -475,7 +475,7 @@ typedef struct r_cons_t {
RConsFunctionKey cb_fkey;
void *user; // Used by <RCore*>
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
struct termios term_raw, term_buf;
#elif R2__WINDOWS__
DWORD term_raw, term_buf, term_xterm;

View File

@ -4,7 +4,7 @@
#include "r_types.h"
#include "r_list.h"
#if __UNIX__ && WANT_DYLINK
#if R2__UNIX__ && WANT_DYLINK
#include <dlfcn.h>
#endif

View File

@ -11,7 +11,7 @@ extern "C" {
R_LIB_VERSION_HEADER (r_socket);
#if __UNIX__
#if R2__UNIX__
#include <netinet/in.h>
#include <sys/un.h>
#include <poll.h>
@ -28,7 +28,7 @@ R_LIB_VERSION_HEADER (r_socket);
#include <openssl/err.h>
#endif
#if __UNIX__
#if R2__UNIX__
#include <netinet/tcp.h>
#endif
@ -100,7 +100,7 @@ R_API bool r_socket_connect(RSocket *s, const char *host, const char *port, int
R_API int r_socket_connect_serial(RSocket *sock, const char *path, int speed, int parity);
#define r_socket_connect_tcp(a, b, c, d) r_socket_connect (a, b, c, R_SOCKET_PROTO_TCP, d)
#define r_socket_connect_udp(a, b, c, d) r_socket_connect (a, b, c, R_SOCKET_PROTO_UDP, d)
#if __UNIX__
#if R2__UNIX__
#define r_socket_connect_unix(a, b) r_socket_connect (a, b, b, R_SOCKET_PROTO_UNIX, 0)
#else
#define r_socket_connect_unix(a, b) (false)

View File

@ -18,7 +18,7 @@
/* operating system */
#undef R2__BSD__
#undef __KFBSD__
#undef __UNIX__
#undef R2__UNIX__
#undef R2__WINDOWS__
#define R_MODE_PRINT 0x000
@ -174,23 +174,23 @@
#endif
#ifdef __HAIKU__
# define __UNIX__ 1
# define R2__UNIX__ 1
#endif
#undef HAVE_PTY
#if EMSCRIPTEN || __wasi__ || defined(__serenity__)
#define HAVE_PTY 0
#else
#define HAVE_PTY __UNIX__ && LIBC_HAVE_FORK && !__sun
#define HAVE_PTY R2__UNIX__ && LIBC_HAVE_FORK && !__sun
#endif
#if defined(EMSCRIPTEN) || defined(__wasi__) || defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__) || defined(__sun) || defined(__HAIKU__) || defined(__serenity__) || defined(__vinix__)
#define R2__BSD__ 0
#define __UNIX__ 1
#define R2__UNIX__ 1
#endif
#if __KFBSD__ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
#define R2__BSD__ 1
#define __UNIX__ 1
#define R2__UNIX__ 1
#endif
#if R2__WINDOWS__ || _WIN32
#ifdef _MSC_VER
@ -204,7 +204,7 @@
typedef int socklen_t;
#undef USE_SOCKETS
#define R2__WINDOWS__ 1
#undef __UNIX__
#undef R2__UNIX__
#undef R2__BSD__
#endif
#if R2__WINDOWS__ || _WIN32
@ -392,7 +392,7 @@ static inline void *r_new_copy(int size, void *data) {
#define r_sys_perror(x) r_sys_perror_str(x);
#endif
#if __UNIX__
#if R2__UNIX__
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

View File

@ -1,7 +1,7 @@
#ifndef R_SIGNAL_H
#define R_SIGNAL_H
#if __UNIX__
#if R2__UNIX__
#include <signal.h>
#endif
@ -17,7 +17,7 @@ R_API const char* r_signal_tostring(int code);
R_API const char *r_signal_to_human(int signum);
// XXX this function should be portable, not-unix specific
#if __UNIX__
#if R2__UNIX__
R_API void r_signal_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask);
#endif

View File

@ -14,7 +14,7 @@
#define MAGIC_EXIT 123
#include <signal.h>
#if __UNIX__
#if R2__UNIX__
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
@ -295,7 +295,7 @@ static void handle_posix_redirection(RRunProfile *rp, posix_spawn_file_actions_t
}
}
// __UNIX__ (not windows)
// R2__UNIX__ (not windows)
static int fork_and_ptraceme_for_mac(RIO *io, int bits, const char *cmd) {
pid_t p = -1;
posix_spawn_file_actions_t fileActions;

View File

@ -302,7 +302,7 @@ static bool __resize(RIO *io, RIODesc *fd, ut64 size) {
return r_io_def_mmap_truncate (mmo, size);
}
#if __UNIX__
#if R2__UNIX__
static bool __is_blockdevice(RIODesc *desc) {
r_return_val_if_fail (desc && desc->data, false);
RIOMMapFileObj *mmo = desc->data;
@ -326,7 +326,7 @@ RIOPlugin r_io_plugin_default = {
.seek = __lseek,
.write = __write,
.resize = __resize,
#if __UNIX__
#if R2__UNIX__
.is_blockdevice = __is_blockdevice,
#endif
};

View File

@ -20,7 +20,7 @@
#include <windows.h>
#else
#if __UNIX__
#if R2__UNIX__
#include <errno.h>
#include <fcntl.h>
#endif
@ -83,7 +83,7 @@ enum {
GPROBE_RUN_CODE_2 = 0x54,
};
#if __UNIX__
#if R2__UNIX__
static ut8 gprobe_checksum_i2c(const ut8 *p, unsigned int size, ut8 initial) {
ut8 res = initial;
unsigned int k;
@ -1118,7 +1118,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
gprobe->gport.name = pathname + strlen ("gprobe://");
if (r_str_startswith (gprobe->gport.name, "i2c-")) {
#if __UNIX__
#if R2__UNIX__
gprobe->gport.send_request = gprobe_send_request_i2c;
gprobe->gport.get_reply = gprobe_get_reply_i2c;
gprobe->gport.frame = gprobe_frame_i2c;

View File

@ -5,8 +5,8 @@
#include <sys/types.h>
#if __ANDROID__ || EMSCRIPTEN
#undef __UNIX__
#define __UNIX__ 0
#undef R2__UNIX__
#define R2__UNIX__ 0
#endif
// linux requires -lrt for this, but still it seems to not work as expected
@ -14,7 +14,7 @@
// make this work across all unixes without adding extra depenencies
#define USE_SHM_OPEN 0
#if __UNIX__ && !defined (__QNX__) && !defined (__HAIKU__)
#if R2__UNIX__ && !defined (__QNX__) && !defined (__HAIKU__)
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/mman.h>

View File

@ -138,7 +138,7 @@ static bool __close(RIODesc *fd) {
if (!fd || !fd->data) {
return false;
}
#if __UNIX__
#if R2__UNIX__
r_sys_cmdf ("pkill rarun2 2>/dev/null");
#endif
return true;

View File

@ -13,7 +13,7 @@ R_LIB_VERSION(r_lang);
#include "p/vala.c" // hardcoded
#include "p/rust.c" // hardcoded
#include "p/zig.c" // hardcoded
#if __UNIX__
#if R2__UNIX__
#include "p/cpipe.c" // hardcoded
#endif
#endif
@ -41,7 +41,7 @@ R_API RLang *r_lang_new(void) {
lang->defs->free = (RListFree)r_lang_def_free;
lang->cb_printf = (PrintfCallback)printf;
#if HAVE_SYSTEM
#if __UNIX__
#if R2__UNIX__
r_lang_add (lang, &r_lang_plugin_c);
r_lang_add (lang, &r_lang_plugin_cpipe);
#endif

View File

@ -6,7 +6,7 @@
#include "r_core.h"
#include "r_lang.h"
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
static int ac = 0;
static const char **av = NULL;

View File

@ -6,7 +6,7 @@
#include "r_core.h"
#include "r_lang.h"
#if __UNIX__
#if R2__UNIX__
static int lang_cpipe_file(RLangSession *lang, const char *file) {
char *a, *cc, *p, name[512];
const char *libpath, *libname;

View File

@ -130,7 +130,7 @@ static void env(const char *s, int f) {
#endif
static bool lang_pipe_run(RLangSession *s, const char *code, int len) {
#if __UNIX__
#if R2__UNIX__
int safe_in = dup (0);
int child, ret;
int input[2];

View File

@ -38,7 +38,7 @@
#include "file.h"
#include "patchlevel.h"
#if __UNIX__ && !defined(_MSC_VER) && !(defined(__wasi__))
#if R2__UNIX__ && !defined(_MSC_VER) && !(defined(__wasi__))
# define QUICK 1
# include <sys/mman.h>
# include <sys/param.h>

View File

@ -241,7 +241,7 @@ static void striptrim(RList *list) {
}
static void r2pm_upgrade(bool force) {
#if __UNIX__
#if R2__UNIX__
char *s = r_sys_cmd_str ("radare2 -qcq -- 2>&1 | grep r2pm | sed -e 's,$,;,g'", NULL, 0);
r_str_trim (s);
RList *list = r_str_split_list (s, "\n", -1);

View File

@ -1022,7 +1022,7 @@ R_API int r_main_rabin2(int argc, const char **argv) {
}
if (file && *file && action & R_BIN_REQ_DLOPEN) {
#if __UNIX__ && HAVE_FORK
#if R2__UNIX__ && HAVE_FORK
int child = r_sys_fork ();
if (child == -1) {
r_core_fini (&core);

View File

@ -1123,7 +1123,7 @@ R_API int r_main_radare2(int argc, const char **argv) {
char *buf = r_stdin_slurp (&sz);
eprintf ("^D\n");
r_cons_set_raw (false);
#if __UNIX__
#if R2__UNIX__
// TODO: keep flags :?
R_UNUSED_RESULT (freopen ("/dev/tty", "rb", stdin));
R_UNUSED_RESULT (freopen ("/dev/tty", "w", stdout));
@ -1243,7 +1243,7 @@ R_API int r_main_radare2(int argc, const char **argv) {
free (pfile);
pfile = strdup ("dbg://");
}
#if __UNIX__
#if R2__UNIX__
/* implicit ./ to make unix behave like windows */
if (f) {
char *path, *escaped_path;
@ -1594,7 +1594,7 @@ R_API int r_main_radare2(int argc, const char **argv) {
}
}
#if UNCOLORIZE_NONTTY
#if __UNIX__
#if R2__UNIX__
if (!r_cons_is_tty ()) {
r_config_set_i (r->config, "scr.color", COLOR_MODE_DISABLED);
}

View File

@ -166,7 +166,7 @@ static int openfile(const char *f, int x) {
return -1;
}
}
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
if (x) {
fchmod (fd, 0755);
}

View File

@ -5,7 +5,7 @@
#include <r_main.h>
#include <r_socket.h>
#if __UNIX__ && HAVE_PTY
#if R2__UNIX__ && HAVE_PTY
static void fwd(int sig) {
/* do nothing? send kill signal to remote process */
}
@ -35,7 +35,7 @@ R_API int r_main_rarun2(int argc, const char **argv) {
}
const char *file = argv[1];
if (!strcmp (file, "-t")) {
#if __UNIX__ && HAVE_PTY
#if R2__UNIX__ && HAVE_PTY
rarun2_tty ();
return 0;
#else

View File

@ -189,7 +189,7 @@ static int w32_createPipe(R2Pipe *r2pipe, const char *cmd) {
static R2Pipe* r2p_open_spawn(R2Pipe* r2p, const char *cmd) {
r_return_val_if_fail (r2p, NULL);
#if HAVE_R2PIPE && (__UNIX__ || defined(__CYGWIN__))
#if HAVE_R2PIPE && (R2__UNIX__ || defined(__CYGWIN__))
char *out = r_sys_getenv ("R2PIPE_IN");
char *in = r_sys_getenv ("R2PIPE_OUT");
int done = false;
@ -218,7 +218,7 @@ static R2Pipe* r2p_open_spawn(R2Pipe* r2p, const char *cmd) {
static R2Pipe *r2pipe_new(void) {
R2Pipe *r2pipe = R_NEW0 (R2Pipe);
if (r2pipe) {
#if HAVE_R2PIPE && __UNIX__
#if HAVE_R2PIPE && R2__UNIX__
r2pipe->input[0] = r2pipe->input[1] = -1;
r2pipe->output[0] = r2pipe->output[1] = -1;
#endif

View File

@ -31,7 +31,7 @@
#include <mach-o/nlist.h>
#endif
#if __UNIX__
#if R2__UNIX__
#include <sys/ioctl.h>
#ifndef __wasi__
#include <sys/resource.h>
@ -73,7 +73,7 @@ static void dyn_init(void) {
if (!dyn_forkpty) {
dyn_forkpty = r_lib_dl_sym (NULL, "forkpty");
}
#if __UNIX__
#if R2__UNIX__
// attempt to fall back on libutil if we failed to load anything
if (!(dyn_openpty && dyn_login_tty && dyn_forkpty)) {
void *libutil;
@ -187,7 +187,7 @@ R_API void r_run_free(RRunProfile *r) {
}
}
#if __UNIX__
#if R2__UNIX__
static void set_limit(int n, int a, ut64 b) {
#ifndef __wasi__
if (n) {
@ -478,7 +478,7 @@ static bool handle_redirection(const char *cmd, bool in, bool out, bool err) {
if (cmd[0] == '"') {
#ifdef __wasi__
R_LOG_ERROR ("Cannot create pipe");
#elif __UNIX__
#elif R2__UNIX__
if (in) {
int pipes[2];
if (pipe (pipes) != -1) {
@ -930,7 +930,7 @@ R_API bool r_run_config_env(RRunProfile *p) {
if (p->_aslr != -1) {
setASLR (p, p->_aslr);
}
#if __UNIX__ && !__wasi__ && !defined(__serenity__)
#if R2__UNIX__ && !__wasi__ && !defined(__serenity__)
set_limit (p->_docore, RLIMIT_CORE, RLIM_INFINITY);
if (p->_maxfd) {
set_limit (p->_maxfd, RLIMIT_NOFILE, p->_maxfd);
@ -1028,7 +1028,7 @@ R_API bool r_run_config_env(RRunProfile *p) {
if (p->_r2sleep != 0) {
r_sys_sleep (p->_r2sleep);
}
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
if (p->_chroot) {
if (chdir (p->_chroot) == -1) {
R_LOG_ERROR ("Cannot chdir to chroot in %s", p->_chroot);
@ -1067,7 +1067,7 @@ R_API bool r_run_config_env(RRunProfile *p) {
}
}
#endif
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
if (p->_setuid) {
ret = setgroups (0, NULL);
if (ret < 0) {
@ -1164,7 +1164,7 @@ R_API bool r_run_config_env(RRunProfile *p) {
if (p->_timeout) {
#if __wasi__
// do nothing
#elif __UNIX__
#elif R2__UNIX__
int mypid = r_sys_getpid ();
if (!r_sys_fork ()) {
int use_signal = p->_timeout_sig;
@ -1291,7 +1291,7 @@ R_API bool r_run_start(RRunProfile *p) {
setsid ();
#endif
if (p->_timeout) {
#if __UNIX__
#if R2__UNIX__
int mypid = r_sys_getpid ();
if (!r_sys_fork ()) {
int use_signal = p->_timeout_sig;
@ -1313,7 +1313,7 @@ R_API bool r_run_start(RRunProfile *p) {
#endif
}
#endif
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
close (0);
close (1);
char *bin_sh = r_file_binsh ();
@ -1350,7 +1350,7 @@ R_API bool r_run_start(RRunProfile *p) {
return false;
}
}
#if __UNIX__
#if R2__UNIX__
// XXX HACK close all non-tty fds
{ int i;
for (i = 3; i < 1024; i++) {
@ -1381,7 +1381,7 @@ R_API bool r_run_start(RRunProfile *p) {
#endif
if (p->_nice) {
#if __UNIX__ && !defined(__HAIKU__) && !defined(__serenity__) && !__wasi__
#if R2__UNIX__ && !defined(__HAIKU__) && !defined(__serenity__) && !__wasi__
if (nice (p->_nice) == -1) {
return false;
}

View File

@ -117,7 +117,7 @@ R_API bool r_socket_is_connected(RSocket *s) {
#endif
}
#if __UNIX__
#if R2__UNIX__
static bool __connect_unix(RSocket *s, const char *file) {
struct sockaddr_un addr;
int sock = socket (PF_UNIX, SOCK_STREAM, 0);
@ -239,7 +239,7 @@ R_API bool r_socket_spawn(RSocket *s, const char *cmd, unsigned int timeout) {
if (!sock) {
return false;
}
#if __UNIX__
#if R2__UNIX__
r_sys_sleep (4);
r_sys_usleep (timeout);
@ -270,11 +270,11 @@ R_API bool r_socket_connect(RSocket *s, const char *host, const char *port, int
if (proto == R_SOCKET_PROTO_NONE) {
proto = R_SOCKET_PROTO_DEFAULT;
}
#if __UNIX__
#if R2__UNIX__
r_sys_signal (SIGPIPE, SIG_IGN);
#endif
if (proto == R_SOCKET_PROTO_UNIX) {
#if __UNIX__
#if R2__UNIX__
if (!__connect_unix (s, host)) {
return false;
}
@ -485,7 +485,7 @@ R_API int r_socket_close(RSocket *s) {
return false;
}
if (s->fd != R_INVALID_SOCKET) {
#if __UNIX__
#if R2__UNIX__
shutdown (s->fd, SHUT_RDWR);
#endif
#if R2__WINDOWS__
@ -540,7 +540,7 @@ R_API bool r_socket_listen(RSocket *s, const char *port, const char *certfile) {
struct linger linger = {0};
if (s->proto == R_SOCKET_PROTO_UNIX) {
#if __UNIX__
#if R2__UNIX__
return __listen_unix (s, port);
#endif
return false;
@ -609,7 +609,7 @@ R_API bool r_socket_listen(RSocket *s, const char *port, const char *certfile) {
#endif
return false;
}
#if __UNIX__
#if R2__UNIX__
r_sys_signal (SIGPIPE, SIG_IGN);
#endif
if (s->proto == R_SOCKET_PROTO_TCP) {
@ -712,13 +712,13 @@ R_API RSocket *r_socket_accept_timeout(RSocket *s, unsigned int timeout) {
// Only applies to read in UNIX
R_API bool r_socket_block_time(RSocket *s, bool block, int sec, int usec) {
#if __UNIX__
#if R2__UNIX__
int ret, flags;
#endif
if (!s) {
return false;
}
#if __UNIX__
#if R2__UNIX__
flags = fcntl (s->fd, F_GETFL, 0);
if (flags < 0) {
return false;
@ -766,7 +766,7 @@ R_API int r_socket_ready(RSocket *s, int secs, int usecs) {
R_API char *r_socket_tostring(RSocket *s) {
#if R2__WINDOWS__
return r_str_newf ("fd%d", (int)(size_t)s->fd);
#elif __UNIX__
#elif R2__UNIX__
char *str = NULL;
struct sockaddr sa;
socklen_t sl = sizeof (sa);
@ -790,7 +790,7 @@ R_API char *r_socket_tostring(RSocket *s) {
/* Read/Write functions */
R_API int r_socket_write(RSocket *s, const void *buf, int len) {
int ret, delta = 0;
#if __UNIX__
#if R2__UNIX__
r_sys_signal (SIGPIPE, SIG_IGN);
#endif
for (;;) {

View File

@ -7,14 +7,14 @@
#include <r_util.h>
#include <signal.h>
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
#include <sys/wait.h>
#endif
#define BUFFER_SIZE 4096
R_API struct r_socket_proc_t *r_socket_proc_open(char* const argv[]) {
#if __UNIX__ && LIBC_HAVE_FORK
#if R2__UNIX__ && LIBC_HAVE_FORK
RSocketProc *sp = R_NEW (RSocketProc);
#ifdef O_CLOEXEC
const int flags = O_CLOEXEC; //O_NONBLOCK|O_CLOEXEC;
@ -74,7 +74,7 @@ error:
}
R_API int r_socket_proc_close(struct r_socket_proc_t *sp) {
#if __UNIX__
#if R2__UNIX__
/* this is wrong */
kill (sp->pid, SIGKILL);
waitpid (sp->pid, NULL, 0); //WNOHANG);

View File

@ -3,7 +3,7 @@
#include <r_socket.h>
#include <r_util/r_sandbox.h>
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
#include <errno.h>
#include <string.h>
@ -59,7 +59,7 @@ R_API int r_socket_connect_serial(RSocket *sock, const char *path, int speed, in
return fd;
}
#else // __UNIX__
#else // R2__UNIX__
R_API int r_socket_connect_serial(RSocket *sock, const char *path, int speed, int parity) {
return -1;

View File

@ -4,7 +4,7 @@ NAME=r_syscall
R2DEPS=r_util
OBJS=syscall.o ioports.o splugs.o
CFLAGS+=-D__UNIX__ -Wall
CFLAGS+=-DR2__UNIX__ -Wall
ifeq (${HAVE_GPERF},1)
OBJS+=d/darwin-arm-32.o

View File

@ -6,7 +6,7 @@
#include <string.h>
#include <sys/stat.h>
#if __UNIX__
#if R2__UNIX__
static bool chmodr(const char *, int recursive);
static bool parsemode(const char *);
static void recurse(const char *path, int rec, bool(*fn)(const char *,int));
@ -16,7 +16,7 @@ static mode_t mode = 0;
#endif
R_API bool r_file_chmod(const char *file, const char *mod, int recursive) {
#if __UNIX__
#if R2__UNIX__
oper = '=';
mode = 0;
if (!parsemode (mod)) {
@ -28,7 +28,7 @@ R_API bool r_file_chmod(const char *file, const char *mod, int recursive) {
#endif
}
#if __UNIX__
#if R2__UNIX__
/* copied from sbase/chmod.c (suckless.org) */
static bool chmodr(const char *path, int rflag) {
struct stat st;

View File

@ -8,7 +8,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <r_lib.h>
#if __UNIX__
#if R2__UNIX__
#include <sys/time.h>
#include <sys/mman.h>
#include <limits.h>
@ -25,7 +25,7 @@
#include <process.h>
#endif
#if __UNIX__ && !defined(__serenity__)
#if R2__UNIX__ && !defined(__serenity__)
#define RDWR_FLAGS O_RDWR | O_SYNC
#else
#define RDWR_FLAGS O_RDWR
@ -234,7 +234,7 @@ R_API char *r_file_abspath_rel(const char *cwd, const char *file) {
if (!strncmp (file, "~/", 2) || !strncmp (file, "~\\", 2)) {
ret = r_file_home (file + 2);
} else {
#if __UNIX__
#if R2__UNIX__
if (cwd && *file != '/') {
ret = r_str_newf ("%s" R_SYS_DIR "%s", cwd, file);
}
@ -264,7 +264,7 @@ R_API char *r_file_abspath_rel(const char *cwd, const char *file) {
if (!ret) {
ret = strdup (file);
}
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
char *abspath = realpath (ret, NULL);
if (abspath) {
free (ret);
@ -340,7 +340,7 @@ R_API char *r_stdin_slurp(int *sz) {
#if __wasi__
#warning r_stdin_slurp not available for wasi
return NULL;
#elif __UNIX__ || R2__WINDOWS__
#elif R2__UNIX__ || R2__WINDOWS__
int i, ret, newfd;
if ((newfd = dup (0)) < 0) {
return NULL;
@ -913,7 +913,7 @@ R_API bool r_file_rm(const char *file) {
R_API char *r_file_readlink(const char *path) {
r_return_val_if_fail (!R_STR_ISEMPTY (path), false);
if (!r_sandbox_enable (0)) {
#if __UNIX__
#if R2__UNIX__
int ret;
char pathbuf[4096] = {0};
strncpy (pathbuf, path, sizeof (pathbuf) - 1);
@ -962,7 +962,7 @@ err_r_file_mmap_write:
return ret;
#elif __wasi__ || EMSCRIPTEN
return -1;
#elif __UNIX__
#elif R2__UNIX__
int fd = r_sandbox_open (file, RDWR_FLAGS, 0644);
const int pagesize = getpagesize ();
int mmlen = len + pagesize;
@ -1027,7 +1027,7 @@ err_r_file_mmap_read:
return ret;
#elif __wasi__ || EMSCRIPTEN
return 0;
#elif __UNIX__
#elif R2__UNIX__
int fd = r_sandbox_open (file, O_RDONLY, 0644);
const int pagesize = 4096;
int mmlen = len+pagesize;
@ -1053,7 +1053,7 @@ err_r_file_mmap_read:
static RMmap *r_file_mmap_unix(RMmap *m, int fd) {
return NULL;
}
#elif __UNIX__
#elif R2__UNIX__
static RMmap *r_file_mmap_unix(RMmap *m, int fd) {
ut8 empty = m->len == 0;
m->buf = mmap (NULL, (empty?BS:m->len) ,
@ -1116,7 +1116,7 @@ R_API RMmap *r_file_mmap_arch(RMmap *mmap, const char *filename, int fd) {
#if R2__WINDOWS__
(void)fd;
return r_file_mmap_windows (mmap, filename);
#elif __UNIX__
#elif R2__UNIX__
(void)filename;
return r_file_mmap_unix (mmap, fd);
#else
@ -1161,7 +1161,7 @@ R_API RMmap *r_file_mmap(const char *file, bool rw, ut64 base) {
R_FREE (m);
return NULL;
}
#if __UNIX__
#if R2__UNIX__
return r_file_mmap_unix (m, fd);
#elif R2__WINDOWS__
close (fd);
@ -1192,7 +1192,7 @@ R_API void r_file_mmap_free(RMmap *m) {
return;
}
free (m->filename);
#if __UNIX__ && !__wasi__
#if R2__UNIX__ && !__wasi__
munmap (m->buf, m->len);
#endif
close (m->fd);
@ -1516,7 +1516,7 @@ R_API RList* r_file_glob(const char *_globbed_path, int maxdepth) {
return files;
}
#if __UNIX__
#if R2__UNIX__
static bool is_executable_header(const char *file) {
bool ret = false;
int osz = 0;
@ -1538,7 +1538,7 @@ static bool is_executable_header(const char *file) {
#endif
R_API bool r_file_is_executable(const char *file) {
bool ret = false;
#if __UNIX__
#if R2__UNIX__
struct stat buf = {0};
if (stat (file, &buf) != 0) {
return false;

View File

@ -35,7 +35,7 @@ R_API int r_lib_types_get_i(const char *str) {
R_API void *r_lib_dl_open(const char *libname) {
void *ret = NULL;
#if WANT_DYLINK
#if __UNIX__
#if R2__UNIX__
if (libname) {
#if __linux__
ret = dlopen (libname, RTLD_NOW);
@ -74,7 +74,7 @@ R_API void *r_lib_dl_open(const char *libname) {
R_API void *r_lib_dl_sym(void *handler, const char *name) {
#if WANT_DYLINK
#if __UNIX__
#if R2__UNIX__
return dlsym (handler, name);
#elif R2__WINDOWS__
return GetProcAddress (handler, name);
@ -87,7 +87,7 @@ R_API void *r_lib_dl_sym(void *handler, const char *name) {
}
R_API int r_lib_dl_close(void *handler) {
#if __UNIX__ && WANT_DYLINK
#if R2__UNIX__ && WANT_DYLINK
return dlclose (handler);
#else
return handler? 0: -1;
@ -132,7 +132,7 @@ err:
#if __APPLE__
char *env = r_sys_getenv ("DYLD_LIBRARY_PATH");
env = r_str_append (env, ":/lib:/usr/lib:/usr/local/lib");
#elif __UNIX__
#elif R2__UNIX__
char *env = r_sys_getenv ("LD_LIBRARY_PATH");
env = r_str_append (env, ":/lib:/usr/lib:/usr/local/lib");
#endif

View File

@ -1,7 +1,7 @@
/* radare - LGPL - Copyright 2007-2022 - pancake */
#include <r_util.h>
#if __UNIX__
#if R2__UNIX__
#include <sys/mman.h>
#endif
@ -262,7 +262,7 @@ R_API const ut8 *r_mem_mem_aligned(const ut8 *haystack, int hlen, const ut8 *nee
R_API bool r_mem_protect(void *ptr, int size, const char *prot) {
#if __wasi__
return false;
#elif __UNIX__
#elif R2__UNIX__
int p = 0;
if (strchr (prot, 'x')) {
p |= PROT_EXEC;
@ -373,7 +373,7 @@ R_API void *r_mem_mmap_resize(RMmap *m, ut64 newsize) {
if (m->buf) {
UnmapViewOfFile (m->buf);
}
#elif __UNIX__ && !__wasi__
#elif R2__UNIX__ && !__wasi__
if (munmap (m->buf, m->len) != 0) {
return NULL;
}

View File

@ -85,7 +85,7 @@ R_API bool r_sandbox_check_path(const char *path) {
if (*path == '/') {
return false;
}
#if __UNIX__
#if R2__UNIX__
char ch;
if (readlink (path, &ch, 1) != -1) {
return false;
@ -505,7 +505,7 @@ R_API int r_sandbox_kill(int pid, int sig) {
if (G_enabled) {
return -1;
}
#if HAVE_SYSTEM && __UNIX__
#if HAVE_SYSTEM && R2__UNIX__
return kill (pid, sig);
#endif
return -1;
@ -545,7 +545,7 @@ R_API bool r_sys_stop(void) {
if (G_enabled) {
return false;
}
#if __UNIX__
#if R2__UNIX__
return !r_sandbox_kill (0, SIGTSTP);
#else
return false;

View File

@ -68,7 +68,7 @@ R_API const char* r_signal_tostring(int code) {
return NULL;
}
#if __UNIX__
#if R2__UNIX__
R_API void r_signal_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask) {
#if HAVE_PTHREAD
pthread_sigmask (how, newmask, oldmask);
@ -77,7 +77,7 @@ R_API void r_signal_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask)
#endif
R_API const char *r_signal_to_human(int signum) {
#if __UNIX__
#if R2__UNIX__
switch (signum) {
case SIGALRM: return "Alarm Clock";
case SIGBUS: return "Bus Error";

View File

@ -1444,7 +1444,7 @@ R_API char *r_str_escape_sh(const char *buf) {
char *q = new_buf;
while (*p) {
switch (*p) {
#if __UNIX__
#if R2__UNIX__
case '$':
case '`':
#endif

View File

@ -58,7 +58,7 @@ int proc_pidpath(int pid, void * buffer, ut32 buffersize);
//# include <libproc.h>
# endif
#endif
#if __UNIX__
#if R2__UNIX__
# include <sys/utsname.h>
# include <sys/stat.h>
# include <errno.h>
@ -363,7 +363,7 @@ R_API int r_sys_sleep(int secs) {
rqtp.tv_sec = secs;
rqtp.tv_nsec = 0;
return clock_nanosleep (CLOCK_MONOTONIC, 0, &rqtp, NULL);
#elif __UNIX__
#elif R2__UNIX__
return sleep (secs);
#else
Sleep (secs * 1000); // W32
@ -377,7 +377,7 @@ R_API int r_sys_usleep(int usecs) {
rqtp.tv_sec = usecs / 1000000;
rqtp.tv_nsec = (usecs - (rqtp.tv_sec * 1000000)) * 1000;
return clock_nanosleep (CLOCK_MONOTONIC, 0, &rqtp, NULL);
#elif __UNIX__
#elif R2__UNIX__
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)
// Old versions of GNU libc return void for usleep
usleep (usecs);
@ -394,7 +394,7 @@ R_API int r_sys_usleep(int usecs) {
}
R_API int r_sys_clearenv(void) {
#if __UNIX__
#if R2__UNIX__
#if __APPLE__ && !HAVE_ENVIRON
/* do nothing */
if (!env) {
@ -424,7 +424,7 @@ R_API int r_sys_setenv(const char *key, const char *value) {
if (!key) {
return 0;
}
#if __UNIX__
#if R2__UNIX__
if (!value) {
unsetenv (key);
return 0;
@ -446,7 +446,7 @@ R_API int r_sys_setenv(const char *key, const char *value) {
#endif
}
#if __UNIX__
#if R2__UNIX__
static char *crash_handler_cmd = NULL;
static void signal_handler(int signum) {
@ -628,7 +628,7 @@ R_API bool r_sys_aslr(int val) {
return ret;
}
#if __UNIX__ && HAVE_SYSTEM
#if R2__UNIX__ && HAVE_SYSTEM
R_API int r_sys_cmd_str_full(const char *cmd, const char *input, int ilen, char **output, int *len, char **sterr) {
if (!r_sandbox_check (R_SANDBOX_GRAIN_EXEC)) {
return false;
@ -824,7 +824,7 @@ R_API int r_sys_cmdf(const char *fmt, ...) {
}
R_API int r_sys_cmdbg(const char *str) {
#if __UNIX__
#if R2__UNIX__
int pid = r_sys_fork ();
if (pid == -1) {
return -1;
@ -930,7 +930,7 @@ R_API bool r_sys_mkdirp(const char *dir) {
}
R_API void r_sys_perror_str(const char *fun) {
#if __UNIX__
#if R2__UNIX__
#pragma push_macro("perror")
#undef perror
perror (fun);
@ -1024,7 +1024,7 @@ R_API int r_sys_run(const ut8 *buf, int len) {
//r_mem_protect (ptr, sz, "rwx"); // try, ignore if fail
cb = (int (*)())ptr;
#if USE_FORK
#if __UNIX__
#if R2__UNIX__
pid = r_sys_fork ();
#else
pid = -1;
@ -1071,7 +1071,7 @@ R_API int r_sys_run_rop(const ut8 *buf, int len) {
}
memcpy (bufptr, buf, len);
#if USE_FORK
#if __UNIX__
#if R2__UNIX__
pid_t pid = r_sys_fork ();
#else
pid = -1;
@ -1317,7 +1317,7 @@ R_API int r_sys_uid(void) {
R_API int r_sys_getpid(void) {
#if __wasi__
return 0;
#elif __UNIX__
#elif R2__UNIX__
return getpid ();
#elif R2__WINDOWS__
return (int)GetCurrentProcessId ();
@ -1365,7 +1365,7 @@ R_API const char *r_sys_prefix(const char *pfx) {
}
R_API RSysInfo *r_sys_info(void) {
#if __UNIX__
#if R2__UNIX__
struct utsname un = {{0}};
if (uname (&un) != -1) {
RSysInfo *si = R_NEW0 (RSysInfo);

View File

@ -12,7 +12,7 @@
R_TH_LOCAL RList *dirstack = NULL;
static char *showfile(char *res, const int nth, const char *fpath, const char *name, int printfmt, bool needs_newline) {
#if __UNIX__
#if R2__UNIX__
struct stat sb;
#endif
const char *n = fpath;
@ -42,7 +42,7 @@ static char *showfile(char *res, const int nth, const char *fpath, const char *n
// TODO: escape non-printable chars in filenames
// TODO: Implement more real info in ls -l
// TODO: handle suid
#if __UNIX__
#if R2__UNIX__
if (lstat (n, &sb) != -1) {
ut32 ifmt = sb.st_mode & S_IFMT;
uid = sb.st_uid;
@ -86,7 +86,7 @@ static char *showfile(char *res, const int nth, const char *fpath, const char *n
const char *icon = eANY;
if (isdir) {
icon = eDIR;
#if __UNIX__
#if R2__UNIX__
} else if ((sb.st_mode & S_IFMT) == S_IFLNK) {
const char *eLNK = "📎";
icon = eLNK;

View File

@ -209,7 +209,7 @@ R_API char *r_ctime_r(const time_t *timer, char *buf) {
}
static int get_time_correction(void) {
#if __UNIX__
#if R2__UNIX__
struct my_timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of DST correction */

View File

@ -16,7 +16,7 @@ ONELIB=0
CC_AR=$(AR) q ${LIBAR}
PARTIALLD=$(CC) -nostdlib -Wl,--whole-archive -Wl,--no-entry
PIC_CFLAGS=-fPIC
CFLAGS+=-MD -D__UNIX__=1
CFLAGS+=-MD -DR2__UNIX__=1
CFLAGS_INCLUDE=-I
LDFLAGS_LINK=-l
LDFLAGS_LINKPATH=-L

View File

@ -12,7 +12,7 @@
#include <r_cons.h>
#include <r_debug.h>
#if __UNIX__
#if R2__UNIX__
#include <errno.h>
#include <fcntl.h>
#include <string.h>
@ -21,7 +21,7 @@
#endif
#endif
#if __UNIX__
#if R2__UNIX__
#include <signal.h>
#endif

View File

@ -7,7 +7,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#if __UNIX__
#if R2__UNIX__
#include <unistd.h>
#endif
#include <stdio.h>

View File

@ -2,7 +2,7 @@
#include "sdb/sdb.h"
#include <fcntl.h>
#if __UNIX__ || __MINGW32__
#if R2__UNIX__ || __MINGW32__
#include <unistd.h>
#endif

View File

@ -3,7 +3,7 @@
#ifndef INCLUDE_P_SPP_H
#define INCLUDE_P_SPP_H
#if __UNIX__
#if R2__UNIX__
#include <unistd.h>
#endif

View File

@ -1,6 +1,6 @@
/* radare2 - LGPL - Copyright 2013-2020 - pancake */
#if __UNIX__
#if R2__UNIX__
#include <unistd.h>
#elif R2__WINDOWS__
#include <windows.h>
@ -103,7 +103,7 @@ int r_sys_setenv(const char *key, const char *value) {
if (!key) {
return 0;
}
#if __UNIX__
#if R2__UNIX__
if (!value) {
unsetenv (key);
return 0;
@ -162,7 +162,7 @@ err_r_sys_get_env:
}
int r_sys_getpid() {
#if __UNIX__
#if R2__UNIX__
return getpid();
#elif R2__WINDOWS__
return GetCurrentProcessId();

View File

@ -31,11 +31,11 @@
#if defined(EMSCRIPTEN) || defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__)
#define R2__BSD__ 0
#define __UNIX__ 1
#define R2__UNIX__ 1
#endif
#if __KFBSD__ || defined(__NetBSD__) || defined(__OpenBSD__)
#define R2__BSD__ 1
#define __UNIX__ 1
#define R2__UNIX__ 1
#endif
#if __WIN32__ || __CYGWIN__ || MINGW32
#define __addr_t_defined
@ -48,7 +48,7 @@
typedef int socklen_t;
#undef USE_SOCKETS
#define R2__WINDOWS__ 1
#undef __UNIX__
#undef R2__UNIX__
#undef R2__BSD__
#endif

View File

@ -116,7 +116,7 @@ bool test_autonames(void) {
bool test_file_slurp(void) {
#ifdef __WINDOWS__
#ifdef R2__WINDOWS__
#define S_IRWXU _S_IREAD | _S_IWRITE
#endif