Search code examples
windowsvisual-c++kerneldevice-driverwdk

Using VC intrinsic in kernel space


My question is how to use intrinsics in kernel space (on Windows), when the header file is contained with the SDK (as installed from VC 10) and the WDK which I'm using to compile the driver has no knowledge of this file. When I #include <intrin.h> everything works fine but when I start to compile I get

error C1083: Cannot open include file: 'intrin.h': No such file or directory

I tried copying the appropriate files to the WDK directory but it didn't work out. I know I can start writing inline assembly but to be honest I want to refrain from this since the intrinsic support is there I just don't know how to access it.


Solution

  • Some of the newer headers are missing in the WDK directories. Just copy the declaration over.

    E.g. (because is missing from the WDK):

    #include <emmintrin.h>
    
    extern "C" {
    extern __m128i _mm_abs_epi16 (__m128i a);
    extern __m128i _mm_shuffle_epi8 (__m128i a, __m128i b);
    extern __m128i _mm_blendv_epi8 (__m128i v1, __m128i v2, __m128i mask);
    extern __m128i _mm_alignr_epi8 (__m128i a, __m128i b, int n);
    };