#include <sys/param.h>

sys/param.h

62 macros

macroBSD

#define BSD 199506
System version (year & month).

macroBSD4_3

#define BSD4_3 1

macroBSD4_4

#define BSD4_4 1

macroNeXTBSD

#define NeXTBSD 1995064
NeXTBSD version (year, month, release)

macroNeXTBSD4_0

#define NeXTBSD4_0 0
NeXTBSD 4.0

macroMAXCOMLEN

#define MAXCOMLEN 16
max command name remembered

macroMAXINTERP

#define MAXINTERP 64
max interpreter file name length

macroMAXLOGNAME

#define MAXLOGNAME 255
max login name length

macroMAXUPRC

#define MAXUPRC CHILD_MAX
max simultaneous processes

macroNCARGS

#define NCARGS ARG_MAX
max bytes for an exec function

macroNGROUPS

#define NGROUPS NGROUPS_MAX
max number groups

macroNOFILE

#define NOFILE 256
default max open files per process

macroNOGROUP

#define NOGROUP 65535
marker for empty group set member

macroMAXHOSTNAMELEN

#define MAXHOSTNAMELEN 256
max hostname size

macroMAXDOMNAMELEN

#define MAXDOMNAMELEN 256
maximum domain name length

macroPSWP

Priorities. Note that with 32 run queues, differences less than 4 are insignificant.
#define PSWP 0

macroPVM

#define PVM 4

macroPINOD

#define PINOD 8

macroPRIBIO

#define PRIBIO 16

macroPVFS

#define PVFS 20

macroPZERO

#define PZERO 22
No longer magic, shouldn't be here. XXX

macroPSOCK

#define PSOCK 24

macroPWAIT

#define PWAIT 32

macroPLOCK

#define PLOCK 36

macroPPAUSE

#define PPAUSE 40

macroPUSER

#define PUSER 50

macroMAXPRI

#define MAXPRI 127
Priorities range from 0 through MAXPRI.

macroPRIMASK

#define PRIMASK 0x0ff

macroPCATCH

#define PCATCH 0x100
OR'd with pri for tsleep to check signals

macroPTTYBLOCK

#define PTTYBLOCK 0x200
for tty SIGTTOU and SIGTTIN blocking

macroPDROP

#define PDROP 0x400
OR'd with pri to stop re-aquistion of mutex upon wakeup

macroPSPIN

#define PSPIN 0x800
OR'd with pri to require mutex in spin mode upon wakeup

macroNBPW

#define NBPW sizeof(int)
number of bytes per word (integer)

macroCMASK

#define CMASK 022
default file mask: S_IWGRP|S_IWOTH

macroNODEV

#define NODEV (dev_t)(-1)
non-existent device

macroCLBYTES

Clustering of hardware pages on machines with ridiculously small page sizes is done here. The paging subsystem deals with units of CLSIZE pte's describing NBPG (from machine/param.h) pages each.
#define CLBYTES (CLSIZE*NBPG)

macroCLOFSET

#define CLOFSET (CLSIZE*NBPG-1)
for clusters, like PGOFSET

macroclaligned

#define claligned(x) ((((int)(x))&CLOFSET)==0)

macroCLOFF

#define CLOFF CLOFSET

macroCLSHIFT

#define CLSHIFT (PGSHIFT+CLSIZELOG2)

macroclbase

#define clbase(i) (i)

macroclrnd

#define clrnd(i) (i)

macroCBLOCK

#define CBLOCK 64
Clist block size, must be a power of 2.

macroCBQSIZE

#define CBQSIZE (CBLOCK/NBBY)
Quote bytes/cblock - can do better.

macroCBSIZE

Data chars/clist.
#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)

macroCROUND

#define CROUND (CBLOCK - 1)
Clist rounding.

macroMAXBSIZE

File system parameters and macros. The file system is made out of blocks of at most MAXPHYS units, with smaller units (fragments) only in the last direct block. MAXBSIZE primarily determines the size of buffers in the buffer pool. It may be made larger than MAXPHYS without any effect on existing file systems; however making it smaller may make some file systems unmountable. We set this to track the value of MAX_UPL_TRANSFER_BYTES from osfmk/mach/memory_object_types.h to bound it at the maximum UPL size.
#define MAXBSIZE (256 * 4096)

macroMAXPHYSIO

#define MAXPHYSIO MAXPHYS

macroMAXFRAG

#define MAXFRAG 8

macroMAXPHYSIO_WIRED

#define MAXPHYSIO_WIRED (16 * 1024 * 1024)

macroMAXPATHLEN

MAXPATHLEN defines the longest permissable path length after expanding symbolic links. It is used to allocate a temporary buffer from the buffer pool in which to do the name expansion, hence should be a power of two, and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the maximum number of symbolic links that may be expanded in a path name. It should be set high enough to allow all legitimate uses, but halt infinite loops reasonably quickly.
#define MAXPATHLEN PATH_MAX

macrosetbit

Bit map related macros.
#define setbit(a, i) (((unsigned char *)(a))[(i)/NBBY] |= 1u<<((i)%NBBY))

macroclrbit

#define clrbit(a, i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1u<<((i)%NBBY)))

macroisset

#define isset(a, i) (((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY)))

macroisclr

#define isclr(a, i) ((((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY))) == 0)

macroroundup

Macros for counting, rounding.
#define roundup(x, y) ((((x) % (y)) == 0) ?
	                (x) : ((x) + ((y) - ((x) % (y)))))

macropowerof2

#define powerof2(x) ((((x)-1)&(x))==0)

macroMIN

Macros for min/max.
#define MIN(a, b) (((a)<(b))?(a):(b))

macroMAX

#define MAX(a, b) (((a)>(b))?(a):(b))

macroFSHIFT

Scale factor for scaled integers used to count %cpu time and load avgs. The number of CPU `tick's that map to a unique `%age' can be expressed by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that can be calculated (assuming 32 bits) can be closely approximated using the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
#define FSHIFT 11
bits to right of fixed binary point

macroFSCALE

#define FSCALE (1<<FSHIFT)