blob: 52dc8689fcd4f7a9c0680c7bf023cb359c9121a2 [file] [log] [blame]
Allan MacKinnon4359d522018-06-19 13:57:04 -07001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can
5 * be found in the LICENSE file.
6 *
7 */
8
9#pragma once
10
11//
12//
13//
14
15#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))
16
17//
18//
19//
20
21#define MAX_MACRO(a,b) (((a) > (b)) ? (a) : (b))
22#define MIN_MACRO(a,b) (((a) < (b)) ? (a) : (b))
23#define GTE_MACRO(a,b) ((a) >= (b))
24#define LT_MACRO(a,b) ((a) < (b))
25
26//
27//
28//
29
30#define BITS_TO_MASK(n) (((uint32_t)1<<(n))-1)
31#define BITS_TO_MASK_64(n) (((uint64_t)1<<(n))-1)
32
33#define BITS_TO_MASK_AT(n,b) (BITS_TO_MASK(n)<<(b))
34#define BITS_TO_MASK_AT_64(n,b) (BITS_TO_MASK_64(n)<<(b))
35
36//
37//
38//
39
Mike Kleinf9ae6702018-06-20 14:05:05 -040040#if defined(_MSC_VER)
Allan MacKinnonc110e792018-06-21 09:09:56 -070041#define ALLOCA(n) _alloca(n)
Mike Kleinf9ae6702018-06-20 14:05:05 -040042#else
Allan MacKinnonc110e792018-06-21 09:09:56 -070043#define ALLOCA(n) alloca(n)
Mike Kleinf9ae6702018-06-20 14:05:05 -040044#endif
Allan MacKinnon4359d522018-06-19 13:57:04 -070045//
46//
47//