Add mi_thunk support for vcalls on hppa.
[official-gcc.git] / libvtv / testsuite / libvtv.cc / register_set_pair.cc
blobb7f08331d68bda71eb6549dedbb2ac81b0ddfa2c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <stdint.h>
4 #include <string.h>
6 #include "vtv_utils.h"
7 #include "vtv_rts.h"
9 /* This configuration will test mostly inserting of elements that are already inserted since
10 the number of repeats is 200 */
12 #define NUM_MAPS 4000
13 #define ELEMENTS_PER_MAP 100
14 #define NUM_REPEATS 200
16 #define KEY_TYPE_FIXED_SIZE 8
17 void *key_buffer = malloc (17);
18 typedef char * name_string;
19 name_string fake_names[NUM_MAPS];
21 /* This variable has to be put in rel.ro */
22 void * maps[NUM_MAPS] VTV_PROTECTED_VAR;
24 struct fake_vt {
25 void * fake_vfp [4];
27 void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP];
29 void
30 generate_names (void)
32 int i;
34 for (i = 0; i < NUM_MAPS; ++i)
36 fake_names[i] = (char *) malloc (9 * sizeof (char));
37 snprintf (fake_names[i], 9, "name%d", i);
41 static uint32_t
42 vtv_string_hash(const char *in)
44 const char *s = in;
45 uint32_t h = 0;
47 for ( ; *s; ++s)
48 h = 5 * h + *s;
49 return h;
52 int main()
54 __VLTChangePermission(__VLTP_READ_WRITE);
56 generate_names ();
58 for (int k = 0; k < NUM_REPEATS; k++)
60 int curr_fake_vt = 0;
61 for (int i = 0; i < NUM_MAPS; i++)
63 uint32_t *value_ptr = (uint32_t *) key_buffer;
64 uint32_t len1 = strlen (fake_names[i]);
65 uint32_t hash_value = vtv_string_hash (fake_names[i]);
66 void *temp_array[ELEMENTS_PER_MAP];
68 *value_ptr = len1;
69 value_ptr++;
70 *value_ptr = hash_value;
72 memcpy ((char *) key_buffer + KEY_TYPE_FIXED_SIZE, fake_names[i],
73 len1);
76 #ifdef VTV_DEBUG
77 __VLTRegisterPairDebug (&maps[i], (char *) key_buffer, 128,
78 &fake_vts[curr_fake_vt], "", "");
79 #else
80 __VLTRegisterPair (&maps[i], (char *) key_buffer, 128,
81 &fake_vts[curr_fake_vt]);
82 #endif
83 for (int j = 0; j < ELEMENTS_PER_MAP; j++)
85 temp_array[j] = &fake_vts[curr_fake_vt];
86 curr_fake_vt++;
88 #ifdef VTV_DEBUG
89 __VLTRegisterSetDebug (&maps[i], (char *) key_buffer, 128, 100,
90 (void **) &temp_array);
91 #else
92 __VLTRegisterSet (&maps[i], (char *) key_buffer, 128, 100,
93 (void **) &temp_array);
94 #endif
98 __VLTChangePermission(__VLTP_READ_ONLY);
100 return 0;