[nanomsg] Re: inline functions vs. macros

  • From: Chip Salzenberg <rev.chip@xxxxxxxxx>
  • To: Martin Sustrik <sustrik@xxxxxxxxxx>
  • Date: Wed, 21 Aug 2013 00:04:32 -0700

IIRC, Linux's list macros (to pick an example) couldn't be done with C
inline functions because they retain information about the intruded-upon
type, of which there are a multitude; in fact sometimes the same struct can
participate in several lists at once, and in C, that needs a macro.  OTOH
Linux makes extensive use of inline functions for other purposes.

Anyway enough theory; you seem open to the possibility so I'll just see if
there's a patch or two that's worth submitting.


On Wed, Aug 21, 2013 at 12:01 AM, Martin Sustrik <sustrik@xxxxxxxxxx> wrote:

> On 20/08/13 20:48, Chip Salzenberg wrote:
>
>> Well, I was going to get to asserts soon enough... but no.  I meant
>> e.g. NN_CMSG_FIRSTHDR, NN_CMSG_DATA, etc.  The sort of thing that would
>> have been a normal function except for efficiency concerns.
>>
>
> I see.
>
> Well, the ancillary data macros are there only for POSIX compliance. In
> reality, the only field returned in ancillary data is SP-level message
> header, so I guess the macros could be hugely simplified.
>
> As for macro vs. function discussion, I've checked how the macros are
> implemented in Linux and done it in similar way. I guess the motivation was
> to make it as efficient as possible.
>
> Martin
>
>

Other related posts: