Skip to contentSkip to conversation

libibmad: Fix conflict with new umad.h header

PATCH In review [email protected] 2 participants 4 messages Feb 24, 2017 3 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libibmad: Fix conflict with new umad.h header

From: Ira Weiny <[email protected]>

---
 include/infiniband/mad.h | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
include/infiniband/mad.h +4 -16
index 77858c3fe6e1..2911dee3cdf4 100644
@@ -1662,29 +1662,17 @@ extern MAD_EXPORT int ibdebug;
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #ifndef ntohll
-static inline uint64_t ntohll(uint64_t x)
-{
-	return bswap_64(x);
-}
+#define ntohll bswap_64
 #endif
 #ifndef htonll
-static inline uint64_t htonll(uint64_t x)
-{
-	return bswap_64(x);
-}
+#define htonll bswap_64
 #endif
 #elif __BYTE_ORDER == __BIG_ENDIAN
 #ifndef ntohll
-static inline uint64_t ntohll(uint64_t x)
-{
-	return x;
-}
+#define ntohll(x) x
 #endif
 #ifndef htonll
-static inline uint64_t htonll(uint64_t x)
-{
-	return x;
-}
+#define htonll(x) x
 #endif
 #endif				/* __BYTE_ORDER == __BIG_ENDIAN */
 
Signature · 6 lines
1.8.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1487914827-339-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 1 line · On Fri, Feb 24, 2017 at 12:40:27AM -0500…

From: Ira Weiny <[email protected]>

Bleck, how did this ever work sanely like this??

This is the version you should copy:

#ifndef ntohll
#undef htonll
#undef ntohll
/* Users should use the glibc functions directly, not these wrappers */ static inline __attribute__((deprecated)) uint64_t htonll(uint64_t x) { return htobe64(x); } static inline __attribute__((deprecated)) uint64_t ntohll(uint64_t x) { return be64toh(x); } #define htonll htonll
#define ntohll ntohll
#endif

Quoted 1 line

+#define ntohll(x) x

missing () around the x.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170224182449.GE22491-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

author
#4 lore raw
Quoted 4 lines · On Fri, Feb 24, 2017 at 12:40:27AM -0500…
Quoted 1 line

From: Ira Weiny <[email protected]>

Bleck, how did this ever work sanely like this??

I don't know...

Libibmad should have been combined into infinband-diags years ago... I just never seem to have the time...

Quoted 10 lines

This is the version you should copy:

#ifndef ntohll
#undef htonll
#undef ntohll
/* Users should use the glibc functions directly, not these wrappers */ static inline __attribute__((deprecated)) uint64_t htonll(uint64_t x) { return htobe64(x); } static inline __attribute__((deprecated)) uint64_t ntohll(uint64_t
x) { return be64toh(x); } #define htonll htonll #define ntohll ntohll #endif

Perhaps...

The question is do you want to rely on BSD or gnu extensions? My reading of the various man pages leads me to the same path as you. That the BSD htobe* has become the standard in glibc.

However, anyone currently using libibmad must have bswap_*. Therefore this will not break them.

Quoted 4 lines
Quoted 2 lines

+#define ntohll(x) x

missing () around the x.

Yea missed that...

Thanks,
Ira

Quoted 2 lines

Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 2807E5FD2F6FDA4886F6618EAC48510E67C5743A-8k97q/[email protected]

#6 lore raw
Quoted 6 lines · Ira

Perhaps...

The question is do you want to rely on BSD or gnu extensions? My reading of the various man pages leads me to the same path as you. That the BSD htobe* has become the standard in glibc.

If you go down that rat hole then __BYTE_ORDER__ isn't portable either..

Which ever you choose, both places should use an identical construct, introducing two different definitions is evil.

bswap_64 is a tiny bit better because it does not rely on __USE_MISC which means the public header might compile with -std=c11/-ansi/etc

However I did a little check and some of our public headers already do not support that mode...

So my conclusion was to go with the simple solution, and mark it deprecated so we can remove it some day and avoid this worry.

I guess it could get wrappered in '#ifdef htobe64' though - then it would still support -ansi mode.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+#define ntohll(x) x

missing () around the x.

Yea missed that...

It is also problematic in that it doesn't force the output to a consistent 64 bit type, so big/little builds get different types which is never fun.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html