Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2018 17:20:31 +0000
From:      bugzilla-noreply@freebsd.org
To:        gnome@FreeBSD.org
Subject:   maintainer-approval requested: [Bug 214338] [PATCH] devel/glib20: new kqueue() backend for file monitoring : [Attachment 195649] Proposed patch (since 475857 revision)
Message-ID:  <bug-214338-6497-Id822onHuR@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-214338-6497@https.bugs.freebsd.org/bugzilla/>
References:  <bug-214338-6497@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
lightside <lightside@gmx.com> has asked freebsd-gnome mailing list
<gnome@FreeBSD.org> for maintainer-approval:
Bug 214338: [PATCH] devel/glib20: new kqueue() backend for file monitoring
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D214338

Attachment 195649: Proposed patch (since 475857 revision)
https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D195649&action=3Dedit



--- Comment #56 from lightside <lightside@gmx.com> ---
Created attachment 195649
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D195649&action=
=3Dedit
Proposed patch (since 475857 revision)

Fixed MSTOSBT macro for files/kqueue_fnm.c.

Test case:
-8<--
/* `cc -O2 -o test test.c` or `cc -O2 -DFIXED=3D1 -o test test.c`
 * ./test && echo ok || echo not ok
 * ./test > test.txt
 * cat test.txt | grep true
 * cat test.txt | grep false
 */
#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>

#ifndef FIXED
#define MSTOSBT(__ms)		((sbintime_t)((((int64_t)(__ms)) *
(int64_t)(((uint64_t)1 << 63) / 500) >> 32)))
#else
#define MSTOSBT(__ms)		(sbintime_t)(((int64_t)__ms * (((uint64_t)1 <<
63) / 500)) >> 32)
#endif

#if defined(__FreeBSD_version) && (__FreeBSD_version < 1200040)
/* https://svnweb.freebsd.org/base?view=3Drevision&revision=3D321686
 *
https://svnweb.freebsd.org/base/head/sys/sys/time.h?view=3Dmarkup&pathrev=
=3D321686#
l198
 */
static __inline sbintime_t
mstosbt(int64_t _ms)
{
	return ((_ms * (((uint64_t)1 << 63) / 500)) >> 32);
}
#endif

int main()
{
	sbintime_t funct, macro;
	int match, result =3D 0;

	for (int64_t i =3D 0; i < 1000; ++i) {
		funct =3D mstosbt(i);
		macro =3D MSTOSBT(i);
		match =3D (funct =3D=3D macro) ? 1 : 0;
		printf("%ld: funct =3D %ld, macro =3D %ld, %s\n", i, funct, macro,
match ? "true" : "false");
		if ((result =3D=3D 0) && (match =3D=3D 0))
			result =3D 1;
	}

	return result;
}

-->8-

% cc -O2 -o test test.c
% ./test && echo ok || echo not ok
<..>
997: funct =3D 4282082394, macro =3D -12884902, false
998: funct =3D 4286377361, macro =3D -8589935, false
999: funct =3D 4290672328, macro =3D -4294968, false
not ok
% ./test | grep true | head -5
0: funct =3D 0, macro =3D 0, true
1: funct =3D 4294967, macro =3D 4294967, true
2: funct =3D 8589934, macro =3D 8589934, true
3: funct =3D 12884901, macro =3D 12884901, true
4: funct =3D 17179869, macro =3D 17179869, true
% ./test | grep false | head -5
501: funct =3D 2151778615, macro =3D -2143188681, false
502: funct =3D 2156073582, macro =3D -2138893714, false
503: funct =3D 2160368549, macro =3D -2134598747, false
504: funct =3D 2164663517, macro =3D -2130303779, false
505: funct =3D 2168958484, macro =3D -2126008812, false
% cc -O2 -DFIXED=3D1 -o test_fixed test.c
% ./test_fixed && echo ok || echo not ok
<..>
997: funct =3D 4282082394, macro =3D 4282082394, true
998: funct =3D 4286377361, macro =3D 4286377361, true
999: funct =3D 4290672328, macro =3D 4290672328, true
ok



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-214338-6497-Id822onHuR>