summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-05-17 16:56:53 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-05-17 16:56:53 +0000
commitffaf2eac4da21357fabef74805bd276e71f3884c (patch)
treeac64bdc9ba35809c90912faac4470b24d743a112
parent1ac08bbc7e83e1101ef0952b4926f8f0ffaeef9b (diff)
downloadbcm5719-llvm-ffaf2eac4da21357fabef74805bd276e71f3884c.tar.gz
bcm5719-llvm-ffaf2eac4da21357fabef74805bd276e71f3884c.zip
[nolibc] Move all platforms to internal_getpid.
Before, we had an unused internal_getpid function for Linux, and a platform-independent GetPid function. To make the naming conventions consistent for syscall-like functions, the GetPid syscall wrapper in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is renamed to internal_getpid, bringing the Linux variant into use. llvm-svn: 182132
-rw-r--r--compiler-rt/lib/asan/asan_rtl.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.cc8
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_libc.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_mac.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_printf.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_win.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_interceptors.cc4
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc4
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc4
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_report.cc3
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cc8
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_suppressions.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc3
15 files changed, 27 insertions, 25 deletions
diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc
index 26c5b072208..b4ced16d20d 100644
--- a/compiler-rt/lib/asan/asan_rtl.cc
+++ b/compiler-rt/lib/asan/asan_rtl.cc
@@ -524,7 +524,7 @@ void __asan_init() {
0, true, 0, &create_main_args);
CHECK_EQ(0, main_tid);
SetCurrentThread(main_thread);
- main_thread->ThreadStart(GetPid());
+ main_thread->ThreadStart(internal_getpid());
force_interface_symbols(); // no-op.
InitializeAllocator();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
index 3684e847c81..abbe5f92d1a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
@@ -35,7 +35,7 @@ fd_t report_fd = kStderrFd;
static char report_path_prefix[4096]; // Set via __sanitizer_set_report_path.
// PID of process that opened |report_fd|. If a fork() occurs, the PID of the
// child thread will be different from |report_fd_pid|.
-static int report_fd_pid = 0;
+static uptr report_fd_pid = 0;
static void (*DieCallback)(void);
void SetDieCallback(void (*callback)(void)) {
@@ -65,10 +65,10 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond,
}
void MaybeOpenReportFile() {
- if (!log_to_file || (report_fd_pid == GetPid())) return;
+ if (!log_to_file || (report_fd_pid == internal_getpid())) return;
InternalScopedBuffer<char> report_path_full(4096);
internal_snprintf(report_path_full.data(), report_path_full.size(),
- "%s.%d", report_path_prefix, GetPid());
+ "%s.%d", report_path_prefix, internal_getpid());
uptr openrv = OpenFile(report_path_full.data(), true);
if (internal_iserror(openrv)) {
report_fd = kStderrFd;
@@ -81,7 +81,7 @@ void MaybeOpenReportFile() {
internal_close(report_fd);
}
report_fd = openrv;
- report_fd_pid = GetPid();
+ report_fd_pid = internal_getpid();
}
void RawWrite(const char *buffer) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index f0208f33333..d800360169f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -40,7 +40,6 @@ uptr GetPageSize();
uptr GetPageSizeCached();
uptr GetMmapGranularity();
// Threads
-int GetPid();
uptr GetTid();
uptr GetThreadSelf();
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
index 5f77ad1e5cf..82d809a0305 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
@@ -85,6 +85,7 @@ uptr internal_lseek(fd_t fd, OFF_T offset, int whence);
uptr internal_ptrace(int request, int pid, void *addr, void *data);
uptr internal_waitpid(int pid, int *status, int options);
+uptr internal_getpid();
uptr internal_getppid();
// Threading
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
index 0181b69e802..9d74a48f535 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
@@ -115,6 +115,10 @@ void internal__exit(int exitcode) {
_exit(exitcode);
}
+uptr internal_getpid() {
+ return getpid();
+}
+
// ----------------- sanitizer_common.h
bool FileExists(const char *filename) {
struct stat st;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
index 1bc99081a6b..72dde4cd7e7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -43,10 +43,6 @@ uptr GetMmapGranularity() {
return GetPageSize();
}
-int GetPid() {
- return getpid();
-}
-
u32 GetUid() {
return getuid();
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc b/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
index ebb8fa07a13..5935d7f17a5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
@@ -218,7 +218,7 @@ static void SharedPrintfCode(bool append_pid, const char *format,
}
needed_length = 0;
if (append_pid) {
- int pid = GetPid();
+ int pid = internal_getpid();
needed_length += internal_snprintf(buffer, buffer_size, "==%d==", pid);
if (needed_length >= buffer_size) {
// The pid doesn't fit into the current buffer.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
index b826cb2f428..e76f1d1f7fa 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
@@ -44,7 +44,7 @@ bool FileExists(const char *filename) {
UNIMPLEMENTED();
}
-int GetPid() {
+uptr internal_getpid() {
return GetProcessId(GetCurrentProcess());
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
index c7651c67bf9..f18b26f6abe 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
@@ -1754,11 +1754,11 @@ TSAN_INTERCEPTOR(int, kill, int pid, int sig) {
SignalContext *sctx = SigCtx(thr);
CHECK_NE(sctx, 0);
int prev = sctx->int_signal_send;
- if (pid == GetPid()) {
+ if (pid == (int)internal_getpid()) {
sctx->int_signal_send = sig;
}
int res = REAL(kill)(pid, sig);
- if (pid == GetPid()) {
+ if (pid == (int)internal_getpid()) {
CHECK_EQ(sctx->int_signal_send, sig);
sctx->int_signal_send = prev;
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc
index 257afcf8fa3..04b4b455d15 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc
@@ -196,7 +196,7 @@ void PrintMatchedBenignRaces() {
&ExpectRace::addcount);
if (hit_matched.Size()) {
Printf("ThreadSanitizer: Matched %d \"benign\" races (pid=%d):\n",
- hit_count, GetPid());
+ hit_count, (int)internal_getpid());
for (uptr i = 0; i < hit_matched.Size(); i++) {
Printf("%d %s:%d %s\n",
hit_matched[i].hitcount, hit_matched[i].file,
@@ -206,7 +206,7 @@ void PrintMatchedBenignRaces() {
if (hit_matched.Size()) {
Printf("ThreadSanitizer: Annotated %d \"benign\" races, %d unique"
" (pid=%d):\n",
- add_count, unique_count, GetPid());
+ add_count, unique_count, (int)internal_getpid());
for (uptr i = 0; i < add_matched.Size(); i++) {
Printf("%d %s:%d %s\n",
add_matched[i].addcount, add_matched[i].file,
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
index 5ccdc49d37d..a0d71e8589d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
@@ -176,8 +176,8 @@ static void MapRodata() {
if (tmpdir == 0)
return;
char filename[256];
- internal_snprintf(filename, sizeof(filename), "%s/tsan.rodata.%u",
- tmpdir, GetPid());
+ internal_snprintf(filename, sizeof(filename), "%s/tsan.rodata.%d",
+ tmpdir, (int)internal_getpid());
uptr openrv = internal_open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
if (internal_iserror(openrv))
return;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cc b/compiler-rt/lib/tsan/rtl/tsan_report.cc
index bfa26602189..c95c5c86be6 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cc
@@ -179,7 +179,8 @@ ReportStack *SkipTsanInternalFrames(ReportStack *ent) {
void PrintReport(const ReportDesc *rep) {
Printf("==================\n");
const char *rep_typ_str = ReportTypeString(rep->typ);
- Printf("WARNING: ThreadSanitizer: %s (pid=%d)\n", rep_typ_str, GetPid());
+ Printf("WARNING: ThreadSanitizer: %s (pid=%d)\n", rep_typ_str,
+ (int)internal_getpid());
for (uptr i = 0; i < rep->stacks.Size(); i++) {
if (i)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index c51a5669060..66b23fe1bc2 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -120,7 +120,7 @@ static void BackgroundThread(void *arg) {
if (flags()->profile_memory && flags()->profile_memory[0]) {
InternalScopedBuffer<char> filename(4096);
internal_snprintf(filename.data(), filename.size(), "%s.%d",
- flags()->profile_memory, GetPid());
+ flags()->profile_memory, (int)internal_getpid());
uptr openrv = OpenFile(filename.data(), true);
if (internal_iserror(openrv)) {
Printf("ThreadSanitizer: failed to open memory profile file '%s'\n",
@@ -229,19 +229,19 @@ void Initialize(ThreadState *thr) {
if (ctx->flags.verbosity)
Printf("***** Running under ThreadSanitizer v2 (pid %d) *****\n",
- GetPid());
+ (int)internal_getpid());
// Initialize thread 0.
int tid = ThreadCreate(thr, 0, 0, true);
CHECK_EQ(tid, 0);
- ThreadStart(thr, tid, GetPid());
+ ThreadStart(thr, tid, internal_getpid());
CHECK_EQ(thr->in_rtl, 1);
ctx->initialized = true;
if (flags()->stop_on_start) {
Printf("ThreadSanitizer is suspended at startup (pid %d)."
" Call __tsan_resume().\n",
- GetPid());
+ (int)internal_getpid());
while (__tsan_resumed == 0) {}
}
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc b/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc
index 14b6a3acacc..6c49355bed8 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc
@@ -194,7 +194,7 @@ void PrintMatchedSuppressions() {
if (hit_count == 0)
return;
Printf("ThreadSanitizer: Matched %d suppressions (pid=%d):\n",
- hit_count, GetPid());
+ hit_count, (int)internal_getpid());
for (Suppression *supp = g_suppressions; supp; supp = supp->next) {
if (supp->hit_count == 0)
continue;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
index 76926e2b5aa..47f9e1fbf41 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
@@ -87,7 +87,8 @@ static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
DlIteratePhdrCtx *ctx = (DlIteratePhdrCtx*)arg;
InternalScopedBuffer<char> tmp(128);
if (ctx->is_first) {
- internal_snprintf(tmp.data(), tmp.size(), "/proc/%d/exe", GetPid());
+ internal_snprintf(tmp.data(), tmp.size(), "/proc/%d/exe",
+ (int)internal_getpid());
info->dlpi_name = tmp.data();
}
ctx->is_first = false;
OpenPOWER on IntegriCloud