(root)/
strace-6.5/
tests-mx32/
pipe2.c
       1  /*
       2   * Check decoding of pipe2 syscall.
       3   *
       4   * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@strace.io>
       5   * Copyright (c) 2017-2021 The strace developers.
       6   * All rights reserved.
       7   *
       8   * SPDX-License-Identifier: GPL-2.0-or-later
       9   */
      10  
      11  #include "tests.h"
      12  #include "scno.h"
      13  
      14  #include <stdio.h>
      15  #include <unistd.h>
      16  #include "kernel_fcntl.h"
      17  
      18  int
      19  main(void)
      20  {
      21  	int *const fds = tail_alloc(sizeof(*fds) * 2);
      22  	int *const efault = fds + 1;
      23  	long rc;
      24  
      25  	rc = syscall(__NR_pipe2, fds, F8ILL_KULONG_MASK | O_NONBLOCK);
      26  	if (rc)
      27  		perror_msg_and_skip("pipe2");
      28  	printf("pipe2([%d, %d], O_NONBLOCK) = 0\n", fds[0], fds[1]);
      29  
      30  	rc = syscall(__NR_pipe2, efault, F8ILL_KULONG_MASK);
      31  	printf("pipe2(%p, 0) = %s\n", efault, sprintrc(rc));
      32  
      33  	if (F8ILL_KULONG_SUPPORTED) {
      34  		const kernel_ulong_t ill = f8ill_ptr_to_kulong(fds);
      35  		rc = syscall(__NR_pipe2, ill, 0);
      36  		printf("pipe2(%#llx, 0) = %s\n",
      37  		       (unsigned long long) ill, sprintrc(rc));
      38  	}
      39  
      40  	puts("+++ exited with 0 +++");
      41  	return 0;
      42  }