ladybird/Userland/Libraries/LibC/fd_set.h
Alex O'Brien ad1065e213 LibC: Remove semicolon in definition of FD_ZERO
This causes problems in code of the form

  if (/* condition */)
    FD_ZERO(&thing);
  else
    do_other_thing();

Wrapping the call to memset() in a do/while block fixes the issue.
2022-03-06 13:00:42 +01:00

22 lines
617 B
C

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#define FD_SETSIZE 1024
#define FD_ZERO(set) \
do { \
memset((set), 0, sizeof(fd_set)); \
} while (0)
#define FD_CLR(fd, set) ((set)->fds_bits[(fd / 8)] &= ~(1 << (fd) % 8))
#define FD_SET(fd, set) ((set)->fds_bits[(fd / 8)] |= (1 << (fd) % 8))
#define FD_ISSET(fd, set) ((set)->fds_bits[(fd / 8)] & (1 << (fd) % 8))
struct __fd_set {
unsigned char fds_bits[FD_SETSIZE / 8];
};
typedef struct __fd_set fd_set;