mailing list of musl libc
 help / color / mirror / code / Atom feed
* missing extern "C" block
@ 2011-10-10 16:44 Szabolcs Nagy
  2011-10-11  3:49 ` Isaac Dunham
  0 siblings, 1 reply; 3+ messages in thread
From: Szabolcs Nagy @ 2011-10-10 16:44 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 394 bytes --]

while we are fixing c++ compatibility
some headers with function prototypes
do not have extern "C" block for c++

extern "C" block ending is wrong in
pty.h

extern "C" block is missing from
arpa/inet.h
alloca.h
ftw.h
math.h
net/if.h
netinet/in.h
sys/mount.h
sys/msg.h
sys/resource.h
sys/shm.h
sys/statfs.h
sys/statvfs.h
sys/swap.h
sys/sysctl.h
sys/sysinfo.h
sys/times.h
sys/uio.h
sys/utsname.h

[-- Attachment #2: cplusplus.diff --]
[-- Type: text/x-diff, Size: 8695 bytes --]

diff --git a/include/alloca.h b/include/alloca.h
index ac78e46..f61b817 100644
--- a/include/alloca.h
+++ b/include/alloca.h
@@ -1,9 +1,17 @@
 #ifndef	_ALLOCA_H
 #define	_ALLOCA_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define	__NEED_size_t
 #include <bits/alltypes.h>
 
 void *alloca(size_t);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/arpa/inet.h b/include/arpa/inet.h
index 9342713..b604f60 100644
--- a/include/arpa/inet.h
+++ b/include/arpa/inet.h
@@ -1,6 +1,10 @@
 #ifndef _ARPA_INET_H
 #define	_ARPA_INET_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <netinet/in.h>
 #include <inttypes.h>
 
@@ -30,4 +34,8 @@ int inet_aton (const char *, struct in_addr *); /* nonstandard but widely used *
 #define INET_ADDRSTRLEN  16
 #define INET6_ADDRSTRLEN 46
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/ftw.h b/include/ftw.h
index 8d31c6d..9bb38c7 100644
--- a/include/ftw.h
+++ b/include/ftw.h
@@ -1,6 +1,10 @@
 #ifndef _FTW_H
 #define	_FTW_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Normally we do not nest header includes. However useless bloat
  * like ftw may be treated as a special case. Otherwise we would
  * have to deal with duplicating all the stat.h mess. */
@@ -28,4 +32,8 @@ struct FTW
 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/math.h b/include/math.h
index 6772482..9c5f06e 100644
--- a/include/math.h
+++ b/include/math.h
@@ -1,6 +1,10 @@
 #ifndef _MATH_H
 #define _MATH_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __NEED___uint16_t
 #define __NEED___uint32_t
 #define __NEED___uint64_t
@@ -317,4 +321,8 @@ extern int signgam;
 double      scalb(double, double);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/net/if.h b/include/net/if.h
index 2ae5f89..f72228b 100644
--- a/include/net/if.h
+++ b/include/net/if.h
@@ -1,6 +1,10 @@
 #ifndef _NET_IF_H
 #define _NET_IF_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define IF_NAMESIZE 16
 
 struct if_nameindex
@@ -104,7 +108,7 @@ struct ifreq {
 #define _IOT_ifreq_int	_IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
 
 struct ifconf {
-	int ifc_len;		
+	int ifc_len;
 	union {
 		void *ifcu_buf;
 		struct ifreq *ifcu_req;
@@ -118,5 +122,8 @@ struct ifconf {
 #endif
 
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/include/netinet/in.h b/include/netinet/in.h
index b7b8c82..cae16c7 100644
--- a/include/netinet/in.h
+++ b/include/netinet/in.h
@@ -1,6 +1,10 @@
 #ifndef	_NETINET_IN_H
 #define	_NETINET_IN_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __NEED_in_addr_t
 #define __NEED_in_port_t
 #define __NEED_sa_family_t
@@ -300,4 +304,8 @@ struct ip6_mtuinfo
 
 #define IPV6_RTHDR_TYPE_0       0
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/pty.h b/include/pty.h
index 46a99f4..db63853 100644
--- a/include/pty.h
+++ b/include/pty.h
@@ -12,7 +12,7 @@ int openpty(int *, int *, char *, const struct termios *, const struct winsize *
 int forkpty(int *, char *, const struct termios *, const struct winsize *);
 
 #ifdef __cplusplus
-extern }
+}
 #endif
 
 #endif
diff --git a/include/sys/mount.h b/include/sys/mount.h
index 9420c56..3f652e9 100644
--- a/include/sys/mount.h
+++ b/include/sys/mount.h
@@ -1,6 +1,10 @@
 #ifndef _SYS_MOUNT_H
 #define _SYS_MOUNT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <sys/ioctl.h>
 
 #define BLKROSET   _IO(0x12, 93)
@@ -43,4 +47,8 @@ int mount(const char *, const char *, const char *, unsigned long, const void *)
 int umount(const char *);
 int umount2(const char *, int);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/msg.h b/include/sys/msg.h
index 06f2553..460275c 100644
--- a/include/sys/msg.h
+++ b/include/sys/msg.h
@@ -1,6 +1,10 @@
 #ifndef _SYS_MSG_H
 #define _SYS_MSG_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <sys/ipc.h>
 
 #define __NEED_pid_t
@@ -33,4 +37,8 @@ int msgget (key_t, int);
 ssize_t msgrcv (int, void *, size_t, long, int);
 int msgsnd (int, const void *, size_t, int);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/resource.h b/include/sys/resource.h
index 7837adb..3e74850 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -1,6 +1,10 @@
 #ifndef	_SYS_RESOURCE_H
 #define	_SYS_RESOURCE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __NEED_id_t
 #define __NEED_time_t
 #define __NEED_struct_timeval
@@ -75,5 +79,8 @@ int setpriority (int, id_t, int);
 
 #define RLIM_NLIMITS RLIMIT_NLIMITS
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/include/sys/shm.h b/include/sys/shm.h
index fa92710..34117cc 100644
--- a/include/sys/shm.h
+++ b/include/sys/shm.h
@@ -1,6 +1,10 @@
 #ifndef _SYS_SHM_H
 #define _SYS_SHM_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __NEED_time_t
 #define __NEED_size_t
 #define __NEED_pid_t
@@ -43,4 +47,8 @@ int shmctl(int, int, struct shmid_ds *);
 int shmdt(const void *);
 int shmget(key_t, size_t, int);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/statfs.h b/include/sys/statfs.h
index 05c9b13..f5239d8 100644
--- a/include/sys/statfs.h
+++ b/include/sys/statfs.h
@@ -1,6 +1,10 @@
 #ifndef	_SYS_STATFS_H
 #define	_SYS_STATFS_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <sys/statvfs.h>
 
 typedef struct {
@@ -12,4 +16,8 @@ typedef struct {
 int statfs (const char *, struct statfs *);
 int fstatfs (int, struct statfs *);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h
index fd22fab..b9f72b7 100644
--- a/include/sys/statvfs.h
+++ b/include/sys/statvfs.h
@@ -1,6 +1,9 @@
 #ifndef	_SYS_STATVFS_H
 #define	_SYS_STATVFS_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #define __NEED_fsblkcnt_t
 #define __NEED_fsfilcnt_t
@@ -38,5 +41,8 @@ int fstatvfs (int, struct statvfs *);
 #define ST_NOATIME     1024
 #define ST_NODIRATIME  2048
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/include/sys/swap.h b/include/sys/swap.h
index c5824f1..2d921ad 100644
--- a/include/sys/swap.h
+++ b/include/sys/swap.h
@@ -1,6 +1,10 @@
 #ifndef _SYS_SWAP_H
 #define _SYS_SWAP_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define	SWAP_FLAG_PREFER        0x8000
 #define	SWAP_FLAG_PRIO_MASK     0x7fff
 #define	SWAP_FLAG_PRIO_SHIFT    0
@@ -8,4 +12,8 @@
 int swapon (const char *, int);
 int swapoff (const char *);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/sysctl.h b/include/sys/sysctl.h
index af5ca8b..c358b79 100644
--- a/include/sys/sysctl.h
+++ b/include/sys/sysctl.h
@@ -1,9 +1,17 @@
 #ifndef	_SYS_SYSCTL_H
 #define	_SYS_SYSCTL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __NEED_size_t
 #include <bits/alltypes.h>
 
 int sysctl (int *, int, void *, size_t *, void *, size_t);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/sysinfo.h b/include/sys/sysinfo.h
index ca52088..3bf6cb0 100644
--- a/include/sys/sysinfo.h
+++ b/include/sys/sysinfo.h
@@ -1,6 +1,10 @@
 #ifndef _SYS_SYSINFO_H
 #define _SYS_SYSINFO_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* ?? */
 #define SI_LOAD_SHIFT 16
 
@@ -26,4 +30,8 @@ int get_nprocs (void);
 long long get_phys_pages (void);
 long long get_avphys_pages (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/times.h b/include/sys/times.h
index aca743d..98d2324 100644
--- a/include/sys/times.h
+++ b/include/sys/times.h
@@ -1,6 +1,10 @@
 #ifndef	_SYS_TIMES_H
 #define	_SYS_TIMES_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __NEED_clock_t
 #include <bits/alltypes.h>
 
@@ -14,4 +18,8 @@ struct tms
 
 clock_t times (struct tms *);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/uio.h b/include/sys/uio.h
index 11b6bd2..f77db33 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -1,6 +1,10 @@
 #ifndef _SYS_UIO_H
 #define _SYS_UIO_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define __NEED_size_t
 #define __NEED_ssize_t
 #define __NEED_struct_iovec
@@ -10,4 +14,8 @@
 ssize_t readv (int, const struct iovec *, int);
 ssize_t writev (int, const struct iovec *, int);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/sys/utsname.h b/include/sys/utsname.h
index 383e825..4c36960 100644
--- a/include/sys/utsname.h
+++ b/include/sys/utsname.h
@@ -1,6 +1,10 @@
 #ifndef	_SYS_UTSNAME_H
 #define	_SYS_UTSNAME_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct utsname
 {
 	char sysname[65];
@@ -17,5 +21,8 @@ struct utsname
 
 int uname (struct utsname *);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: missing extern "C" block
  2011-10-10 16:44 missing extern "C" block Szabolcs Nagy
@ 2011-10-11  3:49 ` Isaac Dunham
  2011-10-11  4:10   ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Isaac Dunham @ 2011-10-11  3:49 UTC (permalink / raw)
  To: musl

On Mon, 10 Oct 2011 18:44:49 +0200
Szabolcs Nagy <nsz@port70.net> wrote:

> while we are fixing c++ compatibility
> some headers with function prototypes
> do not have extern "C" block for c++

<snip list>

I'm certainly not saying that this is the right way to handle it, but this is what GNU libc uses __BEGIN_DECLS & __END_DECLS for (in sys/cdefs.h).  

-- 
Isaac Dunham <idunham@lavabit.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: missing extern "C" block
  2011-10-11  3:49 ` Isaac Dunham
@ 2011-10-11  4:10   ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2011-10-11  4:10 UTC (permalink / raw)
  To: musl

On Mon, Oct 10, 2011 at 08:49:46PM -0700, Isaac Dunham wrote:
> On Mon, 10 Oct 2011 18:44:49 +0200
> Szabolcs Nagy <nsz@port70.net> wrote:
> 
> > while we are fixing c++ compatibility
> > some headers with function prototypes
> > do not have extern "C" block for c++
> 
> <snip list>
> 
> I'm certainly not saying that this is the right way to handle it,
> but this is what GNU libc uses __BEGIN_DECLS & __END_DECLS for (in
> sys/cdefs.h).

Definitely not the right way. It's a lot slower, and it's not
immediately obvious to somebody reading the code what the definitions
of these macros might be. The right fix is the audit that was just
done, and applying the results of it to fix errors and omissions.

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-11  4:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-10 16:44 missing extern "C" block Szabolcs Nagy
2011-10-11  3:49 ` Isaac Dunham
2011-10-11  4:10   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).