Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)

- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
Lionel Sambuc 2013-12-06 12:04:52 +01:00
parent ff10274392
commit 84d9c625bf
4655 changed files with 379317 additions and 151059 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.299 2012/08/17 16:22:27 joerg Exp $ # $NetBSD: Makefile,v 1.303 2013/07/16 09:52:21 joerg Exp $
# #
# This is the top-level makefile for building NetBSD. For an outline of # This is the top-level makefile for building NetBSD. For an outline of
@ -87,11 +87,11 @@
# do-top-obj: creates the top level object directory. # do-top-obj: creates the top level object directory.
# do-tools-obj: creates object directories for the host toolchain. # do-tools-obj: creates object directories for the host toolchain.
# do-tools: builds host toolchain. # do-tools: builds host toolchain.
# params: record the values of variables that might affect the
# build.
# obj: creates object directories. # obj: creates object directories.
# do-distrib-dirs: creates the distribution directories. # do-distrib-dirs: creates the distribution directories.
# includes: installs include files. # includes: installs include files.
# do-tools-compat: builds the "libnbcompat" library; needed for some
# random host tool programs in the source tree.
# do-lib: builds and installs prerequisites from lib # do-lib: builds and installs prerequisites from lib
# if ${MKCOMPAT} != "no". # if ${MKCOMPAT} != "no".
# do-compat-lib: builds and installs prerequisites from compat/lib # do-compat-lib: builds and installs prerequisites from compat/lib
@ -137,15 +137,14 @@ _SRC_TOP_OBJ_=
# _SUBDIR is used to set SUBDIR, after removing directories that have # _SUBDIR is used to set SUBDIR, after removing directories that have
# BUILD_${dir}=no, or that have no ${dir}/Makefile. # BUILD_${dir}=no, or that have no ${dir}/Makefile.
# #
_SUBDIR= tools lib .WAIT include gnu external crypto/external bin games _SUBDIR= tools lib include gnu external crypto/external bin games
_SUBDIR+= libexec sbin usr.bin
_SUBDIR+= commands man
_SUBDIR+= common drivers kernel servers
_SUBDIR+= usr.sbin share rescue sys etc test tests compat .WAIT distrib regress
.if defined(__MINIX) .if defined(__MINIX)
_SUBDIR+= benchmarks _SUBDIR+= commands man benchmarks test
.endif _SUBDIR+= kernel servers drivers
.endif # defined(__MINIX)
_SUBDIR+= libexec sbin usr.bin
_SUBDIR+= usr.sbin share sys etc tests compat
_SUBDIR+= .WAIT rescue .WAIT distrib regress
.for dir in ${_SUBDIR} .for dir in ${_SUBDIR}
.if "${dir}" == ".WAIT" \ .if "${dir}" == ".WAIT" \
@ -232,6 +231,7 @@ BUILDTARGETS+= do-tools-obj
.endif .endif
BUILDTARGETS+= do-tools BUILDTARGETS+= do-tools
.endif # USETOOLS # } .endif # USETOOLS # }
BUILDTARGETS+= params
.if ${MKOBJDIRS} != "no" .if ${MKOBJDIRS} != "no"
BUILDTARGETS+= obj BUILDTARGETS+= obj
.endif .endif
@ -264,6 +264,32 @@ BUILDTARGETS+= do-obsolete
includes-lib: .PHONY includes-include includes-sys includes-lib: .PHONY includes-include includes-sys
includes-gnu: .PHONY includes-lib includes-gnu: .PHONY includes-lib
#
# Record the values of variables that might affect the build.
# If no values have changed, avoid updating the timestamp
# of the params file.
#
# This is referenced by _NETBSD_VERSION_DEPENDS in <bsd.own.mk>.
#
.include "${NETBSDSRCDIR}/etc/Makefile.params"
CLEANDIRFILES+= params
params: .EXEC
${_MKMSG_CREATE} params
@${PRINT_PARAMS} >${.TARGET}.new
@if cmp -s ${.TARGET}.new ${.TARGET} > /dev/null 2>&1; then \
: "params is unchanged" ; \
rm ${.TARGET}.new ; \
else \
: "params has changed or is new" ; \
mv ${.TARGET}.new ${.TARGET} ; \
fi
#
# Display current make(1) parameters
#
show-params: .PHONY .MAKE
@${PRINT_PARAMS}
# #
# Build the system and install into DESTDIR. # Build the system and install into DESTDIR.
# #
@ -342,7 +368,7 @@ installworld: .PHONY .MAKE
.endif .endif
.if !defined(INSTALLWORLDDIR) || \ .if !defined(INSTALLWORLDDIR) || \
${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/"
.if (${HOST_UNAME_S} != "Minix") .if (${HOST_UNAME_S} != "NetBSD") && (${HOST_UNAME_S} != "Minix")
@echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to Minix with INSTALLWORLDDIR=/" @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to Minix with INSTALLWORLDDIR=/"
@false @false
.endif .endif
@ -468,12 +494,8 @@ do-${targ}: .PHONY ${targ}
@true @true
.endfor .endfor
.for dir in tools tools/compat do-tools: .PHONY .MAKE
do-${dir:S/\//-/g}: .PHONY .MAKE ${MAKEDIRTARGET} tools build_install
.for targ in dependall install
${MAKEDIRTARGET} ${dir} ${targ}
.endfor
.endfor
do-lib: .PHONY .MAKE do-lib: .PHONY .MAKE
${MAKEDIRTARGET} lib build_install ${MAKEDIRTARGET} lib build_install
@ -540,9 +562,3 @@ dependall-distrib depend-distrib all-distrib: .PHONY
.include <bsd.obj.mk> .include <bsd.obj.mk>
.include <bsd.kernobj.mk> .include <bsd.kernobj.mk>
.include <bsd.subdir.mk> .include <bsd.subdir.mk>
#
# Display current make(1) parameters
#
params: .PHONY .MAKE
${MAKEDIRTARGET} etc params

16
Makefile.inc Normal file
View file

@ -0,0 +1,16 @@
# $NetBSD: Makefile.inc,v 1.4 2002/04/10 14:53:43 lukem Exp $
.ifndef ABSTOP
ABSTOP!= cd ${.PARSEDIR}; pwd
.if (${.PARSEDIR} == ${.CURDIR})
RELTOP:= .
.else
RELTOP:= ${.PARSEDIR:S,^${.CURDIR},,}
.endif
# you can set BSD{SRC,OBJ}DIR in Makefile.local.inc
.if exists(${ABSTOP}/Makefile.local.inc)
.include "${ABSTOP}/Makefile.local.inc"
.endif
.endif

View file

@ -1,7 +1,8 @@
# $NetBSD: Makefile,v 1.22 2007/12/31 15:31:24 ad Exp $ # $NetBSD: Makefile,v 1.22 2007/12/31 15:31:24 ad Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93 # @(#)Makefile 8.1 (Berkeley) 5/31/93
SUBDIR= cat date df echo ed expr kill ksh ln ls \ SUBDIR= cat date df echo ed expr \
mkdir pax pwd rm rmdir sync test stty kill ksh ln ls mkdir pax pwd rm rmdir \
stty sync test
.include <bsd.subdir.mk> .include <bsd.subdir.mk>

View file

@ -1,4 +1,4 @@
.\" $NetBSD: cat.1,v 1.34 2012/08/09 07:26:28 dholland Exp $ .\" $NetBSD: cat.1,v 1.36 2012/11/10 18:41:10 wiz Exp $
.\" .\"
.\" Copyright (c) 1989, 1990, 1993 .\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -32,7 +32,7 @@
.\" .\"
.\" @(#)cat.1 8.3 (Berkeley) 5/2/95 .\" @(#)cat.1 8.3 (Berkeley) 5/2/95
.\" .\"
.Dd April 6, 2012 .Dd November 10, 2012
.Dt CAT 1 .Dt CAT 1
.Os .Os
.Sh NAME .Sh NAME
@ -41,6 +41,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl beflnstuv .Op Fl beflnstuv
.Op Fl B Ar bsize
.Op Fl .Op Fl
.Op Ar .Op Ar
.Sh DESCRIPTION .Sh DESCRIPTION
@ -65,6 +66,11 @@ is just a verbose synonym for
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl B Ar bsize
Read with a buffer size of
.Ar bsize
bytes, instead of the default buffer size which is the blocksize of the
output file.
.It Fl b .It Fl b
Implies the Implies the
.Fl n .Fl n

View file

@ -1,4 +1,4 @@
/* $NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $ */ /* $NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $ */
/* /*
* Copyright (c) 1989, 1993 * Copyright (c) 1989, 1993
@ -44,7 +44,7 @@ __COPYRIGHT(
#if 0 #if 0
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95"; static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
#else #else
__RCSID("$NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $"); __RCSID("$NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -61,11 +61,11 @@ __RCSID("$NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $");
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
int bflag, eflag, fflag, lflag, nflag, sflag, tflag, vflag; static int bflag, eflag, fflag, lflag, nflag, sflag, tflag, vflag;
int rval; static size_t bsize;
const char *filename; static int rval;
static const char *filename;
int main(int, char *[]);
void cook_args(char *argv[]); void cook_args(char *argv[]);
void cook_buf(FILE *); void cook_buf(FILE *);
void raw_args(char *argv[]); void raw_args(char *argv[]);
@ -80,8 +80,11 @@ main(int argc, char *argv[])
setprogname(argv[0]); setprogname(argv[0]);
(void)setlocale(LC_ALL, ""); (void)setlocale(LC_ALL, "");
while ((ch = getopt(argc, argv, "beflnstuv")) != -1) while ((ch = getopt(argc, argv, "B:beflnstuv")) != -1)
switch (ch) { switch (ch) {
case 'B':
bsize = (size_t)strtol(optarg, NULL, 0);
break;
case 'b': case 'b':
bflag = nflag = 1; /* -b implies -n */ bflag = nflag = 1; /* -b implies -n */
break; break;
@ -112,9 +115,9 @@ main(int argc, char *argv[])
default: default:
case '?': case '?':
(void)fprintf(stderr, (void)fprintf(stderr,
"usage: cat [-beflnstuv] [-] [file ...]\n"); "Usage: %s [-beflnstuv] [-B bsize] [-] "
exit(EXIT_FAILURE); "[file ...]\n", getprogname());
/* NOTREACHED */ return EXIT_FAILURE;
} }
argv += optind; argv += optind;
@ -133,7 +136,7 @@ main(int argc, char *argv[])
raw_args(argv); raw_args(argv);
if (fclose(stdout)) if (fclose(stdout))
err(EXIT_FAILURE, "stdout"); err(EXIT_FAILURE, "stdout");
return (rval); return rval;
} }
void void
@ -286,7 +289,6 @@ raw_cat(int rfd)
{ {
static char *buf; static char *buf;
static char fb_buf[BUFSIZ]; static char fb_buf[BUFSIZ];
static size_t bsize;
ssize_t nr, nw, off; ssize_t nr, nw, off;
int wfd; int wfd;
@ -295,10 +297,15 @@ raw_cat(int rfd)
if (buf == NULL) { if (buf == NULL) {
struct stat sbuf; struct stat sbuf;
if (fstat(wfd, &sbuf) == 0 && sbuf.st_blksize > 0 && if (bsize == 0) {
(size_t)sbuf.st_blksize > sizeof(fb_buf)) { if (fstat(wfd, &sbuf) == 0 && sbuf.st_blksize > 0 &&
bsize = sbuf.st_blksize; (size_t)sbuf.st_blksize > sizeof(fb_buf))
bsize = sbuf.st_blksize;
}
if (bsize > sizeof(fb_buf)) {
buf = malloc(bsize); buf = malloc(bsize);
if (buf == NULL)
warnx("malloc, using %zu buffer", bsize);
} }
if (buf == NULL) { if (buf == NULL) {
bsize = sizeof(fb_buf); bsize = sizeof(fb_buf);

View file

@ -7,9 +7,6 @@ DPADD+= ${LIBUTIL}
LDADD+= -lutil LDADD+= -lutil
CPPFLAGS+=-I${.CURDIR} CPPFLAGS+=-I${.CURDIR}
TZDIR= /usr/share/zoneinfo
CPPFLAGS+= -DHAVE_ADJTIME=0 -DTZDIR=\"$(TZDIR)\"
COPTS.date.c = -Wno-format-nonliteral COPTS.date.c = -Wno-format-nonliteral
.include <bsd.prog.mk> .include <bsd.prog.mk>

View file

@ -1,4 +1,4 @@
.\" $NetBSD: date.1,v 1.41 2010/02/04 22:56:11 wiz Exp $ .\" $NetBSD: date.1,v 1.42 2012/04/06 11:36:56 wiz Exp $
.\" .\"
.\" Copyright (c) 1980, 1990, 1993 .\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -84,7 +84,7 @@ The utility
.Xr timed 8 .Xr timed 8
is used to synchronize the clocks on groups of machines. is used to synchronize the clocks on groups of machines.
By default, if By default, if
timed .Xr timed 8
is running, is running,
.Nm .Nm
will set the time on all of the machines in the local group. will set the time on all of the machines in the local group.
@ -153,7 +153,7 @@ The second of the minute, from 00 to 61.
.Pp .Pp
Everything but the minutes is optional. Everything but the minutes is optional.
.Pp .Pp
Time changes for Daylight Saving and Standard time and leap seconds Time changes for Daylight Saving and Standard Time and leap seconds
and years are handled automatically. and years are handled automatically.
.Sh ENVIRONMENT .Sh ENVIRONMENT
The following environment variables affect the execution of The following environment variables affect the execution of
@ -217,12 +217,13 @@ On these occasions,
prints: prints:
.Ql Network time being set . .Ql Network time being set .
The message The message
.Ql Communication error with timed .Ql Communication error with
.Xr timed 8
occurs when the communication occurs when the communication
between between
.Nm .Nm
and and
timed .Xr timed 8
fails. fails.
.Sh SEE ALSO .Sh SEE ALSO
.Xr adjtime 2 , .Xr adjtime 2 ,
@ -231,6 +232,7 @@ fails.
.Xr parsedate 3 , .Xr parsedate 3 ,
.Xr strftime 3 , .Xr strftime 3 ,
.Xr utmp 5 , .Xr utmp 5 ,
.Xr environ 7 ,
.Xr timed 8 .Xr timed 8
.Rs .Rs
.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"

View file

@ -92,11 +92,11 @@ main(int argc, char *argv[])
nflag = 1; nflag = 1;
break; break;
case 'd': case 'd':
#ifndef __minix #if !defined(__minix)
rflag = 1; rflag = 1;
tval = parsedate(optarg, NULL, NULL); tval = parsedate(optarg, NULL, NULL);
if (tval == -1) if (tval == -1)
#endif #endif /* !defined(__minix) */
badarg: errx(EXIT_FAILURE, badarg: errx(EXIT_FAILURE,
"Cannot parse `%s'", optarg); "Cannot parse `%s'", optarg);
break; break;
@ -311,19 +311,12 @@ setthetime(const char *p)
/* set the time */ /* set the time */
if (nflag || netsettime(new_time)) { if (nflag || netsettime(new_time)) {
logwtmp("|", "date", ""); logwtmp("|", "date", "");
#if HAVE_ADJTIME
if (aflag) { if (aflag) {
tv.tv_sec = new_time - tval; tv.tv_sec = new_time - tval;
tv.tv_usec = 0; tv.tv_usec = 0;
if (adjtime(&tv, NULL)) if (adjtime(&tv, NULL))
err(EXIT_FAILURE, "adjtime"); err(EXIT_FAILURE, "adjtime");
} } else {
#else
if (aflag) {
err(EXIT_FAILURE, "no adjtime");
}
#endif
else {
tval = new_time; tval = new_time;
tv.tv_sec = tval; tv.tv_sec = tval;
tv.tv_usec = 0; tv.tv_usec = 0;

View file

@ -1,4 +1,4 @@
/* $NetBSD: re.c,v 1.19 2005/02/17 16:29:26 xtraeme Exp $ */ /* $NetBSD: re.c,v 1.20 2013/06/28 15:04:35 joerg Exp $ */
/* re.c: This file contains the regular expression interface routines for /* re.c: This file contains the regular expression interface routines for
the ed line editor. */ the ed line editor. */
@ -33,7 +33,7 @@
#if 0 #if 0
static char *rcsid = "@(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp"; static char *rcsid = "@(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp";
#else #else
__RCSID("$NetBSD: re.c,v 1.19 2005/02/17 16:29:26 xtraeme Exp $"); __RCSID("$NetBSD: re.c,v 1.20 2013/06/28 15:04:35 joerg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -95,7 +95,7 @@ extract_pattern(int delimiter)
default: default:
break; break;
case '[': case '[':
if ((nd = parse_char_class(++nd)) == NULL) { if ((nd = parse_char_class(nd + 1)) == NULL) {
sprintf(errmsg, "unbalanced brackets ([])"); sprintf(errmsg, "unbalanced brackets ([])");
return NULL; return NULL;
} }

View file

@ -1,4 +1,4 @@
/* $NetBSD: c_sh.c,v 1.14 2011/08/31 16:24:54 plunky Exp $ */ /* $NetBSD: c_sh.c,v 1.15 2013/10/18 19:53:34 christos Exp $ */
/* /*
* built-in Bourne commands * built-in Bourne commands
@ -6,7 +6,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: c_sh.c,v 1.14 2011/08/31 16:24:54 plunky Exp $"); __RCSID("$NetBSD: c_sh.c,v 1.15 2013/10/18 19:53:34 christos Exp $");
#endif #endif
@ -506,6 +506,8 @@ c_trap(wp)
shprintf(" %s", p->name); shprintf(" %s", p->name);
shprintf(newline); shprintf(newline);
} }
#else
__USE(anydfl);
#endif #endif
return 0; return 0;
} }

View file

@ -1,3 +1,5 @@
/* $NetBSD: config.h,v 1.8 2004/08/19 23:00:22 christos Exp $ */
/* config.h. Generated automatically by configure. */ /* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */ /* config.h.in. Generated automatically from configure.in by autoheader. */
/* /*
@ -9,7 +11,6 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
/* Define if on AIX 3. /* Define if on AIX 3.
System headers sometimes define this. System headers sometimes define this.
We just want to avoid a redefinition error message. */ We just want to avoid a redefinition error message. */
@ -23,12 +24,11 @@
/* Define to empty if the keyword does not work. */ /* Define to empty if the keyword does not work. */
/* #undef const */ /* #undef const */
/* Define to `int' if <sys/types.h> doesn't define. */ /* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */ /* #undef gid_t */
/* Define if you have a working `mmap' system call. */ /* Define if you have a working `mmap' system call. */
/* #undef HAVE_MMAP */ #define HAVE_MMAP 1
/* Define if your struct stat has st_rdev. */ /* Define if your struct stat has st_rdev. */
#define HAVE_ST_RDEV 1 #define HAVE_ST_RDEV 1
@ -53,10 +53,10 @@
/* Define if the system does not provide POSIX.1 features except /* Define if the system does not provide POSIX.1 features except
with this defined. */ with this defined. */
#define _POSIX_1_SOURCE 2 /* #undef _POSIX_1_SOURCE */
/* Define if you need to in order for stat and other things to work. */ /* Define if you need to in order for stat and other things to work. */
#define _POSIX_SOURCE 1 /* #undef _POSIX_SOURCE */
/* Define as the return type of signal handlers (int or void). */ /* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void #define RETSIGTYPE void
@ -76,7 +76,7 @@
/* Define if the closedir function returns void instead of int. */ /* Define if the closedir function returns void instead of int. */
/* #undef VOID_CLOSEDIR */ /* #undef VOID_CLOSEDIR */
/* Define if your kernal doesn't handle scripts starting with #! */ /* Define if your kernel doesn't handle scripts starting with #! */
/* #undef SHARPBANG */ /* #undef SHARPBANG */
/* Define if dup2() preserves the close-on-exec flag (ultrix does this) */ /* Define if dup2() preserves the close-on-exec flag (ultrix does this) */
@ -146,7 +146,7 @@
#define SYS_ERRLIST_DECLARED 1 #define SYS_ERRLIST_DECLARED 1
/* Define if sys_siglist[] is in the C library */ /* Define if sys_siglist[] is in the C library */
/* #undef HAVE_SYS_SIGLIST */ #define HAVE_SYS_SIGLIST 1
/* Define if you have a sane <termios.h> header file */ /* Define if you have a sane <termios.h> header file */
#define HAVE_TERMIOS_H 1 #define HAVE_TERMIOS_H 1
@ -158,7 +158,7 @@
#define HAVE_MEMMOVE 1 #define HAVE_MEMMOVE 1
/* Define if you have a bcopy() function in your C library */ /* Define if you have a bcopy() function in your C library */
/* #undef HAVE_BCOPY */ #define HAVE_BCOPY
/* Define if you have a lstat() function in your C library */ /* Define if you have a lstat() function in your C library */
#define HAVE_LSTAT 1 #define HAVE_LSTAT 1
@ -172,6 +172,9 @@
/* Define if opendir() will open non-directory files */ /* Define if opendir() will open non-directory files */
/* #undef OPENDIR_DOES_NONDIR */ /* #undef OPENDIR_DOES_NONDIR */
/* Define if you have a dup2() function in your C library */
#define HAVE_DUP2 1
/* Define if the pgrp of setpgrp() can't be the pid of a zombie process */ /* Define if the pgrp of setpgrp() can't be the pid of a zombie process */
/* #undef NEED_PGRP_SYNC */ /* #undef NEED_PGRP_SYNC */
@ -184,50 +187,54 @@
/* Define if you arg running OS2 with the EMX library */ /* Define if you arg running OS2 with the EMX library */
/* #undef OS2 */ /* #undef OS2 */
/* Define if you have a POSIX.1 compatiable <sys/wait.h> */ /* Define if you have a POSIX.1 compatible <sys/wait.h> */
#define POSIX_SYS_WAIT 1 #define POSIX_SYS_WAIT 1
/* Define if your OS maps references to /dev/fd/n to file descriptor n */ /* Define if your OS maps references to /dev/fd/n to file descriptor n */
/* #undef HAVE_DEV_FD */ /* #undef HAVE_DEV_FD */
/* Default PATH */
#ifdef RESCUEDIR
#define DEFAULT_PATH RESCUEDIR ":/bin:/usr/bin:/sbin:/usr/sbin"
#else
#define DEFAULT_PATH "/bin:/usr/bin:/sbin:/usr/sbin"
#endif
/* Define if your C library's getwd/getcwd function dumps core in unreadable /* Define if your C library's getwd/getcwd function dumps core in unreadable
* directories. */ * directories. */
/* #undef HPUX_GETWD_BUG */ /* #undef HPUX_GETWD_BUG */
/* Default PATH (see comments in configure.in for more details) */ /* Include ksh features? */
#define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb"
/* Include ksh features? (see comments in configure.in for more details) */
#define KSH 1 #define KSH 1
/* Include emacs editing? (see comments in configure.in for more details) */ /* Include emacs editing? */
#define EMACS 1 #define EMACS 1
/* Include vi editing? (see comments in configure.in for more details) */ /* Include vi editing? */
#define VI 1 #define VI 1
/* Include job control? (see comments in configure.in for more details) */ /* Include job control? */
#define JOBS 1 #define JOBS 1
/* Include brace-expansion? (see comments in configure.in for more details) */ /* Include brace-expansion? */
#define BRACE_EXPAND 1 #define BRACE_EXPAND 1
/* Include any history? (see comments in configure.in for more details) */ /* Include any history? */
#define HISTORY 1 #define HISTORY 1
/* Include complex history? (see comments in configure.in for more details) */ /* Include complex history? */
/* #undef COMPLEX_HISTORY */ /* #undef COMPLEX_HISTORY */
/* Strict POSIX behaviour? (see comments in configure.in for more details) */ /* Strict POSIX behaviour? */
/* #undef POSIXLY_CORRECT */ #define POSIXLY_CORRECT 1
/* Specify default $ENV? (see comments in configure.in for more details) */ /* Specify default $ENV? */
/* #undef DEFAULT_ENV */ #define DEFAULT_ENV "$HOME/.kshrc"
/* Include shl(1) support? (see comments in configure.in for more details) */ /* Include shl(1) support? */
/* #undef SWTCH */ /* #undef SWTCH */
/* Include game-of-life? (see comments in configure.in for more details) */ /* Include game-of-life? */
/* #undef SILLY */ /* #undef SILLY */
/* The number of bytes in a int. */ /* The number of bytes in a int. */
@ -237,14 +244,11 @@
#define SIZEOF_LONG 4 #define SIZEOF_LONG 4
/* Define if you have the _setjmp function. */ /* Define if you have the _setjmp function. */
/* #undef HAVE__SETJMP */ #define HAVE__SETJMP
/* Define if you have the confstr function. */ /* Define if you have the confstr function. */
/* #undef HAVE_CONFSTR */ /* #undef HAVE_CONFSTR */
/* Define if you have the dup2 function. */
#define HAVE_DUP2 1
/* Define if you have the flock function. */ /* Define if you have the flock function. */
#define HAVE_FLOCK 1 #define HAVE_FLOCK 1
@ -261,7 +265,7 @@
/* #undef HAVE_GETRUSAGE */ /* #undef HAVE_GETRUSAGE */
/* Define if you have the getwd function. */ /* Define if you have the getwd function. */
/* #undef HAVE_GETWD */ #define HAVE_GETWD 1
/* Define if you have the killpg function. */ /* Define if you have the killpg function. */
#define HAVE_KILLPG 1 #define HAVE_KILLPG 1
@ -281,11 +285,6 @@
/* Define if you have the strerror function. */ /* Define if you have the strerror function. */
#define HAVE_STRERROR 1 #define HAVE_STRERROR 1
/* Define if you have the strlcat function. */
#define HAVE_STRLCAT 1
/* Define if you have the strlcpy function. */
#define HAVE_STRLCPY 1
/* Define if you have the strstr function. */ /* Define if you have the strstr function. */
#define HAVE_STRSTR 1 #define HAVE_STRSTR 1
@ -296,7 +295,7 @@
#define HAVE_TCSETPGRP 1 #define HAVE_TCSETPGRP 1
/* Define if you have the ulimit function. */ /* Define if you have the ulimit function. */
#define HAVE_ULIMIT 1 #define HAVE_ULIMIT
/* Define if you have the valloc function. */ /* Define if you have the valloc function. */
#define HAVE_VALLOC 1 #define HAVE_VALLOC 1
@ -335,7 +334,7 @@
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
/* Define if you have the <sys/dir.h> header file. */ /* Define if you have the <sys/dir.h> header file. */
/* #undef HAVE_SYS_DIR_H */ #define HAVE_SYS_DIR_H
/* Define if you have the <sys/ndir.h> header file. */ /* Define if you have the <sys/ndir.h> header file. */
/* #undef HAVE_SYS_NDIR_H */ /* #undef HAVE_SYS_NDIR_H */
@ -353,7 +352,7 @@
#define HAVE_SYS_WAIT_H 1 #define HAVE_SYS_WAIT_H 1
/* Define if you have the <ulimit.h> header file. */ /* Define if you have the <ulimit.h> header file. */
#define HAVE_ULIMIT_H 1 #define HAVE_ULIMIT_H
/* Define if you have the <values.h> header file. */ /* Define if you have the <values.h> header file. */
/* #undef HAVE_VALUES_H */ /* #undef HAVE_VALUES_H */

View file

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.14 2011/08/21 21:24:34 dholland Exp $ */ /* $NetBSD: eval.c,v 1.15 2013/10/18 19:53:34 christos Exp $ */
/* /*
* Expansion - quoting, separation, substitution, globbing * Expansion - quoting, separation, substitution, globbing
@ -6,7 +6,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: eval.c,v 1.14 2011/08/21 21:24:34 dholland Exp $"); __RCSID("$NetBSD: eval.c,v 1.15 2013/10/18 19:53:34 christos Exp $");
#endif #endif
#include <stdint.h> #include <stdint.h>
@ -729,13 +729,11 @@ varsub(xp, sp, word, stypep, slenp)
/* Check for size of array */ /* Check for size of array */
if ((p=strchr(sp,'[')) && (p[1]=='*'||p[1]=='@') && p[2]==']') { if ((p=strchr(sp,'[')) && (p[1]=='*'||p[1]=='@') && p[2]==']') {
int n = 0; int n = 0;
int max = 0;
vp = global(arrayname(sp)); vp = global(arrayname(sp));
if (vp->flag & (ISSET|ARRAY)) if (vp->flag & (ISSET|ARRAY))
zero_ok = 1; zero_ok = 1;
for (; vp; vp = vp->u.array) for (; vp; vp = vp->u.array)
if (vp->flag & ISSET) { if (vp->flag & ISSET) {
max = vp->index + 1;
n++; n++;
} }
c = n; /* ksh88/ksh93 go for number, not max index */ c = n; /* ksh88/ksh93 go for number, not max index */

View file

@ -1,9 +1,9 @@
/* $NetBSD: expand.h,v 1.4 2001/07/26 15:05:07 wiz Exp $ */ /* $NetBSD: expand.h,v 1.5 2013/10/18 19:53:34 christos Exp $ */
/* /*
* Expanding strings * Expanding strings
*/ */
/* $Id: expand.h,v 1.4 2001/07/26 15:05:07 wiz Exp $ */ /* $Id: expand.h,v 1.5 2013/10/18 19:53:34 christos Exp $ */
#define X_EXTRA 8 /* this many extra bytes in X string */ #define X_EXTRA 8 /* this many extra bytes in X string */
@ -40,6 +40,7 @@ typedef char * XStringP;
(xs).beg = alloc((xs).len + X_EXTRA, (xs).areap); \ (xs).beg = alloc((xs).len + X_EXTRA, (xs).areap); \
(xs).end = (xs).beg + (xs).len; \ (xs).end = (xs).beg + (xs).len; \
xp = (xs).beg; \ xp = (xs).beg; \
__USE(xp); \
} while (0) } while (0)
/* stuff char into string */ /* stuff char into string */

View file

@ -741,7 +741,8 @@ hist_finish()
{ {
static int once; static int once;
int fd; int fd;
#if !defined(O_EXLOCK) && defined(LOCK_EX) #if defined(__minix)
/* LSC: FIXME: Minix doesn't implement O_EXLOCK yet. */
int rc; int rc;
#endif #endif
FILE *fh; FILE *fh;
@ -760,13 +761,8 @@ hist_finish()
else else
hp = histlist; hp = histlist;
fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0777);
#ifdef O_EXLOCK #if defined(__minix)
| O_EXLOCK
#endif
, 0777);
#if !defined(O_EXLOCK) && defined(LOCK_EX)
do { do {
rc = flock(fd, LOCK_EX); rc = flock(fd, LOCK_EX);
if (rc == -1 && errno != EINTR) if (rc == -1 && errno != EINTR)
@ -779,7 +775,7 @@ hist_finish()
if (fd >= 0 && (fh = fdopen(fd, "w"))) { if (fd >= 0 && (fh = fdopen(fd, "w"))) {
for (i = 0; hp + i <= histptr && hp[i]; i++) for (i = 0; hp + i <= histptr && hp[i]; i++)
fprintf(fh, "%s%c", hp[i], '\0'); fprintf(fh, "%s%c", hp[i], '\0');
#if !defined(O_EXLOCK) && defined(LOCK_EX) #if defined(__minix)
flock(fd, LOCK_UN); flock(fd, LOCK_UN);
#endif #endif
fclose(fh); fclose(fh);

View file

@ -1,4 +1,4 @@
.\" $NetBSD: ls.1,v 1.69 2011/04/02 08:38:56 mbalmer Exp $ .\" $NetBSD: ls.1,v 1.72 2012/11/20 12:37:29 abs Exp $
.\" .\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -32,7 +32,7 @@
.\" .\"
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94 .\" @(#)ls.1 8.7 (Berkeley) 7/29/94
.\" .\"
.Dd April 2, 2011 .Dd November 20, 2012
.Dt LS 1 .Dt LS 1
.Os .Os
.Sh NAME .Sh NAME
@ -40,19 +40,19 @@
.Nd list directory contents .Nd list directory contents
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl AaBbCcdFfghikLlMmnopqRrSsTtuWwx1 .Op Fl 1AaBbCcdFfghikLlMmnopqRrSsTtuWwx
.Op Ar .Op Ar
.Sh DESCRIPTION .Sh DESCRIPTION
For each operand that names a For each
.Ar file .Ar file
of a type other than operand that names a file of a type other than
directory, directory,
.Nm .Nm
displays its name as well as any requested, displays its name as well as any requested,
associated information. associated information.
For each operand that names a For each
.Ar file .Ar file
of type directory, operand that names a file of type directory,
.Nm .Nm
displays the names of files contained displays the names of files contained
within that directory, as well as any requested, associated within that directory, as well as any requested, associated
@ -67,6 +67,11 @@ lexicographical order.
.Pp .Pp
The following options are available: The following options are available:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl \&1
(The numeric digit
.Dq one ) .
Force output to be one entry per line.
This is the default when output is not to a terminal.
.It Fl A .It Fl A
List all entries except for List all entries except for
.Ql \&. .Ql \&.
@ -88,13 +93,18 @@ but use C escape codes whenever possible.
Force multi-column output; this is the default when output is to a terminal. Force multi-column output; this is the default when output is to a terminal.
.It Fl c .It Fl c
Use time when file status was last changed, Use time when file status was last changed,
instead of time of last modification of the file for sorting instead of time of last modification of the file for printing
.Pq Fl t .Pq Fl l
or printing or sorting
.Pq Fl l . .Pq Fl t .
Overrides
.Fl u .
.It Fl d .It Fl d
Directories are listed as plain files (not searched recursively) and Directories are listed as plain files (not searched recursively) and
symbolic links in the argument list are not followed. symbolic links in the argument list are not followed.
Turns off
.Fl R
if also given.
.It Fl F .It Fl F
Display a slash Display a slash
.Pq Sq \&/ .Pq Sq \&/
@ -123,9 +133,9 @@ The same as
except that the owner is not printed. except that the owner is not printed.
.It Fl h .It Fl h
Modifies the Modifies the
.Fl s
and
.Fl l .Fl l
and
.Fl s
options, causing the sizes to be reported in bytes displayed in a human options, causing the sizes to be reported in bytes displayed in a human
readable format. readable format.
Overrides Overrides
@ -138,15 +148,8 @@ For each file, print the file's file serial number (inode number).
Modifies the Modifies the
.Fl s .Fl s
option, causing the sizes to be reported in kilobytes. option, causing the sizes to be reported in kilobytes.
The rightmost of the Overrides
.Fl k .Fl h .
and
.Fl h
flags overrides the previous flag.
See also
.Fl h
and
.Fl M .
.It Fl L .It Fl L
For each file, if it's a link, evaluate file information and file type For each file, if it's a link, evaluate file information and file type
of the referenced file and not the link itself; however still print of the referenced file and not the link itself; however still print
@ -169,8 +172,8 @@ options, causing the sizes or block counts reported to be separated with
commas (or a locale appropriate separator) resulting in a more readable commas (or a locale appropriate separator) resulting in a more readable
output. output.
Overrides Overrides
.Fl h . .Fl h ;
Does not override does not override
.Fl k . .Fl k .
.It Fl m .It Fl m
Stream output format; list files across the page, separated by commas. Stream output format; list files across the page, separated by commas.
@ -201,6 +204,8 @@ the character
this is the default when output is to a terminal. this is the default when output is to a terminal.
.It Fl R .It Fl R
Recursively list subdirectories encountered. Recursively list subdirectories encountered.
See also
.Fl d .
.It Fl r .It Fl r
Reverse the order of the sort to get reverse Reverse the order of the sort to get reverse
lexicographical order or the smallest or oldest entries first. lexicographical order or the smallest or oldest entries first.
@ -230,10 +235,12 @@ order.
.It Fl u .It Fl u
Use time of last access, Use time of last access,
instead of last modification instead of last modification
of the file for sorting of the file for printing
.Pq Fl t .Pq Fl l
or printing or sorting
.Pq Fl l . .Pq Fl t .
Overrides
.Fl c .
.It Fl W .It Fl W
Display whiteouts when scanning directories. Display whiteouts when scanning directories.
.It Fl w .It Fl w
@ -241,19 +248,14 @@ Force raw printing of non-printable characters.
This is the default when output is not to a terminal. This is the default when output is not to a terminal.
.It Fl x .It Fl x
Multi-column output sorted across the page rather than down the page. Multi-column output sorted across the page rather than down the page.
.It Fl \&1
(The numeric digit
.Dq one ) .
Force output to be one entry per line.
This is the default when output is not to a terminal.
.El .El
.Pp .Pp
The The
.Fl B , .Fl B ,
.Fl b , .Fl b ,
.Fl w , .Fl q ,
and and
.Fl q .Fl w
options all override each other; the last one specified determines options all override each other; the last one specified determines
the format used for non-printable characters. the format used for non-printable characters.
.Pp .Pp
@ -278,13 +280,6 @@ even if
.Fl g .Fl g
was specified last. was specified last.
.Pp .Pp
The
.Fl c
and
.Fl u
options override each other; the last one specified determines
the file time used.
.Pp
By default, By default,
.Nm .Nm
lists one entry per line to standard lists one entry per line to standard
@ -296,11 +291,11 @@ options are specified.
.Pp .Pp
File information is displayed with one or more File information is displayed with one or more
.Aq blank .Aq blank
separating the information associated with the characters separating the information associated with the
.Fl i , .Fl i ,
.Fl s , .Fl l ,
and and
.Fl l .Fl s
options. options.
.Ss The Long Format .Ss The Long Format
If the If the
@ -333,9 +328,12 @@ pathname
.El .El
.Pp .Pp
In addition, for each directory whose contents are displayed, the total In addition, for each directory whose contents are displayed, the total
number of 512-byte blocks used by the files in the directory is displayed number of file system blocks in units of 512 bytes or
on a line by itself immediately before the information for the files in the .Ev BLOCKSIZE
directory. (see
.Sx ENVIRONMENT )
used by the files in the directory is displayed on a line by itself
immediately before the information for the files in the directory.
.Pp .Pp
If the owner or group names are not a known owner or group name, If the owner or group names are not a known owner or group name,
or the or the
@ -358,6 +356,8 @@ The entry type character describes the type of file, as
follows: follows:
.Pp .Pp
.Bl -tag -width 4n -offset indent -compact .Bl -tag -width 4n -offset indent -compact
.It Sy \-
Regular file.
.It Sy a .It Sy a
Archive state 1. Archive state 1.
.It Sy A .It Sy A
@ -370,14 +370,12 @@ Character special file.
Directory. Directory.
.It Sy l .It Sy l
Symbolic link. Symbolic link.
.It Sy s
Socket link.
.It Sy p .It Sy p
FIFO. FIFO.
.It Sy s
Socket link.
.It Sy w .It Sy w
Whiteout. Whiteout.
.It Sy \-
Regular file.
.El .El
.Pp .Pp
The next three fields The next three fields
@ -457,11 +455,11 @@ The following environment variables affect the execution of
If the environment variable If the environment variable
.Ev BLOCKSIZE .Ev BLOCKSIZE
is set, and the is set, and the
.Fl h
and
.Fl k .Fl k
options are not specified, the block counts option is not specified, the block counts
(see (see
.Fl l
and
.Fl s ) .Fl s )
will be displayed in units of that size block. will be displayed in units of that size block.
.It Ev COLUMNS .It Ev COLUMNS

View file

@ -1,4 +1,4 @@
/* $NetBSD: ls.c,v 1.69 2011/08/29 14:44:21 joerg Exp $ */ /* $NetBSD: ls.c,v 1.70 2012/11/20 12:37:29 abs Exp $ */
/* /*
* Copyright (c) 1989, 1993, 1994 * Copyright (c) 1989, 1993, 1994
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94"; static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94";
#else #else
__RCSID("$NetBSD: ls.c,v 1.69 2011/08/29 14:44:21 joerg Exp $"); __RCSID("$NetBSD: ls.c,v 1.70 2012/11/20 12:37:29 abs Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -117,7 +117,7 @@ usage(void)
{ {
(void)fprintf(stderr, (void)fprintf(stderr,
"usage: %s [-AaBbCcdFfghikLlMmnopqRrSsTtuWwx1] [file ...]\n", "usage: %s [-1AaBbCcdFfghikLlMmnopqRrSsTtuWwx] [file ...]\n",
getprogname()); getprogname());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* NOTREACHED */ /* NOTREACHED */
@ -331,7 +331,7 @@ ls_main(int argc, char *argv[])
fts_options |= FTS_WHITEOUT; fts_options |= FTS_WHITEOUT;
#endif #endif
/* If -l or -s, figure out block size. */ /* If -i, -l, or -s, figure out block size. */
if (f_inode || f_longform || f_size) { if (f_inode || f_longform || f_size) {
if (!kflag) if (!kflag)
(void)getbsize(NULL, &blocksize); (void)getbsize(NULL, &blocksize);

View file

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.51 2012/06/29 12:51:38 yamt Exp $ */ /* $NetBSD: print.c,v 1.52 2013/05/02 22:43:55 zafer Exp $ */
/* /*
* Copyright (c) 1989, 1993, 1994 * Copyright (c) 1989, 1993, 1994
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94"; static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94";
#else #else
__RCSID("$NetBSD: print.c,v 1.51 2012/06/29 12:51:38 yamt Exp $"); __RCSID("$NetBSD: print.c,v 1.52 2013/05/02 22:43:55 zafer Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -461,4 +461,3 @@ printlink(FTSENT *p)
else else
(void)printf("%s", path); (void)printf("%s", path);
} }

View file

@ -2,9 +2,5 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93 # @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= mkdir PROG= mkdir
.ifdef __MINIX
WARNS=3
SYMLINKS= $(BINDIR)/$(PROG) /usr/bin/$(PROG)
.endif
.include <bsd.prog.mk> .include <bsd.prog.mk>

View file

@ -1,4 +1,4 @@
.\" $NetBSD: mkdir.1,v 1.16 2003/08/07 09:05:16 agc Exp $ .\" $NetBSD: mkdir.1,v 1.17 2012/03/22 07:58:17 wiz Exp $
.\" .\"
.\" Copyright (c) 1989, 1990, 1993 .\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -49,7 +49,7 @@ creates the directories named as operands, in the order specified,
using mode using mode
.Li rwxrwxrwx (\&0777) .Li rwxrwxrwx (\&0777)
as modified by the current as modified by the current
.Xr umask 2 . .Xr umask 2 .
.Pp .Pp
The options are as follows: The options are as follows:
.Pp .Pp

View file

@ -1,4 +1,4 @@
/* $NetBSD: mkdir.c,v 1.37 2008/07/20 00:52:40 lukem Exp $ */ /* $NetBSD: mkdir.c,v 1.38 2011/08/29 14:45:28 joerg Exp $ */
/* /*
* Copyright (c) 1983, 1992, 1993 * Copyright (c) 1983, 1992, 1993
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1992, 1993\
#if 0 #if 0
static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94"; static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94";
#else #else
__RCSID("$NetBSD: mkdir.c,v 1.37 2008/07/20 00:52:40 lukem Exp $"); __RCSID("$NetBSD: mkdir.c,v 1.38 2011/08/29 14:45:28 joerg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -55,9 +55,8 @@ __RCSID("$NetBSD: mkdir.c,v 1.37 2008/07/20 00:52:40 lukem Exp $");
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
int mkpath(char *, mode_t, mode_t); static int mkpath(char *, mode_t, mode_t);
void usage(void); __dead static void usage(void);
int main(int, char *[]);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
@ -149,7 +148,7 @@ main(int argc, char *argv[])
* mode - file mode of terminal directory * mode - file mode of terminal directory
* dir_mode - file mode of intermediate directories * dir_mode - file mode of intermediate directories
*/ */
int static int
mkpath(char *path, mode_t mode, mode_t dir_mode) mkpath(char *path, mode_t mode, mode_t dir_mode)
{ {
struct stat sb; struct stat sb;
@ -213,7 +212,7 @@ mkpath(char *path, mode_t mode, mode_t dir_mode)
return 0; return 0;
} }
void static void
usage(void) usage(void)
{ {

View file

@ -3,10 +3,6 @@
.include <bsd.own.mk> .include <bsd.own.mk>
.if defined(__MINIX)
WARNS=2
.endif
PROG= pax PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c file_subs.c ftree.c\ SRCS= ar_io.c ar_subs.c buf_subs.c file_subs.c ftree.c\
gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\ gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\

View file

@ -1,4 +1,4 @@
/* $NetBSD: file_subs.c,v 1.62 2009/04/07 19:52:35 perry Exp $ */ /* $NetBSD: file_subs.c,v 1.63 2013/07/29 17:46:36 christos Exp $ */
/*- /*-
* Copyright (c) 1992 Keith Muller. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: file_subs.c,v 1.62 2009/04/07 19:52:35 perry Exp $"); __RCSID("$NetBSD: file_subs.c,v 1.63 2013/07/29 17:46:36 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -62,9 +62,9 @@ __RCSID("$NetBSD: file_subs.c,v 1.62 2009/04/07 19:52:35 perry Exp $");
#include "extern.h" #include "extern.h"
#include "options.h" #include "options.h"
#ifdef __minix #if defined(__minix)
#include <utime.h> #include <utime.h>
#endif #endif /* defined(__minix) */
char *xtmp_name; char *xtmp_name;
@ -164,7 +164,7 @@ file_creat(ARCHD *arcn, int write_to_hardlink)
* in the path until chk_path() finds that it cannot fix * in the path until chk_path() finds that it cannot fix
* anything further. if that happens we just give up. * anything further. if that happens we just give up.
*/ */
#ifdef __minix #if defined(__minix)
{ {
/* For minix, generate the temporary filename /* For minix, generate the temporary filename
* conservatively - just write Xes into the last component. * conservatively - just write Xes into the last component.
@ -179,7 +179,7 @@ file_creat(ARCHD *arcn, int write_to_hardlink)
#else #else
(void)snprintf(arcn->tmp_name, arcn->nlen + 8, "%s.XXXXXX", (void)snprintf(arcn->tmp_name, arcn->nlen + 8, "%s.XXXXXX",
arcn->name); arcn->name);
#endif #endif /* defined(__minix) */
fd = mkstemp(arcn->tmp_name); fd = mkstemp(arcn->tmp_name);
if (fd >= 0) if (fd >= 0)
break; break;
@ -809,9 +809,9 @@ set_ftime(char *fnm, time_t mtime, time_t atime, int frc, int slk)
struct timeval tv[2]; struct timeval tv[2];
struct stat sb; struct stat sb;
tv[0].tv_sec = (long)atime; tv[0].tv_sec = atime;
tv[0].tv_usec = 0; tv[0].tv_usec = 0;
tv[1].tv_sec = (long)mtime; tv[1].tv_sec = mtime;
tv[1].tv_usec = 0; tv[1].tv_usec = 0;
if (!frc && (!patime || !pmtime)) { if (!frc && (!patime || !pmtime)) {
/* /*

View file

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.114 2012/08/09 11:05:59 christos Exp $ */ /* $NetBSD: options.c,v 1.115 2013/11/14 04:00:48 christos Exp $ */
/*- /*-
* Copyright (c) 1992 Keith Muller. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
#else #else
__RCSID("$NetBSD: options.c,v 1.114 2012/08/09 11:05:59 christos Exp $"); __RCSID("$NetBSD: options.c,v 1.115 2013/11/14 04:00:48 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -128,8 +128,9 @@ static int get_line_error;
#define OPT_STRICT 15 #define OPT_STRICT 15
#define OPT_SPARSE 16 #define OPT_SPARSE 16
#define OPT_XZ 17 #define OPT_XZ 17
#define OPT_GNU 18
#if !HAVE_NBTOOL_CONFIG_H #if !HAVE_NBTOOL_CONFIG_H
#define OPT_CHROOT 18 #define OPT_CHROOT 19
#endif #endif
/* /*
@ -248,6 +249,8 @@ struct option pax_longopts[] = {
OPT_USE_COMPRESS_PROGRAM }, OPT_USE_COMPRESS_PROGRAM },
{ "xz", no_argument, 0, { "xz", no_argument, 0,
OPT_XZ }, OPT_XZ },
{ "gnu", no_argument, 0,
OPT_GNU },
{ 0, 0, 0, { 0, 0, 0,
0 }, 0 },
}; };
@ -655,6 +658,9 @@ pax_options(int argc, char **argv)
case OPT_XZ: case OPT_XZ:
gzip_program = XZ_CMD; gzip_program = XZ_CMD;
break; break;
case OPT_GNU:
is_gnutar = 1;
break;
case '?': case '?':
default: default:
pax_usage(); pax_usage();

View file

@ -1,4 +1,4 @@
.\" $NetBSD: pax.1,v 1.61 2011/06/19 07:34:24 wiz Exp $ .\" $NetBSD: pax.1,v 1.63 2013/11/14 07:45:05 wiz Exp $
.\" .\"
.\" Copyright (c) 1992 Keith Muller. .\" Copyright (c) 1992 Keith Muller.
.\" Copyright (c) 1992, 1993 .\" Copyright (c) 1992, 1993
@ -33,7 +33,7 @@
.\" .\"
.\" @(#)pax.1 8.4 (Berkeley) 4/18/94 .\" @(#)pax.1 8.4 (Berkeley) 4/18/94
.\" .\"
.Dd June 18, 2011 .Dd November 13, 2013
.Dt PAX 1 .Dt PAX 1
.Os .Os
.Sh NAME .Sh NAME
@ -740,6 +740,8 @@ as the result of any specific archive format restrictions.
The individual archive formats may impose additional restrictions on use. The individual archive formats may impose additional restrictions on use.
Typical archive format restrictions include (but are not limited to): Typical archive format restrictions include (but are not limited to):
file pathname length, file size, link pathname length and the type of the file. file pathname length, file size, link pathname length and the type of the file.
.It Fl Fl gnu
Recognize GNU tar extensions.
.It Fl Fl xz .It Fl Fl xz
Use Use
.Xr xz 1 .Xr xz 1

View file

@ -374,13 +374,13 @@ sig_cleanup(int which_sig)
static int static int
gen_init(void) gen_init(void)
{ {
#ifndef __minix #if !defined(__minix)
struct rlimit reslimit; struct rlimit reslimit;
#endif #endif /* !defined(__minix) */
struct sigaction n_hand; struct sigaction n_hand;
struct sigaction o_hand; struct sigaction o_hand;
#ifndef __minix #if !defined(__minix)
/* /*
* Really needed to handle large archives. We can run out of memory for * Really needed to handle large archives. We can run out of memory for
* internal tables really fast when we have a whole lot of files... * internal tables really fast when we have a whole lot of files...
@ -416,7 +416,7 @@ gen_init(void)
(void)setrlimit(RLIMIT_RSS , &reslimit); (void)setrlimit(RLIMIT_RSS , &reslimit);
} }
#endif #endif
#endif /* __minix */ #endif /* !defined(__minix) */
/* /*
* Handle posix locale * Handle posix locale

View file

@ -37,9 +37,9 @@
#if ! HAVE_NBTOOL_CONFIG_H #if ! HAVE_NBTOOL_CONFIG_H
#define HAVE_LUTIMES 1 #define HAVE_LUTIMES 1
#ifndef __minix #if !defined(__minix)
#define HAVE_STRUCT_STAT_ST_FLAGS 1 #define HAVE_STRUCT_STAT_ST_FLAGS 1
#endif #endif /* !defined(__minix) */
#endif #endif
/* /*
@ -246,7 +246,6 @@ typedef struct oplist {
#ifdef HOSTPROG #ifdef HOSTPROG
# include "pack_dev.h" /* explicitly use NetBSD's macros */ # include "pack_dev.h" /* explicitly use NetBSD's macros */
# define MAJOR(x) major_netbsd(x) # define MAJOR(x) major_netbsd(x)
# define MINOR(x) minor_netbsd(x) # define MINOR(x) minor_netbsd(x)
# define TODEV(x, y) makedev_netbsd((x), (y)) # define TODEV(x, y) makedev_netbsd((x), (y))

View file

@ -1,4 +1,4 @@
/* $NetBSD: tables.c,v 1.30 2008/01/10 04:24:51 tls Exp $ */ /* $NetBSD: tables.c,v 1.31 2013/10/18 19:53:34 christos Exp $ */
/*- /*-
* Copyright (c) 1992 Keith Muller. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: tables.c,v 1.30 2008/01/10 04:24:51 tls Exp $"); __RCSID("$NetBSD: tables.c,v 1.31 2013/10/18 19:53:34 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -1155,7 +1155,9 @@ add_dir(char *name, int nlen, struct stat *psb, int frc_mode)
return; return;
} }
name = rp; name = rp;
#ifdef DIRS_USE_FILE
nlen = strlen(name); nlen = strlen(name);
#endif
} }
#ifdef DIRS_USE_FILE #ifdef DIRS_USE_FILE

View file

@ -1,4 +1,4 @@
/* $NetBSD: tar.c,v 1.70 2012/08/09 08:09:22 christos Exp $ */ /* $NetBSD: tar.c,v 1.71 2013/01/24 17:43:44 christos Exp $ */
/*- /*-
* Copyright (c) 1992 Keith Muller. * Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94"; static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94";
#else #else
__RCSID("$NetBSD: tar.c,v 1.70 2012/08/09 08:09:22 christos Exp $"); __RCSID("$NetBSD: tar.c,v 1.71 2013/01/24 17:43:44 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -948,6 +948,13 @@ ustar_rd(ARCHD *arcn, char *buf)
hd->typeflag == LONGLINKTYPE ? "Link" : "File"); hd->typeflag == LONGLINKTYPE ? "Link" : "File");
} }
break; break;
case FILEXTYPE:
case GLOBXTYPE:
tty_warn(0, "%s extended headers posix ustar archive."
" Extracting as plain files. Following files might be"
" in the wrong directory or have wrong attributes.",
hd->typeflag == FILEXTYPE ? "File" : "Global");
/*FALLTHROUGH*/
case CONTTYPE: case CONTTYPE:
case AREGTYPE: case AREGTYPE:
case REGTYPE: case REGTYPE:

View file

@ -1,4 +1,4 @@
/* $NetBSD: tar.h,v 1.9 2004/05/11 17:12:26 christos Exp $ */ /* $NetBSD: tar.h,v 1.10 2013/01/24 17:43:44 christos Exp $ */
/*- /*-
* Copyright (c) 1992 Keith Muller. * Copyright (c) 1992 Keith Muller.
@ -59,6 +59,8 @@
#define DIRTYPE '5' /* Directory */ #define DIRTYPE '5' /* Directory */
#define FIFOTYPE '6' /* FIFO */ #define FIFOTYPE '6' /* FIFO */
#define CONTTYPE '7' /* high perf file */ #define CONTTYPE '7' /* high perf file */
#define GLOBXTYPE 'g' /* global extended header */
#define FILEXTYPE 'x' /* file extended header */
/* /*
* GNU tar compatibility; * GNU tar compatibility;

View file

@ -1,4 +1,4 @@
.\" $NetBSD: rm.1,v 1.24 2006/09/02 23:28:32 wiz Exp $ .\" $NetBSD: rm.1,v 1.27 2013/04/26 19:34:34 wiz Exp $
.\" .\"
.\" Copyright (c) 1990, 1993, 1994, 2003 .\" Copyright (c) 1990, 1993, 1994, 2003
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -32,7 +32,7 @@
.\" .\"
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94 .\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\" .\"
.Dd August 25, 2006 .Dd April 26, 2013
.Dt RM 1 .Dt RM 1
.Os .Os
.Sh NAME .Sh NAME
@ -41,7 +41,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl f | Fl i .Op Fl f | Fl i
.Op Fl dPRrvW .Op Fl dPRrvWx
.Ar .Ar
.Sh DESCRIPTION .Sh DESCRIPTION
The The
@ -99,7 +99,6 @@ each directory's contents are processed (as well as before the attempt
is made to remove the directory). is made to remove the directory).
If the user does not respond affirmatively, the file hierarchy rooted in If the user does not respond affirmatively, the file hierarchy rooted in
that directory is skipped. that directory is skipped.
.Pp
.It Fl r .It Fl r
Equivalent to Equivalent to
.Fl R . .Fl R .
@ -111,6 +110,8 @@ to be verbose, showing files as they are processed.
Attempts to undelete the named files. Attempts to undelete the named files.
Currently, this option can only be used to recover Currently, this option can only be used to recover
files covered by whiteouts. files covered by whiteouts.
.It Fl x
When removing a hierarchy, do not cross mount points.
.El .El
.Pp .Pp
The The
@ -145,6 +146,18 @@ can be accomplished as follows:
or or
.Pp .Pp
.Ic "rm ./-file" .Ic "rm ./-file"
.Sh COMPATIBILITY
The
.Nm
utility differs from historical implementations in that the
.Fl f
option only masks attempts to remove non-existent files instead of
masking a large variety of errors.
.Pp
Also, historical
.Bx
implementations prompted on the standard output,
not the standard error output.
.Sh SEE ALSO .Sh SEE ALSO
.Xr rmdir 1 , .Xr rmdir 1 ,
.Xr undelete 2 , .Xr undelete 2 ,
@ -152,6 +165,31 @@ or
.Xr fts 3 , .Xr fts 3 ,
.Xr getopt 3 , .Xr getopt 3 ,
.Xr symlink 7 .Xr symlink 7
.Sh STANDARDS
The
.Nm
utility is expected to be
.St -p1003.2
compatible.
The
.Fl v
and
.Fl x
options are extensions.
.Pp
The
.Fl P
option attempts to conform to U.S. DoD 5220-22.M, "National Industrial
Security Program Operating Manual" ("NISPOM") as updated by Change
2 and the July 23, 2003 "Clearing \*[Am] Sanitization Matrix".
However, unlike earlier revisions of NISPOM, the 2003 matrix imposes
requirements which make it clear that the standard does not and
can not apply to the erasure of individual files, in particular
requirements relating to spare sector management for an entire
magnetic disk.
.Em Because these requirements are not met, the
.Fl P
.Em option does not conform to the standard .
.Sh BUGS .Sh BUGS
The The
.Fl P .Fl P
@ -170,38 +208,3 @@ too costly for default operation.
However, it will at least prevent the recovery of data from FFS However, it will at least prevent the recovery of data from FFS
volumes with volumes with
.Xr fsdb 8 . .Xr fsdb 8 .
.Sh COMPATIBILITY
The
.Nm
utility differs from historical implementations in that the
.Fl f
option only masks attempts to remove non-existent files instead of
masking a large variety of errors.
.Pp
Also, historical
.Bx
implementations prompted on the standard output,
not the standard error output.
.Sh STANDARDS
The
.Nm
utility is expected to be
.St -p1003.2
compatible.
The
.Fl v
option is an extension.
.Pp
The
.Fl P
option attempts to conform to U.S. DoD 5220-22.M, "National Industrial
Security Program Operating Manual" ("NISPOM") as updated by Change
2 and the July 23, 2003 "Clearing \*[Am] Sanitization Matrix".
However, unlike earlier revisions of NISPOM, the 2003 matrix imposes
requirements which make it clear that the standard does not and
can not apply to the erasure of individual files, in particular
requirements relating to spare sector management for an entire
magnetic disk.
.Em Because these requirements are not met, the
.Fl P
.Em option does not conform to the standard .

View file

@ -1,4 +1,4 @@
/* $NetBSD: rm.c,v 1.50 2011/08/29 14:48:46 joerg Exp $ */ /* $NetBSD: rm.c,v 1.53 2013/04/26 18:43:22 christos Exp $ */
/*- /*-
* Copyright (c) 1990, 1993, 1994, 2003 * Copyright (c) 1990, 1993, 1994, 2003
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)rm.c 8.8 (Berkeley) 4/27/95"; static char sccsid[] = "@(#)rm.c 8.8 (Berkeley) 4/27/95";
#else #else
__RCSID("$NetBSD: rm.c,v 1.50 2011/08/29 14:48:46 joerg Exp $"); __RCSID("$NetBSD: rm.c,v 1.53 2013/04/26 18:43:22 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -54,28 +54,32 @@ __RCSID("$NetBSD: rm.c,v 1.50 2011/08/29 14:48:46 joerg Exp $");
#include <grp.h> #include <grp.h>
#include <locale.h> #include <locale.h>
#include <pwd.h> #include <pwd.h>
#include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
static int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag, Wflag; static int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag, Wflag;
static int xflag;
static sig_atomic_t pinfo;
static int check(char *, char *, struct stat *); static int check(char *, char *, struct stat *);
static void checkdot(char **); static void checkdot(char **);
static void progress(int);
static void rm_file(char **); static void rm_file(char **);
static int rm_overwrite(char *, struct stat *); static int rm_overwrite(char *, struct stat *);
static void rm_tree(char **); static void rm_tree(char **);
__dead static void usage(void); __dead static void usage(void);
#ifdef __minix #if defined(__minix)
# ifndef O_SYNC # ifndef O_SYNC
# define O_SYNC 0 # define O_SYNC 0
# endif # endif
# ifndef O_RSYNC # ifndef O_RSYNC
# define O_RSYNC 0 # define O_RSYNC 0
# endif # endif
#endif #endif /* defined(__minix) */
/* /*
* For the sake of the `-f' flag, check whether an error number indicates the * For the sake of the `-f' flag, check whether an error number indicates the
@ -100,8 +104,8 @@ main(int argc, char *argv[])
setprogname(argv[0]); setprogname(argv[0]);
(void)setlocale(LC_ALL, ""); (void)setlocale(LC_ALL, "");
Pflag = rflag = 0; Pflag = rflag = xflag = 0;
while ((ch = getopt(argc, argv, "dfiPRrvW")) != -1) while ((ch = getopt(argc, argv, "dfiPRrvWx")) != -1)
switch (ch) { switch (ch) {
case 'd': case 'd':
dflag = 1; dflag = 1;
@ -124,6 +128,9 @@ main(int argc, char *argv[])
case 'v': case 'v':
vflag = 1; vflag = 1;
break; break;
case 'x':
xflag = 1;
break;
case 'W': case 'W':
Wflag = 1; Wflag = 1;
break; break;
@ -140,6 +147,8 @@ main(int argc, char *argv[])
usage(); usage();
} }
(void)signal(SIGINFO, progress);
checkdot(argv); checkdot(argv);
if (*argv) { if (*argv) {
@ -177,10 +186,12 @@ rm_tree(char **argv)
flags = FTS_PHYSICAL; flags = FTS_PHYSICAL;
if (!needstat) if (!needstat)
flags |= FTS_NOSTAT; flags |= FTS_NOSTAT;
#ifndef __minix #if !defined(__minix)
if (Wflag) if (Wflag)
flags |= FTS_WHITEOUT; flags |= FTS_WHITEOUT;
#endif #endif /* !defined(__minix) */
if (xflag)
flags |= FTS_XDEV;
if ((fts = fts_open(argv, flags, NULL)) == NULL) if ((fts = fts_open(argv, flags, NULL)) == NULL)
err(1, "fts_open failed"); err(1, "fts_open failed");
while ((p = fts_read(fts)) != NULL) { while ((p = fts_read(fts)) != NULL) {
@ -244,13 +255,13 @@ rm_tree(char **argv)
continue; continue;
break; break;
#ifndef __minix #if !defined(__minix)
case FTS_W: case FTS_W:
rval = undelete(p->fts_accpath); rval = undelete(p->fts_accpath);
if (rval != 0 && fflag && errno == ENOENT) if (rval != 0 && fflag && errno == ENOENT)
continue; continue;
break; break;
#endif #endif /* !defined(__minix) */
default: default:
if (Pflag) { if (Pflag) {
@ -265,8 +276,10 @@ rm_tree(char **argv)
if (rval != 0) { if (rval != 0) {
warn("%s", p->fts_path); warn("%s", p->fts_path);
eval = 1; eval = 1;
} else if (vflag) } else if (vflag || pinfo) {
pinfo = 0;
(void)printf("%s\n", p->fts_path); (void)printf("%s\n", p->fts_path);
}
} }
if (errno) if (errno)
err(1, "fts_read"); err(1, "fts_read");
@ -288,11 +301,11 @@ rm_file(char **argv)
/* Assume if can't stat the file, can't unlink it. */ /* Assume if can't stat the file, can't unlink it. */
if (lstat(f, &sb)) { if (lstat(f, &sb)) {
if (Wflag) { if (Wflag) {
#ifdef __minix #if defined(__minix)
sb.st_mode = S_IWUSR|S_IRUSR; sb.st_mode = S_IWUSR|S_IRUSR;
#else #else
sb.st_mode = S_IFWHT|S_IWUSR|S_IRUSR; sb.st_mode = S_IFWHT|S_IWUSR|S_IRUSR;
#endif #endif /* defined(__minix) */
} else { } else {
if (!fflag || !NONEXISTENT(errno)) { if (!fflag || !NONEXISTENT(errno)) {
warn("%s", f); warn("%s", f);
@ -311,17 +324,17 @@ rm_file(char **argv)
eval = 1; eval = 1;
continue; continue;
} }
#ifndef __minix #if !defined(__minix)
if (!fflag && !S_ISWHT(sb.st_mode) && !check(f, f, &sb)) if (!fflag && !S_ISWHT(sb.st_mode) && !check(f, f, &sb))
#else #else
if (!fflag && !check(f, f, &sb)) if (!fflag && !check(f, f, &sb))
#endif #endif /* !defined(__minix) */
continue; continue;
#ifndef __minix #if !defined(__minix)
if (S_ISWHT(sb.st_mode)) if (S_ISWHT(sb.st_mode))
rval = undelete(f); rval = undelete(f);
else else
#endif #endif /* !defined(__minix) */
if (S_ISDIR(sb.st_mode)) if (S_ISDIR(sb.st_mode))
rval = rmdir(f); rval = rmdir(f);
else { else {
@ -397,7 +410,7 @@ rm_file(char **argv)
static int static int
rm_overwrite(char *file, struct stat *sbp) rm_overwrite(char *file, struct stat *sbp)
{ {
struct stat sb; struct stat sb, sb2;
int fd, randint; int fd, randint;
char randchar; char randchar;
@ -411,9 +424,19 @@ rm_overwrite(char *file, struct stat *sbp)
return 0; return 0;
/* flags to try to defeat hidden caching by forcing seeks */ /* flags to try to defeat hidden caching by forcing seeks */
if ((fd = open(file, O_RDWR|O_SYNC|O_RSYNC, 0)) == -1) if ((fd = open(file, O_RDWR|O_SYNC|O_RSYNC|O_NOFOLLOW, 0)) == -1)
goto err; goto err;
if (fstat(fd, &sb2)) {
goto err;
}
if (sb2.st_dev != sbp->st_dev || sb2.st_ino != sbp->st_ino ||
!S_ISREG(sb2.st_mode)) {
errno = EPERM;
goto err;
}
#define RAND_BYTES 1 #define RAND_BYTES 1
#define THIS_BYTE 0 #define THIS_BYTE 0
@ -598,8 +621,15 @@ static void
usage(void) usage(void)
{ {
(void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrvW] file ...\n", (void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrvWx] file ...\n",
getprogname()); getprogname());
exit(1); exit(1);
/* NOTREACHED */ /* NOTREACHED */
} }
static void
progress(int sig __unused)
{
pinfo++;
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.12 2011/08/29 14:51:19 joerg Exp $ */ /* $NetBSD: extern.h,v 1.13 2013/09/12 19:47:23 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -43,7 +43,7 @@ void gread(struct termios *, char *);
int ksearch(char ***, struct info *); int ksearch(char ***, struct info *);
int msearch(char ***, struct info *); int msearch(char ***, struct info *);
void optlist(void); void optlist(void);
void print(struct termios *, struct winsize *, int, enum FMT); void print(struct termios *, struct winsize *, int, const char *, enum FMT);
__dead void usage(void); __dead void usage(void);
extern const struct cchar cchars1[], cchars2[]; extern const struct cchar cchars1[], cchars2[];

View file

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.20 2004/04/01 16:10:03 tsarna Exp $ */ /* $NetBSD: key.c,v 1.21 2013/09/12 19:47:23 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993, 1994 * Copyright (c) 1991, 1993, 1994
@ -34,7 +34,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)key.c 8.4 (Berkeley) 2/20/95"; static char sccsid[] = "@(#)key.c 8.4 (Berkeley) 2/20/95";
#else #else
__RCSID("$NetBSD: key.c,v 1.20 2004/04/01 16:10:03 tsarna Exp $"); __RCSID("$NetBSD: key.c,v 1.21 2013/09/12 19:47:23 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -146,7 +146,7 @@ ksearch(char ***argvp, struct info *ip)
void void
f_all(struct info *ip) f_all(struct info *ip)
{ {
print(&ip->t, &ip->win, ip->ldisc, STTY_BSD); print(&ip->t, &ip->win, ip->queue, ip->ldisc, STTY_BSD);
} }
void void
@ -185,7 +185,7 @@ f_dec(struct info *ip)
void void
f_everything(struct info *ip) f_everything(struct info *ip)
{ {
print(&ip->t, &ip->win, ip->ldisc, STTY_BSD); print(&ip->t, &ip->win, ip->queue, ip->ldisc, STTY_BSD);
} }
void void
@ -319,21 +319,13 @@ f_tty(struct info *ip)
void void
f_ostart(struct info *ip) f_ostart(struct info *ip)
{ {
#ifndef __minix
if (ioctl (0, TIOCSTART) < 0) if (ioctl (0, TIOCSTART) < 0)
#else
if (ioctl (0, TIOCSTART, NULL) < 0)
#endif
err(1, "TIOCSTART"); err(1, "TIOCSTART");
} }
void void
f_ostop(struct info *ip) f_ostop(struct info *ip)
{ {
#ifndef __minix
if (ioctl (0, TIOCSTOP) < 0) if (ioctl (0, TIOCSTOP) < 0)
#else
if (ioctl (0, TIOCSTOP, NULL) < 0)
#endif
err(1, "TIOCSTOP"); err(1, "TIOCSTOP");
} }

View file

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.22 2005/06/26 19:10:49 christos Exp $ */ /* $NetBSD: print.c,v 1.23 2013/09/12 19:47:23 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993, 1994 * Copyright (c) 1991, 1993, 1994
@ -34,7 +34,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else #else
__RCSID("$NetBSD: print.c,v 1.22 2005/06/26 19:10:49 christos Exp $"); __RCSID("$NetBSD: print.c,v 1.23 2013/09/12 19:47:23 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -52,7 +52,8 @@ static void bput(const char *);
static const char *ccval(const struct cchar *, int); static const char *ccval(const struct cchar *, int);
void void
print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt) print(struct termios *tp, struct winsize *wp, int queue, const char *ldisc,
enum FMT fmt)
{ {
const struct cchar *p; const struct cchar *p;
long tmp; long tmp;
@ -62,29 +63,6 @@ print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt)
cnt = 0; cnt = 0;
/* Line discipline. */
#ifdef TTYDISC
if (ldisc != TTYDISC) {
switch(ldisc) {
case TABLDISC:
cnt += printf("tablet disc; ");
break;
case SLIPDISC:
cnt += printf("slip disc; ");
break;
case PPPDISC:
cnt += printf("ppp disc; ");
break;
case STRIPDISC:
cnt += printf("strip disc; ");
break;
default:
cnt += printf("#%d disc; ", ldisc);
break;
}
}
#endif
/* Line speed. */ /* Line speed. */
ispeed = cfgetispeed(tp); ispeed = cfgetispeed(tp);
ospeed = cfgetospeed(tp); ospeed = cfgetospeed(tp);
@ -93,8 +71,14 @@ print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt)
printf("ispeed %d baud; ospeed %d baud;", ispeed, ospeed); printf("ispeed %d baud; ospeed %d baud;", ispeed, ospeed);
else else
cnt += printf("speed %d baud;", ispeed); cnt += printf("speed %d baud;", ispeed);
if (fmt >= STTY_BSD) if (fmt >= STTY_BSD) {
cnt += printf(" %d rows; %d columns;", wp->ws_row, wp->ws_col); cnt += printf(" %d rows; %d columns;", wp->ws_row, wp->ws_col);
if (queue)
cnt += printf(" queue = %d;", queue);
if (ldisc)
cnt += printf(" line = %s;", ldisc);
}
if (cnt) if (cnt)
(void)printf("\n"); (void)printf("\n");

View file

@ -1,4 +1,4 @@
/* $NetBSD: stty.c,v 1.22 2012/06/20 10:09:43 wiz Exp $ */ /* $NetBSD: stty.c,v 1.23 2013/09/12 19:47:23 christos Exp $ */
/*- /*-
* Copyright (c) 1989, 1991, 1993, 1994 * Copyright (c) 1989, 1991, 1993, 1994
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1991, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94"; static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
#else #else
__RCSID("$NetBSD: stty.c,v 1.22 2012/06/20 10:09:43 wiz Exp $"); __RCSID("$NetBSD: stty.c,v 1.23 2013/09/12 19:47:23 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -58,8 +58,6 @@ __RCSID("$NetBSD: stty.c,v 1.22 2012/06/20 10:09:43 wiz Exp $");
#include "stty.h" #include "stty.h"
#include "extern.h" #include "extern.h"
int main(int, char *[]);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@ -99,12 +97,14 @@ main(int argc, char *argv[])
args: argc -= optind; args: argc -= optind;
argv += optind; argv += optind;
if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0) if (ioctl(i.fd, TIOCGLINED, i.ldisc) < 0)
err(1, "TIOCGETD"); err(1, "TIOCGLINED");
if (tcgetattr(i.fd, &i.t) < 0) if (tcgetattr(i.fd, &i.t) < 0)
err(1, "tcgetattr"); err(1, "tcgetattr");
if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
warn("TIOCGWINSZ"); warn("TIOCGWINSZ");
if (ioctl(i.fd, TIOCGQSIZE, &i.queue) < 0)
warn("TIOCGQSIZE");
switch(fmt) { switch(fmt) {
case STTY_NOTSET: case STTY_NOTSET:
@ -113,7 +113,7 @@ args: argc -= optind;
/* FALLTHROUGH */ /* FALLTHROUGH */
case STTY_BSD: case STTY_BSD:
case STTY_POSIX: case STTY_POSIX:
print(&i.t, &i.win, i.ldisc, fmt); print(&i.t, &i.win, i.queue, i.ldisc, fmt);
break; break;
case STTY_GFLAG: case STTY_GFLAG:
gprint(&i.t); gprint(&i.t);

View file

@ -1,4 +1,4 @@
/* $NetBSD: stty.h,v 1.10 2003/08/07 09:05:42 agc Exp $ */ /* $NetBSD: stty.h,v 1.11 2013/09/12 19:47:23 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -39,7 +39,8 @@
struct info { struct info {
int fd; /* file descriptor */ int fd; /* file descriptor */
int ldisc; /* line discipline */ linedn_t ldisc; /* line discipline */
int queue; /* queue size */
int off; /* turn off */ int off; /* turn off */
int set; /* need set */ int set; /* need set */
int wset; /* need window set */ int wset; /* need window set */

View file

@ -1,4 +1,4 @@
.\" $NetBSD: test.1,v 1.27 2009/11/10 18:19:46 wiz Exp $ .\" $NetBSD: test.1,v 1.28 2012/12/16 17:57:49 wiz Exp $
.\" .\"
.\" Copyright (c) 1991, 1993 .\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -32,7 +32,7 @@
.\" .\"
.\" @(#)test.1 8.1 (Berkeley) 5/31/93 .\" @(#)test.1 8.1 (Berkeley) 5/31/93
.\" .\"
.Dd November 10, 2009 .Dd December 16, 2012
.Dt TEST 1 .Dt TEST 1
.Os .Os
.Sh NAME .Sh NAME
@ -40,13 +40,13 @@
.Nm \&[ .Nm \&[
.Nd condition evaluation utility .Nd condition evaluation utility
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm test .Nm
.Ar expression .Ar expression
.Nm \&[ .Nm \&[
.Ar expression Cm \&] .Ar expression Cm \&]
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm test .Nm
utility evaluates utility evaluates
.Ar expression .Ar expression
and, if it evaluates and, if it evaluates
@ -55,12 +55,12 @@ it returns 1 (false).
If If
.Ar expression .Ar expression
is not given, is not given,
.Nm test .Nm
also also
returns 1 (false). returns 1 (false).
.Pp .Pp
All operators and flags are separate arguments to the All operators and flags are separate arguments to the
.Nm test .Nm
utility. utility.
.Pp .Pp
The following primaries are used to construct The following primaries are used to construct
@ -293,19 +293,9 @@ Note that all file tests with the exception of
and and
.Fl L .Fl L
follow symbolic links and thus evaluate the test for the file pointed at. follow symbolic links and thus evaluate the test for the file pointed at.
.Sh GRAMMAR AMBIGUITY
The
.Nm test
grammar is inherently ambiguous.
In order to assure a degree of consistency, the cases described in
.St -p1003.2
section 4.62.4,
are evaluated consistently according to the rules specified in the
standards document.
All other cases are subject to the ambiguity in the command semantics.
.Sh EXIT STATUS .Sh EXIT STATUS
The The
.Nm test .Nm
utility exits with one of the following values: utility exits with one of the following values:
.Bl -tag -width Ds .Bl -tag -width Ds
.It 0 .It 0
@ -319,7 +309,17 @@ An error occurred.
.El .El
.Sh STANDARDS .Sh STANDARDS
The The
.Nm test .Nm
utility implements a superset of the utility implements a superset of the
.St -p1003.2 .St -p1003.2
specification. specification.
.Sh CAVEATS
The
.Nm
grammar is inherently ambiguous.
In order to assure a degree of consistency, the cases described in
.St -p1003.2
section 4.62.4,
are evaluated consistently according to the rules specified in the
standards document.
All other cases are subject to the ambiguity in the command semantics.

View file

@ -1,4 +1,4 @@
/* $NetBSD: test.c,v 1.39 2012/03/15 02:02:21 joerg Exp $ */ /* $NetBSD: test.c,v 1.40 2013/05/04 06:26:44 uebayasi Exp $ */
/* /*
* test(1); version 7-like -- author Erik Baalbergen * test(1); version 7-like -- author Erik Baalbergen
@ -12,7 +12,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: test.c,v 1.39 2012/03/15 02:02:21 joerg Exp $"); __RCSID("$NetBSD: test.c,v 1.40 2013/05/04 06:26:44 uebayasi Exp $");
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@ -694,7 +694,7 @@ newerf(const char *f1, const char *f2)
return (stat(f1, &b1) == 0 && return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 && stat(f2, &b2) == 0 &&
b1.st_mtime > b2.st_mtime); timespeccmp(&b1.st_mtim, &b2.st_mtim, >));
} }
static int static int
@ -704,7 +704,7 @@ olderf(const char *f1, const char *f2)
return (stat(f1, &b1) == 0 && return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 && stat(f2, &b2) == 0 &&
b1.st_mtime < b2.st_mtime); timespeccmp(&b1.st_mtim, &b2.st_mtim, <));
} }
static int static int

550
build.sh
View file

@ -1,5 +1,5 @@
#! /usr/bin/env sh #! /usr/bin/env sh
# $NetBSD: build.sh,v 1.256 2012/09/29 04:02:42 tsutsui Exp $ # $NetBSD: build.sh,v 1.273 2013/08/30 10:29:06 pooka Exp $
# #
# Copyright (c) 2001-2011 The NetBSD Foundation, Inc. # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
# All rights reserved. # All rights reserved.
@ -263,6 +263,8 @@ progname=${0##*/}
toppid=$$ toppid=$$
results=/dev/null results=/dev/null
tab=' ' tab=' '
nl='
'
trap "exit 1" 1 2 3 15 trap "exit 1" 1 2 3 15
bomb() bomb()
@ -428,6 +430,7 @@ initdefaults()
unsetmakeenv INFODIR unsetmakeenv INFODIR
unsetmakeenv LESSCHARSET unsetmakeenv LESSCHARSET
unsetmakeenv MAKEFLAGS unsetmakeenv MAKEFLAGS
unsetmakeenv TERMINFO
setmakeenv LC_ALL C setmakeenv LC_ALL C
# Find information about the build platform. This should be # Find information about the build platform. This should be
@ -505,7 +508,8 @@ initdefaults()
do_iso_image_source=false do_iso_image_source=false
do_live_image=false do_live_image=false
do_install_image=false do_install_image=false
do_params=false do_disk_image=false
do_show_params=false
do_rump=false do_rump=false
# done_{operation}=true if given operation has been done. # done_{operation}=true if given operation has been done.
@ -546,211 +550,255 @@ initdefaults()
} }
# valid_MACHINE_ARCH -- A multi-line string, listing all valid
# MACHINE/MACHINE_ARCH pairs.
#
# Each line contains a MACHINE and MACHINE_ARCH value, an optional ALIAS
# which may be used to refer to the MACHINE/MACHINE_ARCH pair, and an
# optional DEFAULT or NO_DEFAULT keyword.
#
# When a MACHINE corresponds to multiple possible values of
# MACHINE_ARCH, then this table should list all allowed combinations.
# If the MACHINE is associated with a default MACHINE_ARCH (to be
# used when the user specifies the MACHINE but fails to specify the
# MACHINE_ARCH), then one of the lines should have the "DEFAULT"
# keyword. If there is no default MACHINE_ARCH for a particular
# MACHINE, then there should be a line with the "NO_DEFAULT" keyword,
# and with a blank MACHINE_ARCH.
#
valid_MACHINE_ARCH='
MACHINE=acorn26 MACHINE_ARCH=arm
MACHINE=acorn32 MACHINE_ARCH=arm
MACHINE=algor MACHINE_ARCH=mips64el ALIAS=algor64
MACHINE=algor MACHINE_ARCH=mipsel DEFAULT
MACHINE=alpha MACHINE_ARCH=alpha
MACHINE=amd64 MACHINE_ARCH=x86_64
MACHINE=amiga MACHINE_ARCH=m68k
MACHINE=amigappc MACHINE_ARCH=powerpc
MACHINE=arc MACHINE_ARCH=mips64el ALIAS=arc64
MACHINE=arc MACHINE_ARCH=mipsel DEFAULT
MACHINE=atari MACHINE_ARCH=m68k
MACHINE=bebox MACHINE_ARCH=powerpc
MACHINE=cats MACHINE_ARCH=arm DEFAULT
MACHINE=cats MACHINE_ARCH=earmv4 ALIAS=ecats
MACHINE=cesfic MACHINE_ARCH=m68k
MACHINE=cobalt MACHINE_ARCH=mips64el ALIAS=cobalt64
MACHINE=cobalt MACHINE_ARCH=mipsel DEFAULT
MACHINE=dreamcast MACHINE_ARCH=sh3el
MACHINE=emips MACHINE_ARCH=mipseb
MACHINE=epoc32 MACHINE_ARCH=arm
MACHINE=evbarm MACHINE_ARCH=arm ALIAS=evbarm-el DEFAULT
MACHINE=evbarm MACHINE_ARCH=armeb ALIAS=evbarm-eb
MACHINE=evbarm MACHINE_ARCH=earm ALIAS=evbearm-el
MACHINE=evbarm MACHINE_ARCH=earmeb ALIAS=evbearm-eb
MACHINE=evbarm MACHINE_ARCH=earmhf ALIAS=evbearmhf-el
MACHINE=evbarm MACHINE_ARCH=earmhfeb ALIAS=evbearmhf-eb
MACHINE=evbarm MACHINE_ARCH=earmv4 ALIAS=evbearmv4-el
MACHINE=evbarm MACHINE_ARCH=earmv4eb ALIAS=evbearmv4-eb
MACHINE=evbarm MACHINE_ARCH=earmv5 ALIAS=evbearmv5-el
MACHINE=evbarm MACHINE_ARCH=earmv5eb ALIAS=evbearmv5-eb
MACHINE=evbarm MACHINE_ARCH=earmv6 ALIAS=evbearmv6-el
MACHINE=evbarm MACHINE_ARCH=earmv6hf ALIAS=evbearmv6hf-el
MACHINE=evbarm MACHINE_ARCH=earmv6eb ALIAS=evbearmv6-eb
MACHINE=evbarm MACHINE_ARCH=earmv6hfeb ALIAS=evbearmv6hf-eb
MACHINE=evbarm MACHINE_ARCH=earmv7 ALIAS=evbearmv7-el
MACHINE=evbarm MACHINE_ARCH=earmv7eb ALIAS=evbearmv7-eb
MACHINE=evbarm MACHINE_ARCH=earmv7hf ALIAS=evbearmv7hf-el
MACHINE=evbarm MACHINE_ARCH=earmv7hfeb ALIAS=evbearmv7hf-eb
MACHINE=evbcf MACHINE_ARCH=coldfire
MACHINE=evbmips MACHINE_ARCH= NO_DEFAULT
MACHINE=evbmips MACHINE_ARCH=mips64eb ALIAS=evbmips64-eb
MACHINE=evbmips MACHINE_ARCH=mips64el ALIAS=evbmips64-el
MACHINE=evbmips MACHINE_ARCH=mipseb ALIAS=evbmips-eb
MACHINE=evbmips MACHINE_ARCH=mipsel ALIAS=evbmips-el
MACHINE=evbppc MACHINE_ARCH=powerpc DEFAULT
MACHINE=evbppc MACHINE_ARCH=powerpc64 ALIAS=evbppc64
MACHINE=evbsh3 MACHINE_ARCH= NO_DEFAULT
MACHINE=evbsh3 MACHINE_ARCH=sh3eb ALIAS=evbsh3-eb
MACHINE=evbsh3 MACHINE_ARCH=sh3el ALIAS=evbsh3-el
MACHINE=ews4800mips MACHINE_ARCH=mipseb
MACHINE=hp300 MACHINE_ARCH=m68k
MACHINE=hp700 MACHINE_ARCH=hppa
MACHINE=hpcarm MACHINE_ARCH=arm DEFAULT
MACHINE=hpcarm MACHINE_ARCH=earm ALIAS=hpcearm
MACHINE=hpcmips MACHINE_ARCH=mipsel
MACHINE=hpcsh MACHINE_ARCH=sh3el
MACHINE=i386 MACHINE_ARCH=i386
MACHINE=ia64 MACHINE_ARCH=ia64
MACHINE=ibmnws MACHINE_ARCH=powerpc
MACHINE=iyonix MACHINE_ARCH=arm DEFAULT
MACHINE=iyonix MACHINE_ARCH=earm ALIAS=eiyonix
MACHINE=landisk MACHINE_ARCH=sh3el
MACHINE=luna68k MACHINE_ARCH=m68k
MACHINE=mac68k MACHINE_ARCH=m68k
MACHINE=macppc MACHINE_ARCH=powerpc DEFAULT
MACHINE=macppc MACHINE_ARCH=powerpc64 ALIAS=macppc64
MACHINE=mipsco MACHINE_ARCH=mipseb
MACHINE=mmeye MACHINE_ARCH=sh3eb
MACHINE=mvme68k MACHINE_ARCH=m68k
MACHINE=mvmeppc MACHINE_ARCH=powerpc
MACHINE=netwinder MACHINE_ARCH=arm DEFAULT
MACHINE=netwinder MACHINE_ARCH=earmv4 ALIAS=enetwinder
MACHINE=news68k MACHINE_ARCH=m68k
MACHINE=newsmips MACHINE_ARCH=mipseb
MACHINE=next68k MACHINE_ARCH=m68k
MACHINE=ofppc MACHINE_ARCH=powerpc DEFAULT
MACHINE=ofppc MACHINE_ARCH=powerpc64 ALIAS=ofppc64
MACHINE=pmax MACHINE_ARCH=mips64el ALIAS=pmax64
MACHINE=pmax MACHINE_ARCH=mipsel DEFAULT
MACHINE=prep MACHINE_ARCH=powerpc
MACHINE=rs6000 MACHINE_ARCH=powerpc
MACHINE=sandpoint MACHINE_ARCH=powerpc
MACHINE=sbmips MACHINE_ARCH= NO_DEFAULT
MACHINE=sbmips MACHINE_ARCH=mips64eb ALIAS=sbmips64-eb
MACHINE=sbmips MACHINE_ARCH=mips64el ALIAS=sbmips64-el
MACHINE=sbmips MACHINE_ARCH=mipseb ALIAS=sbmips-eb
MACHINE=sbmips MACHINE_ARCH=mipsel ALIAS=sbmips-el
MACHINE=sgimips MACHINE_ARCH=mips64eb ALIAS=sgimips64
MACHINE=sgimips MACHINE_ARCH=mipseb DEFAULT
MACHINE=shark MACHINE_ARCH=arm DEFAULT
MACHINE=shark MACHINE_ARCH=earmv4 ALIAS=eshark
MACHINE=sparc MACHINE_ARCH=sparc
MACHINE=sparc64 MACHINE_ARCH=sparc64
MACHINE=sun2 MACHINE_ARCH=m68000
MACHINE=sun3 MACHINE_ARCH=m68k
MACHINE=vax MACHINE_ARCH=vax
MACHINE=x68k MACHINE_ARCH=m68k
MACHINE=zaurus MACHINE_ARCH=arm DEFAULT
MACHINE=zaurus MACHINE_ARCH=earm ALIAS=ezaurus
'
# getarch -- find the default MACHINE_ARCH for a MACHINE,
# or convert an alias to a MACHINE/MACHINE_ARCH pair.
#
# Saves MACHINE in makewrappermachine before possibly modifying MACHINE.
#
# Sets MACHINE and MACHINE_ARCH if the input MACHINE value is
# recognised as an alias, or recognised as a machine that has a default
# MACHINE_ARCH (or that has only one possible MACHINE_ARCH).
#
# Leaves MACHINE and MACHINE_ARCH unchanged if MACHINE is recognised
# as being associated with multiple MACHINE_ARCH values with no default.
#
# Bombs if MACHINE is not recognised.
#
getarch() getarch()
{ {
# Translate some MACHINE name aliases (known only to build.sh) local IFS
# into proper MACHINE and MACHINE_ARCH names. Save the alias local found=""
# name in makewrappermachine. local line
#
case "${MACHINE}" in
evbearm-e[bl]) IFS="${nl}"
makewrappermachine=${MACHINE} makewrappermachine="${MACHINE}"
# MACHINE_ARCH is "arm" or "armeb", not "armel" for line in ${valid_MACHINE_ARCH}; do
MACHINE_ARCH=earm${MACHINE##*-} line="${line%%#*}" # ignore comments
MACHINE_ARCH=${MACHINE_ARCH%el} line="$( IFS=" ${tab}" ; echo $line )" # normalise white space
MACHINE=evbarm case "${line} " in
"")
# skip blank lines or comment lines
continue
;;
*" ALIAS=${MACHINE} "*)
# Found a line with a matching ALIAS=<alias>.
found="$line"
break
;;
"MACHINE=${MACHINE} "*" NO_DEFAULT"*)
# Found an explicit "NO_DEFAULT" for this MACHINE.
found="$line"
break
;;
"MACHINE=${MACHINE} "*" DEFAULT"*)
# Found an explicit "DEFAULT" for this MACHINE.
found="$line"
break
;;
"MACHINE=${MACHINE} "*)
# Found a line for this MACHINE. If it's the
# first such line, then tentatively accept it.
# If it's not the first matching line, then
# remember that there was more than one match.
case "$found" in
'') found="$line" ;;
*) found="MULTIPLE_MATCHES" ; break ;;
esac
;;
esac
done
case "$found" in
*NO_DEFAULT*|*MULTIPLE_MATCHES*)
# MACHINE is OK, but MACHINE_ARCH is still unknown
return
;; ;;
"MACHINE="*" MACHINE_ARCH="*)
evbarm-e[bl]) # Obey the MACHINE= and MACHINE_ARCH= parts of the line.
makewrappermachine=${MACHINE} IFS=" "
# MACHINE_ARCH is "arm" or "armeb", not "armel" for frag in ${found}; do
MACHINE_ARCH=arm${MACHINE##*-} case "$frag" in
MACHINE_ARCH=${MACHINE_ARCH%el} MACHINE=*|MACHINE_ARCH=*)
MACHINE=${MACHINE%-e[bl]} eval "$frag"
;;
esac
done
;; ;;
evbmips-e[bl]|sbmips-e[bl])
makewrappermachine=${MACHINE}
MACHINE_ARCH=mips${MACHINE##*-}
MACHINE=${MACHINE%-e[bl]}
;;
evbmips64-e[bl]|sbmips64-e[bl])
makewrappermachine=${MACHINE}
MACHINE_ARCH=mips64${MACHINE##*-}
MACHINE=${MACHINE%64-e[bl]}
;;
evbsh3-e[bl])
makewrappermachine=${MACHINE}
MACHINE_ARCH=sh3${MACHINE##*-}
MACHINE=${MACHINE%-e[bl]}
;;
esac
# Translate a MACHINE into a default MACHINE_ARCH.
#
case "${MACHINE}" in
acorn26|acorn32|cats|hpcarm|iyonix|netwinder|shark|zaurus)
MACHINE_ARCH=arm
;;
evbarm) # unspecified MACHINE_ARCH gets LE
MACHINE_ARCH=${MACHINE_ARCH:=arm}
;;
hp700)
MACHINE_ARCH=hppa
;;
sun2)
MACHINE_ARCH=m68000
;;
amiga|atari|cesfic|hp300|luna68k|mac68k|mvme68k|news68k|next68k|sun3|x68k)
MACHINE_ARCH=m68k
;;
evbmips|sbmips) # no default MACHINE_ARCH
;;
sgimips64)
makewrappermachine=${MACHINE}
MACHINE=${MACHINE%64}
MACHINE_ARCH=mips64eb
;;
ews4800mips|mipsco|newsmips|sgimips|emips)
MACHINE_ARCH=mipseb
;;
algor64|arc64|cobalt64|pmax64)
makewrappermachine=${MACHINE}
MACHINE=${MACHINE%64}
MACHINE_ARCH=mips64el
;;
algor|arc|cobalt|hpcmips|pmax)
MACHINE_ARCH=mipsel
;;
evbppc64|macppc64|ofppc64)
makewrappermachine=${MACHINE}
MACHINE=${MACHINE%64}
MACHINE_ARCH=powerpc64
;;
amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|prep|rs6000|sandpoint)
MACHINE_ARCH=powerpc
;;
evbsh3) # no default MACHINE_ARCH
;;
mmeye)
MACHINE_ARCH=sh3eb
;;
dreamcast|hpcsh|landisk)
MACHINE_ARCH=sh3el
;;
amd64)
MACHINE_ARCH=x86_64
;;
alpha|i386|sparc|sparc64|vax|ia64)
MACHINE_ARCH=${MACHINE}
;;
i[4-6]86)
# LSC FIXME: This is required as uname -m reports the actual machine.
# We will be able to remove this once our triple has been cleaned up
# (at this time we compile only for i386, and use an incorrect host triple)
MACHINE=i386
MACHINE_ARCH=i386
;;
*) *)
bomb "Unknown target MACHINE: ${MACHINE}" bomb "Unknown target MACHINE: ${MACHINE}"
;; ;;
esac esac
} }
# validatearch -- check that the MACHINE/MACHINE_ARCH pair is supported.
#
# Bombs if the pair is not supported.
#
validatearch() validatearch()
{ {
# Ensure that the MACHINE_ARCH exists (and is supported by build.sh). local IFS
# local line
local foundpair=false foundmachine=false foundarch=false
case "${MACHINE_ARCH}" in case "${MACHINE_ARCH}" in
alpha|arm|armeb|earm|earmeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|powerpc|powerpc64|sh3e[bl]|sparc|sparc64|vax|x86_64|ia64)
;;
"") "")
bomb "No MACHINE_ARCH provided" bomb "No MACHINE_ARCH provided"
;; ;;
esac
*) IFS="${nl}"
for line in ${valid_MACHINE_ARCH}; do
line="${line%%#*}" # ignore comments
line="$( IFS=" ${tab}" ; echo $line )" # normalise white space
case "${line} " in
"")
# skip blank lines or comment lines
continue
;;
"MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} "*)
foundpair=true
;;
"MACHINE=${MACHINE} "*)
foundmachine=true
;;
*"MACHINE_ARCH=${MACHINE_ARCH} "*)
foundarch=true
;;
esac
done
case "${foundpair}:${foundmachine}:${foundarch}" in
true:*)
: OK
;;
*:false:*)
bomb "Unknown target MACHINE: ${MACHINE}"
;;
*:*:false)
bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}" bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}"
;; ;;
esac
# Determine valid MACHINE_ARCHs for MACHINE
#
case "${MACHINE}" in
evbarm)
arches="arm armeb earm earmeb"
;;
cats|iyonix|netwinder|shark|zaurus)
arches="arm earm"
;;
algor|arc|cobalt|pmax)
arches="mipsel mips64el"
;;
evbmips|sbmips)
arches="mipseb mipsel mips64eb mips64el"
;;
sgimips)
arches="mipseb mips64eb"
;;
evbsh3)
arches="sh3eb sh3el"
;;
macppc|evbppc|ofppc)
arches="powerpc powerpc64"
;;
*) *)
oma="${MACHINE_ARCH}" bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
getarch
arches="${MACHINE_ARCH}"
MACHINE_ARCH="${oma}"
;; ;;
esac esac
# Ensure that MACHINE_ARCH supports MACHINE
#
archok=false
for a in ${arches}; do
if [ "${a}" = "${MACHINE_ARCH}" ]; then
archok=true
break
fi
done
${archok} ||
bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
} }
# nobomb_getmakevar -- # nobomb_getmakevar --
@ -892,7 +940,9 @@ Usage: ${progname} [-EhnorUuxy] [-a arch] [-B buildid] [-C cdextras]
RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage. RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage.
install-image Create bootable installation image in install-image Create bootable installation image in
RELEASEDIR/RELEASEMACHINEDIR/installation/installimage. RELEASEDIR/RELEASEMACHINEDIR/installation/installimage.
params Display various make(1) parameters. disk-image=target Creae bootable disk image in
RELEASEDIR/RELEASEMACHINEDIR/binary/gzimg/target.img.gz.
show-params Display various make(1) parameters.
Options: Options:
-a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE] -a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE]
@ -1152,7 +1202,11 @@ parseoptions()
usage usage
;; ;;
makewrapper|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params) makewrapper|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs)
;;
show-params)
op=show_params # used as part of a variable name
;; ;;
iso-image) iso-image)
@ -1178,6 +1232,14 @@ parseoptions()
bomb "Must supply a kernel name with \`${op}=...'" bomb "Must supply a kernel name with \`${op}=...'"
;; ;;
disk-image=*)
arg=${op#*=}
op=disk_image
[ -n "${arg}" ] ||
bomb "Must supply a target name with \`${op}=...'"
;;
modules) modules)
op=modules op=modules
;; ;;
@ -1226,6 +1288,24 @@ parseoptions()
# #
sanitycheck() sanitycheck()
{ {
# Non-root should always use either the -U or -E flag.
#
if ! ${do_expertmode} && \
[ "$id_u" -ne 0 ] && \
[ "${MKUNPRIVED}" = "no" ] ; then
bomb "-U or -E must be set for build as an unprivileged user."
fi
# Install as non-root is a bad idea.
#
if ${do_install} && [ "$id_u" -ne 0 ] ; then
if ${do_expertmode}; then
warning "Will install as an unprivileged user."
else
bomb "-E must be set for install as an unprivileged user."
fi
fi
# If the PATH contains any non-absolute components (including, # If the PATH contains any non-absolute components (including,
# but not limited to, "." or ""), then complain. As an exception, # but not limited to, "." or ""), then complain. As an exception,
# allow "" or "." as the last component of the PATH. This is fatal # allow "" or "." as the last component of the PATH. This is fatal
@ -1375,7 +1455,7 @@ print_tooldir_make()
# 1. build a new version of nbmake in a temporary directory; # 1. build a new version of nbmake in a temporary directory;
# 2. use the temporary nbmake to create the top level obj directory; # 2. use the temporary nbmake to create the top level obj directory;
# 3. use $(getmakevar TOOLDIR) with the temporary nbmake to # 3. use $(getmakevar TOOLDIR) with the temporary nbmake to
# get the corect value of TOOLDIR; # get the correct value of TOOLDIR;
# 4. move the temporary nbmake to ${TOOLDIR}/bin/nbmake. # 4. move the temporary nbmake to ${TOOLDIR}/bin/nbmake.
# #
# However, people don't like building nbmake unnecessarily if their # However, people don't like building nbmake unnecessarily if their
@ -1409,7 +1489,8 @@ rebuildmake()
${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \ ${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \
CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \ CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \
${HOST_SH} "${TOP}/tools/make/configure" || ${HOST_SH} "${TOP}/tools/make/configure" ||
bomb "Configure of ${toolprefix}make failed" ( cp ${tmpdir}/config.log ${tmpdir}-config.log
bomb "Configure of ${toolprefix}make failed, see ${tmpdir}-config.log for details" )
${runcmd} ${HOST_SH} buildmake.sh || ${runcmd} ${HOST_SH} buildmake.sh ||
bomb "Build of ${toolprefix}make failed" bomb "Build of ${toolprefix}make failed"
make="${tmpdir}/${toolprefix}make" make="${tmpdir}/${toolprefix}make"
@ -1423,10 +1504,23 @@ rebuildmake()
# Perform some late sanity checks, after rebuildmake, # Perform some late sanity checks, after rebuildmake,
# but before createmakewrapper or any real work. # but before createmakewrapper or any real work.
# #
# Also create the top-level obj directory. # Creates the top-level obj directory, because that
# is needed by some of the sanity checks.
#
# Prints status messages reporting the values of several variables.
# #
validatemakeparams() validatemakeparams()
{ {
# MAKECONF (which defaults to /etc/mk.conf in share/mk/bsd.own.mk)
# can affect many things, so mention it in an early status message.
#
MAKECONF=$(getmakevar MAKECONF)
if [ -e "${MAKECONF}" ]; then
statusmsg2 "MAKECONF file:" "${MAKECONF}"
else
statusmsg2 "MAKECONF file:" "${MAKECONF} (File not found)"
fi
if [ "${runcmd}" = "echo" ]; then if [ "${runcmd}" = "echo" ]; then
TOOLCHAIN_MISSING=no TOOLCHAIN_MISSING=no
EXTERNAL_TOOLCHAIN="" EXTERNAL_TOOLCHAIN=""
@ -1540,45 +1634,26 @@ validatemakeparams()
removedirs="${TOOLDIR}" removedirs="${TOOLDIR}"
if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; then if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; then
if ${do_build} || ${do_distribution} || ${do_release}; then if ${do_distribution} || ${do_release} || \
if ! ${do_build} || \ ( [ "${uname_s}" != "NetBSD" ] && [ "${uname_s}" != "Minix" ] ) || \
[ "${uname_s}" != "Minix" ] || \ [ "${uname_m}" != "${MACHINE}" ]; then
[ "${uname_m}" != "${MACHINE}" ]; then bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'."
bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'."
fi
if ! ${do_expertmode}; then
bomb "DESTDIR must != / for non -E (expert) builds"
fi
statusmsg "WARNING: Building to /, in expert mode."
statusmsg " This may cause your system to break! Reasons include:"
statusmsg " - your kernel is not up to date"
statusmsg " - the libraries or toolchain have changed"
statusmsg " YOU HAVE BEEN WARNED!"
fi fi
if ! ${do_expertmode}; then
bomb "DESTDIR must != / for non -E (expert) builds"
fi
statusmsg "WARNING: Building to /, in expert mode."
statusmsg " This may cause your system to break! Reasons include:"
statusmsg " - your kernel is not up to date"
statusmsg " - the libraries or toolchain have changed"
statusmsg " YOU HAVE BEEN WARNED!"
else else
removedirs="${removedirs} ${DESTDIR}" removedirs="${removedirs} ${DESTDIR}"
fi fi
if ${do_build} || ${do_distribution} || ${do_release}; then
if ! ${do_expertmode} && \
[ "$id_u" -ne 0 ] && \
[ "${MKUNPRIVED}" = "no" ] ; then
bomb "-U or -E must be set for build as an unprivileged user."
fi
fi
if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then
bomb "Must set RELEASEDIR with \`releasekernel=...'" bomb "Must set RELEASEDIR with \`releasekernel=...'"
fi fi
# Install as non-root is a bad idea.
#
if ${do_install} && [ "$id_u" -ne 0 ] ; then
if ${do_expertmode}; then
warning "Will install as an unprivileged user."
else
bomb "-E must be set for install as an unprivileged user."
fi
fi
# If a previous build.sh run used -U (and therefore created a # If a previous build.sh run used -U (and therefore created a
# METALOG file), then most subsequent build.sh runs must also # METALOG file), then most subsequent build.sh runs must also
# use -U. If DESTDIR is about to be removed, then don't perform # use -U. If DESTDIR is about to be removed, then don't perform
@ -1589,9 +1664,7 @@ validatemakeparams()
# DESTDIR is about to be removed # DESTDIR is about to be removed
;; ;;
*) *)
if ( ${do_build} || ${do_distribution} || ${do_release} || \ if [ -e "${DESTDIR}/METALOG" ] && \
${do_install} ) && \
[ -e "${DESTDIR}/METALOG" ] && \
[ "${MKUNPRIVED}" = "no" ] ; then [ "${MKUNPRIVED}" = "no" ] ; then
if $do_expertmode; then if $do_expertmode; then
warning "A previous build.sh run specified -U." warning "A previous build.sh run specified -U."
@ -1678,7 +1751,7 @@ createmakewrapper()
eval cat <<EOF ${makewrapout} eval cat <<EOF ${makewrapout}
#! ${HOST_SH} #! ${HOST_SH}
# Set proper variables to allow easy "make" building of a NetBSD subtree. # Set proper variables to allow easy "make" building of a NetBSD subtree.
# Generated from: \$NetBSD: build.sh,v 1.256 2012/09/29 04:02:42 tsutsui Exp $ # Generated from: \$NetBSD: build.sh,v 1.273 2013/08/30 10:29:06 pooka Exp $
# with these arguments: ${_args} # with these arguments: ${_args}
# #
@ -1730,8 +1803,7 @@ buildtools()
if [ "${MKUPDATE}" = "no" ]; then if [ "${MKUPDATE}" = "no" ]; then
make_in_dir tools cleandir make_in_dir tools cleandir
fi fi
make_in_dir tools dependall make_in_dir tools build_install
make_in_dir tools install
statusmsg "Tools built to ${TOOLDIR}" statusmsg "Tools built to ${TOOLDIR}"
} }
@ -1762,6 +1834,18 @@ getkernelconf()
kernelbuildpath="${KERNOBJDIR}/${kernelconfname}" kernelbuildpath="${KERNOBJDIR}/${kernelconfname}"
} }
diskimage()
{
ARG="$(echo $1 | tr '[:lower:]' '[:upper:]')"
[ -f "${DESTDIR}/etc/mtree/set.base" ] ||
bomb "The release binaries must be built first"
kerneldir="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel"
kernel="${kerneldir}/netbsd-${ARG}.gz"
[ -f "${kernel}" ] ||
bomb "The kernel ${kernel} must be built first"
make_in_dir "${NETBSDSRCDIR}/etc" "smp_${1}"
}
buildkernel() buildkernel()
{ {
if ! ${do_tools} && ! ${buildkernelwarned:-false}; then if ! ${do_tools} && ! ${buildkernelwarned:-false}; then
@ -1898,6 +1982,7 @@ dorump()
[ "${1}" != "rumptest" ] && bomb 'build.sh rump not yet functional. ' \ [ "${1}" != "rumptest" ] && bomb 'build.sh rump not yet functional. ' \
'did you mean "rumptest"?' 'did you mean "rumptest"?'
export RUMPKERN_ONLY=1
# create obj and distrib dirs # create obj and distrib dirs
if [ "${MKOBJDIRS}" != "no" ]; then if [ "${MKOBJDIRS}" != "no" ]; then
make_in_dir "${NETBSDSRCDIR}/etc/mtree" obj make_in_dir "${NETBSDSRCDIR}/etc/mtree" obj
@ -1938,7 +2023,7 @@ dorump()
/undefined reference/ && /undefined reference/ &&
!/more undefined references.*follow/{ !/more undefined references.*follow/{
if (match($NF, if (match($NF,
"`(rumpuser_|__" quirks ")") == 0) "`(rumpuser_|rumpcomp_|__" quirks ")") == 0)
fails[NR] = $0 fails[NR] = $0
} }
/cannot find -l/{fails[NR] = $0} /cannot find -l/{fails[NR] = $0}
@ -1995,7 +2080,7 @@ main()
statusmsg "Built sets to ${setdir}" statusmsg "Built sets to ${setdir}"
;; ;;
cleandir|obj|build|distribution|release|sourcesets|syspkgs|params) cleandir|obj|build|distribution|release|sourcesets|syspkgs|show-params)
${runcmd} "${makewrapper}" ${parallel} ${op} || ${runcmd} "${makewrapper}" ${parallel} ${op} ||
bomb "Failed to make ${op}" bomb "Failed to make ${op}"
statusmsg "Successful make ${op}" statusmsg "Successful make ${op}"
@ -2029,6 +2114,11 @@ main()
releasekernel "${arg}" releasekernel "${arg}"
;; ;;
disk-image=*)
arg=${op#*=}
diskimage "${arg}"
;;
modules) modules)
buildmodules buildmodules
;; ;;
@ -2036,7 +2126,7 @@ main()
installmodules=*) installmodules=*)
arg=${op#*=} arg=${op#*=}
if [ "${arg}" = "/" ] && \ if [ "${arg}" = "/" ] && \
( [ "${uname_s}" != "Minix" ] || \ ( ( [ "${uname_s}" != "NetBSD" ] && [ "${uname_s}" != "Minix" ] ) || \
[ "${uname_m}" != "${MACHINE}" ] ); then [ "${uname_m}" != "${MACHINE}" ] ); then
bomb "'${op}' must != / for cross builds." bomb "'${op}' must != / for cross builds."
fi fi
@ -2046,7 +2136,7 @@ main()
install=*) install=*)
arg=${op#*=} arg=${op#*=}
if [ "${arg}" = "/" ] && \ if [ "${arg}" = "/" ] && \
( [ "${uname_s}" != "Minix" ] || \ ( ( [ "${uname_s}" != "NetBSD" ] && [ "${uname_s}" != "Minix" ] ) || \
[ "${uname_m}" != "${MACHINE}" ] ); then [ "${uname_m}" != "${MACHINE}" ] ); then
bomb "'${op}' must != / for cross builds." bomb "'${op}' must != / for cross builds."
fi fi

View file

@ -1,5 +1,5 @@
FSCK= ${NETBSDSRCDIR}/sbin/fsck FSCK= ${NETBSDSRCDIR}/sbin/fsck
PROG= fsck.mfs PROG= fsck_mfs
SRCS= fsck.c SRCS= fsck.c
CPPFLAGS+= -I${NETBSDSRCDIR}/servers -I${FSCK} CPPFLAGS+= -I${NETBSDSRCDIR}/servers -I${FSCK}
BINDIR= /sbin BINDIR= /sbin

View file

@ -403,7 +403,7 @@ void devio(bno, dir)
block_nr bno; block_nr bno;
int dir; int dir;
{ {
int r; off_t r;
if(!block_size) fatal("devio() with unknown block size"); if(!block_size) fatal("devio() with unknown block size");
if (dir == READING && bno == thisblk) return; if (dir == READING && bno == thisblk) return;
@ -413,7 +413,7 @@ int dir;
printf("%s at block %5d\n", dir == READING ? "reading " : "writing", bno); printf("%s at block %5d\n", dir == READING ? "reading " : "writing", bno);
#endif #endif
r= lseek(dev, btoa64(bno), SEEK_SET); r= lseek(dev, btoa64(bno), SEEK_SET);
if (r < 0) if (r == (off_t)-1)
fatal("lseek failed"); fatal("lseek failed");
if (dir == READING) { if (dir == READING) {
if (read(dev, rwbuf, block_size) == block_size) if (read(dev, rwbuf, block_size) == block_size)

View file

@ -51,10 +51,6 @@
/* @(#) Id */ /* @(#) Id */
#if defined(__minix) && defined(_STANDALONE)
#include <lib/libkern/libkern.h>
#endif
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =

View file

@ -1,4 +1,4 @@
/* $NetBSD: gzio.c,v 1.3 2011/05/19 22:23:12 tsutsui Exp $ */ /* $NetBSD: gzio.c,v 1.4 2013/11/07 17:26:13 christos Exp $ */
/* gzio.c -- IO on .gz files /* gzio.c -- IO on .gz files
* Copyright (C) 1995-2005 Jean-loup Gailly. * Copyright (C) 1995-2005 Jean-loup Gailly.
@ -157,6 +157,8 @@ local gzFile gz_open (path, mode, fd)
if (s->mode == 'w') { if (s->mode == 'w') {
#ifdef NO_GZCOMPRESS #ifdef NO_GZCOMPRESS
err = Z_STREAM_ERROR; err = Z_STREAM_ERROR;
__USE(level);
__USE(strategy);
#else #else
err = deflateInit2(&(s->stream), level, err = deflateInit2(&(s->stream), level,
Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);

View file

@ -12,10 +12,6 @@
inflate_fast() can be used with either inflate.c or infback.c. inflate_fast() can be used with either inflate.c or infback.c.
*/ */
#if defined(__minix) && defined(_STANDALONE)
#include <lib/libkern/libkern.h>
#endif
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"

View file

@ -82,10 +82,6 @@
* The history for versions after 1.2.0 are in ChangeLog in zlib distribution. * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
*/ */
#if defined(__minix) && defined(_STANDALONE)
#include <lib/libkern/libkern.h>
#endif
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"

View file

@ -18,13 +18,12 @@
#define ZLIB_INTERNAL #define ZLIB_INTERNAL
#include "zlib.h" #include "zlib.h"
#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) #if (defined(__minix) || defined(__NetBSD__)) && (defined(_KERNEL) || defined(_STANDALONE))
/* XXX doesn't seem to need anything at all, but this is for consistency. */ /* XXX doesn't seem to need anything at all, but this is for consistency. */
# include <lib/libkern/libkern.h> # include <lib/libkern/libkern.h>
#else #else
#if defined(__minix) && !defined(_STANDALONE)
#ifdef STDC #ifdef STDC
# ifndef _WIN32_WCE # ifndef _WIN32_WCE
# include <stddef.h> # include <stddef.h>
@ -47,7 +46,6 @@
# include <errno.h> # include <errno.h>
# endif # endif
#endif #endif
#endif /* defined(__minix) && !defined(_STANDALONE) */
#endif /* __NetBSD__ && (_KERNEL || _STANDALONE) */ #endif /* __NetBSD__ && (_KERNEL || _STANDALONE) */
#ifndef local #ifndef local

View file

@ -0,0 +1,9 @@
# $Id: Makefile,v 1.1 2011/08/25 16:15:29 dyoung Exp $
# $NetBSD: Makefile,v 1.1 2011/08/25 16:15:29 dyoung Exp $
INCS= ppath.h ppath_impl.h
INCSDIR= /usr/include/ppath
.include <bsd.prog.mk>

View file

@ -0,0 +1,91 @@
/* $Id: ppath.h,v 1.1 2011/08/25 16:15:29 dyoung Exp $ */
/* Copyright (c) 2010 David Young. All rights reserved. */
#ifndef _PPATH_H
#define _PPATH_H
#include <prop/proplib.h>
#define PPATH_MAX_COMPONENTS 16
struct _ppath;
struct _ppath_component;
typedef struct _ppath ppath_t;
typedef struct _ppath_component ppath_component_t;
ppath_component_t *ppath_idx(unsigned int);
ppath_component_t *ppath_key(const char *);
ppath_component_t *ppath_component_retain(ppath_component_t *);
void ppath_component_release(ppath_component_t *);
ppath_t *ppath_create(void);
unsigned int ppath_length(const ppath_t *);
int ppath_component_idx(const ppath_component_t *);
const char *ppath_component_key(const ppath_component_t *);
ppath_t *ppath_pop(ppath_t *, ppath_component_t **);
ppath_t *ppath_push(ppath_t *, ppath_component_t *);
ppath_component_t *ppath_component_at(const ppath_t *, unsigned int);
ppath_t *ppath_subpath(const ppath_t *, unsigned int, unsigned int);
ppath_t *ppath_push_idx(ppath_t *, unsigned int);
ppath_t *ppath_push_key(ppath_t *, const char *);
ppath_t *ppath_replace_idx(ppath_t *, unsigned int);
ppath_t *ppath_replace_key(ppath_t *, const char *);
ppath_t *ppath_copy(const ppath_t *);
ppath_t *ppath_retain(ppath_t *);
void ppath_release(ppath_t *);
prop_object_t ppath_lookup(prop_object_t, const ppath_t *);
int ppath_copydel_object(prop_object_t, prop_object_t *, const ppath_t *);
int ppath_copyset_object(prop_object_t, prop_object_t *, const ppath_t *,
prop_object_t);
int ppath_create_object(prop_object_t, const ppath_t *, prop_object_t);
int ppath_set_object(prop_object_t, const ppath_t *, prop_object_t);
int ppath_get_object(prop_object_t, const ppath_t *, prop_object_t *);
int ppath_delete_object(prop_object_t, const ppath_t *);
int ppath_copydel_bool(prop_object_t, prop_object_t *, const ppath_t *);
int ppath_copyset_bool(prop_object_t, prop_object_t *, const ppath_t *, bool);
int ppath_create_bool(prop_object_t, const ppath_t *, bool);
int ppath_create_int64(prop_object_t, const ppath_t *, int64_t);
int ppath_create_uint64(prop_object_t, const ppath_t *, uint64_t);
int ppath_create_data(prop_object_t, const ppath_t *, const void *, size_t);
int ppath_create_string(prop_object_t, const ppath_t *, const char *);
int ppath_set_bool(prop_object_t, const ppath_t *, bool);
int ppath_get_bool(prop_object_t, const ppath_t *, bool *);
int ppath_delete_bool(prop_object_t, const ppath_t *);
int ppath_copydel_data(prop_object_t, prop_object_t *, const ppath_t *);
int ppath_copyset_data(prop_object_t, prop_object_t *, const ppath_t *,
const void *, size_t);
int ppath_set_data(prop_object_t, const ppath_t *, const void *, size_t);
int ppath_get_data(prop_object_t, const ppath_t *, const void **, size_t *);
int ppath_dup_data(prop_object_t, const ppath_t *, void **, size_t *);
int ppath_delete_data(prop_object_t, const ppath_t *);
int ppath_copydel_int64(prop_object_t, prop_object_t *, const ppath_t *);
int ppath_copyset_int64(prop_object_t, prop_object_t *, const ppath_t *,
int64_t);
int ppath_set_int64(prop_object_t, const ppath_t *, int64_t);
int ppath_get_int64(prop_object_t, const ppath_t *, int64_t *);
int ppath_delete_int64(prop_object_t, const ppath_t *);
int ppath_copydel_string(prop_object_t, prop_object_t *, const ppath_t *);
int ppath_copyset_string(prop_object_t, prop_object_t *, const ppath_t *,
const char *);
int ppath_set_string(prop_object_t, const ppath_t *, const char *);
int ppath_get_string(prop_object_t, const ppath_t *, const char **);
int ppath_dup_string(prop_object_t, const ppath_t *, char **);
int ppath_delete_string(prop_object_t, const ppath_t *);
int ppath_copydel_uint64(prop_object_t, prop_object_t *, const ppath_t *);
int ppath_copyset_uint64(prop_object_t, prop_object_t *, const ppath_t *,
uint64_t);
int ppath_set_uint64(prop_object_t, const ppath_t *, uint64_t);
int ppath_get_uint64(prop_object_t, const ppath_t *, uint64_t *);
int ppath_delete_uint64(prop_object_t, const ppath_t *);
#endif /* _PPATH_H */

View file

@ -0,0 +1,23 @@
/* $Id: ppath_impl.h,v 1.1 2011/08/25 16:15:29 dyoung Exp $ */
/* Copyright (c) 2010 David Young. All rights reserved. */
#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))
#include <lib/libkern/libkern.h>
#include <sys/errno.h>
#define ppath_assert(__x) KASSERT(__x)
#else
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#define ppath_assert(__x) assert(__x)
#endif /* defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) */
void *ppath_alloc(size_t);
void ppath_free(void *, size_t);
void ppath_component_extant_inc(void);
void ppath_component_extant_dec(void);
void ppath_extant_inc(void);
void ppath_extant_dec(void);

View file

@ -1,16 +1,22 @@
# $NetBSD: Makefile.inc,v 1.10 2012/09/11 20:51:25 matt Exp $ # $NetBSD: Makefile.inc,v 1.14 2013/11/08 22:42:52 matt Exp $
ARMV6= ${CPUFLAGS:M-march=armv7*} ${CPUFLAGS:M-mcpu=cortex*} ARMV6= ${CPUFLAGS:M-march=armv6*} ${CPUFLAGS:M-mcpu=arm11*}
ARMV6+= ${CPUFLAGS:M-march=armv6*} ${CPUFLAGS:M-mcpu=arm11*}
ARMV6+= ${CFLAGS:M-march=armv7*:} ${CFLAGS:M-mcpu=cortex*}
ARMV6+= ${CFLAGS:M-march=armv6*:} ${CFLAGS:M-mcpu=arm11*} ARMV6+= ${CFLAGS:M-march=armv6*:} ${CFLAGS:M-mcpu=arm11*}
ARMV6+= ${CPPFLAGS:M-march=armv7*:} ${CPPFLAGS:M-mcpu=cortex*}
ARMV6+= ${CPPFLAGS:M-march=armv6*:} ${CPPFLAGS:M-mcpu=arm11*} ARMV6+= ${CPPFLAGS:M-march=armv6*:} ${CPPFLAGS:M-mcpu=arm11*}
ARMV7= ${CPUFLAGS:M-march=armv7*} ${CPUFLAGS:M-mcpu=cortex*}
ARMV7+= ${CFLAGS:M-march=armv7*:} ${CFLAGS:M-mcpu=cortex*}
ARMV7+= ${CPPFLAGS:M-march=armv7*:} ${CPPFLAGS:M-mcpu=cortex*}
.if empty(CFLAGS:M-march=*) && empty(CFLAGS:M-mcpu=*) \
&& empty(CPPFLAGS:M-march=*) && empty(CPPFLAGS:M-mcpu=*) \
&& empty(CPUFLAGS:M-march=*) && empty(CPUFLAGS:M-mcpu=*)
ARMV6+= ${MACHINE_ARCH:Mearmv6*}
ARMV7+= ${MACHINE_ARCH:Mearmv7*}
.endif
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
|| ${LIB} == "rump" || (defined(__MINIX) && ${LIB} == "sys")) || ${LIB} == "rump" || (defined(__MINIX) && ${LIB} == "sys"))
.if empty(ARMV6) .if empty(ARMV6) && empty(ARMV7)
SRCS.atomic+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \ SRCS.atomic+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \
atomic_and_32_cas.c atomic_and_32_nv_cas.c \ atomic_and_32_cas.c atomic_and_32_nv_cas.c \
atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
@ -18,19 +24,37 @@ SRCS.atomic+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \
atomic_or_32_cas.c atomic_or_32_nv_cas.c \ atomic_or_32_cas.c atomic_or_32_nv_cas.c \
atomic_swap_32_cas.c membar_ops_nop.c atomic_swap_32_cas.c membar_ops_nop.c
.else .else
SRCS.atomic+= atomic_add_32.S atomic_and_32.S atomic_cas_32.S .for op in add and cas nand or xor
SRCS.atomic+= atomic_dec_32.S atomic_inc_32.S atomic_or_32.S .for sz in 8 16 32 64
SRCS.atomic+= atomic_swap.S membar_ops.S SRCS.atomic+= atomic_${op}_${sz}.S
SRCS.atomic+= atomic_add_64.S atomic_and_64.S atomic_cas_64.S .endfor
SRCS.atomic+= atomic_dec_64.S atomic_inc_64.S atomic_or_64.S .endfor
SRCS.atomic+= atomic_swap_64.S SRCS.atomic+= atomic_dec_32.S atomic_dec_64.S
SRCS.atomic+= atomic_inc_32.S atomic_inc_64.S
SRCS.atomic+= atomic_swap.S atomic_swap_16.S atomic_swap_64.S
SRCS.atomic+= membar_ops.S
.for op in add and nand or sub xor
SRCS.atomic+= sync_fetch_and_${op}_8.S
.endfor
.for sz in 1 2 4 8
SRCS.atomic+= sync_bool_compare_and_swap_${sz}.S
.endfor
.endif
.endif
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread" || ${LIB} == "rump")
SRCS.atomic+= atomic_simplelock.c
.if empty(ARMV7)
CPUFLAGS.atomic_simplelock.c+= -marm
.endif .endif
.endif .endif
.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread") .if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
.if empty(ARMV6) .if empty(ARMV6) && empty(ARMV7)
SRCS.atomic+= atomic_init_testset.c SRCS.atomic+= atomic_init_testset.c
SRCS.atomic+= atomic_cas_up.S SRCS.atomic+= atomic_cas_up.S
CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
@ -40,4 +64,10 @@ SRCS.atomic+= atomic_init_cas.c
.endif .endif
.if !empty(ARMV6)
.for f in ${SRCS.atomic:M*.S}
CPUFLAGS.$f+= -marm
.endfor
.endif
SRCS+= ${SRCS.atomic} SRCS+= ${SRCS.atomic}

View file

@ -0,0 +1,100 @@
/* $NetBSD: atomic_add_16.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_sub_16)
negs r1, r1
/* FALLTHROUGH */
ENTRY_NP(_atomic_add_16)
mov ip, r0
1: ldrexh r0, [ip] /* load old value */
adds r3, r0, r1 /* calculate new value */
strexh r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_add_16)
END(_atomic_sub_16)
ATOMIC_OP_ALIAS(atomic_add_16,_atomic_add_16)
ATOMIC_OP_ALIAS(atomic_add_short,_atomic_add_16)
ATOMIC_OP_ALIAS(atomic_add_ushort,_atomic_add_16)
STRONG_ALIAS(__sync_fetch_and_add_2,_atomic_add_16)
STRONG_ALIAS(_atomic_add_short,_atomic_add_16)
STRONG_ALIAS(_atomic_add_ushort,_atomic_add_16)
ATOMIC_OP_ALIAS(atomic_sub_16,_atomic_sub_16)
ATOMIC_OP_ALIAS(atomic_sub_short,_atomic_sub_16)
ATOMIC_OP_ALIAS(atomic_sub_ushort,_atomic_sub_16)
STRONG_ALIAS(__sync_fetch_and_sub_2,_atomic_sub_16)
STRONG_ALIAS(_atomic_sub_short,_atomic_sub_16)
STRONG_ALIAS(_atomic_sub_ushort,_atomic_sub_16)
ENTRY_NP(_atomic_sub_16_nv)
negs r1, r1
/* FALLTHROUGH */
ENTRY_NP(_atomic_add_16_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexh r0, [ip] /* load old value */
adds r0, r0, r1 /* calculate new value (return value) */
strexh r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_add_16_nv)
END(_atomic_sub_16_nv)
ATOMIC_OP_ALIAS(atomic_add_16_nv,_atomic_add_16_nv)
ATOMIC_OP_ALIAS(atomic_add_short_nv,_atomic_add_16_nv)
ATOMIC_OP_ALIAS(atomic_add_ushort_nv,_atomic_add_16_nv)
STRONG_ALIAS(__sync_add_and_fetch_2,_atomic_add_16_nv)
STRONG_ALIAS(_atomic_add_short_nv,_atomic_add_16_nv)
STRONG_ALIAS(_atomic_add_ushort_nv,_atomic_add_16_nv)
ATOMIC_OP_ALIAS(atomic_sub_16_nv,_atomic_sub_16_nv)
ATOMIC_OP_ALIAS(atomic_sub_short_nv,_atomic_sub_16_nv)
ATOMIC_OP_ALIAS(atomic_sub_ushort_nv,_atomic_sub_16_nv)
STRONG_ALIAS(__sync_sub_and_fetch_2,_atomic_sub_16_nv)
STRONG_ALIAS(_atomic_sub_short_nv,_atomic_sub_16_nv)
STRONG_ALIAS(_atomic_sub_ushort_nv,_atomic_sub_16_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_add_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_add_32.S,v 1.6 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -33,48 +33,76 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_sub_32)
negs r1, r1
/* FALLTHROUGH */
ENTRY_NP(_atomic_add_32) ENTRY_NP(_atomic_add_32)
mov r3, r0 /* need r0 for return value */ mov ip, r0
1: ldrex r0, [r3] /* load old value (to be returned) */ 1: ldrex r0, [ip] /* load old value */
add r2, r0, r1 /* calculate new value */ adds r3, r0, r1 /* calculate new value */
strex ip, r2, [r3] /* try to store */ strex r2, r3, [ip] /* try to store */
cmp ip, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again */ bne 1b /* no, try again */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return old value */ RET /* return old value */
END(_atomic_add_32) END(_atomic_add_32)
END(_atomic_sub_32)
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32) ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32) ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32) ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32) ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32)
STRONG_ALIAS(__sync_fetch_and_add_4,_atomic_add_32)
STRONG_ALIAS(_atomic_add_int,_atomic_add_32) STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
STRONG_ALIAS(_atomic_add_long,_atomic_add_32) STRONG_ALIAS(_atomic_add_long,_atomic_add_32)
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32) STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_sub_32,_atomic_sub_32)
ATOMIC_OP_ALIAS(atomic_sub_int,_atomic_sub_32)
ATOMIC_OP_ALIAS(atomic_sub_long,_atomic_sub_32)
ATOMIC_OP_ALIAS(atomic_sub_ptr,_atomic_sub_32)
STRONG_ALIAS(__sync_fetch_and_sub_4,_atomic_sub_32)
STRONG_ALIAS(_atomic_sub_int,_atomic_sub_32)
STRONG_ALIAS(_atomic_sub_long,_atomic_sub_32)
STRONG_ALIAS(_atomic_sub_ptr,_atomic_sub_32)
ENTRY_NP(_atomic_sub_32_nv)
negs r1, r1
/* FALLTHROUGH */
ENTRY_NP(_atomic_add_32_nv) ENTRY_NP(_atomic_add_32_nv)
mov r3, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrex r0, [r3] /* load old value */ 1: ldrex r0, [ip] /* load old value */
add r0, r0, r1 /* calculate new value (return value) */ adds r0, r0, r1 /* calculate new value (return value) */
strex r2, r0, [r3] /* try to store */ strex r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_add_32_nv) END(_atomic_add_32_nv)
END(_atomic_sub_32_nv)
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv) ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv) ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv) ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv) ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
STRONG_ALIAS(__sync_add_and_fetch_4,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv) STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv) STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv) STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_sub_32_nv,_atomic_sub_32_nv)
ATOMIC_OP_ALIAS(atomic_sub_int_nv,_atomic_sub_32_nv)
ATOMIC_OP_ALIAS(atomic_sub_long_nv,_atomic_sub_32_nv)
ATOMIC_OP_ALIAS(atomic_sub_ptr_nv,_atomic_sub_32_nv)
STRONG_ALIAS(__sync_sub_and_fetch_4,_atomic_sub_32_nv)
STRONG_ALIAS(_atomic_sub_int_nv,_atomic_sub_32_nv)
STRONG_ALIAS(_atomic_sub_long_nv,_atomic_sub_32_nv)
STRONG_ALIAS(_atomic_sub_ptr_nv,_atomic_sub_32_nv)
#endif /* _ARM_ARCH_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_add_64.S,v 1.3 2012/09/13 00:36:12 matt Exp $ */ /* $NetBSD: atomic_add_64.S,v 1.10 2013/11/30 20:43:53 joerg Exp $ */
/*- /*-
* Copyright (c) 2012 The NetBSD Foundation, Inc. * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -32,50 +32,31 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_add_64)
str r4, [sp, #-4]! /* save temporary */
mov r4, r0 /* need r0 for return value */
#ifndef __ARM_EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, [r4] /* load old value (to be returned) */
adds NLO, LO, NLO /* calculate new value */
adc NHI, HI, NHI /* calculate new value */
strexd ip, r2, [r4] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
#endif
ldr r4, [sp], #4 /* restore temporary */
RET /* return old value */
END(_atomic_add_64)
ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64)
ENTRY_NP(_atomic_add_64_nv) ENTRY_NP(_atomic_add_64_nv)
str r4, [sp, #-4]! /* save temporary */ push {r3,r4} /* save temporary */
mov r4, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
#ifndef __ARM_EABI__ #ifndef __ARM_EABI__
mov r3, r2 mov r3, r2
mov r2, r1 mov r2, r1
#endif #endif
1: ldrexd r0, [r4] /* load old value */ 1: ldrexd r0, r1, [ip] /* load old value */
adds LO, LO, NLO /* calculate new value lo */ adds LO, LO, NLO /* calculate new value lo */
adc HI, HI, NHI /* calculate new value hi */ adcs HI, HI, NHI /* calculate new value hi */
strexd ip, r0, [r4] /* try to store */ strexd r4, r0, r1, [ip] /* try to store */
cmp ip, #0 /* succeed? */ cmp r4, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */
#endif #endif
ldr r4, [sp], #4 /* restore temporary */ pop {r3,r4} /* restore temporary */
RET /* return new value */ RET /* return new value */
END(_atomic_add_64_nv) END(_atomic_add_64_nv)
STRONG_ALIAS(_atomic_add_64,_atomic_add_64_nv)
ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv) ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64)
STRONG_ALIAS(__sync_add_and_fetch_8,_atomic_add_64_nv)
#endif /* _ARM_ARCH_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,100 @@
/* $NetBSD: atomic_add_8.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_sub_8)
negs r1, r1
/* FALLTHROUGH */
ENTRY_NP(_atomic_add_8)
mov ip, r0
1: ldrexb r0, [ip] /* load old value */
adds r3, r0, r1 /* calculate new value */
strexb r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_add_8)
END(_atomic_sub_8)
ATOMIC_OP_ALIAS(atomic_add_8,_atomic_add_8)
ATOMIC_OP_ALIAS(atomic_add_char,_atomic_add_8)
ATOMIC_OP_ALIAS(atomic_add_uchar,_atomic_add_8)
STRONG_ALIAS(__sync_fetch_and_add_1,_atomic_add_8)
STRONG_ALIAS(_atomic_add_char,_atomic_add_8)
STRONG_ALIAS(_atomic_add_uchar,_atomic_add_8)
ATOMIC_OP_ALIAS(atomic_sub_8,_atomic_sub_8)
ATOMIC_OP_ALIAS(atomic_sub_char,_atomic_sub_8)
ATOMIC_OP_ALIAS(atomic_sub_uchar,_atomic_sub_8)
STRONG_ALIAS(__sync_fetch_and_sub_1,_atomic_sub_8)
STRONG_ALIAS(_atomic_sub_char,_atomic_sub_8)
STRONG_ALIAS(_atomic_sub_uchar,_atomic_sub_8)
ENTRY_NP(_atomic_sub_8_nv)
negs r1, r1
/* FALLTHROUGH */
ENTRY_NP(_atomic_add_8_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexb r0, [ip] /* load old value */
adds r0, r0, r1 /* calculate new value (return value) */
strexb r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_add_8_nv)
END(_atomic_sub_8_nv)
ATOMIC_OP_ALIAS(atomic_add_8_nv,_atomic_add_8_nv)
ATOMIC_OP_ALIAS(atomic_add_char_nv,_atomic_add_8_nv)
ATOMIC_OP_ALIAS(atomic_add_uchar_nv,_atomic_add_8_nv)
STRONG_ALIAS(__sync_add_and_fetch_1,_atomic_add_8_nv)
STRONG_ALIAS(_atomic_add_char_nv,_atomic_add_8_nv)
STRONG_ALIAS(_atomic_add_uchar_nv,_atomic_add_8_nv)
ATOMIC_OP_ALIAS(atomic_sub_8_nv,_atomic_sub_8_nv)
ATOMIC_OP_ALIAS(atomic_sub_char_nv,_atomic_sub_8_nv)
ATOMIC_OP_ALIAS(atomic_sub_uchar_nv,_atomic_sub_8_nv)
STRONG_ALIAS(__sync_sub_and_fetch_1,_atomic_sub_8_nv)
STRONG_ALIAS(_atomic_sub_char_nv,_atomic_sub_8_nv)
STRONG_ALIAS(_atomic_sub_uchar_nv,_atomic_sub_8_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,76 @@
/* $NetBSD: atomic_and_16.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_and_16)
mov ip, r0
1: ldrexh r0, [ip] /* load old value (to be returned) */
ands r3, r0, r1 /* calculate new value */
strexh r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_and_16)
ATOMIC_OP_ALIAS(atomic_and_16,_atomic_and_16)
ATOMIC_OP_ALIAS(atomic_and_ushort,_atomic_and_16)
STRONG_ALIAS(__sync_fetch_and_and_2,_atomic_and_16)
STRONG_ALIAS(_atomic_and_ushort,_atomic_and_16)
ENTRY_NP(_atomic_and_16_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexh r0, [ip] /* load old value */
ands r0, r0, r1 /* calculate new value (return value) */
strexh r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_and_16_nv)
ATOMIC_OP_ALIAS(atomic_and_16_nv,_atomic_and_16_nv)
ATOMIC_OP_ALIAS(atomic_and_ushort_nv,_atomic_and_16_nv)
STRONG_ALIAS(__sync_and_and_fetch_2,_atomic_and_16_nv)
STRONG_ALIAS(_atomic_and_ushort_nv,_atomic_and_16_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_and_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_and_32.S,v 1.6 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -34,42 +34,46 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_and_32) ENTRY_NP(_atomic_and_32)
mov r3, r0 /* need r0 for return value */ mov ip, r0
1: ldrex r0, [r3] /* load old value (to be returned) */ 1: ldrex r0, [ip] /* load old value (to be returned) */
and r2, r0, r1 /* calculate new value */ ands r3, r0, r1 /* calculate new value */
strex ip, r2, [r3] /* try to store */ strex r2, r3, [ip] /* try to store */
cmp ip, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again */ bne 1b /* no, try again */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return old value */ RET /* return old value */
END(_atomic_and_32) END(_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32) ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32) ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32) ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32)
STRONG_ALIAS(__sync_fetch_and_and_4,_atomic_and_32)
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
ENTRY_NP(_atomic_and_32_nv) ENTRY_NP(_atomic_and_32_nv)
mov r3, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrex r0, [r3] /* load old value */ 1: ldrex r0, [ip] /* load old value */
and r0, r0, r1 /* calculate new value (return value) */ ands r0, r0, r1 /* calculate new value (return value) */
strex r2, r0, [r3] /* try to store */ strex r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_and_32_nv) END(_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv) ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv) ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv) ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
STRONG_ALIAS(__sync_and_and_fetch_4,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv) STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv) STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_and_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */ /* $NetBSD: atomic_and_64.S,v 1.9 2013/11/30 21:09:11 joerg Exp $ */
/*- /*-
* Copyright (c) 2012 The NetBSD Foundation, Inc. * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -32,50 +32,31 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_and_64)
str r4, [sp, #-4]! /* save temporary */
#ifndef __ARM_EABI__
mov r3, r2
mov r2, r1
#endif
mov r4, r0 /* need r0 for return value */
1: ldrexd r0, [r4] /* load old value (to be returned) */
and r2, r0, r2 /* calculate new value */
and r3, r1, r3 /* calculate new value */
strexd ip, r2, [r4] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
#endif
ldr r4, [sp], #4 /* restore temporary */
RET /* return old value */
END(_atomic_and_64)
ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64)
ENTRY_NP(_atomic_and_64_nv) ENTRY_NP(_atomic_and_64_nv)
str r4, [sp, #-4]! /* save temporary */ push {r3,r4} /* save temporary */
#ifndef __ARM_EABI__ #ifndef __ARM_EABI__
mov r3, r2 mov r3, r2
mov r2, r1 mov r2, r1
#endif #endif
mov r4, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrexd r0, [r4] /* load old value */ 1: ldrexd r0, r1, [ip] /* load old value */
and r0, r0, r2 /* calculate new value */ ands r0, r0, r2 /* calculate new value */
and r1, r1, r3 /* calculate new value */ ands r1, r1, r3 /* calculate new value */
strexd ip, r0, [r4] /* try to store */ strexd r4, r0, r1, [ip] /* try to store */
cmp ip, #0 /* succeed? */ cmp r4, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */
#endif #endif
ldr r4, [sp], #4 /* restore temporary */ pop {r3,r4} /* restore temporary */
RET /* return new value */ RET /* return new value */
END(_atomic_and_64_nv) END(_atomic_and_64_nv)
STRONG_ALIAS(_atomic_and_64,_atomic_and_64_nv)
ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv) ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64_nv)
STRONG_ALIAS(__sync_and_and_fetch_8,_atomic_and_64_nv)
#endif /* _ARM_ARCH_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,76 @@
/* $NetBSD: atomic_and_8.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_and_8)
mov ip, r0
1: ldrexb r0, [ip] /* load old value (to be returned) */
ands r3, r0, r1 /* calculate new value */
strexb r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_and_8)
ATOMIC_OP_ALIAS(atomic_and_8,_atomic_and_8)
ATOMIC_OP_ALIAS(atomic_and_uchar,_atomic_and_8)
STRONG_ALIAS(__sync_fetch_and_and_1,_atomic_and_8)
STRONG_ALIAS(_atomic_and_uchar,_atomic_and_8)
ENTRY_NP(_atomic_and_8_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexb r0, [ip] /* load old value */
ands r0, r0, r1 /* calculate new value (return value) */
strexb r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_and_8_nv)
ATOMIC_OP_ALIAS(atomic_and_8_nv,_atomic_and_8_nv)
ATOMIC_OP_ALIAS(atomic_and_uchar_nv,_atomic_and_8_nv)
STRONG_ALIAS(__sync_and_and_fetch_1,_atomic_and_8_nv)
STRONG_ALIAS(_atomic_and_uchar_nv,_atomic_and_8_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,64 @@
/* $NetBSD: atomic_cas_16.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#if defined(_ARM_ARCH_6)
/*
* ARMv6 has load-exclusive/store-exclusive which works for both user
* and kernel.
*/
ENTRY_NP(_atomic_cas_16)
mov ip, r0 /* we need r0 for return value */
1:
ldrexh r0, [ip] /* load old value */
cmp r0, r1 /* compare? */
#ifdef __thumb__
bne 2f
#else
RETc(ne) /* return if different */
#endif
strexh r3, r2, [ip] /* store new value */
cmp r3, #0 /* succeed? */
bne 1b /* nope, try again. */
#ifdef _ARM_ARCH_7
dsb /* data synchronization barrier */
#else
mcr p15, 0, r3, c7, c10, 4 /* data synchronization barrier */
#endif
2: RET /* return. */
END(_atomic_cas_16)
ATOMIC_OP_ALIAS(atomic_cas_16,_atomic_cas_16)
STRONG_ALIAS(_atomic_cas_short,_atomic_cas_16)
STRONG_ALIAS(_atomic_cas_ushort,_atomic_cas_16)
STRONG_ALIAS(__sync_val_compare_and_swap_2,_atomic_cas_16)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_cas_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_cas_32.S,v 1.6 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -36,21 +36,25 @@
* and kernel. * and kernel.
*/ */
ENTRY_NP(_atomic_cas_32) ENTRY_NP(_atomic_cas_32)
mov r3, r0 /* we need r0 for return value */ mov ip, r0 /* we need r0 for return value */
1: 1:
ldrex r0, [r3] /* load old value */ ldrex r0, [ip] /* load old value */
teq r0, r1 /* compare? */ cmp r0, r1 /* compare? */
#ifdef __thumb__
bne 2f /* return if different */
#else
RETc(ne) /* return if different */ RETc(ne) /* return if different */
strex ip, r2, [r3] /* store new value */ #endif
cmp ip, #0 /* succeed? */ strex r3, r2, [ip] /* store new value */
cmp r3, #0 /* succeed? */
bne 1b /* nope, try again. */ bne 1b /* nope, try again. */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dsb dsb
#else #else
mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */ mcr p15, 0, r3, c7, c10, 4 /* data synchronization barrier */
#endif #endif
RET /* return. */ 2: RET /* return. */
END(_atomic_cas_32) END(_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
@ -60,6 +64,7 @@ ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32) ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
STRONG_ALIAS(__sync_val_compare_and_swap_4,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
@ -68,4 +73,4 @@ STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32) STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
#endif /* _ARCH_ARM_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_cas_64.S,v 1.1 2012/09/11 20:51:25 matt Exp $ */ /* $NetBSD: atomic_cas_64.S,v 1.5 2013/11/30 21:09:11 joerg Exp $ */
/*- /*-
* Copyright (c) 2012 The NetBSD Foundation, Inc. * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -36,23 +36,28 @@
* and kernel. * and kernel.
*/ */
ENTRY_NP(_atomic_cas_64) ENTRY_NP(_atomic_cas_64)
stmfd sp!, {r4, r5, r6} /* save temporaries */ push {r4, r5, r6} /* save temporaries */
mov r6, r0 /* we need r0 for return value */ mov ip, r0 /* we need r0 for return value */
#ifdef __ARM_EABI__ #ifdef __ARM_EABI__
ldrd r4, [sp] /* fetch new value */ ldrd r4, r5, [sp] /* fetch new value */
#else #else
ldr r5, [sp, #4] /* fetch new value */
ldr r4, [sp, #0] /* fetch new value */ ldr r4, [sp, #0] /* fetch new value */
ldr r5, [sp, #4] /* fetch new value */
mov r3, r2 /* r2 will be overwritten by r1 which ... */ mov r3, r2 /* r2 will be overwritten by r1 which ... */
mov r2, r1 /* r1 will be overwritten by ldrexd */ mov r2, r1 /* r1 will be overwritten by ldrexd */
#endif #endif
1: 1:
ldrexd r0, [r6] /* load current value */ ldrexd r0, r1, [ip] /* load current value */
teq r0, r2 /* compare to old? 1st half */ cmp r0, r2 /* compare to old? 1st half */
teqeq r1, r3 /* compare to old? 2nd half */ #ifdef __thumb__
bne 2f /* jump to return if different */ bne 2f /* jump to return if different */
strexd ip, r4, [r6] /* store new value */ cmp r1, r3 /* compare to old? 2nd half */
cmp ip, #0 /* succeed? */ #else
cmpeq r1, r3 /* compare to old? 2nd half */
#endif
bne 2f /* jump to return if different */
strexd r6, r4, r5, [ip] /* store new value */
cmp r6, #0 /* succeed? */
bne 1b /* nope, try again. */ bne 1b /* nope, try again. */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dsb dsb
@ -60,10 +65,11 @@ ENTRY_NP(_atomic_cas_64)
mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */ mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
#endif #endif
2: 2:
ldmfd sp!, {r4, r5, r6} /* restore temporaries */ pop {r4, r5, r6} /* restore temporaries */
RET /* return. */ RET /* return. */
END(_atomic_cas_64) END(_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
STRONG_ALIAS(__sync_val_compare_and_swap_8,_atomic_cas_64)
#endif /* _ARCH_ARM_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -1,6 +1,7 @@
/* $NetBSD: atomic_cas_8.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_cas_8.S,v 1.6 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -36,24 +37,29 @@
* and kernel. * and kernel.
*/ */
ENTRY_NP(_atomic_cas_8) ENTRY_NP(_atomic_cas_8)
mov r3, r0 /* we need r0 for return value */ mov ip, r0 /* we need r0 for return value */
1: 1:
ldrexb r0, [r3] /* load old value */ ldrexb r0, [ip] /* load old value */
teq r0, r1 /* compare? */ cmp r0, r1 /* compare? */
#ifdef __thumb__
bne 2f
#else
RETc(ne) /* return if different */ RETc(ne) /* return if different */
strexb ip, r2, [r3] /* store new value */ #endif
cmp ip, #0 /* succeed? */ strexb r3, r2, [ip] /* store new value */
cmp r3, #0 /* succeed? */
bne 1b /* nope, try again. */ bne 1b /* nope, try again. */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dsb /* data synchronization barrier */ dsb /* data synchronization barrier */
#else #else
mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */ mcr p15, 0, r3, c7, c10, 4 /* data synchronization barrier */
#endif #endif
RET /* return. */ 2: RET /* return. */
END(_atomic_cas_8) END(_atomic_cas_8)
ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8) ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8)
STRONG_ALIAS(_atomic_cas_char,_atomic_cas_8) STRONG_ALIAS(_atomic_cas_char,_atomic_cas_8)
STRONG_ALIAS(_atomic_cas_uchar,_atomic_cas_8) STRONG_ALIAS(_atomic_cas_uchar,_atomic_cas_8)
STRONG_ALIAS(__sync_val_compare_and_swap_1,_atomic_cas_8)
#endif /* _ARCH_ARM_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_cas_up.S,v 1.2 2008/05/25 15:56:11 chs Exp $ */ /* $NetBSD: atomic_cas_up.S,v 1.4 2013/08/19 00:35:06 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -35,9 +35,16 @@
ENTRY(_atomic_cas_up) ENTRY(_atomic_cas_up)
.hidden _C_LABEL(_atomic_cas_up) .hidden _C_LABEL(_atomic_cas_up)
mov r3, r0 mov r3, r0
.align 0
RAS_START_ASM_HIDDEN(_atomic_cas) RAS_START_ASM_HIDDEN(_atomic_cas)
ldr r0, [r3] ldr r0, [r3]
cmp r0, r1 cmp r0, r1
#if defined(__thumb__)
beq 1f
#else
streq r2, [r3] streq r2, [r3]
#endif
.align 0
RAS_END_ASM_HIDDEN(_atomic_cas) RAS_END_ASM_HIDDEN(_atomic_cas)
RET 1: RET
END(_atomic_cas_up)

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_dec_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_dec_32.S,v 1.5 2013/08/11 04:41:17 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -33,19 +33,19 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_dec_32) ENTRY_NP(_atomic_dec_32)
mov r2, r0 /* need r0 for return value */ 1: ldrex r3, [r0] /* load old value (return value) */
1: ldrex r0, [r2] /* load old value (return value) */ subs r3, r3, #1 /* calculate new value */
sub r1, r0, #1 /* calculate new value */ strex r2, r3, [r0] /* try to store */
strex r3, r1, [r2] /* try to store */ cmp r2, #0 /* succeed? */
cmp r3, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_dec_32) END(_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32) ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32) ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32) ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32)
@ -55,19 +55,20 @@ STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32) STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32)
ENTRY_NP(_atomic_dec_32_nv) ENTRY_NP(_atomic_dec_32_nv)
mov r2, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrex r0, [r2] /* load old value */ 1: ldrex r0, [ip] /* load old value */
sub r0, r0, #1 /* calculate new value (return value) */ subs r0, r0, #1 /* calculate new value (return value) */
strex r1, r0, [r2] /* try to store */ strex r2, r0, [ip] /* try to store */
cmp r1, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_dec_32_nv) END(_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv) ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv) ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv) ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv)

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_dec_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */ /* $NetBSD: atomic_dec_64.S,v 1.7 2013/11/30 21:09:11 joerg Exp $ */
/*- /*-
* Copyright (c) 2012 The NetBSD Foundation, Inc. * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -32,42 +32,24 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_dec_64)
mvn r2, #0
mov r3, r0 /* need r0 for return value */
1: ldrexd r0, [r3] /* load old value (return value) */
adds LO, LO, r2 /* calculate new value */
adc HI, HI, r2 /* calculate new value */
strexd ip, r0, [r3] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
#endif
adds LO, LO, #1
adc HI, HI, #0
RET /* return old value */
END(_atomic_dec_64)
ATOMIC_OP_ALIAS(atomic_dec_64,_atomic_dec_64)
ENTRY_NP(_atomic_dec_64_nv) ENTRY_NP(_atomic_dec_64_nv)
mvn r2, #0 mov ip, r0 /* need r0 for return value */
mov r3, r0 /* need r0 for return value */ 1: ldrexd r0, r1, [ip] /* load old value */
1: ldrexd r0, [r3] /* load old value */ subs LO, LO, #1 /* calculate new value */
adds LO, LO, r2 /* calculate new value */ sbcs HI, HI, #0 /* calculate new value */
adc HI, HI, r2 /* calculate new value */ strexd r2, r0, r1, [ip] /* try to store */
strexd ip, r0, [r3] /* try to store */ cmp r2, #0 /* succeed? */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_dec_64_nv) END(_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_dec_64,_atomic_dec_64_nv)
ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv) ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
ATOMIC_OP_ALIAS(atomic_dec_64,_atomic_dec_64)
#endif /* _ARM_ARCH_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_inc_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_inc_32.S,v 1.7 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -33,19 +33,18 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_inc_32) ENTRY_NP(_atomic_inc_32)
mov r2, r0 /* need r0 for return value */ 1: ldrex r3, [r0] /* load old value (return value) */
1: ldrex r0, [r2] /* load old value (return value) */ adds r3, r3, #1 /* calculate new value */
add r1, r0, #1 /* calculate new value */ strex r2, r3, [r0] /* try to store */
strex r3, r1, [r2] /* try to store */ cmp r2, #0 /* succeed? */
cmp r3, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_inc_32) END(_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32) ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32) ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_32) ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_32)
@ -55,19 +54,19 @@ STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32) STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32)
ENTRY_NP(_atomic_inc_32_nv) ENTRY_NP(_atomic_inc_32_nv)
mov r2, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrex r0, [r2] /* load old value */ 1: ldrex r0, [ip] /* load old value */
add r0, r0, #1 /* calculate new value (return value) */ adds r0, r0, #1 /* calculate new value (return value) */
strex r1, r0, [r2] /* try to store */ strex r2, r0, [ip] /* try to store */
cmp r1, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_inc_32_nv) END(_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv) ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv) ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv) ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv)
@ -76,4 +75,4 @@ STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv) STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv) STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv)
#endif /* _ARCH_ARM_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_inc_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */ /* $NetBSD: atomic_inc_64.S,v 1.9 2013/11/30 21:09:11 joerg Exp $ */
/*- /*-
* Copyright (c) 2012 The NetBSD Foundation, Inc. * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -32,41 +32,24 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_inc_64)
mov r3, r0 /* need r0 for return value */
1: ldrexd r0, [r3] /* load old value (return value) */
adds LO, LO, #1 /* calculate new value */
adc HI, HI, #0 /* zero means we carried */
strexd ip, r0, [r3] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
#endif
mvn r2, #0 /* r2 = -1 */
adds LO, LO, r2 /* add it */
adc HI, HI, r2 /* add with carry */
RET /* return orig value */
END(_atomic_inc_64)
ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64)
ENTRY_NP(_atomic_inc_64_nv) ENTRY_NP(_atomic_inc_64_nv)
mov r3, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrexd r0, [r3] /* load old value */ 1: ldrexd r0, r1, [ip] /* load old value */
add LO, LO, #1 /* calculate new value (return value) */ adds LO, LO, #1 /* calculate new value (return value) */
adc HI, HI, #0 /* fold carry into high */ adcs HI, HI, #0 /* fold carry into high */
strexd ip, r0, [r3] /* try to store */ strexd r2, r0, r1, [ip] /* try to store */
cmp ip, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_inc_64_nv) END(_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
#endif /* _ARCH_ARM_6 */ STRONG_ALIAS(_atomic_inc_64,_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,78 @@
/* $NetBSD: atomic_nand_16.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_nand_16)
mov ip, r0
1: ldrexh r0, [ip] /* load old value (to be returned) */
mvns r3, r0 /* complement source */
ands r3, r3, r1 /* calculate new value */
strexh r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_nand_16)
ATOMIC_OP_ALIAS(atomic_nand_16,_atomic_nand_16)
ATOMIC_OP_ALIAS(atomic_nand_ushort,_atomic_nand_16)
STRONG_ALIAS(__sync_fetch_and_nand_2,_atomic_nand_16)
STRONG_ALIAS(_atomic_nand_ushort,_atomic_nand_16)
ENTRY_NP(_atomic_nand_16_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexh r0, [ip] /* load old value */
mvns r0, r0 /* complement source */
ands r0, r0, r1 /* calculate new value (return value) */
strexh r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_nand_16_nv)
ATOMIC_OP_ALIAS(atomic_nand_16_nv,_atomic_nand_16_nv)
ATOMIC_OP_ALIAS(atomic_nand_ushort_nv,_atomic_nand_16_nv)
STRONG_ALIAS(__sync_nand_and_fetch_2,_atomic_nand_16_nv)
STRONG_ALIAS(_atomic_nand_ushort_nv,_atomic_nand_16_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,82 @@
/* $NetBSD: atomic_nand_32.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_nand_32)
mov ip, r0
1: ldrex r0, [ip] /* load old value (to be returned) */
mvns r3, r0 /* complement source */
ands r3, r3, r1 /* calculate new value */
strex r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_nand_32)
ATOMIC_OP_ALIAS(atomic_nand_32,_atomic_nand_32)
ATOMIC_OP_ALIAS(atomic_nand_uint,_atomic_nand_32)
ATOMIC_OP_ALIAS(atomic_nand_ulong,_atomic_nand_32)
STRONG_ALIAS(__sync_fetch_and_nand_4,_atomic_nand_32)
STRONG_ALIAS(_atomic_nand_uint,_atomic_nand_32)
STRONG_ALIAS(_atomic_nand_ulong,_atomic_nand_32)
ENTRY_NP(_atomic_nand_32_nv)
mov ip, r0 /* need r0 for return value */
1: ldrex r0, [ip] /* load old value */
mvns r0, r0 /* complement source */
ands r0, r0, r1 /* calculate new value (return value) */
strex r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_nand_32_nv)
ATOMIC_OP_ALIAS(atomic_nand_32_nv,_atomic_nand_32_nv)
ATOMIC_OP_ALIAS(atomic_nand_uint_nv,_atomic_nand_32_nv)
ATOMIC_OP_ALIAS(atomic_nand_ulong_nv,_atomic_nand_32_nv)
STRONG_ALIAS(__sync_nand_and_fetch_4,_atomic_nand_32_nv)
STRONG_ALIAS(_atomic_nand_uint_nv,_atomic_nand_32_nv)
STRONG_ALIAS(_atomic_nand_ulong_nv,_atomic_nand_32_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,64 @@
/* $NetBSD: atomic_nand_64.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_nand_64_nv)
push {r3,r4} /* save temporary */
#ifndef __ARM_EABI__
mov r3, r2
mov r2, r1
#endif
mov ip, r0 /* need r0 for return value */
1: ldrexd r0, r1, [ip] /* load old value */
mvns r0, r0 /* complement old value */
mvns r1, r1 /* complement old value */
ands r0, r0, r2 /* calculate new value */
ands r1, r1, r3 /* calculate new value */
strexd r4, r0, r1, [ip] /* try to store */
cmp r4, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */
#endif
pop {r3,r4} /* restore temporary */
RET /* return new value */
END(_atomic_nand_64_nv)
STRONG_ALIAS(_atomic_nand_64,_atomic_nand_64_nv)
ATOMIC_OP_ALIAS(atomic_nand_64_nv,_atomic_nand_64_nv)
ATOMIC_OP_ALIAS(atomic_nand_64,_atomic_nand_64_nv)
STRONG_ALIAS(__sync_nand_and_fetch_8,_atomic_nand_64_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,78 @@
/* $NetBSD: atomic_nand_8.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_nand_8)
mov ip, r0
1: ldrexb r0, [ip] /* load old value (to be returned) */
mvns r3, r0 /* complement source */
ands r3, r3, r1 /* calculate new value */
strexb r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_nand_8)
ATOMIC_OP_ALIAS(atomic_nand_8,_atomic_nand_8)
ATOMIC_OP_ALIAS(atomic_nand_uchar,_atomic_nand_8)
STRONG_ALIAS(__sync_fetch_and_nand_1,_atomic_nand_8)
STRONG_ALIAS(_atomic_nand_uchar,_atomic_nand_8)
ENTRY_NP(_atomic_nand_8_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexb r0, [ip] /* load old value */
mvns r0, r0 /* complement source */
ands r0, r0, r1 /* calculate new value (return value) */
strexb r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_nand_8_nv)
ATOMIC_OP_ALIAS(atomic_nand_8_nv,_atomic_nand_8_nv)
ATOMIC_OP_ALIAS(atomic_nand_uchar_nv,_atomic_nand_8_nv)
STRONG_ALIAS(__sync_nand_and_fetch_1,_atomic_nand_8_nv)
STRONG_ALIAS(_atomic_nand_uchar_nv,_atomic_nand_8_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_op_asm.h,v 1.3 2012/09/11 20:51:25 matt Exp $ */ /* $NetBSD: atomic_op_asm.h,v 1.4 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -56,11 +56,15 @@
#define LO r1 #define LO r1
#define NHI r2 #define NHI r2
#define NLO r3 #define NLO r3
#define THI r4
#define TLO r5
#else #else
#define LO r0 #define LO r0
#define HI r1 #define HI r1
#define NLO r2 #define NLO r2
#define NHI r3 #define NHI r3
#define TLO r4
#define THI r5
#endif #endif
#endif /* _ATOMIC_OP_ASM_H_ */ #endif /* _ATOMIC_OP_ASM_H_ */

View file

@ -0,0 +1,75 @@
/* $NetBSD: atomic_or_16.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_or_16)
mov ip, r0
1: ldrexh r0, [ip] /* load old value (to be returned) */
orrs r3, r0, r1 /* calculate new value */
strexh r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_or_16)
ATOMIC_OP_ALIAS(atomic_or_16,_atomic_or_16)
ATOMIC_OP_ALIAS(atomic_or_ushort,_atomic_or_16)
STRONG_ALIAS(__sync_fetch_and_or_2,_atomic_or_16)
STRONG_ALIAS(_atomic_or_ushort,_atomic_or_16)
ENTRY_NP(_atomic_or_16_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexh r0, [ip] /* load old value */
orrs r0, r0, r1 /* calculate new value (return value) */
strexh r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_or_16_nv)
ATOMIC_OP_ALIAS(atomic_or_16_nv,_atomic_or_16_nv)
ATOMIC_OP_ALIAS(atomic_or_ushort_nv,_atomic_or_16_nv)
STRONG_ALIAS(__sync_or_and_fetch_2,_atomic_or_16_nv)
STRONG_ALIAS(_atomic_or_ushort_nv,_atomic_or_16_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_or_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_or_32.S,v 1.6 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -33,42 +33,46 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_or_32) ENTRY_NP(_atomic_or_32)
mov r3, r0 /* need r0 for return value */ mov ip, r0
1: ldrex r0, [r3] /* load old value (to be returned) */ 1: ldrex r0, [ip] /* load old value (to be returned) */
orr r2, r0, r1 /* calculate new value */ orrs r3, r0, r1 /* calculate new value */
strex ip, r2, [r3] /* try to store */ strex r2, r3, [ip] /* try to store */
cmp ip, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again */ bne 1b /* no, try again */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return old value */ RET /* return old value */
END(_atomic_or_32) END(_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32) ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32) ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32) ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32)
STRONG_ALIAS(__sync_fetch_and_or_4,_atomic_or_32)
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32) STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32) STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32)
ENTRY_NP(_atomic_or_32_nv) ENTRY_NP(_atomic_or_32_nv)
mov r3, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrex r0, [r3] /* load old value */ 1: ldrex r0, [ip] /* load old value */
orr r0, r0, r1 /* calculate new value (return value) */ orrs r0, r0, r1 /* calculate new value (return value) */
strex r2, r0, [r3] /* try to store */ strex r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */ cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif #endif
RET /* return new value */ RET /* return new value */
END(_atomic_or_32_nv) END(_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv) ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv) ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv) ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv)
STRONG_ALIAS(__sync_or_and_fetch_4,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv) STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv)

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_or_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */ /* $NetBSD: atomic_or_64.S,v 1.9 2013/11/30 21:09:11 joerg Exp $ */
/*- /*-
* Copyright (c) 2012 The NetBSD Foundation, Inc. * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -32,50 +32,31 @@
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_or_64)
str r4, [sp, #-4]! /* save temporary */
#ifndef __ARM_EABI__
mov r3, r2
mov r2, r1
#endif
mov r4, r0 /* need r0 for return value */
1: ldrexd r0, [r4] /* load old value (to be returned) */
orr r2, r0, r2 /* calculate new value */
orr r3, r1, r3 /* calculate new value */
strexd ip, r2, [r4] /* try to store */
cmp ip, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
#endif
ldr r4, [sp], #4 /* restore temporary */
RET /* return old value */
END(_atomic_or_64)
ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64)
ENTRY_NP(_atomic_or_64_nv) ENTRY_NP(_atomic_or_64_nv)
str r4, [sp, #-4]! /* save temporary */ push {r3,r4} /* save temporary */
#ifndef __ARM_EABI__ #ifndef __ARM_EABI__
mov r3, r2 mov r3, r2
mov r2, r1 mov r2, r1
#endif #endif
mov r4, r0 /* need r0 for return value */ mov ip, r0 /* need r0 for return value */
1: ldrexd r0, [r4] /* load old value */ 1: ldrexd r0, r1, [ip] /* load old value */
orr r0, r0, r2 /* calculate new value (return value) */ orrs r0, r0, r2 /* calculate new value (return value) */
orr r1, r1, r3 /* calculate new value (return value) */ orrs r1, r1, r3 /* calculate new value (return value) */
strexd ip, r0, [r4] /* try to store */ strexd r4, r0, r1, [ip] /* try to store */
cmp ip, #0 /* succeed? */ cmp r4, #0 /* succeed? */
bne 1b /* no, try again? */ bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */
#endif #endif
ldr r4, [sp], #4 /* restore temporary */ pop {r3,r4} /* restore temporary */
RET /* return new value */ RET /* return new value */
END(_atomic_or_64_nv) END(_atomic_or_64_nv)
STRONG_ALIAS(_atomic_or_64,_atomic_or_64_nv)
ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64_nv) ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64)
STRONG_ALIAS(__sync_or_and_fetch_8,_atomic_or_64)
#endif /* _ARM_ARCH_6 */ #endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,76 @@
/* $NetBSD: atomic_or_8.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_or_8)
mov ip, r0
1: ldrexb r0, [ip] /* load old value (to be returned) */
orrs r3, r0, r1 /* calculate new value */
strexb r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_or_8)
ATOMIC_OP_ALIAS(atomic_or_8,_atomic_or_8)
ATOMIC_OP_ALIAS(atomic_or_char,_atomic_or_8)
STRONG_ALIAS(__sync_fetch_and_or_1,_atomic_or_8)
STRONG_ALIAS(_atomic_or_char,_atomic_or_8)
ENTRY_NP(_atomic_or_8_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexb r0, [ip] /* load old value */
orrs r0, r0, r1 /* calculate new value (return value) */
strexb r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_or_8_nv)
ATOMIC_OP_ALIAS(atomic_or_8_nv,_atomic_or_8_nv)
ATOMIC_OP_ALIAS(atomic_or_char_nv,_atomic_or_8_nv)
STRONG_ALIAS(__sync_or_and_fetch_1,_atomic_or_8_nv)
STRONG_ALIAS(_atomic_or_char_nv,_atomic_or_8_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,72 @@
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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>
__RCSID("$NetBSD: atomic_simplelock.c,v 1.2 2013/08/16 01:47:41 matt Exp $");
#include <sys/types.h>
#if !defined(_ARM_ARCH_T2)
/*
* We need to use the inlines so redefine out of the way.
*/
#define __cpu_simple_lock __arm_simple_lock
#define __cpu_simple_lock_try __arm_simple_lock_try
#include <arm/lock.h>
/*
* Now get rid of them.
*/
#undef __cpu_simple_lock
#undef __cpu_simple_lock_try
/*
* Since we overrode lock.h we have to provide these ourselves.
*/
#ifdef __LIBPTHREAD_SOURCE__
__dso_hidden void __cpu_simple_lock(__cpu_simple_lock_t *);
__dso_hidden int __cpu_simple_lock_try(__cpu_simple_lock_t *);
#else
void __cpu_simple_lock(__cpu_simple_lock_t *);
int __cpu_simple_lock_try(__cpu_simple_lock_t *);
#endif
void
__cpu_simple_lock(__cpu_simple_lock_t *alp)
{
__arm_simple_lock(alp);
}
int
__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
{
return __arm_simple_lock_try(alp);
}
#endif

View file

@ -0,0 +1,63 @@
/* $NetBSD: atomic_sub_64.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_sub_64_nv)
push {r3,r4} /* save temporary */
mov ip, r0 /* need r0 for return value */
#ifndef __ARM_EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, [ip] /* load old value */
subs LO, LO, NLO /* calculate new value lo */
sbcs HI, HI, NHI /* calculate new value hi */
strexd r4, r0, [ip] /* try to store */
cmp r4, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */
#endif
pop {r3,r4} /* restore temporary */
RET /* return new value */
END(_atomic_sub_64_nv)
STRONG_ALIAS(_atomic_sub_64,_atomic_sub_64_nv)
ATOMIC_OP_ALIAS(atomic_sub_64_nv,_atomic_sub_64_nv)
ATOMIC_OP_ALIAS(atomic_sub_64,_atomic_sub_64)
STRONG_ALIAS(__sync_sub_and_fetch_8,_atomic_sub_64_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_swap.S,v 1.4 2012/08/31 23:41:52 matt Exp $ */ /* $NetBSD: atomic_swap.S,v 1.8 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2007,2012 The NetBSD Foundation, Inc. * Copyright (c) 2007,2012 The NetBSD Foundation, Inc.
@ -45,42 +45,58 @@
*/ */
ENTRY_NP(_atomic_swap_32) ENTRY_NP(_atomic_swap_32)
mov r2, r0 mov ip, r0
1: 1:
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ldrex r0, [r2] ldrex r0, [ip]
cmp r0, r1 cmp r0, r1
strexne ip, r1, [r2] #ifdef __thumb__
beq 99f
strex r3, r1, [ip]
cmp r3, #0
#else #else
swp r0, r1, [r2] strexne r3, r1, [ip]
cmp r0, r1 cmpne r3, #0
movsne ip, #0 #endif
#else
swp r0, r1, [ip]
cmp r0, r1
movnes r3, #0
cmpne r3, #0
#endif #endif
cmpne ip, #0
bne 1b bne 1b
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r3, c7, c10, 5 /* data memory barrier */
#endif #endif
99:
RET RET
END(_atomic_swap_32) END(_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32) ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32) ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32) ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32) ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32)
STRONG_ALIAS(__sync_lock_test_and_set_4,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32) STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32) STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
ENTRY_NP(__sync_lock_release_4)
mov r1, #0
strb r1, [r0]
RET
END(__sync_lock_release_4)
ENTRY_NP(_atomic_swap_8) ENTRY_NP(_atomic_swap_8)
mov r2, r0 mov ip, r0
1: 1:
#ifdef _ARM_ARCH_6 #ifdef _ARM_ARCH_6
ldrexb r0, [r2] ldrexb r0, [ip]
strexb r3, r1, [r2] strexb r3, r1, [ip]
#else #else
swpb r0, r1, [r2] swpb r0, r1, [ip]
mov r3, #0 mov r3, #0
#endif #endif
cmp r3, #0 cmp r3, #0
@ -91,9 +107,17 @@ ENTRY_NP(_atomic_swap_8)
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
#endif #endif
RET RET
END(_atomic_swap_8) END(_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8) ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_char,_atomic_swap_8) ATOMIC_OP_ALIAS(atomic_swap_char,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_uchar,_atomic_swap_8) ATOMIC_OP_ALIAS(atomic_swap_uchar,_atomic_swap_8)
STRONG_ALIAS(__sync_lock_test_and_set_1,_atomic_swap_8)
STRONG_ALIAS(_atomic_swap_char,_atomic_swap_8) STRONG_ALIAS(_atomic_swap_char,_atomic_swap_8)
STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_8) STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_8)
ENTRY_NP(__sync_lock_release_1)
mov r1, #0
strb r1, [r0]
RET
END(__sync_lock_release_1)

