/contrib/timer-wheel/

, or (at your option) any later version. GlusterFS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _COMMON_UTILS_H #define _COMMON_UTILS_H #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #ifndef GF_BSD_HOST_OS #include #endif void trap (void); #define GF_UNIVERSAL_ANSWER 42 /* :O */ /* To solve type punned error */ #define VOID(ptr) ((void **) ((void *) ptr)) #include "logging.h" #include "glusterfs.h" #include "locking.h" #include "mem-pool.h" #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) #define roof(a,b) ((((a)+(b)-1)/((b)?(b):1))*(b)) #define floor(a,b) (((a)/((b)?(b):1))*(b)) #define GF_UNIT_KB 1024ULL #define GF_UNIT_MB 1048576ULL #define GF_UNIT_GB 1073741824ULL #define GF_UNIT_TB 1099511627776ULL #define GF_UNIT_PB 1125899906842624ULL #define GF_UNIT_KB_STRING "KB" #define GF_UNIT_MB_STRING "MB" #define GF_UNIT_GB_STRING "GB" #define GF_UNIT_TB_STRING "TB" #define GF_UNIT_PB_STRING "PB" #define ERR_ABORT(ptr) \ if (ptr == NULL) { \ abort (); \ } enum _gf_boolean { _gf_false = 0, _gf_true = 1 }; typedef enum _gf_boolean gf_boolean_t; void gf_global_variable_init(void); void set_global_ctx_ptr (glusterfs_ctx_t *ctx); glusterfs_ctx_t *get_global_ctx_ptr (void); in_addr_t gf_resolve_ip (const char *hostname, void **dnscache); void gf_log_volume_file (FILE *specfp); void gf_print_trace (int32_t signal); extern char *gf_fop_list[GF_FOP_MAXVALUE]; extern char *gf_mop_list[GF_MOP_MAXVALUE]; extern char *gf_cbk_list[GF_CBK_MAXVALUE]; #define VECTORSIZE(count) (count * (sizeof (struct iovec))) #define STRLEN_0(str) (strlen(str) + 1) #define VALIDATE_OR_GOTO(arg,label) do { \ if (!arg) { \ errno = EINVAL; \ gf_log ((this ? this->name : "(Govinda! Govinda!)"), \ GF_LOG_ERROR, \ "invalid argument: " #arg); \ goto label; \ } \ } while (0); #define GF_VALIDATE_OR_GOTO(name,arg,label) do { \ if (!arg) { \ errno = EINVAL; \ gf_log (name, GF_LOG_ERROR, \ "invalid argument: " #arg); \ goto label; \ } \ } while (0); #define GF_FILE_CONTENT_REQUESTED(_xattr_req,_content_limit) \ (dict_get_uint64 (_xattr_req, "glusterfs.content", _content_limit) == 0) static inline void iov_free (struct iovec *vector, int count) { int i; for (i = 0; i < count; i++) FREE (vector[i].iov_base); FREE (vector); } static inline int iov_length (const struct iovec *vector, int count) { int i = 0; size_t size = 0; for (i = 0; i < count; i++) size += vector[i].iov_len; return size; } static inline struct iovec * iov_dup (struct iovec *vector, int count) { int bytecount = 0; int i; struct iovec *newvec = NULL; bytecount = (count * sizeof (struct iovec)); newvec = MALL