Don't rely on gcc extensions

Make the code more compatible with different compilers.
clang doesn't allow extra static qualifiers on template
specializations, const qualifiers on function types,
or inline attributes on lambda functions, and is more
picky about casting away constness with reinterpret_cast.

These modifications are compatible with both gcc and
clang.

Change-Id: I739b10df2780bec537827a13679fd2bcc2cc7188
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h
index bfdbd74..a60446c 100644
--- a/runtime/entrypoints/entrypoint_utils.h
+++ b/runtime/entrypoints/entrypoint_utils.h
@@ -262,9 +262,9 @@
 // Explicit template declarations of FindFieldFromCode for all field access types.
 #define EXPLICIT_FIND_FIELD_FROM_CODE_TEMPLATE_DECL(_type, _access_check) \
 template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \
-static mirror::ArtField* FindFieldFromCode<_type, _access_check>(uint32_t field_idx, \
-                                                                 const mirror::ArtMethod* referrer, \
-                                                                 Thread* self, size_t expected_size) \
+mirror::ArtField* FindFieldFromCode<_type, _access_check>(uint32_t field_idx, \
+                                                          const mirror::ArtMethod* referrer, \
+                                                          Thread* self, size_t expected_size) \
 
 #define EXPLICIT_FIND_FIELD_FROM_CODE_TYPED_TEMPLATE_DECL(_type) \
     EXPLICIT_FIND_FIELD_FROM_CODE_TEMPLATE_DECL(_type, false); \
@@ -393,12 +393,12 @@
 }
 
 // Explicit template declarations of FindMethodFromCode for all invoke types.
-#define EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL(_type, _access_check)                        \
-  template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE                              \
-  static mirror::ArtMethod* FindMethodFromCode<_type, _access_check>(uint32_t method_idx,         \
-                                                                     mirror::Object* this_object, \
-                                                                     mirror::ArtMethod* referrer, \
-                                                                     Thread* self)
+#define EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL(_type, _access_check)                 \
+  template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE                       \
+  mirror::ArtMethod* FindMethodFromCode<_type, _access_check>(uint32_t method_idx,         \
+                                                              mirror::Object* this_object, \
+                                                              mirror::ArtMethod* referrer, \
+                                                              Thread* self)
 #define EXPLICIT_FIND_METHOD_FROM_CODE_TYPED_TEMPLATE_DECL(_type) \
     EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL(_type, false);   \
     EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL(_type, true)
diff --git a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc
index e2a0cc2..47ccbb1 100644
--- a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc
+++ b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc
@@ -22,8 +22,8 @@
 namespace art {
 
 template<InvokeType type, bool access_check>
-static mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, mirror::Object* this_object,
-                                           mirror::ArtMethod* caller_method, Thread* thread) {
+mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, mirror::Object* this_object,
+                                    mirror::ArtMethod* caller_method, Thread* thread) {
   mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method,
                                              access_check, type);
   if (UNLIKELY(method == NULL)) {
@@ -46,12 +46,12 @@
 }
 
 // Explicit template declarations of FindMethodHelper for all invoke types.
-#define EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL(_type, _access_check)                               \
-  template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)                                                \
-  static mirror::ArtMethod* FindMethodHelper<_type, _access_check>(uint32_t method_idx,               \
-                                                                   mirror::Object* this_object,       \
-                                                                   mirror::ArtMethod* caller_method,  \
-                                                                   Thread* thread)
+#define EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL(_type, _access_check)                        \
+  template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)                                         \
+  mirror::ArtMethod* FindMethodHelper<_type, _access_check>(uint32_t method_idx,               \
+                                                            mirror::Object* this_object,       \
+                                                            mirror::ArtMethod* caller_method,  \
+                                                            Thread* thread)
 #define EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL(_type) \
     EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL(_type, false);   \
     EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL(_type, true)
diff --git a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc
index b852a32..5a1b3e8 100644
--- a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc
@@ -142,9 +142,9 @@
 }
 
 template<InvokeType type, bool access_check>
-static uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object,
-                                mirror::ArtMethod* caller_method,
-                                Thread* self, mirror::ArtMethod** sp) {
+uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object,
+                         mirror::ArtMethod* caller_method,
+                         Thread* self, mirror::ArtMethod** sp) {
   mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method,
                                                   access_check, type);
   if (UNLIKELY(method == NULL)) {
@@ -174,12 +174,12 @@
 }
 
 // Explicit template declarations of artInvokeCommon for all invoke types.
-#define EXPLICIT_ART_INVOKE_COMMON_TEMPLATE_DECL(_type, _access_check)                        \
-  template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)                                        \
-  static uint64_t artInvokeCommon<_type, _access_check>(uint32_t method_idx,                  \
-                                                        mirror::Object* this_object,          \
-                                                        mirror::ArtMethod* caller_method,     \
-                                                        Thread* self, mirror::ArtMethod** sp)
+#define EXPLICIT_ART_INVOKE_COMMON_TEMPLATE_DECL(_type, _access_check)                 \
+  template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)                                 \
+  uint64_t artInvokeCommon<_type, _access_check>(uint32_t method_idx,                  \
+                                                 mirror::Object* this_object,          \
+                                                 mirror::ArtMethod* caller_method,     \
+                                                 Thread* self, mirror::ArtMethod** sp)
 
 #define EXPLICIT_ART_INVOKE_COMMON_TYPED_TEMPLATE_DECL(_type) \
     EXPLICIT_ART_INVOKE_COMMON_TEMPLATE_DECL(_type, false);   \