summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-09-27 18:20:14 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-09-27 18:20:14 +0000
commit44765bc62cb9ce9364fb2e7268c568775adf3852 (patch)
treea5d3922eaa81ead657e7e54fd78b45272c3cb756 /lib/libc
parentc4e0520e81b513d872bde4f70ff36805d66f64e9 (diff)
Add an implementation of IRIX-compatible cacheflush() routine to mips ports,
needed for gcc -ftrampoline operation as well as by some third-party software. Although the implementation uses the sysarch() sysctl, the wrapper is added to libc as it was a direct system call (which it is on IRIX).
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/arch/mips64/gen/Makefile.inc3
-rw-r--r--lib/libc/arch/mips64/gen/cacheflush.c37
2 files changed, 39 insertions, 1 deletions
diff --git a/lib/libc/arch/mips64/gen/Makefile.inc b/lib/libc/arch/mips64/gen/Makefile.inc
index 2e12b8d105f..d1e0a54c66d 100644
--- a/lib/libc/arch/mips64/gen/Makefile.inc
+++ b/lib/libc/arch/mips64/gen/Makefile.inc
@@ -1,9 +1,10 @@
-# $OpenBSD: Makefile.inc,v 1.7 2008/12/09 19:52:33 martynas Exp $
+# $OpenBSD: Makefile.inc,v 1.8 2009/09/27 18:20:13 miod Exp $
SRCS+= _setjmp.S fabs.S infinity.c ldexp.S modf.S nan.c
SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
fpsetround.c fpsetsticky.c
SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c isnormall.c signbitl.c
SRCS+= setjmp.S sigsetjmp.S
+SRCS+= cacheflush.c
SRCS+= alloca.c
diff --git a/lib/libc/arch/mips64/gen/cacheflush.c b/lib/libc/arch/mips64/gen/cacheflush.c
new file mode 100644
index 00000000000..17291fe8d73
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/cacheflush.c
@@ -0,0 +1,37 @@
+/* $OpenBSD: cacheflush.c,v 1.1 2009/09/27 18:20:13 miod Exp $ */
+
+/*
+ * Copyright (c) 2009 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * IRIX-compatible cacheflush() and _flush_cache() functions
+ */
+
+#include <sys/types.h>
+#include <machine/sysarch.h>
+
+int
+cacheflush(void *addr, int nbytes, int cache)
+{
+ struct mips64_cacheflush_args args;
+
+ args.va = (vaddr_t)addr;
+ args.sz = (size_t)nbytes;
+ args.which = cache;
+ return sysarch(MIPS64_CACHEFLUSH, (void *)&args);
+}
+
+__weak_alias(_flush_cache, cacheflush);