forked from filebench/filebench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vars.c
897 lines (751 loc) · 18.4 KB
/
vars.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Portions Copyright 2008 Denis Cheng
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include "filebench.h"
#include "vars.h"
#include "misc.h"
#include "utils.h"
#include "stats.h"
#include "eventgen.h"
#include "fb_random.h"
/*
* The filebench variables system has attribute value descriptors (avd_t) where
* an avd contains a boolean, integer, double, string, random distribution
* object ptr, boolean ptr, integer ptr, double ptr, string ptr, or variable
* ptr. The system also has the variables themselves, (var_t), which are named
* and typed entities that can be allocated, selected and changed using the
* "set" command and used in attribute assignments. The variables contain
* either a boolean, an integer, a double, a string or pointer to an associated
* random distribution object. Both avd_t and var_t entities are allocated from
* interprocess shared memory space.
*
* The attribute descriptors implement delayed binding to variable values,
* which is necessary because the values of variables may be changed between
* the time the workload model is loaded and the time it actually runs by
* further "set" commands.
*
* For static attributes, the value is just loaded in the descriptor directly,
* avoiding the need to allocate a variable to hold the static value.
*
* For random variables, they actually point to the random distribution object,
* allowing Filebench to invoke the appropriate random distribution function on
* each access to the attribute.
*
* The routines in this module are used to allocate, locate, and manipulate the
* attribute descriptors and vars. Routines are also included to convert
* between the component strings, doubles and integers of vars, and said
* components of avd_t.
*/
static char *
avd_get_type_textified(avd_t avd)
{
switch (avd->avd_type) {
case AVD_INVALID:
return "uninitialized";
case AVD_VAL_BOOL:
return "boolean";
case AVD_VARVAL_BOOL:
return "pointer to a boolean in a variable";
case AVD_VAL_INT:
return "integer";
case AVD_VARVAL_INT:
return "pointer to an integer in a variable";
case AVD_VAL_DBL:
return "double";
case AVD_VARVAL_DBL:
return "pointer to a double in a variable";
case AVD_VAL_STR:
return "string";
case AVD_VARVAL_STR:
return "pointer to a string in a variable";
case AVD_VARVAL_RANDOM:
return "pointer to a random variable";
case AVD_VARVAL_CUSTOM:
return "pointer to a custom variable";
case AVD_VARVAL_UNKNOWN:
return "pointer to variable of unknown type";
default:
return "illegal avd type";
}
}
static void
set_avd_type_by_var(avd_t avd, var_t *var, int error_on_unknown) {
switch (var->var_type) {
case VAR_BOOL:
avd->avd_type = AVD_VARVAL_BOOL;
avd->avd_val.boolptr = &var->var_val.boolean;
break;
case VAR_INT:
avd->avd_type = AVD_VARVAL_INT;
avd->avd_val.intptr = &var->var_val.integer;
break;
case VAR_DBL:
avd->avd_type = AVD_VARVAL_DBL;
avd->avd_val.dblptr = &var->var_val.dbl;
break;
case VAR_STR:
avd->avd_type = AVD_VARVAL_STR;
avd->avd_val.strptr = &var->var_val.string;
break;
case VAR_RANDOM:
avd->avd_type = AVD_VARVAL_RANDOM;
avd->avd_val.randptr = var->var_val.randptr;
break;
case VAR_CUSTOM:
avd->avd_type = AVD_VARVAL_CUSTOM;
avd->avd_val.cvarptr = var->var_val.cvarptr;
break;
case VAR_UNKNOWN:
if (error_on_unknown) {
filebench_log(LOG_ERROR,
"Noninitialized variable %s", var->var_name);
filebench_shutdown(1);
}
avd->avd_type = AVD_VARVAL_UNKNOWN;
avd->avd_val.varptr = var;
break;
default:
filebench_log(LOG_ERROR,
"Invalid variable type (variable: %s)", var->var_name);
filebench_shutdown(1);
}
}
boolean_t
avd_get_bool(avd_t avd)
{
var_t *var;
assert(avd);
switch (avd->avd_type) {
case AVD_VAL_BOOL:
return avd->avd_val.boolval;
case AVD_VARVAL_BOOL:
assert(avd->avd_val.boolptr);
return *(avd->avd_val.boolptr);
case AVD_VAL_INT:
if (avd->avd_val.intval)
return TRUE;
return FALSE;
case AVD_VARVAL_INT:
assert(avd->avd_val.intptr);
if (*(avd->avd_val.intptr))
return TRUE;
return FALSE;
case AVD_VAL_DBL:
if (avd->avd_val.dblval)
return TRUE;
return FALSE;
case AVD_VARVAL_DBL:
assert(avd->avd_val.dblptr);
if (*(avd->avd_val.dblptr))
return TRUE;
return FALSE;
case AVD_VARVAL_UNKNOWN:
var = avd->avd_val.varptr;
set_avd_type_by_var(avd, var, 1);
return avd_get_bool(avd);
default:
filebench_log(LOG_ERROR,
"Attempt to get boolean from %s avd",
avd_get_type_textified(avd));
return FALSE;
}
}
uint64_t
avd_get_int(avd_t avd)
{
randdist_t *rndp;
cvar_t *cvar;
var_t *var;
assert(avd);
switch (avd->avd_type) {
case AVD_VAL_INT:
return avd->avd_val.intval;
case AVD_VARVAL_INT:
assert(avd->avd_val.intptr);
return *(avd->avd_val.intptr);
case AVD_VAL_DBL:
return (uint64_t)avd->avd_val.dblval;
case AVD_VARVAL_DBL:
assert(avd->avd_val.dblptr);
return (uint64_t)*(avd->avd_val.dblptr);
case AVD_VARVAL_RANDOM:
rndp = avd->avd_val.randptr;
assert(rndp);
return (uint64_t)rndp->rnd_get(rndp);
case AVD_VARVAL_CUSTOM:
cvar = avd->avd_val.cvarptr;
assert(cvar);
return (uint64_t)get_cvar_value(cvar);
case AVD_VARVAL_UNKNOWN:
var = avd->avd_val.varptr;
set_avd_type_by_var(avd, var, 1);
return avd_get_int(avd);
default:
filebench_log(LOG_ERROR,
"Attempt to get integer from %s avd",
avd_get_type_textified(avd));
return 0;
}
}
double
avd_get_dbl(avd_t avd)
{
randdist_t *rndp;
cvar_t *cvar;
var_t *var;
assert(avd);
switch (avd->avd_type) {
case AVD_VAL_DBL:
return avd->avd_val.dblval;
case AVD_VARVAL_DBL:
assert(avd->avd_val.dblptr);
return *(avd->avd_val.dblptr);
case AVD_VAL_INT:
return (double)avd->avd_val.intval;
case AVD_VARVAL_INT:
assert(avd->avd_val.intptr);
return (double)(*(avd->avd_val.intptr));
case AVD_VARVAL_RANDOM:
rndp = avd->avd_val.randptr;
assert(rndp);
return rndp->rnd_get(rndp);
case AVD_VARVAL_CUSTOM:
cvar = avd->avd_val.cvarptr;
assert(cvar);
return get_cvar_value(cvar);
case AVD_VARVAL_UNKNOWN:
var = avd->avd_val.varptr;
set_avd_type_by_var(avd, var, 1);
return avd_get_dbl(avd);
default:
filebench_log(LOG_ERROR,
"Attempt to get floating point from %s avd",
avd_get_type_textified(avd));
return 0.0;
}
}
char *
avd_get_str(avd_t avd)
{
assert(avd);
var_t *var;
switch (avd->avd_type) {
case AVD_VAL_STR:
return avd->avd_val.strval;
case AVD_VARVAL_STR:
assert(avd->avd_val.strptr);
return *avd->avd_val.strptr;
case AVD_VARVAL_UNKNOWN:
var = avd->avd_val.varptr;
set_avd_type_by_var(avd, var, 1);
return avd_get_str(avd);
default:
filebench_log(LOG_ERROR,
"Attempt to get string from %s avd",
avd_get_type_textified(avd));
return NULL;
}
}
static avd_t
avd_alloc_cmn(void)
{
avd_t avd;
avd = (avd_t)ipc_malloc(FILEBENCH_AVD);
if (!avd)
filebench_log(LOG_ERROR, "AVD allocation failed");
return avd;
}
avd_t
avd_bool_alloc(boolean_t val)
{
avd_t avd;
avd = avd_alloc_cmn();
if (!avd)
return NULL;
avd->avd_type = AVD_VAL_BOOL;
avd->avd_val.boolval = val;
return avd;
}
avd_t
avd_int_alloc(uint64_t val)
{
avd_t avd;
avd = avd_alloc_cmn();
if (!avd)
return NULL;
avd->avd_type = AVD_VAL_INT;
avd->avd_val.intval = val;
return avd;
}
avd_t
avd_dbl_alloc(double val)
{
avd_t avd;
avd = avd_alloc_cmn();
if (!avd)
return NULL;
avd->avd_type = AVD_VAL_DBL;
avd->avd_val.dblval = val;
return avd;
}
avd_t
avd_str_alloc(char *string)
{
avd_t avd;
assert(string);
avd = avd_alloc_cmn();
if (!avd)
return NULL;
avd->avd_type = AVD_VAL_STR;
avd->avd_val.strval = ipc_stralloc(string);
return avd;
}
static var_t *
var_alloc(char *name)
{
var_t *var;
var = (var_t *)ipc_malloc(FILEBENCH_VARIABLE);
if (!var) {
filebench_log(LOG_ERROR, "Out of memory for variables");
return NULL;
}
memset(var, 0, sizeof(*var));
VAR_SET_UNKNOWN(var);
var->var_name = ipc_stralloc(name);
if (!var->var_name) {
filebench_log(LOG_ERROR, "Out of memory for strings");
return NULL;
}
var->var_next = filebench_shm->shm_var_list;
filebench_shm->shm_var_list = var;
return var;
}
static var_t *
var_find(char *name)
{
var_t *var;
for (var = filebench_shm->shm_var_list; var; var = var->var_next)
if (!strcmp(var->var_name, name))
return var;
return NULL;
}
static var_t *
var_find_alloc(char *name)
{
var_t *var;
var = var_find(name);
if (!var)
var = var_alloc(name);
return var;
}
int
var_assign_boolean(char *name, boolean_t bool)
{
var_t *var;
var = var_find_alloc(name);
if (!var) {
filebench_log(LOG_ERROR, "Could not assign variable %s", name);
return -1;
}
VAR_SET_BOOL(var, bool);
return 0;
}
int
var_assign_integer(char *name, uint64_t integer)
{
var_t *var;
var = var_find_alloc(name);
if (!var) {
filebench_log(LOG_ERROR, "Could not assign variable %s", name);
return -1;
}
VAR_SET_INT(var, integer);
return 0;
}
int
var_assign_double(char *name, double dbl)
{
var_t *var;
var = var_find_alloc(name);
if (!var) {
filebench_log(LOG_ERROR, "Could not assign variable %s", name);
return -1;
}
VAR_SET_DBL(var, dbl);
return 0;
}
int
var_assign_string(char *name, char *string)
{
var_t *var;
char *strptr;
var = var_find_alloc(name);
if (!var) {
filebench_log(LOG_ERROR, "Could not assign variable %s", name);
return -1;
}
strptr = ipc_stralloc(string);
if (!strptr) {
filebench_log(LOG_ERROR, "Could not assign variable %s", name);
return -1;
}
VAR_SET_STR(var, strptr);
return 0;
}
int
var_assign_random(char *name, randdist_t *rndp)
{
var_t *var;
var = var_find_alloc(name);
if (!var) {
filebench_log(LOG_ERROR, "Could not assign variable %s", name);
return -1;
}
VAR_SET_RANDOM(var, rndp);
return 0;
}
int
var_assign_custom(char *name, struct cvar *cvar)
{
var_t *var;
var = var_find_alloc(name);
if (!var) {
filebench_log(LOG_ERROR, "Could not assign variable %s", name);
return -1;
}
VAR_SET_CUSTOM(var, cvar);
return 0;
}
/*
* This function is called during the workload description parsing prior to the
* execution phase. It is called when parser encounters a variable used as a
* value (for attributes or command arguments, e.g., instances=$myinstances).
*
* At this point, the user might or might NOT have set the value (and consequently
* its type is not known as well).
*/
avd_t
avd_var_alloc(char *varname)
{
var_t *var;
avd_t avd;
var = var_find_alloc(varname);
if (!var) {
filebench_log(LOG_ERROR, "Could not access variable %s", varname);
filebench_shutdown(1);
}
avd = avd_alloc_cmn();
if (!avd)
return NULL;
set_avd_type_by_var(avd, var, 0);
return avd;
}
static char *
__var_to_string(var_t *var)
{
char tmp[128];
if (VAR_HAS_RANDOM(var)) {
switch (var->var_val.randptr->rnd_type & RAND_TYPE_MASK) {
case RAND_TYPE_UNIFORM:
return fb_stralloc("uniform random var");
case RAND_TYPE_GAMMA:
return fb_stralloc("gamma random var");
case RAND_TYPE_TABLE:
return fb_stralloc("tabular random var");
default:
return fb_stralloc("unitialized random var");
}
}
if (VAR_HAS_CUSTOM(var))
return fb_stralloc("custom variable");
if (VAR_HAS_STRING(var) && var->var_val.string)
return fb_stralloc(var->var_val.string);
if (VAR_HAS_BOOLEAN(var)) {
if (var->var_val.boolean)
return fb_stralloc("true");
else
return fb_stralloc("false");
}
if (VAR_HAS_INTEGER(var)) {
(void) snprintf(tmp, sizeof (tmp), "%llu",
(u_longlong_t)var->var_val.integer);
return fb_stralloc(tmp);
}
if (VAR_HAS_DOUBLE(var)) {
(void) snprintf(tmp, sizeof (tmp), "%lf",
var->var_val.dbl);
return fb_stralloc(tmp);
}
return fb_stralloc("No default");
}
char *
var_to_string(char *name)
{
var_t *var;
var = var_find(name);
if (!var)
return NULL;
return __var_to_string(var);
}
char *
var_randvar_to_string(char *name, int param_name)
{
var_t *var;
uint64_t value;
char tmp[128];
var = var_find(name);
if (!var)
return var_to_string(name);
if (!VAR_HAS_RANDOM(var))
return var_to_string(name);
switch (param_name) {
case RAND_PARAM_TYPE:
switch (var->var_val.randptr->rnd_type & RAND_TYPE_MASK) {
case RAND_TYPE_UNIFORM:
return fb_stralloc("uniform");
case RAND_TYPE_GAMMA:
return fb_stralloc("gamma");
case RAND_TYPE_TABLE:
return fb_stralloc("tabular");
default:
return fb_stralloc("uninitialized");
}
case RAND_PARAM_SRC:
if (var->var_val.randptr->rnd_type & RAND_SRC_GENERATOR)
return fb_stralloc("rand48");
else
return fb_stralloc("urandom");
case RAND_PARAM_SEED:
value = avd_get_int(var->var_val.randptr->rnd_seed);
break;
case RAND_PARAM_MIN:
value = avd_get_int(var->var_val.randptr->rnd_min);
break;
case RAND_PARAM_MEAN:
value = avd_get_int(var->var_val.randptr->rnd_mean);
break;
case RAND_PARAM_GAMMA:
value = avd_get_int(var->var_val.randptr->rnd_gamma);
break;
case RAND_PARAM_ROUND:
value = avd_get_int(var->var_val.randptr->rnd_round);
break;
default:
return NULL;
}
/* just an integer value if we got here */
(void) snprintf(tmp, sizeof (tmp), "%llu", (u_longlong_t)value);
return (fb_stralloc(tmp));
}
/* XXX: Local variables related */
static var_t *
var_find_list_only(char *name, var_t *var_list)
{
var_t *var;
for (var = var_list; var; var = var->var_next) {
if (!strcmp(var->var_name, name))
return var;
}
return NULL;
}
static var_t *
var_find_local_normal(char *name)
{
var_t *var;
var = var_find_list_only(name, filebench_shm->shm_var_loc_list);
if (!var)
var = var_find_list_only(name, filebench_shm->shm_var_list);
return var;
}
/*
* Copies the value stored in the source variable into the destination
* variable. Returns -1 if any problems encountered, 0 otherwise.
*/
static int
var_copy(var_t *dst_var, var_t *src_var) {
char *strptr;
if (VAR_HAS_BOOLEAN(src_var))
VAR_SET_BOOL(dst_var, src_var->var_val.boolean);
if (VAR_HAS_INTEGER(src_var))
VAR_SET_INT(dst_var, src_var->var_val.integer);
if (VAR_HAS_DOUBLE(src_var))
VAR_SET_DBL(dst_var, src_var->var_val.dbl);
if (VAR_HAS_STRING(src_var)) {
strptr = ipc_stralloc(src_var->var_val.string);
if (!strptr) {
filebench_log(LOG_ERROR,
"Cannot assign string for variable %s",
dst_var->var_name);
return -1;
}
VAR_SET_STR(dst_var, strptr);
}
return 0;
}
/*
* Allocates a local var (var_t) from interprocess shared memory after
* first adjusting the name to elminate the leading $.
*/
var_t *
var_lvar_alloc_local(char *name)
{
return var_alloc(name);
}
/*
* Allocates a local var and then extracts the var_string from
* the var named "string" and copies it into the var_string
* of the var "name", after first allocating a piece of
* interprocess shared string memory. Returns a pointer to the
* newly allocated local var or NULL on error.
*/
var_t *
var_lvar_assign_var(char *name, char *src_name)
{
var_t *dst_var, *src_var;
char *strptr;
src_name += 1;
src_var = var_find_local_normal(src_name);
if (!src_var) {
filebench_log(LOG_ERROR,
"Cannot find source variable %s", src_name);
return NULL;
}
dst_var = var_lvar_alloc_local(name);
if (!dst_var) {
filebench_log(LOG_ERROR, "Cannot assign variable %s", name);
return NULL;
}
if (VAR_HAS_BOOLEAN(src_var)) {
VAR_SET_BOOL(dst_var, src_var->var_val.boolean);
} else if (VAR_HAS_INTEGER(src_var)) {
VAR_SET_INT(dst_var, src_var->var_val.integer);
} else if (VAR_HAS_STRING(src_var)) {
strptr = ipc_stralloc(src_var->var_val.string);
if (!strptr) {
filebench_log(LOG_ERROR,
"Cannot assign variable %s", name);
return NULL;
}
VAR_SET_STR(dst_var, strptr);
} else if (VAR_HAS_DOUBLE(src_var)) {
VAR_SET_INT(dst_var, src_var->var_val.dbl);
} else if (VAR_HAS_RANDOM(src_var))
VAR_SET_RANDOM(dst_var, src_var->var_val.randptr);
return dst_var;
}
var_t *
var_lvar_assign_boolean(char *name, boolean_t bool)
{
var_t *var;
var = var_lvar_alloc_local(name);
if (!var) {
filebench_log(LOG_ERROR, "Cannot assign variable %s",
name);
return NULL;
}
VAR_SET_BOOL(var, bool);
return var;
}
var_t *
var_lvar_assign_integer(char *name, uint64_t integer)
{
var_t *var;
var = var_lvar_alloc_local(name);
if (!var) {
filebench_log(LOG_ERROR, "Cannot assign variable %s",
name);
return NULL;
}
VAR_SET_INT(var, integer);
return var;
}
var_t *
var_lvar_assign_double(char *name, double dbl)
{
var_t *var;
var = var_lvar_alloc_local(name);
if (!var) {
filebench_log(LOG_ERROR, "Cannot assign variable %s",
name);
return NULL;
}
VAR_SET_DBL(var, dbl);
return var;
}
var_t *
var_lvar_assign_string(char *name, char *string)
{
var_t *var;
char *strptr;
var = var_lvar_alloc_local(name);
if (!var) {
filebench_log(LOG_ERROR, "Cannot assign variable %s",
name);
return NULL;
}
strptr = ipc_stralloc(string);
if (!strptr) {
filebench_log(LOG_ERROR, "Cannot assign variable %s",
name);
return NULL;
}
VAR_SET_STR(var, strptr);
return var;
}
/*
* replace the avd_t attribute value descriptor in the new FLOW_MASTER flowop
* that points to a local variable with a new avd_t containing
* the actual value from the local variable.
*/
void
avd_update(avd_t *avdp, var_t *lvar_list)
{
/* Empty or not indirect, so no update needed */
return;
}
void
var_update_comp_lvars(var_t *newlvar, var_t *proto_comp_vars,
var_t *mstr_lvars)
{
var_t *proto_lvar;
/* find the prototype lvar from the inherited list */
proto_lvar = var_find_list_only(newlvar->var_name, proto_comp_vars);
if (!proto_lvar)
return;
/*
* if the new local variable has not already been assigned
* a value, try to copy a value from the prototype local variable
*/
if (VAR_HAS_UNKNOWN(newlvar)) {
/* copy value from prototype lvar to new lvar */
(void) var_copy(newlvar, proto_lvar);
}
}