after discussion with ciruZ, switch mksh from NZAT to NZAAT fully
to get rid of the bias introduced by making the hash never zero … he also pointed out a memory (heap) usage optimisation… which may impact code size a bit though as I’d need to pass an additional argument on hashtable function calls… or, forgo the benefit of not having to pointer-align the key in the structure, which can be as much as 3/7 octets per item, heap storage… OTOH the saved space is 4/8 octets per not-allocated item, possibly some code (use of an multiply-add opcode), but the function call overhead/cost would possibly be quite a bit… I guess I’ll have to measure…
This commit is contained in:
parent
48da83288d
commit
5204e7cc4f
6
check.t
6
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.532 2012/04/14 16:07:44 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.533 2012/04/22 21:50:29 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -29,7 +29,7 @@
|
|||||||
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R40 2012/04/14
|
@(#)MIRBSD KSH R40 2012/04/22
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -7089,7 +7089,7 @@ stdin:
|
|||||||
print ${foo@#123} ${bar@#456} ${baz@#789} .
|
print ${foo@#123} ${bar@#456} ${baz@#789} .
|
||||||
print ${foo@#bla} ${bar@#bar} ${baz@#OPTIND} .
|
print ${foo@#bla} ${bar@#bar} ${baz@#OPTIND} .
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
D50219A0 20E5DB5B 00000001 .
|
D50219A0 20E5DB5B 00000000 .
|
||||||
554A1C76 004A212E CB209562 .
|
554A1C76 004A212E CB209562 .
|
||||||
6B21CF91 20E5DB5B 124EA49D .
|
6B21CF91 20E5DB5B 124EA49D .
|
||||||
---
|
---
|
||||||
|
4
eval.c
4
eval.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.116 2012/04/06 14:07:52 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.117 2012/04/22 21:50:31 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* string expansion
|
* string expansion
|
||||||
@ -392,7 +392,7 @@ expand(const char *cp, /* input word */
|
|||||||
h = seed;
|
h = seed;
|
||||||
NZATUpdateString(h,
|
NZATUpdateString(h,
|
||||||
str_val(st->var));
|
str_val(st->var));
|
||||||
NZATFinish(h);
|
NZAATFinish(h);
|
||||||
x.str = shf_smprintf("%08X",
|
x.str = shf_smprintf("%08X",
|
||||||
(unsigned int)h);
|
(unsigned int)h);
|
||||||
break;
|
break;
|
||||||
|
6
mksh.1
6
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.284 2012/04/14 12:51:34 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.285 2012/04/22 21:50:32 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.141 2011/09/03 22:59:08 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.141 2011/09/03 22:59:08 jmc Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
@ -74,7 +74,7 @@
|
|||||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||||
.\" use our own definition. And .Dd must come *first*, always.
|
.\" use our own definition. And .Dd must come *first*, always.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: April 14 2012 $
|
.Dd $Mdocdate: April 22 2012 $
|
||||||
.\"
|
.\"
|
||||||
.\" Check which macro package we use, and do other -mdoc setup.
|
.\" Check which macro package we use, and do other -mdoc setup.
|
||||||
.\"
|
.\"
|
||||||
@ -1626,7 +1626,7 @@ The internal hash of the expansion of
|
|||||||
.Ar name ,
|
.Ar name ,
|
||||||
with an optional (defaulting to zero)
|
with an optional (defaulting to zero)
|
||||||
.Ar seed .
|
.Ar seed .
|
||||||
At the moment, this is NZAT (a never-zero 32-bit hash based on
|
At the moment, this is NZAAT (a 32-bit hash based on
|
||||||
Bob Jenkins' one-at-a-time hash), but this is not set.
|
Bob Jenkins' one-at-a-time hash), but this is not set.
|
||||||
This is the hash the shell uses internally for its associative arrays.
|
This is the hash the shell uses internally for its associative arrays.
|
||||||
.El
|
.El
|
||||||
|
15
sh.h
15
sh.h
@ -152,9 +152,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.549 2012/04/14 16:07:48 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.550 2012/04/22 21:50:33 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R40 2012/04/14"
|
#define MKSH_VERSION "R40 2012/04/22"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -1491,7 +1491,7 @@ EXTERN struct timeval j_usrtime, j_systime;
|
|||||||
} while (/* CONSTCOND */ 0)
|
} while (/* CONSTCOND */ 0)
|
||||||
|
|
||||||
|
|
||||||
/* NZAT/NZAAT hashes based on Bob Jenkins' one-at-a-time hash */
|
/* NZAAT hash based on Bob Jenkins' one-at-a-time hash */
|
||||||
|
|
||||||
/* From: src/kern/include/nzat.h,v 1.2 2011/07/18 00:35:40 tg Exp $ */
|
/* From: src/kern/include/nzat.h,v 1.2 2011/07/18 00:35:40 tg Exp $ */
|
||||||
|
|
||||||
@ -1524,15 +1524,6 @@ EXTERN struct timeval j_usrtime, j_systime;
|
|||||||
NZATUpdateByte((h), NZATUpdateString_c); \
|
NZATUpdateByte((h), NZATUpdateString_c); \
|
||||||
} while (/* CONSTCOND */ 0)
|
} while (/* CONSTCOND */ 0)
|
||||||
|
|
||||||
/* not zero after termination */
|
|
||||||
#define NZATFinish(h) do { \
|
|
||||||
if ((h) == 0) \
|
|
||||||
++(h); \
|
|
||||||
else \
|
|
||||||
NZAATFinish(h); \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
|
|
||||||
/* NULs zählen an allen Teilen */
|
|
||||||
#define NZAATFinish(h) do { \
|
#define NZAATFinish(h) do { \
|
||||||
(h) += (h) << 10; \
|
(h) += (h) << 10; \
|
||||||
(h) ^= (h) >> 6; \
|
(h) ^= (h) >> 6; \
|
||||||
|
4
var.c
4
var.c
@ -27,7 +27,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.146 2012/04/14 14:35:13 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.147 2012/04/22 21:50:35 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
@ -1471,7 +1471,7 @@ hash(const void *s)
|
|||||||
|
|
||||||
NZATInit(h);
|
NZATInit(h);
|
||||||
NZATUpdateString(h, s);
|
NZATUpdateString(h, s);
|
||||||
NZATFinish(h);
|
NZAATFinish(h);
|
||||||
return (h);
|
return (h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user