-
Notifications
You must be signed in to change notification settings - Fork 0
/
skiplist.h
98 lines (83 loc) · 2.77 KB
/
skiplist.h
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
/*
* File:
* skiplist.h
* Author(s):
* Vincent Gramoli <[email protected]>
* Description:
* Stress test of the skip list implementation.
*
* Copyright (c) 2009-2010.
*
* skiplist.h is part of Synchrobench
*
* Synchrobench is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <assert.h>
#include <getopt.h>
#include <limits.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <atomic_ops.h>
#include "atomic_ops_if.h"
#include "tm.h"
#include "ssalloc.h"
#define DEFAULT_DURATION 1000
#define DEFAULT_INITIAL 1024
#define DEFAULT_NB_THREADS 1
#define DEFAULT_RANGE (2 * DEFAULT_INITIAL)
#define DEFAULT_SEED 1
#define DEFAULT_UPDATE 20
#define DEFAULT_ELASTICITY 4
#define DEFAULT_ALTERNATE 0
#define DEFAULT_PQ 0
#define DEFAULT_SL 0
#define DEFAULT_ES 0
#define DEFAULT_LIN 0
#define DEFAULT_RSL 0
#define DEFAULT_EFFECTIVE 1
#define XSTR(s) STR(s)
#define STR(s) #s
extern uint8_t levelmax[64];
#define TRANSACTIONAL 4 // TODO: get rid of this
typedef unsigned long slkey_t;
typedef unsigned long val_t;
typedef intptr_t level_t;
#define KEY_MIN INT_MIN
#define KEY_MAX INT_MAX
#define DEFAULT_VAL 0
typedef ALIGNED(64) struct sl_node
{
slkey_t key;
val_t val;
int toplevel;
intptr_t deleted;
struct sl_node *next[19];
} sl_node_t;
typedef ALIGNED(64) struct sl_intset
{
sl_node_t *head;
} sl_intset_t;
int get_rand_level();
int floor_log_2(unsigned int n);
sl_node_t *sl_new_simple_node(slkey_t key, int toplevel, int transactional);
sl_node_t *sl_new_simple_node_val(slkey_t key, val_t val, int toplevel, int transactional);
sl_node_t *sl_new_node_val(slkey_t key, val_t val, sl_node_t *next, int toplevel, int transactional);
sl_node_t *sl_new_node(slkey_t key, sl_node_t *next, int toplevel, int transactional);
void sl_delete_node(sl_node_t *n);
sl_intset_t *sl_set_new();
void sl_set_delete(sl_intset_t *set);
int sl_set_size(sl_intset_t *set);
inline long rand_range(long r); /* declared in test.c */