diff --git a/extmod/moduselect.c b/extmod/moduselect.c index c8f5e57363..5744d2839c 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -9,7 +9,7 @@ #include -#include "py/ioctl.h" +#include "py/stream.h" #include "py/runtime.h" #include "py/obj.h" #include "py/objlist.h" diff --git a/py/ioctl.h b/py/ioctl.h deleted file mode 100644 index 8c84835cc1..0000000000 --- a/py/ioctl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * SPDX-FileCopyrightText: Copyright (c) 2013-2015 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_PY_IOCTL_H -#define MICROPY_INCLUDED_PY_IOCTL_H - -#define MP_IOCTL_POLL (0x100 | 1) - -// These values are compatible with Linux, which are in turn -// compatible with iBCS2 spec. -#define MP_IOCTL_POLL_RD (0x0001) -#define MP_IOCTL_POLL_WR (0x0004) -#define MP_IOCTL_POLL_ERR (0x0008) -#define MP_IOCTL_POLL_HUP (0x0010) - -#endif // MICROPY_INCLUDED_PY_IOCTL_H diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 9b44114a99..12853b3ac3 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -25,7 +25,7 @@ */ #include "py/mperrno.h" -#include "py/ioctl.h" +#include "py/stream.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" @@ -138,15 +138,15 @@ STATIC mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r check_for_deinit(self); raise_error_if_not_connected(self); mp_uint_t ret; - if (request == MP_IOCTL_POLL) { + if (request == MP_STREAM_POLL) { mp_uint_t flags = arg; ret = 0; - if ((flags & MP_IOCTL_POLL_RD) && common_hal_bleio_characteristic_buffer_rx_characters_available(self) > 0) { - ret |= MP_IOCTL_POLL_RD; + if ((flags & MP_STREAM_POLL_RD) && common_hal_bleio_characteristic_buffer_rx_characters_available(self) > 0) { + ret |= MP_STREAM_POLL_RD; } // No writing provided. -// if ((flags & MP_IOCTL_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) { -// ret |= MP_IOCTL_POLL_WR; +// if ((flags & MP_STREAM_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) { +// ret |= MP_STREAM_POLL_WR; // } } else { *errcode = MP_EINVAL; diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index 8c6b017c9c..0ce74beff4 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -25,7 +25,7 @@ */ #include "py/mperrno.h" -#include "py/ioctl.h" +#include "py/stream.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index a65984c3fb..5663254897 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -33,7 +33,7 @@ #include "shared/runtime/context_manager_helpers.h" #include "shared/runtime/interrupt_char.h" -#include "py/ioctl.h" +#include "py/stream.h" #include "py/objproperty.h" #include "py/objtype.h" #include "py/runtime.h" @@ -276,14 +276,14 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t busio_uart_obj_t *self = native_uart(self_in); check_for_deinit(self); mp_uint_t ret; - if (request == MP_IOCTL_POLL) { + if (request == MP_STREAM_POLL) { mp_uint_t flags = arg; ret = 0; - if ((flags & MP_IOCTL_POLL_RD) && common_hal_busio_uart_rx_characters_available(self) > 0) { - ret |= MP_IOCTL_POLL_RD; + if ((flags & MP_STREAM_POLL_RD) && common_hal_busio_uart_rx_characters_available(self) > 0) { + ret |= MP_STREAM_POLL_RD; } - if ((flags & MP_IOCTL_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) { - ret |= MP_IOCTL_POLL_WR; + if ((flags & MP_STREAM_POLL_WR) && common_hal_busio_uart_ready_to_tx(self)) { + ret |= MP_STREAM_POLL_WR; } } else { *errcode = MP_EINVAL; diff --git a/shared-bindings/keypad/EventQueue.c b/shared-bindings/keypad/EventQueue.c index 615c051188..d09d5db129 100644 --- a/shared-bindings/keypad/EventQueue.c +++ b/shared-bindings/keypad/EventQueue.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "py/ioctl.h" +#include "py/stream.h" #include "py/mperrno.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -147,8 +147,8 @@ STATIC mp_uint_t eventqueue_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t case MP_STREAM_POLL: { mp_uint_t flags = arg; mp_uint_t ret = 0; - if ((flags & MP_IOCTL_POLL_RD) && common_hal_keypad_eventqueue_get_length(self)) { - ret |= MP_IOCTL_POLL_RD; + if ((flags & MP_STREAM_POLL_RD) && common_hal_keypad_eventqueue_get_length(self)) { + ret |= MP_STREAM_POLL_RD; } return ret; } diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index a666a79461..2dfe29035e 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -29,7 +29,7 @@ #include "shared-bindings/terminalio/Terminal.h" #include "shared-bindings/util.h" -#include "py/ioctl.h" +#include "py/stream.h" #include "py/objproperty.h" #include "py/objstr.h" #include "py/runtime.h" @@ -111,11 +111,11 @@ STATIC mp_uint_t terminalio_terminal_write(mp_obj_t self_in, const void *buf_in, STATIC mp_uint_t terminalio_terminal_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) { terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_uint_t ret; - if (request == MP_IOCTL_POLL) { + if (request == MP_STREAM_POLL) { mp_uint_t flags = arg; ret = 0; - if ((flags & MP_IOCTL_POLL_WR) && common_hal_terminalio_terminal_ready_to_tx(self)) { - ret |= MP_IOCTL_POLL_WR; + if ((flags & MP_STREAM_POLL_WR) && common_hal_terminalio_terminal_ready_to_tx(self)) { + ret |= MP_STREAM_POLL_WR; } } else { *errcode = MP_EINVAL; diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index df96debe7f..9fe6cafd5f 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -29,7 +29,7 @@ #include "shared-bindings/usb_cdc/Serial.h" #include "shared-bindings/util.h" -#include "py/ioctl.h" +#include "py/stream.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" @@ -114,14 +114,14 @@ STATIC mp_uint_t usb_cdc_serial_ioctl_stream(mp_obj_t self_in, mp_uint_t request usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_uint_t ret = 0; switch (request) { - case MP_IOCTL_POLL: { + case MP_STREAM_POLL: { mp_uint_t flags = arg; ret = 0; - if ((flags & MP_IOCTL_POLL_RD) && common_hal_usb_cdc_serial_get_in_waiting(self) > 0) { - ret |= MP_IOCTL_POLL_RD; + if ((flags & MP_STREAM_POLL_RD) && common_hal_usb_cdc_serial_get_in_waiting(self) > 0) { + ret |= MP_STREAM_POLL_RD; } - if ((flags & MP_IOCTL_POLL_WR) && common_hal_usb_cdc_serial_get_out_waiting(self) == 0) { - ret |= MP_IOCTL_POLL_WR; + if ((flags & MP_STREAM_POLL_WR) && common_hal_usb_cdc_serial_get_out_waiting(self) == 0) { + ret |= MP_STREAM_POLL_WR; } break; } diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index b63843e8dd..ca07c8695a 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -29,7 +29,7 @@ #include "shared-bindings/usb_midi/PortIn.h" #include "shared-bindings/util.h" -#include "py/ioctl.h" +#include "py/stream.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" @@ -81,11 +81,11 @@ STATIC mp_uint_t usb_midi_portin_read(mp_obj_t self_in, void *buf_in, mp_uint_t STATIC mp_uint_t usb_midi_portin_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) { usb_midi_portin_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_uint_t ret; - if (request == MP_IOCTL_POLL) { + if (request == MP_STREAM_POLL) { mp_uint_t flags = arg; ret = 0; - if ((flags & MP_IOCTL_POLL_RD) && common_hal_usb_midi_portin_bytes_available(self) > 0) { - ret |= MP_IOCTL_POLL_RD; + if ((flags & MP_STREAM_POLL_RD) && common_hal_usb_midi_portin_bytes_available(self) > 0) { + ret |= MP_STREAM_POLL_RD; } } else { *errcode = MP_EINVAL; diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index 5888045b79..f1f61f948a 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -29,7 +29,7 @@ #include "shared-bindings/usb_midi/PortOut.h" #include "shared-bindings/util.h" -#include "py/ioctl.h" +#include "py/stream.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" @@ -64,11 +64,11 @@ STATIC mp_uint_t usb_midi_portout_write(mp_obj_t self_in, const void *buf_in, mp STATIC mp_uint_t usb_midi_portout_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) { usb_midi_portout_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_uint_t ret; - if (request == MP_IOCTL_POLL) { + if (request == MP_STREAM_POLL) { mp_uint_t flags = arg; ret = 0; - if ((flags & MP_IOCTL_POLL_WR) && common_hal_usb_midi_portout_ready_to_tx(self)) { - ret |= MP_IOCTL_POLL_WR; + if ((flags & MP_STREAM_POLL_WR) && common_hal_usb_midi_portout_ready_to_tx(self)) { + ret |= MP_STREAM_POLL_WR; } } else { *errcode = MP_EINVAL;