-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunc_swap.c
73 lines (62 loc) · 837 Bytes
/
func_swap.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
/**
* func_swap.c
* Copyright (C) 2012 Jan Viktorin
*/
#include "func.h"
#include "rndgen.h"
#include <stdlib.h>
#include <math.h>
/**
* Available functions.
*/
enum func_enum_t {
F_CMP_SWAP
};
size_t func_inputs_max(void)
{
return 2;
}
size_t func_outputs_max(void)
{
return 2;
}
size_t func_inputs(func_t f)
{
return 2;
}
size_t func_outputs(func_t f)
{
return 2;
}
size_t func_count(void)
{
return 1;
}
const char *func_to_str(func_t f)
{
switch((enum func_enum_t) f) {
case F_CMP_SWAP:
return "C&S";
default:
return "<?>";
}
}
void func_gen(func_t *f)
{
*f = 0;
}
void func_mut(func_t *f)
{
func_gen(f);
}
void func_eval64(func_t f, uint64_t *op, uint64_t *dst)
{
switch((enum func_enum_t) f) {
case F_CMP_SWAP:
dst[0] = op[0] & op[1];
dst[1] = op[0] | op[1];
break;
default:
abort();
}
}