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 __LIBCFS_PORTALS_LIB_H__
26 #define __LIBCFS_PORTALS_LIB_H__
28 #if defined(__linux__)
29 #include <libcfs/linux/portals_lib.h>
30 #elif defined(__APPLE__)
31 #include <libcfs/darwin/portals_lib.h>
33 #error Unsupported Operating System
37 #define MIN(a,b) (((a)<(b)) ? (a): (b))
39 #define MAX(a,b) (((a)>(b)) ? (a): (b))
40 #define MKSTR(ptr) ((ptr))? (ptr) : ""
42 static inline int size_round4 (int val)
44 return (val + 3) & (~0x3);
47 static inline int size_round (int val)
49 return (val + 7) & (~0x7);
52 static inline int size_round16(int val)
54 return (val + 0xf) & (~0xf);
57 static inline int size_round32(int val)
59 return (val + 0x1f) & (~0x1f);
62 static inline int size_round0(int val)
66 return (val + 1 + 7) & (~0x7);
69 static inline size_t round_strlen(char *fset)
71 return size_round(strlen(fset) + 1);
74 #define LOGL(var,len,ptr) \
77 memcpy((char *)ptr, (const char *)var, len); \
78 ptr += size_round(len); \
81 #define LOGU(var,len,ptr) \
84 memcpy((char *)var, (const char *)ptr, len); \
85 ptr += size_round(len); \
88 #define LOGL0(var,len,ptr) \
92 memcpy((char *)ptr, (const char *)var, len); \
93 *((char *)(ptr) + len) = 0; \
94 ptr += size_round(len + 1); \
97 #endif /* _PORTALS_LIB_H */