4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-24 07:57:22 +08:00
Ken Brown 5d4f405d3b Cygwin: redefine some macros for Linux compatibility
Define FD_SETSIZE (<sys/select.h>) to be 1024 by default, and define
NOFILE (<sys/param.h>) to be OPEN_MAX (== 3200) by default.

Remove the comment in <sys/select.h> that FD_SETSIZE should be >=
NOFILE.

Bump API minor.

Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251839.html
2022-07-07 08:22:40 -04:00

71 lines
2.2 KiB
C

/* sys/param.h
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _SYS_PARAM_H
#define _SYS_PARAM_H
#include <sys/types.h>
/* Linux includes limits.h, but this is not universally done. */
#include <limits.h>
#define __need_NULL
#include <stddef.h>
/* Max number of open files. The Posix version is OPEN_MAX. */
/* Number of fds is virtually unlimited in cygwin, but we must provide
some reasonable value for Posix conformance */
#if !defined NOFILE && defined OPEN_MAX
# define NOFILE OPEN_MAX
#endif
/* Max number of groups; must keep in sync with NGROUPS_MAX in limits.h */
#define NGROUPS NGROUPS_MAX
/* Ticks/second for system calls such as times() */
/* FIXME: is this the appropriate value? */
#define HZ 1000
/* Max hostname size that can be dealt with (== Win32 MAX_HOSTNAME_LEN) */
#define MAXHOSTNAMELEN 128
/* Maximum path length including trailing NUL; the Posix version is PATH_MAX.
MAXPATHLEN is the BSD variant. */
#define MAXPATHLEN PATH_MAX
/* Maximum number of nested symlinks; the Posix version is SYMLOOP_MAX.
MAXSYMLINKS is the BSD variant. */
#define MAXSYMLINKS SYMLOOP_MAX
/* This is the number of bytes per block given in the st_blocks stat member.
It should be in sync with S_BLKSIZE in sys/stat.h. S_BLKSIZE is the
BSD variant of this constant. */
#define DEV_BSIZE 1024
#ifndef NBBY
#define NBBY 8
#endif
/* Bit map related macros. */
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
/* Macros for counting and rounding. */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#define rounddown(x, y) (((x)/(y))*(y))
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
#define powerof2(x) ((((x)-1)&(x))==0)
/* Macros for min/max. */
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif