Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #ifndef ART_SRC_GLOBALS_H_ |
| 4 | #define ART_SRC_GLOBALS_H_ |
| 5 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 6 | #include <stddef.h> |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 9 | namespace art { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 10 | |
| 11 | typedef uint8_t byte; |
| 12 | typedef intptr_t word; |
| 13 | typedef uintptr_t uword; |
| 14 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 15 | const size_t KB = 1024; |
| 16 | const size_t MB = KB * KB; |
| 17 | const size_t GB = KB * KB * KB; |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 18 | const int kMaxInt = 0x7FFFFFFF; |
| 19 | const int kMinInt = -kMaxInt - 1; |
| 20 | |
| 21 | const int kCharSize = sizeof(char); |
| 22 | const int kShortSize = sizeof(short); |
| 23 | const int kIntSize = sizeof(int); |
| 24 | const int kDoubleSize = sizeof(double); |
| 25 | const int kIntptrSize = sizeof(intptr_t); |
| 26 | const int kWordSize = sizeof(word); |
| 27 | const int kPointerSize = sizeof(void*); |
| 28 | |
| 29 | const int kBitsPerByte = 8; |
| 30 | const int kBitsPerByteLog2 = 3; |
| 31 | const int kBitsPerPointer = kPointerSize * kBitsPerByte; |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 32 | const int kBitsPerWord = kWordSize * kBitsPerByte; |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 33 | const int kBitsPerInt = kIntSize * kBitsPerByte; |
| 34 | |
Ian Rogers | 0d666d8 | 2011-08-14 16:03:46 -0700 | [diff] [blame^] | 35 | // Required stack alignment |
| 36 | const int kStackAlignment = 16; |
Brian Carlstrom | 0024d6c | 2011-08-09 08:26:12 -0700 | [diff] [blame] | 37 | |
| 38 | // System page size. Normally you're expected to get this from |
| 39 | // sysconf(_SC_PAGESIZE) or some system-specific define (usually |
| 40 | // PAGESIZE or PAGE_SIZE). If we use a simple compile-time constant |
| 41 | // the compiler can generate appropriate masks directly, so we define |
| 42 | // it here and verify it as the runtime is starting up. |
| 43 | // |
| 44 | // Must be a power of 2. |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 45 | const int kPageSize = 4096; |
| 46 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 47 | } // namespace art |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 48 | |
| 49 | #endif // ART_SRC_GLOBALS_H_ |