Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/m68k/fpe - consistently use #ifdef DEBUG_FPE and #i...



details:   https://anonhg.NetBSD.org/src/rev/d1265f46fc2e
branches:  trunk
changeset: 765408:d1265f46fc2e
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed May 25 15:47:19 2011 +0000

description:
- consistently use #ifdef DEBUG_FPE and #ifdef DIAGNOSTIC
- use DPRINTF() style debug printfs
- use __func__ to print function names

diffstat:

 sys/arch/m68k/fpe/fpu_calcea.c |  267 +++++++++++++++-------------------------
 1 files changed, 99 insertions(+), 168 deletions(-)

diffs (truncated from 541 to 300 lines):

diff -r 09a921b4ddfa -r d1265f46fc2e sys/arch/m68k/fpe/fpu_calcea.c
--- a/sys/arch/m68k/fpe/fpu_calcea.c    Wed May 25 15:34:19 2011 +0000
+++ b/sys/arch/m68k/fpe/fpu_calcea.c    Wed May 25 15:47:19 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu_calcea.c,v 1.23 2011/05/25 15:17:21 tsutsui Exp $  */
+/*     $NetBSD: fpu_calcea.c,v 1.24 2011/05/25 15:47:19 tsutsui Exp $  */
 
 /*
  * Copyright (c) 1995 Gordon W. Ross
@@ -34,7 +34,7 @@
 #include "opt_m68k_arch.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_calcea.c,v 1.23 2011/05/25 15:17:21 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_calcea.c,v 1.24 2011/05/25 15:47:19 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/signal.h>
@@ -44,6 +44,12 @@
 
 #include "fpu_emulate.h"
 
+#ifdef DEBUG_FPE
+#define DPRINTF(x)     printf x
+#else
+#define DPRINTF(x)     do {} while (/* CONSTCOND */ 0)
+#endif
+
 /*
  * Prototypes of static functions
  */
@@ -67,9 +73,9 @@
 {
        int sig;
 
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
        if (insn->is_datasize < 0)
-               panic("decode_ea: called with uninitialized datasize");
+               panic("%s: called with uninitialized datasize", __func__);
 #endif
 
        sig = 0;
@@ -81,16 +87,14 @@
                /* register direct */
                ea->ea_regnum = modreg & 0xf;
                ea->ea_flags = EA_DIRECT;
-#ifdef DEBUG_FPE
-               printf("decode_ea: register direct reg=%d\n", ea->ea_regnum);
-#endif
+               DPRINTF(("%s: register direct reg=%d\n",
+                   __func__, ea->ea_regnum));
        } else if ((modreg & 077) == 074) {
                /* immediate */
                ea->ea_flags = EA_IMMED;
                sig = fetch_immed(frame, insn, &ea->ea_immed[0]);
-#ifdef DEBUG_FPE
-               printf("decode_ea: immediate size=%d\n", insn->is_datasize);
-#endif
+               DPRINTF(("%s: immediate size=%d\n",
+                   __func__, insn->is_datasize));
        }
        /*
         * rest of the address modes need to be separately
@@ -101,10 +105,8 @@
                /* LC040 */
                ea->ea_flags = EA_FRAME_EA;
                ea->ea_fea = frame->f_fmt4.f_fa;
