Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
platform/mbed_poll.h@2:4364577b5ad8, 2020-11-09 (annotated)
- Committer:
- elijahsj
- Date:
- Mon Nov 09 00:33:19 2020 -0500
- Revision:
- 2:4364577b5ad8
- Parent:
- 1:8a094db1347f
copied mbed library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| elijahsj | 1:8a094db1347f | 1 | /* mbed Microcontroller Library |
| elijahsj | 1:8a094db1347f | 2 | * Copyright (c) 2017 ARM Limited |
| elijahsj | 1:8a094db1347f | 3 | * |
| elijahsj | 1:8a094db1347f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| elijahsj | 1:8a094db1347f | 5 | * you may not use this file except in compliance with the License. |
| elijahsj | 1:8a094db1347f | 6 | * You may obtain a copy of the License at |
| elijahsj | 1:8a094db1347f | 7 | * |
| elijahsj | 1:8a094db1347f | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| elijahsj | 1:8a094db1347f | 9 | * |
| elijahsj | 1:8a094db1347f | 10 | * Unless required by applicable law or agreed to in writing, software |
| elijahsj | 1:8a094db1347f | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| elijahsj | 1:8a094db1347f | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| elijahsj | 1:8a094db1347f | 13 | * See the License for the specific language governing permissions and |
| elijahsj | 1:8a094db1347f | 14 | * limitations under the License. |
| elijahsj | 1:8a094db1347f | 15 | */ |
| elijahsj | 1:8a094db1347f | 16 | #ifndef MBED_POLL_H |
| elijahsj | 1:8a094db1347f | 17 | #define MBED_POLL_H |
| elijahsj | 1:8a094db1347f | 18 | |
| elijahsj | 1:8a094db1347f | 19 | #define POLLIN 0x0001 ///< Data may be read without blocking |
| elijahsj | 1:8a094db1347f | 20 | #define POLLOUT 0x0010 ///< Data may be written without blocking |
| elijahsj | 1:8a094db1347f | 21 | #define POLLERR 0x1000 ///< An error has occurred on the device or stream |
| elijahsj | 1:8a094db1347f | 22 | #define POLLHUP 0x2000 ///< The device has been disconnected |
| elijahsj | 1:8a094db1347f | 23 | #define POLLNVAL 0x4000 ///< The specified file handle value is invalid |
| elijahsj | 1:8a094db1347f | 24 | |
| elijahsj | 1:8a094db1347f | 25 | namespace mbed { |
| elijahsj | 1:8a094db1347f | 26 | |
| elijahsj | 1:8a094db1347f | 27 | class FileHandle; |
| elijahsj | 1:8a094db1347f | 28 | |
| elijahsj | 1:8a094db1347f | 29 | /** \addtogroup platform */ |
| elijahsj | 1:8a094db1347f | 30 | |
| elijahsj | 1:8a094db1347f | 31 | |
| elijahsj | 1:8a094db1347f | 32 | struct pollfh { |
| elijahsj | 1:8a094db1347f | 33 | FileHandle *fh; |
| elijahsj | 1:8a094db1347f | 34 | short events; |
| elijahsj | 1:8a094db1347f | 35 | short revents; |
| elijahsj | 1:8a094db1347f | 36 | }; |
| elijahsj | 1:8a094db1347f | 37 | |
| elijahsj | 1:8a094db1347f | 38 | /** A mechanism to multiplex input/output over a set of file handles(file descriptors). |
| elijahsj | 1:8a094db1347f | 39 | * For every file handle provided, poll() examines it for any events registered for that particular |
| elijahsj | 1:8a094db1347f | 40 | * file handle. |
| elijahsj | 1:8a094db1347f | 41 | * |
| elijahsj | 1:8a094db1347f | 42 | * @param fhs an array of PollFh struct carrying a FileHandle and bitmasks of events |
| elijahsj | 1:8a094db1347f | 43 | * @param nfhs number of file handles |
| elijahsj | 1:8a094db1347f | 44 | * @param timeout timer value to timeout or -1 for loop forever |
| elijahsj | 1:8a094db1347f | 45 | * |
| elijahsj | 1:8a094db1347f | 46 | * @return number of file handles selected (for which revents is non-zero). 0 if timed out with nothing selected. -1 for error. |
| elijahsj | 1:8a094db1347f | 47 | */ |
| elijahsj | 1:8a094db1347f | 48 | int poll(pollfh fhs[], unsigned nfhs, int timeout); |
| elijahsj | 1:8a094db1347f | 49 | |
| elijahsj | 1:8a094db1347f | 50 | } // namespace mbed |
| elijahsj | 1:8a094db1347f | 51 | |
| elijahsj | 1:8a094db1347f | 52 | #endif //MBED_POLL_H |