diff options
author | April Chin <April.Chin@Sun.COM> | 2008-12-27 14:59:38 -0800 |
---|---|---|
committer | April Chin <April.Chin@Sun.COM> | 2008-12-27 14:59:38 -0800 |
commit | 7c2fbfb345896881c631598ee3852ce9ce33fb07 (patch) | |
tree | 4b173b5657508562dfc0aa05f7d056d1e9add505 /usr/src/lib/libsum/common/sum-ast4.c | |
parent | 6071ac1de68fed78e1e10052045bbb5f1732a263 (diff) | |
download | illumos-joyent-7c2fbfb345896881c631598ee3852ce9ce33fb07.tar.gz |
PSARC/2008/094 ksh93 Update 1
PSARC/2008/344 ksh93 Integration Update 1 Amendments 1
PSARC/2008/589 Remove /usr/bin/printf from PSARC case 2008 094
6619428 *ksh93* RFE: Update ksh93 in Solaris to ast-ksh.2008-11-04
6788659 RFE: Update libpp in Solaris to ast-open.2008-07-25
6561901 RFE: Add "shcomp" (shell script compiler) + kernel module to exec binary sh code
6599668 RFE: Move consumers of alias.sh over to ksh93
6595183 *ksh93* RFE: Update ksh93-integration demo code
6775901 *ksh93* no C message catalogs are generated for ksh93
6451262 *sleep* RFE: /usr/bin/sleep should support floating-point values
6687139 *ksh93* command substitution, exec, and stdout redirection cause allocation loop
6703761 *ksh93* crashes in script containing uncommon output redirections
6715496 *ksh93* SEGVs on array reinitialization
6713682 *ksh93* Creating a compound variable in a subshell "bleeds through" to the calling subshell
6672350 *ksh93* causes parent shell to die when child shell is suspended
6745015 *ksh93* VARIABLE=`command substitution` assignment is not reliable on OpenSolaris
6710205 *ksh93* problem with command substitution (within back quotes) containing \$'
6737600 *ksh93* exits debugger when user presses ctrl-c
6748645 *ksh93* fc -l -e - is mis-parsed, outputs wrong error message "-e - requires single argument"
6754020 *ksh93* does weird '[' expansion
6753538 *ksh93* umask modification leaks out of a ksh93 subshell
6766246 *ksh93* bug in pattern matching
6763594 *ksh93* executes command after "command" builtin twice on failure
6762665 *ksh93* Difficult-to-reproduce SIGSEGV in ksh93
Diffstat (limited to 'usr/src/lib/libsum/common/sum-ast4.c')
-rw-r--r-- | usr/src/lib/libsum/common/sum-ast4.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/usr/src/lib/libsum/common/sum-ast4.c b/usr/src/lib/libsum/common/sum-ast4.c new file mode 100644 index 0000000000..59697893f8 --- /dev/null +++ b/usr/src/lib/libsum/common/sum-ast4.c @@ -0,0 +1,120 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1996-2008 AT&T Intellectual Property * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.opensource.org/licenses/cpl1.0.txt * +* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler <gsf@research.att.com> * +* * +***********************************************************************/ +#pragma prototyped + +/* + * ast4 + */ + +#define ast4_description \ + "The \bast\b 128 bit PRNG hash generated by catenating 4 separate 32 \ + bit PNRG hashes. The block count is not printed." +#define ast4_options 0 +#define ast4_match "ast4|32x4|tw" +#define ast4_done long_done +#define ast4_scale 0 + +typedef struct Ast4_sum_s +{ + uint32_t sum0; + uint32_t sum1; + uint32_t sum2; + uint32_t sum3; +} Ast4_sum_t; + +typedef struct Ast4_s +{ + _SUM_PUBLIC_ + _SUM_PRIVATE_ + Ast4_sum_t cur; + Ast4_sum_t tot; + unsigned char buf[sizeof(Ast4_sum_t)]; +} Ast4_t; + +static int +ast4_init(Sum_t* p) +{ + register Ast4_t* a = (Ast4_t*)p; + + a->tot.sum0 ^= a->cur.sum0; + a->cur.sum0 = 0; + a->tot.sum1 ^= a->cur.sum1; + a->cur.sum1 = 0; + a->tot.sum2 ^= a->cur.sum2; + a->cur.sum2 = 0; + a->tot.sum3 ^= a->cur.sum3; + a->cur.sum3 = 0; + return 0; +} + +static Sum_t* +ast4_open(const Method_t* method, const char* name) +{ + Ast4_t* p; + + if (p = newof(0, Ast4_t, 1, 0)) + { + p->method = (Method_t*)method; + p->name = name; + } + return (Sum_t*)p; +} + +static int +ast4_block(Sum_t* p, const void* s, size_t n) +{ + register Ast4_sum_t* a = &((Ast4_t*)p)->cur; + register unsigned char* b = (unsigned char*)s; + register unsigned char* e = b + n; + register int c; + + while (b < e) + { + c = *b++; + a->sum0 = a->sum0 * 0x63c63cd9 + 0x9c39c33d + c; + a->sum1 = a->sum1 * 0x00000011 + 0x00017cfb + c; + a->sum2 = a->sum2 * 0x12345679 + 0x3ade68b1 + c; + a->sum3 = a->sum3 * 0xf1eac01d + 0xcafe10af + c; + } + return 0; +} + +static int +ast4_print(Sum_t* p, Sfio_t* sp, int flags, size_t scale) +{ + register Ast4_sum_t* a; + + a = (flags & SUM_TOTAL) ? &((Ast4_t*)p)->tot : &((Ast4_t*)p)->cur; + sfprintf(sp, "%06..64u%06..64u%06..64u%06..64u", a->sum0, a->sum1, a->sum2, a->sum3); + return 0; +} + +static int +ast4_data(Sum_t* p, Sumdata_t* data) +{ + data->size = sizeof(((Ast4_t*)p)->cur); + data->num = 0; +#if _ast_intswap + swapmem(_ast_intswap, data->buf = ((Ast4_t*)p)->buf, &((Ast4_t*)p)->cur, sizeof(((Ast4_t*)p)->cur)); +#else + data->buf = &((Ast4_t*)p)->cur; +#endif + return 0; +} |