On Sun, 2009-05-24 at 21:40 -0400, Duane Ellis wrote:
> > That is the other question: stdint.h is a C99 header, yes? It might be
>  > better to unconditionally included it, defining our short types from it.
>  > What do you think?
> 
> We already do, it is included by 'types.h'.

Conditionally.  The attached patch does what I actually said, coupled
with the added knowledge below.

> I am saying that *IF* for some bizzaro reason, some platform does not 
> have it we can "fake it" and make the names work
> 
> As far as I know - all platforms are GCC, and ALL platforms have STDINT 
> right now.

After doing some research on Wikipedia, it looks like <inttypes.h> is
part of the C99 standard, and it includes <stdint.h> (which was also
introduced with C99).  The attached patch uses the former, which also
includes the intmax_t type that is used in a few places in OpenOCD.

> We *only* build with GCC, and no other compiler.

Today, but I would like OpenOCD to support all "sane" C99 compilers, if
someone wants to put in the effort to help debug the support for them.
The tricks are easy and would not obfuscate the code and might actually
improve readability (e.g. marking GCC attributes).

> (Rick may point out something about the Mac, but I am fairly certain it 
> will have stdint.h)

It's GCC+C99, so I expect it is there.  I think the attached patch is
the first step in the right direction, but there is more cleanup that
could be follow.

Cheers,

Zach

Index: src/helper/types.h
===================================================================
--- src/helper/types.h	(revision 1906)
+++ src/helper/types.h	(working copy)
@@ -23,27 +23,25 @@
 #ifndef TYPES_H
 #define TYPES_H
 
+#include <inttypes.h>
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 
 #ifndef u8
-typedef unsigned char u8;
+typedef uint8_t u8;
 #endif
 
 #ifndef u16
-typedef unsigned short u16;
+typedef uint16_t u16;
 #endif
 
 #ifndef u32
-typedef unsigned int u32;
+typedef uint32_t u32;
 #endif
 
 #ifndef u64
-typedef unsigned long long u64;
+typedef uint64_t u64;
 #endif
 
 typedef struct jtag_tap_s jtag_tap_t;
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to