aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compute/common/macros.h
blob: 52dc8689fcd4f7a9c0680c7bf023cb359c9121a2 (plain)
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
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can
 * be found in the LICENSE file.
 *
 */

#pragma once

//
//
//

#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))

//
//
//

#define MAX_MACRO(a,b)  (((a) > (b)) ? (a) : (b))
#define MIN_MACRO(a,b)  (((a) < (b)) ? (a) : (b))
#define GTE_MACRO(a,b)  ((a) >= (b))
#define LT_MACRO(a,b)   ((a) <  (b))

//
//
//

#define BITS_TO_MASK(n)         (((uint32_t)1<<(n))-1)
#define BITS_TO_MASK_64(n)      (((uint64_t)1<<(n))-1)

#define BITS_TO_MASK_AT(n,b)    (BITS_TO_MASK(n)<<(b))
#define BITS_TO_MASK_AT_64(n,b) (BITS_TO_MASK_64(n)<<(b))

//
//
//

#if defined(_MSC_VER)
#define ALLOCA(n)  _alloca(n)
#else
#define ALLOCA(n) alloca(n)
#endif
//
//
//