Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/os.cpp @ 12147:c636758ea616
Merge
author | dcubed |
---|---|
date | Fri, 30 Aug 2013 07:04:42 -0700 |
parents | f92b82d454fa d8e99408faad |
children | 8e94527f601e 40136aa2cdb1 9b4ce069642e |
comparison
equal
deleted
inserted
replaced
12128:c169f7038414 | 12147:c636758ea616 |
---|---|
1483 } | 1483 } |
1484 } | 1484 } |
1485 return result; | 1485 return result; |
1486 } | 1486 } |
1487 | 1487 |
1488 // Read file line by line, if line is longer than bsize, | |
1489 // skip rest of line. | |
1490 int os::get_line_chars(int fd, char* buf, const size_t bsize){ | |
1491 size_t sz, i = 0; | |
1492 | |
1493 // read until EOF, EOL or buf is full | |
1494 while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') { | |
1495 ++i; | |
1496 } | |
1497 | |
1498 if (buf[i] == '\n') { | |
1499 // EOL reached so ignore EOL character and return | |
1500 | |
1501 buf[i] = 0; | |
1502 return (int) i; | |
1503 } | |
1504 | |
1505 buf[i+1] = 0; | |
1506 | |
1507 if (sz != 1) { | |
1508 // EOF reached. if we read chars before EOF return them and | |
1509 // return EOF on next call otherwise return EOF | |
1510 | |
1511 return (i == 0) ? -1 : (int) i; | |
1512 } | |
1513 | |
1514 // line is longer than size of buf, skip to EOL | |
1515 char ch; | |
1516 while (read(fd, &ch, 1) == 1 && ch != '\n') { | |
1517 // Do nothing | |
1518 } | |
1519 | |
1520 // return initial part of line that fits in buf. | |
1521 // If we reached EOF, it will be returned on next call. | |
1522 | |
1523 return (int) i; | |
1524 } | |
1525 | |
1526 void os::SuspendedThreadTask::run() { | 1488 void os::SuspendedThreadTask::run() { |
1527 assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this"); | 1489 assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this"); |
1528 internal_do_task(); | 1490 internal_do_task(); |
1529 _done = true; | 1491 _done = true; |
1530 } | 1492 } |