RandomRDRand.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Jun 2019 14:28:51 +0200
changeset 5050 44fa8672d102
parent 4927 8e944da8fc20
child 5067 2fbc7ccd7e68
permissions -rw-r--r--
#DOCUMENTATION by cg class: SharedQueue comment/format in: #next #nextWithTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
     1
"{ Encoding: utf8 }"
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
     2
4322
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
     3
"
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
     4
 COPYRIGHT (c) 2014 Claus Gittinger
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
     5
	      All Rights Reserved
4322
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
     6
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
     7
 This software is furnished under a license and may be used
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
     8
 only in accordance with the terms of that license and with the
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    10
 be provided or otherwise made available to, or used by, any
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    11
 other person.  No title to or ownership of the software is
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    12
 hereby transferred.
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    13
"
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libbasic2' }"
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
4322
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    16
"{ NameSpace: Smalltalk }"
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    17
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
Object subclass:#RandomRDRand
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
    19
	instanceVariableNames:''
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
4595
39b2f30679c0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
    22
	category:'Magnitude-Numbers-Random'
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!RandomRDRand class methodsFor:'documentation'!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
4322
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    27
copyright
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    28
"
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    29
 COPYRIGHT (c) 2014 Claus Gittinger
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    30
	      All Rights Reserved
4322
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    31
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    32
 This software is furnished under a license and may be used
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    33
 only in accordance with the terms of that license and with the
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    35
 be provided or otherwise made available to, or used by, any
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    36
 other person.  No title to or ownership of the software is
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    37
 hereby transferred.
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    38
"
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    39
!
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
    40
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    43
    This generator uses the rdgen random generator which is built into modern intel chips.
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    44
    Before using, you should check via the isSupported query.
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    45
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    46
    Warning:
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    47
	there have been discussions about the security of the intel rdgen instruction
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    48
	and whether there are NSA backdoors built into it.
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    49
	Linus Torwalds refuses to use it for /dev/urandom in the linux kernel, for that very reason.
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    50
	Be sure you know what you are doing, if you use this generator for sensitive cryptographic stuff.
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    51
	We recommend using one of the libcrypt-based generators and use this only to get additional
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    52
	entropy for the seed.
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    NO WARRANTY
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    RandomRDGen new nextInteger
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    [see also:]
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    59
	RandomGenerator - the default; uses the machine's /dev/random if available
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    60
	Random  - fast, but generates less quality random numbers
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    61
	RandomTT800 - another random generator
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    62
	RandomParkMiller - another random generator
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    63
	RandomMT19937 - another random generator
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    64
	RandomKISS - another random generator
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    65
	exept:libcrypt - a library containing more stuff based on hashes and cyphers
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    [author:]
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
    68
	Claus Gittinger.
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
"
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
! !
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
!RandomRDRand class methodsFor:'instance creation'!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
new
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    self isSupported ifFalse:[ self error:'this generator needs a cpu with rdgen instruction' ].
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    76
    ^ self basicNew initialize
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    77
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    78
    "
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    79
     self new nextInteger
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    80
    "
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
new:seed
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    84
    "seed is actually ignored"
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    self isSupported ifFalse:[ self error:'this generator needs a cpu with rdgen instruction' ].
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
    87
    ^ self basicNew initialize; seed:seed
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
! !
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
!RandomRDRand class methodsFor:'queries'!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
isSupported
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "true if this architecture supports hardware random numbers"
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
4925
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
    95
    ^ (OperatingSystem getSystemInfo at:#extendedInstructions ifAbsent:#())
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
    96
              includes:#rdmd
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    "
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
     self isSupported
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "
4925
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   101
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   102
    "Modified: / 28-03-2019 / 10:59:32 / Stefan Vogel"
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
! !
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
!RandomRDRand methodsFor:'initialization'!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   107
initialize
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   108
!
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   109
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
seed:seed
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    "/ ignored
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
! !
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
!RandomRDRand methodsFor:'random numbers'!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
nextBoolean
3416
a71369580f84 comments
Claus Gittinger <cg@exept.de>
parents: 3405
diff changeset
   117
    "generates a boolean random"
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
4927
8e944da8fc20 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4926
diff changeset
   119
    ^ self nextInteger bitTest:1
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   120
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   121
    "
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   122
        |bag rng|
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   123
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   124
        rng := self new.
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   125
        bag := Bag new.
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   126
        100000 timesRepeat:[
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   127
            bag add:rng nextBoolean.
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   128
        ].
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   129
        bag
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   130
    "
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
nextInteger
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   134
    "generates the next integer in 0..MAXINT.
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
     Notice, it may raise an illegal instruction exception on some cpu chips,
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
     even though the cpuid instruction says that it is available"
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
   138
    |cfStillSet|
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
   139
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
%{
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   141
    unsigned INT r = 0;
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   142
    unsigned char cf;
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
   143
    int count = 50;
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    do {
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   146
#ifdef USE_DRAND64
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   147
        cf = _rdrand64_step(&r);
4925
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   148
#elif defined(USE_DRAND32)
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   149
        cf = _rdrand32_step(&r);
4925
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   150
#elif defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 2)
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   151
        // Encoding of rdrand %eax
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   152
        asm(".byte 0x0F, 0xC7, 0xF0; setc %1"
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   153
            : "=a" (r), "=r" (cf)
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   154
            : "0" (r), "1" (cf)
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   155
            : "cc");
4598
409af0c80e09 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   156
4925
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   157
#elif defined(__x86_64__) && defined(__GNUC__) && (__GNUC__ >= 2)
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   158
        // Encoding of rdrand %rax
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   159
        asm(".byte 0x48, 0x0F, 0xC7, 0xF0; setc %1"
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   160
            : "=a" (r), "=r" (cf)
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   161
            : "0" (r), "1" (cf)
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   162
            : "cc");
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
   163
4925
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   164
#else
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   165
        goto unsupported;
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
#endif
4926
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   167
    } while ((cf == 0) && (--count > 0));
0d707ba99ea5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4925
diff changeset
   168
    if (cf != 0) {
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   169
        RETURN (__MKUINT(r));
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
   170
    }
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
   171
    cfStillSet = true;
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
unsupported: ;
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
%}.
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   174
    cfStillSet == true ifTrue:[
4927
8e944da8fc20 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 4926
diff changeset
   175
        self primitiveFailed:'carry flag not set after 50 tries'
4667
35e1ebb8020e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4598
diff changeset
   176
    ].
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    self primitiveFailed:'unsupported on this architecture'
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    "
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
     self new nextInteger
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    "
4925
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   182
3b6b894d2664 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4887
diff changeset
   183
    "Modified: / 28-03-2019 / 10:46:29 / Stefan Vogel"
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
! !
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
!RandomRDRand class methodsFor:'documentation'!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
version
4322
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
   189
    ^ '$Header$'
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
!
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
version_CVS
4322
97661b0035ed #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
   193
    ^ '$Header$'
3405
84393adea27c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
! !
4887
8c49f1189e7c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
   195