Patch submitted by Nic Schraudolph to fix compiling problems on Mac OS X.

This commit is contained in:
Naoaki Okazaki 2010-11-17 09:25:11 +09:00
parent 4a7248af48
commit 94854170e7
4 changed files with 25 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2010-xx-xx Naoaki Okazaki <okazaki at chokkan org>
* libLBFGS 1.10:
- Fixed compiling errors on Mac OS X; this patch was kindly submitted by Nic Schraudolph.
2010-01-29 Naoaki Okazaki <okazaki at chokkan org> 2010-01-29 Naoaki Okazaki <okazaki at chokkan org>
* libLBFGS 1.9: * libLBFGS 1.9:

View File

@ -598,6 +598,9 @@ libLBFGS is distributed under the term of the
<a href="http://opensource.org/licenses/mit-license.php">MIT license</a>. <a href="http://opensource.org/licenses/mit-license.php">MIT license</a>.
@section changelog History @section changelog History
- Version 1.10 (2010-xx-xx):
- Fixed compiling errors on Mac OS X; this patch was kindly submitted by
Nic Schraudolph.
- Version 1.9 (2010-01-29): - Version 1.9 (2010-01-29):
- Fixed a mistake in checking the validity of the parameters "ftol" and - Fixed a mistake in checking the validity of the parameters "ftol" and
"wolfe"; this was discovered by Kevin S. Van Horn. "wolfe"; this was discovered by Kevin S. Van Horn.
@ -718,6 +721,7 @@ Special thanks go to:
- Yoshimasa Tsuruoka and Daisuke Okanohara for technical information about - Yoshimasa Tsuruoka and Daisuke Okanohara for technical information about
OWL-QN OWL-QN
- Takashi Imamichi for the useful enhancements of the backtracking method - Takashi Imamichi for the useful enhancements of the backtracking method
- Kevin S. Van Horn and Nic Schraudolph for bug fixes
Finally I would like to thank the original author, Jorge Nocedal, who has been Finally I would like to thank the original author, Jorge Nocedal, who has been
distributing the effieicnt and explanatory implementation in an open source distributing the effieicnt and explanatory implementation in an open source

View File

@ -26,7 +26,9 @@
/* $Id$ */ /* $Id$ */
#include <stdlib.h> #include <stdlib.h>
#ifndef __APPLE__
#include <malloc.h> #include <malloc.h>
#endif
#include <memory.h> #include <memory.h>
#if 1400 <= _MSC_VER #if 1400 <= _MSC_VER
@ -39,8 +41,10 @@
inline static void* vecalloc(size_t size) inline static void* vecalloc(size_t size)
{ {
#ifdef _MSC_VER #if defined(_MSC_VER)
void *memblock = _aligned_malloc(size, 16); void *memblock = _aligned_malloc(size, 16);
#elif defined(__APPLE__) /* OS X always aligns on 16-byte boundaries */
void *memblock = malloc(size);
#else #else
void *memblock = memalign(16, size); void *memblock = memalign(16, size);
#endif #endif
@ -192,7 +196,7 @@ inline static void vecfree(void *memblock)
#if 3 <= __SSE__ #if 3 <= __SSE__ || defined(__SSE3__)
/* /*
Horizontal add with haddps SSE3 instruction. The work register (rw) Horizontal add with haddps SSE3 instruction. The work register (rw)
is unused. is unused.

View File

@ -26,7 +26,9 @@
/* $Id$ */ /* $Id$ */
#include <stdlib.h> #include <stdlib.h>
#ifndef __APPLE__
#include <malloc.h> #include <malloc.h>
#endif
#include <memory.h> #include <memory.h>
#if 1400 <= _MSC_VER #if 1400 <= _MSC_VER
@ -45,7 +47,13 @@
inline static void* vecalloc(size_t size) inline static void* vecalloc(size_t size)
{ {
#if defined(_MSC_VER)
void *memblock = _aligned_malloc(size, 16); void *memblock = _aligned_malloc(size, 16);
#elif defined(__APPLE__) /* OS X always aligns on 16-byte boundaries */
void *memblock = malloc(size);
#else
void *memblock = memalign(16, size);
#endif
if (memblock != NULL) { if (memblock != NULL) {
memset(memblock, 0, size); memset(memblock, 0, size);
} }
@ -185,7 +193,7 @@ inline static void vecfree(void *memblock)
#if 3 <= __SSE__ #if 3 <= __SSE__ || defined(__SSE3__)
/* /*
Horizontal add with haddps SSE3 instruction. The work register (rw) Horizontal add with haddps SSE3 instruction. The work register (rw)
is unused. is unused.