summaryrefslogtreecommitdiff
path: root/libgcompat/gnulib.c
blob: efe1c317ab0eb1a2a9d477d868defd8bcdea9cb9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <sys/select.h>
#include "internal.h"
#include "alias.h"	/* alias */

#define REASON_FD_SET_OVERFLOW                                                 \
	"Fault: Overflow in fd_set detected.\n"                                \
	"Description: This is caused by a programmer naively attempting to\n"  \
	"  redefine FD_SETSIZE, which is not allowed on POSIX platforms.\n"    \
	"  The program must either be rebuilt with the correct FD_SETSIZE\n"   \
	"  definition, or else be rewritten to avoid use of select(2) in \n"   \
	"  general.  See also: poll(2).\n"                                     \
	"  libgcompat believes FD_SETSIZE to be %zu.\n"

unsigned long __fdelt_chk(unsigned long size)
{
	GCOMPAT__assert_with_reason(size < FD_SETSIZE, REASON_FD_SET_OVERFLOW,
	                            FD_SETSIZE);
	return size / (sizeof(unsigned long) << 3);
}
alias(__fdelt_chk, __fdelt_warn);