maintainer-approval requested: [Bug 214338] [PATCH] devel/glib20: new kqueue() backend for file monitoring : [Attachment 195649] Proposed patch (since 475857 revision)

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Jul 30 17:20:35 UTC 2018


lightside <lightside at gmx.com> has asked freebsd-gnome mailing list
<gnome at 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=214338

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



--- Comment #56 from lightside <lightside at gmx.com> ---
Created attachment 195649
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=195649&action=edit
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=1 -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=revision&revision=321686
 *
https://svnweb.freebsd.org/base/head/sys/sys/time.h?view=markup&pathrev=321686#
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 = 0;

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

	return result;
}

-->8-

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


More information about the freebsd-gnome mailing list