git: 26bc5ce8ba1e - main - net/libfabric: fix build with clang 16

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 20 May 2023 20:04:06 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/ports/commit/?id=26bc5ce8ba1e9cfbb40d77530b99307a98eac10d

commit 26bc5ce8ba1e9cfbb40d77530b99307a98eac10d
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-05-20 18:27:11 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-05-20 20:02:45 +0000

    net/libfabric: fix build with clang 16
    
    Clang 16 has a new error about incompatible function types, which shows
    up when building net/libfabric (on i386):
    
      prov/hook/src/hook_domain.c:124:12: error: incompatible function pointer types passing 'ssize_t (struct fid_ep *, size_t)' (aka 'int (struct fid_ep *, unsigned int)') to parameter of type 'ssize_t (*)(struct fid_ep *, uint64_t)' (aka 'int (*)(struct fid_ep *, unsigned long long)') [-Wincompatible-function-pointer-types]
                                                           hook_credit_handler);
                                                           ^~~~~~~~~~~~~~~~~~~
      prov/hook/src/hook_domain.c:150:17: error: incompatible function pointer types initializing 'void (*)(struct fid_ep *, uint64_t)' (aka 'void (*)(struct fid_ep *, unsigned long long)') with an expression of type 'void (struct fid_ep *, size_t)' (aka 'void (struct fid_ep *, unsigned int)') [-Wincompatible-function-pointer-types]
              .add_credits = hook_add_credits,
                             ^~~~~~~~~~~~~~~~
      prov/hook/src/hook_domain.c:152:22: error: incompatible function pointer types initializing 'void (*)(struct fid_domain *, ssize_t (*)(struct fid_ep *, uint64_t))' (aka 'void (*)(struct fid_domain *, int (*)(struct fid_ep *, unsigned long long))') with an expression of type 'void (struct fid_domain *, ssize_t (*)(struct fid_ep *, size_t))' (aka 'void (struct fid_domain *, int (*)(struct fid_ep *, unsigned int))') [-Wincompatible-function-pointer-types]
              .set_send_handler = hook_set_send_handler,
                                  ^~~~~~~~~~~~~~~~~~~~~
    
    The problem is that the 'credits' parameter used in these functions is
    size_t in some cases, but uint64_t in other cases. On LP64 architectures
    this does not result in any errors, but on e.g. i386 you get the above.
    
    Make the 'credits' parameter uint64_t everywhere to fix this issue.
    
    PR:             271537
    Approved by:    yuri (maintainer)
    MFH:            2023Q2
---
 net/libfabric/Makefile                             |  1 +
 net/libfabric/files/patch-include_ofi__hook.h      | 11 ++++++++
 .../files/patch-prov_hook_src_hook__domain.c       | 29 ++++++++++++++++++++++
 .../files/patch-prov_rxm_src_rxm__domain.c         | 25 +++++++++++++++++++
 .../files/patch-prov_verbs_src_fi__verbs.h         | 11 ++++++++
 .../files/patch-prov_verbs_src_verbs__domain.c     | 16 ++++++++++++
 .../files/patch-prov_verbs_src_verbs__ep.c         | 11 ++++++++
 7 files changed, 104 insertions(+)

diff --git a/net/libfabric/Makefile b/net/libfabric/Makefile
index 5dc71c377423..e91c9773efd7 100644
--- a/net/libfabric/Makefile
+++ b/net/libfabric/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	libfabric
 DISTVERSION=	1.15.1
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	https://github.com/ofiwg/${PORTNAME}/releases/download/v${DISTVERSION}/
 
