public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Prathamesh Kulkarni <bilbotheelffriend@gmail.com>
To: Diego Novillo <dnovillo@google.com>
Cc: gcc <gcc@gcc.gnu.org>
Subject: Re: replace do-while macros with static inline functions
Date: Fri, 13 Dec 2013 22:06:00 -0000	[thread overview]
Message-ID: <CAJXstsC7N4J0ZJg17UEJRm+_555dfPt=JKh6VkATSPPH0zn7Nw@mail.gmail.com> (raw)
In-Reply-To: <CAD_=9DRy95wpMmLAhrMr8EQ55qcWDzGouhHMckSR2SJMYRemDQ@mail.gmail.com>

On Sat, Dec 14, 2013 at 1:17 AM, Diego Novillo <dnovillo@google.com> wrote:
>
>
>
> On Wed, Dec 11, 2013 at 10:03 AM, Prathamesh Kulkarni
> <bilbotheelffriend@gmail.com> wrote:
>>
>> I was wondering if it was a good idea to replace do-while macros with
>> static inline functions returning void, where appropriate ?
>> By "where appropriate" I mean:
>> a) call to macro contains no side-effects
>> b) macro does not modify the arguments.
>> c) macro does not use any preprocessor operators (like ##)
>> d) macro does not get undefined or is conditionally defined.
>> e) macro is not type independent (use inline template for these?)
>> f) Any other case ?
>>
>> Example:
>> Consider C_EXPR_APPEND macro defined in c-tree.h:
>>
>> /* Append a new c_expr_t element to V.  */
>> #define C_EXPR_APPEND(V, ELEM) \
>>   do { \
>>     c_expr_t __elem = (ELEM); \
>>     vec_safe_push (V, __elem); \
>>   } while (0)
>>
>
> Yes, it's a good idea.  One thing you will likely need to do, however, is to
> add some of the replaced functions into gdb's list of ignored inline
> functions. Some folks are used to gdb stepping over macro calls when 's' is
> used.
>
> Not all macros need to be turned into functions. Some can be completely
> removed (Trevor mentions an example in his reply).

Thanks. I shall start working on it.
>
>
> Diego.

      parent reply	other threads:[~2013-12-13 22:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 15:03 Prathamesh Kulkarni
2013-12-13 19:42 ` Trevor Saunders
2013-12-13 20:47   ` Ondřej Bílka
     [not found] ` <CAD_=9DRy95wpMmLAhrMr8EQ55qcWDzGouhHMckSR2SJMYRemDQ@mail.gmail.com>
2013-12-13 19:48   ` Diego Novillo
2013-12-13 22:06   ` Prathamesh Kulkarni [this message]

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='CAJXstsC7N4J0ZJg17UEJRm+_555dfPt=JKh6VkATSPPH0zn7Nw@mail.gmail.com' \
    --to=bilbotheelffriend@gmail.com \
    --cc=dnovillo@google.com \
    --cc=gcc@gcc.gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).