mbed-dev-f303

Committer:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4
Date:
Tue Jun 14 09:21:18 2022 +0000
Revision:
0:bdf663c61a82
lib

Who changed what in which revision?

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