View file

@ -0,0 +1,62 @@
/* $NetBSD: atomic_swap_16.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_swap_16)
mov ip, r0
1:
ldrexh r0, [ip]
strexh r3, r1, [ip]
cmp r3, #0
bne 1b
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
#endif
RET
END(_atomic_swap_16)
ATOMIC_OP_ALIAS(atomic_swap_16,_atomic_swap_16)
ATOMIC_OP_ALIAS(atomic_swap_short,_atomic_swap_16)
ATOMIC_OP_ALIAS(atomic_swap_ushort,_atomic_swap_16)
STRONG_ALIAS(__sync_lock_test_and_set_2,_atomic_swap_16)
STRONG_ALIAS(_atomic_swap_short,_atomic_swap_16)
STRONG_ALIAS(_atomic_swap_ushort,_atomic_swap_16)
ENTRY_NP(__sync_lock_release_2)
mov r1, #0
strh r1, [r0]
RET
END(__sync_lock_release_2)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: atomic_swap_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */ /* $NetBSD: atomic_swap_64.S,v 1.7 2013/11/30 21:09:11 joerg Exp $ */
/*- /*-
* Copyright (c) 2012 The NetBSD Foundation, Inc. * Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -31,23 +31,30 @@
#include "atomic_op_asm.h" #include "atomic_op_asm.h"
ENTRY_NP(_atomic_swap_64) ENTRY_NP(_atomic_swap_64)
str r4, [sp, #-4]! /* save temporary */ push {r3,r4} /* save temporary */
mov r4, r0 /* return value will be in r0 */ mov ip, r0 /* return value will be in r0 */
#ifndef __ARM_EABI__ #ifndef __ARM_EABI__
mov r3, r2 /* r2 will be overwriten by r1 */ mov r3, r2 /* r2 will be overwriten by r1 */
mov r2, r1 /* and r1 will be overwritten by ldrexd */ mov r2, r1 /* and r1 will be overwritten by ldrexd */
#endif #endif
1: 1: ldrexd r0, r1, [ip] /* load old value */
ldrexd r0, [r4] /* load old value */ strexd r4, r2, r3, [ip] /* store new value */
strexd ip, r2, [r4] /* store new value */ cmp r4, #0 /* succeed? */
cmpne ip, #0 /* succeed? */
bne 1b /* no, try again */ bne 1b /* no, try again */
#ifdef _ARM_ARCH_7 #ifdef _ARM_ARCH_7
dmb dmb
#else #else
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */ mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */
#endif #endif
ldr r4, [sp], #4 /* restore temporary */ pop {r3,r4} /* restore temporary */
RET RET
END(_atomic_swap_64) END(_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64) ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64)
STRONG_ALIAS(__sync_lock_test_and_set_8,_atomic_swap_64)
ENTRY_NP(__sync_lock_release_8)
mov r2, #0
mov r3, #0
strd r2, r3, [r0]
RET
END(__sync_lock_release_8)

