Skip to content

Commit

Permalink
Fix compile and link error for OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
t-mat committed Jul 11, 2013
1 parent ce7a63b commit 342c7e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ OBJDIR = obj
CC = gcc
CXX = g++
##CXX = g++-4.6
DUMPMACHINE = $(shell gcc -dumpmachine)

CFLAGS = -Wall -W -Wextra -pedantic -O2 -std=c99
CXXFLAGS = -Wall -W -Wextra -pedantic -Weffc++ -Wno-missing-field-initializers -O2 -std=c++0x -Ilz4/

LD = $(CXX)
LDFLAGS = -lrt -pthread
LDFLAGS =

ifneq(, $(findstring darwin, $(DUMPMACHINE)))
## Mac OS X
LDFLAGS += -pthread
else
## Linux, etc
LDFLAGS += -lrt -pthread
endif

SRCS = $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(addprefix $(OBJDIR)/,$(notdir $(SRCS:.cpp=.o)))
Expand Down
4 changes: 2 additions & 2 deletions src/lz4mt_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ unsigned Lz4Mt::getHardwareConcurrency() {

// following code is borrowed from boost-1.53.0/libs/thread/src/pthread/thread.cpp
#if defined(__APPLE__) || defined(__FreeBSD__)
{ // ## NOT TESTED ##
{
int c = 0;
size_t size = sizeof(c);
if(0 == sysctlbyname("hw.ncpu", &count, &size, NULL, 0)) {
if(0 == sysctlbyname("hw.ncpu", &c, &size, NULL, 0)) {
return static_cast<unsigned>(c);
}
}
Expand Down

0 comments on commit 342c7e6

Please sign in to comment.