Fix two uses of __BEGIN_DECLS

Message ID CA+5-Q5+f+oJx_P06ZcD_7cJzNtPYSvx-w7VaS3g10zNYXNA+xQ@mail.gmail.com
State New, archived
Headers

Commit Message

Stan Shebs Aug. 12, 2015, 9:14 p.m. UTC
  We ran across a couple cases of problems in headers when they were included in
C++ sources, the positioning of extern "C" wrappers came out wrong.

(Is there a test for this kind of thing?  I didn't see anything relevant.)

Stan

2015-08-12  Stan Shebs <stanshebs@google.com>

        * elf/link.h: Move __BEGIN_DECLS up.
        * socket/sys/un.h: Include string.h before __BEGIN_DECLS.
  

Comments

Mike Frysinger Aug. 13, 2015, 4:26 a.m. UTC | #1
On 12 Aug 2015 16:14, Stan Shebs wrote:
> We ran across a couple cases of problems in headers when they were included in
> C++ sources, the positioning of extern "C" wrappers came out wrong.

what problems ?  you're moving structs/enums under the external part.
-mike
  
Stan Shebs Aug. 13, 2015, 12:08 p.m. UTC | #2
On Wed, Aug 12, 2015 at 11:26 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 12 Aug 2015 16:14, Stan Shebs wrote:
>> We ran across a couple cases of problems in headers when they were included in
>> C++ sources, the positioning of extern "C" wrappers came out wrong.
>
> what problems ?  you're moving structs/enums under the external part.

Also _DYNAMIC - Google has several chunks of C++ code that iterate over it.

Stan
  
Mike Frysinger Aug. 13, 2015, 4:07 p.m. UTC | #3
On 13 Aug 2015 07:08, Stan Shebs wrote:
> On Wed, Aug 12, 2015 at 11:26 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On 12 Aug 2015 16:14, Stan Shebs wrote:
> >> We ran across a couple cases of problems in headers when they were included in
> >> C++ sources, the positioning of extern "C" wrappers came out wrong.
> >
> > what problems ?  you're moving structs/enums under the external part.
> 
> Also _DYNAMIC - Google has several chunks of C++ code that iterate over it.

so it's the few symbols that are causing problems ?  i'm not against the
patch, but we want to see the reason behind it including error messages.
-mike
  

Patch

diff --git a/elf/link.h b/elf/link.h
index eaca802..6ec9b55 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -34,6 +34,8 @@ 
 #include <bits/elfclass.h>             /* Defines __ELF_NATIVE_CLASS.  */
 #include <bits/link.h>

+__BEGIN_DECLS
+
 /* Rendezvous structure used by the run-time dynamic linker to communicate
    details of shared object loading to the debugger.  If the executable's
    dynamic section has a DT_DEBUG element, the run-time linker sets that
@@ -162,8 +164,6 @@  struct dl_phdr_info
     void *dlpi_tls_data;
   };

-__BEGIN_DECLS
-
 extern int dl_iterate_phdr (int (*__callback) (struct dl_phdr_info *,
                                               size_t, void *),
                            void *__data);
diff --git a/socket/sys/un.h b/socket/sys/un.h
index 0059570..2fbf1fe 100644
--- a/socket/sys/un.h
+++ b/socket/sys/un.h
@@ -23,6 +23,10 @@ 
 /* Get the definition of the macro to define the common sockaddr members.  */
 #include <bits/sockaddr.h>

+#ifdef __USE_MISC
+# include <string.h>           /* For prototype of `strlen'.  */
+#endif
+
 __BEGIN_DECLS

 /* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket.  */
@@ -34,7 +38,6 @@  struct sockaddr_un


 #ifdef __USE_MISC
-# include <string.h>           /* For prototype of `strlen'.  */

 /* Evaluate to actual length of the `sockaddr_un' structure.  */
 # define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path)       \