| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * libjingle | 3 * libjingle |
| 4 * Copyright 2015 Google Inc. | 4 * Copyright 2015 Google Inc. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are met: | 7 * modification, are permitted provided that the following conditions are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright notice, | 9 * 1. Redistributions of source code must retain the above copyright notice, |
| 10 * this list of conditions and the following disclaimer. | 10 * this list of conditions and the following disclaimer. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 << "Failed to attach thread"; | 141 << "Failed to attach thread"; |
| 142 RTC_CHECK(env) << "AttachCurrentThread handed back NULL!"; | 142 RTC_CHECK(env) << "AttachCurrentThread handed back NULL!"; |
| 143 jni = reinterpret_cast<JNIEnv*>(env); | 143 jni = reinterpret_cast<JNIEnv*>(env); |
| 144 RTC_CHECK(!pthread_setspecific(g_jni_ptr, jni)) << "pthread_setspecific"; | 144 RTC_CHECK(!pthread_setspecific(g_jni_ptr, jni)) << "pthread_setspecific"; |
| 145 return jni; | 145 return jni; |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Return a |jlong| that will correctly convert back to |ptr|. This is needed | 148 // Return a |jlong| that will correctly convert back to |ptr|. This is needed |
| 149 // because the alternative (of silently passing a 32-bit pointer to a vararg | 149 // because the alternative (of silently passing a 32-bit pointer to a vararg |
| 150 // function expecting a 64-bit param) picks up garbage in the high 32 bits. | 150 // function expecting a 64-bit param) picks up garbage in the high 32 bits. |
| 151 jlong jlongFromPointer(void* ptr) { | 151 jlong jlongFromPointer(const void* ptr) { |
| 152 static_assert(sizeof(intptr_t) <= sizeof(jlong), | 152 static_assert(sizeof(intptr_t) <= sizeof(jlong), |
| 153 "Time to rethink the use of jlongs"); | 153 "Time to rethink the use of jlongs"); |
| 154 // Going through intptr_t to be obvious about the definedness of the | 154 // Going through intptr_t to be obvious about the definedness of the |
| 155 // conversion from pointer to integral type. intptr_t to jlong is a standard | 155 // conversion from pointer to integral type. intptr_t to jlong is a standard |
| 156 // widening by the static_assert above. | 156 // widening by the static_assert above. |
| 157 jlong ret = reinterpret_cast<intptr_t>(ptr); | 157 jlong ret = reinterpret_cast<intptr_t>(ptr); |
| 158 RTC_DCHECK(reinterpret_cast<void*>(ret) == ptr); | 158 RTC_DCHECK(reinterpret_cast<void*>(ret) == ptr); |
| 159 return ret; | 159 return ret; |
| 160 } | 160 } |
| 161 | 161 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // callbacks (i.e. entry points that don't originate in a Java callstack | 279 // callbacks (i.e. entry points that don't originate in a Java callstack |
| 280 // through a "native" method call). | 280 // through a "native" method call). |
| 281 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) { | 281 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) { |
| 282 RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame"; | 282 RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame"; |
| 283 } | 283 } |
| 284 ScopedLocalRefFrame::~ScopedLocalRefFrame() { | 284 ScopedLocalRefFrame::~ScopedLocalRefFrame() { |
| 285 jni_->PopLocalFrame(NULL); | 285 jni_->PopLocalFrame(NULL); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace webrtc_jni | 288 } // namespace webrtc_jni |
| OLD | NEW |