1 /***************************************************************************
2 utils.h - some utility funtions
4 begin : lun ott 24 2005
5 copyright : (C) 2005-2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
28 #define SWITCH(a, b) ({ typeof(a) tmp = b; b = a; a = tmp; })
29 #define MAX(a,b) ({ typeof(a) _a=(a); typeof(b) _b=(b); _a > _b ? _a : _b; })
30 #define MIN(a,b) ({ typeof(a) _a=(a); typeof(b) _b=(b); _a < _b ? _a : _b; })
31 #define ABS(a) ({ typeof(a) _a=(a); _a > 0 ? _a : -_a; })
39 #define PROF(f,n) {uint64_t tmp = rdtsc(); f; prof_##n += rdtsc()-tmp; }
41 char **tokenize(const char *str
, int* numtokens
= NULL
, bool accept_quotes
= true);
42 char **tokenize(const char *str
, const char *whitespaces
, int* numtokens
= NULL
, bool accept_quotes
= true);
44 char **get_tokenized(int* numtokens
= NULL
, bool accept_quotes
= true);
45 char **get_tokenized(const char *whitespaces
, int* numtokens
= NULL
, bool accept_quotes
= true);
46 char **fget_tokenized(FILE* f
, int* numtokens
= NULL
, bool accept_quotes
= true);
47 char **fget_tokenized(FILE* f
, const char *whitespaces
, int* numtokens
= NULL
, bool accept_quotes
= true);