x86/cpu: Include system headers before local headers

Message ID 1344199618-55350-1-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Aug. 5, 2012, 8:46 p.m.
An inline function in MSVC system headers included by these
headers use free(). The local headers (after 239fdf1b) include
internal.h that redirect free to please_use_av_free_instead_of_free.
---
 libavutil/x86/cpu.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Mans Rullgard Aug. 5, 2012, 8:52 p.m. | #1
Martin Storsjö <martin@martin.st> writes:

> An inline function in MSVC system headers included by these
> headers use free(). 

Which function?

> The local headers (after 239fdf1b) include internal.h that redirect
> free to please_use_av_free_instead_of_free.

That is because avutil.h foolishly includes common.h.  It really ought
not do that.  Can we please fix that instead?
Martin Storsjö Aug. 5, 2012, 9:10 p.m. | #2
On Sun, 5 Aug 2012, Måns Rullgård wrote:

> Martin Storsjö <martin@martin.st> writes:
>
>> An inline function in MSVC system headers included by these
>> headers use free().
>
> Which function?

It's in _freea in the MSVC malloc.h (which is included implicitly). It's 
not used by us, but we enable the equivalent of 
-Werror=implicit-function-declaration, so it fails just by parsing the 
inline function.

>> The local headers (after 239fdf1b) include internal.h that redirect
>> free to please_use_av_free_instead_of_free.
>
> That is because avutil.h foolishly includes common.h.  It really ought
> not do that.  Can we please fix that instead?

I'll give it a shot.

// Martin

Patch

diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index a63b564..27f51ca 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -22,6 +22,16 @@ 
 
 #include <stdlib.h>
 #include <string.h>
+#if HAVE_CPUID
+#include <intrin.h>
+#endif
+#if HAVE_XGETBV
+#include <immintrin.h>
+#endif
+#if HAVE_RWEFLAGS
+#include <intrin.h>
+#endif
+
 #include "libavutil/x86_cpu.h"
 #include "libavutil/cpu.h"
 
@@ -35,7 +45,6 @@ 
         : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)        \
         : "0" (index))
 #elif HAVE_CPUID
-#include <intrin.h>
 
 #define cpuid(index, eax, ebx, ecx, edx)        \
     do {                                        \
@@ -52,7 +61,6 @@ 
 #define xgetbv(index, eax, edx)                                 \
     __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
 #elif HAVE_XGETBV
-#include <immintrin.h>
 
 #define xgetbv(index, eax, edx)                 \
     do {                                        \
@@ -76,8 +84,6 @@ 
 
 #elif HAVE_RWEFLAGS
 
-#include <intrin.h>
-
 #define get_eflags(x)                           \
     x = __readeflags()