Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 1 | /* |
| 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 Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 17 | #ifndef ART_SRC_GREENLAND_RUNTIME_UTILS_H_ |
| 18 | #define ART_SRC_GREENLAND_RUNTIME_UTILS_H_ |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 19 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 20 | #include "asm_support.h" |
| 21 | #include "thread.h" |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 22 | |
| 23 | namespace art { |
| 24 | namespace greenland { |
| 25 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 26 | static 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 Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | } // namespace greenland |
| 40 | } // namespace art |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 41 | |
| 42 | #endif // ART_SRC_GREENLAND_RUNTIME_UTILS_H_ |