Blame gl/tests/pipe.c

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