shithub: mc

Download patch

ref: 5f8ce4d91c5ae77dad2eb17b7a005723b2b8a90f
parent: 1c3ed5fc8e69003a0d91a9976afb40bdc6f525ba
author: Ori Bernstein <[email protected]>
date: Fri Oct 18 09:40:54 EDT 2013

Add symbolic constants for units.

--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -3,6 +3,7 @@
     alloc.myr \
     blat.myr \
     chartype.myr \
+    consts.myr \
     die.myr \
     env.myr \
     error.myr \
--- a/libstd/alloc.myr
+++ b/libstd/alloc.myr
@@ -1,3 +1,4 @@
+use "consts.use"
 use "die.use"
 use "extremum.use"
 use "sys.use"
@@ -47,9 +48,9 @@
 const Zslab	= 0 castto(slab#)
 const Zchunk	= 0 castto(chunk#)
 
-const Slabsz 	= 1048576	/* 1 meg slabs */
+const Slabsz 	= 1*MiB	/* 1 meg slabs */
 const Cachemax	= 16	/* maximum number of slabs in the cache */
-const Bktmax	= 32768	/* Slabsz / 8; a balance. */
+const Bktmax	= 32*KiB	/* Slabsz / 8; a balance. */
 const Align	= 16	/* minimum allocation alignment */
 
 var buckets	: bucket[32] /* excessive */
--- /dev/null
+++ b/libstd/consts.myr
@@ -1,0 +1,11 @@
+pkg std =
+	/* JEDEC 100B.1 memory sizes */
+	generic KiB	: @a::(tcint,tcnum,tctest)	= 1024 
+	generic MiB	: @a::(tcint,tcnum,tctest)	= KiB*1024
+	generic GiB	: @a::(tcint,tcnum,tctest)	= MiB*1024
+	generic TiB	: @a::(tcint,tcnum,tctest)	= GiB*1024
+	generic PiB	: @a::(tcint,tcnum,tctest)	= TiB*1024
+	generic EiB	: @a::(tcint,tcnum,tctest)	= PiB*1024
+	generic ZiB	: @a::(tcint,tcnum,tctest)	= EiB*1024
+	generic YiB	: @a::(tcint,tcnum,tctest)	= ZiB*1024
+;;