Skip to contentSkip to conversation

nfs: replace uses of __constant_{endian}

PATCH Applied Harvey Harrison 3 participants 5 messages Feb 12, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs: replace uses of __constant_{endian}

The base versions handle constant folding now, none of these headers are exported to userspace, so the __ prefixed versions are not necessary.

---
 include/linux/lockd/xdr.h  |   12 ++--
 include/linux/lockd/xdr4.h |   10 ++--
 include/linux/nfsd/nfsd.h  |  132 ++++++++++++++++++++++----------------------
 include/linux/sunrpc/xdr.h |   42 +++++++-------
 4 files changed, 98 insertions(+), 98 deletions(-)
include/linux/lockd/xdr.h +6 -6
index 7dc5b6c..d39ed1c 100644
@@ -25,13 +25,13 @@ struct svc_rqst;
 #define NLM_MAXCOOKIELEN    	32
 #define NLM_MAXSTRLEN		1024
 
-#define	nlm_granted		__constant_htonl(NLM_LCK_GRANTED)
-#define	nlm_lck_denied		__constant_htonl(NLM_LCK_DENIED)
-#define	nlm_lck_denied_nolocks	__constant_htonl(NLM_LCK_DENIED_NOLOCKS)
-#define	nlm_lck_blocked		__constant_htonl(NLM_LCK_BLOCKED)
-#define	nlm_lck_denied_grace_period	__constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD)
+#define	nlm_granted		cpu_to_be32(NLM_LCK_GRANTED)
+#define	nlm_lck_denied		cpu_to_be32(NLM_LCK_DENIED)
+#define	nlm_lck_denied_nolocks	cpu_to_be32(NLM_LCK_DENIED_NOLOCKS)
+#define	nlm_lck_blocked		cpu_to_be32(NLM_LCK_BLOCKED)
+#define	nlm_lck_denied_grace_period	cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD)
 
-#define nlm_drop_reply		__constant_htonl(30000)
+#define nlm_drop_reply		cpu_to_be32(30000)
 
 /* Lock info passed via NLM */
 struct nlm_lock {
include/linux/lockd/xdr4.h +5 -5
index 12bfe09..7353821 100644
@@ -15,11 +15,11 @@
 #include <linux/lockd/xdr.h>
 
 /* error codes new to NLMv4 */
-#define	nlm4_deadlock		__constant_htonl(NLM_DEADLCK)
-#define	nlm4_rofs		__constant_htonl(NLM_ROFS)
-#define	nlm4_stale_fh		__constant_htonl(NLM_STALE_FH)
-#define	nlm4_fbig		__constant_htonl(NLM_FBIG)
-#define	nlm4_failed		__constant_htonl(NLM_FAILED)
+#define	nlm4_deadlock		cpu_to_be32(NLM_DEADLCK)
+#define	nlm4_rofs		cpu_to_be32(NLM_ROFS)
+#define	nlm4_stale_fh		cpu_to_be32(NLM_STALE_FH)
+#define	nlm4_fbig		cpu_to_be32(NLM_FBIG)
+#define	nlm4_failed		cpu_to_be32(NLM_FAILED)
 
 
 
include/linux/nfsd/nfsd.h +66 -66

144 lines not on this page · raw message

include/linux/sunrpc/xdr.h +21 -21

48 lines not on this page · raw message

Signature · 1 line
1.6.2.rc0.218.gde7c
#1 lore raw
Quoted 3 lines · Harvey Harrison

The base versions handle constant folding now, none of these headers are exported to userspace, so the __ prefixed versions are not necessary.

I assume you compile tested this?

I seem to recall that the reason we did it that way was that some of the error codes are used in switch statements, and the value for a 'case:' really has to look like a constant, not just happen to evaluate to one.

However if it really does work with all supported compilers this way, then its a nice improvement, thanks.

NeilBrown

Quoted 32 lines
---
 include/linux/lockd/xdr.h  |   12 ++--
 include/linux/lockd/xdr4.h |   10 ++--
 include/linux/nfsd/nfsd.h  |  132
++++++++++++++++++++++----------------------
 include/linux/sunrpc/xdr.h |   42 +++++++-------
 4 files changed, 98 insertions(+), 98 deletions(-)
include/linux/lockd/xdr.h +6 -6
index 7dc5b6c..d39ed1c 100644
@@ -25,13 +25,13 @@ struct svc_rqst;
 #define NLM_MAXCOOKIELEN    	32
 #define NLM_MAXSTRLEN		1024
 
-#define	nlm_granted		__constant_htonl(NLM_LCK_GRANTED)
-#define	nlm_lck_denied		__constant_htonl(NLM_LCK_DENIED)
-#define	nlm_lck_denied_nolocks	__constant_htonl(NLM_LCK_DENIED_NOLOCKS)
-#define	nlm_lck_blocked		__constant_htonl(NLM_LCK_BLOCKED)
-#define	nlm_lck_denied_grace_period	__constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD)
+#define	nlm_granted		cpu_to_be32(NLM_LCK_GRANTED)
+#define	nlm_lck_denied		cpu_to_be32(NLM_LCK_DENIED)
+#define	nlm_lck_denied_nolocks	cpu_to_be32(NLM_LCK_DENIED_NOLOCKS)
+#define	nlm_lck_blocked		cpu_to_be32(NLM_LCK_BLOCKED)
+#define	nlm_lck_denied_grace_period	cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD)
 
-#define nlm_drop_reply		__constant_htonl(30000)
+#define nlm_drop_reply		cpu_to_be32(30000)
 
#2 lore raw
Quoted 11 lines · NeilBrown
Quoted 3 lines · Harvey Harrison

The base versions handle constant folding now, none of these headers are exported to userspace, so the __ prefixed versions are not necessary.

I assume you compile tested this?

I seem to recall that the reason we did it that way was that some of the error codes are used in switch statements, and the value for a 'case:' really has to look like a constant, not just happen to evaluate to one.

Yes, this requirement was explicitly built-in. See how the various __swabXX bits are done in linux/swab.h.

Harvey

#3 lore raw
Quoted 8 lines · Harvey Harrison
Quoted 7 lines · NeilBrown
Quoted 3 lines · Harvey Harrison

The base versions handle constant folding now, none of these headers are exported to userspace, so the __ prefixed versions are not necessary.

I assume you compile tested this?

Quoted 7 lines
Quoted 4 lines

I seem to recall that the reason we did it that way was that some of the error codes are used in switch statements, and the value for a 'case:' really has to look like a constant, not just happen to evaluate to one.

Yes, this requirement was explicitly built-in. See how the various __swabXX bits are done in linux/swab.h.

Cool, thanks!

NeilBrown

#4 lore raw
Quoted 14 lines · NeilBrown
Quoted 13 lines · Harvey Harrison
Quoted 11 lines · NeilBrown
Quoted 3 lines · Harvey Harrison

The base versions handle constant folding now, none of these headers are exported to userspace, so the __ prefixed versions are not necessary.

I assume you compile tested this?

I seem to recall that the reason we did it that way was that some of the error codes are used in switch statements, and the value for a 'case:' really has to look like a constant, not just happen to evaluate to one.

Quoted 4 lines
Quoted 2 lines

Yes, this requirement was explicitly built-in. See how the various __swabXX bits are done in linux/swab.h.

Cool, thanks!

Thanks, applied.--b.