Skip to content

Commit fe69fa6

Browse files
committed
chore: update vendored liblbfgs from https://github.com/chokkan/liblbfgs
1 parent c98d8be commit fe69fa6

File tree

5 files changed

+219
-65
lines changed

5 files changed

+219
-65
lines changed

src/arithmetic_ansi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
/* $Id: arithmetic_ansi.h 65 2010-01-29 12:19:16Z naoaki $ */
26+
/* $Id$ */
2727

2828
#include <stdlib.h>
2929
#include <memory.h>
@@ -51,7 +51,7 @@ inline static void vecfree(void *memblock)
5151
inline static void vecset(lbfgsfloatval_t *x, const lbfgsfloatval_t c, const int n)
5252
{
5353
int i;
54-
54+
5555
for (i = 0;i < n;++i) {
5656
x[i] = c;
5757
}

src/arithmetic_sse_double.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
/* $Id: arithmetic_sse_double.h 65 2010-01-29 12:19:16Z naoaki $ */
26+
/* $Id$ */
2727

2828
#include <stdlib.h>
29-
30-
#if !defined(__APPLE__)
29+
#ifndef __APPLE__
3130
#include <malloc.h>
3231
#endif
33-
3432
#include <memory.h>
3533

3634
#if 1400 <= _MSC_VER
@@ -43,13 +41,15 @@
4341

4442
inline static void* vecalloc(size_t size)
4543
{
46-
#ifdef _WIN32
44+
#if defined(_WIN32)
4745
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);
5148
#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+
}
5353
#endif
5454
if (memblock != NULL) {
5555
memset(memblock, 0, size);
@@ -59,7 +59,7 @@ inline static void* vecalloc(size_t size)
5959

6060
inline static void vecfree(void *memblock)
6161
{
62-
#ifdef _WIN32
62+
#ifdef _MSC_VER
6363
_aligned_free(memblock);
6464
#else
6565
free(memblock);
@@ -199,7 +199,7 @@ inline static void vecfree(void *memblock)
199199

200200

201201

202-
#if 3 <= __SSE__
202+
#if 3 <= __SSE__ || defined(__SSE3__)
203203
/*
204204
Horizontal add with haddps SSE3 instruction. The work register (rw)
205205
is unused.

src/arithmetic_sse_float.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
/* $Id: arithmetic_sse_float.h 65 2010-01-29 12:19:16Z naoaki $ */
26+
/* $Id$ */
2727

2828
#include <stdlib.h>
29-
30-
#if !defined(__APPLE__)
29+
#ifndef __APPLE__
3130
#include <malloc.h>
3231
#endif
33-
3432
#include <memory.h>
3533

3634
#if 1400 <= _MSC_VER
@@ -49,7 +47,16 @@
4947

5048
inline static void* vecalloc(size_t size)
5149
{
50+
#if defined(_MSC_VER)
5251
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
5360
if (memblock != NULL) {
5461
memset(memblock, 0, size);
5562
}
@@ -58,7 +65,11 @@ inline static void* vecalloc(size_t size)
5865

5966
inline static void vecfree(void *memblock)
6067
{
68+
#ifdef _MSC_VER
6169
_aligned_free(memblock);
70+
#else
71+
free(memblock);
72+
#endif
6273
}
6374

6475
#define vecset(x, c, n) \
@@ -189,7 +200,7 @@ inline static void vecfree(void *memblock)
189200

190201

191202

192-
#if 3 <= __SSE__
203+
#if 3 <= __SSE__ || defined(__SSE3__)
193204
/*
194205
Horizontal add with haddps SSE3 instruction. The work register (rw)
195206
is unused.

0 commit comments

Comments
 (0)