diff mbox series

[Ada] Keepalive control on Windows

Message ID 20210707162541.GA2543228@adacore.com
State New
Headers show
Series [Ada] Keepalive control on Windows | expand

Commit Message

Pierre-Marie de Rodat July 7, 2021, 4:25 p.m. UTC
Windows headers in GCC could miss some available constants. Hardcode
TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL constants for such case.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* s-oscons-tmplt.c (TCP_KEEPCNT TCP_KEEPIDLE, TCP_KEEPINTVL):
	Hardcode on Windows if undefined.
diff mbox series

Patch

diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c
--- a/gcc/ada/s-oscons-tmplt.c
+++ b/gcc/ada/s-oscons-tmplt.c
@@ -1502,18 +1502,36 @@  CNS(MSG_Forced_Flags, "")
 CND(TCP_NODELAY, "Do not coalesce packets")
 
 #ifndef TCP_KEEPCNT
+#ifdef __MINGW32__
+/* Windows headers can be too old to have all available constants.
+ * We know this one. */
+# define TCP_KEEPCNT 16
+#else
 # define TCP_KEEPCNT -1
 #endif
+#endif
 CND(TCP_KEEPCNT, "Maximum number of keepalive probes")
 
 #ifndef TCP_KEEPIDLE
+#ifdef __MINGW32__
+/* Windows headers can be too old to have all available constants.
+ * We know this one. */
+# define TCP_KEEPIDLE 3
+#else
 # define TCP_KEEPIDLE -1
 #endif
+#endif
 CND(TCP_KEEPIDLE, "Idle time before TCP starts sending keepalive probes")
 
 #ifndef TCP_KEEPINTVL
+#ifdef __MINGW32__
+/* Windows headers can be too old to have all available constants.
+ * We know this one. */
+# define TCP_KEEPINTVL 17
+#else
 # define TCP_KEEPINTVL -1
 #endif
+#endif
 CND(TCP_KEEPINTVL, "Time between individual keepalive probes")
 
 #ifndef SO_REUSEADDR