[Glibc-bsd-commits] r4856 - in trunk/freebsd-glue: . debian include src

Robert Millan rmh at alioth.debian.org
Sun Aug 4 14:52:18 UTC 2013


Author: rmh
Date: 2013-08-04 14:52:17 +0000 (Sun, 04 Aug 2013)
New Revision: 4856

Added:
   trunk/freebsd-glue/Makefile
   trunk/freebsd-glue/src/
   trunk/freebsd-glue/src/Makefile
   trunk/freebsd-glue/src/exec.c
   trunk/freebsd-glue/src/feature_present.c
   trunk/freebsd-glue/src/getosreldate.c
Modified:
   trunk/freebsd-glue/debian/changelog
   trunk/freebsd-glue/debian/control
   trunk/freebsd-glue/debian/install
   trunk/freebsd-glue/debian/rules
   trunk/freebsd-glue/include/unistd.h
Log:
  * Fix header pollution in <unistd.h> by moving non-trivial inline
    functions into static objects of their own.
  * Add nlm_syscall() inline function.

Added: trunk/freebsd-glue/Makefile
===================================================================
--- trunk/freebsd-glue/Makefile	                        (rev 0)
+++ trunk/freebsd-glue/Makefile	2013-08-04 14:52:17 UTC (rev 4856)
@@ -0,0 +1,3 @@
+SUBDIR=	src
+
+.include <bsd.subdir.mk>

Modified: trunk/freebsd-glue/debian/changelog
===================================================================
--- trunk/freebsd-glue/debian/changelog	2013-08-04 14:47:46 UTC (rev 4855)
+++ trunk/freebsd-glue/debian/changelog	2013-08-04 14:52:17 UTC (rev 4856)
@@ -1,3 +1,11 @@
+freebsd-glue (0.1.0) unstable; urgency=low
+
+  * Fix header pollution in <unistd.h> by moving non-trivial inline
+    functions into static objects of their own.
+  * Add nlm_syscall() inline function.
+
+ -- Robert Millan <rmh at debian.org>  Sun, 04 Aug 2013 16:21:56 +0200
+
 freebsd-glue (0.0.10) unstable; urgency=low
 
   [ Guillem Jover ]

Modified: trunk/freebsd-glue/debian/control
===================================================================
--- trunk/freebsd-glue/debian/control	2013-08-04 14:47:46 UTC (rev 4855)
+++ trunk/freebsd-glue/debian/control	2013-08-04 14:52:17 UTC (rev 4856)
@@ -5,12 +5,13 @@
 Uploaders: Robert Millan <rmh at debian.org>
 Build-Depends:
  debhelper (>= 8.0),
+ freebsd-buildutils,
 Vcs-Browser: http://anonscm.debian.org/viewvc/glibc-bsd/trunk/freebsd-glue/
 Vcs-Svn: svn://anonscm.debian.org/glibc-bsd/trunk/freebsd-glue/
 Standards-Version: 3.9.3
 
 Package: freebsd-glue
-Architecture: all
+Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends},
  original-awk,
  make,

Modified: trunk/freebsd-glue/debian/install
===================================================================
--- trunk/freebsd-glue/debian/install	2013-08-04 14:47:46 UTC (rev 4855)
+++ trunk/freebsd-glue/debian/install	2013-08-04 14:52:17 UTC (rev 4856)
@@ -1 +1,2 @@
 include/*		usr/include/freebsd
+usr/lib/lib*.a

Modified: trunk/freebsd-glue/debian/rules
===================================================================
--- trunk/freebsd-glue/debian/rules	2013-08-04 14:47:46 UTC (rev 4855)
+++ trunk/freebsd-glue/debian/rules	2013-08-04 14:52:17 UTC (rev 4856)
@@ -1,5 +1,58 @@
 #!/usr/bin/make -f
 # -*- makefile -*-
 
-%:
-	dh $@
+CFLAGS = -Wall -g -pipe -fPIC -D_GNU_SOURCE \
+	-Werror=implicit-function-declaration \
+	-isystem $(CURDIR)/include \
+	$(NULL)
+DESTDIR = $(CURDIR)/debian/tmp
+PATH := /usr/lib/freebsd:$(PATH)
+PMAKE := CFLAGS="$(CFLAGS)" DESTDIR="$(DESTDIR)" make
+
+clean:
+	dh_testdir
+	$(PMAKE) clean
+	dh_clean
+
+build: build-arch
+build-arch:
+	$(PMAKE)
+
+build-indep:
+	:
+
+install-arch: build-arch
+	dh_testdir
+	dh_testroot
+	dh_prep -a
+	dh_installdirs -a
+	mkdir -p $(DESTDIR)/usr/lib
+	$(PMAKE) install SHLIBDIR=/usr/lib
+	dh_install -a --list-missing
+
+binary: binary-arch binary-indep
+binary-arch: install-arch
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs -a
+	dh_installdocs -a
+#	dh_installexamples
+#	dh_installinit
+#	dh_installcron
+#	dh_installinfo
+#	dh_installman
+	dh_link -a
+	dh_strip -a
+	dh_compress -a
+	dh_fixperms -a
+#	dh_perl
+#	dh_python
+	dh_makeshlibs -a
+	dh_installdeb -a
+	dh_shlibdeps -a
+	dh_gencontrol -a
+	dh_md5sums -a
+	dh_builddeb -a
+
+binary-indep:
+	:

Modified: trunk/freebsd-glue/include/unistd.h
===================================================================
--- trunk/freebsd-glue/include/unistd.h	2013-08-04 14:47:46 UTC (rev 4855)
+++ trunk/freebsd-glue/include/unistd.h	2013-08-04 14:52:17 UTC (rev 4856)
@@ -7,7 +7,6 @@
 
 #ifdef __FreeBSD_kernel__
 #include <sys/syscall.h>
-#include <stdlib.h>		/* setenv */
 #endif
 
 #define getopt(argc, argv, options) bsd_getopt(argc, argv, options)
@@ -35,136 +34,23 @@
   syscall (SYS_closefrom, lowfd);
 }
 
-/*
- * Copyright (c) 1989, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+int getosreldate(void);
+int feature_present(const char *);
+int execvP(const char *, const char *, char * const[]);
 
-#include <stddef.h>
-#include <sys/sysctl.h>
-#include <stdlib.h>
+mode_t getmode(const void *, mode_t);
+void *setmode(const char *);
 
-static inline int
-getosreldate(void)
-{
-	int mib[2];
-	size_t size;
-	int value;
-	char *temp;
+#ifndef SYS_nlm_syscall
+#define SYS_nlm_syscall		154
+#endif
 
-	if ((temp = getenv("OSVERSION"))) {
-		value = atoi(temp);
-		return (value);
-	}
-
-	mib[0] = CTL_KERN;
-	mib[1] = KERN_OSRELDATE;
-	size = sizeof value;
-	if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
-		return (-1);
-	return (value);
-}
-
-/*-
- * Copyright (c) 2008 Yahoo!, Inc.
- * All rights reserved.
- * Written by: John Baldwin <jhb at FreeBSD.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/*
- * Returns true if the named feature is present in the currently
- * running kernel.  A feature's presence is indicated by an integer
- * sysctl node called kern.feature.<feature> that is non-zero.
- */
 static inline int
-feature_present(const char *feature)
+nlm_syscall (int a, int b, int c, char **d)
 {
-	char *mib;
-	size_t len;
-	int i;
-
-	if ((!strcmp(feature, "inet") || !strcmp(feature, "inet6")) && getosreldate() <= 900038)
-		return (1);
-
-	if (asprintf(&mib, "kern.features.%s", feature) < 0)
-		return (0);
-	len = sizeof(i);
-	if (sysctlbyname(mib, &i, &len, NULL, 0) < 0) {
-		free(mib);
-		return (0);
-	}
-	free(mib);
-	if (len != sizeof(i))
-		return (0);
-	return (i != 0);
+  return syscall (SYS_nlm_syscall, a, b, c, d);
 }
 
-static inline int
-execvP(const char *name, const char *path, char * const argv[])
-{
-	setenv ("PATH", path, 1);
-	return execvp(name, argv);
-}
-
-mode_t getmode(const void *, mode_t);
-void *setmode(const char *);
-int nlm_syscall(int, int, int, char **);
-
 #endif /* __FreeBSD_kernel__ */
 
 void setproctitle(const char *fmt, ...);

Added: trunk/freebsd-glue/src/Makefile
===================================================================
--- trunk/freebsd-glue/src/Makefile	                        (rev 0)
+++ trunk/freebsd-glue/src/Makefile	2013-08-04 14:52:17 UTC (rev 4856)
@@ -0,0 +1,8 @@
+LIB=	freebsd-glue
+SRCS=	\
+	exec.c \
+	feature_present.c \
+	getosreldate.c \
+	${NULL}
+
+.include <bsd.lib.mk>

Added: trunk/freebsd-glue/src/exec.c
===================================================================
--- trunk/freebsd-glue/src/exec.c	                        (rev 0)
+++ trunk/freebsd-glue/src/exec.c	2013-08-04 14:52:17 UTC (rev 4856)
@@ -0,0 +1,9 @@
+#include <stdlib.h>	/* setenv */
+#include <unistd.h>	/* execvp */
+
+int
+execvP(const char *name, const char *path, char * const argv[])
+{
+	setenv ("PATH", path, 1);
+	return execvp(name, argv);
+}

Added: trunk/freebsd-glue/src/feature_present.c
===================================================================
--- trunk/freebsd-glue/src/feature_present.c	                        (rev 0)
+++ trunk/freebsd-glue/src/feature_present.c	2013-08-04 14:52:17 UTC (rev 4856)
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2008 Yahoo!, Inc.
+ * All rights reserved.
+ * Written by: John Baldwin <jhb at FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+ * Returns true if the named feature is present in the currently
+ * running kernel.  A feature's presence is indicated by an integer
+ * sysctl node called kern.feature.<feature> that is non-zero.
+ */
+int
+feature_present(const char *feature)
+{
+#ifdef __FreeBSD_kernel__
+	char *mib;
+	size_t len;
+	int i;
+
+	if ((!strcmp(feature, "inet") || !strcmp(feature, "inet6")) && getosreldate() <= 900038)
+		return (1);
+
+	if (asprintf(&mib, "kern.features.%s", feature) < 0)
+		return (0);
+	len = sizeof(i);
+	if (sysctlbyname(mib, &i, &len, NULL, 0) < 0) {
+		free(mib);
+		return (0);
+	}
+	free(mib);
+	if (len != sizeof(i))
+		return (0);
+	return (i != 0);
+#else
+	return (0);
+#endif
+}

Added: trunk/freebsd-glue/src/getosreldate.c
===================================================================
--- trunk/freebsd-glue/src/getosreldate.c	                        (rev 0)
+++ trunk/freebsd-glue/src/getosreldate.c	2013-08-04 14:52:17 UTC (rev 4856)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <sys/sysctl.h>
+#include <stdlib.h>
+
+int
+getosreldate(void)
+{
+	int mib[2];
+	size_t size;
+	int value;
+	char *temp;
+
+	if ((temp = getenv("OSVERSION"))) {
+		value = atoi(temp);
+		return (value);
+	}
+
+#ifdef __FreeBSD_kernel__ 
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_OSRELDATE;
+	size = sizeof value;
+	if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
+		return (-1);
+	return (value);
+#else
+	return 0;
+#endif
+}




More information about the Glibc-bsd-commits mailing list