[2/4] Installed-header compilation hygiene, 2/4 (struct osockaddr).

Message ID 2af4c6fd5f5c6e98426e2d5c967a7341dbca19e2.1468441534.git.zackw@panix.com
State Superseded
Headers

Commit Message

Zack Weinberg July 13, 2016, 8:45 p.m. UTC
  This is a little ugly, but I don't see a cleaner alternative, and it
only affects things that probably nobody uses anymore anyway.

zw

	BZ #20366, 2/4 (struct osockaddr)

	* socket/sys/socket.h: Only define struct osockaddr if not already
	defined; guard macro is __struct_osockaddr_defined.
	* inet/protocols/talkd.h: Duplicate definition of struct osockaddr
	here, also guarded by __struct_osockaddr_defined.
---
 inet/protocols/talkd.h | 12 ++++++++++++
 socket/sys/socket.h    |  6 +++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
  

Patch

diff --git a/inet/protocols/talkd.h b/inet/protocols/talkd.h
index 34e2654..99b241b 100644
--- a/inet/protocols/talkd.h
+++ b/inet/protocols/talkd.h
@@ -54,6 +54,18 @@ 
 #include <sys/socket.h>
 #include <stdint.h>
 
+#ifndef __struct_osockaddr_defined
+/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire
+   format in the grotty old 4.3 `talk' protocol.  It's also defined in
+   sys/socket.h, but only under __USE_MISC.  */
+struct osockaddr
+  {
+    unsigned short int sa_family;
+    unsigned char sa_data[14];
+  };
+# define __struct_osockaddr_defined
+#endif
+
 /*
  * Client->server request message format.
  */
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index c9f0f50..dfdd8cd 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -38,13 +38,17 @@  __BEGIN_DECLS
 #include <bits/socket.h>
 
 #ifdef __USE_MISC
+# ifndef __struct_osockaddr_defined
 /* This is the 4.3 BSD `struct sockaddr' format, which is used as wire
-   format in the grotty old 4.3 `talk' protocol.  */
+   format in the grotty old 4.3 `talk' protocol.  It is also defined,
+   unconditionally, in protocols/talkd.h.  */
 struct osockaddr
   {
     unsigned short int sa_family;
     unsigned char sa_data[14];
   };
+#  define __struct_osockaddr_defined
+# endif
 #endif
 
 /* The following constants should be used for the second parameter of