View file

@ -0,0 +1,76 @@
/* $NetBSD: atomic_xor_16.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_xor_16)
mov ip, r0
1: ldrexh r0, [ip] /* load old value (to be returned) */
eors r3, r0, r1 /* calculate new value */
strexh r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_xor_16)
ATOMIC_OP_ALIAS(atomic_xor_16,_atomic_xor_16)
ATOMIC_OP_ALIAS(atomic_xor_ushort,_atomic_xor_16)
STRONG_ALIAS(__sync_fetch_and_xor_2,_atomic_xor_16)
STRONG_ALIAS(_atomic_xor_ushort,_atomic_xor_16)
ENTRY_NP(_atomic_xor_16_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexh r0, [ip] /* load old value */
eors r0, r0, r1 /* calculate new value (return value) */
strexh r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_xor_16_nv)
ATOMIC_OP_ALIAS(atomic_xor_16_nv,_atomic_xor_16_nv)
ATOMIC_OP_ALIAS(atomic_xor_ushort_nv,_atomic_xor_16_nv)
STRONG_ALIAS(__sync_xor_and_fetch_2,_atomic_xor_16_nv)
STRONG_ALIAS(_atomic_xor_ushort_nv,_atomic_xor_16_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,79 @@
/* $NetBSD: atomic_xor_32.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_xor_32)
mov ip, r0
1: ldrex r0, [ip] /* load old value (to be returned) */
eors r3, r0, r1 /* calculate new value */
strex r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_xor_32)
ATOMIC_OP_ALIAS(atomic_xor_32,_atomic_xor_32)
ATOMIC_OP_ALIAS(atomic_xor_uint,_atomic_xor_32)
ATOMIC_OP_ALIAS(atomic_xor_ulong,_atomic_xor_32)
STRONG_ALIAS(__sync_fetch_and_xor_4,_atomic_xor_32)
STRONG_ALIAS(_atomic_xor_uint,_atomic_xor_32)
STRONG_ALIAS(_atomic_xor_ulong,_atomic_xor_32)
ENTRY_NP(_atomic_xor_32_nv)
mov ip, r0 /* need r0 for return value */
1: ldrex r0, [ip] /* load old value */
eors r0, r0, r1 /* calculate new value (return value) */
strex r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_xor_32_nv)
ATOMIC_OP_ALIAS(atomic_xor_32_nv,_atomic_xor_32_nv)
ATOMIC_OP_ALIAS(atomic_xor_uint_nv,_atomic_xor_32_nv)
ATOMIC_OP_ALIAS(atomic_xor_ulong_nv,_atomic_xor_32_nv)
STRONG_ALIAS(__sync_xor_and_fetch_4,_atomic_xor_32_nv)
STRONG_ALIAS(_atomic_xor_uint_nv,_atomic_xor_32_nv)
STRONG_ALIAS(_atomic_xor_ulong_nv,_atomic_xor_32_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,62 @@
/* $NetBSD: atomic_xor_64.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_xor_64_nv)
push {r3,r4} /* save temporary */
#ifndef __ARM_EABI__
mov r3, r2
mov r2, r1
#endif
mov ip, r0 /* need r0 for return value */
1: ldrexd r0, r1, [ip] /* load old value */
eors r0, r0, r2 /* calculate new value (return value) */
eors r1, r1, r3 /* calculate new value (return value) */
strexd r4, r0, r1, [ip] /* try to store */
cmp r4, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r4, c7, c10, 5 /* data memory barrier */
#endif
pop {r3,r4} /* restore temporary */
RET /* return new value */
END(_atomic_xor_64_nv)
STRONG_ALIAS(_atomic_xor_64,_atomic_xor_64_nv)
ATOMIC_OP_ALIAS(atomic_xor_64_nv,_atomic_xor_64_nv)
ATOMIC_OP_ALIAS(atomic_xor_64,_atomic_xor_64)
STRONG_ALIAS(__sync_xor_and_fetch_8,_atomic_xor_64)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,76 @@
/* $NetBSD: atomic_xor_8.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(_atomic_xor_8)
mov ip, r0
1: ldrexb r0, [ip] /* load old value (to be returned) */
eors r3, r0, r1 /* calculate new value */
strexb r2, r3, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return old value */
END(_atomic_xor_8)
ATOMIC_OP_ALIAS(atomic_xor_8,_atomic_xor_8)
ATOMIC_OP_ALIAS(atomic_xor_uchar,_atomic_xor_8)
STRONG_ALIAS(__sync_fetch_and_xor_1,_atomic_xor_8)
STRONG_ALIAS(_atomic_xor_uchar,_atomic_xor_8)
ENTRY_NP(_atomic_xor_8_nv)
mov ip, r0 /* need r0 for return value */
1: ldrexb r0, [ip] /* load old value */
eors r0, r0, r1 /* calculate new value (return value) */
strexb r2, r0, [ip] /* try to store */
cmp r2, #0 /* succeed? */
bne 1b /* no, try again? */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
RET /* return new value */
END(_atomic_xor_8_nv)
ATOMIC_OP_ALIAS(atomic_xor_8_nv,_atomic_xor_8_nv)
ATOMIC_OP_ALIAS(atomic_xor_uchar_nv,_atomic_xor_8_nv)
STRONG_ALIAS(__sync_xor_and_fetch_1,_atomic_xor_8_nv)
STRONG_ALIAS(_atomic_xor_uchar_nv,_atomic_xor_8_nv)
#endif /* _ARM_ARCH_6 */

View file

@ -1,4 +1,4 @@
/* $NetBSD: membar_ops.S,v 1.3 2012/08/16 16:49:10 matt Exp $ */ /* $NetBSD: membar_ops.S,v 1.4 2013/11/08 22:42:52 matt Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
@ -39,7 +39,7 @@ ENTRY_NP(_membar_producer)
mcr p15, 0, r0, c7, c10, 4 /* Data Synchronization Barrier */ mcr p15, 0, r0, c7, c10, 4 /* Data Synchronization Barrier */
#endif #endif
RET RET
END(_membar_producer) END(_membar_producer)
ATOMIC_OP_ALIAS(membar_producer,_membar_producer) ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
ATOMIC_OP_ALIAS(membar_write,_membar_producer) ATOMIC_OP_ALIAS(membar_write,_membar_producer)
STRONG_ALIAS(_membar_write,_membar_producer) STRONG_ALIAS(_membar_write,_membar_producer)
@ -51,12 +51,13 @@ ENTRY_NP(_membar_sync)
mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */ mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */
#endif #endif
RET RET
END(_membar_sync) END(_membar_sync)
ATOMIC_OP_ALIAS(membar_sync,_membar_sync) ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
ATOMIC_OP_ALIAS(membar_enter,_membar_sync) ATOMIC_OP_ALIAS(membar_enter,_membar_sync)
ATOMIC_OP_ALIAS(membar_exit,_membar_sync) ATOMIC_OP_ALIAS(membar_exit,_membar_sync)
ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) ATOMIC_OP_ALIAS(membar_consumer,_membar_sync)
ATOMIC_OP_ALIAS(membar_read,_membar_sync) ATOMIC_OP_ALIAS(membar_read,_membar_sync)
STRONG_ALIAS(__sync_synchronize,_membar_sync)
STRONG_ALIAS(_membar_enter,_membar_sync) STRONG_ALIAS(_membar_enter,_membar_sync)
STRONG_ALIAS(_membar_exit,_membar_sync) STRONG_ALIAS(_membar_exit,_membar_sync)
STRONG_ALIAS(_membar_consumer,_membar_sync) STRONG_ALIAS(_membar_consumer,_membar_sync)

View file

@ -0,0 +1,62 @@
/* $NetBSD: sync_bool_compare_and_swap_1.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#if defined(_ARM_ARCH_6)
/*
* ARMv6 has load-exclusive/store-exclusive which works for both user
* and kernel.
*/
ENTRY_NP(__sync_bool_compare_and_swap_1)
mov ip, r0 /* we need r0 for return value */
mov r0, #0 /* assume no match */
1:
ldrexb r3, [ip] /* load old value */
cmp r3, r1 /* compare? */
#ifdef __thumb__
bne 2f
#else
RETc(ne) /* return if different */
#endif
strexb r0, r2, [ip] /* store new value */
cmp r0, #0 /* succeed? */
bne 1b /* nope, try again. */
mov r0, #1 /* it was a success */
#ifdef _ARM_ARCH_7
dsb /* data synchronization barrier */
#else
mcr p15, 0, r3, c7, c10, 4 /* data synchronization barrier */
#endif
2: RET /* return. */
END(__sync_bool_compare_and_swap_1)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,61 @@
/* $NetBSD: sync_bool_compare_and_swap_2.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#if defined(_ARM_ARCH_6)
/*
* ARMv6 has load-exclusive/store-exclusive which works for both user
* and kernel.
*/
ENTRY_NP(__sync_bool_compare_and_swap_2)
mov ip, r0 /* we need r0 for return value */
movs r0, #0 /* assume failure */
1:
ldrexh r3, [ip] /* load old value */
cmp r3, r1 /* compare? */
#ifdef __thumb__
bne 2f
#else
RETc(ne) /* return if different */
#endif
strexh r0, r2, [ip] /* store new value */
cmp r0, #0 /* succeed? */
bne 1b /* nope, try again. */
movs r0, #1 /* indicate success */
#ifdef _ARM_ARCH_7
dsb /* data synchronization barrier */
#else
mcr p15, 0, r3, c7, c10, 4 /* data synchronization barrier */
#endif
2: RET /* return. */
END(__sync_bool_compare_and_swap_2)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,61 @@
/* $NetBSD: sync_bool_compare_and_swap_4.S,v 1.1 2013/11/08 22:42:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#if defined(_ARM_ARCH_6)
/*
* ARMv6 has load-exclusive/store-exclusive which works for both user
* and kernel.
*/
ENTRY_NP(__sync_bool_compare_and_swap_4)
mov ip, r0 /* we need r0 for return value */
movs r0, #0 /* assume failure */
1:
ldrex r3, [ip] /* load old value */
cmp r3, r1 /* compare? */
#ifdef __thumb__
bne 2f /* return if different */
#else
RETc(ne) /* return if different */
#endif
strex r0, r2, [ip] /* store new value */
cmp r0, #0 /* succeed? */
bne 1b /* nope, try again. */
movs r0, #1 /* indicate success */
#ifdef _ARM_ARCH_7
dsb
#else
mcr p15, 0, r3, c7, c10, 4 /* data synchronization barrier */
#endif
2: RET /* return. */
END(__sync_bool_compare_and_swap_4)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,73 @@
/* $NetBSD: sync_bool_compare_and_swap_8.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#if defined(_ARM_ARCH_6)
/*
* ARMv6 has load-exclusive/store-exclusive which works for both user
* and kernel.
*/
ENTRY_NP(__sync_bool_compare_and_swap_8)
push {r4-r7} /* save temporaries */
mov ip, r0 /* we need r0 for return value */
movs r0, #0 /* assume failure */
#ifdef __ARM_EABI__
ldrd r4, r5, [sp] /* fetch new value from stack */
#else
ldr r4, [sp, #0] /* fetch new value from stack */
ldr r5, [sp, #4] /* fetch new value from stack */
mov r3, r2 /* r2 will be overwritten by r1 which ... */
mov r2, r1 /* r1 will be overwritten by ldrexd */
#endif
1:
ldrexd r6, r7, [ip] /* load current value */
cmp r6, r2 /* compare to old? 1st half */
#ifdef __thumb__
bne 2f /* jump to return if different */
cmp r7, r3 /* compare to old? 2nd half */
#else
cmpeq r7, r3 /* compare to old? 2nd half */
#endif
bne 2f /* jump to return if different */
strexd r0, r4, r5, [ip] /* store new value */
cmp r0, #0 /* succeed? */
bne 1b /* nope, try again. */
movs r0, #1 /* indicate success */
#ifdef _ARM_ARCH_7
dsb
#else
mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
#endif
2: pop {r4-r7} /* restore temporaries */
RET /* return. */
END(__sync_bool_compare_and_swap_8)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,58 @@
/* $NetBSD: sync_fetch_and_add_8.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(__sync_fetch_and_add_8)
push {r4-r7}
mov ip, r0
#ifndef __ARM__EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, r1, [ip] /* load old value */
adds TLO, LO, NLO /* calculate new value */
adcs THI, HI, NHI /* calculate new value */
strexd r6, r4, r5, [ip] /* try to store */
cmp r6, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
pop {r4-r7}
RET /* return old value */
END(__sync_fetch_and_add_8)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,58 @@
/* $NetBSD: sync_fetch_and_and_8.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(__sync_fetch_and_and_8)
push {r4-r7}
mov ip, r0
#ifndef __ARM__EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, r1, [ip] /* load old value */
ands r4, r0, r2 /* calculate new value */
ands r5, r1, r3 /* calculate new value */
strexd r6, r4, r5, [ip] /* try to store */
cmp r6, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
pop {r4-r7}
RET /* return old value */
END(__sync_fetch_and_and_8)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,60 @@
/* $NetBSD: sync_fetch_and_nand_8.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(__sync_fetch_and_nand_8)
push {r4-r7}
mov ip, r0
#ifndef __ARM__EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, r1, [ip] /* load old value */
mvns r4, r0 /* complement old value */
mvns r5, r0 /* complement old value */
ands r4, r4, r2 /* calculate new value */
ands r5, r5, r3 /* calculate new value */
strexd r6, r4, r5, [ip] /* try to store */
cmp r6, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
pop {r4-r7}
RET /* return old value */
END(__sync_fetch_and_nand_8)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,58 @@
/* $NetBSD: sync_fetch_and_or_8.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(__sync_fetch_and_or_8)
push {r4-r7}
mov ip, r0
#ifndef __ARM__EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, r1, [ip] /* load old value */
orrs r4, r0, r2 /* calculate new value */
orrs r5, r1, r3 /* calculate new value */
strexd r6, r4, r5, [ip] /* try to store */
cmp r6, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
pop {r4-r7}
RET /* return old value */
END(__sync_fetch_and_or_8)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,58 @@
/* $NetBSD: sync_fetch_and_sub_8.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(__sync_fetch_and_sub_8)
push {r4-r7}
mov ip, r0
#ifndef __ARM__EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, r1, [ip] /* load old value */
subs TLO, LO, NLO /* calculate new value */
sbcs THI, HI, NHI /* calculate new value */
strexd r6, r4, r5, [ip] /* try to store */
cmp r6, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
pop {r4-r7}
RET /* return old value */
END(__sync_fetch_and_sub_8)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,58 @@
/* $NetBSD: sync_fetch_and_xor_8.S,v 1.2 2013/11/30 21:09:11 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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 "atomic_op_asm.h"
#ifdef _ARM_ARCH_6
ENTRY_NP(__sync_fetch_and_xor_8)
push {r4-r7}
mov ip, r0
#ifndef __ARM__EABI__
mov r3, r2
mov r2, r1
#endif
1: ldrexd r0, r1, [ip] /* load old value */
eors r4, r0, r2 /* calculate new value */
eors r5, r1, r3 /* calculate new value */
strexd r6, r4, r5, [ip] /* try to store */
cmp r6, #0 /* succeed? */
bne 1b /* no, try again */
#ifdef _ARM_ARCH_7
dmb
#else
mcr p15, 0, r2, c7, c10, 5 /* data memory barrier */
#endif
pop {r4-r7}
RET /* return old value */
END(__sync_fetch_and_xor_8)
#endif /* _ARM_ARCH_6 */

View file

@ -0,0 +1,64 @@
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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>
__RCSID("$NetBSD: __aeabi_idiv0.c,v 1.2 2013/05/08 05:13:56 matt Exp $");
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/siginfo.h>
#endif
#include <arm/aeabi.h>
int
__aeabi_idiv0(int result)
{
/* MINIX: LSC: Changed || to &&. */
#if !defined(_KERNEL) && !defined(_STANDALONE)
#if !defined(__minix) /* LSC: No sigqueueinfo on Minix. */
siginfo_t info;
memset(&info, 0, sizeof info);
info.si_signo = SIGFPE;
info.si_pid = getpid();
info.si_uid = geteuid();
info.si_code = FPE_INTDIV;
sigqueueinfo(getpid(), &info);
#else
/* LSC: So just trigger the signal. */
raise(SIGFPE);
#endif /* !defined(__minix) */
#endif
return result;
}

View file

@ -0,0 +1,63 @@
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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>
__RCSID("$NetBSD: __aeabi_ldiv0.c,v 1.2 2013/05/08 05:13:56 matt Exp $");
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/siginfo.h>
#endif
#include <arm/aeabi.h>
long long
__aeabi_ldiv0(long long result)
{
#if !defined(_KERNEL) && !defined(_STANDALONE)
#if !defined(__minix) /* LSC: No sigqueueinfo on Minix. */
siginfo_t info;
memset(&info, 0, sizeof info);
info.si_signo = SIGFPE;
info.si_pid = getpid();
info.si_uid = geteuid();
info.si_code = FPE_INTDIV;
sigqueueinfo(getpid(), &info);
#else
/* LSC: So just trigger the signal. */
raise(SIGFPE);
#endif /* !defined(__minix) */
#endif
return result;
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: byte_swap_2.S,v 1.4 2008/04/28 20:22:52 martin Exp $ */ /* $NetBSD: byte_swap_2.S,v 1.6 2013/08/19 03:44:18 matt Exp $ */
/*- /*-
* Copyright (c) 1999 The NetBSD Foundation, Inc. * Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -32,16 +32,30 @@
#include <machine/asm.h> #include <machine/asm.h>
#if defined(_KERNEL) || defined(_STANDALONE) #if defined(_KERNEL) || defined(_STANDALONE)
_ENTRY(_C_LABEL(bswap16)) #define FUNC _C_LABEL(bswap16)
#else #else
_ENTRY(_C_LABEL(__bswap16)) #define FUNC _C_LABEL(__bswap16)
#endif #endif
#if BYTE_ORDER == LITTLE_ENDIAN
_ENTRY(_C_LABEL(ntohs)) ENTRY(FUNC)
_ENTRY(_C_LABEL(htons)) #ifdef _ARM_ARCH_6
#endif rev16 r0, r0
_PROF_PROLOGUE #elif !defined(__thumb__)
and r1, r0, #0xff and r1, r0, #0xff
mov r0, r0, lsr #8 mov r0, r0, lsr #8
orr r0, r0, r1, lsl #8 orr r0, r0, r1, lsl #8
#else
movs r2, #0xff
movs r1, r0
ands r1, r1, r2
lsls r1, r1, #8
lsrs r0, r0, #8
ands r0, r0, r2
orrs r0, r0, r1
#endif
RET RET
END(FUNC)
#if BYTE_ORDER == LITTLE_ENDIAN
STRONG_ALIAS(_C_LABEL(ntohs), FUNC)
STRONG_ALIAS(_C_LABEL(htons), FUNC)
#endif

View file

@ -1,4 +1,4 @@
/* $NetBSD: byte_swap_4.S,v 1.4 2008/04/28 20:22:52 martin Exp $ */ /* $NetBSD: byte_swap_4.S,v 1.7 2013/08/19 03:44:47 matt Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -32,17 +32,34 @@
#include <machine/asm.h> #include <machine/asm.h>
#if defined(_KERNEL) || defined(_STANDALONE) #if defined(_KERNEL) || defined(_STANDALONE)
_ENTRY(_C_LABEL(bswap32)) #define FUNC _C_LABEL(bswap32)
#else #else
_ENTRY(_C_LABEL(__bswap32)) #define FUNC _C_LABEL(__bswap32)
#endif #endif
#if BYTE_ORDER == LITTLE_ENDIAN ENTRY(FUNC)
_ENTRY(_C_LABEL(ntohl)) #ifdef _ARM_ARCH_6
_ENTRY(_C_LABEL(htonl)) rev r0, r0
#elif !defined(__thumb__)
eor r1, r0, r0, ror #16 /* 4.3.2.1 -> 42.31.42.31 */
bic r1, r1, #0x00FF0000 /* 42.31.42.31 -> 42.0.42.31 */
mov r0, r0, ror #8 /* 4.3.2.1 -> 1.4.3.2 */
eor r0, r0, r1, lsr #8 /* 1.4.3.2 ^ 0.42.0.42 -> 1.2.3.4 */
#else
movs r3, #16
lsls r1, r0, #8 /* 4.3.2.1 -> 3.2.1.0 /*
lsrs r0, r0, #8 /* 4.3.2.1 -> 0.4.3.2 */
rors r1, r3 /* 3.2.1.0 -> 1.0.3.2 */
rors r0, r3 /* 0.4.3.2 -> 3.2.0.4 */
lsrs r1, r1, #8 /* 1.0.3.2 -> 0.1.0.3 */
lsls r1, r1, #8 /* 0.1.0.3 -> 1.0.3.0 */
lsls r0, r0, #8 /* 3.2.0.4 -> 2.0.4.0 */
lsrs r0, r0, #8 /* 2.0.4.0 -> 0.2.0.4 */
orrs r0, r0, r1 /* 1.0.3.0 | 0.2.0.4 -> 1.2.3.4 */
#endif #endif
_PROF_PROLOGUE
eor r1, r0, r0, ror #16
bic r1, r1, #0x00FF0000
mov r0, r0, ror #8
eor r0, r0, r1, lsr #8
RET RET
END(FUNC)
#if BYTE_ORDER == LITTLE_ENDIAN
STRONG_ALIAS(_C_LABEL(ntohl), FUNC)
STRONG_ALIAS(_C_LABEL(htonl), FUNC)
#endif

Some files were not shown because too many files have changed in this diff Show more