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

Side by Side Diff: base/logging.cc

Issue 199105: Continue with the FreeBSD port - this version builds and links, though... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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 | « base/icu_util.cc ('k') | base/message_loop.h » ('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 (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 typedef HANDLE FileHandle; 9 typedef HANDLE FileHandle;
10 typedef HANDLE MutexHandle; 10 typedef HANDLE MutexHandle;
11 #elif defined(OS_MACOSX) 11 #elif defined(OS_MACOSX)
12 #include <CoreFoundation/CoreFoundation.h> 12 #include <CoreFoundation/CoreFoundation.h>
13 #include <mach/mach.h> 13 #include <mach/mach.h>
14 #include <mach/mach_time.h> 14 #include <mach/mach_time.h>
15 #include <mach-o/dyld.h> 15 #include <mach-o/dyld.h>
16 #elif defined(OS_LINUX) 16 #elif defined(OS_LINUX) || defined(OS_FREEBSD)
17 #include <sys/syscall.h> 17 #include <sys/syscall.h>
18 #include <time.h> 18 #include <time.h>
19 #endif 19 #endif
20 20
21 #if defined(OS_POSIX) 21 #if defined(OS_POSIX)
22 #include <stdlib.h> 22 #include <stdlib.h>
23 #include <stdio.h> 23 #include <stdio.h>
24 #include <string.h> 24 #include <string.h>
25 #include <unistd.h> 25 #include <unistd.h>
26 #define MAX_PATH PATH_MAX 26 #define MAX_PATH PATH_MAX
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 #endif 118 #endif
119 } 119 }
120 120
121 int32 CurrentThreadId() { 121 int32 CurrentThreadId() {
122 #if defined(OS_WIN) 122 #if defined(OS_WIN)
123 return GetCurrentThreadId(); 123 return GetCurrentThreadId();
124 #elif defined(OS_MACOSX) 124 #elif defined(OS_MACOSX)
125 return mach_thread_self(); 125 return mach_thread_self();
126 #elif defined(OS_LINUX) 126 #elif defined(OS_LINUX)
127 return syscall(__NR_gettid); 127 return syscall(__NR_gettid);
128 #elif defined(OS_FREEBSD)
129 // TODO(benl): find a better thread ID
130 return reinterpret_cast<int32>(pthread_self());
128 #endif 131 #endif
129 } 132 }
130 133
131 uint64 TickCount() { 134 uint64 TickCount() {
132 #if defined(OS_WIN) 135 #if defined(OS_WIN)
133 return GetTickCount(); 136 return GetTickCount();
134 #elif defined(OS_MACOSX) 137 #elif defined(OS_MACOSX)
135 return mach_absolute_time(); 138 return mach_absolute_time();
136 #elif defined(OS_LINUX) 139 #elif defined(OS_LINUX) || defined(OS_FREEBSD)
137 struct timespec ts; 140 struct timespec ts;
138 clock_gettime(CLOCK_MONOTONIC, &ts); 141 clock_gettime(CLOCK_MONOTONIC, &ts);
139 142
140 uint64 absolute_micro = 143 uint64 absolute_micro =
141 static_cast<int64>(ts.tv_sec) * 1000000 + 144 static_cast<int64>(ts.tv_sec) * 1000000 +
142 static_cast<int64>(ts.tv_nsec) / 1000; 145 static_cast<int64>(ts.tv_nsec) / 1000;
143 146
144 return absolute_micro; 147 return absolute_micro;
145 #endif 148 #endif
146 } 149 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 #elif defined(OS_POSIX) 210 #elif defined(OS_POSIX)
208 log_file = fopen(log_file_name->c_str(), "a"); 211 log_file = fopen(log_file_name->c_str(), "a");
209 if (log_file == NULL) 212 if (log_file == NULL)
210 return false; 213 return false;
211 #endif 214 #endif
212 } 215 }
213 216
214 return true; 217 return true;
215 } 218 }
216 219
217 #if defined(OS_LINUX) 220 #if defined(OS_LINUX) || defined(OS_FREEBSD)
218 int GetLoggingFileDescriptor() { 221 int GetLoggingFileDescriptor() {
219 // No locking needed, since this is only called by the zygote server, 222 // No locking needed, since this is only called by the zygote server,
220 // which is single-threaded. 223 // which is single-threaded.
221 if (log_file) 224 if (log_file)
222 return fileno(log_file); 225 return fileno(log_file);
223 return -1; 226 return -1;
224 } 227 }
225 #endif 228 #endif
226 229
227 void InitLogMutex() { 230 void InitLogMutex() {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 576
574 CloseFile(log_file); 577 CloseFile(log_file);
575 log_file = NULL; 578 log_file = NULL;
576 } 579 }
577 580
578 } // namespace logging 581 } // namespace logging
579 582
580 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { 583 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) {
581 return out << base::SysWideToUTF8(std::wstring(wstr)); 584 return out << base::SysWideToUTF8(std::wstring(wstr));
582 } 585 }
OLDNEW
« no previous file with comments | « base/icu_util.cc ('k') | base/message_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698