File tree Expand file tree Collapse file tree 5 files changed +219
-65
lines changed Expand file tree Collapse file tree 5 files changed +219
-65
lines changed Original file line number Diff line number Diff line change 23
23
* THE SOFTWARE.
24
24
*/
25
25
26
- /* $Id: arithmetic_ansi.h 65 2010-01-29 12:19:16Z naoaki $ */
26
+ /* $Id$ */
27
27
28
28
#include <stdlib.h>
29
29
#include <memory.h>
@@ -51,7 +51,7 @@ inline static void vecfree(void *memblock)
51
51
inline static void vecset (lbfgsfloatval_t * x , const lbfgsfloatval_t c , const int n )
52
52
{
53
53
int i ;
54
-
54
+
55
55
for (i = 0 ;i < n ;++ i ) {
56
56
x [i ] = c ;
57
57
}
Original file line number Diff line number Diff line change 23
23
* THE SOFTWARE.
24
24
*/
25
25
26
- /* $Id: arithmetic_sse_double.h 65 2010-01-29 12:19:16Z naoaki $ */
26
+ /* $Id$ */
27
27
28
28
#include <stdlib.h>
29
-
30
- #if !defined(__APPLE__ )
29
+ #ifndef __APPLE__
31
30
#include <malloc.h>
32
31
#endif
33
-
34
32
#include <memory.h>
35
33
36
34
#if 1400 <= _MSC_VER
43
41
44
42
inline static void * vecalloc (size_t size )
45
43
{
46
- #ifdef _WIN32
44
+ #if defined( _WIN32 )
47
45
void * memblock = _aligned_malloc (size , 16 );
48
- #elif defined(__APPLE__ )
49
- /* Memory on Mac OS X is already aligned to 16 bytes */
50
- void * memblock = malloc (size );
46
+ #elif defined(__APPLE__ ) /* OS X always aligns on 16-byte boundaries */
47
+ void * memblock = malloc (size );
51
48
#else
52
- void * memblock = memalign (16 , size );
49
+ void * memblock = NULL , * p = NULL ;
50
+ if (posix_memalign (& p , 16 , size ) == 0 ) {
51
+ memblock = p ;
52
+ }
53
53
#endif
54
54
if (memblock != NULL ) {
55
55
memset (memblock , 0 , size );
@@ -59,7 +59,7 @@ inline static void* vecalloc(size_t size)
59
59
60
60
inline static void vecfree (void * memblock )
61
61
{
62
- #ifdef _WIN32
62
+ #ifdef _MSC_VER
63
63
_aligned_free (memblock );
64
64
#else
65
65
free (memblock );
@@ -199,7 +199,7 @@ inline static void vecfree(void *memblock)
199
199
200
200
201
201
202
- #if 3 <= __SSE__
202
+ #if 3 <= __SSE__ || defined( __SSE3__ )
203
203
/*
204
204
Horizontal add with haddps SSE3 instruction. The work register (rw)
205
205
is unused.
Original file line number Diff line number Diff line change 23
23
* THE SOFTWARE.
24
24
*/
25
25
26
- /* $Id: arithmetic_sse_float.h 65 2010-01-29 12:19:16Z naoaki $ */
26
+ /* $Id$ */
27
27
28
28
#include <stdlib.h>
29
-
30
- #if !defined(__APPLE__ )
29
+ #ifndef __APPLE__
31
30
#include <malloc.h>
32
31
#endif
33
-
34
32
#include <memory.h>
35
33
36
34
#if 1400 <= _MSC_VER
49
47
50
48
inline static void * vecalloc (size_t size )
51
49
{
50
+ #if defined(_MSC_VER )
52
51
void * memblock = _aligned_malloc (size , 16 );
52
+ #elif defined(__APPLE__ ) /* OS X always aligns on 16-byte boundaries */
53
+ void * memblock = malloc (size );
54
+ #else
55
+ void * memblock = NULL , * p = NULL ;
56
+ if (posix_memalign (& p , 16 , size ) == 0 ) {
57
+ memblock = p ;
58
+ }
59
+ #endif
53
60
if (memblock != NULL ) {
54
61
memset (memblock , 0 , size );
55
62
}
@@ -58,7 +65,11 @@ inline static void* vecalloc(size_t size)
58
65
59
66
inline static void vecfree (void * memblock )
60
67
{
68
+ #ifdef _MSC_VER
61
69
_aligned_free (memblock );
70
+ #else
71
+ free (memblock );
72
+ #endif
62
73
}
63
74
64
75
#define vecset (x , c , n ) \
@@ -189,7 +200,7 @@ inline static void vecfree(void *memblock)
189
200
190
201
191
202
192
- #if 3 <= __SSE__
203
+ #if 3 <= __SSE__ || defined( __SSE3__ )
193
204
/*
194
205
Horizontal add with haddps SSE3 instruction. The work register (rw)
195
206
is unused.
You can’t perform that action at this time.
0 commit comments