Wireshark-dev: Re: [Wireshark-dev] How to define HAVE_SSE42 with autotools?
From: Jakub Zawadzki <[email protected]>
Date: Tue, 10 Jun 2014 23:54:55 +0200

On Tue, Jun 10, 2014 at 05:06:24PM +0000, Anders Broman wrote:
> >From: [email protected] [mailto:[email protected]] On Behalf Of Guy Harris
> >
> >HAVE_SSE42 is used in two places:
> >
> >	1) wsutil/ws_mempbrk_sse42.c, where it controls whether to build that file at all;
> >
> >	2) wsutil/ws_mempbrk.c, where it controls whether to check whether the CPU has SSE 4.2 and, if it does, call the SSE 4.2 version of the code.
> >
> >So what HAVE_SSE42 really seems to mean is "does the compiler support the intrinsics used in wsutil/ws_mempbrk_sse42.c?"
> >
> >Should we, instead, check for compiler support for those intrinsics?
> Yes I guess...
> >And will the compiler generate code for those intrinsics, using the SSE 4.2 instructions, even if you haven't told it, with a command-line option, to generate SSE 4.2 code in general?  Or does the >compiler not do a good job of supporting choosing whether to use SSE 4.2 instructions at run time rather than at compile time?
> I have recently added some macros I found that define HAVE_SSE4_2 so at least the stuff compiles now on all the buildbots(I think).
> I'm not sure if there should be a command line option or not. But ideally we should compile ws_mempbrk_sse42.c if the compiler supports it and check cpu_info() at runtime to use it or not.

What about using simple standard AC_TRY_COMPILE( )?

something like:


AC_MSG_CHECKING([whether the compiler support -msse4.2 and if there is nmmintrin.h header])

CFLAGS="$CFLAGS -msse4.2"

[#include <nmmintrin.h>],
[return 0;],
	AC_DEFINE(HAVE_SSE42,,[Support SSSE4.2 (Streaming SIMD Extensions 4.2) instructions])

dnl build libwsutil_sse42 only if there is SSE4.2
AM_CONDITIONAL(SSE42_SUPPORTED, test "x$ac_cv_wireshark_have_sse42" = "xno")



+ uncommented if SSE42_SUPPORTED in wsutil/Makefile.am

Anders it's ok for you?

I like idea to force (don't do runtime detection) SSE4.2 if -msse4.2 is supported & host CPU support can do sse4.2, but I think it's not worth troubles :)

With Regards,