/*
- * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#include "tests.h"
-#include <errno.h>
#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
#include <sys/syscall.h>
+#if defined __NR_userfaultfd && defined O_CLOEXEC
+
+# include <assert.h>
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
int
main(void)
{
-#if defined __NR_userfaultfd && defined O_CLOEXEC
- if (syscall(__NR_userfaultfd, 1 | O_NONBLOCK | O_CLOEXEC) != -1)
- return 77;
- printf("userfaultfd(O_NONBLOCK|O_CLOEXEC|0x1) = -1 %s\n",
- errno == ENOSYS ?
- "ENOSYS (Function not implemented)" :
- "EINVAL (Invalid argument)");
+ assert(syscall(__NR_userfaultfd, 1 | O_NONBLOCK | O_CLOEXEC) == -1);
+ printf("userfaultfd(O_NONBLOCK|O_CLOEXEC|0x1) = -1 %s (%m)\n",
+ errno == ENOSYS ? "ENOSYS" : "EINVAL");
puts("+++ exited with 0 +++");
return 0;
+}
+
#else
- return 77;
+
+SKIP_MAIN_UNDEFINED("__NR_userfaultfd && O_CLOEXEC")
+
#endif
-}