[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] -mint8 problem with setjmp/longjmp

From: Joerg Wunsch
Subject: Re: [avr-libc-dev] -mint8 problem with setjmp/longjmp
Date: Fri, 8 Nov 2002 14:50:17 +0100
User-agent: Mutt/1.2.5i

Well, -mint8 is clearly marked as unsupported by avr-libc.  I'm quite
surprised you've got even that far.

As Nils Kristian Strom wrote:

> Looking at the setjmp.h header, I noticed the use of unsigned int in
> stead of void * for all addresses.  The following patch seems to fix
> this problem.

I don't think the fix is quite right.  Syntactically, you cannot
simply replace an integer by a pointer type.

Normally, <inttypes.h> should be used, and then uint8_t, uint16_t etc.
But if you look into this header file, you'll suddenly be faced with
the very same problem: uint16_t is simply an alias for `unsigned int',
so with -mint8, all this is entirely wrong...  This leaves the
question how to rewrite <inttypes.h> so it at least gives the correct
results regardless of whether -mint8 is in effect or not.  I'd
consider this the bare minimum required before we don't even need to
think about fixing anything else for -mint8.

How about the following patch to <inttypes.h> for a start?  Then, we
could slowly start fixing other parts, and document what will not work
(and cannot be made work) with -mint8.  But that needs a volunteer.

Index: inttypes.h
RCS file: /home/cvs/avr-libc/avr-libc/include/inttypes.h,v
retrieving revision 1.2
diff -u -r1.2 inttypes.h
--- inttypes.h  26 Jul 2002 05:49:44 -0000      1.2
+++ inttypes.h  8 Nov 2002 13:48:27 -0000
@@ -38,19 +38,32 @@
     Use [u]intN_t if you need exactly N bits.
-    \note These should probably not be used if avr-gcc's \c -mint8 option is
-    used. 
+    \note If avr-gcc's \c -mint8 option is used, no 32-bit types will be
+    available.
     @{ */
+#if __INT_MAX__ == 127
+# define __USING_MINT8 1
 typedef signed char int8_t;
 typedef unsigned char uint8_t;
+#if __USING_MINT8
+typedef long int16_t;
+typedef unsigned long uint16_t;
+#else /* no -mint8 */
 typedef int int16_t;
 typedef unsigned int uint16_t;
 typedef long int32_t;
 typedef unsigned long uint32_t;
 typedef long long int64_t;
 typedef unsigned long long uint64_t;

J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]