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.
Fork of mbed-dev by
platform/mbed_poll.h@178:79309dc6340a, 2017-11-23 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 23 11:57:25 2017 +0000
- Revision:
- 178:79309dc6340a
- Parent:
- 167:e84263d55307
mbed-dev library. Release version 156
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 167:e84263d55307 | 1 | /* mbed Microcontroller Library |
AnnaBridge | 167:e84263d55307 | 2 | * Copyright (c) 2017 ARM Limited |
AnnaBridge | 167:e84263d55307 | 3 | * |
AnnaBridge | 167:e84263d55307 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
AnnaBridge | 167:e84263d55307 | 5 | * you may not use this file except in compliance with the License. |
AnnaBridge | 167:e84263d55307 | 6 | * You may obtain a copy of the License at |
AnnaBridge | 167:e84263d55307 | 7 | * |
AnnaBridge | 167:e84263d55307 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
AnnaBridge | 167:e84263d55307 | 9 | * |
AnnaBridge | 167:e84263d55307 | 10 | * Unless required by applicable law or agreed to in writing, software |
AnnaBridge | 167:e84263d55307 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AnnaBridge | 167:e84263d55307 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AnnaBridge | 167:e84263d55307 | 13 | * See the License for the specific language governing permissions and |
AnnaBridge | 167:e84263d55307 | 14 | * limitations under the License. |
AnnaBridge | 167:e84263d55307 | 15 | */ |
AnnaBridge | 167:e84263d55307 | 16 | #ifndef MBED_POLL_H |
AnnaBridge | 167:e84263d55307 | 17 | #define MBED_POLL_H |
AnnaBridge | 167:e84263d55307 | 18 | |
AnnaBridge | 167:e84263d55307 | 19 | #define POLLIN 0x0001 ///< Data may be read without blocking |
AnnaBridge | 167:e84263d55307 | 20 | #define POLLOUT 0x0010 ///< Data may be written without blocking |
AnnaBridge | 167:e84263d55307 | 21 | #define POLLERR 0x1000 ///< An error has occurred on the device or stream |
AnnaBridge | 167:e84263d55307 | 22 | #define POLLHUP 0x2000 ///< The device has been disconnected |
AnnaBridge | 167:e84263d55307 | 23 | #define POLLNVAL 0x4000 ///< The specified file handle value is invalid |
AnnaBridge | 167:e84263d55307 | 24 | |
AnnaBridge | 167:e84263d55307 | 25 | namespace mbed { |
AnnaBridge | 167:e84263d55307 | 26 | |
AnnaBridge | 167:e84263d55307 | 27 | class FileHandle; |
AnnaBridge | 167:e84263d55307 | 28 | |
AnnaBridge | 167:e84263d55307 | 29 | /** \addtogroup platform */ |
AnnaBridge | 178:79309dc6340a | 30 | /** @{*/ |
AnnaBridge | 178:79309dc6340a | 31 | /** |
AnnaBridge | 178:79309dc6340a | 32 | * \defgroup platform_poll poll functions |
AnnaBridge | 178:79309dc6340a | 33 | * @{ |
AnnaBridge | 178:79309dc6340a | 34 | */ |
AnnaBridge | 167:e84263d55307 | 35 | |
AnnaBridge | 167:e84263d55307 | 36 | struct pollfh { |
AnnaBridge | 167:e84263d55307 | 37 | FileHandle *fh; |
AnnaBridge | 167:e84263d55307 | 38 | short events; |
AnnaBridge | 167:e84263d55307 | 39 | short revents; |
AnnaBridge | 167:e84263d55307 | 40 | }; |
AnnaBridge | 167:e84263d55307 | 41 | |
AnnaBridge | 167:e84263d55307 | 42 | /** A mechanism to multiplex input/output over a set of file handles(file descriptors). |
AnnaBridge | 167:e84263d55307 | 43 | * For every file handle provided, poll() examines it for any events registered for that particular |
AnnaBridge | 167:e84263d55307 | 44 | * file handle. |
AnnaBridge | 167:e84263d55307 | 45 | * |
AnnaBridge | 167:e84263d55307 | 46 | * @param fhs an array of PollFh struct carrying a FileHandle and bitmasks of events |
AnnaBridge | 167:e84263d55307 | 47 | * @param nfhs number of file handles |
AnnaBridge | 167:e84263d55307 | 48 | * @param timeout timer value to timeout or -1 for loop forever |
AnnaBridge | 167:e84263d55307 | 49 | * |
AnnaBridge | 167:e84263d55307 | 50 | * @return number of file handles selected (for which revents is non-zero). 0 if timed out with nothing selected. -1 for error. |
AnnaBridge | 167:e84263d55307 | 51 | */ |
AnnaBridge | 167:e84263d55307 | 52 | int poll(pollfh fhs[], unsigned nfhs, int timeout); |
AnnaBridge | 167:e84263d55307 | 53 | |
AnnaBridge | 178:79309dc6340a | 54 | /**@}*/ |
AnnaBridge | 178:79309dc6340a | 55 | |
AnnaBridge | 178:79309dc6340a | 56 | /**@}*/ |
AnnaBridge | 178:79309dc6340a | 57 | |
AnnaBridge | 167:e84263d55307 | 58 | } // namespace mbed |
AnnaBridge | 167:e84263d55307 | 59 | |
AnnaBridge | 167:e84263d55307 | 60 | #endif //MBED_POLL_H |