From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org,
yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org
Subject: [PATCH rdma-core 2/5] utils: Create utils directory to put all common code and move min/max into it
Date: Sun, 25 Sep 2016 09:50:04 +0300 [thread overview]
Message-ID: <1474786207-2149-3-git-send-email-leon@kernel.org> (raw)
In-Reply-To: <1474786207-2149-1-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
CMakeLists.txt | 6 ++++++
ibacm/linux/osd.h | 5 ++---
libibverbs/examples/rc_pingpong.c | 8 +------
libmlx5/src/mlx5.h | 16 ++------------
librdmacm/src/cma.h | 5 ++---
utils/math.h | 44 +++++++++++++++++++++++++++++++++++++++
6 files changed, 57 insertions(+), 27 deletions(-)
create mode 100644 utils/math.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 557d3a8..c997c6d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,8 @@ set(BUILD_INCLUDE ${CMAKE_BINARY_DIR}/include)
set(BUILD_BIN ${CMAKE_BINARY_DIR}/bin)
# Libraries
set(BUILD_LIB ${CMAKE_BINARY_DIR}/lib)
+# Common code
+set(COMMON_CODE utils)
# Location to place provider .driver files
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/libibverbs.d")
@@ -139,6 +141,10 @@ RDMA_AddOptCFlag(CMAKE_SHARED_LINKER_FLAGS SUPPORTS_NO_UNDEFINED "-Wl,--no-undef
find_package(LDSymVer REQUIRED)
#-------------------------
+# Common code
+include_directories(${COMMON_CODE})
+
+#-------------------------
# Find libraries
# pthread
FIND_PACKAGE (Threads REQUIRED)
diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 5ca4c6f..ec18f7b 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -46,6 +46,8 @@
#include <sys/time.h>
#include <netinet/in.h>
+#include "../../utils/math.h"
+
#define ACM_CONF_DIR IBACM_CONFIG_PATH
#define ACM_ADDR_FILE "ibacm_addr.cfg"
#define ACM_OPTS_FILE "ibacm_opts.cfg"
@@ -56,9 +58,6 @@
#define container_of(ptr, type, field) \
((type *) ((void *) ptr - offsetof(type, field)))
-#define min(a, b) (a < b ? a : b)
-#define max(a, b) (a > b ? a : b)
-
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htonll(x) bswap_64(x)
#else
diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c
index 9676783..cc45741 100644
--- a/libibverbs/examples/rc_pingpong.c
+++ b/libibverbs/examples/rc_pingpong.c
@@ -49,13 +49,7 @@
#include "pingpong.h"
-#ifndef max
-#define max(x, y) (((x) > (y)) ? (x) : (y))
-#endif
-
-#ifndef min
-#define min(x, y) (((x) < (y)) ? (x) : (y))
-#endif
+#include "../../utils/math.h"
enum {
PINGPONG_RECV_WRID = 1,
diff --git a/libmlx5/src/mlx5.h b/libmlx5/src/mlx5.h
index dc90892..453aeb8 100644
--- a/libmlx5/src/mlx5.h
+++ b/libmlx5/src/mlx5.h
@@ -42,6 +42,8 @@
#include "list.h"
#include "bitmap.h"
+#include "../../utils/math.h"
+
#ifdef __GNUC__
#define likely(x) __builtin_expect((x), 1)
#define unlikely(x) __builtin_expect((x), 0)
@@ -91,20 +93,6 @@
#endif
-#ifndef min
-#define min(a, b) \
- ({ typeof(a) _a = (a); \
- typeof(b) _b = (b); \
- _a < _b ? _a : _b; })
-#endif
-
-#ifndef max
-#define max(a, b) \
- ({ typeof(a) _a = (a); \
- typeof(b) _b = (b); \
- _a > _b ? _a : _b; })
-#endif
-
#define HIDDEN __attribute__((visibility("hidden")))
#ifdef HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE
diff --git a/librdmacm/src/cma.h b/librdmacm/src/cma.h
index 98eba8d..d640688 100644
--- a/librdmacm/src/cma.h
+++ b/librdmacm/src/cma.h
@@ -47,6 +47,8 @@
#include <rdma/rdma_cma.h>
#include <infiniband/ib.h>
+#include "../../utils/math.h"
+
#ifdef INCLUDE_VALGRIND
# include <valgrind/memcheck.h>
# ifndef VALGRIND_MAKE_MEM_DEFINED
@@ -68,9 +70,6 @@ static inline uint64_t htonll(uint64_t x) { return x; }
static inline uint64_t ntohll(uint64_t x) { return x; }
#endif
-#define max(a, b) ((a) > (b) ? a : b)
-#define min(a, b) ((a) < (b) ? a : b)
-
#ifndef container_of
#define container_of(ptr, type, field) \
((type *) ((void *)ptr - offsetof(type, field)))
diff --git a/utils/math.h b/utils/math.h
new file mode 100644
index 0000000..ffef543
--- /dev/null
+++ b/utils/math.h
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef _RDMA_MATH_H_
+#define _RDMA_MATH_H_
+/*
+ * This include contains all common mathematical functions
+ */
+#ifndef min
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef max
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+#endif /* _RDMA_MATH_H_ */
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-09-25 6:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-25 6:50 [PATCH rdma-core 0/5] Add directory to place common code and move trivial functions into it Leon Romanovsky
[not found] ` <1474786207-2149-1-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-09-25 6:50 ` [PATCH rdma-core 1/5] cmake: Update build instructions in CmakeList Leon Romanovsky
2016-09-25 6:50 ` Leon Romanovsky [this message]
[not found] ` <1474786207-2149-3-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-09-26 7:05 ` [PATCH rdma-core 2/5] utils: Create utils directory to put all common code and move min/max into it Leon Romanovsky
[not found] ` <20160926070520.GJ4088-2ukJVAZIZ/Y@public.gmane.org>
2016-09-26 17:17 ` Jason Gunthorpe
2016-09-26 17:20 ` Jason Gunthorpe
2016-09-25 6:50 ` [PATCH rdma-core 3/5] utils: Remove container_of and offset local declarations Leon Romanovsky
[not found] ` <1474786207-2149-4-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-09-26 15:32 ` Hefty, Sean
2016-09-26 17:27 ` Jason Gunthorpe
2016-09-25 6:50 ` [PATCH rdma-core 4/5] libocrdma: Move ocrdma's list implementation into common directory Leon Romanovsky
[not found] ` <1474786207-2149-5-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-09-25 14:41 ` Christoph Hellwig
[not found] ` <20160925144121.GA12246-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-09-25 16:13 ` Leon Romanovsky
[not found] ` <20160925161315.GD4088-2ukJVAZIZ/Y@public.gmane.org>
2016-09-25 16:22 ` Christoph Hellwig
[not found] ` <20160925162203.GA32434-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-09-25 17:50 ` Bart Van Assche
2016-09-26 17:40 ` Jason Gunthorpe
[not found] ` <20160926174057.GD22965-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-26 22:14 ` Christoph Hellwig
[not found] ` <20160926221440.GA5878-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-09-26 22:23 ` Jason Gunthorpe
[not found] ` <20160926222319.GA2358-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-09-27 16:14 ` Yishai Hadas
[not found] ` <ff764b75-19af-340b-7228-328462c524ae-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-09-27 18:03 ` Jason Gunthorpe
2016-09-25 22:05 ` Jason Gunthorpe
2016-09-25 6:50 ` [PATCH rdma-core 5/5] libmlx5: Convert libmlx5 to use common list implementation Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474786207-2149-3-git-send-email-leon@kernel.org \
--to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.