diff --git a/CMakeLists.txt b/CMakeLists.txt index e7aeef0..af0437b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,8 @@ add_definitions(-DLASP_MAX_NFFT=33554432) # 2**25 add_definitions(-D_REENTRANT) # ############### Choose an fft backend here -#set(LASP_FFT_BACKEND fftpack) -set(LASP_FFT_BACKEND "fftw") +set(LASP_FFT_BACKEND fftpack) +#set(LASP_FFT_BACKEND "fftw") if(LASP_FFT_BACKEND STREQUAL "fftw") find_library(FFTW_LIBRARY NAMES fftw3 fftw) @@ -55,6 +55,32 @@ endif(NOT DEFINED LASP_DEBUG) set(Python_ADDITIONAL_VERSIONS "3") # #################### Setting definitions and debug-specific compilation flags +# General make flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -Wno-type-limits \ +-Werror=implicit-function-declaration \ +-Werror=return-type") + +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(win32 true) + message("Building for Windows") + include_directories( + ..\\rtaudio + C:\\mingw\\include\\OpenBLAS + ) + add_definitions(-DMS_WIN64) + link_directories(C:\\mingw\\lib) + link_directories(C:\\mingw\\bin) + link_directories(..\\rtaudio) + link_directories(C:\\Users\\librewin7\\Miniconda3) +else() + set(win32 false) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c11 \ + -Werror=incompatible-pointer-types") + + + +endif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + if(LASP_DEBUG) set(TRACERNAME LASPTracer) set(LASP_DEBUG_CYTHON=True) @@ -87,10 +113,7 @@ endif(LASP_DEBUG) ############################## General compilation flags (independent of debug mode, windows or linux) set(CYTHON_EXTRA_C_FLAGS "-Wno-sign-compare -Wno-cpp -Wno-implicit-fallthrough -Wno-incompatible-pointer-types -Wno-strict-aliasing") -# General make flags -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c11 -Wall -Wextra -Wno-type-limits \ --Werror=implicit-function-declaration -Werror=incompatible-pointer-types \ --Werror=return-type") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11 -Wall -Wextra \ -Wno-type-limits") @@ -111,11 +134,7 @@ endif(LASP_USE_BLAS) # ############################# End compilation flags -if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(win32 true) -else() - set(win32 false) -endif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_package(PythonLibs REQUIRED ) find_package(PythonInterp REQUIRED) diff --git a/lasp/CMakeLists.txt b/lasp/CMakeLists.txt index 021e6d5..c44e31d 100644 --- a/lasp/CMakeLists.txt +++ b/lasp/CMakeLists.txt @@ -15,4 +15,4 @@ add_subdirectory(device) set_source_files_properties(wrappers.c PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} ${CYTHON_EXTRA_C_FLAGS}") cython_add_module(wrappers wrappers.pyx) -target_link_libraries(wrappers lasp_lib ) +target_link_libraries(wrappers lasp_lib python37) diff --git a/lasp/c/lasp_mq.c b/lasp/c/lasp_mq.c index d2c7ab1..e30f555 100644 --- a/lasp/c/lasp_mq.c +++ b/lasp/c/lasp_mq.c @@ -18,7 +18,9 @@ #define _GNU_SOURCE #include #include +#ifndef MS_WIN64 #include +#endif /* #endif */ typedef struct { diff --git a/lasp/c/lasp_tracer.c b/lasp/c/lasp_tracer.c index ebcee45..f122a77 100644 --- a/lasp/c/lasp_tracer.c +++ b/lasp/c/lasp_tracer.c @@ -11,17 +11,17 @@ #include "lasp_types.h" #ifdef _REENTRANT -#include -static _Thread_local us ASCEE_FN_LEVEL = 0; -static _Atomic(int) TRACERNAME = ATOMIC_VAR_INIT(DEFAULTTRACERLEVEL); +static __thread us ASCEE_FN_LEVEL = 0; + +static int TRACERNAME = DEFAULTTRACERLEVEL; void setTracerLevel(int level) { - atomic_store(&TRACERNAME,level); + __sync_lock_test_and_set(&TRACERNAME, level); } int getTracerLevel() { - return atomic_load(&TRACERNAME); + return __sync_fetch_and_add(&TRACERNAME, 0); } #else diff --git a/lasp/c/lasp_worker.c b/lasp/c/lasp_worker.c index 9d69aad..239c87f 100644 --- a/lasp/c/lasp_worker.c +++ b/lasp/c/lasp_worker.c @@ -26,7 +26,7 @@ typedef struct Workers_s { us num_workers; } Workers; -static void* threadfcn(void* data); +static void threadfcn(void* data); Workers* Workers_create(const us num_workers, JobQueue* jq, @@ -123,7 +123,7 @@ void Workers_free(Workers* w) { } -static void* threadfcn(void* thread_global_data) { +static void threadfcn(void* thread_global_data) { TRACE(15,"Started worker thread function"); dbgassert(thread_global_data,NULLPTRDEREF "thread_data in" diff --git a/lasp/device/CMakeLists.txt b/lasp/device/CMakeLists.txt index 708995a..a2fed95 100644 --- a/lasp/device/CMakeLists.txt +++ b/lasp/device/CMakeLists.txt @@ -5,5 +5,4 @@ set_source_files_properties(lasp_rtaudio.cxx PROPERTIES COMPILE_FLAGS cython_add_module(lasp_rtaudio lasp_rtaudio.pyx) -# target_link_libraries(lasp_portaudio portaudio) */ -target_link_libraries(lasp_rtaudio pthread rtaudio) +target_link_libraries(lasp_rtaudio pthread rtaudio python37) \ No newline at end of file diff --git a/lasp/lasp_common.py b/lasp/lasp_common.py index d623be6..60e856b 100644 --- a/lasp/lasp_common.py +++ b/lasp/lasp_common.py @@ -3,7 +3,7 @@ import os import platform import shelve - +import sys import appdirs import numpy as np @@ -22,10 +22,10 @@ lasp_appdir = appdirs.user_data_dir('Lasp', 'ASCEE') if not os.path.exists(lasp_appdir): try: - os.mkdir(lasp_appdir) + os.makedirs(lasp_appdir, exist_ok=True) except: print('Fatal error: could not create application directory') - exit(1) + sys.exit(1) class Shelve: def load(self, key, default_value):