Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/util-linux/readprofile.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/util-linux/readprofile.c
r1765 r2725 5 5 * Copyright (C) 1994,1996 Alessandro Rubini (rubini@ipvvis.unipv.it) 6 6 * 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 9 10 10 /* 11 * 1999-02-22 Arkadiusz Mi ¶kiewicz <misiek@pld.ORG.PL>11 * 1999-02-22 Arkadiusz Mickiewicz <misiek@pld.ORG.PL> 12 12 * - added Native Language Support 13 13 * 1999-09-01 Stephane Eranian <eranian@cello.hpl.hp.com> … … 42 42 static const char defaultpro[] ALIGN1 = "/proc/profile"; 43 43 44 int readprofile_main(int argc, char **argv) ;45 int readprofile_main(int argc , char **argv)44 int readprofile_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 45 int readprofile_main(int argc UNUSED_PARAM, char **argv) 46 46 { 47 47 FILE *map; 48 const char *mapFile, *proFile , *mult = 0;48 const char *mapFile, *proFile; 49 49 unsigned long indx = 1; 50 50 size_t len; … … 56 56 char mapline[S_LEN]; 57 57 char mode[8]; 58 int optAll = 0, optInfo = 0, optReset = 0;59 int optVerbose = 0, optNative = 0;60 int optBins = 0, optSub = 0;61 58 int maplineno = 1; 62 59 int header_printed; 60 int multiplier = 0; 61 unsigned opt; 62 enum { 63 OPT_M = (1 << 0), 64 OPT_m = (1 << 1), 65 OPT_p = (1 << 2), 66 OPT_n = (1 << 3), 67 OPT_a = (1 << 4), 68 OPT_b = (1 << 5), 69 OPT_s = (1 << 6), 70 OPT_i = (1 << 7), 71 OPT_r = (1 << 8), 72 OPT_v = (1 << 9), 73 }; 74 #define optMult (opt & OPT_M) 75 #define optNative (opt & OPT_n) 76 #define optAll (opt & OPT_a) 77 #define optBins (opt & OPT_b) 78 #define optSub (opt & OPT_s) 79 #define optInfo (opt & OPT_i) 80 #define optReset (opt & OPT_r) 81 #define optVerbose (opt & OPT_v) 63 82 64 83 #define next (current^1) … … 67 86 mapFile = defaultmap; 68 87 69 opt_complementary = "nn:aa:bb:ss:ii:rr:vv"; 70 getopt32(argv, "M:m:p:nabsirv", 71 &mult, &mapFile, &proFile, 72 &optNative, &optAll, &optBins, &optSub, 73 &optInfo, &optReset, &optVerbose); 74 75 if (optReset || mult) { 76 int multiplier, fd, to_write; 88 opt_complementary = "M+"; /* -M N */ 89 opt = getopt32(argv, "M:m:p:nabsirv", &multiplier, &mapFile, &proFile); 90 91 if (opt & (OPT_M|OPT_r)) { /* mult or reset, or both */ 92 int fd, to_write; 77 93 78 94 /* … … 80 96 * not sizeof(int), the multiplier is not changed 81 97 */ 82 if (mult) { 83 multiplier = xatoi_u(mult); 84 to_write = sizeof(int); 85 } else { 86 multiplier = 0; 87 to_write = 1; /* sth different from sizeof(int) */ 88 } 98 to_write = sizeof(int); 99 if (!optMult) 100 to_write = 1; /* sth different from sizeof(int) */ 89 101 90 102 fd = xopen(defaultpro, O_WRONLY); 91 92 if (full_write(fd, &multiplier, to_write) != to_write) 93 bb_perror_msg_and_die("error writing %s", defaultpro); 94 103 xwrite(fd, &multiplier, to_write); 95 104 close(fd); 96 105 return EXIT_SUCCESS; … … 101 110 */ 102 111 len = MAXINT(ssize_t); 103 buf = xmalloc_ open_read_close(proFile, &len);112 buf = xmalloc_xopen_read_close(proFile, &len); 104 113 if (!optNative) { 105 int entries = len /sizeof(*buf);114 int entries = len / sizeof(*buf); 106 115 int big = 0, small = 0, i; 107 116 unsigned *p; … … 136 145 total = 0; 137 146 138 map = xfopen (mapFile, "r");147 map = xfopen_for_read(mapFile); 139 148 140 149 while (fgets(mapline, S_LEN, map)) { … … 168 177 Absolute symbols */ 169 178 if ((*mode == 'A' || *mode == '?') && total == 0) continue; 170 if (*mode != 'T' && *mode != 't' && 171 *mode != 'W' && *mode != 'w') 172 break; /* only text is profiled */ 179 if (*mode != 'T' && *mode != 't' 180 && *mode != 'W' && *mode != 'w' 181 ) { 182 break; /* only text is profiled */ 183 } 173 184 174 185 if (indx >= len / sizeof(*buf)) … … 191 202 if (optVerbose || this > 0) 192 203 printf(" total\t\t\t\t%u\n", this); 193 } else if ((this || optAll) && 194 (fn_len = next_add-fn_add) != 0) { 204 } else if ((this || optAll) 205 && (fn_len = next_add-fn_add) != 0 206 ) { 195 207 if (optVerbose) 196 208 printf("%016llx %-40s %6i %8.4f\n", fn_add,
Note:
See TracChangeset
for help on using the changeset viewer.