Skip to contentSkip to conversation

Add definitions of USHRT_MAX

PATCH In review Zhang, Yanmin 3 participants 4 messages Mar 21, 2008 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add definitions of USHRT_MAX

Add definitions of USHRT_MAX and others into kernel. ipc uses it and slub implementation might also use it.

The patch is against 2.6.25-rc6.

---

include/linux/kernel.h +3 -0
@@ -20,6 +20,9 @@
 extern const char linux_banner[];
 extern const char linux_proc_banner[];
 
+#define USHRT_MAX	((u16)(~0U))
+#define SHRT_MAX	((s16)(USHRT_MAX>>1))
+#define SHRT_MIN	(-SHRT_MAX - 1)
 #define INT_MAX		((int)(~0U>>1))
 #define INT_MIN		(-INT_MAX - 1)
 #define UINT_MAX	(~0U)
ipc/util.h +0 -1
@@ -12,7 +12,6 @@
 
 #include <linux/err.h>
 
-#define USHRT_MAX 0xffff
 #define SEQ_MULTIPLIER	(IPCMNI)
 
 void sem_init (void);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

include/linux/kernel.h line 25

Quoted 5 lines · Yanmin

Add definitions of USHRT_MAX and others into kernel. ipc uses it and slub implementation might also use it.

include/linux/kernel.h +3 -0
+#define USHRT_MAX	((u16)(~0U))
+#define SHRT_MAX	((s16)(USHRT_MAX>>1))
+#define SHRT_MIN	(-SHRT_MAX - 1)

Perhaps it's better to use the most common kernel types? Perhaps U16_MAX, S16_MAX and S16_MIN?

Don't you need to cast SHRT_MIN/S16_MIN too?
#define S16_MIN ((s16)(-SHRT_MAX - 1))

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 8 lines · Joe Perches

include/linux/kernel.h line 25

Quoted 5 lines · Yanmin

Add definitions of USHRT_MAX and others into kernel. ipc uses it and slub implementation might also use it.

include/linux/kernel.h +3 -0
+#define USHRT_MAX	((u16)(~0U))
+#define SHRT_MAX	((s16)(USHRT_MAX>>1))
+#define SHRT_MIN	(-SHRT_MAX - 1)

Perhaps it's better to use the most common kernel types?

ipc uses USHRT_MAX in a couple of files. Should we keep it consistent?

If ipc wouldn't use it, I would prefer your idea.

Quoted 4 lines

Perhaps U16_MAX, S16_MAX and S16_MIN?

Don't you need to cast SHRT_MIN/S16_MIN too?
#define S16_MIN ((s16)(-SHRT_MAX - 1))

No. I simulate INT_MIN. I also tested it by defining a var and didn't get compilation warning.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Joe Perches
Quoted 10 lines · Joe Perches

include/linux/kernel.h line 25

Quoted 5 lines · Yanmin

Add definitions of USHRT_MAX and others into kernel. ipc uses it and slub implementation might also use it.

include/linux/kernel.h +3 -0
+#define USHRT_MAX	((u16)(~0U))
+#define SHRT_MAX	((s16)(USHRT_MAX>>1))
+#define SHRT_MIN	(-SHRT_MAX - 1)

Perhaps it's better to use the most common kernel types? Perhaps U16_MAX, S16_MAX and S16_MIN?

Quoted 2 lines

Don't you need to cast SHRT_MIN/S16_MIN too?
#define S16_MIN ((s16)(-SHRT_MAX - 1))

SHRT_MAX is already s16.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>