Changeset 933cadf in mainline
- Timestamp:
- 2011-04-22T13:35:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3dbe4ca2, afdcc60e, b678410
- Parents:
- 74c8f344
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/mm/frame.c
r74c8f344 r933cadf 88 88 /* gxemul devices */ 89 89 if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE, 90 0x10000000, M B2SIZE(256)))90 0x10000000, MiB2SIZE(256))) 91 91 return false; 92 92 #endif -
kernel/generic/include/macros.h
r74c8f344 r933cadf 95 95 overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy)) 96 96 97 #define SIZE2KB(size) ((size) >> 10) 98 #define SIZE2MB(size) ((size) >> 20) 99 100 #define KB2SIZE(kb) ((kb) << 10) 101 #define MB2SIZE(mb) ((mb) << 20) 97 #define KiB2SIZE(kb) ((kb) << 10) 98 #define MiB2SIZE(mb) ((mb) << 20) 102 99 103 100 #define STRING(arg) STRING_ARG(arg) -
kernel/generic/include/str.h
r74c8f344 r933cadf 99 99 extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *); 100 100 101 extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix); 101 extern void order_suffix(const uint64_t, uint64_t *, char *); 102 extern void bin_order_suffix(const uint64_t, uint64_t *, const char **, bool); 102 103 103 104 #endif -
kernel/generic/src/lib/str.c
r74c8f344 r933cadf 922 922 void order_suffix(const uint64_t val, uint64_t *rv, char *suffix) 923 923 { 924 if (val > 10000000000000000000ULL) {925 *rv = val / 1000000000000000000ULL;924 if (val > UINT64_C(10000000000000000000)) { 925 *rv = val / UINT64_C(1000000000000000000); 926 926 *suffix = 'Z'; 927 } else if (val > 1000000000000000000ULL) {928 *rv = val / 1000000000000000ULL;927 } else if (val > UINT64_C(1000000000000000000)) { 928 *rv = val / UINT64_C(1000000000000000); 929 929 *suffix = 'E'; 930 } else if (val > 1000000000000000ULL) {931 *rv = val / 1000000000000ULL;930 } else if (val > UINT64_C(1000000000000000)) { 931 *rv = val / UINT64_C(1000000000000); 932 932 *suffix = 'T'; 933 } else if (val > 1000000000000ULL) {934 *rv = val / 1000000000ULL;933 } else if (val > UINT64_C(1000000000000)) { 934 *rv = val / UINT64_C(1000000000); 935 935 *suffix = 'G'; 936 } else if (val > 1000000000ULL) {937 *rv = val / 1000000ULL;936 } else if (val > UINT64_C(1000000000)) { 937 *rv = val / UINT64_C(1000000); 938 938 *suffix = 'M'; 939 } else if (val > 1000000ULL) {940 *rv = val / 1000ULL;939 } else if (val > UINT64_C(1000000)) { 940 *rv = val / UINT64_C(1000); 941 941 *suffix = 'k'; 942 942 } else { … … 946 946 } 947 947 948 void bin_order_suffix(const uint64_t val, uint64_t *rv, const char **suffix, 949 bool fixed) 950 { 951 if (val > UINT64_C(1152921504606846976)) { 952 *rv = val / UINT64_C(1125899906842624); 953 *suffix = "EiB"; 954 } else if (val > UINT64_C(1125899906842624)) { 955 *rv = val / UINT64_C(1099511627776); 956 *suffix = "TiB"; 957 } else if (val > UINT64_C(1099511627776)) { 958 *rv = val / UINT64_C(1073741824); 959 *suffix = "GiB"; 960 } else if (val > UINT64_C(1073741824)) { 961 *rv = val / UINT64_C(1048576); 962 *suffix = "MiB"; 963 } else if (val > UINT64_C(1048576)) { 964 *rv = val / UINT64_C(1024); 965 *suffix = "KiB"; 966 } else { 967 *rv = val; 968 if (fixed) 969 *suffix = "B "; 970 else 971 *suffix = "B"; 972 } 973 } 974 948 975 /** @} 949 976 */ -
kernel/generic/src/main/main.c
r74c8f344 r933cadf 223 223 slab_enable_cpucache(); 224 224 225 printf("Detected %u CPU(s), %" PRIu64 " MiB free memory\n", 226 config.cpu_count, SIZE2MB(zones_total_size())); 225 uint64_t size; 226 const char *size_suffix; 227 bin_order_suffix(zones_total_size(), &size, &size_suffix, false); 228 printf("Detected %u CPU(s), %" PRIu64 " %s free memory\n", 229 config.cpu_count, size, size_suffix); 227 230 228 231 cpu_init(); -
kernel/generic/src/mm/frame.c
r74c8f344 r933cadf 60 60 #include <macros.h> 61 61 #include <config.h> 62 #include <str.h> 62 63 63 64 zones_t zones; … … 1395 1396 bool available = zone_flags_available(flags); 1396 1397 1398 uint64_t size; 1399 const char *size_suffix; 1400 bin_order_suffix(FRAMES2SIZE(count), &size, &size_suffix, false); 1401 1397 1402 printf("Zone number: %zu\n", znum); 1398 1403 printf("Zone base address: %p\n", (void *) base); 1399 printf("Zone size: %zu frames (% zu KiB)\n", count,1400 SIZE2KB(FRAMES2SIZE(count)));1404 printf("Zone size: %zu frames (%" PRIu64 " %s)\n", count, 1405 size, size_suffix); 1401 1406 printf("Zone flags: %c%c%c\n", 1402 1407 available ? 'A' : ' ', … … 1405 1410 1406 1411 if (available) { 1407 printf("Allocated space: %zu frames (%zu KiB)\n", 1408 busy_count, SIZE2KB(FRAMES2SIZE(busy_count))); 1409 printf("Available space: %zu frames (%zu KiB)\n", 1410 free_count, SIZE2KB(FRAMES2SIZE(free_count))); 1412 bin_order_suffix(FRAMES2SIZE(busy_count), &size, &size_suffix, 1413 false); 1414 printf("Allocated space: %zu frames (%" PRIu64 " %s)\n", 1415 busy_count, size, size_suffix); 1416 bin_order_suffix(FRAMES2SIZE(free_count), &size, &size_suffix, 1417 false); 1418 printf("Available space: %zu frames (%" PRIu64 " %s)\n", 1419 free_count, size, size_suffix); 1411 1420 } 1412 1421 } -
uspace/app/stats/stats.c
r74c8f344 r933cadf 69 69 size_t i; 70 70 for (i = 0; i < count; i++) { 71 uint64_t resmem, virtmem, ucycles, kcycles; 72 char resmem_suffix, virtmem_suffix, usuffix, ksuffix; 73 74 order_suffix(stats_tasks[i].resmem, &resmem, &resmem_suffix); 75 order_suffix(stats_tasks[i].virtmem, &virtmem, &virtmem_suffix); 71 uint64_t resmem; 72 uint64_t virtmem; 73 uint64_t ucycles; 74 uint64_t kcycles; 75 const char *resmem_suffix; 76 const char *virtmem_suffix; 77 char usuffix; 78 char ksuffix; 79 80 bin_order_suffix(stats_tasks[i].resmem, &resmem, &resmem_suffix, true); 81 bin_order_suffix(stats_tasks[i].virtmem, &virtmem, &virtmem_suffix, true); 76 82 order_suffix(stats_tasks[i].ucycles, &ucycles, &usuffix); 77 83 order_suffix(stats_tasks[i].kcycles, &kcycles, &ksuffix); 78 84 79 printf("%-8" PRIu64 " %7zu % 9" PRIu64 "%c %8" PRIu64 "%c"85 printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s %6" PRIu64 "%s" 80 86 " %8" PRIu64 "%c %8" PRIu64 "%c %s\n", 81 87 stats_tasks[i].task_id, stats_tasks[i].threads, -
uspace/app/top/screen.c
r74c8f344 r933cadf 254 254 uint64_t used; 255 255 uint64_t free; 256 c hartotal_suffix;257 c harunavail_suffix;258 c harused_suffix;259 c harfree_suffix;260 261 order_suffix(data->physmem->total, &total, &total_suffix);262 order_suffix(data->physmem->unavail, &unavail, &unavail_suffix);263 order_suffix(data->physmem->used, &used, &used_suffix);264 order_suffix(data->physmem->free, &free, &free_suffix);265 266 printf("memory: %" PRIu64 "% c total, %" PRIu64 "%cunavail, %"267 PRIu64 "% c used, %" PRIu64 "%cfree", total, total_suffix,256 const char *total_suffix; 257 const char *unavail_suffix; 258 const char *used_suffix; 259 const char *free_suffix; 260 261 bin_order_suffix(data->physmem->total, &total, &total_suffix, false); 262 bin_order_suffix(data->physmem->unavail, &unavail, &unavail_suffix, false); 263 bin_order_suffix(data->physmem->used, &used, &used_suffix, false); 264 bin_order_suffix(data->physmem->free, &free, &free_suffix, false); 265 266 printf("memory: %" PRIu64 "%s total, %" PRIu64 "%s unavail, %" 267 PRIu64 "%s used, %" PRIu64 "%s free", total, total_suffix, 268 268 unavail, unavail_suffix, used, used_suffix, free, free_suffix); 269 269 screen_newline(); … … 295 295 296 296 uint64_t resmem; 297 c harresmem_suffix;298 order_suffix(task->resmem, &resmem, &resmem_suffix);297 const char *resmem_suffix; 298 bin_order_suffix(task->resmem, &resmem, &resmem_suffix, true); 299 299 300 300 uint64_t virtmem; 301 c harvirtmem_suffix;302 order_suffix(task->virtmem, &virtmem, &virtmem_suffix);303 304 printf("%-8" PRIu64 " %7zu % 9" PRIu64 "%c",301 const char *virtmem_suffix; 302 bin_order_suffix(task->virtmem, &virtmem, &virtmem_suffix, true); 303 304 printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s ", 305 305 task->task_id, task->threads, resmem, resmem_suffix); 306 306 print_percent(perc->resmem, 2); 307 printf(" % 8" PRIu64 "%c", virtmem, virtmem_suffix);307 printf(" %6" PRIu64 "%s ", virtmem, virtmem_suffix); 308 308 print_percent(perc->virtmem, 2); 309 309 puts(" "); -
uspace/lib/c/generic/str.c
r74c8f344 r933cadf 1215 1215 void order_suffix(const uint64_t val, uint64_t *rv, char *suffix) 1216 1216 { 1217 if (val > 10000000000000000000ULL) {1218 *rv = val / 1000000000000000000ULL;1217 if (val > UINT64_C(10000000000000000000)) { 1218 *rv = val / UINT64_C(1000000000000000000); 1219 1219 *suffix = 'Z'; 1220 } else if (val > 1000000000000000000ULL) {1221 *rv = val / 1000000000000000ULL;1220 } else if (val > UINT64_C(1000000000000000000)) { 1221 *rv = val / UINT64_C(1000000000000000); 1222 1222 *suffix = 'E'; 1223 } else if (val > 1000000000000000ULL) {1224 *rv = val / 1000000000000ULL;1223 } else if (val > UINT64_C(1000000000000000)) { 1224 *rv = val / UINT64_C(1000000000000); 1225 1225 *suffix = 'T'; 1226 } else if (val > 1000000000000ULL) {1227 *rv = val / 1000000000ULL;1226 } else if (val > UINT64_C(1000000000000)) { 1227 *rv = val / UINT64_C(1000000000); 1228 1228 *suffix = 'G'; 1229 } else if (val > 1000000000ULL) {1230 *rv = val / 1000000ULL;1229 } else if (val > UINT64_C(1000000000)) { 1230 *rv = val / UINT64_C(1000000); 1231 1231 *suffix = 'M'; 1232 } else if (val > 1000000ULL) {1233 *rv = val / 1000ULL;1232 } else if (val > UINT64_C(1000000)) { 1233 *rv = val / UINT64_C(1000); 1234 1234 *suffix = 'k'; 1235 1235 } else { … … 1239 1239 } 1240 1240 1241 void bin_order_suffix(const uint64_t val, uint64_t *rv, const char **suffix, 1242 bool fixed) 1243 { 1244 if (val > UINT64_C(1152921504606846976)) { 1245 *rv = val / UINT64_C(1125899906842624); 1246 *suffix = "EiB"; 1247 } else if (val > UINT64_C(1125899906842624)) { 1248 *rv = val / UINT64_C(1099511627776); 1249 *suffix = "TiB"; 1250 } else if (val > UINT64_C(1099511627776)) { 1251 *rv = val / UINT64_C(1073741824); 1252 *suffix = "GiB"; 1253 } else if (val > UINT64_C(1073741824)) { 1254 *rv = val / UINT64_C(1048576); 1255 *suffix = "MiB"; 1256 } else if (val > UINT64_C(1048576)) { 1257 *rv = val / UINT64_C(1024); 1258 *suffix = "KiB"; 1259 } else { 1260 *rv = val; 1261 if (fixed) 1262 *suffix = "B "; 1263 else 1264 *suffix = "B"; 1265 } 1266 } 1267 1241 1268 /** @} 1242 1269 */ -
uspace/lib/c/include/macros.h
r74c8f344 r933cadf 39 39 #define max(a, b) ((a) > (b) ? (a) : (b)) 40 40 41 #define SIZE2KB(size) ((size) >> 10) 42 #define SIZE2MB(size) ((size) >> 20) 43 44 #define KB2SIZE(kb) ((kb) << 10) 45 #define MB2SIZE(mb) ((mb) << 20) 41 #define KiB2SIZE(kb) ((kb) << 10) 42 #define MiB2SIZE(mb) ((mb) << 20) 46 43 47 44 #define STRING(arg) STRING_ARG(arg) -
uspace/lib/c/include/str.h
r74c8f344 r933cadf 89 89 extern int str_size_t(const char *, char **, unsigned int, bool, size_t *); 90 90 91 extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix); 91 extern void order_suffix(const uint64_t, uint64_t *, char *); 92 extern void bin_order_suffix(const uint64_t, uint64_t *, const char **, bool); 92 93 93 94 /*
Note:
See TracChangeset
for help on using the changeset viewer.