blob: cbdfcc66d7384f2f6428f019d3974cdd1b22b68c [file] [log] [blame]
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -07001/*
2 * Copyright (C) 2012 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 */
16
Shih-wei Liao21d28f52012-06-12 05:55:00 -070017#ifndef ART_SRC_GREENLAND_RUNTIME_UTILS_H_
18#define ART_SRC_GREENLAND_RUNTIME_UTILS_H_
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070019
Shih-wei Liao21d28f52012-06-12 05:55:00 -070020#include "asm_support.h"
21#include "thread.h"
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070022
23namespace art {
24namespace greenland {
25
Shih-wei Liao21d28f52012-06-12 05:55:00 -070026static inline Thread* art_get_current_thread() {
27#if defined(__i386__)
28 Thread* ptr;
29 __asm__ __volatile__("movl %%fs:(%1), %0"
30 : "=r"(ptr) // output
31 : "r"(THREAD_SELF_OFFSET) // input
32 :); // clobber
33 return ptr;
34#else
35 return Thread::Current();
36#endif
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070037}
38
39} // namespace greenland
40} // namespace art
Shih-wei Liao21d28f52012-06-12 05:55:00 -070041
42#endif // ART_SRC_GREENLAND_RUNTIME_UTILS_H_