diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-03-20 16:13:17 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-03-20 16:13:17 -0300 |
| commit | 5a04f1851e0d42b4bcbb0af103490bc964e985aa (patch) | |
| tree | 227f98d4fff3f1bd1eea4d20ddd4aa0ec7562ddd /manual | |
| parent | 8c064fdc23bd745bbd3456a58cc9e2521f8e4263 (diff) | |
| download | lua-5a04f1851e0d42b4bcbb0af103490bc964e985aa.tar.gz lua-5a04f1851e0d42b4bcbb0af103490bc964e985aa.tar.bz2 lua-5a04f1851e0d42b4bcbb0af103490bc964e985aa.zip | |
New function 'luaL_makeseed'
This function unifies code from 'lua_newstate', 'math.randomseed',
and 'table.sort' that tries to create a value with a minimum level
of randomness.
Diffstat (limited to 'manual')
| -rw-r--r-- | manual/manual.of | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/manual/manual.of b/manual/manual.of index 73d25951..fdae76f2 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
| @@ -20,7 +20,7 @@ making it ideal for configuration, scripting, | |||
| 20 | and rapid prototyping. | 20 | and rapid prototyping. |
| 21 | 21 | ||
| 22 | Lua is implemented as a library, written in @emphx{clean C}, | 22 | Lua is implemented as a library, written in @emphx{clean C}, |
| 23 | the common subset of @N{Standard C} and C++. | 23 | the common subset of C and C++. |
| 24 | The Lua distribution includes a host program called @id{lua}, | 24 | The Lua distribution includes a host program called @id{lua}, |
| 25 | which uses the Lua library to offer a complete, | 25 | which uses the Lua library to offer a complete, |
| 26 | standalone Lua interpreter, | 26 | standalone Lua interpreter, |
| @@ -2957,7 +2957,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, | |||
| 2957 | return realloc(ptr, nsize); | 2957 | return realloc(ptr, nsize); |
| 2958 | } | 2958 | } |
| 2959 | } | 2959 | } |
| 2960 | Note that @N{Standard C} ensures | 2960 | Note that @N{ISO C} ensures |
| 2961 | that @T{free(NULL)} has no effect and that | 2961 | that @T{free(NULL)} has no effect and that |
| 2962 | @T{realloc(NULL,size)} is equivalent to @T{malloc(size)}. | 2962 | @T{realloc(NULL,size)} is equivalent to @T{malloc(size)}. |
| 2963 | 2963 | ||
| @@ -3644,7 +3644,8 @@ Other upvalues are initialized with @nil. | |||
| 3644 | 3644 | ||
| 3645 | } | 3645 | } |
| 3646 | 3646 | ||
| 3647 | @APIEntry{lua_State *lua_newstate (lua_Alloc f, void *ud);| | 3647 | @APIEntry{lua_State *lua_newstate (lua_Alloc f, void *ud, |
| 3648 | unsigned int seed);| | ||
| 3648 | @apii{0,0,-} | 3649 | @apii{0,0,-} |
| 3649 | 3650 | ||
| 3650 | Creates a new independent state and returns its main thread. | 3651 | Creates a new independent state and returns its main thread. |
| @@ -3655,6 +3656,8 @@ Lua will do all memory allocation for this state | |||
| 3655 | through this function @seeF{lua_Alloc}. | 3656 | through this function @seeF{lua_Alloc}. |
| 3656 | The second argument, @id{ud}, is an opaque pointer that Lua | 3657 | The second argument, @id{ud}, is an opaque pointer that Lua |
| 3657 | passes to the allocator in every call. | 3658 | passes to the allocator in every call. |
| 3659 | The third argument, @id{seed}, is a seed for the hashing of | ||
| 3660 | strings when they are used as table keys. | ||
| 3658 | 3661 | ||
| 3659 | } | 3662 | } |
| 3660 | 3663 | ||
| @@ -5721,6 +5724,16 @@ it does not run it. | |||
| 5721 | 5724 | ||
| 5722 | } | 5725 | } |
| 5723 | 5726 | ||
| 5727 | @APIEntry{unsigned int luaL_makeseed (lua_State *L);| | ||
| 5728 | @apii{0,0,-} | ||
| 5729 | |||
| 5730 | Returns a value with a weak attempt for randomness. | ||
| 5731 | (It produces that value based on the current date and time, | ||
| 5732 | the current processor time, and the address of an internal variable, | ||
| 5733 | in case the machine has Address Space Layout Randomization.) | ||
| 5734 | |||
| 5735 | } | ||
| 5736 | |||
| 5724 | 5737 | ||
| 5725 | @APIEntry{void luaL_newlib (lua_State *L, const luaL_Reg l[]);| | 5738 | @APIEntry{void luaL_newlib (lua_State *L, const luaL_Reg l[]);| |
| 5726 | @apii{0,1,m} | 5739 | @apii{0,1,m} |
| @@ -6892,7 +6905,7 @@ including if necessary a path and an extension. | |||
| 6892 | @id{funcname} must be the exact name exported by the @N{C library} | 6905 | @id{funcname} must be the exact name exported by the @N{C library} |
| 6893 | (which may depend on the @N{C compiler} and linker used). | 6906 | (which may depend on the @N{C compiler} and linker used). |
| 6894 | 6907 | ||
| 6895 | This function is not supported by @N{Standard C}. | 6908 | This function is not supported by @N{ISO C}. |
| 6896 | As such, it is only available on some platforms | 6909 | As such, it is only available on some platforms |
| 6897 | (Windows, Linux, Mac OS X, Solaris, BSD, | 6910 | (Windows, Linux, Mac OS X, Solaris, BSD, |
| 6898 | plus other Unix systems that support the @id{dlfcn} standard). | 6911 | plus other Unix systems that support the @id{dlfcn} standard). |
| @@ -8093,7 +8106,7 @@ different sequences of results each time the program runs. | |||
| 8093 | 8106 | ||
| 8094 | When called with at least one argument, | 8107 | When called with at least one argument, |
| 8095 | the integer parameters @id{x} and @id{y} are | 8108 | the integer parameters @id{x} and @id{y} are |
| 8096 | joined into a 128-bit @emphx{seed} that | 8109 | joined into a @emphx{seed} that |
| 8097 | is used to reinitialize the pseudo-random generator; | 8110 | is used to reinitialize the pseudo-random generator; |
| 8098 | equal seeds produce equal sequences of numbers. | 8111 | equal seeds produce equal sequences of numbers. |
| 8099 | The default for @id{y} is zero. | 8112 | The default for @id{y} is zero. |
