- Timestamp:
- 2010-07-12T10:53:30Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bd11d3e
- Parents:
- c40e6ef (diff), bee2d4c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 1 added
- 3 deleted
- 24 edited
- 2 moved
-
app/top/screen.c (modified) (1 diff)
-
app/top/top.c (modified) (13 diffs)
-
app/top/top.h (modified) (3 diffs)
-
lib/c/Makefile (modified) (1 diff)
-
lib/c/arch/abs32le/include/types.h (modified) (1 diff)
-
lib/c/arch/amd64/include/types.h (modified) (1 diff)
-
lib/c/arch/arm32/include/types.h (modified) (1 diff)
-
lib/c/arch/ia32/include/types.h (modified) (1 diff)
-
lib/c/arch/ia64/include/types.h (modified) (1 diff)
-
lib/c/arch/ia64/src/entry.s (modified) (1 diff)
-
lib/c/arch/ia64/src/thread_entry.s (modified) (1 diff)
-
lib/c/arch/mips32/include/types.h (modified) (1 diff)
-
lib/c/arch/mips32eb/include/limits.h (deleted)
-
lib/c/arch/ppc32/include/limits.h (deleted)
-
lib/c/arch/ppc32/include/types.h (modified) (1 diff)
-
lib/c/arch/sparc64/include/limits.h (deleted)
-
lib/c/arch/sparc64/include/types.h (modified) (1 diff)
-
lib/c/generic/sort.c (added)
-
lib/c/generic/str.c (modified) (1 diff)
-
lib/c/include/sort.h (moved) (moved from uspace/lib/c/arch/ia64/include/limits.h ) (3 diffs)
-
lib/c/include/stdint.h (modified) (1 diff)
-
lib/c/include/trace.h (moved) (moved from uspace/lib/c/arch/ia32/include/limits.h ) (3 diffs)
-
lib/pci/types.h (modified) (1 diff)
-
lib/socket/generic/socket_client.c (modified) (1 diff)
-
lib/socket/generic/socket_core.c (modified) (1 diff)
-
lib/softfloat/generic/conversion.c (modified) (11 diffs)
-
lib/softint/generic/multiplication.c (modified) (3 diffs)
-
srv/fs/tmpfs/tmpfs_ops.c (modified) (1 diff)
-
srv/net/tl/icmp/icmp.c (modified) (3 diffs)
-
srv/vfs/vfs_ops.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/top/screen.c
rc40e6ef rbd48f4c 288 288 size_t i; 289 289 for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) { 290 stats_task_t *task = data->tasks + data->tasks_map[i]; 291 perc_task_t *perc = data->tasks_perc + data->tasks_map[i]; 292 290 293 uint64_t virtmem; 291 294 char virtmem_suffix; 292 order_suffix( data->tasks[i].virtmem, &virtmem, &virtmem_suffix);293 294 printf("%-8" PRIu64 " %9u %8" PRIu64 "%c ", data->tasks[i].task_id,295 data->tasks[i].threads, virtmem, virtmem_suffix);296 print_percent( data->tasks_perc[i].virtmem, 2);295 order_suffix(task->virtmem, &virtmem, &virtmem_suffix); 296 297 printf("%-8" PRIu64 " %9u %8" PRIu64 "%c ", task->task_id, 298 task->threads, virtmem, virtmem_suffix); 299 print_percent(perc->virtmem, 2); 297 300 puts(" "); 298 print_percent( data->tasks_perc[i].ucycles, 2);301 print_percent(perc->ucycles, 2); 299 302 puts(" "); 300 print_percent( data->tasks_perc[i].kcycles, 2);303 print_percent(perc->kcycles, 2); 301 304 puts(" "); 302 print_string( data->tasks[i].name);305 print_string(task->name); 303 306 304 307 screen_newline(); -
uspace/app/top/top.c
rc40e6ef rbd48f4c 44 44 #include <arch/barrier.h> 45 45 #include <errno.h> 46 #include <sort.h> 46 47 #include "screen.h" 47 48 #include "input.h" … … 57 58 58 59 op_mode_t op_mode = OP_TASKS; 60 sort_mode_t sort_mode = SORT_TASK_CYCLES; 59 61 bool excs_all = false; 60 62 … … 67 69 target->tasks = NULL; 68 70 target->tasks_perc = NULL; 71 target->tasks_map = NULL; 69 72 target->threads = NULL; 70 73 target->exceptions = NULL; 71 74 target->exceptions_perc = NULL; 72 75 target->physmem = NULL; 76 target->ucycles_diff = NULL; 77 target->kcycles_diff = NULL; 78 target->ecycles_diff = NULL; 79 target->ecount_diff = NULL; 73 80 74 81 /* Get current time */ … … 113 120 return "Not enough memory for task utilization"; 114 121 122 target->tasks_map = 123 (size_t *) calloc(target->tasks_count, sizeof(size_t)); 124 if (target->tasks_map == NULL) 125 return "Not enough memory for task map"; 126 115 127 /* Get threads */ 116 128 target->threads = stats_get_threads(&(target->threads_count)); … … 132 144 if (target->physmem == NULL) 133 145 return "Cannot get physical memory"; 146 147 target->ucycles_diff = calloc(target->tasks_count, 148 sizeof(uint64_t)); 149 if (target->ucycles_diff == NULL) 150 return "Not enough memory for user utilization"; 151 152 /* Allocate memory for computed values */ 153 target->kcycles_diff = calloc(target->tasks_count, 154 sizeof(uint64_t)); 155 if (target->kcycles_diff == NULL) 156 return "Not enough memory for kernel utilization"; 157 158 target->ecycles_diff = calloc(target->exceptions_count, 159 sizeof(uint64_t)); 160 if (target->ecycles_diff == NULL) 161 return "Not enough memory for exception cycles utilization"; 162 163 target->ecount_diff = calloc(target->exceptions_count, 164 sizeof(uint64_t)); 165 if (target->ecount_diff == NULL) 166 return "Not enough memory for exception count utilization"; 134 167 135 168 return NULL; … … 142 175 * 143 176 */ 144 static const char *compute_percentages(data_t *old_data, data_t *new_data) 145 { 146 /* Allocate memory */ 147 148 uint64_t *ucycles_diff = calloc(new_data->tasks_count, 149 sizeof(uint64_t)); 150 if (ucycles_diff == NULL) 151 return "Not enough memory for user utilization"; 152 153 uint64_t *kcycles_diff = calloc(new_data->tasks_count, 154 sizeof(uint64_t)); 155 if (kcycles_diff == NULL) { 156 free(ucycles_diff); 157 return "Not enough memory for kernel utilization"; 158 } 159 160 uint64_t *ecycles_diff = calloc(new_data->exceptions_count, 161 sizeof(uint64_t)); 162 if (ecycles_diff == NULL) { 163 free(ucycles_diff); 164 free(kcycles_diff); 165 return "Not enough memory for exception cycles utilization"; 166 } 167 168 uint64_t *ecount_diff = calloc(new_data->exceptions_count, 169 sizeof(uint64_t)); 170 if (ecount_diff == NULL) { 171 free(ucycles_diff); 172 free(kcycles_diff); 173 free(ecycles_diff); 174 return "Not enough memory for exception count utilization"; 175 } 176 177 static void compute_percentages(data_t *old_data, data_t *new_data) 178 { 177 179 /* For each CPU: Compute total cycles and divide it between 178 180 user and kernel */ … … 210 212 if (!found) { 211 213 /* This is newly borned task, ignore it */ 212 ucycles_diff[i] = 0;213 kcycles_diff[i] = 0;214 new_data->ucycles_diff[i] = 0; 215 new_data->kcycles_diff[i] = 0; 214 216 continue; 215 217 } 216 218 217 ucycles_diff[i] =219 new_data->ucycles_diff[i] = 218 220 new_data->tasks[i].ucycles - old_data->tasks[j].ucycles; 219 kcycles_diff[i] =221 new_data->kcycles_diff[i] = 220 222 new_data->tasks[i].kcycles - old_data->tasks[j].kcycles; 221 223 222 224 virtmem_total += new_data->tasks[i].virtmem; 223 ucycles_total += ucycles_diff[i];224 kcycles_total += kcycles_diff[i];225 ucycles_total += new_data->ucycles_diff[i]; 226 kcycles_total += new_data->kcycles_diff[i]; 225 227 } 226 228 … … 231 233 new_data->tasks[i].virtmem * 100, virtmem_total); 232 234 FRACTION_TO_FLOAT(new_data->tasks_perc[i].ucycles, 233 ucycles_diff[i] * 100, ucycles_total);235 new_data->ucycles_diff[i] * 100, ucycles_total); 234 236 FRACTION_TO_FLOAT(new_data->tasks_perc[i].kcycles, 235 kcycles_diff[i] * 100, kcycles_total);237 new_data->kcycles_diff[i] * 100, kcycles_total); 236 238 } 237 239 … … 259 261 if (!found) { 260 262 /* This is a new exception, ignore it */ 261 ecycles_diff[i] = 0;262 ecount_diff[i] = 0;263 new_data->ecycles_diff[i] = 0; 264 new_data->ecount_diff[i] = 0; 263 265 continue; 264 266 } 265 267 266 ecycles_diff[i] =268 new_data->ecycles_diff[i] = 267 269 new_data->exceptions[i].cycles - old_data->exceptions[j].cycles; 268 ecount_diff[i] =270 new_data->ecount_diff[i] = 269 271 new_data->exceptions[i].count - old_data->exceptions[i].count; 270 272 271 ecycles_total += ecycles_diff[i];272 ecount_total += ecount_diff[i];273 ecycles_total += new_data->ecycles_diff[i]; 274 ecount_total += new_data->ecount_diff[i]; 273 275 } 274 276 … … 277 279 for (i = 0; i < new_data->exceptions_count; i++) { 278 280 FRACTION_TO_FLOAT(new_data->exceptions_perc[i].cycles, 279 ecycles_diff[i] * 100, ecycles_total);281 new_data->ecycles_diff[i] * 100, ecycles_total); 280 282 FRACTION_TO_FLOAT(new_data->exceptions_perc[i].count, 281 ecount_diff[i] * 100, ecount_total); 282 } 283 284 /* Cleanup */ 285 286 free(ucycles_diff); 287 free(kcycles_diff); 288 free(ecycles_diff); 289 free(ecount_diff); 290 291 return NULL; 283 new_data->ecount_diff[i] * 100, ecount_total); 284 } 285 } 286 287 static int cmp_data(void *a, void *b, void *arg) 288 { 289 size_t ia = *((size_t *) a); 290 size_t ib = *((size_t *) b); 291 data_t *data = (data_t *) arg; 292 293 uint64_t acycles = data->ucycles_diff[ia] + data->kcycles_diff[ia]; 294 uint64_t bcycles = data->ucycles_diff[ib] + data->kcycles_diff[ib]; 295 296 if (acycles > bcycles) 297 return -1; 298 299 if (acycles < bcycles) 300 return 1; 301 302 return 0; 303 } 304 305 static void sort_data(data_t *data) 306 { 307 size_t i; 308 309 for (i = 0; i < data->tasks_count; i++) 310 data->tasks_map[i] = i; 311 312 qsort((void *) data->tasks_map, data->tasks_count, 313 sizeof(size_t), cmp_data, (void *) data); 292 314 } 293 315 … … 320 342 if (target->physmem != NULL) 321 343 free(target->physmem); 344 345 if (target->ucycles_diff != NULL) 346 free(target->ucycles_diff); 347 348 if (target->kcycles_diff != NULL) 349 free(target->kcycles_diff); 350 351 if (target->ecycles_diff != NULL) 352 free(target->ecycles_diff); 353 354 if (target->ecount_diff != NULL) 355 free(target->ecount_diff); 322 356 } 323 357 … … 335 369 336 370 /* Compute some rubbish to have initialised values */ 337 if ((ret = compute_percentages(&data_prev, &data_prev)) != NULL) 338 goto out; 371 compute_percentages(&data_prev, &data_prev); 339 372 340 373 /* And paint screen until death */ … … 347 380 } 348 381 349 if ((ret = compute_percentages(&data_prev, &data)) != NULL) { 350 free_data(&data); 351 goto out; 352 } 353 382 compute_percentages(&data_prev, &data); 383 sort_data(&data); 354 384 print_data(&data); 355 385 free_data(&data_prev); -
uspace/app/top/top.h
rc40e6ef rbd48f4c 57 57 } op_mode_t; 58 58 59 typedef enum { 60 SORT_TASK_CYCLES 61 } sort_mode_t; 62 59 63 extern op_mode_t op_mode; 64 extern sort_mode_t sort_mode; 60 65 extern bool excs_all; 61 66 … … 101 106 stats_task_t *tasks; 102 107 perc_task_t *tasks_perc; 108 size_t *tasks_map; 103 109 104 110 size_t threads_count; … … 110 116 111 117 stats_physmem_t *physmem; 118 119 uint64_t *ucycles_diff; 120 uint64_t *kcycles_diff; 121 uint64_t *ecycles_diff; 122 uint64_t *ecount_diff; 112 123 } data_t; 113 124 -
uspace/lib/c/Makefile
rc40e6ef rbd48f4c 97 97 generic/stacktrace.c \ 98 98 generic/arg_parse.c \ 99 generic/sort.c \ 99 100 generic/stats.c 100 101 -
uspace/lib/c/arch/abs32le/include/types.h
rc40e6ef rbd48f4c 40 40 #include <libarch/common.h> 41 41 42 #define SIZE_MIN UINT32_MIN 43 #define SIZE_MAX UINT32_MAX 44 45 #define SSIZE_MIN INT32_MIN 46 #define SSIZE_MAX INT32_MAX 47 42 48 typedef uint32_t sysarg_t; 43 49 -
uspace/lib/c/arch/amd64/include/types.h
rc40e6ef rbd48f4c 40 40 #include <libarch/common.h> 41 41 42 #define SIZE_MIN UINT64_MIN 43 #define SIZE_MAX UINT64_MAX 44 45 #define SSIZE_MIN INT64_MIN 46 #define SSIZE_MAX INT64_MAX 47 42 48 typedef uint64_t sysarg_t; 43 49 -
uspace/lib/c/arch/arm32/include/types.h
rc40e6ef rbd48f4c 41 41 #include <libarch/common.h> 42 42 43 #define SIZE_MIN UINT32_MIN 44 #define SIZE_MAX UINT32_MAX 45 46 #define SSIZE_MIN INT32_MIN 47 #define SSIZE_MAX INT32_MAX 48 43 49 typedef uint32_t sysarg_t; 44 50 -
uspace/lib/c/arch/ia32/include/types.h
rc40e6ef rbd48f4c 40 40 #include <libarch/common.h> 41 41 42 #define SIZE_MIN UINT32_MIN 43 #define SIZE_MAX UINT32_MAX 44 45 #define SSIZE_MIN INT32_MIN 46 #define SSIZE_MAX INT32_MAX 47 42 48 typedef uint32_t sysarg_t; 43 49 -
uspace/lib/c/arch/ia64/include/types.h
rc40e6ef rbd48f4c 40 40 #include <libarch/common.h> 41 41 42 #define SIZE_MIN UINT64_MIN 43 #define SIZE_MAX UINT64_MAX 44 45 #define SSIZE_MIN INT64_MIN 46 #define SSIZE_MAX INT64_MAX 47 42 48 typedef struct { 43 49 uint64_t lo; -
uspace/lib/c/arch/ia64/src/entry.s
rc40e6ef rbd48f4c 39 39 __entry: 40 40 alloc loc0 = ar.pfs, 0, 1, 2, 0 41 movl r1= _gp41 movl gp = _gp 42 42 43 43 # Pass PCB pointer as the first argument to __main -
uspace/lib/c/arch/ia64/src/thread_entry.s
rc40e6ef rbd48f4c 37 37 alloc loc0 = ar.pfs, 0, 1, 1, 0 38 38 39 movl r1= _gp39 movl gp = _gp 40 40 41 41 # -
uspace/lib/c/arch/mips32/include/types.h
rc40e6ef rbd48f4c 41 41 #include <libarch/common.h> 42 42 43 #define SIZE_MIN UINT32_MIN 44 #define SIZE_MAX UINT32_MAX 45 46 #define SSIZE_MIN INT32_MIN 47 #define SSIZE_MAX INT32_MAX 48 43 49 typedef uint32_t sysarg_t; 44 50 -
uspace/lib/c/arch/ppc32/include/types.h
rc40e6ef rbd48f4c 40 40 #include <libarch/common.h> 41 41 42 #define SIZE_MIN UINT32_MIN 43 #define SIZE_MAX UINT32_MAX 44 45 #define SSIZE_MIN INT32_MIN 46 #define SSIZE_MAX INT32_MAX 47 42 48 typedef uint32_t sysarg_t; 43 49 -
uspace/lib/c/arch/sparc64/include/types.h
rc40e6ef rbd48f4c 40 40 #include <libarch/common.h> 41 41 42 #define SIZE_MIN UINT64_MIN 43 #define SIZE_MAX UINT64_MAX 44 45 #define SSIZE_MIN INT64_MIN 46 #define SSIZE_MAX INT64_MAX 47 42 48 typedef uint64_t sysarg_t; 43 49 -
uspace/lib/c/generic/str.c
rc40e6ef rbd48f4c 37 37 #include <stdlib.h> 38 38 #include <assert.h> 39 #include < limits.h>39 #include <stdint.h> 40 40 #include <ctype.h> 41 41 #include <malloc.h> -
uspace/lib/c/include/sort.h
rc40e6ef rbd48f4c 1 1 /* 2 * Copyright (c) 200 6 Josef Cejka2 * Copyright (c) 2005 Sergey Bondari 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc ia6429 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef LIBC_ ia64_LIMITS_H_36 #define LIBC_ ia64_LIMITS_H_35 #ifndef LIBC_SORT_H_ 36 #define LIBC_SORT_H_ 37 37 38 #define LONG_MIN MIN_INT64 39 #define LONG_MAX MAX_INT64 40 #define ULONG_MIN MIN_UINT64 41 #define ULONG_MAX MAX_UINT64 38 #include <sys/types.h> 39 #include <bool.h> 42 40 43 #define SIZE_MIN MIN_UINT64 44 #define SIZE_MAX MAX_UINT64 45 #define SSIZE_MIN MIN_INT64 46 #define SSIZE_MAX MAX_INT64 41 typedef int (* sort_cmp_t)(void *, void *, void *); 42 43 extern bool gsort(void *, size_t, size_t, sort_cmp_t, void *); 44 extern bool qsort(void *, size_t, size_t, sort_cmp_t, void *); 47 45 48 46 #endif -
uspace/lib/c/include/stdint.h
rc40e6ef rbd48f4c 36 36 #define LIBC_STDINT_H_ 37 37 38 /* Definitions of types with fixed size */ 38 #define INT8_MIN (0x80) 39 #define INT8_MAX (0x7F) 40 41 #define UINT8_MIN (0u) 42 #define UINT8_MAX (0xFFu) 43 44 #define INT16_MIN (0x8000) 45 #define INT16_MAX (0x7FFF) 46 47 #define UINT16_MIN (0u) 48 #define UINT16_MAX (0xFFFFu) 49 50 #define INT32_MIN (0x80000000l) 51 #define INT32_MAX (0x7FFFFFFFl) 52 53 #define UINT32_MIN (0ul) 54 #define UINT32_MAX (0xFFFFFFFFul) 55 56 #define INT64_MIN (0x8000000000000000ll) 57 #define INT64_MAX (0x7FFFFFFFFFFFFFFFll) 58 59 #define UINT64_MIN (0ull) 60 #define UINT64_MAX (0xFFFFFFFFFFFFFFFFull) 61 39 62 #include <libarch/types.h> 40 63 41 #define MAX_INT8 (0x7F) 42 #define MIN_INT8 (0x80) 43 #define MAX_UINT8 (0xFFu) 44 #define MIN_UINT8 (0u) 64 /* off64_t */ 65 #define OFF64_MIN INT64_MIN 66 #define OFF64_MAX INT64_MAX 45 67 46 #define MAX_INT16 (0x7FFF) 47 #define MIN_INT16 (0x8000) 48 #define MAX_UINT16 (0xFFFFu) 49 #define MIN_UINT16 (0u) 50 51 #define MAX_INT32 (0x7FFFFFFF) 52 #define MIN_INT32 (0x80000000) 53 #define MAX_UINT32 (0xFFFFFFFFu) 54 #define MIN_UINT32 (0u) 55 56 #define MAX_INT64 (0x7FFFFFFFFFFFFFFFll) 57 #define MIN_INT64 (0x8000000000000000ll) 58 #define MAX_UINT64 (0xFFFFFFFFFFFFFFFFull) 59 #define MIN_UINT64 (0ull) 68 /* aoff64_t */ 69 #define AOFF64_MIN UINT64_MIN 70 #define AOFF64_MAX UINT64_MAX 60 71 61 72 #endif -
uspace/lib/c/include/trace.h
rc40e6ef rbd48f4c 1 1 /* 2 * Copyright (c) 20 06 Josef Cejka2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc ia3229 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef LIBC_ ia32__LIMITS_H_36 #define LIBC_ ia32__LIMITS_H_35 #ifndef LIBC_TRACE_H_ 36 #define LIBC_TRACE_H_ 37 37 38 #define LONG_MIN MIN_INT32 39 #define LONG_MAX MAX_INT32 40 #define ULONG_MIN MIN_UINT32 41 #define ULONG_MAX MAX_UINT32 42 43 #define SIZE_MIN MIN_UINT32 44 #define SIZE_MAX MAX_UINT32 45 #define SSIZE_MIN MIN_INT32 46 #define SSIZE_MAX MAX_INT32 38 #define NO_TRACE __attribute__((no_instrument_function)) 47 39 48 40 #endif -
uspace/lib/pci/types.h
rc40e6ef rbd48f4c 18 18 19 19 #ifdef PCI_HAVE_64BIT_ADDRESS 20 #include <limits.h> 20 21 #include <stdint.h> 22 21 23 #if ULONG_MAX > 0xffffffff 24 22 25 typedef unsigned long u64; 23 26 #define PCI_U64_FMT "l" 24 #else 27 28 #else /* ULONG_MAX > 0xffffffff */ 29 25 30 typedef unsigned long long u64; 26 31 #define PCI_U64_FMT "ll" 27 #endif28 #endif29 32 30 #endif /* PCI_HAVE_Uxx_TYPES */ 33 #endif /* ULONG_MAX > 0xffffffff */ 34 #endif /* PCI_HAVE_64BIT_ADDRESS */ 35 #endif /* PCI_HAVE_Uxx_TYPES */ 31 36 32 37 #ifdef PCI_HAVE_64BIT_ADDRESS 38 33 39 typedef u64 pciaddr_t; 34 40 #define PCIADDR_T_FMT "%08" PCI_U64_FMT "x" 35 41 #define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x" 36 #else 42 43 #else /* PCI_HAVE_64BIT_ADDRESS */ 44 37 45 typedef u32 pciaddr_t; 38 46 #define PCIADDR_T_FMT "%08x" 39 47 #define PCIADDR_PORT_FMT "%04x" 40 #endif 48 49 #endif /* PCI_HAVE_64BIT_ADDRESS */ 41 50 42 51 #ifdef PCI_ARCH_SPARC64 52 43 53 /* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */ 44 54 #undef PCIADDR_PORT_FMT 45 55 #define PCIADDR_PORT_FMT PCIADDR_T_FMT 46 56 #define PCIIRQ_FMT "%08x" 47 #else 57 58 #else /* PCI_ARCH_SPARC64 */ 59 48 60 #define PCIIRQ_FMT "%d" 49 #endif 61 62 #endif /* PCI_ARCH_SPARC64 */ -
uspace/lib/socket/generic/socket_client.c
rc40e6ef rbd48f4c 40 40 #include <async.h> 41 41 #include <fibril_synch.h> 42 #include < limits.h>42 #include <stdint.h> 43 43 #include <stdlib.h> 44 44 -
uspace/lib/socket/generic/socket_core.c
rc40e6ef rbd48f4c 35 35 */ 36 36 37 #include < limits.h>37 #include <stdint.h> 38 38 #include <stdlib.h> 39 39 -
uspace/lib/softfloat/generic/conversion.c
rc40e6ef rbd48f4c 27 27 */ 28 28 29 /** @addtogroup softfloat 29 /** @addtogroup softfloat 30 30 * @{ 31 31 */ … … 45 45 result.parts.sign = a.parts.sign; 46 46 result.parts.fraction = a.parts.fraction; 47 result.parts.fraction <<= (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE );48 49 if ((isFloat32Infinity(a)) ||(isFloat32NaN(a))) {47 result.parts.fraction <<= (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE); 48 49 if ((isFloat32Infinity(a)) || (isFloat32NaN(a))) { 50 50 result.parts.exp = 0x7FF; 51 51 /* TODO; check if its correct for SigNaNs*/ … … 53 53 }; 54 54 55 result.parts.exp = a.parts.exp + ( (int)FLOAT64_BIAS - FLOAT32_BIAS);55 result.parts.exp = a.parts.exp + ((int) FLOAT64_BIAS - FLOAT32_BIAS); 56 56 if (a.parts.exp == 0) { 57 57 /* normalize denormalized numbers */ … … 181 181 uint32_t float32_to_uint32(float32 a) 182 182 { 183 if (isFloat32NaN(a)) { 184 return MAX_UINT32; 185 } 186 187 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) { 188 if (a.parts.sign) { 189 return MIN_UINT32; 190 } 191 return MAX_UINT32; 192 } 193 194 return _float32_to_uint32_helper(a); 183 if (isFloat32NaN(a)) 184 return UINT32_MAX; 185 186 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) { 187 if (a.parts.sign) 188 return UINT32_MIN; 189 190 return UINT32_MAX; 191 } 192 193 return _float32_to_uint32_helper(a); 195 194 } 196 195 … … 201 200 int32_t float32_to_int32(float32 a) 202 201 { 203 if (isFloat32NaN(a)) {204 return MAX_INT32;205 }206 207 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) {208 if (a.parts.sign) {209 return MIN_INT32;210 }211 return MAX_INT32;212 }202 if (isFloat32NaN(a)) 203 return INT32_MAX; 204 205 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) { 206 if (a.parts.sign) 207 return INT32_MIN; 208 209 return INT32_MAX; 210 } 211 213 212 return _float32_to_uint32_helper(a); 214 } 213 } 215 214 216 215 … … 249 248 uint64_t float64_to_uint64(float64 a) 250 249 { 251 if (isFloat64NaN(a)) {252 return MAX_UINT64;253 }254 255 if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) {256 if (a.parts.sign) {257 return MIN_UINT64;258 }259 return MAX_UINT64;260 } 261 262 return _float64_to_uint64_helper(a); 250 if (isFloat64NaN(a)) 251 return UINT64_MAX; 252 253 254 if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) { 255 if (a.parts.sign) 256 return UINT64_MIN; 257 258 return UINT64_MAX; 259 } 260 261 return _float64_to_uint64_helper(a); 263 262 } 264 263 … … 269 268 int64_t float64_to_int64(float64 a) 270 269 { 271 if (isFloat64NaN(a)) { 272 return MAX_INT64; 273 } 274 275 if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) { 276 if (a.parts.sign) { 277 return MIN_INT64; 278 } 279 return MAX_INT64; 280 } 270 if (isFloat64NaN(a)) 271 return INT64_MAX; 272 273 274 if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) { 275 if (a.parts.sign) 276 return INT64_MIN; 277 278 return INT64_MAX; 279 } 280 281 281 return _float64_to_uint64_helper(a); 282 } 282 } 283 283 284 284 … … 320 320 uint64_t float32_to_uint64(float32 a) 321 321 { 322 if (isFloat32NaN(a)) {323 return MAX_UINT64;324 }325 326 if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) {327 if (a.parts.sign) {328 return MIN_UINT64;329 }330 return MAX_UINT64;331 } 332 333 return _float32_to_uint64_helper(a); 322 if (isFloat32NaN(a)) 323 return UINT64_MAX; 324 325 326 if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) { 327 if (a.parts.sign) 328 return UINT64_MIN; 329 330 return UINT64_MAX; 331 } 332 333 return _float32_to_uint64_helper(a); 334 334 } 335 335 … … 340 340 int64_t float32_to_int64(float32 a) 341 341 { 342 if (isFloat32NaN(a)) {343 return MAX_INT64;344 }345 346 if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) {347 if (a.parts.sign) {348 return (MIN_INT64);349 }350 return MAX_INT64;351 }342 if (isFloat32NaN(a)) 343 return INT64_MAX; 344 345 if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) { 346 if (a.parts.sign) 347 return INT64_MIN; 348 349 return INT64_MAX; 350 } 351 352 352 return _float32_to_uint64_helper(a); 353 } 353 } 354 354 355 355 … … 360 360 uint32_t float64_to_uint32(float64 a) 361 361 { 362 if (isFloat64NaN(a)) {363 return MAX_UINT32;364 }365 366 if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) {367 if (a.parts.sign) {368 return MIN_UINT32;369 }370 return MAX_UINT32;371 } 372 373 return (uint32_t) _float64_to_uint64_helper(a);362 if (isFloat64NaN(a)) 363 return UINT32_MAX; 364 365 366 if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) { 367 if (a.parts.sign) 368 return UINT32_MIN; 369 370 return UINT32_MAX; 371 } 372 373 return (uint32_t) _float64_to_uint64_helper(a); 374 374 } 375 375 … … 380 380 int32_t float64_to_int32(float64 a) 381 381 { 382 if (isFloat64NaN(a)) { 383 return MAX_INT32; 384 } 385 386 if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) { 387 if (a.parts.sign) { 388 return MIN_INT32; 389 } 390 return MAX_INT32; 391 } 392 return (int32_t)_float64_to_uint64_helper(a); 393 } 382 if (isFloat64NaN(a)) 383 return INT32_MAX; 384 385 386 if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) { 387 if (a.parts.sign) 388 return INT32_MIN; 389 390 return INT32_MAX; 391 } 392 393 return (int32_t) _float64_to_uint64_helper(a); 394 } 394 395 395 396 /** Convert unsigned integer to float32 -
uspace/lib/softint/generic/multiplication.c
rc40e6ef rbd48f4c 29 29 /** @addtogroup softint 30 30 * @{ 31 */ 31 */ 32 32 /** 33 33 * @file … … 36 36 37 37 #include <multiplication.h> 38 #include <stdint.h> 38 #include <stdint.h> 39 39 40 /** Set 1 to return MAX_INT64 or MIN_INT64on overflow */40 /** Set 1 to return INT64_MAX or INT64_MIN on overflow */ 41 41 #ifndef SOFTINT_CHECK_OF 42 # define SOFTINT_CHECK_OF042 #define SOFTINT_CHECK_OF 0 43 43 #endif 44 44 45 /** 46 * Multiply two integers and return long long as result.45 /** Multiply two integers and return long long as result. 46 * 47 47 * This function is overflow safe. 48 * @param a 49 * @param b 50 * @result 48 * 51 49 */ 52 50 static unsigned long long mul(unsigned int a, unsigned int b) { 53 unsigned int a1, a2, b1, b2; 54 unsigned long long t1, t2, t3; 55 56 a1 = a >> 16; 57 a2 = a & MAX_UINT16; 58 b1 = b >> 16; 59 b2 = b & MAX_UINT16; 60 61 t1 = a1 * b1; 62 t2 = a1*b2; 63 t2 += a2*b1; 64 t3 = a2*b2; 65 66 t3 = (((t1 << 16) + t2) << 16) + t3; 67 51 unsigned int a1 = a >> 16; 52 unsigned int a2 = a & UINT16_MAX; 53 unsigned int b1 = b >> 16; 54 unsigned int b2 = b & UINT16_MAX; 55 56 unsigned long long t1 = a1 * b1; 57 unsigned long long t2 = a1 * b2; 58 t2 += a2 * b1; 59 unsigned long long t3 = a2 * b2; 60 61 t3 = (((t1 << 16) + t2) << 16) + t3; 62 68 63 return t3; 69 64 } … … 74 69 long long __muldi3 (long long a, long long b) 75 70 { 76 long long result;77 unsigned long long t1,t2;78 unsigned long long a1, a2, b1, b2;79 71 char neg = 0; 80 72 81 73 if (a < 0) { 82 74 neg = !neg; 83 75 a = -a; 84 76 } 85 77 86 78 if (b < 0) { 87 79 neg = !neg; 88 80 b = -b; 89 81 } 90 91 a1 = a >> 32;92 b1 = b >> 32;93 94 a2 = a & (MAX_UINT32);95 b2 = b & (MAX_UINT32);96 82 83 unsigned long long a1 = a >> 32; 84 unsigned long long b1 = b >> 32; 85 86 unsigned long long a2 = a & (UINT32_MAX); 87 unsigned long long b2 = b & (UINT32_MAX); 88 97 89 if (SOFTINT_CHECK_OF && (a1 != 0) && (b1 != 0)) { 98 / / error, overflow99 return (neg ?MIN_INT64:MAX_INT64);90 /* Error (overflow) */ 91 return (neg ? INT64_MIN : INT64_MAX); 100 92 } 101 102 // (if OF checked) a1 or b1 is zero => result fits in 64 bits, no need to another overflow check 103 t1 = mul(a1,b2) + mul(b1,a2); 104 105 if (SOFTINT_CHECK_OF && t1 > MAX_UINT32) { 106 // error, overflow 107 return (neg?MIN_INT64:MAX_INT64); 93 94 /* (if OF checked) a1 or b1 is zero => result fits in 64 bits, 95 * no need to another overflow check 96 */ 97 unsigned long long t1 = mul(a1, b2) + mul(b1, a2); 98 99 if ((SOFTINT_CHECK_OF) && (t1 > UINT32_MAX)) { 100 /* Error (overflow) */ 101 return (neg ? INT64_MIN : INT64_MAX); 108 102 } 109 103 110 104 t1 = t1 << 32; 111 t2 = mul(a2,b2);105 unsigned long long t2 = mul(a2, b2); 112 106 t2 += t1; 113 107 114 108 /* t2 & (1ull << 63) - if this bit is set in unsigned long long, 115 109 * result does not fit in signed one */ 116 110 if (SOFTINT_CHECK_OF && ((t2 < t1) || (t2 & (1ull << 63)))) { 117 111 // error, overflow 118 return (neg ?MIN_INT64:MAX_INT64);112 return (neg ? INT64_MIN : INT64_MAX); 119 113 } 120 121 result = t2; 122 123 if (neg) { 114 115 long long result = t2; 116 if (neg) 124 117 result = -result; 125 } 126 118 127 119 return result; 128 } 120 } 129 121 130 122 /** @} -
uspace/srv/fs/tmpfs/tmpfs_ops.c
rc40e6ef rbd48f4c 41 41 #include <ipc/ipc.h> 42 42 #include <macros.h> 43 #include < limits.h>43 #include <stdint.h> 44 44 #include <async.h> 45 45 #include <errno.h> -
uspace/srv/net/tl/icmp/icmp.c
rc40e6ef rbd48f4c 98 98 /** Free identifier numbers pool end. 99 99 */ 100 #define ICMP_FREE_IDS_END MAX_UINT16100 #define ICMP_FREE_IDS_END UINT16_MAX 101 101 102 102 /** Computes the ICMP datagram checksum. … … 263 263 }else{ 264 264 res = icmp_echo(echo_data->identifier, echo_data->sequence_number, size, timeout, ttl, tos, dont_fragment, addr, addrlen); 265 if(echo_data->sequence_number < MAX_UINT16){265 if(echo_data->sequence_number < UINT16_MAX){ 266 266 ++ echo_data->sequence_number; 267 267 }else{ … … 731 731 fibril_rwlock_write_unlock(&icmp_globals.lock); 732 732 free(addr); 733 if(echo_data->sequence_number < MAX_UINT16){733 if(echo_data->sequence_number < UINT16_MAX){ 734 734 ++ echo_data->sequence_number; 735 735 }else{ -
uspace/srv/vfs/vfs_ops.c
rc40e6ef rbd48f4c 39 39 #include <ipc/ipc.h> 40 40 #include <macros.h> 41 #include < limits.h>41 #include <stdint.h> 42 42 #include <async.h> 43 43 #include <errno.h>
Note:
See TracChangeset
for help on using the changeset viewer.
