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

Side by Side Diff: src/platform-macos.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 | « src/platform-linux.cc ('k') | src/platform-win32.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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (-1.0 < x && x < 0.0) { 66 if (-1.0 < x && x < 0.0) {
67 return -0.0; 67 return -0.0;
68 } else { 68 } else {
69 return ceil(x); 69 return ceil(x);
70 } 70 }
71 } 71 }
72 72
73 73
74 void OS::Setup() { 74 void OS::Setup() {
75 // Seed the random number generator. 75 // Seed the random number generator.
76 srandom(static_cast<unsigned int>(TimeCurrentMillis())); 76 // Convert the current time to a 64-bit integer first, before converting it
77 // to an unsigned. Going directly will cause an overflow and the seed to be
78 // set to all ones. The seed will be identical for different instances that
79 // call this setup code within the same millisecond.
80 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
81 srandom(static_cast<unsigned int>(seed));
77 } 82 }
78 83
79 84
80 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { 85 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
81 struct rusage usage; 86 struct rusage usage;
82 87
83 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; 88 if (getrusage(RUSAGE_SELF, &usage) < 0) return -1;
84 *secs = usage.ru_utime.tv_sec; 89 *secs = usage.ru_utime.tv_sec;
85 *usecs = usage.ru_utime.tv_usec; 90 *usecs = usage.ru_utime.tv_usec;
86 return 0; 91 return 0;
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 609 }
605 610
606 // This sampler is no longer the active sampler. 611 // This sampler is no longer the active sampler.
607 active_sampler_ = NULL; 612 active_sampler_ = NULL;
608 active_ = false; 613 active_ = false;
609 } 614 }
610 615
611 #endif // ENABLE_LOGGING_AND_PROFILING 616 #endif // ENABLE_LOGGING_AND_PROFILING
612 617
613 } } // namespace v8::internal 618 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698