~kennylevinsen/wlsunset-devel

main.c: define timezone to tm.tm_gmtoff on FreeBSD v1 APPLIED

Evgeniy Khramtsov: 2
 main.c: define timezone to tm.tm_gmtoff on FreeBSD
 main.c: define timezone to tm.tm_gmtoff on FreeBSD

 2 files changed, 10 insertions(+), 1 deletions(-)
Applied, thanks!
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/~kennylevinsen/wlsunset-devel/patches/26904/mbox | git am -3
Learn more about email & git

[PATCH] main.c: define timezone to tm.tm_gmtoff on FreeBSD Export this patch

FreeBSD has BSD extension timezone, which conflicts with XSI extension
with the same name, according to time.h:

char *timezone(int, int);	/* XXX XSI conflict */
...

FreeBSD also has long tm_gmtoff member of struct tm, which is offset
from UTC in seconds, according to time.h:

struct tm {
...
long    tm_gmtoff;	/* offset from UTC in seconds */
char	*tm_zone;	/* timezone abbreviation */
}

which is the same as XSI extension timezone.

Co-authored-by: Jan Beich <jbeich@FreeBSD.org> (downstream patch)
---
 main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/main.c b/main.c
index 1042d17..4319745 100644
--- a/main.c
+++ b/main.c
@@ -17,6 +17,10 @@
#include "wlr-gamma-control-unstable-v1-client-protocol.h"
#include "color_math.h"

#if defined(__FreeBSD__)
#define timezone tm.tm_gmtoff
#endif

#if defined(SPEEDRUN)
static time_t start = 0, offset = 0, multiplier = 1000;
static void init_time(void) {
-- 
2.34.1

[PATCH] main.c: define timezone to tm.tm_gmtoff on FreeBSD Export this patch

FreeBSD has BSD extension timezone, which conflicts with XSI extension
with the same name, according to time.h:

char *timezone(int, int);	/* XXX XSI conflict */
...

FreeBSD also has long tm_gmtoff member of struct tm, which is offset
from UTC in seconds, according to time.h:

struct tm {
...
long    tm_gmtoff;	/* offset from UTC in seconds */
char	*tm_zone;	/* timezone abbreviation */
}

which is the same as XSI extension timezone.

Co-authored-by: Jan Beich <jbeich@FreeBSD.org> (downstream patch)
Reviewed by: Kenny Levinsen <kl@kl.wtf>
---
 main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 1042d17..38e0faa 100644
--- a/main.c
+++ b/main.c
@@ -707,7 +707,12 @@ static int parse_time_of_day(const char *s, time_t *time) {
	if (strptime(s, "%H:%M", &tm) == NULL) {
		return -1;
	}
	*time = tm.tm_hour * 3600 + tm.tm_min * 60 + timezone;
	*time = tm.tm_hour * 3600 + tm.tm_min * 60;
#if defined(__FreeBSD__)
	*time += tm.tm_gmtoff;
#else
	*time += timezone;
#endif
	return 0;
}

-- 
2.34.1
Applied, thanks!