On Wed, Oct 2, 2013 at 8:57 AM, Cedric Bail <cedric.b...@samsung.com> wrote: > cedric pushed a commit to branch master. > > http://git.enlightenment.org/core/efl.git/commit/?id=ff3d2a68d5762ec6bed88f97f2a3751bb51caf86 > > commit ff3d2a68d5762ec6bed88f97f2a3751bb51caf86 > Author: Cedric Bail <cedric.b...@samsung.com> > Date: Wed Oct 2 18:31:10 2013 +0900 > > eina: add infrastructure to handle more CPU and compiler builtin > information. > --- > configure.ac | 3 ++ > m4/gcc_check_builtin.m4 | 17 +++------- > src/Makefile_Eina.am | 1 + > src/lib/eina/eina_config.h.in | 15 +++++++++ > src/lib/eina/eina_cpu.c | 37 +++++++++++++++++++--- > src/lib/eina/eina_cpu.h | 11 +++++++ > src/lib/eina/eina_inline_cpu.x | 70 > ++++++++++++++++++++++++++++++++++++++++++ > src/lib/eina/eina_main.c | 4 ++- > 8 files changed, 140 insertions(+), 18 deletions(-) > > diff --git a/configure.ac b/configure.ac > index dd327bb..6ca409e 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -792,6 +792,9 @@ AC_DEFINE_IF([HAVE_DIRENT_H], [test "x${have_dirent}" = > "xyes"], > ### Checks for structures > > ### Checks for compiler characteristics > +EFL_CHECK_GCC_BUILTIN([bswap16], [HAVE_BSWAP16]) > +EFL_CHECK_GCC_BUILTIN([bswap32], [HAVE_BSWAP32]) > +EFL_CHECK_GCC_BUILTIN([bswap64], [HAVE_BSWAP64]) > > ### Checks for linker characteristics > > diff --git a/m4/gcc_check_builtin.m4 b/m4/gcc_check_builtin.m4 > index 1434c5f..d512250 100644 > --- a/m4/gcc_check_builtin.m4 > +++ b/m4/gcc_check_builtin.m4 > @@ -1,20 +1,13 @@ > AC_DEFUN([EFL_CHECK_GCC_BUILTIN], > [efl_check_gcc_builtin_save_libs=$LIBS > +EINA_CONFIGURE_$2="" > LIBS="-lm $LIBS" > AC_LINK_IFELSE( > [AC_LANG_PROGRAM( > -[[#ifndef __GNUC__ > -choke me > -#else > -#undef $1 > -/* Declare this function with same prototype as __builtin_$1. > - This removes warning about conflicting type with builtin */ > -__typeof__(__builtin_$1) $1; > - > -__typeof__(__builtin_$1) *f = $1; > -#endif > -]], [[return f != $1;]] > +[[]], [[return __builtin_$1(42);]] > )], > -[AC_DEFINE([$2], [123], [GCC builtin $1 exists])]) > +[EINA_CONFIGURE_$2="#define EINA_$2" > +AC_DEFINE([$2], [1], [GCC builtin $1 exists])]) > +AC_SUBST(EINA_CONFIGURE_$2) > LIBS=$efl_check_gcc_builtin_save_libs]) > > diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am > index 7e40749..09264ce 100644 > --- a/src/Makefile_Eina.am > +++ b/src/Makefile_Eina.am > @@ -57,6 +57,7 @@ lib/eina/eina_trash.h \ > lib/eina/eina_iterator.h \ > lib/eina/eina_main.h \ > lib/eina/eina_cpu.h \ > +lib/eina/eina_inline_cpu.x \ > lib/eina/eina_sched.h \ > lib/eina/eina_tiler.h \ > lib/eina/eina_hamster.h \ > diff --git a/src/lib/eina/eina_config.h.in b/src/lib/eina/eina_config.h.in > index abcf2f9..eb0869c 100644 > --- a/src/lib/eina/eina_config.h.in > +++ b/src/lib/eina/eina_config.h.in > @@ -72,4 +72,19 @@ > #endif > @EINA_CONFIGURE_HAVE_ALLOCA_H@ > > +#ifdef EINA_HAVE_BSWAP16 > +# undef EINA_HAVE_BSWAP16 > +#endif > +@EINA_CONFIGURE_HAVE_BSWAP16@ > + > +#ifdef EINA_HAVE_BSWAP32 > +# undef EINA_HAVE_BSWAP32 > +#endif > +@EINA_CONFIGURE_HAVE_BSWAP32@ > + > +#ifdef EINA_HAVE_BSWAP64 > +# undef EINA_HAVE_BSWAP64 > +#endif > +@EINA_CONFIGURE_HAVE_BSWAP64@ > + > #endif /* EINA_CONFIG_H_ */ > diff --git a/src/lib/eina/eina_cpu.c b/src/lib/eina/eina_cpu.c > index eb71002..670b21c 100644 > --- a/src/lib/eina/eina_cpu.c > +++ b/src/lib/eina/eina_cpu.c > @@ -92,6 +92,9 @@ void _x86_simd(Eina_Cpu_Features *features) > * 28 = HTT (Hyper Threading) > * ecx > * 0 = SSE3 > + * 9 = SSSE3 > + * 19 = SSE4.1 > + * 20 = SSE4.2 > */ > if ((d >> 23) & 1) > *features |= EINA_CPU_MMX; > @@ -104,6 +107,15 @@ void _x86_simd(Eina_Cpu_Features *features) > > if (c & 1) > *features |= EINA_CPU_SSE3; > + > + if ((c >> 9) & 1) > + *features |= EINA_CPU_SSSE3; > + > + if ((c >> 19) & 1) > + *features |= EINA_CPU_SSE41; > + > + if ((c >> 20) & 1) > + *features |= EINA_CPU_SSE42; > } > #endif > > @@ -118,17 +130,32 @@ void _x86_simd(Eina_Cpu_Features *features) > /* FIXME the features checks should be called when this function is called? > * or make it static by doing eina_cpu_init() and return a local var > */ > +EAPI Eina_Cpu_Features eina_cpu_features = 0; > + > +Eina_Bool > +eina_cpu_init(void) > +{ > +#if defined(__i386__) || defined(__x86_64__) > + _x86_simd(&eina_cpu_features); > +#endif > + // FIXME: Handle NEON and friends > + > + return EINA_TRUE; > +} > + > +Eina_Bool > +eina_cpu_shutdown(void) > +{ > + return EINA_TRUE; > +} > + > /** > * > * @return > */ > EAPI Eina_Cpu_Features eina_cpu_features_get(void) > { > - Eina_Cpu_Features ecf = 0; > -#if defined(__i386__) || defined(__x86_64__) > - _x86_simd(&ecf); > -#endif > - return ecf; > + return eina_cpu_features; > } > > static int _cpu_count = -1; > diff --git a/src/lib/eina/eina_cpu.h b/src/lib/eina/eina_cpu.h > index ac32e1d..651d925 100644 > --- a/src/lib/eina/eina_cpu.h > +++ b/src/lib/eina/eina_cpu.h > @@ -31,9 +31,20 @@ typedef enum _Eina_Cpu_Features > EINA_CPU_ALTIVEC = 0x00000010, > EINA_CPU_VIS = 0x00000020, > EINA_CPU_NEON = 0x00000040, > + EINA_CPU_SSSE3 = 0x00000080, > + EINA_CPU_SSE41 = 0x00000100, > + EINA_CPU_SSE42 = 0x00000200 > } Eina_Cpu_Features; > > +EAPI extern Eina_Cpu_Features eina_cpu_features; > + > EAPI Eina_Cpu_Features eina_cpu_features_get(void); > EAPI int eina_cpu_count(void); > > +static inline unsigned short eina_swap16(unsigned short x); > +static inline unsigned int eina_swap32(unsigned int x); > +static inline unsigned long long eina_swap64(unsigned long long x);
what's wrong with bswap_{32,16,64}? At least with gcc the correct bswap instruction is emitted when available. Lucas De Marchi ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel