From 64b8d39133a0c72de6e87f9436f07e089591a826 Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Thu, 23 Mar 2006 11:17:41 +0000
Subject: Mark some functions as BSD only

---
 libc/inet/hostid.c                        | 2 ++
 libc/pwd_grp/pwd_grp.c                    | 6 +++++-
 libc/stdio/setbuffer.c                    | 3 +++
 libc/stdio/setlinebuf.c                   | 3 +++
 libc/stdlib/mkdtemp.c                     | 2 ++
 libc/string/generic/strsep.c              | 5 ++++-
 libc/string/strsep.c                      | 5 ++++-
 libc/sysdeps/linux/common/acct.c          | 2 ++
 libc/sysdeps/linux/common/chroot.c        | 2 ++
 libc/sysdeps/linux/common/getdnnm.c       | 8 ++++----
 libc/sysdeps/linux/common/madvise.c       | 2 +-
 libc/sysdeps/linux/common/setdomainname.c | 2 ++
 libc/sysdeps/linux/common/setgroups.c     | 3 +++
 libc/sysdeps/linux/common/sethostname.c   | 2 ++
 libc/sysdeps/linux/common/settimeofday.c  | 3 +++
 libc/sysdeps/linux/common/vhangup.c       | 2 ++
 libc/termios/cfmakeraw.c                  | 2 ++
 libc/termios/cfsetspeed.c                 | 3 +++
 libc/unistd/daemon.c                      | 3 +++
 libc/unistd/getpass.c                     | 3 +++
 libc/unistd/usershell.c                   | 3 +++
 21 files changed, 58 insertions(+), 8 deletions(-)

diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index 8d6001818..716bffaf3 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -27,6 +27,7 @@ libc_hidden_proto(gethostname)
 
 #define HOSTID "/etc/hostid"
 
+#ifdef __USE_BSD
 int sethostid(long int new_id)
 {
 	int fd;
@@ -39,6 +40,7 @@ int sethostid(long int new_id)
 	close (fd);
 	return ret;
 }
+#endif
 
 long int gethostid(void)
 {
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index 1b341f3fd..551ded762 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/libc/pwd_grp/pwd_grp.c
@@ -42,7 +42,6 @@ libc_hidden_proto(strchr)
 libc_hidden_proto(strcmp)
 libc_hidden_proto(strcpy)
 libc_hidden_proto(strlen)
-libc_hidden_proto(setgroups)
 libc_hidden_proto(strtoul)
 libc_hidden_proto(rewind)
 libc_hidden_proto(fgets_unlocked)
@@ -702,6 +701,10 @@ struct spwd *sgetspent(const char *string)
 /**********************************************************************/
 #ifdef L_initgroups
 
+#ifdef __USE_BSD
+
+libc_hidden_proto(setgroups)
+
 int initgroups(const char *user, gid_t gid)
 {
 	FILE *grfile;
@@ -755,6 +758,7 @@ int initgroups(const char *user, gid_t gid)
 	free(group_list);
 	return rv;
 }
+#endif
 
 #endif
 /**********************************************************************/
diff --git a/libc/stdio/setbuffer.c b/libc/stdio/setbuffer.c
index 3ca4fb7f8..ea2421aa8 100644
--- a/libc/stdio/setbuffer.c
+++ b/libc/stdio/setbuffer.c
@@ -7,6 +7,8 @@
 
 #include "_stdio.h"
 
+#ifdef __USE_BSD
+
 libc_hidden_proto(setvbuf)
 
 /* A BSD function.  The implementation matches the linux man page,
@@ -21,3 +23,4 @@ void setbuffer(FILE * __restrict stream, register char * __restrict buf,
 	setvbuf(stream, buf, (buf ? _IOFBF : _IONBF), size);
 #endif
 }
+#endif
diff --git a/libc/stdio/setlinebuf.c b/libc/stdio/setlinebuf.c
index 29b2bdeac..9b4be53eb 100644
--- a/libc/stdio/setlinebuf.c
+++ b/libc/stdio/setlinebuf.c
@@ -7,6 +7,8 @@
 
 #include "_stdio.h"
 
+#ifdef __USE_BSD
+
 libc_hidden_proto(setvbuf)
 
 /* A BSD function.  The implementation matches the linux man page,
@@ -20,3 +22,4 @@ void setlinebuf(FILE * __restrict stream)
 	setvbuf(stream, NULL, _IOLBF, (size_t) 0);
 #endif
 }
+#endif
diff --git a/libc/stdlib/mkdtemp.c b/libc/stdlib/mkdtemp.c
index e1ece812f..20a2e16bc 100644
--- a/libc/stdlib/mkdtemp.c
+++ b/libc/stdlib/mkdtemp.c
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include "../misc/internals/tempname.h"
 
+#ifdef __USE_BSD
 /* Generate a unique temporary directory name from TEMPLATE.
    The last six characters of TEMPLATE must be "XXXXXX";
    they are replaced with a string that makes the filename unique.
@@ -34,3 +35,4 @@ char * mkdtemp (char *template)
 
     return template;
 }
+#endif
diff --git a/libc/string/generic/strsep.c b/libc/string/generic/strsep.c
index 7b34e2c16..5cb1779d2 100644
--- a/libc/string/generic/strsep.c
+++ b/libc/string/generic/strsep.c
@@ -18,10 +18,12 @@
 
 #include <string.h>
 
-libc_hidden_proto(strsep)
+#ifdef __USE_BSD
+
 libc_hidden_proto(strchr)
 libc_hidden_proto(strpbrk)
 
+libc_hidden_proto(strsep)
 char *strsep (char **stringp, const char *delim)
 {
   char *begin, *end;
@@ -66,3 +68,4 @@ char *strsep (char **stringp, const char *delim)
   return begin;
 }
 libc_hidden_def(strsep)
+#endif
diff --git a/libc/string/strsep.c b/libc/string/strsep.c
index 7f421891e..2cc940def 100644
--- a/libc/string/strsep.c
+++ b/libc/string/strsep.c
@@ -7,10 +7,12 @@
 
 #include "_string.h"
 
-libc_hidden_proto(strsep)
+#ifdef __USE_BSD
+
 libc_hidden_proto(strpbrk)
 libc_hidden_proto(strcspn)
 
+libc_hidden_proto(strsep)
 char *strsep(char ** __restrict s1, const char * __restrict s2)
 {
 	register char *s = *s1;
@@ -32,3 +34,4 @@ char *strsep(char ** __restrict s1, const char * __restrict s2)
 	return s;
 }
 libc_hidden_def(strsep)
+#endif
diff --git a/libc/sysdeps/linux/common/acct.c b/libc/sysdeps/linux/common/acct.c
index 5c64623fb..2e7d1c600 100644
--- a/libc/sysdeps/linux/common/acct.c
+++ b/libc/sysdeps/linux/common/acct.c
@@ -9,4 +9,6 @@
 
 #include "syscalls.h"
 #include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
 _syscall1(int, acct, const char *, filename);
+#endif
diff --git a/libc/sysdeps/linux/common/chroot.c b/libc/sysdeps/linux/common/chroot.c
index fcf2adac2..527310a15 100644
--- a/libc/sysdeps/linux/common/chroot.c
+++ b/libc/sysdeps/linux/common/chroot.c
@@ -12,6 +12,7 @@
 #include <string.h>
 #include <sys/param.h>
 
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
 #define __NR___syscall_chroot __NR_chroot
 static inline _syscall1(int, __syscall_chroot, const char *, path);
 
@@ -19,3 +20,4 @@ int chroot(const char *path)
 {
 	return __syscall_chroot(path);
 }
+#endif
diff --git a/libc/sysdeps/linux/common/getdnnm.c b/libc/sysdeps/linux/common/getdnnm.c
index d4caec6ad..ee1b012c4 100644
--- a/libc/sysdeps/linux/common/getdnnm.c
+++ b/libc/sysdeps/linux/common/getdnnm.c
@@ -11,14 +11,13 @@
 #include <errno.h>
 #include <sys/utsname.h>
 
-libc_hidden_proto(getdomainname)
-
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
 libc_hidden_proto(strlen)
 libc_hidden_proto(strcpy)
 libc_hidden_proto(uname)
 
-int
-getdomainname(char *name, size_t len)
+libc_hidden_proto(getdomainname)
+int getdomainname(char *name, size_t len)
 {
   struct utsname uts;
 
@@ -45,3 +44,4 @@ getdomainname(char *name, size_t len)
   return 0;
 }
 libc_hidden_def(getdomainname)
+#endif
diff --git a/libc/sysdeps/linux/common/madvise.c b/libc/sysdeps/linux/common/madvise.c
index 70ed9c4cb..8c3918060 100644
--- a/libc/sysdeps/linux/common/madvise.c
+++ b/libc/sysdeps/linux/common/madvise.c
@@ -9,6 +9,6 @@
 
 #include "syscalls.h"
 #include <sys/mman.h>
-#ifdef __NR_madvise
+#if defined __NR_madvise && defined __USE_BSD
 _syscall3(int, madvise, void *, __addr, size_t, __len, int, __advice);
 #endif
diff --git a/libc/sysdeps/linux/common/setdomainname.c b/libc/sysdeps/linux/common/setdomainname.c
index 138250d09..3b9f535e5 100644
--- a/libc/sysdeps/linux/common/setdomainname.c
+++ b/libc/sysdeps/linux/common/setdomainname.c
@@ -9,4 +9,6 @@
 
 #include "syscalls.h"
 #include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
 _syscall2(int, setdomainname, const char *, name, size_t, len);
+#endif
diff --git a/libc/sysdeps/linux/common/setgroups.c b/libc/sysdeps/linux/common/setgroups.c
index dd1a03f38..49f3dc61f 100644
--- a/libc/sysdeps/linux/common/setgroups.c
+++ b/libc/sysdeps/linux/common/setgroups.c
@@ -12,6 +12,8 @@
 #include <unistd.h>
 #include <grp.h>
 
+#ifdef __USE_BSD
+
 libc_hidden_proto(setgroups)
 
 #if defined(__NR_setgroups32)
@@ -62,3 +64,4 @@ ret_error:
 #endif
 
 libc_hidden_def(setgroups)
+#endif
diff --git a/libc/sysdeps/linux/common/sethostname.c b/libc/sysdeps/linux/common/sethostname.c
index d8e0789bb..62867fc16 100644
--- a/libc/sysdeps/linux/common/sethostname.c
+++ b/libc/sysdeps/linux/common/sethostname.c
@@ -9,4 +9,6 @@
 
 #include "syscalls.h"
 #include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
 _syscall2(int, sethostname, const char *, name, size_t, len);
+#endif
diff --git a/libc/sysdeps/linux/common/settimeofday.c b/libc/sysdeps/linux/common/settimeofday.c
index 2dc2a6a44..a0ae95fa5 100644
--- a/libc/sysdeps/linux/common/settimeofday.c
+++ b/libc/sysdeps/linux/common/settimeofday.c
@@ -10,8 +10,11 @@
 #include "syscalls.h"
 #include <sys/time.h>
 
+#ifdef __USE_BSD
+
 libc_hidden_proto(settimeofday)
 
 _syscall2(int, settimeofday, const struct timeval *, tv,
 		  const struct timezone *, tz);
 libc_hidden_def(settimeofday)
+#endif
diff --git a/libc/sysdeps/linux/common/vhangup.c b/libc/sysdeps/linux/common/vhangup.c
index f6dc0865f..984a09dec 100644
--- a/libc/sysdeps/linux/common/vhangup.c
+++ b/libc/sysdeps/linux/common/vhangup.c
@@ -9,4 +9,6 @@
 
 #include "syscalls.h"
 #include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
 _syscall0(int, vhangup);
+#endif
diff --git a/libc/termios/cfmakeraw.c b/libc/termios/cfmakeraw.c
index bf2012489..aae76782d 100644
--- a/libc/termios/cfmakeraw.c
+++ b/libc/termios/cfmakeraw.c
@@ -18,6 +18,7 @@
 
 #include <termios.h>
 
+#ifdef __USE_BSD
 /* Set *T to indicate raw mode.  */
 void cfmakeraw (struct termios *t)
 {
@@ -29,3 +30,4 @@ void cfmakeraw (struct termios *t)
   t->c_cc[VMIN] = 1;		/* read returns when one char is available.  */
   t->c_cc[VTIME] = 0;
 }
+#endif
diff --git a/libc/termios/cfsetspeed.c b/libc/termios/cfsetspeed.c
index 0d35d1474..b9e95805b 100644
--- a/libc/termios/cfsetspeed.c
+++ b/libc/termios/cfsetspeed.c
@@ -20,6 +20,8 @@
 #include <errno.h>
 #include <stddef.h>
 
+#ifdef __USE_BSD
+
 libc_hidden_proto(cfsetispeed)
 libc_hidden_proto(cfsetospeed)
 
@@ -171,3 +173,4 @@ int cfsetspeed (struct termios *termios_p, speed_t speed)
 
   return -1;
 }
+#endif
diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c
index 03cffc7d1..2d1d9af27 100644
--- a/libc/unistd/daemon.c
+++ b/libc/unistd/daemon.c
@@ -46,6 +46,8 @@
 #include <paths.h>
 #include <unistd.h>
 
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
+
 libc_hidden_proto(open)
 libc_hidden_proto(close)
 libc_hidden_proto(_exit)
@@ -87,3 +89,4 @@ int daemon( int nochdir, int noclose )
 	}
 	return(0);
 }
+#endif
diff --git a/libc/unistd/getpass.c b/libc/unistd/getpass.c
index 5833bc317..fbf82d1c4 100644
--- a/libc/unistd/getpass.c
+++ b/libc/unistd/getpass.c
@@ -22,6 +22,8 @@
 #include <unistd.h>
 #include <string.h>
 
+#if defined __USE_BSD && (defined __USE_XOPEN && !defined __USE_XOPEN2K)
+
 libc_hidden_proto(strlen)
 libc_hidden_proto(tcsetattr)
 libc_hidden_proto(tcgetattr)
@@ -118,3 +120,4 @@ getpass (prompt)
 
   return buf;
 }
+#endif
diff --git a/libc/unistd/usershell.c b/libc/unistd/usershell.c
index be8fb71d6..ea4a04ba4 100644
--- a/libc/unistd/usershell.c
+++ b/libc/unistd/usershell.c
@@ -40,6 +40,8 @@
 #include <unistd.h>
 #include <paths.h>
 
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
+
 libc_hidden_proto(fstat)
 libc_hidden_proto(fopen)
 libc_hidden_proto(fclose)
@@ -146,3 +148,4 @@ cleanup:
     fclose(fp);
     return (char **) validsh;
 }
+#endif
-- 
cgit v1.2.3