From c3162f373fbd6bacae946f717f41e271ffbe0835 Mon Sep 17 00:00:00 2001 From: "Man, Jianting (Meco)" <920369182@qq.com> Date: Sun, 16 Jan 2022 22:21:39 -0500 Subject: [PATCH] =?UTF-8?q?[libc][lwip]=20=E4=BF=AE=E5=A4=8Dioctl=E4=B8=8E?= =?UTF-8?q?lwip=20socket=E5=AE=9A=E4=B9=89=E5=86=B2=E7=AA=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#5504)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [lwip] 修复ioctl与lwip socket定义冲突的问题 * format sys/ioctl.h --- components/libc/compilers/common/sys/ioctl.h | 76 ++++++++++++++------ components/net/lwip-1.4.1/src/lwipopts.h | 1 + components/net/lwip-2.0.2/src/lwipopts.h | 1 + components/net/lwip-2.0.3/src/lwipopts.h | 1 + components/net/lwip-2.1.2/src/lwipopts.h | 1 + 5 files changed, 58 insertions(+), 22 deletions(-) diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h index c663025c1f..0b1edca699 100644 --- a/components/libc/compilers/common/sys/ioctl.h +++ b/components/libc/compilers/common/sys/ioctl.h @@ -11,34 +11,79 @@ #ifndef __SYS_IOCTL_H__ #define __SYS_IOCTL_H__ -#include - #ifdef _WIN32 #include #endif -struct winsize { +struct winsize +{ unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; unsigned short ws_ypixel; }; -#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) ) +/* + * Direction bits, which any architecture can choose to override + * before including this file. + */ + +#ifndef _IOC_NONE #define _IOC_NONE 0U +#endif + +#ifndef _IOC_WRITE #define _IOC_WRITE 1U +#endif + +#ifndef _IOC_READ #define _IOC_READ 2U +#endif -#if !defined (_WIN32) && !defined (__TASKING__) -#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0) -#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c)) -#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c)) -#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c)) +#ifndef _IOC +#define _IOC(a,b,c,d) (((a)<<30) | ((b)<<8) | (c) | ((d)<<16)) +#endif +#ifndef _IO +#define _IO(a,b) _IOC(_IOC_NONE, (a), (b), 0) +#endif + +#ifndef _IOW +#define _IOW(a,b,c) _IOC(_IOC_WRITE, (a), (b), sizeof(c)) +#endif + +#ifndef _IOR +#define _IOR(a,b,c) _IOC(_IOC_READ, (a), (b), sizeof(c)) +#endif + +#ifndef _IOWR +#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE, (a), (b), sizeof(c)) +#endif + +#ifndef FIONREAD #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ +#endif + +#ifndef FIONBIO #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ #endif + +#ifndef FIOASYNC +#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ +#endif + +#ifndef FIONWRITE #define FIONWRITE _IOR('f', 121, int) /* get # bytes outstanding in send queue */ +#endif + +/* Socket I/O Controls */ +#ifndef SIOCSHIWAT +#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ +#endif #define TCGETS 0x5401 #define TCSETS 0x5402 @@ -66,18 +111,12 @@ struct winsize { #define TIOCMSET 0x5418 #define TIOCGSOFTCAR 0x5419 #define TIOCSSOFTCAR 0x541A -#ifndef FIONREAD -#define FIONREAD 0x541B -#endif #define TIOCINQ FIONREAD #define TIOCLINUX 0x541C #define TIOCCONS 0x541D #define TIOCGSERIAL 0x541E #define TIOCSSERIAL 0x541F #define TIOCPKT 0x5420 -#ifndef FIONBIO -#define FIONBIO 0x5421 -#endif #define TIOCNOTTY 0x5422 #define TIOCSETD 0x5423 #define TIOCGETD 0x5424 @@ -103,10 +142,6 @@ struct winsize { #define FIONCLEX 0x5450 #define FIOCLEX 0x5451 -#ifndef _WIN32 -#define FIOASYNC 0x5452 -#endif - #define TIOCSERCONFIG 0x5453 #define TIOCSERGWILD 0x5454 #define TIOCSERSWILD 0x5455 @@ -168,9 +203,6 @@ struct winsize { #define SIOCSPGRP 0x8902 #define FIOGETOWN 0x8903 #define SIOCGPGRP 0x8904 -#ifndef SIOCATMARK -#define SIOCATMARK 0x8905 -#endif #define SIOCGSTAMP 0x8906 #define SIOCGSTAMPNS 0x8907 diff --git a/components/net/lwip-1.4.1/src/lwipopts.h b/components/net/lwip-1.4.1/src/lwipopts.h index d7a6807cbd..03930c8741 100644 --- a/components/net/lwip-1.4.1/src/lwipopts.h +++ b/components/net/lwip-1.4.1/src/lwipopts.h @@ -526,6 +526,7 @@ #define LWIP_SOCKET 1 #endif #include +#include /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. diff --git a/components/net/lwip-2.0.2/src/lwipopts.h b/components/net/lwip-2.0.2/src/lwipopts.h index 5c99013d2e..2de6aa1052 100644 --- a/components/net/lwip-2.0.2/src/lwipopts.h +++ b/components/net/lwip-2.0.2/src/lwipopts.h @@ -565,6 +565,7 @@ #define LWIP_SOCKET 1 #endif #include +#include /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. diff --git a/components/net/lwip-2.0.3/src/lwipopts.h b/components/net/lwip-2.0.3/src/lwipopts.h index 5c99013d2e..2de6aa1052 100644 --- a/components/net/lwip-2.0.3/src/lwipopts.h +++ b/components/net/lwip-2.0.3/src/lwipopts.h @@ -565,6 +565,7 @@ #define LWIP_SOCKET 1 #endif #include +#include /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. diff --git a/components/net/lwip-2.1.2/src/lwipopts.h b/components/net/lwip-2.1.2/src/lwipopts.h index ca70de012a..701449c108 100644 --- a/components/net/lwip-2.1.2/src/lwipopts.h +++ b/components/net/lwip-2.1.2/src/lwipopts.h @@ -568,6 +568,7 @@ #define LWIP_SOCKET 1 #endif #include +#include /* * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names.