diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-05-28 02:50:53 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-05-28 02:50:53 +0000 |
commit | f16084723ce9ef03a03bc3465eca3df2e6301df7 (patch) | |
tree | febacd9c7088eee5ed1d588539da3c5ade334cef /compiler-rt/lib/profile | |
parent | 74f987f3b6e40db65f89977bdfcf8741334a05ad (diff) | |
download | bcm5719-llvm-f16084723ce9ef03a03bc3465eca3df2e6301df7.tar.gz bcm5719-llvm-f16084723ce9ef03a03bc3465eca3df2e6301df7.zip |
Don't use 'strrchr', which isn't implemented here yet.
llvm-svn: 157560
Diffstat (limited to 'compiler-rt/lib/profile')
-rw-r--r-- | compiler-rt/lib/profile/GCDAProfiling.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c index 3774b6d99c2..d4a720c8b9d 100644 --- a/compiler-rt/lib/profile/GCDAProfiling.c +++ b/compiler-rt/lib/profile/GCDAProfiling.c @@ -117,12 +117,20 @@ void llvm_gcda_start_file(const char *orig_filename) { output_file = fopen(filename, "w+b"); if (!output_file) { - const char *cptr = strrchr(orig_filename, '/'); - output_file = fopen(cptr ? cptr + 1 : orig_filename, "w+b"); + int len = strlen(orig_filename) - 1; + + for (; len >= 0 && orig_filename[len] != '/'; --len) + /* empty */; + + if (len < 0) + len = 0; + else if (orig_filename[len] == '/') + ++len; + + output_file = fopen(&orig_filename[len], "w+b"); if (!output_file) { - fprintf(stderr, "profiling:%s: cannot open\n", - cptr ? cptr + 1 : orig_filename); + fprintf(stderr, "profiling:%s: cannot open\n", &orig_filename[len]); return; } } @@ -160,8 +168,9 @@ void llvm_gcda_increment_indirect_counter(uint32_t *predecessor, ++*counter; #ifdef DEBUG_GCDAPROFILING else - printf("llvmgcda: increment_indirect_counter counters=%x, pred=%u\n", - state_table_row, *predecessor); + fprintf(stderr, + "llvmgcda: increment_indirect_counter counters=%x, pred=%u\n", + state_table_row, *predecessor); #endif } |