Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from janbar/2.0.9
Browse files Browse the repository at this point in the history
version 2.0.9
  • Loading branch information
Lars Op den Kamp committed Mar 15, 2015
2 parents 767c8df + f63100f commit 59d0ddf
Show file tree
Hide file tree
Showing 15 changed files with 296 additions and 118 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ set(MYTHTV_SOURCES src/avinfo.cpp
add_subdirectory(lib/cppmyth)

set(DEPLIBS ${kodiplatform_LIBRARIES} cppmyth)
if (WIN32)
if(WIN32)
list(APPEND DEPLIBS ws2_32)
else()
list(APPEND DEPLIBS m)
Expand All @@ -72,6 +72,15 @@ if(__link_flags)
add_options(ALL_LANGUAGES ALL_BUILDS "${__link_flags}")
endif()

if(NOT WIN32 AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX))
if(HAS_BUILTIN_SYNC_ADD_AND_FETCH)
add_options(ALL_LANGUAGES ALL_BUILDS "-DHAS_BUILTIN_SYNC_ADD_AND_FETCH")
endif()
if(HAS_BUILTIN_SYNC_SUB_AND_FETCH)
add_options(ALL_LANGUAGES ALL_BUILDS "-DHAS_BUILTIN_SYNC_SUB_AND_FETCH")
endif()
endif()

set(BUILD_SHARED_LIBS ON)
build_addon(pvr.mythtv MYTHTV DEPLIBS)

Expand Down
43 changes: 33 additions & 10 deletions lib/cppmyth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ cmake_policy (VERSION 2.6)

project (cppmyth)

set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

enable_language(CXX)
enable_language(C)

Expand All @@ -15,29 +17,42 @@ endif ()

###############################################################################
# set lib version here
set (CPPMYTH_LIB_VERSION "1.2.0")
set (CPPMYTH_LIB_SOVERSION "1.2")
set (CPPMYTH_LIB_VERSION "1.3.1")
set (CPPMYTH_LIB_SOVERSION "1.3")

###############################################################################
# add definitions
if (MSVC)
# Turn off Microsofts "security" warnings.
add_definitions("/W3 /D_USE_32BIT_TIME_T /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo")
add_definitions ("/D_USE_32BIT_TIME_T /D_CRT_SECURE_NO_WARNINGS")
if (STATIC_CRT)
set (CMAKE_C_FLAGS_RELEASE "/MT")
set (CMAKE_C_FLAGS_DEBUG "/MTd")
set (CMAKE_CXX_FLAGS_RELEASE "/MT")
set (CMAKE_CXX_FLAGS_DEBUG "/MTd")
endif ()
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /W3")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W3")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /Od /RTC1 /EHsc /nologo")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W3 /Od /RTC1 /EHsc /nologo")
endif ()

if (NOT WIN32 AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX))
add_definitions ("-fPIC")
add_definitions ("-fPIC")
include (CheckLibraryExists)
include (CheckAtomic)
if (HAS_BUILTIN_SYNC_ADD_AND_FETCH)
add_definitions ("-DHAS_BUILTIN_SYNC_ADD_AND_FETCH")
endif ()
if (HAS_BUILTIN_SYNC_SUB_AND_FETCH)
add_definitions ("-DHAS_BUILTIN_SYNC_SUB_AND_FETCH")
endif ()
endif ()

###############################################################################
# configure
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include (CheckFunctionExists)
include (CheckFunctionKeywords)
find_package (Threads REQUIRED)

check_function_exists (timegm CHK_TIMEGM)
if (CHK_TIMEGM)
Expand Down Expand Up @@ -105,9 +120,17 @@ set (CPPMYTH_SOURCES

###############################################################################
# add targets
add_library(cppmyth STATIC ${CPPMYTH_SOURCES})
set (cppmyth_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
if (MSVC)
list (APPEND cppmyth_LIBRARIES ws2_32)
else ()
list (APPEND cppmyth_LIBRARIES m)
find_library (LIBRT rt)
if (LIBRT)
list (APPEND cppmyth_LIBRARIES rt)
endif ()
endif ()

if(MSVC)
target_link_libraries(cppmyth ws2_32)
endif()
add_library (cppmyth STATIC ${CPPMYTH_SOURCES})
target_link_libraries (cppmyth ${cppmyth_LIBRARIES})

10 changes: 10 additions & 0 deletions lib/cppmyth/cmake/CheckAtomic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(CheckCXXSourceCompiles)

check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
if (HAVE_LIBATOMIC)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
endif()

CHECK_CXX_SOURCE_COMPILES("int main() { long* temp=0; long ret=__sync_add_and_fetch(temp, 1); return 0; }" HAS_BUILTIN_SYNC_ADD_AND_FETCH)
CHECK_CXX_SOURCE_COMPILES("int main() { long* temp=0; long ret=__sync_sub_and_fetch(temp, 1); return 0; }" HAS_BUILTIN_SYNC_SUB_AND_FETCH)
CHECK_CXX_SOURCE_COMPILES("int main() { long *temp = 0; long ret=__sync_val_compare_and_swap(temp, 1, 1); return 0; }" HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP)
7 changes: 3 additions & 4 deletions lib/cppmyth/src/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ typedef volatile unsigned atomic_t;
#define __ARM_ARCH 7
#else
#warning could not detect ARM architecture
#define __ARM_ARCH 8
#endif
#endif
#endif
Expand Down Expand Up @@ -194,7 +193,7 @@ static CC_INLINE unsigned atomic_increment(atomic_t *valp)
: "r" (valp), "r"(inc)
: "cc", "memory");

#elif defined __GNUC__
#elif defined HAS_BUILTIN_SYNC_ADD_AND_FETCH
/*
* Don't know how to atomic increment for a generic architecture
* so try to use GCC builtin
Expand Down Expand Up @@ -330,10 +329,10 @@ static CC_INLINE unsigned atomic_decrement(atomic_t *valp)
: "r" (valp), "r"(inc)
: "cc", "memory");

#elif defined __GNUC__
#elif defined HAS_BUILTIN_SYNC_SUB_AND_FETCH
/*
* Don't know how to atomic decrement for a generic architecture
* so use GCC builtin
* so try to use GCC builtin
*/
__val = __sync_sub_and_fetch(valp, 1);

Expand Down
Loading

0 comments on commit 59d0ddf

Please sign in to comment.