From 11eb3ca7f5d3f1be8b72c6755b5ec8256c9be655 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 12 Oct 2015 23:20:10 +0100 Subject: [PATCH] buffers: enum is evil, use a uint8_t instead and save a byte a buffer 520 is also a cheaper multiply on processors without mul instructions --- Kernel/include/kernel.h | 10 ++++++---- Kernel/kernel09.def | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Kernel/include/kernel.h b/Kernel/include/kernel.h index c437c92a..094a807a 100644 --- a/Kernel/include/kernel.h +++ b/Kernel/include/kernel.h @@ -99,7 +99,9 @@ typedef uint16_t blkno_t; /* Can have 65536 512-byte blocks in filesystem */ /* we need a busier-than-busy state for superblocks, so that if those blocks * are read by userspace through bread() they are not subsequently freed by * bfree() until the filesystem is unmounted */ -typedef enum { BF_FREE=0, BF_BUSY, BF_SUPERBLOCK } bf_busy_t; +#define BF_FREE 0 +#define BF_BUSY 1 +#define BF_SUPERBLOCK 2 /* FIXME: if we could split the data and the header we could keep blocks outside of our kernel data (as ELKS does) which would be a win, but need @@ -108,9 +110,9 @@ typedef struct blkbuf { uint8_t bf_data[BLKSIZE]; /* This MUST be first ! */ uint16_t bf_dev; blkno_t bf_blk; - bool bf_dirty; - bf_busy_t bf_busy; - uint16_t bf_time; /* LRU time stamp */ + uint8_t bf_dirty; /* bit 0 used */ + uint8_t bf_busy; /* bits 0-1 used */ + uint16_t bf_time; /* LRU time stamp */ } blkbuf, *bufptr; /* TODO: consider smaller inodes or clever caching. 2BSD uses small diff --git a/Kernel/kernel09.def b/Kernel/kernel09.def index d58fdbea..499ad2b7 100644 --- a/Kernel/kernel09.def +++ b/Kernel/kernel09.def @@ -34,4 +34,4 @@ EAGAIN equ 11 ; value from include/kernel.h ; Keep in sync with struct blkbuf -BUFSIZE equ 521 +BUFSIZE equ 520 -- 2.34.1