src/lib/w32/random.h File Reference

#include <io.h>

Include dependency graph for random.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  random_data

Defines

#define NULL   ((void *)0)
#define __libc_lock_lock(lock)
#define __libc_lock_unlock(lock)
#define __libc_lock_define_initialized(static1, lock)
#define __set_errno(val)   (errno = (val))
#define weak_alias(arg1, arg2)
#define srandom_r(seed, buf)   __srandom_r((seed), (buf))
#define random_r(buf, result)   __random_r((buf), (result))
#define initstate_r(seed, state, size, buf)   __initstate_r((seed), (state), (size), (buf))
#define setstate_r(state, buf)   __setstate_r((state), (buf))

Typedefs

typedef int int32_t

Functions

int __random_r (struct random_data *__restrict __buf, int32_t *__restrict __result)
int __srandom_r (unsigned int __seed, struct random_data *__buf)
int __initstate_r (unsigned int __seed, char *__restrict __statebuf, size_t __statelen, struct random_data *__restrict __buf)
int __setstate_r (char *__restrict __statebuf, struct random_data *__restrict __buf)


Define Documentation

#define __libc_lock_define_initialized ( static1,
lock   ) 

Definition at line 22 of file random.h.

#define __libc_lock_lock ( lock   ) 

Definition at line 20 of file random.h.

Referenced by __initstate(), __random(), __setstate(), and __srandom().

#define __libc_lock_unlock ( lock   ) 

Definition at line 21 of file random.h.

Referenced by __initstate(), __random(), __setstate(), and __srandom().

#define __set_errno ( val   )     (errno = (val))

Definition at line 27 of file random.h.

Referenced by __initstate_r(), __random_r(), and __setstate_r().

#define initstate_r ( seed,
state,
size,
buf   )     __initstate_r((seed), (state), (size), (buf))

Definition at line 33 of file random.h.

#define NULL   ((void *)0)

Definition at line 4 of file random.h.

Referenced by __initstate_r(), __random_r(), __setstate(), __setstate_r(), __srandom_r(), ac_encounter(), acce(), add(), add2symset(), add_shiplist(), age_levels(), allocate_memory(), anti_torp(), apro(), as_add_cachepath(), as_clear_cachepath(), as_extend(), as_find_cachepath(), as_free_hashtab(), as_init(), as_iscinq(), as_merge(), as_newnode(), as_reset(), as_search(), as_setcinq(), as_winnow(), assemble_dist_paths(), att_ask_support(), best_path(), BestAirPath(), BestLandPath(), bestownedpath(), BestShipPath(), bp_init(), bp_neighbors(), calc_all(), chan(), coas(), comm_bomb(), conv_num(), count_pop(), daytime(), daytime_range(), delete_old_announcements(), delete_old_news(), deli(), demandupdatecheck(), disable_coms(), dispatch(), display_region_map(), do_fallout(), do_unit_move(), dopipe(), doredir(), draw_map(), ef_close(), ef_fina_view(), ef_open(), ef_ptr(), emp_config(), emp_obj_chr_name(), empth_create(), empth_exit(), empth_init(), empth_init_signals(), empth_rwlock_create(), empth_select(), empth_sleep(), empth_start(), empth_threadMain(), empth_yield(), execute(), fcntl(), fileno(), find_string(), finish_sects(), free_shiplist(), game_tick_tick(), gamedown(), gen_power(), get_assembly_point(), get_empobj_chr(), get_empobjp(), getfld(), getin(), getpath(), getplayer(), getsose(), getstring(), guerrilla(), hostaddr(), hostport(), info(), install_service(), io_open(), is_daytime_allowed(), is_wday_allowed(), journal_shutdown(), keylookup(), lload(), lnd_prewrite(), load(), loc_BlockThisThread(), loc_RunThisThread(), login(), look_land(), look_ship(), lookup_handle(), lretr(), lwp_rwlock_create(), lwpCreate(), lwpGetSig(), lwpInitSigWait(), lwpInitSystem(), lwpNewContext(), lwpReschedule(), lwpSelect(), lwpSigWakeup(), lwpSleepUntil(), lwpWakeupSleep(), main(), map(), mission(), mob_land(), mob_plane(), mob_sect(), mob_ship(), move_ground(), mtsymset(), natargp(), natbyname(), nati(), nav_map(), ncache(), new(), nstr_comp_val(), nstr_exec_val(), nstr_resolve_id(), nstr_resolve_sel(), on_shiplist(), options_cmd(), orig(), panic(), parse(), parse_every(), parse_skip(), parse_time(), parse_until(), path(), perform_mission(), planerepair(), play(), player_accept(), player_init(), player_login(), player_new(), pln_equip(), pln_oneway_to_carrier_ok(), pln_prewrite(), posix_accept(), powe(), pr_player(), prepare_sects(), print_shiplist(), prod_land(), prod_nat(), prod_plane(), prod_ship(), produce_sect(), quiet_bigdef(), rea(), read_builtin_tables(), read_custom_tables(), read_schedule(), readv(), real(), rela(), remove_service(), retr(), ReversePath(), rout(), run_hook(), sail_ship(), sct(), sendcmd(), servercmd(), set_paths(), setstr(), setsym(), share_incr(), ship_bomb(), show_land_capab(), show_motd(), show_nuke_capab(), show_plane_capab(), show_ship_capab(), show_updates(), showsat(), showship(), shp_prewrite(), shutdown_initiate(), skyw(), snxtitem(), sona(), strptime(), surv(), symbol_by_value(), take_casualties(), take_casualty(), tcp_listen(), tele(), tend(), torp(), turn(), typed_wu(), ugetstring(), unit_map(), upd_slmilcosts(), update_get_schedule(), update_init(), update_main(), update_removewants(), update_sched(), wall(), weekday(), writev(), xdhdr(), xdvisible(), xubody(), xuesc(), xufld(), and zdon().

#define random_r ( buf,
result   )     __random_r((buf), (result))

Definition at line 32 of file random.h.

#define setstate_r ( state,
buf   )     __setstate_r((state), (buf))

Definition at line 35 of file random.h.

#define srandom_r ( seed,
buf   )     __srandom_r((seed), (buf))

Definition at line 31 of file random.h.

#define weak_alias ( arg1,
arg2   ) 

Definition at line 30 of file random.h.


Typedef Documentation

typedef int int32_t

Definition at line 3 of file random.h.


Function Documentation

int __initstate_r ( unsigned int  __seed,
char *__restrict  __statebuf,
size_t  __statelen,
struct random_data *__restrict  __buf 
)

Referenced by __initstate().

int __random_r ( struct random_data *__restrict  __buf,
int32_t *__restrict  __result 
)

Referenced by __random(), and __srandom_r().

int __setstate_r ( char *__restrict  __statebuf,
struct random_data *__restrict  __buf 
)

Referenced by __setstate().

int __srandom_r ( unsigned int  __seed,
struct random_data __buf 
)

Definition at line 166 of file random_r.c.

References __random_r(), random_data::fptr, MAX_TYPES, NULL, random_data::rand_deg, random_data::rand_sep, random_data::rand_type, random_data::rptr, random_data::state, and TYPE_0.

Referenced by __initstate_r(), and __srandom().

00169 {
00170   int type;
00171   int32_t *state;
00172   long int i;
00173   long int word;
00174   int32_t *dst;
00175   int kc;
00176 
00177   if (buf == NULL)
00178     goto fail;
00179   type = buf->rand_type;
00180   if ((unsigned int) type >= MAX_TYPES)
00181     goto fail;
00182 
00183   state = buf->state;
00184   /* We must make sure the seed is not 0.  Take arbitrarily 1 in this case.  */
00185   if (seed == 0)
00186     seed = 1;
00187   state[0] = seed;
00188   if (type == TYPE_0)
00189     goto done;
00190 
00191   dst = state;
00192   word = seed;
00193   kc = buf->rand_deg;
00194   for (i = 1; i < kc; ++i)
00195     {
00196       /* This does:
00197            state[i] = (16807 * state[i - 1]) % 2147483647;
00198          but avoids overflowing 31 bits.  */
00199       long int hi = word / 127773;
00200       long int lo = word % 127773;
00201       word = 16807 * lo - 2836 * hi;
00202       if (word < 0)
00203         word += 2147483647;
00204       *++dst = word;
00205     }
00206 
00207   buf->fptr = &state[buf->rand_sep];
00208   buf->rptr = &state[0];
00209   kc *= 10;
00210   while (--kc >= 0)
00211     {
00212       int32_t discard;
00213       (void) __random_r (buf, &discard);
00214     }
00215 
00216  done:
00217   return 0;
00218 
00219  fail:
00220   return -1;
00221 }

Here is the call graph for this function:


Generated on Fri Mar 28 11:01:56 2008 for empserver by  doxygen 1.5.2