diff --git a/utils/utils.c b/utils/utils.c index fe9bd3cae55cba1924fe524f1e1fd73959c0e275..9bab73cc467e544cacc17ca7f89f41ced8cad3ce 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -21,9 +21,14 @@ double timestamp(void) return((double)(tp.tv_sec*1.0e3 + tp.tv_nsec*1.0e-6)); } +/* Gera string '<baseName>_n' + * Por exemplo, se baseName = "ABC" e n = 10, + * Função retorna a string "ABC_10" + * Útil para gerar marcadores para LIKWID + */ string_t markerName(string_t baseName, int n) { - string_t mark = (string_t) malloc( (strlen(baseName)+1) + (log10(n)+1) + 1 ); + string_t mark = (string_t) malloc( (strlen(baseName)+1) + ( (int) log10(n) + 1) + 1 ); sprintf(mark, "%s_%u", baseName,n); @@ -34,6 +39,10 @@ string_t markerName(string_t baseName, int n) } /* +// Retorna TRUE se 'n' é uma potência de 2 +// [OBSOLETO] +// Definida macro em 'utils.h' para substituir esta função +// int isPot2(int n) { int k; diff --git a/utils/utils.h b/utils/utils.h index b48f3c28f9784945b926fdf7e8c14ec57557cd72..6e4dde80e696d77fafcdf1c795bb3582160c4bbc 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -14,11 +14,11 @@ typedef char * string_t; #define ALIGN_32 __attribute__((aligned(32))) #define ALIGN_16 __attribute__((aligned(16))) +// Macro para verificar de valor 'n' é potência de 2 ou não +#define isPot2(n) (n && !(n & (n - 1))) + double timestamp(void); string_t markerName(string_t baseName, int n); -// int isPot2 (int n); - -#define isPot2(n) (n && !(n & (n - 1))) #endif // __UTILS_H__