cvg, h5, cpuid.c: fixed strict aliasing issue with newer gcc versions.

This commit is contained in:
sezero
2018-08-09 20:51:50 +03:00
parent 5f69e69154
commit faf890d878
2 changed files with 11 additions and 15 deletions

View File

@@ -33,14 +33,17 @@
* *
*/ */
#include <signal.h> #include <signal.h>
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#include "cpuid.h" #include "cpuid.h"
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 3)))
typedef unsigned int __attribute__((__may_alias__)) word32;
#else
typedef unsigned int word32; typedef unsigned int word32;
#endif
/* These are the bit flags that get set on calling cpuid /* These are the bit flags that get set on calling cpuid
* with register eax set to 1 * with register eax set to 1
@@ -87,7 +90,6 @@ typedef unsigned int word32;
static jmp_buf j; static jmp_buf j;
/* Desc: signal handler /* Desc: signal handler
* *
* In : signal number * In : signal number
@@ -101,7 +103,6 @@ static void handler (int signal)
} }
/* Desc: check if CPU has specific feature /* Desc: check if CPU has specific feature
* *
* In : feature request * In : feature request
@@ -135,7 +136,6 @@ static int check_feature (int feature)
#endif #endif
/* Desc: perform (possibly faulting) instructions in a safe manner /* Desc: perform (possibly faulting) instructions in a safe manner
* *
* In : feature request * In : feature request
@@ -182,7 +182,6 @@ static int has_feature (int feature)
} }
/* Desc: get CPU info /* Desc: get CPU info
* *
* In : pointer to _p_info * In : pointer to _p_info
@@ -234,7 +233,7 @@ int _cpuid (_p_info *pinfo)
movl %%edx, %0 \n\ movl %%edx, %0 \n\
0: \n\ 0: \n\
":"=g"(dwExt), "=g"(dwId), "=g"(dwFeature), ":"=g"(dwExt), "=g"(dwId), "=g"(dwFeature),
"=g"(((long *)Ident)[0]), "=g"(((long *)Ident)[1]), "=g"(((long *)Ident)[2]) "=g"(((word32 *)Ident)[0]), "=g"(((word32 *)Ident)[1]), "=g"(((word32 *)Ident)[2])
::"%eax", "%ecx", "%edx"); ::"%eax", "%ecx", "%edx");
#else #else
_asm _asm
@@ -315,7 +314,6 @@ notamd:
} }
#if CPUTEST #if CPUTEST
#include <stdio.h> #include <stdio.h>
/* Desc: /* Desc:

View File

@@ -30,14 +30,17 @@
* *
*/ */
#include <signal.h> #include <signal.h>
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#include "cpuid.h" #include "cpuid.h"
typedef unsigned long word32; #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 3)))
typedef unsigned int __attribute__((__may_alias__)) word32;
#else
typedef unsigned int word32;
#endif
/* These are the bit flags that get set on calling cpuid /* These are the bit flags that get set on calling cpuid
* with register eax set to 1 * with register eax set to 1
@@ -84,7 +87,6 @@ typedef unsigned long word32;
static jmp_buf j; static jmp_buf j;
/* Desc: signal handler /* Desc: signal handler
* *
* In : signal number * In : signal number
@@ -98,7 +100,6 @@ static void handler (int signal)
} }
/* Desc: check if CPU has specific feature /* Desc: check if CPU has specific feature
* *
* In : feature request * In : feature request
@@ -132,7 +133,6 @@ static int check_feature (int feature)
#endif #endif
/* Desc: perform (possibly faulting) instructions in a safe manner /* Desc: perform (possibly faulting) instructions in a safe manner
* *
* In : feature request * In : feature request
@@ -179,7 +179,6 @@ static int has_feature (int feature)
} }
/* Desc: get CPU info /* Desc: get CPU info
* *
* In : pointer to _p_info * In : pointer to _p_info
@@ -231,7 +230,7 @@ int _cpuid (_p_info *pinfo)
movl %%edx, %0 \n\ movl %%edx, %0 \n\
0: \n\ 0: \n\
":"=g"(dwExt), "=g"(dwId), "=g"(dwFeature), ":"=g"(dwExt), "=g"(dwId), "=g"(dwFeature),
"=g"(((long *)Ident)[0]), "=g"(((long *)Ident)[1]), "=g"(((long *)Ident)[2]) "=g"(((word32 *)Ident)[0]), "=g"(((word32 *)Ident)[1]), "=g"(((word32 *)Ident)[2])
::"%eax", "%ecx", "%edx"); ::"%eax", "%ecx", "%edx");
#else #else
_asm _asm
@@ -312,7 +311,6 @@ notamd:
} }
#if CPUTEST #if CPUTEST
#include <stdio.h> #include <stdio.h>
/* Desc: /* Desc: