From bf9e0158a15792feaf1896dbe092357f05c7a1d2 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Thu, 6 May 2010 15:44:38 -0700 Subject: [PATCH] librdmacm: move common definitions to internal header file Signed-off-by: Sean Hefty --- Makefile.am | 2 +- src/cma.c | 28 +------------------- src/cma.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 28 deletions(-) create mode 100644 src/cma.h diff --git a/Makefile.am b/Makefile.am index 2898ad9e..c9be437b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,7 +70,7 @@ man_MANS = \ EXTRA_DIST = include/rdma/rdma_cma_abi.h include/rdma/rdma_cma.h \ include/infiniband/ib.h \ - src/librdmacm.map librdmacm.spec.in $(man_MANS) + src/cma.h src/librdmacm.map librdmacm.spec.in $(man_MANS) dist-hook: librdmacm.spec cp librdmacm.spec $(distdir) diff --git a/src/cma.c b/src/cma.c index 8b6585e8..c8f385f1 100644 --- a/src/cma.c +++ b/src/cma.c @@ -50,39 +50,13 @@ #include #include +#include "cma.h" #include #include #include #include #include -#ifdef INCLUDE_VALGRIND -# include -# ifndef VALGRIND_MAKE_MEM_DEFINED -# warning "Valgrind requested, but VALGRIND_MAKE_MEM_DEFINED undefined" -# endif -#endif - -#ifndef VALGRIND_MAKE_MEM_DEFINED -# define VALGRIND_MAKE_MEM_DEFINED(addr,len) -#endif - -#define PFX "librdmacm: " - -#if __BYTE_ORDER == __LITTLE_ENDIAN -static inline uint64_t htonll(uint64_t x) { return bswap_64(x); } -static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); } -#else -static inline uint64_t htonll(uint64_t x) { return x; } -static inline uint64_t ntohll(uint64_t x) { return x; } -#endif - -static inline int ERR(int err) -{ - errno = err; - return -1; -} - #define CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size) \ do { \ struct ucma_abi_cmd_hdr *hdr; \ diff --git a/src/cma.h b/src/cma.h new file mode 100644 index 00000000..1c0ab8b9 --- /dev/null +++ b/src/cma.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2005-2010 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(CMA_H) +#define CMA_H + +#if HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include + +#ifdef INCLUDE_VALGRIND +# include +# ifndef VALGRIND_MAKE_MEM_DEFINED +# warning "Valgrind requested, but VALGRIND_MAKE_MEM_DEFINED undefined" +# endif +#endif + +#ifndef VALGRIND_MAKE_MEM_DEFINED +# define VALGRIND_MAKE_MEM_DEFINED(addr,len) +#endif + +#define PFX "librdmacm: " + +#if __BYTE_ORDER == __LITTLE_ENDIAN +static inline uint64_t htonll(uint64_t x) { return bswap_64(x); } +static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); } +#else +static inline uint64_t htonll(uint64_t x) { return x; } +static inline uint64_t ntohll(uint64_t x) { return x; } +#endif + +static inline int ERR(int err) +{ + errno = err; + return -1; +} + +#endif /* CMA_H */ + -- 2.46.0