[Glibc-bsd-commits] r4039 - in trunk/freebsd-buildutils/debian: . local/include

Robert Millan rmh at alioth.debian.org
Sun Jan 29 01:59:35 UTC 2012


Author: rmh
Date: 2012-01-29 01:59:34 +0000 (Sun, 29 Jan 2012)
New Revision: 4039

Modified:
   trunk/freebsd-buildutils/debian/changelog
   trunk/freebsd-buildutils/debian/local/include/unistd.h
Log:
Add nfssvc, closefrom and feature_present to unistd.h.

Modified: trunk/freebsd-buildutils/debian/changelog
===================================================================
--- trunk/freebsd-buildutils/debian/changelog	2012-01-29 01:55:44 UTC (rev 4038)
+++ trunk/freebsd-buildutils/debian/changelog	2012-01-29 01:59:34 UTC (rev 4039)
@@ -9,8 +9,9 @@
   * Remove getline kludge. The second part was unneeded, the first one
     caused version_gen.awk to hang.
   * Add __offsetof().
+  * Add nfssvc, closefrom and feature_present to unistd.h.
 
- -- Robert Millan <rmh at debian.org>  Sun, 29 Jan 2012 01:55:23 +0100
+ -- Robert Millan <rmh at debian.org>  Sun, 29 Jan 2012 02:59:15 +0100
 
 freebsd-buildutils (9.0-2) unstable; urgency=low
 

Modified: trunk/freebsd-buildutils/debian/local/include/unistd.h
===================================================================
--- trunk/freebsd-buildutils/debian/local/include/unistd.h	2012-01-29 01:55:44 UTC (rev 4038)
+++ trunk/freebsd-buildutils/debian/local/include/unistd.h	2012-01-29 01:59:34 UTC (rev 4039)
@@ -1,7 +1,12 @@
+#include_next <unistd.h>
+
 #ifndef _UNISTD_H_
 #define	_UNISTD_H_
-#include_next <unistd.h>
 
+#ifdef __FreeBSD_kernel__
+#include <sys/syscall.h>
+#endif
+
 #define getopt(argc, argv, options) bsd_getopt(argc, argv, options)
 
 __BEGIN_DECLS
@@ -9,6 +14,88 @@
 int bsd_getopt(int, char **, char *);
 extern int optreset;
 
+#ifdef __FreeBSD_kernel__
+
+static inline int
+nfssvc (int a, void *b)
+{
+  return syscall (SYS_nfssvc, a, b);
+}
+
+#ifndef SYS_closefrom
+#define SYS_closefrom 509
+#endif
+
+static inline void
+closefrom (int lowfd)
+{
+  syscall (SYS_closefrom, lowfd);
+}
+
+
+/*-
+ * 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>
+
+/*
+ * 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)
+{
+	char *mib;
+	size_t len;
+	int i;
+
+	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);
+}
+
+#endif /* __FreeBSD_kernel__ */
+
 __END_DECLS
 
 #endif




More information about the Glibc-bsd-commits mailing list