OLD | NEW |
1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #endif /* TH32CS_SNAPMODULE32 */ | 79 #endif /* TH32CS_SNAPMODULE32 */ |
80 #endif /* PLATFORM_WINDOWS */ | 80 #endif /* PLATFORM_WINDOWS */ |
81 | 81 |
82 // Re-run fn until it doesn't cause EINTR. | 82 // Re-run fn until it doesn't cause EINTR. |
83 #define NO_INTR(fn) do {} while ((fn) < 0 && errno == EINTR) | 83 #define NO_INTR(fn) do {} while ((fn) < 0 && errno == EINTR) |
84 | 84 |
85 // open/read/close can set errno, which may be illegal at this | 85 // open/read/close can set errno, which may be illegal at this |
86 // time, so prefer making the syscalls directly if we can. | 86 // time, so prefer making the syscalls directly if we can. |
87 #ifdef HAVE_SYS_SYSCALL_H | 87 #ifdef HAVE_SYS_SYSCALL_H |
88 # include <sys/syscall.h> | 88 # include <sys/syscall.h> |
89 #endif | |
90 #ifdef SYS_open // solaris 11, at least sometimes, only defines SYS_openat | |
91 # define safeopen(filename, mode) syscall(SYS_open, filename, mode) | 89 # define safeopen(filename, mode) syscall(SYS_open, filename, mode) |
| 90 # define saferead(fd, buffer, size) syscall(SYS_read, fd, buffer, size) |
| 91 # define safeclose(fd) syscall(SYS_close, fd) |
92 #else | 92 #else |
93 # define safeopen(filename, mode) open(filename, mode) | 93 # define safeopen(filename, mode) open(filename, mode) |
94 #endif | |
95 #ifdef SYS_read | |
96 # define saferead(fd, buffer, size) syscall(SYS_read, fd, buffer, size) | |
97 #else | |
98 # define saferead(fd, buffer, size) read(fd, buffer, size) | 94 # define saferead(fd, buffer, size) read(fd, buffer, size) |
99 #endif | |
100 #ifdef SYS_close | |
101 # define safeclose(fd) syscall(SYS_close, fd) | |
102 #else | |
103 # define safeclose(fd) close(fd) | 95 # define safeclose(fd) close(fd) |
104 #endif | 96 #endif |
105 | 97 |
106 // ---------------------------------------------------------------------- | 98 // ---------------------------------------------------------------------- |
107 // GetenvBeforeMain() | 99 // GetenvBeforeMain() |
108 // GetUniquePathFromEnv() | 100 // GetUniquePathFromEnv() |
109 // Some non-trivial getenv-related functions. | 101 // Some non-trivial getenv-related functions. |
110 // ---------------------------------------------------------------------- | 102 // ---------------------------------------------------------------------- |
111 | 103 |
112 // It's not safe to call getenv() in the malloc hooks, because they | 104 // It's not safe to call getenv() in the malloc hooks, because they |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 ProcMapsIterator::Buffer linebuf; | 973 ProcMapsIterator::Buffer linebuf; |
982 while (it.Next(&start, &end, &flags, &offset, &inode, &filename)) { | 974 while (it.Next(&start, &end, &flags, &offset, &inode, &filename)) { |
983 int written = it.FormatLine(linebuf.buf_, sizeof(linebuf.buf_), | 975 int written = it.FormatLine(linebuf.buf_, sizeof(linebuf.buf_), |
984 start, end, flags, offset, inode, filename, | 976 start, end, flags, offset, inode, filename, |
985 0); | 977 0); |
986 RawWrite(fd, linebuf.buf_, written); | 978 RawWrite(fd, linebuf.buf_, written); |
987 } | 979 } |
988 } | 980 } |
989 | 981 |
990 } // namespace tcmalloc | 982 } // namespace tcmalloc |
OLD | NEW |