[FFmpeg-devel] os_support: define socket shutdown SHUT_xxx macros if they are not defined

Submitted by Peter Ross on Nov. 28, 2018, 11:03 a.m.

Details

Message ID 431404290a744dd63f8e133d28bbca3af7e81b80.1543402654.git.pross@xvid.org
State Accepted
Commit b41f378fc4ddb1a34aebe459805d3c8dbcc96b36
Headers show

Commit Message

Peter Ross Nov. 28, 2018, 11:03 a.m.
sys/socket.h (with WIN32 guard) is needed to check if the SHUT_xxx macro exists.
and because of this, SHUT_xxx defs have been moved into the CONFIG_NETWORK block,
since they only affect network capable platforms.
---

This is a minor reworking of Dave's suggestion to make it work on *nix and windows.


 libavformat/os_support.h | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Comments

Peter Ross Dec. 8, 2018, 10:20 p.m.
On Wed, Nov 28, 2018 at 10:03:15PM +1100, Peter Ross wrote:
> sys/socket.h (with WIN32 guard) is needed to check if the SHUT_xxx macro exists.
> and because of this, SHUT_xxx defs have been moved into the CONFIG_NETWORK block,
> since they only affect network capable platforms.
> ---
> 
> This is a minor reworking of Dave's suggestion to make it work on *nix and windows.

if no objections i will apply this one in next day or so.

because the patch drags in sys/socket.h, there is a chance it could affect some obscure
platform. hence why we have fate.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

Patch hide | download patch | download mbox

diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 7a56dc9a7c..5e6b32d2dc 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -76,17 +76,7 @@  static inline int is_dos_path(const char *path)
     return 0;
 }
 
-#if defined(__OS2__)
-#define SHUT_RD 0
-#define SHUT_WR 1
-#define SHUT_RDWR 2
-#endif
-
 #if defined(_WIN32)
-#define SHUT_RD SD_RECEIVE
-#define SHUT_WR SD_SEND
-#define SHUT_RDWR SD_BOTH
-
 #ifndef S_IRUSR
 #define S_IRUSR S_IREAD
 #endif
@@ -96,6 +86,19 @@  static inline int is_dos_path(const char *path)
 #endif
 
 #if CONFIG_NETWORK
+#if defined(_WIN32)
+#define SHUT_RD SD_RECEIVE
+#define SHUT_WR SD_SEND
+#define SHUT_RDWR SD_BOTH
+#else
+#include <sys/socket.h>
+#if !defined(SHUT_RD) /* OS/2, DJGPP */
+#define SHUT_RD 0
+#define SHUT_WR 1
+#define SHUT_RDWR 2
+#endif
+#endif
+
 #if !HAVE_SOCKLEN_T
 typedef int socklen_t;
 #endif