-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshared_dlist.c
More file actions
51 lines (41 loc) · 1.39 KB
/
shared_dlist.c
File metadata and controls
51 lines (41 loc) · 1.39 KB
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
/*
* ---- The Unbalanced Tree Search (UTS) Benchmark ----
*
* Copyright (c) 2010 See AUTHORS file for copyright holders
*
* This file is part of the unbalanced tree search benchmark. This
* project is licensed under the MIT Open Source license. See the LICENSE
* file for copyright and licensing information.
*
* UTS is a collaborative project between researchers at the University of
* Maryland, the University of North Carolina at Chapel Hill, and the Ohio
* State University. See AUTHORS file for more information.
*
*/
#include <stdio.h>
#include "shared_dlist.h"
shr_dlist shr_dcons(shared void *element, shr_dlist prev, shr_dlist next) {
shr_dlist temp = upc_alloc(sizeof(struct shr_dcell));
temp -> element = element;
temp -> prev = prev;
temp -> next = next;
return temp;
}
shr_dlist shr_create_and_link(shared void *element, shr_dlist prev, shr_dlist next) {
shr_dlist temp = shr_dcons(element, prev, next);
prev -> next = temp;
next -> prev = temp;
return temp;
}
shared void* shr_unlink_and_free(shr_dlist l) {
shared void *temp;
if (l == NULL) return NULL;
temp = l -> element;
//printf("unlink_and_free(0x%0x-%d): Called by PE %d, work=0x%x-%d\n", upc_addrfield(l), upc_threadof(l), MYTHREAD,
// upc_addrfield(temp), upc_threadof(temp));
//fflush(NULL);
l -> next -> prev = l -> prev;
l -> prev -> next = l -> next;
upc_free(l);
return temp;
}