Skip to content

Commit

Permalink
prov/verbs: Replace __BITS_PER_LONG with LONG_WIDTH
Browse files Browse the repository at this point in the history
The verbs provider uses asm/types.h for __BITS_PER_LONG, but that header
is limited to Linux systems. LONG_WIDTH is defined in C23 in
limits.h. Use it instead, and add logic to define it if not
available. This will allow the verbs provider to compile on FreeBSD
systems.

Signed-off-by: Ken Raffenetti <[email protected]>
  • Loading branch information
raffenet authored and j-xiong committed Aug 6, 2024
1 parent da596e7 commit c459970
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions prov/verbs/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ AC_DEFUN([FI_VERBS_CONFIGURE],[
])
AC_CHECK_HEADERS([asm/types.h])
AS_IF([test $verbs_ibverbs_happy -eq 1 && \
test $verbs_rdmacm_happy -eq 1], [$1], [$2])
Expand Down
2 changes: 1 addition & 1 deletion prov/verbs/src/verbs_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,7 @@ int vrb_query_atomic(struct fid_domain *domain_fid, enum fi_datatype datatype,
switch (datatype) {
case FI_INT64:
case FI_UINT64:
#if __BITS_PER_LONG == 64
#if LONG_WIDTH == 64
case FI_DOUBLE:
case FI_FLOAT:
#endif
Expand Down
17 changes: 16 additions & 1 deletion prov/verbs/src/verbs_ofi.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#include "config.h"

#include <asm/types.h>
#include <errno.h>
#include <fcntl.h>
#include <arpa/inet.h>
Expand Down Expand Up @@ -79,6 +78,22 @@

#include "ofi_verbs_compat.h"

/* define LONG_WIDTH used by atomics */
#include <limits.h>
#ifndef LONG_WIDTH
#ifdef LONG_BIT
#define LONG_WIDTH LONG_BIT
#elif defined(HAVE_ASM_TYPES_H)
#include <asm/types.h>
#define LONG_WIDTH __BITS_PER_LONG
#elif defined(__x86_64__) || defined(__aarch64__)
#ifndef __ILP32__
#define LONG_WIDTH 64
#else
#define LONG_WIDTH 32
#endif
#endif
#endif

#ifndef AF_IB
#define AF_IB 27
Expand Down

0 comments on commit c459970

Please sign in to comment.