Blame gl/tests/test-sys_socket.c

Packit aea12f
/* Test of <sys/socket.h> substitute.
Packit aea12f
   Copyright (C) 2007, 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 of the License, or
Packit aea12f
   (at your option) 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
Packit aea12f
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit aea12f
Packit aea12f
/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
Packit aea12f
Packit aea12f
#include <config.h>
Packit aea12f
Packit aea12f
#include <sys/socket.h>
Packit aea12f
Packit aea12f
#include <errno.h>
Packit aea12f
Packit aea12f
#if HAVE_SHUTDOWN
Packit aea12f
/* Check some integer constant expressions.  */
Packit aea12f
int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Check that the 'socklen_t' type is defined.  */
Packit aea12f
socklen_t t1;
Packit aea12f
Packit aea12f
/* Check that the 'size_t' and 'ssize_t' types are defined.  */
Packit aea12f
size_t t2;
Packit aea12f
ssize_t t3;
Packit aea12f
Packit aea12f
/* Check that 'struct iovec' is defined.  */
Packit aea12f
struct iovec io;
Packit aea12f
Packit aea12f
/* Check that a minimal set of 'struct msghdr' is defined.  */
Packit aea12f
struct msghdr msg;
Packit aea12f
Packit aea12f
int
Packit aea12f
main (void)
Packit aea12f
{
Packit aea12f
  struct sockaddr_storage x;
Packit aea12f
  sa_family_t i;
Packit aea12f
Packit aea12f
  /* Check some errno values.  */
Packit aea12f
  switch (ENOTSOCK)
Packit aea12f
    {
Packit aea12f
    case ENOTSOCK:
Packit aea12f
    case EADDRINUSE:
Packit aea12f
    case ENETRESET:
Packit aea12f
    case ECONNABORTED:
Packit aea12f
    case ECONNRESET:
Packit aea12f
    case ENOTCONN:
Packit aea12f
    case ESHUTDOWN:
Packit aea12f
      break;
Packit aea12f
    }
Packit aea12f
Packit aea12f
  x.ss_family = 42;
Packit aea12f
  i = 42;
Packit aea12f
  msg.msg_iov = &io;
Packit aea12f
Packit aea12f
  return (x.ss_family - i + msg.msg_namelen + msg.msg_iov->iov_len
Packit aea12f
          + msg.msg_iovlen);
Packit aea12f
}