# 2.11BSD#431 - /usr/src/new/jove/temp.h

##### Macros

    BNO_MASK          X
    BNO_SHIFT         X
    CH_BITS           X
    CH_PBLOCK         X
    CH_SIZE           X
    MAX_BLOCKS        X
    OFF_MASK          X
    RND_MASK          X
    blk_round         X
    da_to_bno         X
    da_to_off         X
    da_too_huge       X
    forward_block     X

       1: /***************************************************************************
       2:  * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
       3:  * is provided to you without charge, and with no warranty.  You may give  *
       4:  * away copies of JOVE, including sources, provided that this notice is    *
       5:  * included in all the files.                                              *
       6:  ***************************************************************************/
       7:
       8: /* The tmp file is indexed in chunks of CH_SIZE characters.  CH_SIZE is
       9:    (1 << CH_BITS).  New lines are added to the end of the tmp file.  The
      10:    file is not garbage collected because that would be too painful.  As a
      11:    result, commands like Yank and Kill are really easy; basically all we
      12:    do is make copies of the disk addresses of the lines (as opposed to
      13:    the contents).  So, putline(buf) writes BUF to the disk and returns a
      14:    new disk address.  Getline(addr, buf) is the opposite of putline().
      15:    f_getputl(line, fp) reads from open FP directly into the tmp file (into
      16:    the buffer cache (see below)) and stores the address in LINE.  This is
      17:    used during read_file to minimize compying.
      18:
      19:    Lines do NOT cross block bounderies in the tmp file so that accessing
      20:    the contents of lines can be much faster.  Pointers to offsets into
      21:    disk buffers are returned instead of copying the contents into local
      22:    arrays and then using them.  This cuts down on the amount of copying a
      23:    great deal, at the expense of less efficiency.  The lower bit of disk
      24:    addresses is used for marking lines as needing redisplay done.
      25:
      26:    There is a buffer cache of NBUF buffers (64 on !SMALL machines and the
      27:    3 on small ones).  The blocks are stored in LRU order and each block
      28:    is also stored in a hash table by block #.  When a block is requested
      29:    it can quickly be looked up in the hash table.  If it's not there the
      30:    LRU block is assigned the new block #.  If it finds that the LRU block
      31:    is dirty (i.e., has pending IO) it syncs the WHOLE tmp file, i.e.,
      32:    does all the pending writes.  This works much better on floppy disk
      33:    systems, like the IBM PC, if the blocks are sorted before sync'ing. */
      34:
      35: #ifdef SMALL
      36: #   define CH_BITS      4
      37: #   if BUFSIZ == 512
      38: #	define MAX_BLOCKS 1024
      39: #   else
      40: #	define MAX_BLOCKS 512
      41: #   endif
      42: #else
      43: #   define CH_BITS      0
      44: #   define MAX_BLOCKS       4096    /* basically unlimited */
      45: #endif /* SMALL */
      46:
      47: #if BUFSIZ == 512
      48: #   define BNO_SHIFT        (9 - CH_BITS)
      49: #else
      50: #   define BNO_SHIFT        (10 - CH_BITS)
      51: #endif
      52:
      53: /* CH_SIZE is how big each chunk is.  For each 1 the DFree pointer
      54:    is incremented we extend the tmp file by CH_SIZE characters.
      55:    CH_PBLOCK is the # of chunks per block.  RND_MASK is used to mask
      56:    off the lower order bits of the daddr to round down to the beginning
      57:    of a block.  OFF_MASK masks off the higher order bits so we can get
      58:    at the offset into the disk buffer.
      59:
      60:    NOTE:  It's pretty important that these numbers be multiples of
      61: 	  2.  Be careful if you change things. */
      62: #ifndef MAC
      63: #define CH_SIZE         (1 << CH_BITS)
      64: #define CH_PBLOCK       (BUFSIZ / CH_SIZE)
      65: #define RND_MASK        (CH_PBLOCK - 1)
      66: #define OFF_MASK        (BUFSIZ - 1)
      67: #define BNO_MASK        (MAX_BLOCKS - 1)
      68: #define blk_round(daddr)    (daddr & ~RND_MASK)
      69: #define forward_block(daddr)    (daddr + CH_PBLOCK)
      70: #define da_to_bno(daddr)    ((daddr >> BNO_SHIFT) & BNO_MASK)
      71: #define da_to_off(daddr)    ((daddr << CH_BITS) & OFF_MASK)
      72: #define da_too_huge(daddr)  ((daddr >> BNO_SHIFT) >= MAX_BLOCKS)
      73: #else
      74: #define CH_SIZE         ((disk_line)1 << CH_BITS)
      75: #define CH_PBLOCK       ((disk_line)BUFSIZ / CH_SIZE)
      76: #define RND_MASK        ((disk_line)CH_PBLOCK - 1)
      77: #define OFF_MASK        ((disk_line)BUFSIZ - 1)
      78: #define BNO_MASK        ((disk_line)MAX_BLOCKS - 1)
      79: #define blk_round(daddr)    ((disk_line)daddr & ~RND_MASK)
      80: #define forward_block(daddr)    ((disk_line)daddr + CH_PBLOCK)
      81: #define da_to_bno(daddr)    ((disk_line)(daddr >> BNO_SHIFT) & BNO_MASK)
      82: #define da_to_off(daddr)    ((disk_line)(daddr << CH_BITS) & OFF_MASK)
      83: #define da_too_huge(daddr)  ((disk_line)(daddr >> BNO_SHIFT) >= MAX_BLOCKS)
      84: #endif

#### Defined macros

BNO_MASK defined in line 78; used 2 times

- in line 70, 81

BNO_SHIFT defined in line 50; used 4 times

- in line 70-72(2), 81-83(2)

CH_BITS defined in line 43; used 6 times

- in line 48-50(2), 63, 71-74(2), 82

CH_PBLOCK defined in line 75; used 4 times

- in line 65-69(2), 76-80(2)

CH_SIZE defined in line 74; used 6 times

- in line 64, 75
- in /usr/src/new/jove/io.c line 1013(2), 1080(2)

MAX_BLOCKS defined in line 44; used 4 times

- in line 67-72(2), 78-83(2)

OFF_MASK defined in line 77; used 2 times

- in line 71, 82

RND_MASK defined in line 76; used 2 times

- in line 68, 79

blk_round defined in line 79; used 3 times

- in /usr/src/new/jove/io.c line 998, 1044
- in /usr/src/new/jove/recover.c line 128

da_to_bno defined in line 81; used 2 times

- in /usr/src/new/jove/io.c line 1287
- in /usr/src/new/jove/recover.c line 147

da_to_off defined in line 82; used 2 times

- in /usr/src/new/jove/io.c line 1288
- in /usr/src/new/jove/recover.c line 148

da_too_huge defined in line 83; used 1 times

- in /usr/src/new/jove/io.c line 1289

forward_block defined in line 80; used 3 times

- in /usr/src/new/jove/io.c line 1005, 1067
- in /usr/src/new/jove/recover.c line 132

#### Usage of this include

temp.h used 2 times

- in /usr/src/new/jove/io.c line 913
- in /usr/src/new/jove/recover.c line 28

Last modified: 1988-03-15 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 502 |