From 762dcb3f66ca143461e4a6742cbf6042f9707c77 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Wed, 30 Oct 2019 14:34:43 +0000 Subject: [PATCH] minor changes in MOO_STATIC_ASSERT() definition. defined O_CLOEXEC to 0 when it's not defined --- moo/lib/moo-cmn.h | 4 +++- moo/mod/io-file.c | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/moo/lib/moo-cmn.h b/moo/lib/moo-cmn.h index d996a2e..e8d060a 100644 --- a/moo/lib/moo-cmn.h +++ b/moo/lib/moo-cmn.h @@ -1043,8 +1043,10 @@ typedef struct moo_t moo_t; # define MOO_STATIC_ASSERT(expr) _Static_assert (expr, "invalid assertion") #elif defined(__cplusplus) && (__cplusplus >= 201103L) # define MOO_STATIC_ASSERT(expr) static_assert (expr, "invalid assertion") -#else +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define MOO_STATIC_ASSERT(expr) typedef char MOO_STATIC_JOIN(MOO_STATIC_ASSERT_T_, __LINE__)[(expr)? 1: -1] MOO_UNUSED +#else +# define MOO_STATIC_ASSERT(expr) do { typedef char MOO_STATIC_JOIN(MOO_STATIC_ASSERT_T_, __LINE__)[(expr)? 1: -1] MOO_UNUSED; } while(0) #endif #define MOO_STATIC_ASSERT_EXPR(expr) ((void)MOO_SIZEOF(char[(expr)? 1: -1])) diff --git a/moo/mod/io-file.c b/moo/mod/io-file.c index c7faad7..2d55877 100644 --- a/moo/mod/io-file.c +++ b/moo/mod/io-file.c @@ -34,6 +34,10 @@ #include #include +#if !defined(O_CLOEXEC) +# define O_CLOEXEC 0 /* since it's not defined, 0 results in no effect when bitwise-ORed. */ +#endif + static moo_pfrc_t pf_open_file (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) { oop_io_t io; @@ -93,10 +97,7 @@ static moo_pfrc_t pf_open_file (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) goto oops; } - fl |= O_NONBLOCK; -#if defined(O_CLOEXEC) - fl |= O_CLOEXEC; -#endif + fl |= O_NONBLOCK | O_CLOEXEC; if (fcntl(fd, F_SETFL, fl) == -1) goto fcntl_failure;