[svn:parrot] r37042 - in trunk: . config/gen/makefiles runtime/parrot/library/Math t/library

fperrad at svn.parrot.org fperrad at svn.parrot.org
Sat Feb 28 11:44:34 UTC 2009


Author: fperrad
Date: Sat Feb 28 11:44:33 2009
New Revision: 37042
URL: https://trac.parrot.org/parrot/changeset/37042

Log:
rename rand library

Added:
   trunk/runtime/parrot/library/Math/Rand.pir   (contents, props changed)
      - copied, changed from r37040, trunk/runtime/parrot/library/Math/rand.pir
Deleted:
   trunk/runtime/parrot/library/Math/rand.pir
Modified:
   trunk/MANIFEST
   trunk/MANIFEST.generated
   trunk/config/gen/makefiles/root.in
   trunk/t/library/rand.t

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Sat Feb 28 11:42:30 2009	(r37041)
+++ trunk/MANIFEST	Sat Feb 28 11:44:33 2009	(r37042)
@@ -1946,7 +1946,7 @@
 runtime/parrot/library/JSON.pir                             [library]
 runtime/parrot/library/MIME/Base64.pir                      [library]
 runtime/parrot/library/Math/Random/mt19937ar.pir            [library]
-runtime/parrot/library/Math/rand.pir                        [library]
+runtime/parrot/library/Math/Rand.pir                        [library]
 runtime/parrot/library/NCI/call_toolkit_init.pir            [library]
 runtime/parrot/library/OpenGL.pir                           [library]
 runtime/parrot/library/P6object.pir                         [library]

Modified: trunk/MANIFEST.generated
==============================================================================
--- trunk/MANIFEST.generated	Sat Feb 28 11:42:30 2009	(r37041)
+++ trunk/MANIFEST.generated	Sat Feb 28 11:44:33 2009	(r37042)
@@ -216,7 +216,7 @@
 runtime/parrot/library/dumper.pbc                 [main]
 runtime/parrot/library/Getopt/Obj.pbc             [main]
 runtime/parrot/library/Math/Random/mt19937ar.pbc  [main]
-runtime/parrot/library/Math/rand.pbc              [main]
+runtime/parrot/library/Math/Rand.pbc              [main]
 runtime/parrot/library/MIME/Base64.pbc            [main]
 runtime/parrot/library/NCI/call_toolkit_init.pbc  [main]
 runtime/parrot/library/ncurses.pbc                [main]

Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in	Sat Feb 28 11:42:30 2009	(r37041)
+++ trunk/config/gen/makefiles/root.in	Sat Feb 28 11:44:33 2009	(r37042)
@@ -252,7 +252,7 @@
     $(LIBRARY_DIR)/Getopt/Obj.pbc \
     $(LIBRARY_DIR)/JSON.pbc \
     $(LIBRARY_DIR)/Math/Random/mt19937ar.pbc \
-    $(LIBRARY_DIR)/Math/rand.pbc \
+    $(LIBRARY_DIR)/Math/Rand.pbc \
     $(LIBRARY_DIR)/MIME/Base64.pbc \
     $(LIBRARY_DIR)/NCI/call_toolkit_init.pbc \
     $(LIBRARY_DIR)/ncurses.pbc \

Copied and modified: trunk/runtime/parrot/library/Math/Rand.pir (from r37040, trunk/runtime/parrot/library/Math/rand.pir)
==============================================================================
--- trunk/runtime/parrot/library/Math/rand.pir	Sat Feb 28 10:47:04 2009	(r37040, copy source)
+++ trunk/runtime/parrot/library/Math/Rand.pir	Sat Feb 28 11:44:33 2009	(r37042)
@@ -34,7 +34,7 @@
 
 =head1 USAGE
 
-    load_bytecode 'library/Math/rand.pbc'
+    load_bytecode 'library/Math/Rand.pbc'
     .local pmc rand
     rand = get_global [ 'Math'; 'Rand' ], 'rand'
     .local pmc srand

Deleted: trunk/runtime/parrot/library/Math/rand.pir
==============================================================================
--- trunk/runtime/parrot/library/Math/rand.pir	Sat Feb 28 11:44:33 2009	(r37041)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,96 +0,0 @@
-# Copyright (C) 2009, Parrot Foundation.
-# $Id$
-
-=head1 NAME
-
-Math/rand.pir - the ANSI C rand pseudorandom number generator
-
-=head1 DESCRIPTION
-
-The C<rand> function computes a sequence of pseudo-random integers in the
-range 0 to C<RAND_MAX>.
-
-The C<srand> function uses the argment as a seed for a new sequence of
-pseudo-random numbers to be returned by subsequent calls to C<rand>.
-If C<srand> is then called with the same seed value, the sequence of
-pseudo-random numbers shall be repeated. If C<rand> is called before any calls
-to C<srand> have been made, the same sequence shall be generated as when
-C<srand> is first called with a seed value of 1.
-
-Portage of the following C implementation, given as example by ISO/IEC 9899:1999.
-
-  static unsigned long int next = 1;
-  //
-  int rand(void);
-  {
-      next = next * 1103515245 + 12345;
-      return (unsigned int)(next/65536) % 32768;
-  }
-  //
-  void srand(unsigned int seed)
-  {
-      next = seed;
-  }
-
-=head1 USAGE
-
-    load_bytecode 'library/Math/rand.pbc'
-    .local pmc rand
-    rand = get_global [ 'Math'; 'Rand' ], 'rand'
-    .local pmc srand
-    srand = get_global [ 'Math'; 'Rand' ], 'srand'
-    .local int seed
-    srand(seed)
-    $I0 = rand()
-    .local pmc rand_max
-    rand_max = get_global [ 'Math'; 'Rand' ], 'RAND_MAX'
-    .local int RAND_MAX
-    RAND_MAX = rand_max()
-
-=cut
-
-.namespace [ 'Math'; 'Rand' ]
-
-.sub '__onload' :anon :load
-#    print "__onload Math::Rand\n"
-    new $P0, 'Integer'
-    set $P0, 1
-    set_global 'next', $P0
-.end
-
-.sub 'RAND_MAX'
-    .return (32767)
-.end
-
-.sub 'rand'
-    $P0 = get_global 'next'
-    $I0 = $P0
-    $I0 *= 1103515245
-    $I0 += 12345
-    set $P0, $I0
-    $I0 /= 65536
-    $I0 %= 32768
-    .return ($I0)
-.end
-
-.sub 'srand'
-    .param int seed
-    $P0 = get_global 'next'
-    set $P0, seed
-.end
-
-
-=back
-
-=head1 AUTHORS
-
-Francois Perrad
-
-=cut
-
-
-# Local Variables:
-#   mode: pir
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:

Modified: trunk/t/library/rand.t
==============================================================================
--- trunk/t/library/rand.t	Sat Feb 28 11:42:30 2009	(r37041)
+++ trunk/t/library/rand.t	Sat Feb 28 11:44:33 2009	(r37042)
@@ -20,7 +20,7 @@
 
 pir_output_is( << 'CODE', << 'OUTPUT', 'rand / srand' );
 .sub test :main
-    load_bytecode 'Math/rand.pbc'
+    load_bytecode 'Math/Rand.pbc'
     .local pmc rand
     rand = get_global [ 'Math'; 'Rand' ], 'rand'
     .local pmc srand
@@ -50,7 +50,7 @@
 
 pir_output_is( << 'CODE', << 'OUTPUT', 'RAND_MAX' );
 .sub test :main
-    load_bytecode 'Math/rand.pbc'
+    load_bytecode 'Math/Rand.pbc'
     .local pmc rand_max
     rand_max = get_global [ 'Math'; 'Rand' ], 'RAND_MAX'
     $I0 = rand_max()


More information about the parrot-commits mailing list