-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaux_.h
53 lines (40 loc) · 1.32 KB
/
aux_.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
/* Copyright 2011 ZAO "Begun".
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This library 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 Lesser General Public License for more
* details.
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
// $Id$
#ifndef LOCKFREE_AUX_H
#define LOCKFREE_AUX_H 1
#include <unistd.h>
#include <sys/mman.h>
namespace lockfree
{
static size_t const ptr_size = sizeof (void *);
template <typename T>
struct Linked
{
Linked () : next (NULL) {}
T *next;
};
struct Link : public Linked <Link> {};
//we have page size hardcoded; it is not quite correct, but still eases things
//TODO: would it be any slower with get_page_size ()?
size_t const base_page = 4 * 1024;
} //namespace lockfree
inline
size_t
align_up (size_t v, size_t alignment)
{
return (v + alignment - 1) / alignment * alignment;
}
namespace lf = lockfree;
#endif //LOCKFREE_AUX_H