-#ifdef DEBUG_FPE
-               printf("decode_ea: 68LC040 - in-frame EA (%p) size %d\n",
-                   (void *)ea->ea_fea, insn->is_datasize);
-#endif
+               DPRINTF(("%s: 68LC040 - in-frame EA (%p) size %d\n",
+                   __func__, (void *)ea->ea_fea, insn->is_datasize));
                if ((modreg & 070) == 030) {
                        /* postincrement mode */
                        ea->ea_flags |= EA_POSTINCR;
@@ -127,35 +129,27 @@
 
                case 020:                       /* (An) */
                        ea->ea_flags = 0;
-#ifdef DEBUG_FPE
-                       printf("decode_ea: register indirect reg=%d\n",
-                           ea->ea_regnum);
-#endif
+                       DPRINTF(("%s: register indirect reg=%d\n",
+                           __func__, ea->ea_regnum));
                        break;
 
                case 030:                       /* (An)+ */
                        ea->ea_flags = EA_POSTINCR;
-#ifdef DEBUG_FPE
-                       printf("decode_ea: reg indirect postincrement reg=%d\n",
-                           ea->ea_regnum);
-#endif
+                       DPRINTF(("%s: reg indirect postincrement reg=%d\n",
+                           __func__, ea->ea_regnum));
                        break;
 
                case 040:                       /* -(An) */
                        ea->ea_flags = EA_PREDECR;
-#ifdef DEBUG_FPE
-                       printf("decode_ea: reg indirect predecrement reg=%d\n",
-                           ea->ea_regnum);
-#endif
+                       DPRINTF(("%s: reg indirect predecrement reg=%d\n",
+                           __func__, ea->ea_regnum));
                        break;
 
                case 050:                       /* (d16,An) */
                        ea->ea_flags = EA_OFFSET;
                        sig = fetch_disp(frame, insn, 1, &ea->ea_offset);
-#ifdef DEBUG_FPE
-                       printf("decode_ea: reg indirect with displacement "
-                           "reg=%d\n", ea->ea_regnum);
-#endif
+                       DPRINTF(("%s: reg indirect with displacement reg=%d\n",
+                           __func__, ea->ea_regnum));
                break;
 
                case 060:                       /* (d8,An,Xn) */
@@ -171,28 +165,24 @@
                                ea->ea_flags = EA_ABS;
                                sig = fetch_disp(frame, insn, 1,
                                    &ea->ea_absaddr);
-#ifdef DEBUG_FPE
-                               printf("decode_ea: absolute address (word)\n");
-#endif
+                               DPRINTF(("%s: absolute address (word)\n",
+                                   __func__));
                                break;
 
                        case 1:                 /* (xxxxxxxx).L */
                                ea->ea_flags = EA_ABS;
                                sig = fetch_disp(frame, insn, 2,
                                    &ea->ea_absaddr);
-#ifdef DEBUG_FPE
-                               printf("decode_ea: absolute address (long)\n");
-#endif
+                               DPRINTF(("%s: absolute address (long)\n",
+                                   __func__));
                                break;
 
                        case 2:                 /* (d16,PC) */
                                ea->ea_flags = EA_PC_REL | EA_OFFSET;
                                sig = fetch_disp(frame, insn, 1,
                                    &ea->ea_absaddr);
-#ifdef DEBUG_FPE
-                               printf("decode_ea: pc relative word "
-                                   "displacement\n");
-#endif
+                               DPRINTF(("%s: pc relative word displacement\n",
+                                   __func__));
                                break;
 
                        case 3:                 /* (d8,PC,Xn) */
@@ -203,10 +193,8 @@
                        case 4:                 /* #data */
                                /* it should have been taken care of earlier */
                        default:
-#ifdef DEBUG_FPE
-                               printf("decode_ea: invalid addr mode (7,%d)\n",
-                                   modreg & 7);
-#endif
+                               DPRINTF(("%s: invalid addr mode (7,%d)\n",
+                                   __func__, modreg & 7));
                                return SIGILL;
                        }
                        break;
@@ -257,10 +245,8 @@
 
                ea->ea_basedisp = idx + basedisp;
                ea->ea_outerdisp = 0;
-#if DEBUG_FPE
-               printf("decode_ea6: brief ext word idxreg=%d, basedisp=%08x\n",
-                   ea->ea_idxreg, ea->ea_basedisp);
-#endif
+               DPRINTF(("%s: brief ext word idxreg=%d, basedisp=%08x\n",
+                   __func__, ea->ea_idxreg, ea->ea_basedisp));
        } else {
                /* full extension word */
                if (extword & 0x80) {
@@ -291,23 +277,17 @@
                        ea->ea_outerdisp = outerdisp;
                        break;
                default:
-#ifdef DEBUG
-                       printf("decode_ea6: invalid indirect mode: "
-                           "ext word %04x\n", extword);
-#endif
+                       DPRINTF(("%s: invalid indirect mode: ext word %04x\n",
+                           __func__, extword));
                        return SIGILL;
                        break;
                }
-#if DEBUG_FPE
-               printf("decode_ea6: full ext idxreg=%d, basedisp=%x, "
-                   "outerdisp=%x\n",
-                   ea->ea_idxreg, ea->ea_basedisp, ea->ea_outerdisp);
-#endif
+               DPRINTF(("%s: full ext idxreg=%d, basedisp=%x, outerdisp=%x\n",
+                   __func__,
+                   ea->ea_idxreg, ea->ea_basedisp, ea->ea_outerdisp));
        }
-#if DEBUG_FPE
-       printf("decode_ea6: regnum=%d, flags=%x\n",
-           ea->ea_regnum, ea->ea_flags);
-#endif
+       DPRINTF(("%s: regnum=%d, flags=%x\n",
+           __func__, ea->ea_regnum, ea->ea_flags));
        return 0;
 }
 
@@ -326,12 +306,10 @@
 
 #ifdef DIAGNOSTIC
        if (ea->ea_regnum & ~0xF)
-               panic("load_ea: bad regnum");
+               panic("%s: bad regnum", __func__);
 #endif
 
-#ifdef DEBUG_FPE
-       printf("load_ea: frame at %p\n", frame);
-#endif
+       DPRINTF(("%s: frame at %p\n", __func__, frame));
        /* dst is always int or larger. */
        len = insn->is_datasize;
        if (len < 4)
@@ -343,10 +321,10 @@
                /* Using LC040 frame EA */
 #ifdef DEBUG_FPE
                if (ea->ea_flags & (EA_PREDECR|EA_POSTINCR)) {
-                       printf("load_ea: frame ea %08x w/r%d\n",
-                  ea->ea_fea, ea->ea_regnum);
+                       printf("%s: frame ea %08x w/r%d\n",
+                           __func__, ea->ea_fea, ea->ea_regnum);
                } else {
-                       printf("load_ea: frame ea %08x\n", ea->ea_fea);
+                       printf("%s: frame ea %08x\n", __func__, ea->ea_fea);
                }
 #endif
                src = (char *)ea->ea_fea;
@@ -367,85 +345,66 @@
 #endif
        if (ea->ea_flags & EA_DIRECT) {
                if (len > 4) {
-#ifdef DEBUG
-                       printf("load_ea: operand doesn't fit CPU reg\n");
-#endif
+                       DPRINTF(("%s: operand doesn't fit CPU reg\n",
+                           __func__));
                        return SIGILL;
                }
                if (ea->ea_moffs > 0) {
-#ifdef DEBUG
-                       printf("load_ea: more than one move from CPU reg\n");
-#endif
+                       DPRINTF(("%s: more than one move from CPU reg\n",
+                           __func__));
                        return SIGILL;
                }
                src = (char *)&frame->f_regs[ea->ea_regnum];
                /* The source is an int. */
                if (len < 4) {
                        src += (4 - len);
-#ifdef DEBUG_FPE
-                       printf("load_ea: short/byte opr - addr adjusted\n");
-#endif
+                       DPRINTF(("%s: short/byte opr - addr adjusted\n",
+                           __func__));
                }
-#ifdef DEBUG_FPE
-               printf("load_ea: src %p\n", src);
-#endif
+               DPRINTF(("%s: src %p\n", __func__, src));
                memcpy(dst, src, len);
        } else if (ea->ea_flags & EA_IMMED) {
-#ifdef DEBUG_FPE
-               printf("load_ea: immed %08x%08x%08x size %d\n",
-                   ea->ea_immed[0], ea->ea_immed[1], ea->ea_immed[2], len);
-#endif
+               DPRINTF(("%s: immed %08x%08x%08x size %d\n", __func__,
+                   ea->ea_immed[0], ea->ea_immed[1], ea->ea_immed[2], len));
                src = (char *)&ea->ea_immed[0];
                if (len < 4) {
                        src += (4 - len);
-#ifdef DEBUG_FPE
-                       printf("load_ea: short/byte immed opr - "
-                           "addr adjusted\n");
-#endif
+                       DPRINTF(("%s: short/byte immed opr - "
+                           "addr adjusted\n", __func__));
                }
                memcpy(dst, src, len);
        } else if (ea->ea_flags & EA_ABS) {
-#ifdef DEBUG_FPE
-               printf("load_ea: abs addr %08x\n", ea->ea_absaddr);
-#endif
+               DPRINTF(("%s: abs addr %08x\n", __func__, ea->ea_absaddr));
                src = (char *)ea->ea_absaddr;



Home | Main Index | Thread Index | Old Index