#include <string.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
+
#ifndef O_NOATIME
# define O_NOATIME 0
#endif
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
close (fd);
struct stat64 st;
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
/* Before closing the file, try using this file descriptor to open
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
#include <support/test-driver.h>
#include <support/temp_file.h>
+#include <support/xunistd.h>
#ifndef struct_stat
# define struct_stat struct stat64
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct_stat st1;
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
#include <string.h>
#include <unistd.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
/* Before closing the file, try using this file descriptor to open
another file. This must fail. */
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
#include <unistd.h>
#include <sys/stat.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
puts ("file created");
struct stat64 st1;
#include <string.h>
#include <unistd.h>
+#include <support/xunistd.h>
static void prepare (void);
#define PREPARE(argc, argv) prepare ()
puts ("file creation failed");
return 1;
}
- write (fd, "hello", 5);
+ xwrite (fd, "hello", 5);
close (fd);
puts ("file created");
#include <stdio.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern));
+ xwrite (fd, pattern, sizeof (pattern));
close (fd);
}
#include <stdio.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern));
+ xwrite (fd, pattern, sizeof (pattern));
close (fd);
}
#include <stdio.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern) - 1);
+ xwrite (fd, pattern, sizeof (pattern) - 1);
close (fd);
}
#include <stdio.h>
#include <wchar.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, "1!", 2);
+ xwrite (fd, "1!", 2);
close (fd);
}
#include <stdio.h>
#include <wchar.h>
+#include <support/xunistd.h>
+
static void do_prepare (void);
#define PREPARE(argc, argv) do_prepare ()
static int do_test (void);
printf ("cannot create temporary file: %m\n");
exit (1);
}
- write (fd, pattern, sizeof (pattern));
+ xwrite (fd, pattern, sizeof (pattern));
close (fd);
}
#include <tls.h>
#include <unistd.h>
+#include <support/xunistd.h>
+
static const char *command;
static bool child;
static uintptr_t stack_chk_guard_copy;
else if (ret != NULL)
return 1;
- write (2, &stack_chk_guard_copy, sizeof (stack_chk_guard_copy));
+ xwrite (2, &stack_chk_guard_copy, sizeof (stack_chk_guard_copy));
return 0;
}
#include <unistd.h>
#include <pthreaddef.h>
+#include <support/xunistd.h>
+
#define THE_SIG SIGUSR1
/* The stack size can be overriden. With a sufficiently large stack
#include <pthreaddef.h>
#include <descr.h>
+#include <support/xunistd.h>
extern pthread_barrier_t b;
{
if (sig != THE_SIG)
{
- write (STDOUT_FILENO, "wrong signal\n", 13);
+ xwrite (STDOUT_FILENO, "wrong signal\n", 13);
_exit (1);
}
if (sem_post (&s) != 0)
{
- write (STDOUT_FILENO, "sem_post failed\n", 16);
+ xwrite (STDOUT_FILENO, "sem_post failed\n", 16);
_exit (1);
}
}
#include <errno.h>
#include <pthread.h>
+#include <support/xunistd.h>
+
static pthread_barrier_t barrier;
/* This function is intended to rack up both user and system time. */
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
}
#include <time.h>
#include <pthread.h>
+#include <support/xunistd.h>
+
#define TEST_CLOCK CLOCK_PROCESS_CPUTIME_ID
#define TEST_CLOCK_MISSING(clock) \
(setup_test () ? "process CPU clock timer support" : NULL)
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
}
#include <time.h>
#include <pthread.h>
+#include <support/xunistd.h>
+
static clockid_t worker_thread_clock;
#define TEST_CLOCK worker_thread_clock
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
}
#include <signal.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
+
static clockid_t child_clock;
#define TEST_CLOCK child_clock
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
if (getppid () == 1)
_exit (2);
int status;
/* Send the child's "outside" pid to it. */
- write (pipes[1], &child, sizeof(child));
+ xwrite (pipes[1], &child, sizeof(child));
close (pipes[0]);
close (pipes[1]);
sprintf (tmp, "%lld %lld 1\n",
(long long) (be_su ? 0 : original_uid), (long long) original_uid);
- write (UMAP, tmp, strlen (tmp));
+ xwrite (UMAP, tmp, strlen (tmp));
xclose (UMAP);
/* We must disable setgroups () before we can map our groups, else we
if (GMAP >= 0)
{
/* We support kernels old enough to not have this. */
- write (GMAP, "deny\n", 5);
+ xwrite (GMAP, "deny\n", 5);
xclose (GMAP);
}
sprintf (tmp, "%lld %lld 1\n",
(long long) (be_su ? 0 : original_gid), (long long) original_gid);
- write (GMAP, tmp, strlen (tmp));
+ xwrite (GMAP, tmp, strlen (tmp));
xclose (GMAP);
}
#include <stdio.h>
#include <unistd.h>
+#include <support/xunistd.h>
+
pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
bool exiting;
while (!exiting)
{
if ((spins++ % 1000) == 0)
- write (fd, ".", 1);
+ xwrite (fd, ".", 1);
pthread_mutex_unlock (&lock);
pthread_mutex_lock (&lock);
#include <unistd.h>
#include <sys/file.h>
+#include <support/xunistd.h>
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
unlink (tmp);
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
if (flock (fd, LOCK_EX | LOCK_NB) != 0)
{
#include <sys/mman.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
int i;
for (i = 0; i < 20; ++i)
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
pthread_barrier_t *b;
b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
#include <stdlib.h>
#include <unistd.h>
+#include <support/xunistd.h>
static int do_test (void);
if (pthread_setspecific (keys[i], (const void *) (i + 100l)) != 0)
{
- write (2, "setspecific failed\n", 19);
+ xwrite (2, "setspecific failed\n", 19);
_exit (1);
}
}
{
if (pthread_getspecific (keys[i]) != (void *) (i + 100l))
{
- write (2, "getspecific failed\n", 19);
+ xwrite (2, "getspecific failed\n", 19);
_exit (1);
}
if (pthread_key_delete (keys[i]) != 0)
{
- write (2, "key_delete failed\n", 18);
+ xwrite (2, "key_delete failed\n", 18);
_exit (1);
}
}
/* Now it must be once again possible to allocate keys. */
if (pthread_key_create (&keys[0], NULL) != 0)
{
- write (2, "2nd key_create failed\n", 22);
+ xwrite (2, "2nd key_create failed\n", 22);
_exit (1);
}
if (pthread_key_delete (keys[0]) != 0)
{
- write (2, "2nd key_delete failed\n", 22);
+ xwrite (2, "2nd key_delete failed\n", 22);
_exit (1);
}
#include <sys/mman.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
static sigset_t ss;
static pthread_barrier_t *b;
int i;
for (i = 0; i < 20; ++i)
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
#include <sys/wait.h>
#include <string.h>
+#include <support/xunistd.h>
static sigset_t ss;
static pthread_barrier_t *b;
int i;
for (i = 0; i < 20; ++i)
- write (fd, "foobar xyzzy", 12);
+ xwrite (fd, "foobar xyzzy", 12);
b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
#include <stdlib.h>
#include <stdint.h>
+#include <support/xunistd.h>
static void
notify_func1 (union sigval sigval)
{
static const char text[] = "signal_func\n";
signal (sig, signal_func);
- write (STDOUT_FILENO, text, sizeof text - 1);
+ xwrite (STDOUT_FILENO, text, sizeof text - 1);
}
static void
#include <stdint.h>
#include <sys/wait.h>
+#include <support/xunistd.h>
+
/* This function is intended to rack up both user and system time. */
static void
chew_cpu (void)
for (int i = 0; i < 100; ++i)
for (size_t j = 0; j < sizeof buf; ++j)
buf[j] = 0xbb;
- write (nullfd, (char *) buf, sizeof buf);
+ xwrite (nullfd, (char *) buf, sizeof buf);
close (nullfd);
if (getppid () == 1)
_exit (2);