Fixes for DragonFly BSD from Weitian LI #1121

This commit is contained in:
nick black 2021-01-11 12:10:04 -05:00
parent 01d9b63c5b
commit d4aef247ea
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 15 additions and 3 deletions

View File

@ -262,6 +262,8 @@ target_compile_definitions(notcurses-static
set(PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly")
set(PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig")
endif()
# libnotcurses++
@ -375,7 +377,7 @@ install(FILES ${NCPP_INTERNAL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/n
# notcurses-demo
file(GLOB DEMOSRCS CONFIGURE_DEPENDS src/demo/*.c)
add_executable(notcurses-demo ${DEMOSRCS})
add_executable(notcurses-demo ${DEMOSRCS} ${COMPATSRC})
target_compile_definitions(notcurses-demo
PRIVATE
_GNU_SOURCE
@ -549,7 +551,7 @@ target_link_libraries(notcurses-tetris
# notcurses-view
if(${USE_FFMPEG} OR ${USE_OIIO})
file(GLOB VIEWSRCS CONFIGURE_DEPENDS src/view/*.cpp)
add_executable(notcurses-view ${VIEWSRCS})
add_executable(notcurses-view ${VIEWSRCS} ${COMPATSRC})
target_include_directories(notcurses-view
PRIVATE
include

View File

@ -1,6 +1,8 @@
#ifndef __linux__
#ifndef __FreeBSD__
#include <time.h>
#include <stdint.h>
#include "compat/compat.h"
// clock_nanosleep is unavailable on DragonFly BSD and Mac OS X
int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *request,
struct timespec *remain){
@ -9,7 +11,7 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *request
return -1;
}
uint64_t nowns = timespec_to_ns(&now);
uint64_t targns = timespec_to_ns(&request);
uint64_t targns = timespec_to_ns(request);
if(flags != TIMER_ABSTIME){
targns += nowns;
}

View File

@ -1,6 +1,10 @@
#ifndef NOTCURSES_COMPAT
#define NOTCURSES_COMPAT
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#define NANOSECS_IN_SEC 1000000000ul
@ -24,4 +28,8 @@ int clock_nanosleep(clockid_t clockid, int flags,
const struct timespec *request,
struct timespec *remain);
#ifdef __cplusplus
}
#endif
#endif