Blame gnulib-tests/pipe.c

Packit 709fb3
/* Create a pipe.
Packit 709fb3
   Copyright (C) 2009-2017 Free Software Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software; you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3, or (at your option)
Packit 709fb3
   any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License along
Packit 709fb3
   with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 709fb3
Packit 709fb3
#include <config.h>
Packit 709fb3
Packit 709fb3
/* Specification.  */
Packit 709fb3
#include <unistd.h>
Packit 709fb3
Packit 709fb3
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
Packit 709fb3
/* Native Windows API.  */
Packit 709fb3
Packit 709fb3
/* Get _pipe().  */
Packit 709fb3
# include <io.h>
Packit 709fb3
Packit 709fb3
/* Get _O_BINARY.  */
Packit 709fb3
# include <fcntl.h>
Packit 709fb3
Packit 709fb3
int
Packit 709fb3
pipe (int fd[2])
Packit 709fb3
{
Packit 709fb3
  /* Mingw changes fd to {-1,-1} on failure, but this violates
Packit 709fb3
     http://austingroupbugs.net/view.php?id=467 */
Packit 709fb3
  int tmp[2];
Packit 709fb3
  int result = _pipe (tmp, 4096, _O_BINARY);
Packit 709fb3
  if (!result)
Packit 709fb3
    {
Packit 709fb3
      fd[0] = tmp[0];
Packit 709fb3
      fd[1] = tmp[1];
Packit 709fb3
    }
Packit 709fb3
  return result;
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
#else
Packit 709fb3
Packit 709fb3
# error "This platform lacks a pipe function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib."
Packit 709fb3
Packit 709fb3
#endif