Skip to content
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

[DNM] Pfalcon's addition to PR22863 #24613

Closed
wants to merge 2 commits into from

Conversation

pfalcon
Copy link
Contributor

@pfalcon pfalcon commented Apr 22, 2020

No description provided.

@pfalcon pfalcon added the DNM This PR should not be merged (Do Not Merge) label Apr 22, 2020
@zephyrbot zephyrbot added area: POSIX POSIX API Library area: native port Host native arch port (native_sim) area: API Changes to public APIs area: Samples Samples area: Tests Issues related to a particular existing or missing test labels Apr 22, 2020
@zephyrbot
Copy link
Collaborator

zephyrbot commented Apr 22, 2020

All checks are passing now.

checkpatch (informational only, not a failure)

-:468: WARNING:PREFER_KERNEL_TYPES: Prefer kernel type 'u64_t' over 'uint64_t'
#468: FILE: samples/posix/eventfd/src/main.c:28:
+	uint64_t u;

-:484: WARNING:PREFER_KERNEL_TYPES: Prefer kernel type 'u64_t' over 'uint64_t'
#484: FILE: samples/posix/eventfd/src/main.c:44:
+	uint64_t u;

-:501: WARNING:ARRAY_SIZE: Prefer ARRAY_SIZE(input_argv)
#501: FILE: samples/posix/eventfd/src/main.c:61:
+	argc = sizeof(input_argv) / sizeof(input_argv[0]);

- total: 0 errors, 3 warnings, 674 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

This implements a file descriptor used for event notification that
behaves like the eventfd in Linux.

The eventfd supports nonblocking operation by setting the EFD_NONBLOCK
flag and semaphore operation by settings the EFD_SEMAPHORE flag.

The major use case for this is when using poll() and the sockets that
you poll are dynamic. When a new socket needs to be added to the poll,
there must be some way to wake the thread and update the pollfds before
calling poll again. One way to solve it is to have a timeout set in the
poll call and only update the pollfds during a timeout but that is not
a very nice solution. By instead including an eventfd in the pollfds,
it is possible to wake the polling thread by simply writing to the
eventfd.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
Roughly based on eventfd example code from Linux manpages. Similarly
to other POSIX-compatible sample, Makefile.posix is provided to build
the code on a POSIX system (in this case, as eventfd() is
Linux-specific, this has to be a Linux system).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
@pfalcon
Copy link
Contributor Author

pfalcon commented Apr 22, 2020

Top commit of this PR is intended to be cherry-picked to #22863 . Closing otherwise (the underlying branch remains active.)

@pfalcon pfalcon closed this Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: native port Host native arch port (native_sim) area: POSIX POSIX API Library area: Samples Samples area: Tests Issues related to a particular existing or missing test DNM This PR should not be merged (Do Not Merge)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants