Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libutil Add getbyteorder() call.
details: https://anonhg.NetBSD.org/src/rev/cfef8800c7fe
branches: trunk
changeset: 786575:cfef8800c7fe
user: matt <matt%NetBSD.org@localhost>
date: Thu May 02 07:17:09 2013 +0000
description:
Add getbyteorder() call.
diffstat:
lib/libutil/Makefile | 8 +++--
lib/libutil/getbyteorder.3 | 59 ++++++++++++++++++++++++++++++++++++++++++++++
lib/libutil/getbyteorder.c | 54 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 118 insertions(+), 3 deletions(-)
diffs (150 lines):
diff -r 8d7cd1a4ee38 -r cfef8800c7fe lib/libutil/Makefile
--- a/lib/libutil/Makefile Thu May 02 07:01:55 2013 +0000
+++ b/lib/libutil/Makefile Thu May 02 07:17:09 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.73 2012/04/07 16:44:39 christos Exp $
+# $NetBSD: Makefile,v 1.74 2013/05/02 07:17:09 matt Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
@@ -11,7 +11,8 @@
LIB= util
CPPFLAGS+=-DLIBC_SCCS -I${.CURDIR}
LINTFLAGS+=-w
-SRCS+= efun.c getbootfile.c getlabelsector.c getmaxpartitions.c \
+SRCS+= efun.c \
+ getbootfile.c getbyteorder.c getlabelsector.c getmaxpartitions.c \
getfsspecname.c getmntopts.c getrawpartition.c getdiskrawname.c \
disklabel_dkcksum.c disklabel_scan.c \
if_media.c \
@@ -22,7 +23,8 @@
secure_path.c sockaddr_snprintf.c stat_flags.c \
strpct.c ttyaction.c ttymsg.c
-MAN= efun.3 getbootfile.3 getfstypename.3 getlabelsector.3 \
+MAN= efun.3 \
+ getbootfile.3 getbyteorder.3 getfstypename.3 getlabelsector.3 \
getmaxpartitions.3 getmntopts.3 getrawpartition.3 \
getdiskrawname.3 getfsspecname.3 \
login.3 login_cap.3 loginx.3 \
diff -r 8d7cd1a4ee38 -r cfef8800c7fe lib/libutil/getbyteorder.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libutil/getbyteorder.3 Thu May 02 07:17:09 2013 +0000
@@ -0,0 +1,59 @@
+.\" $NetBSD: getbyteorder.3,v 1.1 2013/05/02 07:17:09 matt Exp $
+.\"
+.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jason R. Thorpe.
+.\"
+.\" 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+.\"
+.Dd May 1, 2013
+.Dt GETBYTEORDER 3
+.Os
+.Sh NAME
+.Nm getbyteorder
+.Nd get the current byte order
+.Sh LIBRARY
+.Lb libutil
+.Sh SYNOPSIS
+.In util.h
+.In sys/endian.h
+.Ft int
+.Fn getbyteorder void
+.Sh DESCRIPTION
+.Fn getbyteorder
+returns LITTLE_ENDIAN, BIG_ENDIAN,
+or \-1 in case of an error, setting the global
+.Va errno
+variable.
+The possible values for
+.Va errno
+are the same as in
+.Xr sysctl 3 .
+.Sh SEE ALSO
+.Xr sysctl 3
+.Sh HISTORY
+The
+.Fn getbyteorder
+function call appeared in
+.Nx 7 .
diff -r 8d7cd1a4ee38 -r cfef8800c7fe lib/libutil/getbyteorder.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libutil/getbyteorder.c Thu May 02 07:17:09 2013 +0000
@@ -0,0 +1,54 @@
+/* $NetBSD: getbyteorder.c,v 1.1 2013/05/02 07:17:10 matt Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: getbyteorder.c,v 1.1 2013/05/02 07:17:10 matt Exp $");
+#endif
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <util.h>
+
+int
+getbyteorder(void)
+{
+ int byteorder, mib[2];
+ size_t varlen;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_BYTEORDER;
+ varlen = sizeof(byteorder);
+ if (sysctl(mib, 2, &byteorder, &varlen, NULL, (size_t)0) < 0)
+ return (-1);
+
+ return (byteorder);
+}
- Prev by Date:
[src/trunk]: src This change arm, armeb, earm, earmeb, earmhf, earmhfeb so al...
- Next by Date:
[src/trunk]: src/include Add getbyteorder(void) prototype.
- Previous by Thread:
[src/trunk]: src This change arm, armeb, earm, earmeb, earmhf, earmhfeb so al...
- Next by Thread:
[src/trunk]: src/include Add getbyteorder(void) prototype.
- Indexes:
Home |
Main Index |
Thread Index |
Old Index