blob: 2fb0225f38431f9161029d07db1901ec16dad796 [file] [log] [blame]
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_GLOBALS_H_
4#define ART_SRC_GLOBALS_H_
5
Carl Shapiro1fb86202011-06-27 17:43:13 -07006#include <stddef.h>
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -07007#include <stdint.h>
8
Carl Shapiro6b6b5f02011-06-21 15:05:09 -07009namespace art {
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070010
11typedef uint8_t byte;
12typedef intptr_t word;
13typedef uintptr_t uword;
14
Carl Shapiro69759ea2011-07-21 18:13:35 -070015const size_t KB = 1024;
16const size_t MB = KB * KB;
17const size_t GB = KB * KB * KB;
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070018const int kMaxInt = 0x7FFFFFFF;
19const int kMinInt = -kMaxInt - 1;
20
21const int kCharSize = sizeof(char);
22const int kShortSize = sizeof(short);
23const int kIntSize = sizeof(int);
24const int kDoubleSize = sizeof(double);
25const int kIntptrSize = sizeof(intptr_t);
26const int kWordSize = sizeof(word);
27const int kPointerSize = sizeof(void*);
28
29const int kBitsPerByte = 8;
30const int kBitsPerByteLog2 = 3;
31const int kBitsPerPointer = kPointerSize * kBitsPerByte;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070032const int kBitsPerWord = kWordSize * kBitsPerByte;
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070033const int kBitsPerInt = kIntSize * kBitsPerByte;
34
Ian Rogers0d666d82011-08-14 16:03:46 -070035// Required stack alignment
36const int kStackAlignment = 16;
Brian Carlstrom0024d6c2011-08-09 08:26:12 -070037
Ian Rogers408f79a2011-08-23 18:22:33 -070038// Required object alignment
39const int kObjectAlignment = 8;
40
Brian Carlstrom0024d6c2011-08-09 08:26:12 -070041// System page size. Normally you're expected to get this from
42// sysconf(_SC_PAGESIZE) or some system-specific define (usually
43// PAGESIZE or PAGE_SIZE). If we use a simple compile-time constant
44// the compiler can generate appropriate masks directly, so we define
45// it here and verify it as the runtime is starting up.
46//
47// Must be a power of 2.
Brian Carlstromb0460ea2011-07-29 10:08:05 -070048const int kPageSize = 4096;
49
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070050} // namespace art
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070051
52#endif // ART_SRC_GLOBALS_H_