blob: 0cf42608e046768a3c1bda6f8dd098f766e8d06d [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070016
17#ifndef ART_SRC_GLOBALS_H_
18#define ART_SRC_GLOBALS_H_
19
Carl Shapiro1fb86202011-06-27 17:43:13 -070020#include <stddef.h>
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070021#include <stdint.h>
22
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070023namespace art {
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070024
25typedef uint8_t byte;
26typedef intptr_t word;
27typedef uintptr_t uword;
28
Carl Shapiro69759ea2011-07-21 18:13:35 -070029const size_t KB = 1024;
30const size_t MB = KB * KB;
31const size_t GB = KB * KB * KB;
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070032
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070033const int kWordSize = sizeof(word);
34const int kPointerSize = sizeof(void*);
35
36const int kBitsPerByte = 8;
37const int kBitsPerByteLog2 = 3;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070038const int kBitsPerWord = kWordSize * kBitsPerByte;
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070039
Ian Rogers0d666d82011-08-14 16:03:46 -070040// Required stack alignment
41const int kStackAlignment = 16;
Brian Carlstrom0024d6c2011-08-09 08:26:12 -070042
Ian Rogers408f79a2011-08-23 18:22:33 -070043// Required object alignment
44const int kObjectAlignment = 8;
45
Brian Carlstrome24fa612011-09-29 00:53:55 -070046// Required ARM instruction alignment
47const int kArmAlignment = 4;
48
Ian Rogersb41b33b2012-03-20 14:22:54 -070049// Required X86 instruction alignment
50const int kX86Alignment = 16;
51
Brian Carlstrom0024d6c2011-08-09 08:26:12 -070052// System page size. Normally you're expected to get this from
53// sysconf(_SC_PAGESIZE) or some system-specific define (usually
54// PAGESIZE or PAGE_SIZE). If we use a simple compile-time constant
55// the compiler can generate appropriate masks directly, so we define
56// it here and verify it as the runtime is starting up.
57//
58// Must be a power of 2.
Brian Carlstromb0460ea2011-07-29 10:08:05 -070059const int kPageSize = 4096;
60
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070061} // namespace art
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070062
63#endif // ART_SRC_GLOBALS_H_