| 1 | /* | 
|---|
| 2 | * Legal Notice | 
|---|
| 3 | * | 
|---|
| 4 | * This document and associated source code (the "Work") is a part of a | 
|---|
| 5 | * benchmark specification maintained by the TPC. | 
|---|
| 6 | * | 
|---|
| 7 | * The TPC reserves all right, title, and interest to the Work as provided | 
|---|
| 8 | * under U.S. and international laws, including without limitation all patent | 
|---|
| 9 | * and trademark rights therein. | 
|---|
| 10 | * | 
|---|
| 11 | * No Warranty | 
|---|
| 12 | * | 
|---|
| 13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION | 
|---|
| 14 | *     CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE | 
|---|
| 15 | *     AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER | 
|---|
| 16 | *     WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, | 
|---|
| 17 | *     INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, | 
|---|
| 18 | *     DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR | 
|---|
| 19 | *     PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF | 
|---|
| 20 | *     WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. | 
|---|
| 21 | *     ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, | 
|---|
| 22 | *     QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT | 
|---|
| 23 | *     WITH REGARD TO THE WORK. | 
|---|
| 24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO | 
|---|
| 25 | *     ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE | 
|---|
| 26 | *     COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS | 
|---|
| 27 | *     OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, | 
|---|
| 28 | *     INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, | 
|---|
| 29 | *     OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT | 
|---|
| 30 | *     RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD | 
|---|
| 31 | *     ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. | 
|---|
| 32 | * | 
|---|
| 33 | * Contributors: | 
|---|
| 34 | * Gradient Systems | 
|---|
| 35 | */ | 
|---|
| 36 | #ifndef R_DIST_H | 
|---|
| 37 | #define R_DIST_H | 
|---|
| 38 |  | 
|---|
| 39 | #ifdef __cplusplus | 
|---|
| 40 | extern "C"{ | 
|---|
| 41 | #endif | 
|---|
| 42 |  | 
|---|
| 43 | #define D_NAME_LEN 20 | 
|---|
| 44 |  | 
|---|
| 45 | typedef struct DIST_T { | 
|---|
| 46 | int *type_vector; | 
|---|
| 47 | int **weight_sets; | 
|---|
| 48 | int *maximums; | 
|---|
| 49 | int **value_sets; | 
|---|
| 50 | char *strings; | 
|---|
| 51 | char *names; | 
|---|
| 52 | int size; | 
|---|
| 53 | } dist_t; | 
|---|
| 54 |  | 
|---|
| 55 | typedef struct D_IDX_T { | 
|---|
| 56 | char name[D_NAME_LEN + 1]; | 
|---|
| 57 | int index; | 
|---|
| 58 | int nAllocatedLength; | 
|---|
| 59 | int nRemainingStrSpace; | 
|---|
| 60 | int offset; | 
|---|
| 61 | int str_space; | 
|---|
| 62 | int name_space; | 
|---|
| 63 | int length; | 
|---|
| 64 | int w_width; | 
|---|
| 65 | int v_width; | 
|---|
| 66 | int flags; | 
|---|
| 67 | dist_t *dist; | 
|---|
| 68 | } d_idx_t; | 
|---|
| 69 |  | 
|---|
| 70 | typedef struct DISTINDEX_T { | 
|---|
| 71 | int nDistCount; | 
|---|
| 72 | int nAllocatedCount; | 
|---|
| 73 | d_idx_t *pEntries; | 
|---|
| 74 | } distindex_t; | 
|---|
| 75 |  | 
|---|
| 76 | /* must match WriteDist() in dcomp.c */ | 
|---|
| 77 | #define IDX_SIZE (D_NAME_LEN + 7 * sizeof(int)) | 
|---|
| 78 |  | 
|---|
| 79 | int dist_op(void *dest, int op, char *d_name, int vset, int wset, int stream); | 
|---|
| 80 | #define pick_distribution(dest, dist, v, w, s) dist_op(dest, 0, dist, v, w, s) | 
|---|
| 81 | #define dist_member(dest, dist, v, w) dist_op(dest, 1, dist, v, w, 0) | 
|---|
| 82 | #define dist_max(dist, w) dist->maximums[w - 1] | 
|---|
| 83 | int dist_weight(int *dest, char *d, int index, int wset); | 
|---|
| 84 | int distsize(char *szDistname); | 
|---|
| 85 | int dist_type(char *szDistName, int vset); | 
|---|
| 86 | d_idx_t *find_dist(char *name); | 
|---|
| 87 | int IntegrateDist(char *szDistName, int nPct, int nStartIndex, int nWeightSet); | 
|---|
| 88 | void dump_dist(char *szName); | 
|---|
| 89 | int dist_active(char *szName, int nWeightSet); | 
|---|
| 90 | int DistNameIndex(char *szDist, int nNameType, char *szName); | 
|---|
| 91 | int DistSizeToShiftWidth(char *szDist, int nWeightSet); | 
|---|
| 92 | int MatchDistWeight(void *dest, char *szDist, int nWeight, int nWeightSet, int ValueSet); | 
|---|
| 93 | int findDistValue(char *szValue, char *szDistName, int ValueSet); | 
|---|
| 94 | int di_compare(const void *op1, const void *op2); | 
|---|
| 95 |  | 
|---|
| 96 | #define DIST_UNIFORM 0x0001 | 
|---|
| 97 | #define DIST_EXPONENTIAL 0x0002 | 
|---|
| 98 | /* sales and returns are special; they must match calendar.dst */ | 
|---|
| 99 | #define DIST_SALES 3 | 
|---|
| 100 | #define DIST_RETURNS 5 | 
|---|
| 101 | #define DIST_CHAR 0x0004 | 
|---|
| 102 | #define DIST_INT 0x0008 | 
|---|
| 103 | #define DIST_NAMES_SET 0xff00 | 
|---|
| 104 |  | 
|---|
| 105 | /* DistNameIndex needs to know what sort of name we are trying to match */ | 
|---|
| 106 | #define VALUE_NAME 0x0000 | 
|---|
| 107 | #define WEIGHT_NAME 0x0001 | 
|---|
| 108 |  | 
|---|
| 109 | #ifdef __cplusplus | 
|---|
| 110 | }; | 
|---|
| 111 | #endif | 
|---|
| 112 |  | 
|---|
| 113 | #endif /* R_DIST_H */ | 
|---|
| 114 |  | 
|---|