Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: src/platform-linux.cc

Issue 1887: Fix issue http://code.google.com/p/v8/issues/detail?id=58:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/platform-macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 static const pthread_t kNoThread = (pthread_t) 0; 60 static const pthread_t kNoThread = (pthread_t) 0;
61 61
62 62
63 double ceiling(double x) { 63 double ceiling(double x) {
64 return ceil(x); 64 return ceil(x);
65 } 65 }
66 66
67 67
68 void OS::Setup() { 68 void OS::Setup() {
69 // Seed the random number generator. 69 // Seed the random number generator.
70 srandom(static_cast<unsigned int>(TimeCurrentMillis())); 70 // Convert the current time to a 64-bit integer first, before converting it
71 // to an unsigned. Going directly can cause an overflow and the seed to be
72 // set to all ones. The seed will be identical for different instances that
73 // call this setup code within the same millisecond.
74 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
75 srandom(static_cast<unsigned int>(seed));
71 } 76 }
72 77
73 78
74 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { 79 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
75 struct rusage usage; 80 struct rusage usage;
76 81
77 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; 82 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1;
78 *secs = usage.ru_utime.tv_sec; 83 *secs = usage.ru_utime.tv_sec;
79 *usecs = usage.ru_utime.tv_usec; 84 *usecs = usage.ru_utime.tv_usec;
80 return 0; 85 return 0;
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 } 653 }
649 654
650 // This sampler is no longer the active sampler. 655 // This sampler is no longer the active sampler.
651 active_sampler_ = NULL; 656 active_sampler_ = NULL;
652 active_ = false; 657 active_ = false;
653 } 658 }
654 659
655 #endif // ENABLE_LOGGING_AND_PROFILING 660 #endif // ENABLE_LOGGING_AND_PROFILING
656 661
657 } } // namespace v8::internal 662 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/platform-macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698