blob: c37343ce747cf04463873c55234180ccd084daa0 [file] [log] [blame]
Elliott Hughes11e45072011-08-16 17:40:46 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2// Author: enh@google.com (Elliott Hughes)
3
Elliott Hughes42ee1422011-09-06 12:33:32 -07004#include "utils.h"
5
Elliott Hughes92b3b562011-09-08 16:32:26 -07006#include <pthread.h>
Brian Carlstroma9f19782011-10-13 00:14:47 -07007#include <sys/stat.h>
Elliott Hughes42ee1422011-09-06 12:33:32 -07008#include <sys/syscall.h>
9#include <sys/types.h>
10#include <unistd.h>
11
Elliott Hughes90a33692011-08-30 13:27:07 -070012#include "UniquePtr.h"
Ian Rogersd81871c2011-10-03 13:57:23 -070013#include "class_loader.h"
buzbeec143c552011-08-20 17:38:58 -070014#include "file.h"
Elliott Hughes11e45072011-08-16 17:40:46 -070015#include "object.h"
buzbeec143c552011-08-20 17:38:58 -070016#include "os.h"
Elliott Hughes11e45072011-08-16 17:40:46 -070017
Elliott Hughesdcc24742011-09-07 14:02:44 -070018#if defined(HAVE_PRCTL)
19#include <sys/prctl.h>
20#endif
21
Elliott Hughes11e45072011-08-16 17:40:46 -070022namespace art {
23
Elliott Hughesd92bec42011-09-02 17:04:36 -070024bool ReadFileToString(const std::string& file_name, std::string* result) {
25 UniquePtr<File> file(OS::OpenFile(file_name.c_str(), false));
26 if (file.get() == NULL) {
27 return false;
28 }
buzbeec143c552011-08-20 17:38:58 -070029
Elliott Hughes3b6baaa2011-10-14 19:13:56 -070030 std::vector<char> buf(8 * KB);
buzbeec143c552011-08-20 17:38:58 -070031 while (true) {
Elliott Hughes3b6baaa2011-10-14 19:13:56 -070032 int64_t n = file->Read(&buf[0], buf.size());
Elliott Hughesd92bec42011-09-02 17:04:36 -070033 if (n == -1) {
34 return false;
buzbeec143c552011-08-20 17:38:58 -070035 }
Elliott Hughesd92bec42011-09-02 17:04:36 -070036 if (n == 0) {
37 return true;
38 }
Elliott Hughes3b6baaa2011-10-14 19:13:56 -070039 result->append(&buf[0], n);
buzbeec143c552011-08-20 17:38:58 -070040 }
buzbeec143c552011-08-20 17:38:58 -070041}
42
Elliott Hughese27955c2011-08-26 15:21:24 -070043std::string GetIsoDate() {
44 time_t now = time(NULL);
45 struct tm tmbuf;
46 struct tm* ptm = localtime_r(&now, &tmbuf);
47 return StringPrintf("%04d-%02d-%02d %02d:%02d:%02d",
48 ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday,
49 ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
50}
51
Elliott Hughes7162ad92011-10-27 14:08:42 -070052uint64_t MilliTime() {
53 struct timespec now;
54 clock_gettime(CLOCK_MONOTONIC, &now);
55 return static_cast<uint64_t>(now.tv_sec) * 1000LL + now.tv_nsec / 1000000LL;
56}
57
Elliott Hughes83df2ac2011-10-11 16:37:54 -070058uint64_t NanoTime() {
59 struct timespec now;
60 clock_gettime(CLOCK_MONOTONIC, &now);
61 return static_cast<uint64_t>(now.tv_sec) * 1000000000LL + now.tv_nsec;
62}
63
Elliott Hughes5174fe62011-08-23 15:12:35 -070064std::string PrettyDescriptor(const String* java_descriptor) {
Brian Carlstrome24fa612011-09-29 00:53:55 -070065 if (java_descriptor == NULL) {
66 return "null";
67 }
Elliott Hughes6c8867d2011-10-03 16:34:05 -070068 return PrettyDescriptor(java_descriptor->ToModifiedUtf8());
69}
Elliott Hughes5174fe62011-08-23 15:12:35 -070070
Elliott Hughes6c8867d2011-10-03 16:34:05 -070071std::string PrettyDescriptor(const std::string& descriptor) {
Elliott Hughes11e45072011-08-16 17:40:46 -070072 // Count the number of '['s to get the dimensionality.
Elliott Hughes5174fe62011-08-23 15:12:35 -070073 const char* c = descriptor.c_str();
Elliott Hughes11e45072011-08-16 17:40:46 -070074 size_t dim = 0;
75 while (*c == '[') {
76 dim++;
77 c++;
78 }
79
80 // Reference or primitive?
81 if (*c == 'L') {
82 // "[[La/b/C;" -> "a.b.C[][]".
83 c++; // Skip the 'L'.
84 } else {
85 // "[[B" -> "byte[][]".
86 // To make life easier, we make primitives look like unqualified
87 // reference types.
88 switch (*c) {
89 case 'B': c = "byte;"; break;
90 case 'C': c = "char;"; break;
91 case 'D': c = "double;"; break;
92 case 'F': c = "float;"; break;
93 case 'I': c = "int;"; break;
94 case 'J': c = "long;"; break;
95 case 'S': c = "short;"; break;
96 case 'Z': c = "boolean;"; break;
Elliott Hughes5174fe62011-08-23 15:12:35 -070097 default: return descriptor;
Elliott Hughes11e45072011-08-16 17:40:46 -070098 }
99 }
100
101 // At this point, 'c' is a string of the form "fully/qualified/Type;"
102 // or "primitive;". Rewrite the type with '.' instead of '/':
103 std::string result;
104 const char* p = c;
105 while (*p != ';') {
106 char ch = *p++;
107 if (ch == '/') {
108 ch = '.';
109 }
110 result.push_back(ch);
111 }
112 // ...and replace the semicolon with 'dim' "[]" pairs:
113 while (dim--) {
114 result += "[]";
115 }
116 return result;
117}
118
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700119std::string PrettyDescriptor(Primitive::Type type) {
120 char descriptor_char = Primitive::DescriptorChar(type);
121 std::string descriptor_string(1, descriptor_char);
122 return PrettyDescriptor(descriptor_string);
123}
124
Elliott Hughes54e7df12011-09-16 11:47:04 -0700125std::string PrettyField(const Field* f, bool with_type) {
Elliott Hughesa2501992011-08-26 19:39:54 -0700126 if (f == NULL) {
127 return "null";
128 }
Elliott Hughes54e7df12011-09-16 11:47:04 -0700129 std::string result;
130 if (with_type) {
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700131 result += PrettyDescriptor(f->GetTypeDescriptor());
Elliott Hughes54e7df12011-09-16 11:47:04 -0700132 result += ' ';
133 }
134 result += PrettyDescriptor(f->GetDeclaringClass()->GetDescriptor());
Elliott Hughesa2501992011-08-26 19:39:54 -0700135 result += '.';
136 result += f->GetName()->ToModifiedUtf8();
137 return result;
138}
139
Elliott Hughesa0b8feb2011-08-20 09:50:55 -0700140std::string PrettyMethod(const Method* m, bool with_signature) {
141 if (m == NULL) {
142 return "null";
143 }
144 Class* c = m->GetDeclaringClass();
Elliott Hughes5174fe62011-08-23 15:12:35 -0700145 std::string result(PrettyDescriptor(c->GetDescriptor()));
Elliott Hughesa0b8feb2011-08-20 09:50:55 -0700146 result += '.';
147 result += m->GetName()->ToModifiedUtf8();
148 if (with_signature) {
149 // TODO: iterate over the signature's elements and pass them all to
150 // PrettyDescriptor? We'd need to pull out the return type specially, too.
151 result += m->GetSignature()->ToModifiedUtf8();
152 }
153 return result;
154}
155
Elliott Hughes54e7df12011-09-16 11:47:04 -0700156std::string PrettyTypeOf(const Object* obj) {
Elliott Hughes11e45072011-08-16 17:40:46 -0700157 if (obj == NULL) {
158 return "null";
159 }
160 if (obj->GetClass() == NULL) {
161 return "(raw)";
162 }
Elliott Hughes5174fe62011-08-23 15:12:35 -0700163 std::string result(PrettyDescriptor(obj->GetClass()->GetDescriptor()));
Elliott Hughes11e45072011-08-16 17:40:46 -0700164 if (obj->IsClass()) {
Elliott Hughes5174fe62011-08-23 15:12:35 -0700165 result += "<" + PrettyDescriptor(obj->AsClass()->GetDescriptor()) + ">";
Elliott Hughes11e45072011-08-16 17:40:46 -0700166 }
167 return result;
168}
169
Elliott Hughes54e7df12011-09-16 11:47:04 -0700170std::string PrettyClass(const Class* c) {
171 if (c == NULL) {
172 return "null";
173 }
174 std::string result;
175 result += "java.lang.Class<";
176 result += PrettyDescriptor(c->GetDescriptor());
177 result += ">";
178 return result;
179}
180
Ian Rogersd81871c2011-10-03 13:57:23 -0700181std::string PrettyClassAndClassLoader(const Class* c) {
182 if (c == NULL) {
183 return "null";
184 }
185 std::string result;
186 result += "java.lang.Class<";
187 result += PrettyDescriptor(c->GetDescriptor());
188 result += ",";
189 result += PrettyTypeOf(c->GetClassLoader());
190 // TODO: add an identifying hash value for the loader
191 result += ">";
192 return result;
193}
194
Elliott Hughes79082e32011-08-25 12:07:32 -0700195std::string MangleForJni(const std::string& s) {
196 std::string result;
197 size_t char_count = CountModifiedUtf8Chars(s.c_str());
198 const char* cp = &s[0];
199 for (size_t i = 0; i < char_count; ++i) {
200 uint16_t ch = GetUtf16FromUtf8(&cp);
201 if (ch == '$' || ch > 127) {
202 StringAppendF(&result, "_0%04x", ch);
203 } else {
204 switch (ch) {
205 case '_':
206 result += "_1";
207 break;
208 case ';':
209 result += "_2";
210 break;
211 case '[':
212 result += "_3";
213 break;
214 case '/':
215 result += "_";
216 break;
217 default:
218 result.push_back(ch);
219 break;
220 }
221 }
222 }
223 return result;
224}
225
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700226std::string DotToDescriptor(const char* class_name) {
227 std::string descriptor(class_name);
228 std::replace(descriptor.begin(), descriptor.end(), '.', '/');
229 if (descriptor.length() > 0 && descriptor[0] != '[') {
230 descriptor = "L" + descriptor + ";";
231 }
232 return descriptor;
233}
234
Brian Carlstromaded5f72011-10-07 17:15:04 -0700235std::string DescriptorToDot(const std::string& descriptor) {
236 DCHECK_EQ(descriptor[0], 'L');
237 DCHECK_EQ(descriptor[descriptor.size()-1], ';');
238 std::string dot = descriptor.substr(1, descriptor.size()-2);
239 std::replace(dot.begin(), dot.end(), '/', '.');
240 return dot;
241}
242
Elliott Hughes79082e32011-08-25 12:07:32 -0700243std::string JniShortName(const Method* m) {
244 Class* declaring_class = m->GetDeclaringClass();
245
246 std::string class_name(declaring_class->GetDescriptor()->ToModifiedUtf8());
247 // Remove the leading 'L' and trailing ';'...
Elliott Hughesf5a7a472011-10-07 14:31:02 -0700248 CHECK_EQ(class_name[0], 'L') << class_name;
249 CHECK_EQ(class_name[class_name.size() - 1], ';') << class_name;
Elliott Hughes79082e32011-08-25 12:07:32 -0700250 class_name.erase(0, 1);
251 class_name.erase(class_name.size() - 1, 1);
252
253 std::string method_name(m->GetName()->ToModifiedUtf8());
254
255 std::string short_name;
256 short_name += "Java_";
257 short_name += MangleForJni(class_name);
258 short_name += "_";
259 short_name += MangleForJni(method_name);
260 return short_name;
261}
262
263std::string JniLongName(const Method* m) {
264 std::string long_name;
265 long_name += JniShortName(m);
266 long_name += "__";
267
268 std::string signature(m->GetSignature()->ToModifiedUtf8());
269 signature.erase(0, 1);
270 signature.erase(signature.begin() + signature.find(')'), signature.end());
271
272 long_name += MangleForJni(signature);
273
274 return long_name;
275}
276
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700277// Helper for IsValidMemberNameUtf8(), a bit vector indicating valid low ascii.
278uint32_t DEX_MEMBER_VALID_LOW_ASCII[4] = {
279 0x00000000, // 00..1f low control characters; nothing valid
280 0x03ff2010, // 20..3f digits and symbols; valid: '0'..'9', '$', '-'
281 0x87fffffe, // 40..5f uppercase etc.; valid: 'A'..'Z', '_'
282 0x07fffffe // 60..7f lowercase etc.; valid: 'a'..'z'
283};
284
285// Helper for IsValidMemberNameUtf8(); do not call directly.
286bool IsValidMemberNameUtf8Slow(const char** pUtf8Ptr) {
287 /*
288 * It's a multibyte encoded character. Decode it and analyze. We
289 * accept anything that isn't (a) an improperly encoded low value,
290 * (b) an improper surrogate pair, (c) an encoded '\0', (d) a high
291 * control character, or (e) a high space, layout, or special
292 * character (U+00a0, U+2000..U+200f, U+2028..U+202f,
293 * U+fff0..U+ffff). This is all specified in the dex format
294 * document.
295 */
296
297 uint16_t utf16 = GetUtf16FromUtf8(pUtf8Ptr);
298
299 // Perform follow-up tests based on the high 8 bits.
300 switch (utf16 >> 8) {
301 case 0x00:
302 // It's only valid if it's above the ISO-8859-1 high space (0xa0).
303 return (utf16 > 0x00a0);
304 case 0xd8:
305 case 0xd9:
306 case 0xda:
307 case 0xdb:
308 // It's a leading surrogate. Check to see that a trailing
309 // surrogate follows.
310 utf16 = GetUtf16FromUtf8(pUtf8Ptr);
311 return (utf16 >= 0xdc00) && (utf16 <= 0xdfff);
312 case 0xdc:
313 case 0xdd:
314 case 0xde:
315 case 0xdf:
316 // It's a trailing surrogate, which is not valid at this point.
317 return false;
318 case 0x20:
319 case 0xff:
320 // It's in the range that has spaces, controls, and specials.
321 switch (utf16 & 0xfff8) {
322 case 0x2000:
323 case 0x2008:
324 case 0x2028:
325 case 0xfff0:
326 case 0xfff8:
327 return false;
328 }
329 break;
330 }
331 return true;
332}
333
334/* Return whether the pointed-at modified-UTF-8 encoded character is
335 * valid as part of a member name, updating the pointer to point past
336 * the consumed character. This will consume two encoded UTF-16 code
337 * points if the character is encoded as a surrogate pair. Also, if
338 * this function returns false, then the given pointer may only have
339 * been partially advanced.
340 */
341bool IsValidMemberNameUtf8(const char** pUtf8Ptr) {
342 uint8_t c = (uint8_t) **pUtf8Ptr;
343 if (c <= 0x7f) {
344 // It's low-ascii, so check the table.
345 uint32_t wordIdx = c >> 5;
346 uint32_t bitIdx = c & 0x1f;
347 (*pUtf8Ptr)++;
348 return (DEX_MEMBER_VALID_LOW_ASCII[wordIdx] & (1 << bitIdx)) != 0;
349 }
350
351 // It's a multibyte encoded character. Call a non-inline function
352 // for the heavy lifting.
353 return IsValidMemberNameUtf8Slow(pUtf8Ptr);
354}
355
Elliott Hughes906e6852011-10-28 14:52:10 -0700356enum ClassNameType { kName, kDescriptor };
357bool IsValidClassName(const char* s, ClassNameType type, char separator) {
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700358 int arrayCount = 0;
359 while (*s == '[') {
360 arrayCount++;
361 s++;
362 }
363
364 if (arrayCount > 255) {
365 // Arrays may have no more than 255 dimensions.
366 return false;
367 }
368
369 if (arrayCount != 0) {
370 /*
371 * If we're looking at an array of some sort, then it doesn't
372 * matter if what is being asked for is a class name; the
373 * format looks the same as a type descriptor in that case, so
374 * treat it as such.
375 */
Elliott Hughes906e6852011-10-28 14:52:10 -0700376 type = kDescriptor;
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700377 }
378
Elliott Hughes906e6852011-10-28 14:52:10 -0700379 if (type == kDescriptor) {
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700380 /*
381 * We are looking for a descriptor. Either validate it as a
382 * single-character primitive type, or continue on to check the
383 * embedded class name (bracketed by "L" and ";").
384 */
385 switch (*(s++)) {
386 case 'B':
387 case 'C':
388 case 'D':
389 case 'F':
390 case 'I':
391 case 'J':
392 case 'S':
393 case 'Z':
394 // These are all single-character descriptors for primitive types.
395 return (*s == '\0');
396 case 'V':
397 // Non-array void is valid, but you can't have an array of void.
398 return (arrayCount == 0) && (*s == '\0');
399 case 'L':
400 // Class name: Break out and continue below.
401 break;
402 default:
403 // Oddball descriptor character.
404 return false;
405 }
406 }
407
408 /*
409 * We just consumed the 'L' that introduces a class name as part
410 * of a type descriptor, or we are looking for an unadorned class
411 * name.
412 */
413
414 bool sepOrFirst = true; // first character or just encountered a separator.
415 for (;;) {
416 uint8_t c = (uint8_t) *s;
417 switch (c) {
418 case '\0':
419 /*
420 * Premature end for a type descriptor, but valid for
421 * a class name as long as we haven't encountered an
422 * empty component (including the degenerate case of
423 * the empty string "").
424 */
Elliott Hughes906e6852011-10-28 14:52:10 -0700425 return (type == kName) && !sepOrFirst;
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700426 case ';':
427 /*
428 * Invalid character for a class name, but the
429 * legitimate end of a type descriptor. In the latter
430 * case, make sure that this is the end of the string
431 * and that it doesn't end with an empty component
432 * (including the degenerate case of "L;").
433 */
Elliott Hughes906e6852011-10-28 14:52:10 -0700434 return (type == kDescriptor) && !sepOrFirst && (s[1] == '\0');
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700435 case '/':
436 case '.':
437 if (c != separator) {
438 // The wrong separator character.
439 return false;
440 }
441 if (sepOrFirst) {
442 // Separator at start or two separators in a row.
443 return false;
444 }
445 sepOrFirst = true;
446 s++;
447 break;
448 default:
449 if (!IsValidMemberNameUtf8(&s)) {
450 return false;
451 }
452 sepOrFirst = false;
453 break;
454 }
455 }
456}
457
Elliott Hughes906e6852011-10-28 14:52:10 -0700458bool IsValidBinaryClassName(const char* s) {
459 return IsValidClassName(s, kName, '.');
460}
461
462bool IsValidJniClassName(const char* s) {
463 return IsValidClassName(s, kName, '/');
464}
465
466bool IsValidDescriptor(const char* s) {
467 return IsValidClassName(s, kDescriptor, '/');
468}
469
Elliott Hughes34023802011-08-30 12:06:17 -0700470void Split(const std::string& s, char delim, std::vector<std::string>& result) {
471 const char* p = s.data();
472 const char* end = p + s.size();
473 while (p != end) {
474 if (*p == delim) {
475 ++p;
476 } else {
477 const char* start = p;
478 while (++p != end && *p != delim) {
479 // Skip to the next occurrence of the delimiter.
480 }
481 result.push_back(std::string(start, p - start));
482 }
483 }
484}
485
Elliott Hughesdcc24742011-09-07 14:02:44 -0700486void SetThreadName(const char *threadName) {
487 int hasAt = 0;
488 int hasDot = 0;
489 const char *s = threadName;
490 while (*s) {
491 if (*s == '.') {
492 hasDot = 1;
493 } else if (*s == '@') {
494 hasAt = 1;
495 }
496 s++;
497 }
498 int len = s - threadName;
499 if (len < 15 || hasAt || !hasDot) {
500 s = threadName;
501 } else {
502 s = threadName + len - 15;
503 }
504#if defined(HAVE_ANDROID_PTHREAD_SETNAME_NP)
505 /* pthread_setname_np fails rather than truncating long strings */
506 char buf[16]; // MAX_TASK_COMM_LEN=16 is hard-coded into bionic
507 strncpy(buf, s, sizeof(buf)-1);
508 buf[sizeof(buf)-1] = '\0';
509 errno = pthread_setname_np(pthread_self(), buf);
510 if (errno != 0) {
511 PLOG(WARNING) << "Unable to set the name of current thread to '" << buf << "'";
512 }
513#elif defined(HAVE_PRCTL)
514 prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0);
515#else
516#error no implementation for SetThreadName
517#endif
518}
519
Elliott Hughesbfe487b2011-10-26 15:48:55 -0700520void GetTaskStats(pid_t tid, int& utime, int& stime, int& task_cpu) {
521 utime = stime = task_cpu = 0;
522 std::string stats;
523 if (!ReadFileToString(StringPrintf("/proc/self/task/%d/stat", GetTid()).c_str(), &stats)) {
524 return;
525 }
526 // Skip the command, which may contain spaces.
527 stats = stats.substr(stats.find(')') + 2);
528 // Extract the three fields we care about.
529 std::vector<std::string> fields;
530 Split(stats, ' ', fields);
531 utime = strtoull(fields[11].c_str(), NULL, 10);
532 stime = strtoull(fields[12].c_str(), NULL, 10);
533 task_cpu = strtoull(fields[36].c_str(), NULL, 10);
534}
535
Brian Carlstroma9f19782011-10-13 00:14:47 -0700536std::string GetArtCacheOrDie() {
537 const char* data_root = getenv("ANDROID_DATA");
538 if (data_root == NULL) {
539 if (OS::DirectoryExists("/data")) {
540 data_root = "/data";
541 } else {
542 data_root = "/tmp";
543 }
544 }
545 if (!OS::DirectoryExists(data_root)) {
546 LOG(FATAL) << "Failed to find ANDROID_DATA directory " << data_root;
547 return "";
548 }
549
550 std::string art_cache = StringPrintf("%s/art-cache", data_root);
551
552 if (!OS::DirectoryExists(art_cache.c_str())) {
553 if (StringPiece(art_cache).starts_with("/tmp/")) {
554 int result = mkdir(art_cache.c_str(), 0700);
555 if (result != 0) {
556 LOG(FATAL) << "Failed to create art-cache directory " << art_cache;
557 return "";
558 }
559 } else {
560 LOG(FATAL) << "Failed to find art-cache directory " << art_cache;
561 return "";
562 }
563 }
564 return art_cache;
565}
566
jeffhao262bf462011-10-20 18:36:32 -0700567std::string GetArtCacheFilenameOrDie(const std::string& location) {
Brian Carlstromb7bbba42011-10-13 14:58:47 -0700568 std::string art_cache = GetArtCacheOrDie();
569 CHECK_EQ(location[0], '/');
570 std::string cache_file(location, 1); // skip leading slash
571 std::replace(cache_file.begin(), cache_file.end(), '/', '@');
572 return art_cache + "/" + cache_file;
573}
574
jeffhao262bf462011-10-20 18:36:32 -0700575bool IsValidZipFilename(const std::string& filename) {
576 if (filename.size() < 4) {
577 return false;
578 }
579 std::string suffix(filename.substr(filename.size() - 4));
580 return (suffix == ".zip" || suffix == ".jar" || suffix == ".apk");
581}
582
583bool IsValidDexFilename(const std::string& filename) {
584 if (filename.size() < 4) {
585 return false;
586 }
587 std::string suffix(filename.substr(filename.size() - 4));
588 return (suffix == ".dex");
589}
590
Elliott Hughes11e45072011-08-16 17:40:46 -0700591} // namespace art
Elliott Hughes42ee1422011-09-06 12:33:32 -0700592
593// Neither bionic nor glibc exposes gettid(2).
594#define __KERNEL__
595#include <linux/unistd.h>
596namespace art {
597#ifdef _syscall0
598_syscall0(pid_t, GetTid)
599#else
600pid_t GetTid() { return syscall(__NR_gettid); }
601#endif
602} // namespace art
603#undef __KERNEL__