diff --git a/net/libfabric/files/patch-include_ofi__hook.h b/net/libfabric/files/patch-include_ofi__hook.h
new file mode 100644
index 000000000000..bdc7ca538df7
--- /dev/null
+++ b/net/libfabric/files/patch-include_ofi__hook.h
@@ -0,0 +1,11 @@
+--- include/ofi_hook.h.orig	2022-04-30 21:46:31 UTC
++++ include/ofi_hook.h
+@@ -163,7 +163,7 @@ struct hook_domain {
+ 	struct fid_domain *hdomain;
+ 	struct hook_fabric *fabric;
+ 	struct ofi_ops_flow_ctrl *base_ops_flow_ctrl;
+-	ssize_t (*base_credit_handler)(struct fid_ep *ep_fid, size_t credits);
++	ssize_t (*base_credit_handler)(struct fid_ep *ep_fid, uint64_t credits);
+ };
+ 
+ int hook_domain_init(struct fid_fabric *fabric, struct fi_info *info,
diff --git a/net/libfabric/files/patch-prov_hook_src_hook__domain.c b/net/libfabric/files/patch-prov_hook_src_hook__domain.c
new file mode 100644
index 000000000000..513036779fdc
--- /dev/null
+++ b/net/libfabric/files/patch-prov_hook_src_hook__domain.c
@@ -0,0 +1,29 @@
+--- prov/hook/src/hook_domain.c.orig	2022-04-30 21:46:31 UTC
++++ prov/hook/src/hook_domain.c
+@@ -102,7 +102,7 @@ static struct fi_ops_mr hook_mr_ops = {
+ 	.regattr = hook_mr_regattr,
+ };
+ 
+-static ssize_t hook_credit_handler(struct fid_ep *ep_fid, size_t credits)
++static ssize_t hook_credit_handler(struct fid_ep *ep_fid, uint64_t credits)
+ {
+ 	/*
+ 	 * called from the base provider, ep_fid is the base ep, and
+@@ -114,7 +114,7 @@ static void hook_set_send_handler(struct fid_domain *d
+ }
+ 
+ static void hook_set_send_handler(struct fid_domain *domain_fid,
+-		ssize_t (*credit_handler)(struct fid_ep *ep, size_t credits))
++		ssize_t (*credit_handler)(struct fid_ep *ep, uint64_t credits))
+ {
+ 	struct hook_domain *domain = container_of(domain_fid,
+ 						  struct hook_domain, domain);
+@@ -131,7 +131,7 @@ static int hook_enable_ep_flow_ctrl(struct fid_ep *ep_
+ 	return ep->domain->base_ops_flow_ctrl->enable(ep->hep, threshold);
+ }
+ 
+-static void hook_add_credits(struct fid_ep *ep_fid, size_t credits)
++static void hook_add_credits(struct fid_ep *ep_fid, uint64_t credits)
+ {
+ 	struct hook_ep *ep = container_of(ep_fid, struct hook_ep, ep);
+ 
diff --git a/net/libfabric/files/patch-prov_rxm_src_rxm__domain.c b/net/libfabric/files/patch-prov_rxm_src_rxm__domain.c
new file mode 100644
index 000000000000..f631f8233700
--- /dev/null
+++ b/net/libfabric/files/patch-prov_rxm_src_rxm__domain.c
@@ -0,0 +1,25 @@
+--- prov/rxm/src/rxm_domain.c.orig	2022-04-30 21:46:32 UTC
++++ prov/rxm/src/rxm_domain.c
+@@ -567,7 +621,7 @@ static struct fi_ops_mr rxm_domain_mr_thru_ops = {
+ 	.regattr = rxm_mr_regattr_thru,
+ };
+ 
+-static ssize_t rxm_send_credits(struct fid_ep *ep, size_t credits)
++static ssize_t rxm_send_credits(struct fid_ep *ep, uint64_t credits)
+ {
+ 	struct rxm_conn *rxm_conn = ep->fid.context;
+ 	struct rxm_ep *rxm_ep = rxm_conn->ep;
+@@ -620,11 +674,11 @@ defer:
+ 	return FI_SUCCESS;
+ }
+ 
+-static void rxm_no_add_credits(struct fid_ep *ep_fid, size_t credits)
++static void rxm_no_add_credits(struct fid_ep *ep_fid, uint64_t credits)
+ { }
+ 
+ static void rxm_no_credit_handler(struct fid_domain *domain_fid,
+-		ssize_t (*credit_handler)(struct fid_ep *ep, size_t credits))
++		ssize_t (*credit_handler)(struct fid_ep *ep, uint64_t credits))
+ { }
+ 
+ static int rxm_no_enable_flow_ctrl(struct fid_ep *ep_fid, uint64_t threshold)
diff --git a/net/libfabric/files/patch-prov_verbs_src_fi__verbs.h b/net/libfabric/files/patch-prov_verbs_src_fi__verbs.h
new file mode 100644
index 000000000000..fe556dda9df8
--- /dev/null
+++ b/net/libfabric/files/patch-prov_verbs_src_fi__verbs.h
@@ -0,0 +1,11 @@
+--- prov/verbs/src/fi_verbs.h.orig	2022-05-13 15:08:17 UTC
++++ prov/verbs/src/fi_verbs.h
+@@ -943,7 +943,7 @@ ssize_t vrb_send_iov(struct vrb_ep *ep, struct ibv_sen
+ 		     const struct iovec *iov, void **desc, int count,
+ 		     uint64_t flags);
+ 
+-void vrb_add_credits(struct fid_ep *ep, size_t credits);
++void vrb_add_credits(struct fid_ep *ep, uint64_t credits);
+ 
+ int vrb_get_rai_id(const char *node, const char *service, uint64_t flags,
+ 		      const struct fi_info *hints, struct rdma_addrinfo **rai,
diff --git a/net/libfabric/files/patch-prov_verbs_src_verbs__domain.c b/net/libfabric/files/patch-prov_verbs_src_verbs__domain.c
new file mode 100644
index 000000000000..6a6314b03481
--- /dev/null
+++ b/net/libfabric/files/patch-prov_verbs_src_verbs__domain.c
@@ -0,0 +1,16 @@
+--- prov/verbs/src/verbs_domain.c.orig	2022-04-30 21:46:32 UTC
++++ prov/verbs/src/verbs_domain.c
+@@ -36,11 +36,11 @@
+ #include "ofi_iov.h"
+ 
+ #include "fi_verbs.h"
+-#include <malloc.h>
++#include <stdlib.h>
+ 
+ 
+ static void vrb_set_credit_handler(struct fid_domain *domain_fid,
+-		ssize_t (*credit_handler)(struct fid_ep *ep, size_t credits))
++		ssize_t (*credit_handler)(struct fid_ep *ep, uint64_t credits))
+ {
+ 	struct vrb_domain *domain;
+ 
diff --git a/net/libfabric/files/patch-prov_verbs_src_verbs__ep.c b/net/libfabric/files/patch-prov_verbs_src_verbs__ep.c
new file mode 100644
index 000000000000..3b0a7ec88d24
--- /dev/null
+++ b/net/libfabric/files/patch-prov_verbs_src_verbs__ep.c
@@ -0,0 +1,11 @@
+--- prov/verbs/src/verbs_ep.c.orig	2022-05-10 03:27:55 UTC
++++ prov/verbs/src/verbs_ep.c
+@@ -38,7 +38,7 @@ static struct fi_ops_msg vrb_srq_msg_ops;
+ static struct fi_ops_msg vrb_srq_msg_ops;
+ 
+ 
+-void vrb_add_credits(struct fid_ep *ep_fid, size_t credits)
++void vrb_add_credits(struct fid_ep *ep_fid, uint64_t credits)
+ {
+ 	struct vrb_ep *ep;
+ 	struct util_cq *cq;