Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin <imun@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 2/2] lua: abort trace recording on fiber yield
Date: Wed, 30 Sep 2020 09:27:25 +0300	[thread overview]
Message-ID: <20200930062725.GA18920@tarantool.org> (raw)
In-Reply-To: <f903f4f2-1317-5121-c3f8-eeb179c0582b@tarantool.org>

Vlad,

Thanks for your review!

On 30.09.20, Vladislav Shpilevoy wrote:
> Thanks for the patch!
> 
> Functionally all looks good. See one comment related not to Lua.
> 
> > diff --git a/src/lua/utils.c b/src/lua/utils.c
> > index 8e98f7607..6e38f5734 100644
> > --- a/src/lua/utils.c
> > +++ b/src/lua/utils.c
> > @@ -1309,10 +1310,61 @@ tarantool_lua_utils_init(struct lua_State *L)
> >  	return 0;
> >  }
> >  
> > +/*
> > + * XXX: There is already defined <panic> macro in say.h header
> > + * (included in diag.h). As a result the call below is misexpanded
> > + * and compilation fails with the corresponding error. To avoid
> > + * this error the macro is temporary renamed and restored later.
> > + * Compilation now fails for the following cases:
> > + * * temporary name <gh1700_panic> is used in scope of this
> > + *   translation unit
> > + * * <panic> is not define, so this hack can be freely dropped
> > + */
> > +#if defined(panic) && !defined(gh1700_panic)
> > +#  define gh1700_panic panic
> > +#  undef panic
> > +#else
> > +#  error "Can't redefine <panic> macro"
> > +#endif
> 
> Unfortunately, it won't work. Macros are not variables. You
> can's assign them like that. I wish we could.
> 
> What you did here is you eliminated 'panic' macro, and added a
> new macro 'gh1700_panic' whose value is "panic". Not what was
> in the old 'panic', but exactly "panic". So the old value of 'panic'
> is lost here.

Hell, you're right. They can be recursively expanded, but if panic macro
is undefined then it is just a bareword (as I originally wanted).

> 

<snipped>

> 
> Also when you try to restore the old 'panic', it also won't work
> again. As an alternative you can just do '#undef panic', since your
> code is in the end of the file anyway, it won't break shit. Or make
> a separate patch, which would turn panic() into a function.

I simply undefined <panic> macro (the diff is below) and filed an
issue[1] to rewrite this part.

================================================================================

diff --git a/src/lua/utils.c b/src/lua/utils.c
index 6e38f5734..bb2287162 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -1314,18 +1314,10 @@ tarantool_lua_utils_init(struct lua_State *L)
  * XXX: There is already defined <panic> macro in say.h header
  * (included in diag.h). As a result the call below is misexpanded
  * and compilation fails with the corresponding error. To avoid
- * this error the macro is temporary renamed and restored later.
- * Compilation now fails for the following cases:
- * * temporary name <gh1700_panic> is used in scope of this
- *   translation unit
- * * <panic> is not define, so this hack can be freely dropped
+ * this error the macro is undefined since it's not used anymore
+ * in scope of this translation unit.
  */
-#if defined(panic) && !defined(gh1700_panic)
-#  define gh1700_panic panic
-#  undef panic
-#else
-#  error "Can't redefine <panic> macro"
-#endif
+#undef panic
 
 /**
  * This routine encloses the checks and actions to be done when
@@ -1364,7 +1356,3 @@ void cord_on_yield(void)
 	 */
 	lj_trace_abort(g);
 }
-
-/* Restore <panic> macro back */
-#define panic gh1700_panic
-#undef gh1700_panic

================================================================================

[1]: https://github.com/tarantool/tarantool/issues/5365

-- 
Best regards,
IM

  reply	other threads:[~2020-09-30  6:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 19:06 [Tarantool-patches] [PATCH v2 0/2] Prevent JIT engine breakage on fibers switch-over Igor Munkin
2020-09-23 19:06 ` [Tarantool-patches] [PATCH v2 1/2] fiber: introduce a callback for " Igor Munkin
2020-09-24 12:54   ` sergos
2020-09-28 13:06     ` Igor Munkin
2020-09-29  9:15       ` Sergey Ostanevich
2020-09-29 10:05         ` Igor Munkin
2020-09-29 22:41   ` Vladislav Shpilevoy
2020-09-30  9:30     ` Igor Munkin
2020-09-30 22:00       ` Vladislav Shpilevoy
2020-09-23 19:06 ` [Tarantool-patches] [PATCH v2 2/2] lua: abort trace recording on fiber yield Igor Munkin
2020-09-24 13:00   ` sergos
2020-09-28 13:07     ` Igor Munkin
2020-09-28 15:36       ` Igor Munkin
2020-09-28 16:37         ` Igor Munkin
2020-09-28 17:45           ` Igor Munkin
2020-09-29  9:24             ` Sergey Ostanevich
2020-09-29 10:06               ` Igor Munkin
2020-09-29 22:41   ` Vladislav Shpilevoy
2020-09-30  6:27     ` Igor Munkin [this message]
2020-09-30 21:59       ` Vladislav Shpilevoy
2020-10-01  6:14         ` Igor Munkin
2020-09-24 13:15 ` [Tarantool-patches] [PATCH v2 0/2] Prevent JIT engine breakage on fibers switch-over sergos
2020-09-28 13:06   ` Igor Munkin
2020-09-29  9:14     ` Sergey Ostanevich
2020-10-01 21:25 ` Vladislav Shpilevoy
2020-10-01 21:29   ` Igor Munkin
2020-10-01 22:17 ` Igor Munkin
2020-10-02 12:43 ` Kirill Yukhin
2020-10-02 12:44   ` Igor Munkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200930062725.GA18920@tarantool.org \
    --to=imun@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 2/2] lua: abort trace recording on fiber yield' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox