* PATCH: stdint constants
@ 2004-11-03 13:30 roman.fietze
2004-11-04 17:45 ` H. Peter Anvin
0 siblings, 1 reply; 2+ messages in thread
From: roman.fietze @ 2004-11-03 13:30 UTC (permalink / raw)
To: linux-kernel
Hello,
First of all: sorry for using Notes MUA, but cannot route to kernel.org
due to NJABL.
Allthough many books recommend using the types uint8_t to uint64_t as
well as their signed counterparts, I could not find the MIX/MAX values
for those types in any kernel include file.
Tested on a 2.4 ARM/PPC/I386 kernel with gcc 3.0.4/3.2.2/3.3.2. Not
tested on any 64 bit architecture.
Any comments to this patch?
diff -uprN linux-2.6.9/include/linux/kernel.h
linux-2.6.9-stdint/include/linux/kernel.h
--- linux-2.6.9/include/linux/kernel.h 2004-10-18 23:53:05.000000000
+0200
+++ linux-2.6.9-stdint/include/linux/kernel.h 2004-11-03
14:15:24.000000000 +0100
@@ -23,6 +23,30 @@
#define LONG_MIN (-LONG_MAX - 1)
#define ULONG_MAX (~0UL)
+#define INT8_MIN (-128)
+#define INT16_MIN (-32767-1)
+#define INT32_MIN (-2147483647-1)
+
+#define INT8_MAX (127)
+#define INT16_MAX (32767)
+#define INT32_MAX (2147483647)
+
+#define UINT8_MAX (255)
+#define UINT16_MAX (65535)
+#define UINT32_MAX (4294967295U)
+
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+# if BITS_PER_LONG == 32
+# define INT64_MIN (-9223372036854775807LL - 1LL)
+# define INT64_MAX (9223372036854775807LL)
+# define UINT64_MAX (18446744073709551615ULL)
+# else
+# define INT64_MIN (-9223372036854775807L - 1L)
+# define INT64_MAX (9223372036854775807L)
+# define UINT64_MAX (18446744073709551615UL)
+# endif
+#endif
+
#define STACK_MAGIC 0xdeadbeef
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
Roman
--
Roman Fietze Telemotive AG Büro Mühlhausen
Breitwiesen 73347 Mühlhausen
Tel.: +49(0)7335 18493-45 http://www.telemotive.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: stdint constants
2004-11-03 13:30 PATCH: stdint constants roman.fietze
@ 2004-11-04 17:45 ` H. Peter Anvin
0 siblings, 0 replies; 2+ messages in thread
From: H. Peter Anvin @ 2004-11-04 17:45 UTC (permalink / raw)
To: linux-kernel
Followup to: <OF1C112AC2.560EA5F6-ONC1256F41.0049C0DE@telemotive.de>
By author: roman.fietze@telemotive.de
In newsgroup: linux.dev.kernel
>
> Hello,
>
> First of all: sorry for using Notes MUA, but cannot route to kernel.org
> due to NJABL.
>
> Allthough many books recommend using the types uint8_t to uint64_t as
> well as their signed counterparts, I could not find the MIX/MAX values
> for those types in any kernel include file.
>
> Tested on a 2.4 ARM/PPC/I386 kernel with gcc 3.0.4/3.2.2/3.3.2. Not
> tested on any 64 bit architecture.
>
> Any comments to this patch?
>
Yes. Long long is a ISO C99 type guaranteed to be at least 64 bits.
Thus,
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
is wrong; it's in fact actively harmful.
Furthermore, this should only be used by the kernel, since this comes
from <stdint.h> in userspace.
<stdint.h> really should be a compiler-provided header file. Sigh.
-hpa
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-11-04 17:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-03 13:30 PATCH: stdint constants roman.fietze
2004-11-04 17:45 ` H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox