This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

diag_printf, long long


Hi,

I guess that diag_printf can't handle long long type of integers, at least
as far as with the gcc for 32 bit mips.
Below is the program to prove it.

#include <cyg/infra/diag.h>     // diag_printf
#include <stdio.h>              // printf
void cyg_user_start(void)
{
        unsigned long t1=0xaa00aa00;
        unsigned long long t2=0x22002200bb00bb00;
        unsigned long long t3=0x33003300cc00cc00;

        diag_printf("diag : t1:%16lx t1:%16llx t3:%16llx\n",t1,t2,t3);
        printf("stdio: t1:%16lx t1:%16llx t3:%16llx\n",t1,t2,t3);
        diag_printf("diag : t2:%16llx t1:%16lx t3:%16llx\n",t2,t1,t3);
        printf("stdio: t2:%16llx t1:%16lx t3:%16llx\n",t2,t1,t3);
        diag_printf("diag : t2:%16llx t3:%16llx t1:%16lx\n",t2,t3,t1);
        printf("stdio: t2:%16llx t3:%16llx t1:%16lx\n",t2,t3,t1);
	for(;;);
}

The attachment is my patch for this problem. I think this works with
32-bit compiler. But I suspect it does so with 64 bit compiler.
If you find anything or have better idea, please suggest me. 

Thank you in advance.

Regards,
Motoya Kurotsu
Alilled Telesis K.K.
-----------------------------------------------

--- diag.cxx.orig	Thu Jul 12 13:53:32 2001
+++ diag.cxx	Thu Jul 12 14:34:56 2001
@@ -262,6 +262,9 @@
 
 externC void diag_vprintf( const char *fmt, CYG_ADDRWORD *args)
 {
+
+    cyg_bool pad = true;
+
     if( !diag_check_string(fmt) )
     {
         int i;
@@ -309,6 +312,13 @@
                 }
             }
 
+            if (long_op) {
+                    if(pad) args++;
+                    pad=false;
+            } else {
+                    pad=!pad;
+            }
+		
             switch( c )
             {
             case 'd':


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]