[FFmpeg-devel] [PATCH 3/3] two functions were declaredinlinebut were referenced elsewhere

J. Bohl jbohl at jbohl.de
Thu Jun 14 23:39:07 CEST 2012


I read through these articles
http://www.greenend.org.uk/rjk/tech/inline.html and
http://stackoverflow.com/questions/216510/extern-inline - and got even
more confused.
Well, the my state of mind is now:
- in C99 "extern inline" creates an out-of-line function (=externally
- GCC before 4.3 treats "inline" the same way (creates always an
out-of-line function as well)

In addition, every compiler that compiles/links the current code without
a linker error obviously treats "inline" as "create an out-of-line
function as well".

So I arrived at:

#ifndef av_extern_inline
#if defined(__INTEL_COMPILER) ||  defined(__GNUC_STDC_INLINE__)
#    define av_extern_inline extern inline
#    define av_extern_inline inline

The compilers known to follow C99-semantic (according to the first
reference __GNUC_STDC_INLINE__ is defined if GCC uses C99-semantic) see
the "extern inline" definition, for all others we leave it as is - just
"inline". No need to further distinguish between "pre-GCC4.3 semantic"
and "inline without creating out-of-line function" since, as stated
above, every compiler that works ok now obviously uses "pre-GCC4.3
semantic" (and I don't know how to tell them apart...). That way also
your concerns about performance are met - since no change happens here
(the two functions are still always attributed inline - as opposed to
define av_extern_inline to nothing).
I could only test with GCC4.6.1 and ICL12.1. I attached a corresponding

Thanks for the hint regarding the dead-code elimination btw. You are
right, it is just a matter of passing "/OPT:REF" to the linker.



-----Original Message-----
From: ffmpeg-devel-bounces at ffmpeg.org
[mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of Michael
Sent: Thursday, June 14, 2012 2:09 AM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH 3/3] two functions were
declaredinlinebut were referenced elsewhere

On Thu, Jun 14, 2012 at 01:16:16AM +0200, J. Bohl wrote:
> Hi,
> >iam a bit affraid this could cause a slowdown. did you check what
> effect this change has
> >on compilers supporting the code currently ?
> No, sorry I am not able to quantify the impact of this change at this 
> point. At least not with tangible numbers, with a quick transcoding 
> run (Linux x86, gcc4.6) I didn't notice a (significant) difference.
> Maybe you like the attached revised patch better - having two 
> functions, one that is attributed inline and one for external
> >changing all MANGLE() to "m" will break compilation on several
> compilers
> Yeah, I understand this. And cluttering the code with #ifdef's would 
> be a mess I suppose. OK, then can't help it.
> >isnt icc able to optimize this out with some command line switches ?
> >under linux ICC is able to do such elimination of calls ...
> >if it really doesnt work its maybe worth to report to intel if it 
> >hasnt
> been reported yet. Intel
> >is likely interrested to improve ICCs dead code elimination.
> Good idea, I didn't think of that. I'll check this out. I seem to 
> remember that it is a compatibility issue (compatibility with the 
> Microsoft compiler).
> Regards,
> Juergen

>  motion_est.c          |   27 ++++++++++++++++++++-------
>  motion_est_template.c |    4 ++--
>  2 files changed, 22 insertions(+), 9 deletions(-)
> dd4877673d834fdafc7b9ca55debd9385da11625  
> 0004-revised-patch-for-ff_get_mb_score-ff_epzs_motion_sea.patch
> From fedc50c96aa9d909bc2e93566c77643b82235455 Mon Sep 17 00:00:00 2001
> From: "J. Bohl" <jbohl at h-quer.de>
> Date: Thu, 14 Jun 2012 00:31:28 +0200
> Subject: [PATCH 4/4] revised patch for ff_get_mb_score &  
> ff_epzs_motion_search declared inline, but referenced  elsewhere

I think it would be better to have a
av_extern_inline and something like:

#ifndef av_extern_inline
# if whatever
#  define av_extern_inline
# else
#  define av_extern_inline inline
# endif

in libavutil/attributes.h

The semantics simply differ a bit between C99, and various compilers In
theory we could use extern inline but i doubt it would work with all



Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-new-attribute-extern-inline-fixing-linker-error-with.patch
Type: application/octet-stream
Size: 2010 bytes
Desc: 0001-new-attribute-extern-inline-fixing-linker-error-with.patch
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120614/0179bafd/attachment.obj>

More information about the ffmpeg-devel mailing list