Skip to content

Commit

Permalink
macOS: increase max allowed file descriptors via FD_SETSIZE, added mi…
Browse files Browse the repository at this point in the history
…ssing defines for APPLE to cmake lists (not tested)
  • Loading branch information
danomatika committed Apr 15, 2024
1 parent 4ffcf8c commit 4b8a840
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ else()
if(NOT APPLE AND NOT WIN32)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic")
endif()
if(APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -DFD_SETSIZE=10240")
endif()
endif()
add_definitions(-DPD=1 -DUSEAPI_DUMMY=1)

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ ifeq ($(UNAME), Darwin) # Mac
PDNATIVE_PLATFORM = mac
PDNATIVE_ARCH =
PLATFORM_CFLAGS = -DHAVE_ALLOCA_H -DHAVE_LIBDL -DHAVE_MACHINE_ENDIAN_H \
-D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT \
-I"$(JAVA_HOME)/include/" -I"$(JAVA_HOME)/include/darwin/"
LDFLAGS = -dynamiclib -ldl -Wl,-no_compact_unwind
# helps for machine/endian.h to be found
PLATFORM_CFLAGS += -D_DARWIN_C_SOURCE
# increase max allowed file descriptors
PLATFORM_CFLAGS += -D_DARWIN_UNLIMITED_SELECT -DFD_SETSIZE=10240
ifeq ($(FAT_LIB), true)
# macOS universal "fat" lib compilation
MAC_VER = $(shell sw_vers -productVersion | cut -f1 -f2 -d.)
Expand Down
1 change: 1 addition & 0 deletions libpd.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Pod::Spec.new do |spec|
spec.compiler_flags = '-DPD', '-DUSEAPI_DUMMY', '-DPD_INTERNAL',
'-DHAVE_UNISTD_H', '-DHAVE_ALLOCA_H',
'-DHAVE_MACHINE_ENDIAN_H', '-D_DARWIN_C_SOURCE',
'-D_DARWIN_UNLIMITED_SELECT', '-DFD_SETSIZE=10240',
'-DLIBPD_EXTRA', '-fcommon'
spec.frameworks = 'Foundation'

Expand Down
2 changes: 2 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
pd_defines.append(('HAVE_ALLOCA_H', 1))
pd_defines.append(('HAVE_MACHINE_ENDIAN_H', 1))
pd_defines.append(('_DARWIN_C_SOURCE', 1))
pd_defines.append(('_DARWIN_UNLIMITED_SELECT', 1))
pd_defines.append(('FD_SETSIZE', 10240))
pd_defines.append(('HAVE_LIBDL', 1))
pd_libraries.append('dl')
elif sys.platform.startswith('win32') or sys.platform.startswith('msys'):
Expand Down

0 comments on commit 4b8a840

Please sign in to comment.