From d583cf251456aae95a97c9a87d0d240e7eb1f955 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 31 Jan 2019 13:27:37 +0000 Subject: [PATCH] redefined MEM macros --- mio/lib/main.c | 5 +++- mio/lib/mio-prv.h | 61 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/mio/lib/main.c b/mio/lib/main.c index dec76d4..6212a40 100644 --- a/mio/lib/main.c +++ b/mio/lib/main.c @@ -315,6 +315,7 @@ static int pro_on_read (mio_dev_pro_t* pro, mio_dev_pro_sid_t sid, const void* d static int pro_on_write (mio_dev_pro_t* pro, mio_iolen_t wrlen, void* wrctx) { mio_t* mio = pro->mio; + mio_ntime_t tmout; if (wrlen <= -1) { MIO_INFO1 (mio, "PROCESS(%d): WRITE TIMED OUT...\n", (int)pro->child_pid); @@ -323,7 +324,9 @@ static int pro_on_write (mio_dev_pro_t* pro, mio_iolen_t wrlen, void* wrctx) } MIO_DEBUG2 (mio, "PROCESS(%d) wrote data of %d bytes\n", (int)pro->child_pid, (int)wrlen); - mio_dev_pro_read (pro, MIO_DEV_PRO_OUT, 1); + /*mio_dev_pro_read (pro, MIO_DEV_PRO_OUT, 1);*/ + MIO_INIT_NTIME (&tmout, 5, 0); + mio_dev_pro_timedread (pro, MIO_DEV_PRO_OUT, 1, &tmout); return 0; } diff --git a/mio/lib/mio-prv.h b/mio/lib/mio-prv.h index 2445c64..05818b4 100644 --- a/mio/lib/mio-prv.h +++ b/mio/lib/mio-prv.h @@ -31,12 +31,61 @@ #include "mio-utl.h" #include -/*TODO: redefine and remove these */ -#include -#define MIO_MEMSET(dst,byte,count) memset(dst,byte,count) -#define MIO_MEMCPY(dst,src,count) memcpy(dst,src,count) -#define MIO_MEMMOVE(dst,src,count) memmove(dst,src,count) -#define MIO_MEMCMP(dst,src,count) memcmp(dst,src,count) +#if defined(__has_builtin) + +# if (!__has_builtin(__builtin_memset) || !__has_builtin(__builtin_memcpy) || !__has_builtin(__builtin_memmove) || !__has_builtin(__builtin_memcmp)) +# include +# endif + +# if __has_builtin(__builtin_memset) +# define MIO_MEMSET(dst,src,size) __builtin_memset(dst,src,size) +# else +# define MIO_MEMSET(dst,src,size) memset(dst,src,size) +# endif +# if __has_builtin(__builtin_memcpy) +# define MIO_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size) +# else +# define MIO_MEMCPY(dst,src,size) memcpy(dst,src,size) +# endif +# if __has_builtin(__builtin_memmove) +# define MIO_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size) +# else +# define MIO_MEMMOVE(dst,src,size) memmove(dst,src,size) +# endif +# if __has_builtin(__builtin_memcmp) +# define MIO_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size) +# else +# define MIO_MEMCMP(dst,src,size) memcmp(dst,src,size) +# endif + +#else + +# if defined(HAVE___BUILTIN_MEMSET) || !defined(HAVE___BUILTIN_MEMCPY) || !defined(HAVE___BUILTIN_MEMMOVE) || !defined(HAVE___BUILTIN_MEMCMP) +# include +# endif + +# if defined(HAVE___BUILTIN_MEMSET) +# define MIO_MEMSET(dst,src,size) __builtin_memset(dst,src,size) +# else +# define MIO_MEMSET(dst,src,size) memset(dst,src,size) +# endif +# if defined(HAVE___BUILTIN_MEMCPY) +# define MIO_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size) +# else +# define MIO_MEMCPY(dst,src,size) memcpy(dst,src,size) +# endif +# if defined(HAVE___BUILTIN_MEMMOVE) +# define MIO_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size) +# else +# define MIO_MEMMOVE(dst,src,size) memmove(dst,src,size) +# endif +# if defined(HAVE___BUILTIN_MEMCMP) +# define MIO_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size) +# else +# define MIO_MEMCMP(dst,src,size) memcmp(dst,src,size) +# endif + +#endif /* ========================================================================= * MIO ASSERTION