Message ID | 20250310182954.1396724-8-sandeen@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | fstests: enable sparse checking & fix fallout | expand |
On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote: > sparse points out that lots of things in random.c could be static, > and upon doing so we realize that nothing in this file is used. > Which is unsurprising since these are all part of the standard > C library ... so just remove the file. > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> > Reviewed-by: Christoph Hellwig <hch@lst.de> > --- Hi Eric, When I did the fstests regression test this weekend, I found a regression failure on generic/007 (diff output): --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400 +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400 @@ -14,9 +14,9 @@ ......................................................................... ......................................................................... .................................................... -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST) -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT) -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT) -total : 49411 OK, 50589 w/error (100000 total, 50% w/error) +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST) +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT) +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT) +total : 49480 OK, 50520 w/error (100000 total, 50% w/error) -cleanup: 61 removes +cleanup: 56 removes By bisecting, the first failed commit is this patch. After removing the fstests internal lib/random.c, the output of src/nametest.c is changed too, that breaks the g/007 (xfs/188 maybe too) test. It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs, cifs etc). I'll defer the release of this week (03.16), hope we can fix this regression next week :) Thanks, Zorro > lib/Makefile | 5 +- > lib/random.c | 224 --------------------------------------------------- > 2 files changed, 2 insertions(+), 227 deletions(-) > delete mode 100644 lib/random.c > > diff --git a/lib/Makefile b/lib/Makefile > index 53540ca7..ce4381a2 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -11,13 +11,12 @@ LT_REVISION = 0 > LT_AGE = 0 > > # > -# Everything (except for random.c) copied directly from LTP. > +# Everything copied directly from LTP. > # Refer to http://ltp.sourceforge.net/ for complete source. > # > CFILES = dataascii.c databin.c datapid.c file_lock.c forker.c \ > pattern.c open_flags.c random_range.c string_to_tokens.c \ > - str_to_bytes.c tlibio.c write_log.c \ > - random.c > + str_to_bytes.c tlibio.c write_log.c > > default: depend $(LTLIBRARY) > > diff --git a/lib/random.c b/lib/random.c > deleted file mode 100644 > index d5c81be8..00000000 > --- a/lib/random.c > +++ /dev/null > @@ -1,224 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0+ > -/* > - * random.c -- pseudo random number generator > - * Copyright (C) 1994 Chris Wallace (csw@bruce.cs.monash.edu.au) > - */ > - > -#include <sys/types.h> > - > -/* > - * modified by dxm@sgi.com so that this file acts as a drop in replacement > - * for srandom and random. > - */ > - > -/* > - * A random number generator called as a function by > - * random (iseed) or irandm (iseed) > - * The parameter should be a pointer to a 2-element int32_t vector. > - * The first function returns a double uniform in 0 .. 1. > - * The second returns a int32_t integer uniform in 0 .. 2**31-1 > - * Both update iseed[] in exactly the same way. > - * iseed[] must be a 2-element integer vector. > - * The initial value of the second element may be anything. > - * > - * The period of the random sequence is 2**32 * (2**32-1) > - * The table mt[0:127] is defined by mt[i] = 69069 ** (128-i) > - */ > - > -#define MASK ((int32_t) 593970775) > -/* or in hex, 23674657 */ > - > -#define SCALE ((double) 1.0 / (1024.0 * 1024.0 * 1024.0 * 2.0)) > -/* i.e. 2 to power -31 */ > - > -static int32_t mt [128] = { > - 902906369, > - 2030498053, > - -473499623, > - 1640834941, > - 723406961, > - 1993558325, > - -257162999, > - -1627724755, > - 913952737, > - 278845029, > - 1327502073, > - -1261253155, > - 981676113, > - -1785280363, > - 1700077033, > - 366908557, > - -1514479167, > - -682799163, > - 141955545, > - -830150595, > - 317871153, > - 1542036469, > - -946413879, > - -1950779155, > - 985397153, > - 626515237, > - 530871481, > - 783087261, > - -1512358895, > - 1031357269, > - -2007710807, > - -1652747955, > - -1867214463, > - 928251525, > - 1243003801, > - -2132510467, > - 1874683889, > - -717013323, > - 218254473, > - -1628774995, > - -2064896159, > - 69678053, > - 281568889, > - -2104168611, > - -165128239, > - 1536495125, > - -39650967, > - 546594317, > - -725987007, > - 1392966981, > - 1044706649, > - 687331773, > - -2051306575, > - 1544302965, > - -758494647, > - -1243934099, > - -75073759, > - 293132965, > - -1935153095, > - 118929437, > - 807830417, > - -1416222507, > - -1550074071, > - -84903219, > - 1355292929, > - -380482555, > - -1818444007, > - -204797315, > - 170442609, > - -1636797387, > - 868931593, > - -623503571, > - 1711722209, > - 381210981, > - -161547783, > - -272740131, > - -1450066095, > - 2116588437, > - 1100682473, > - 358442893, > - -1529216831, > - 2116152005, > - -776333095, > - 1265240893, > - -482278607, > - 1067190005, > - 333444553, > - 86502381, > - 753481377, > - 39000101, > - 1779014585, > - 219658653, > - -920253679, > - 2029538901, > - 1207761577, > - -1515772851, > - -236195711, > - 442620293, > - 423166617, > - -1763648515, > - -398436623, > - -1749358155, > - -538598519, > - -652439379, > - 430550625, > - -1481396507, > - 2093206905, > - -1934691747, > - -962631983, > - 1454463253, > - -1877118871, > - -291917555, > - -1711673279, > - 201201733, > - -474645415, > - -96764739, > - -1587365199, > - 1945705589, > - 1303896393, > - 1744831853, > - 381957665, > - 2135332261, > - -55996615, > - -1190135011, > - 1790562961, > - -1493191723, > - 475559465, > - 69069 > - }; > - > -double > -_random (int32_t is [2]) > -{ > - int32_t it, leh, nit; > - > - it = is [0]; > - leh = is [1]; > - if (it <= 0) > - it = (it + it) ^ MASK; > - else > - it = it + it; > - nit = it - 1; > -/* to ensure all-ones pattern omitted */ > - leh = leh * mt[nit & 127] + nit; > - is [0] = it; is [1] = leh; > - if (leh < 0) leh = ~leh; > - return (SCALE * ((int32_t) (leh | 1))); > -} > - > - > - > -int32_t > -_irandm (int32_t is [2]) > -{ > - int32_t it, leh, nit; > - > - it = is [0]; > - leh = is [1]; > - if (it <= 0) > - it = (it + it) ^ MASK; > - else > - it = it + it; > - nit = it - 1; > -/* to ensure all-ones pattern omitted */ > - leh = leh * mt[nit & 127] + nit; > - is [0] = it; is [1] = leh; > - if (leh < 0) leh = ~leh; > - return (leh); > -} > - > -/* > - * make this a drop in replacement for random and srandom > - * > - * XXX not thread safe I guess. > - */ > - > -static int32_t saved_seed[2]; > - > -long random(void) > -{ > - return _irandm(saved_seed); > -} > - > -void srandom(unsigned seed) > -{ > - saved_seed[0]=seed; > - saved_seed[1]=0; > - _irandm(saved_seed); > -} > - > -- > 2.48.0 > >
On 3/16/25 9:54 AM, Zorro Lang wrote: > On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote: >> sparse points out that lots of things in random.c could be static, >> and upon doing so we realize that nothing in this file is used. >> Which is unsurprising since these are all part of the standard >> C library ... so just remove the file. >> >> Signed-off-by: Eric Sandeen <sandeen@redhat.com> >> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> >> Reviewed-by: Christoph Hellwig <hch@lst.de> >> --- > > Hi Eric, > > When I did the fstests regression test this weekend, I found a regression > failure on generic/007 (diff output): > > --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400 > +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400 > @@ -14,9 +14,9 @@ > ......................................................................... > ......................................................................... > .................................................... > -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST) > -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT) > -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT) > -total : 49411 OK, 50589 w/error (100000 total, 50% w/error) > +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST) > +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT) > +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT) > +total : 49480 OK, 50520 w/error (100000 total, 50% w/error) > > -cleanup: 61 removes > +cleanup: 56 removes > > By bisecting, the first failed commit is this patch. After removing > the fstests internal lib/random.c, the output of src/nametest.c is > changed too, that breaks the g/007 (xfs/188 maybe too) test. > > It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs, > cifs etc). I'll defer the release of this week (03.16), hope we can > fix this regression next week :) Oh no, I'm sorry. I thought that if this stuff was never used it'd be safe to just yank, but I clearly must have missed something. It's probably best to just revert/remove this patch for now, so it doesn't delay any release. -Eric
On Sun, Mar 16, 2025 at 10:48:50AM -0500, Eric Sandeen wrote: > On 3/16/25 9:54 AM, Zorro Lang wrote: > > On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote: > >> sparse points out that lots of things in random.c could be static, > >> and upon doing so we realize that nothing in this file is used. > >> Which is unsurprising since these are all part of the standard > >> C library ... so just remove the file. > >> > >> Signed-off-by: Eric Sandeen <sandeen@redhat.com> > >> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> > >> Reviewed-by: Christoph Hellwig <hch@lst.de> > >> --- > > > > Hi Eric, > > > > When I did the fstests regression test this weekend, I found a regression > > failure on generic/007 (diff output): > > > > --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400 > > +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400 > > @@ -14,9 +14,9 @@ > > ......................................................................... > > ......................................................................... > > .................................................... > > -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST) > > -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT) > > -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT) > > -total : 49411 OK, 50589 w/error (100000 total, 50% w/error) > > +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST) > > +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT) > > +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT) > > +total : 49480 OK, 50520 w/error (100000 total, 50% w/error) > > > > -cleanup: 61 removes > > +cleanup: 56 removes > > > > By bisecting, the first failed commit is this patch. After removing > > the fstests internal lib/random.c, the output of src/nametest.c is > > changed too, that breaks the g/007 (xfs/188 maybe too) test. > > > > It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs, > > cifs etc). I'll defer the release of this week (03.16), hope we can > > fix this regression next week :) > > Oh no, I'm sorry. I thought that if this stuff was never used it'd > be safe to just yank, but I clearly must have missed something. Ahahaha, it's linked into libtest.a, which is then linked into every fstests binary. Therefore, any binary calling srandom and random get this bespoke version instead of the one in the C library. From the looks of it, the RNG code itself runs the same operations in the same order every time, which is why you can pass a seed to fsx/fsstress to get the exact same sequence of operations. Maybe lib/random.c should have its comment updated? Clearly two reviewers, myself, and the patch author missed this point: /* * modified by dxm@sgi.com so that this file acts as a drop in replacement * for srandom and random. */ Because that doesn't really explain /why/ the code is needed as a drop in replacement. How about: /* * modified by dxm@sgi.com so that this file acts as a drop in replacement * for srandom and random. fstests programs rely on the exact sequence * of integers generated by these functions for reproducibility and the * golden output, which is why we override the C library. */ --D > It's probably best to just revert/remove this patch for now, so it > doesn't delay any release. > > -Eric >
On Sun, Mar 16, 2025 at 10:48:50AM -0500, Eric Sandeen wrote: > On 3/16/25 9:54 AM, Zorro Lang wrote: > > On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote: > >> sparse points out that lots of things in random.c could be static, > >> and upon doing so we realize that nothing in this file is used. > >> Which is unsurprising since these are all part of the standard > >> C library ... so just remove the file. > >> > >> Signed-off-by: Eric Sandeen <sandeen@redhat.com> > >> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> > >> Reviewed-by: Christoph Hellwig <hch@lst.de> > >> --- > > > > Hi Eric, > > > > When I did the fstests regression test this weekend, I found a regression > > failure on generic/007 (diff output): > > > > --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400 > > +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400 > > @@ -14,9 +14,9 @@ > > ......................................................................... > > ......................................................................... > > .................................................... > > -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST) > > -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT) > > -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT) > > -total : 49411 OK, 50589 w/error (100000 total, 50% w/error) > > +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST) > > +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT) > > +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT) > > +total : 49480 OK, 50520 w/error (100000 total, 50% w/error) > > > > -cleanup: 61 removes > > +cleanup: 56 removes > > > > By bisecting, the first failed commit is this patch. After removing > > the fstests internal lib/random.c, the output of src/nametest.c is > > changed too, that breaks the g/007 (xfs/188 maybe too) test. > > > > It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs, > > cifs etc). I'll defer the release of this week (03.16), hope we can > > fix this regression next week :) > > Oh no, I'm sorry. I thought that if this stuff was never used it'd > be safe to just yank, but I clearly must have missed something. > > It's probably best to just revert/remove this patch for now, so it > doesn't delay any release. Sure, thanks Eric. Not only generic/007, generic/311 fails on this patch too. I'll revert this patch, then release fstests. > > -Eric >
On 3/16/25 11:40 AM, Darrick J. Wong wrote: > On Sun, Mar 16, 2025 at 10:48:50AM -0500, Eric Sandeen wrote: >> On 3/16/25 9:54 AM, Zorro Lang wrote: >>> On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote: >>>> sparse points out that lots of things in random.c could be static, >>>> and upon doing so we realize that nothing in this file is used. >>>> Which is unsurprising since these are all part of the standard >>>> C library ... so just remove the file. >>>> >>>> Signed-off-by: Eric Sandeen <sandeen@redhat.com> >>>> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> >>>> Reviewed-by: Christoph Hellwig <hch@lst.de> >>>> --- >>> >>> Hi Eric, >>> >>> When I did the fstests regression test this weekend, I found a regression >>> failure on generic/007 (diff output): >>> >>> --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400 >>> +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400 >>> @@ -14,9 +14,9 @@ >>> ......................................................................... >>> ......................................................................... >>> .................................................... >>> -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST) >>> -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT) >>> -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT) >>> -total : 49411 OK, 50589 w/error (100000 total, 50% w/error) >>> +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST) >>> +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT) >>> +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT) >>> +total : 49480 OK, 50520 w/error (100000 total, 50% w/error) >>> >>> -cleanup: 61 removes >>> +cleanup: 56 removes >>> >>> By bisecting, the first failed commit is this patch. After removing >>> the fstests internal lib/random.c, the output of src/nametest.c is >>> changed too, that breaks the g/007 (xfs/188 maybe too) test. >>> >>> It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs, >>> cifs etc). I'll defer the release of this week (03.16), hope we can >>> fix this regression next week :) >> >> Oh no, I'm sorry. I thought that if this stuff was never used it'd >> be safe to just yank, but I clearly must have missed something. > > Ahahaha, it's linked into libtest.a, which is then linked into every > fstests binary. Therefore, any binary calling srandom and random get > this bespoke version instead of the one in the C library. From the > looks of it, the RNG code itself runs the same operations in the same > order every time, which is why you can pass a seed to fsx/fsstress to > get the exact same sequence of operations. > > Maybe lib/random.c should have its comment updated? Clearly two > reviewers, myself, and the patch author missed this point: > > /* > * modified by dxm@sgi.com so that this file acts as a drop in replacement > * for srandom and random. > */ > > Because that doesn't really explain /why/ the code is needed as a drop > in replacement. How about: > > /* > * modified by dxm@sgi.com so that this file acts as a drop in replacement > * for srandom and random. fstests programs rely on the exact sequence > * of integers generated by these functions for reproducibility and the > * golden output, which is why we override the C library. > */ Yeah, I agree. We need a stable random.c copy for reproducibility on tests that expect it. :( Sorry about that, it's my near-constant reminder that even "trivial" changes need testing :( And I'll figure out how to make sparse happier about it. -Eric > --D > >> It's probably best to just revert/remove this patch for now, so it >> doesn't delay any release. >> >> -Eric >> >
diff --git a/lib/Makefile b/lib/Makefile index 53540ca7..ce4381a2 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -11,13 +11,12 @@ LT_REVISION = 0 LT_AGE = 0 # -# Everything (except for random.c) copied directly from LTP. +# Everything copied directly from LTP. # Refer to http://ltp.sourceforge.net/ for complete source. # CFILES = dataascii.c databin.c datapid.c file_lock.c forker.c \ pattern.c open_flags.c random_range.c string_to_tokens.c \ - str_to_bytes.c tlibio.c write_log.c \ - random.c + str_to_bytes.c tlibio.c write_log.c default: depend $(LTLIBRARY) diff --git a/lib/random.c b/lib/random.c deleted file mode 100644 index d5c81be8..00000000 --- a/lib/random.c +++ /dev/null @@ -1,224 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * random.c -- pseudo random number generator - * Copyright (C) 1994 Chris Wallace (csw@bruce.cs.monash.edu.au) - */ - -#include <sys/types.h> - -/* - * modified by dxm@sgi.com so that this file acts as a drop in replacement - * for srandom and random. - */ - -/* - * A random number generator called as a function by - * random (iseed) or irandm (iseed) - * The parameter should be a pointer to a 2-element int32_t vector. - * The first function returns a double uniform in 0 .. 1. - * The second returns a int32_t integer uniform in 0 .. 2**31-1 - * Both update iseed[] in exactly the same way. - * iseed[] must be a 2-element integer vector. - * The initial value of the second element may be anything. - * - * The period of the random sequence is 2**32 * (2**32-1) - * The table mt[0:127] is defined by mt[i] = 69069 ** (128-i) - */ - -#define MASK ((int32_t) 593970775) -/* or in hex, 23674657 */ - -#define SCALE ((double) 1.0 / (1024.0 * 1024.0 * 1024.0 * 2.0)) -/* i.e. 2 to power -31 */ - -static int32_t mt [128] = { - 902906369, - 2030498053, - -473499623, - 1640834941, - 723406961, - 1993558325, - -257162999, - -1627724755, - 913952737, - 278845029, - 1327502073, - -1261253155, - 981676113, - -1785280363, - 1700077033, - 366908557, - -1514479167, - -682799163, - 141955545, - -830150595, - 317871153, - 1542036469, - -946413879, - -1950779155, - 985397153, - 626515237, - 530871481, - 783087261, - -1512358895, - 1031357269, - -2007710807, - -1652747955, - -1867214463, - 928251525, - 1243003801, - -2132510467, - 1874683889, - -717013323, - 218254473, - -1628774995, - -2064896159, - 69678053, - 281568889, - -2104168611, - -165128239, - 1536495125, - -39650967, - 546594317, - -725987007, - 1392966981, - 1044706649, - 687331773, - -2051306575, - 1544302965, - -758494647, - -1243934099, - -75073759, - 293132965, - -1935153095, - 118929437, - 807830417, - -1416222507, - -1550074071, - -84903219, - 1355292929, - -380482555, - -1818444007, - -204797315, - 170442609, - -1636797387, - 868931593, - -623503571, - 1711722209, - 381210981, - -161547783, - -272740131, - -1450066095, - 2116588437, - 1100682473, - 358442893, - -1529216831, - 2116152005, - -776333095, - 1265240893, - -482278607, - 1067190005, - 333444553, - 86502381, - 753481377, - 39000101, - 1779014585, - 219658653, - -920253679, - 2029538901, - 1207761577, - -1515772851, - -236195711, - 442620293, - 423166617, - -1763648515, - -398436623, - -1749358155, - -538598519, - -652439379, - 430550625, - -1481396507, - 2093206905, - -1934691747, - -962631983, - 1454463253, - -1877118871, - -291917555, - -1711673279, - 201201733, - -474645415, - -96764739, - -1587365199, - 1945705589, - 1303896393, - 1744831853, - 381957665, - 2135332261, - -55996615, - -1190135011, - 1790562961, - -1493191723, - 475559465, - 69069 - }; - -double -_random (int32_t is [2]) -{ - int32_t it, leh, nit; - - it = is [0]; - leh = is [1]; - if (it <= 0) - it = (it + it) ^ MASK; - else - it = it + it; - nit = it - 1; -/* to ensure all-ones pattern omitted */ - leh = leh * mt[nit & 127] + nit; - is [0] = it; is [1] = leh; - if (leh < 0) leh = ~leh; - return (SCALE * ((int32_t) (leh | 1))); -} - - - -int32_t -_irandm (int32_t is [2]) -{ - int32_t it, leh, nit; - - it = is [0]; - leh = is [1]; - if (it <= 0) - it = (it + it) ^ MASK; - else - it = it + it; - nit = it - 1; -/* to ensure all-ones pattern omitted */ - leh = leh * mt[nit & 127] + nit; - is [0] = it; is [1] = leh; - if (leh < 0) leh = ~leh; - return (leh); -} - -/* - * make this a drop in replacement for random and srandom - * - * XXX not thread safe I guess. - */ - -static int32_t saved_seed[2]; - -long random(void) -{ - return _irandm(saved_seed); -} - -void srandom(unsigned seed) -{ - saved_seed[0]=seed; - saved_seed[1]=0; - _irandm(saved_seed); -} -