~rabbits/public-inbox

uxn: Remove dependency on non-posix timerfd for *BSD and non-Linux systems v1 PROPOSED

On OpenBSD I was unable to compile the original source since the timerfd
stuff is Linux only.
I suggest to just use usleep(16666) in the main loop.

After the modify I was able to compile and run the emulator.

crossbower (1):
  src/uxn11.c: remove dependency on non-posix timerfd (just use usleep)

 src/uxn11.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

-- 
2.34.2
#766629 .build.yml failed
uxn/patches/.build.yml: FAILED in 55s

[Remove dependency on non-posix timerfd for *BSD and non-Linux systems][0] from [~crossbower][1]

[0]: https://lists.sr.ht/~rabbits/public-inbox/patches/32512
[1]: mailto:crossbower@tuta.io

✗ #766629 FAILED uxn/patches/.build.yml https://builds.sr.ht/~rabbits/job/766629
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rabbits/public-inbox/patches/32512/mbox | git am -3
Learn more about email & git

[PATCH uxn11 1/1] [PATCH uxn] src/uxn11.c: remove dependency on non-posix timerfd (just use usleep) Export this patch

From: crossbower <crossbower@gmail.com>

Signed-off-by: crossbower <crossbower@gmail.com>
---
 src/uxn11.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/uxn11.c b/src/uxn11.c
index e68300f..c690882 100644
--- a/src/uxn11.c
+++ b/src/uxn11.c
@@ -3,7 +3,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysymdef.h>
#include <sys/timerfd.h>
//#include <sys/timerfd.h>
#include <unistd.h>
#include <poll.h>

@@ -223,8 +223,7 @@ main(int argc, char **argv)
	Uxn u;
	int i;
	char expirations[8];
	struct pollfd fds[2];
	static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
	struct pollfd fds[1];
	if(argc < 2)
		return emu_error("Usage", "uxn11 game.rom args");
	/* start sequence */
@@ -241,19 +240,15 @@ main(int argc, char **argv)
	}
	/* timer */
	fds[0].fd = XConnectionNumber(display);
	fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
	timerfd_settime(fds[1].fd, 0, &screen_tspec, NULL);
	fds[0].events = fds[1].events = POLLIN;
	fds[0].events = POLLIN;
	/* main loop */
	while(1) {
		if(poll(fds, 2, 1000) <= 0)
		if(poll(fds, 1, 1000) <= 0)
			continue;
		while(XPending(display))
			emu_event(&u);
		if(poll(&fds[1], 1, 0)) {
			read(fds[1].fd, expirations, 8);    /* Indicate we handled the timer */
			uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
		}
		usleep(16666); // <--- INSTEAD OF TIMERFD
		uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
		if(uxn_screen.fg.changed || uxn_screen.bg.changed)
			emu_draw();
	}
-- 
2.34.2
uxn/patches/.build.yml: FAILED in 55s

[Remove dependency on non-posix timerfd for *BSD and non-Linux systems][0] from [~crossbower][1]

[0]: https://lists.sr.ht/~rabbits/public-inbox/patches/32512
[1]: mailto:crossbower@tuta.io

✗ #766629 FAILED uxn/patches/.build.yml https://builds.sr.ht/~rabbits/job/766629