home *** CD-ROM | disk | FTP | other *** search
- /*
- * @(#) sysmacros.h 2.2 88/05/18
- *
- * Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987, 1988.
- * Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987, 1988.
- * This Module contains Proprietary Information of
- * The Santa Cruz Operation, Microsoft Corporation
- * and AT&T, and should be treated as Confidential.
- */
-
- /*
- * Some macros for units conversion
- */
- /* Core clicks to segments and vice versa */
- #define ctos(x) ((x+(NCPS-1))/NCPS)
- #define stoc(x) ((x)*NCPS)
-
- /* Core clicks to disk blocks */
- #ifdef NCPD
- #define ctod(x) ((x+(NCPD-1))/NCPD)
- #else
- #define ctod(x) ((x) * NDPC)
- #endif
-
- /* inumber to disk address */
- #ifdef INOSHIFT
- #define itod(x) (daddr_t)(((unsigned)x+(2*INOPB-1))>>INOSHIFT)
- #else
- #define itod(x) (daddr_t)(((unsigned)x+(2*INOPB-1))/INOPB)
- #endif
-
- /* inumber to disk offset */
- #ifdef INOSHIFT
- #define itoo(x) (int)(((unsigned)x+(2*INOPB-1))&(INOPB-1))
- #else
- #define itoo(x) (int)(((unsigned)x+(2*INOPB-1))%INOPB)
- #endif
-
- /* clicks to bytes */
- #ifdef BPCSHIFT
- #define ctob(x) (((long) x) << BPCSHIFT)
- #else
- #define ctob(x) (((long) x) * NBPC)
- #endif
-
- /* bytes to clicks */
- #ifdef BPCSHIFT
- #define btoc(x) (((unsigned)(x)+(NBPC-1))>>BPCSHIFT)
- #define btoct(x) ((unsigned)(x)>>BPCSHIFT)
- #else
- #define btoc(x) (((unsigned)(x)+(NBPC-1))/NBPC)
- #define btoct(x) ((unsigned)(x)/NBPC)
- #endif
-
- /* major part of a device */
- #define major(x) (int)((unsigned)x>>8)
- #define bmajor(x) (int)(((unsigned)x>>8)&037)
- #define brdev(x) (x&0x1fff)
-
- /* minor part of a device */
- #define minor(x) (int)(x&0377)
-
- /* make a device number */
- #define makedev(x,y) (dev_t)(((x)<<8) | (y))
-
-
-
- #ifndef M_I386
- /* far pointer (faddr_t) to segment (int) (get high 16 bits of faddr_t) */
- #define ftoseg(x) ((unsigned)((long)(x) >> 16))
-
- /* far pointer (faddr_t) to offset (int) */
- #define ftooff(x) ((unsigned)((long)(x)))
-
- /* real mode far pointer to physical address */
- #define ftop(x) \
- ((paddr_t)((((long)(x) >> 12) & 0x000ffff0L) + (ushort)(x)))
-
- /* seg off to far pointer (faddr_t) */
- #define sotofar(seg, off) \
- (((char far *) (((long)(unsigned) (seg)) << 16)) + (unsigned) (off))
-
- /* real mode seg, off to physical address */
- #define sotop(seg, off) \
- ((((paddr_t) (ushort) (seg)) << 4) + (ushort) (off))
-
- /* physical address to real mode far pointer */
- #define ptofar(p) \
- ((char far *) ((((p) << 12) & 0xffff0000) + ((p) & 0x0000000f)))
-
- /* physical address to real mode seg, off */
- #define ptoseg(p) ((ushort) ((p) >> 4))
- #define ptooff(p) ((ushort) (p) & 0x000f)
-
- #define FADDR(seg, off) off, seg
-
- /* Memory location to real mode far pointer */
- #define mltofar(x) ((char far *) ((long)(x) << 16 ))
-
- /* Memory location to logical address */
- #define mltoa(x) ((paddr_t) (x) << LMMPGSZ)
-
- /* address (long (32 bit)) to page count (int)*/
- #define atoml(x) ((int)(((paddr_t)(x)+(MMPGSZ-1))>>LMMPGSZ))
-
- /* address (long (32 bit)) to page number (int)*/
- #define atomlt(x) ((int)(((paddr_t)(x))>>LMMPGSZ))
-
- #define DSHFT (BSHIFT-LMMPGSZ)
-
- #define mstod(x) ((unsigned)((x) + BSIZE/MMPGSZ - 1) >> DSHFT)
- #define dtoms(x) ((x) << DSHFT)
-
- #define mstob(x) ((x)<<LMMPGSZ)
-
-
-
- #ifdef M_I8086
- /* bytes to mem size - this macro rounds up to a disk block boundary */
- /* process memory is allocated only in BSIZE chunks */
- #define btoms(x) (msize_t)((x) ? (((((x)-1) | BMASK) >> LMMPGSZ) + 1) : 0)
-
- /* bytes to pages */
- #define btop(x) (((((unsigned)(x) - 1) | MMPGMASK) + 1) >> LMMPGSZ)
-
- /* pages to bytes */
- #define ptob(x) ((x) << LMMPGSZ)
- #endif
-
- #ifdef M_I286
- /* bytes to mem size */
- #define btoms(x) ((unsigned) (((long)(x) + (MMPGSZ-1)) >> LMMPGSZ))
-
- /* selector number to table index */
- #define stoi(sel) ((sel)/SELSZ)
- #endif
-
- #endif
-
- /* Calculate user process priority. */
-
- #ifdef VPIX
- #define calcppri(p) ((p->p_cpu) >> 1) + p->p_nice + (PUSER - NZERO)
- #endif
-