The error occurs in all versions of gcc 3.4 - 4.2
The error occurs because in config.h (line 303) _mm_alloc is linked to
_mingw_aligned_malloc
#elif defined(__MINGW32__)
#ifndef _mm_malloc
#define _mm_malloc(a, b) __mingw_aligned_malloc(a, b)
#define _mm_free(a) __mingw_aligned_free(a)
#endif
#define CRYPTOPP_MM_MALLOC_AVAILABLE
while in salsa.cpp (line 9) including emmintrin.h results in a error
since _mm_alloc is defined in mm_alloc.h as local function.
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
#include <emmintrin.h>
#endif
This quick and dirty fix in salsa.cpp solved the problem
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
+ #if defined(__MINGW32__)
+ #ifdef _mm_malloc
+ #undef _mm_malloc
+ #undef _mm_free
+ #endif
+ #endif
#include <emmintrin.h>
#endif
another possible fix could be in config.h
#if !defined(CRYPTOPP_DISABLE_SSE2) &&
(defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
+ #if defined(__MINGW32__)
+ #include <emmintrin.h>
+ #endif
#else
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
#endif
The reason _mm_alloc is defined to be __mingw_aligned_malloc is that
_mm_alloc doesn't exist in my build of GCC (3.4.2) for MINGW. I'm not sure
if either of your suggested fixes is backwards compatible.
The simplest fix would be to remove all of the following from config.h:
#elif defined(__MINGW32__)
#if (CRYPTOPP_GCC_VERSION < 40100) && !defined(_mm_malloc)
#define _mm_malloc(a, b) __mingw_aligned_malloc(a, b)
#define _mm_free(a) __mingw_aligned_free(a)
#endif
#define CRYPTOPP_MM_MALLOC_AVAILABLE
and just let the code in Crypto++ do the malloc alignment. Can you try that
and let me know if it works?
On May 28, 2:51 pm, "Wei Dai" <wei...@weidai.com> wrote:
> It doesn't look like an official build of GCC 4.2 for MINGW is available. I
> do see an unofficial one athttp://www.thisiscool.com/gcc_mingw.htm#gcj42.
> Is that where you obtained your copy?
mingw's "official" builds seem to be stuck in purgatory;) while the
rest of the world has moved on. They have not released an official
build in almost 3 years. You can however try the candidate build (v
3.4.5) and you should be able to reproduce the problem. I didnt
download the 4.2 version from the link you mentioned as that is an old
build with one of the beta snapshots. I downloaded mine from here
http://forum.doom9.org/showthread.php?p=1004932. which is build from
the final release of 4.2 on may 13. This build supports multithreading
using OpenMP :). If the download link do not work please let me know
and i will upload it somewhere.
> The reason _mm_alloc is defined to be __mingw_aligned_malloc is that
> _mm_alloc doesn't exist in my build of GCC (3.4.2) for MINGW.
You are right, v3.4.2 does not define _mm_alloc at all. However v3.4.5
and above do. You can check if the following file exists.
C:\mingw\lib\gcc\i686-pc-mingw32\4.2.0\include\mm_malloc.h
Even in the latest gcc builds _mm_alloc is not defined in malloc.h .
It is only if you include one of the sse/sse2/sse3 headers emmintrin.h/
xmmintrin.h/pmmintrin.h , that _mm_alloc gets defined through
mm_malloc.h
>I'm not sure if either of your suggested fixes is backwards compatible.
You are right, they arent. I didnt bother to check with 3.4.2 or
older.
> The simplest fix would be to remove all of the following from config.h:
>
> #elif defined(__MINGW32__)
> #if (CRYPTOPP_GCC_VERSION < 40100) && !defined(_mm_malloc)
> #define _mm_malloc(a, b) __mingw_aligned_malloc(a, b)
> #define _mm_free(a) __mingw_aligned_free(a)
> #endif
> #define CRYPTOPP_MM_MALLOC_AVAILABLE
>
> and just let the code in Crypto++ do the malloc alignment. Can you try that
> and let me know if it works?
Yup this works fine. This probably is the simplest fix as opposed to
version checking.