Skip to content

Linux fixes for dispatch-806 merge #216

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

Conversation

dgrove-oss
Copy link
Contributor

Collection of small fixes to dispatch-806 merge to
allow code to compile/link/run on Linux.

#else
// TODO: Need to write a real check for epoll-backend here
return true;
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not intending this as the final fix for this code; just an expedient hack to allow the merge to proceed.

@@ -194,7 +202,7 @@ _dispatch_unote_register(dispatch_unote_t du, dispatch_priority_t pri)
case DISPATCH_EVFILT_CUSTOM_ADD:
case DISPATCH_EVFILT_CUSTOM_OR:
case DISPATCH_EVFILT_CUSTOM_REPLACE:
du._du->du_wlh = DISPATCH_WLH_GLOBAL;
du._du->du_wlh = wlh;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this diff is wrong, it should always use DISPATCH_WLH_GLOBAL

Copy link
Contributor Author

@dgrove-oss dgrove-oss Feb 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok; I think I should then add an assert that the value of the wlh parameter is DISPATCH_WLH_GLOBAL. I don't like ignoring the value the caller passed in without asserting it has a known value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it needs to be GLOBAL here, event_kevent.c does the same. it is meant to be that.

Copy link
Contributor Author

@dgrove-oss dgrove-oss Feb 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we're looking at different pieces of code. In event_kevent.c, I think the matching piece of code is:

bool
_dispatch_unote_register(dispatch_unote_t du, dispatch_wlh_t wlh,
		dispatch_priority_t pri)
{
	dispatch_assert(!_dispatch_unote_registered(du));
	du._du->du_priority = pri;
	switch (du._du->du_filter) {
	case DISPATCH_EVFILT_CUSTOM_ADD:
	case DISPATCH_EVFILT_CUSTOM_OR:
	case DISPATCH_EVFILT_CUSTOM_REPLACE:
		du._du->du_wlh = wlh;
		return true;
	}
	if (!du._du->du_is_direct) {
		return _dispatch_unote_register_muxed(du, DISPATCH_WLH_GLOBAL);
	}
	return _dispatch_kq_unote_update(wlh, du, EV_ADD | EV_ENABLE);
}
```
``

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, event_kevent.c also sets it to 'wlh'. I think these are arguably both wrong and should both be the GLOBAL constant (but it also doesn't really matter for this 'synthetic event' case)

@MadCoder
Copy link
Contributor

everything makes perfect sense to me but for the commented hunk.

@@ -133,7 +133,7 @@
# define EV_ONESHOT 0x0010
# define EV_CLEAR 0x0020
# define EV_DISPATCH 0x0080
# define EV_UDATA_SPECIFIC 0x0100
# define EV_UDATA_SPECIFIC 0x0000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this really be defined at all ? I would have thought the #ifdef EV_UDATA_SPECIFIC below would have done the right thing if it is not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recollection is that @MadCoder preferred us to define it as 0x0000 instead of leaving it undefined. I believe it is a matter of style; I think either leaving it undefined or defining it to be 0x0000 accomplish the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the conditional below defines it to 0x0000 already, that is what I am talking about

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e.

#ifdef EV_UDATA_SPECIFIC
#	define DISPATCH_EV_DIRECT		(EV_UDATA_SPECIFIC|EV_DISPATCH)
#else
#	define DISPATCH_EV_DIRECT		0x0000
#	define EV_UDATA_SPECIFIC		0x0000
#	undef  EV_VANISHED
#	define EV_VANISHED				0x0000
#endif

that is there exactly for the cases where EV_UDATA_SPECIFIC isn't present (in both cases of backend, we also support the absence of this flag with kevent)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and in particular doing it that way will also cause EV_VANISHED to be 0x0000 on Linux. currently it is 0x0200 via the #define at the top of the file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. makes sense.

I changed to not define EV_UDATA_SPECIFIC on Linux and squashed/rebased.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, lgtm, thanks!

@das das dismissed MadCoder’s stale review February 22, 2017 03:19

let's not worry about this inconsistency for this review, matching event_kevent.c seems fine

Collection of small fixes to dispatch-806 merge to
allow code to compile/link/run on Linux.
@dgrove-oss dgrove-oss force-pushed the das-darwin-libdispatch-806-merge-master-linux-fixes branch from 69bcf03 to 7b4281e Compare February 22, 2017 03:27
@MadCoder
Copy link
Contributor

Indeed, seems I misremembered, this is fine :)

@das das merged commit ff05109 into swiftlang:das-darwin-libdispatch-806-merge-master Feb 22, 2017
@dgrove-oss dgrove-oss deleted the das-darwin-libdispatch-806-merge-master-linux-fixes branch February 24, 2017 16:08
das added a commit that referenced this pull request May 25, 2017
…rge-master-linux-fixes

Linux fixes for dispatch-806 merge

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants