UnixOperatingSystem.st
changeset 19434 fee1fbb3d8e5
parent 19432 c5d2a0141327
child 19477 af82888ceb72
child 19573 661541c56e08
equal deleted inserted replaced
19433:2bb4959d41ad 19434:fee1fbb3d8e5
  9154      NOTE: This is a private interface, please use RandomGenerator!!"
  9154      NOTE: This is a private interface, please use RandomGenerator!!"
  9155 
  9155 
  9156 %{
  9156 %{
  9157 #if defined(LINUX)
  9157 #if defined(LINUX)
  9158 # include <sys/syscall.h>
  9158 # include <sys/syscall.h>
  9159 # if defined(SYS_getrandom) // getrandom(2) is upported starting with linux 3.17 (2014-10-05)     
  9159 # if defined(SYS_getrandom) // getrandom(2) is supported starting with linux 3.17 (2014-10-05)     
  9160 
  9160 
  9161 # if 1 || !(defined(__GLIBC__) && __GLIBC_PREREQ(2, 23))
  9161 # if 1 || !(defined(__GLIBC__) && __GLIBC_PREREQ(2, 23))
  9162     // getrandom() appears first in GLIBC 2.23
  9162     // getrandom() appears first in GLIBC 2.23
  9163     // but we define it here until this GLIBC has been deployed on all linux distributions
  9163     // but we define it here until this GLIBC has been deployed on all linux distributions
  9164     // used by our customers
  9164     // used by our customers
  9168     }
  9168     }
  9169 # endif
  9169 # endif
  9170 
  9170 
  9171     size_t wanted, cnt, gotSoFar = 0;
  9171     size_t wanted, cnt, gotSoFar = 0;
  9172     char *buffer;
  9172     char *buffer;
  9173     INT intBufffer = 0;
  9173     INT intBuffer = 0;
  9174     int wantInteger = 0;
  9174     int wantInteger = 0;
  9175     
  9175     
  9176     if (__isSmallInteger(bufferOrInteger)) {
  9176     if (__isSmallInteger(bufferOrInteger)) {
  9177         wanted = __smallIntegerVal(bufferOrInteger);
  9177         wanted = __smallIntegerVal(bufferOrInteger);
  9178         if (wanted > sizeof(INT)) goto error;
  9178         if (wanted > sizeof(INT)) goto error;
  9197         } else {
  9197         } else {
  9198             gotSoFar = gotSoFar + cnt;
  9198             gotSoFar = gotSoFar + cnt;
  9199         }
  9199         }
  9200     } while (gotSoFar < wanted);
  9200     } while (gotSoFar < wanted);
  9201     if (wantInteger) {
  9201     if (wantInteger) {
  9202         RETURN(__mkSmallInteger(intBufffer & _MAX_INT));
  9202         RETURN(__mkSmallInteger(intBuffer & _MAX_INT));
  9203     }
  9203     }
  9204     RETURN(bufferOrInteger);
  9204     RETURN(bufferOrInteger);
  9205 # endif // SYS_getrandom
  9205 # endif // SYS_getrandom
  9206 #endif
  9206 #endif
  9207 error: ;
  9207 error: ;