summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-01-09 12:11:05 -0200
committerRenato Botelho <renato@netgate.com>2017-01-09 12:11:05 -0200
commit681a482d8fc4bfc14a24f7a9d75cca6337f2a520 (patch)
tree08368e0c4dcea4baa16f4a34b2cc104c42e1ed27 /contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
parentcbeab2a9b6b7ac70992175202f35fcc05a5821d5 (diff)
parent91f6edbb8913d163d5c16fb615e84baf8a16d390 (diff)
downloadFreeBSD-src-681a482d8fc4bfc14a24f7a9d75cca6337f2a520.zip
FreeBSD-src-681a482d8fc4bfc14a24f7a9d75cca6337f2a520.tar.gz
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'contrib/netbsd-tests/lib/libpthread/t_swapcontext.c')
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_swapcontext.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c b/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
index c0c375f..a18ac2f 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
@@ -30,6 +30,8 @@ __RCSID("$NetBSD");
#ifdef __FreeBSD__
#include <sys/types.h>
+#include <errno.h>
+#include <string.h>
#endif
#include <pthread.h>
#include <ucontext.h>
@@ -80,7 +82,12 @@ threadfunc(void *arg)
oself = (void *)pthread_self();
printf("before swapcontext self = %p\n", oself);
+#ifdef __FreeBSD__
+ ATF_REQUIRE_MSG(swapcontext(&octx, &nctx) != -1, "swapcontext failed: %s",
+ strerror(errno));
+#else
PTHREAD_REQUIRE(swapcontext(&octx, &nctx));
+#endif
/* NOTREACHED */
return NULL;
@@ -102,7 +109,12 @@ ATF_TC_BODY(swapcontext1, tc)
printf("Testing if swapcontext() alters pthread_self()\n");
+#ifdef __FreeBSD__
+ ATF_REQUIRE_MSG(getcontext(&nctx) != -1, "getcontext failed: %s",
+ strerror(errno));
+#else
PTHREAD_REQUIRE(getcontext(&nctx));
+#endif
PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc, NULL));
PTHREAD_REQUIRE(pthread_join(thread, NULL));
}
OpenPOWER on IntegriCloud