-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement clock_nanosleep() for DragonFly BSD #1121
Comments
GNUlib doesn't implement Of course, we then need integrate it with the project. |
It looks like @grendello 's #1280 will implement |
I've created the new files src/compat/compat.{hc}. These are available to all binaries by adding src to the include directories, and src/compat/compat.c to the sources. Several functions are implemented here which one or more target operating systems are missing, right now all related to time. This includes clock_nanosleep(), which is missing on OS X and DragonFly BSD. Eliminate the other three definitions of timespec_to_ns() and friends. Standardize on NANOSECS_IN_SEC rather than the more opaque GIG. Progress on #1121.
I've gone ahead and implemented |
I've asked the DragonFlyBSD people to attempt a build with this fix. Closing until we hear otherwise. |
Hi @dankamongmen , thank you for taking care of DragonFly BSD. With this change, notcurses still has issues to compile on DragonFly. I've made the following patches to fix the compilation issues: --- CMakeLists.txt.orig 2021-01-10 21:47:39 UTC
+++ CMakeLists.txt
@@ -262,6 +262,8 @@ target_compile_definitions(notcurses-sta
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} D
# 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
--- src/compat/compat.c.orig 2021-01-10 21:47:39 UTC
+++ src/compat/compat.c
@@ -1,6 +1,8 @@
#ifndef __linux__
#ifndef __FreeBSD__
+#include <stdint.h>
#include <time.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, i
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;
}
--- src/compat/compat.h.orig 2021-01-11 04:14:28 UTC
+++ src/compat/compat.h
@@ -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, i
const struct timespec *request,
struct timespec *remain);
+#ifdef __cplusplus
+}
+#endif
+
#endif In addition, notcurses requires the |
Beautiful! It looks like most of these are changes I ought make upstream--thanks for correcting my stupidities! All necessary changes will be present in the 2.1.5 release. |
@liweitianux i've merged all the changes you provided above, which all look good and correct. They will be released as part of 2.1.5. Until that release (sometime this week, most likely), your patch ought suffice. THANK YOU! |
@dankamongmen No problem :D I've switched to GCC 9.x to retry the build, and now I'm having this issue:
And the execvpe(3) man page on Linux says |
|
@dankamongmen Cool. With the following minor fix, I managed to build and package notcurses on DragonFly BSD: --- CMakeLists.txt.orig 2021-01-11 22:11:39 UTC
+++ CMakeLists.txt
@@ -405,7 +405,7 @@ if(USE_POC)
file(GLOB POCSRCS CONFIGURE_DEPENDS src/poc/*.c src/poc/*.cpp)
foreach(f ${POCSRCS})
get_filename_component(fe "${f}" NAME_WE)
- add_executable(${fe} ${f})
+ add_executable(${fe} ${f} ${COMPATSRC})
target_include_directories(${fe}
PRIVATE include src "${TERMINFO_INCLUDE_DIRS}"
"${PROJECT_BINARY_DIR}/include" (I missed this since I was unable to reach to this stage yesterday.) In addition, I propose the following patch: diff --git a/README.md b/README.md
index 89d9b340..0df85ad2 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ may well be possible to use still older versions. Let me know of any successes!
* (OPTIONAL) (documentation) [pandoc](https://pandoc.org/index.html) 1.19.2+
* (OPTIONAL) (python bindings): Python 3.7+, [CFFI](https://pypi.org/project/cffi/) 1.13.2+, [pypandoc](https://pypi.org/project/pypandoc/) 1.5+
* (OPTIONAL) (rust bindings): rust 1.47.0+, [bindgen](https://crates.io/crates/bindgen) 0.55.1+, pkg-config 0.3.18+, cty 0.2.1+
-* (runtime) Linux 5.3+ or FreeBSD 11+
+* (runtime) Linux 5.3+ or FreeBSD 11+ or DragonFly BSD 5.9+
### Building
diff --git a/src/fetch/main.c b/src/fetch/main.c
index 0d8488bb..9ed54b8e 100644
--- a/src/fetch/main.c
+++ b/src/fetch/main.c
@@ -243,6 +243,7 @@ unix_gethostname(fetched_info* fi){
typedef enum {
NCNEO_LINUX,
NCNEO_FREEBSD,
+ NCNEO_DRAGONFLY,
NCNEO_UNKNOWN,
} ncneo_kernel_e;
@@ -259,6 +260,8 @@ get_kernel(fetched_info* fi){
return NCNEO_LINUX;
}else if(strcmp(uts.sysname, "FreeBSD") == 0){
return NCNEO_FREEBSD;
+ }else if(strcmp(uts.sysname, "DragonFly") == 0){
+ return NCNEO_DRAGONFLY;
}
fprintf(stderr, "Unknown operating system via uname: %s\n", uts.sysname);
return NCNEO_UNKNOWN;
@@ -274,6 +277,16 @@ freebsd_ncneofetch(fetched_info* fi){
return &fbsd;
}
+static const distro_info*
+dragonfly_ncneofetch(fetched_info* fi){
+ static const distro_info dfly = {
+ .name = "DragonFly",
+ .logofile = NULL, // FIXME
+ };
+ fi->distro_pretty = NULL;
+ return &dfly;
+}
+
static int
drawpalette(struct ncdirect* nc){
int psize = ncdirect_palette_size(nc);
@@ -484,6 +497,9 @@ ncneofetch(struct ncdirect* nc){
case NCNEO_FREEBSD:
fi.distro = freebsd_ncneofetch(&fi);
break;
+ case NCNEO_DRAGONFLY:
+ fi.distro = dragonfly_ncneofetch(&fi);
+ break;
case NCNEO_UNKNOWN:
break;
} Moreover, compared to FreeBSD, notcurses still misses the DragonFly logo in Thank you. |
Thank YOU, both for this and for the fascinating DragonFly BSD! i'm really happy to be on it. I am happy to commit this myself, or if you'd like to get the credit, you can send a PR. It all goes in either way. Is there any copy of the DragonFly BSD logo on the local filesystem? If not, might I recommend you:
I just don't want to end up carrying around logos from a bunch of projects, and having to consider licensing, and keeping them up to date, and all that stuff. since you seem to be exploring the project thoroughly, might i ask whether |
Cool. I'll explore your suggestions more and open a PR in tomorrow. With UTF-8 disabled, this is result of
With UTF-8 enabled, the above test stucks in the following phase (and uses 100% CPU...):
By the way, the demos are awesome and render notcurses really appealing 😄 I'll try |
btw, i only now hooked up the neofetch-style logos; they weren't
|
with the logo you provide, we get the rather appealing i'm also going to add code to alright, i'm gonna go ahead and set up a DragonFly BSD VM to work on the problems you identified above -- thanks a lot for running that test! i still think it's probably worth going ahead and making the DPort available, but that's your call. 2.1.5 might get released without |
Great! Thank you for the work. Actually, I'm testing notcurse in a VirtualBox VM on Linux (ofc I have a DFly desktop 😄) I recommend you use the snapshot image (i.e., DragonFly 5.9-DEVELOPMENT) to create the VM. It takes a bit effort to build notcurses on DFly. So currently, I cloned the dports sources and copy the --- Makefile 2021-01-12 07:23:38.530843000 +0800
+++ Makefile.orig 2021-01-12 11:17:42.623815000 +0800
@@ -2,7 +2,7 @@
PORTNAME= notcurses
DISTVERSIONPREFIX= v
-PORTVERSION= ${ABIVERSION}.1.4
+DISTVERSION= ${ABIVERSION}.1.4
CATEGORIES= devel
MAINTAINER= nickblack@linux.com
@@ -18,7 +18,6 @@
USES= cmake:noninja compiler:c++17-lang localbase ncurses:port pkgconfig
USE_GITHUB= yes
GH_ACCOUNT= dankamongmen
-GH_TAGNAME= ee3dc54
USE_LDCONFIG= yes
CONFIGURE_ENV+= PKGCONFIG_DIR=${LOCALBASE}/libdata/pkgconfig
@@ -27,7 +26,7 @@
TEST_TARGET= test
-PLIST_SUB= REL_VER=${ABIVERSION}.1.4 ABI_VER=${ABIVERSION}
+PLIST_SUB= REL_VER=${DISTVERSION} ABI_VER=${ABIVERSION}
PORTDOCS= *.md
OPTIONS_DEFINE= DOCS MANPAGES
--- /dev/null 2021-01-12 11:16:55.828081000 +0800
+++ Makefile.DragonFly 2021-01-11 17:14:31.710120000 +0800
@@ -0,0 +1 @@
+USE_GCC_VERSION= 9 I'll also try to manually build notcurses later and report to you. (I tried direct cmake yesterday but failed to find |
i think i'm misunderstanding something, then -- i thought you were able to build the port? uniwbrk.h is from libunistring (devel/libunistring). |
Yes, I'm able to build the Well, I just tried cmake again and it works now (one difference is that I was using GCC 8.3 in base):
And it builds fine :D So never mind ;) |
|
2.1.5 has been released. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252704 updates FreeBSD Ports to 2.1.5. |
Great work! By the way, I'm adding the |
Hi @dankamongmen , I've gotten |
Uhoh, I'll presumably need to disable our implementation when it's present, then, or else we'll get redefinition errors. |
We can use |
you're a beautiful human being |
We're failing in DPorts, last tested on 1.6.6: DragonFlyBSD/DeltaPorts#995
Apparently, we need work around a missing
clock_nanosleep()
at a minimum.The text was updated successfully, but these errors were encountered: