1 6212 aw148015 /* 2 6212 aw148015 * CDDL HEADER START 3 6212 aw148015 * 4 6212 aw148015 * The contents of this file are subject to the terms of the 5 6212 aw148015 * Common Development and Distribution License (the "License"). 6 6212 aw148015 * You may not use this file except in compliance with the License. 7 6212 aw148015 * 8 6212 aw148015 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 6212 aw148015 * or http://www.opensolaris.org/os/licensing. 10 6212 aw148015 * See the License for the specific language governing permissions 11 6212 aw148015 * and limitations under the License. 12 6212 aw148015 * 13 6212 aw148015 * When distributing Covered Code, include this CDDL HEADER in each 14 6212 aw148015 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 6212 aw148015 * If applicable, add the following below this CDDL HEADER, with the 16 6212 aw148015 * fields enclosed by brackets "[]" replaced with your own identifying 17 6212 aw148015 * information: Portions Copyright [yyyy] [name of copyright owner] 18 6212 aw148015 * 19 6212 aw148015 * CDDL HEADER END 20 6212 aw148015 */ 21 6212 aw148015 /* 22 6212 aw148015 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 6212 aw148015 * Use is subject to license terms. 24 6212 aw148015 */ 25 6212 aw148015 26 6212 aw148015 #ifndef _FB_RANDOM_H 27 6212 aw148015 #define _FB_RANDOM_H 28 6212 aw148015 29 6212 aw148015 #pragma ident "%Z%%M% %I% %E% SMI" 30 6212 aw148015 31 6212 aw148015 #include "config.h" 32 6212 aw148015 33 6212 aw148015 #ifdef HAVE_STDINT_H 34 6212 aw148015 #include <stdint.h> 35 6212 aw148015 #endif 36 6212 aw148015 37 6212 aw148015 #ifdef __cplusplus 38 6212 aw148015 extern "C" { 39 6212 aw148015 #endif 40 6212 aw148015 41 6212 aw148015 /* 42 6212 aw148015 * probability table entry, used while parsing the supplied 43 6212 aw148015 * probability table 44 6212 aw148015 */ 45 6212 aw148015 typedef struct probtabent { 46 6212 aw148015 struct probtabent *pte_next; 47 6212 aw148015 avd_t pte_percent; 48 6212 aw148015 avd_t pte_segmin; 49 6212 aw148015 avd_t pte_segmax; 50 6212 aw148015 } probtabent_t; 51 6212 aw148015 52 6212 aw148015 /* 53 6212 aw148015 * The supplied probability table is converted into a probability funtion 54 6212 aw148015 * lookup table at initialization time. This is the definition for each 55 6212 aw148015 * entry in the table. 56 6212 aw148015 */ 57 6212 aw148015 typedef struct randfunc { 58 6212 aw148015 double rf_base; 59 6212 aw148015 double rf_range; 60 6212 aw148015 } randfunc_t; 61 6212 aw148015 62 6212 aw148015 /* Number of entries in the probability function table */ 63 6212 aw148015 #define PF_TAB_SIZE 100 64 6212 aw148015 65 6212 aw148015 /* 66 6212 aw148015 * Random Distribution definition object. Includes a pointer to the 67 6212 aw148015 * appropriate function to access the distribution defined by the object, 68 6212 aw148015 * as well as a function pointer to the specified source of random 69 6212 aw148015 * numbers. 70 6212 aw148015 */ 71 6212 aw148015 typedef struct randdist { 72 6212 aw148015 double (*rnd_get)(struct randdist *); 73 6212 aw148015 double (*rnd_src)(unsigned short *); 74 6212 aw148015 struct randdist *rnd_next; 75 6212 aw148015 struct var *rnd_var; 76 6212 aw148015 avd_t rnd_seed; 77 6212 aw148015 avd_t rnd_mean; 78 6212 aw148015 avd_t rnd_gamma; 79 6212 aw148015 avd_t rnd_min; 80 6212 aw148015 avd_t rnd_round; 81 6212 aw148015 double rnd_dbl_mean; 82 6212 aw148015 double rnd_dbl_gamma; 83 6212 aw148015 fbint_t rnd_vint_min; 84 6212 aw148015 fbint_t rnd_vint_round; 85 6212 aw148015 probtabent_t *rnd_probtabs; 86 6212 aw148015 randfunc_t rnd_rft[PF_TAB_SIZE]; 87 6212 aw148015 uint16_t rnd_xi[3]; 88 6212 aw148015 uint16_t rnd_type; 89 6212 aw148015 } randdist_t; 90 6212 aw148015 91 6212 aw148015 #define RAND_TYPE_UNIFORM 0x1 92 6212 aw148015 #define RAND_TYPE_GAMMA 0x2 93 6212 aw148015 #define RAND_TYPE_TABLE 0x3 94 6212 aw148015 #define RAND_TYPE_MASK 0x0fff 95 6212 aw148015 #define RAND_SRC_URANDOM 0x0000 96 6212 aw148015 #define RAND_SRC_GENERATOR 0x1000 97 6212 aw148015 98 6212 aw148015 #define RAND_PARAM_TYPE 1 99 6212 aw148015 #define RAND_PARAM_SRC 2 100 6212 aw148015 #define RAND_PARAM_SEED 3 101 6212 aw148015 #define RAND_PARAM_MIN 4 102 6212 aw148015 #define RAND_PARAM_MEAN 5 103 6212 aw148015 #define RAND_PARAM_GAMMA 6 104 6212 aw148015 #define RAND_PARAM_ROUND 7 105 6212 aw148015 106 6212 aw148015 randdist_t *randdist_alloc(void); 107 6212 aw148015 void randdist_init(void); 108 6212 aw148015 int filebench_randomno32(uint32_t *, uint32_t, uint32_t, avd_t); 109 6212 aw148015 int filebench_randomno64(uint64_t *, uint64_t, uint64_t, avd_t); 110 6212 aw148015 void fb_random_init(void); 111 6212 aw148015 112 6212 aw148015 #ifdef __cplusplus 113 6212 aw148015 } 114 6212 aw148015 #endif 115 6212 aw148015 116 6212 aw148015 #endif /* _FB_RANDOM_H */ 117