1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Basic library routines.
25 #ifndef _PORTALS_LIB_H
26 #define _PORTALS_LIB_H
31 # include <asm/types.h>
35 #define MIN(a,b) (((a)<(b)) ? (a): (b))
37 #define MAX(a,b) (((a)>(b)) ? (a): (b))
38 #define MKSTR(ptr) ((ptr))? (ptr) : ""
40 static inline int size_round (int val)
42 return (val + 7) & (~0x7);
45 static inline int size_round16(int val)
47 return (val + 0xf) & (~0xf);
50 static inline int size_round32(int val)
52 return (val + 0x1f) & (~0x1f);
55 static inline int size_round0(int val)
59 return (val + 1 + 7) & (~0x7);
62 static inline size_t round_strlen(char *fset)
64 return size_round(strlen(fset) + 1);
67 #define LOGL(var,len,ptr) \
70 memcpy((char *)ptr, (const char *)var, len); \
71 ptr += size_round(len); \
74 #define LOGU(var,len,ptr) \
77 memcpy((char *)var, (const char *)ptr, len); \
78 ptr += size_round(len); \
81 #define LOGL0(var,len,ptr) \
85 memcpy((char *)ptr, (const char *)var, len); \
86 *((char *)(ptr) + len) = 0; \
87 ptr += size_round(len + 1); \
90 #endif /* _PORTALS_LIB_H */