tcledit/libwld: Tool cannot use NuttX debug macros. Must have its own.

This commit is contained in:
Gregory Nutt 2016-11-12 12:08:44 -06:00
parent ae89057270
commit fcda9116d3
5 changed files with 108 additions and 43 deletions

View File

@ -40,19 +40,14 @@ NXINCNX = $(TOPDIR)/include/nuttx
# Targets
all: debug.h nuttx
all: nuttx
default: all
.PHONY: clean
debug.h : $(NXINC)/debug.h
@cp $(NXINC)/debug.h debug.h
nuttx : $(NXINCNX)
@cp -a $(NXINCNX) nuttx
clean:
@rm -f debug.h
@rm -rf nuttx

View File

@ -0,0 +1,70 @@
/****************************************************************************
* apps/graphics/traveler/tools/libwld/wld_debug.h
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_DEBUG_H
#define __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_DEBUG_H
/*************************************************************************
* Included files
*************************************************************************/
#include <stdio.h>
/*************************************************************************
* Pre-processor Definitions
*************************************************************************/
#ifndef DEBUG_LEVEL
# define DEBUG_LEVEL 0
#endif
#define EXTRA_FMT "%s: "
#define EXTRA_ARG ,__FUNCTION__
#if DEBUG_LEVEL > 0
# define info(format, ...) \
fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# if DEBUG_LEVEL > 1
# define error(format, ...) \
fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# else
# define error(x...)
# endif
#else
# define info(x...)
# define error(x...)
#endif
#endif /* __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_DEBUG_H */

View File

@ -47,8 +47,8 @@
#include <tk.h>
#include "trv_types.h"
#include "debug.h"
#include "wld_world.h"
#include "wld_debug.h"
#include "wld_utils.h"
#include "tcl_x11graphics.h"
#include "tcl_colors.h"
@ -175,7 +175,7 @@ static void tcledit_update_newmode_display(void)
static int tcledit_setmode(ClientData clientData,
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
info("Processing command: %s\n", argv[0]);
if (argc != 3)
{
@ -184,7 +184,7 @@ static int tcledit_setmode(ClientData clientData,
}
else if (strcmp(argv[1], "POS") == 0)
{
ginfo("Entering POS mode\n");
info("Entering POS mode\n");
g_edit_mode = EDITMODE_POS;
tcledit_update_posmode_display();
}
@ -195,7 +195,7 @@ static int tcledit_setmode(ClientData clientData,
memset(&g_edit_rect, 0, sizeof(rect_data_t));
if (strcmp(argv[2], "x") == 0)
{
ginfo("Entering NEWX mode\n");
info("Entering NEWX mode\n");
g_edit_plane = EDITPLANE_X;
g_edit_rect.plane = g_plane_position[EDITPLANE_X];
g_edit_rect.hstart = g_plane_position[EDITPLANE_Y];
@ -205,7 +205,7 @@ static int tcledit_setmode(ClientData clientData,
}
else if (strcmp(argv[2], "y") == 0)
{
ginfo("Entering NEWY mode\n");
info("Entering NEWY mode\n");
g_edit_plane = EDITPLANE_Y;
g_edit_rect.plane = g_plane_position[EDITPLANE_Y];
g_edit_rect.hstart = g_plane_position[EDITPLANE_X];
@ -215,7 +215,7 @@ static int tcledit_setmode(ClientData clientData,
}
else if (strcmp(argv[2], "z") == 0)
{
ginfo("Entering NEWZ mode\n");
info("Entering NEWZ mode\n");
g_edit_plane = EDITPLANE_Z;
g_edit_rect.plane = g_plane_position[EDITPLANE_Z];
g_edit_rect.hstart = g_plane_position[EDITPLANE_X];
@ -244,7 +244,7 @@ static int tcledit_setmode(ClientData clientData,
static int tcledit_new_position(ClientData clientData,
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
info("Processing command: %s\n", argv[0]);
if (argc != 4)
{
@ -256,7 +256,7 @@ static int tcledit_new_position(ClientData clientData,
g_plane_position[1] = atoi(argv[2]);
g_plane_position[2] = atoi(argv[3]);
ginfo("New plane positions: {%d,%d,%d}\n",
info("New plane positions: {%d,%d,%d}\n",
g_plane_position[0], g_plane_position[1], g_plane_position[2]);
tcledit_update_posmode_display();
@ -268,7 +268,7 @@ static int tcledit_new_position(ClientData clientData,
static int tcledit_new_zoom(ClientData clientData,
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
info("Processing command: %s\n", argv[0]);
if (argc != 5)
{
@ -318,8 +318,8 @@ static int tcledit_new_zoom(ClientData clientData,
g_grid_step = 2048; /* 16 lines at 32768 */
}
ginfo("New g_view_size, g_grid_step: %d, %d\n", g_view_size, g_grid_step);
ginfo("New coordinate offsets: {%d,%d,%d}\n",
info("New g_view_size, g_grid_step: %d, %d\n", g_view_size, g_grid_step);
info("New coordinate offsets: {%d,%d,%d}\n",
g_coord_offset[0], g_coord_offset[1], g_coord_offset[2]);
if (g_edit_mode == EDITMODE_POS)
@ -342,7 +342,7 @@ static int tcledit_new_edit(ClientData clientData,
int end;
int extent;
ginfo("Processing command: %s\n", argv[0]);
info("Processing command: %s\n", argv[0]);
if (argc != 4)
{
@ -367,18 +367,18 @@ static int tcledit_new_edit(ClientData clientData,
case EDITPLANE_X:
if (strcmp(argv[1], "x") == 0)
{
ginfo("New X plane position: %d\n", start);
info("New X plane position: %d\n", start);
g_edit_rect.plane = start;
}
else if (strcmp(argv[1], "y") == 0)
{
ginfo("New horizontal Y coordinates: {%d,%d}\n", start, end);
info("New horizontal Y coordinates: {%d,%d}\n", start, end);
g_edit_rect.hstart = start;
g_edit_rect.hend = end;
}
else if (strcmp(argv[1], "z") == 0)
{
ginfo("New vertical Z coordinates: {%d,%d}\n", start, end);
info("New vertical Z coordinates: {%d,%d}\n", start, end);
g_edit_rect.vstart = start;
g_edit_rect.vend = end;
}
@ -392,18 +392,18 @@ static int tcledit_new_edit(ClientData clientData,
case EDITPLANE_Y:
if (strcmp(argv[1], "x") == 0)
{
ginfo("New horizontal X coordinates: {%d,%d}\n", start, end);
info("New horizontal X coordinates: {%d,%d}\n", start, end);
g_edit_rect.hstart = start;
g_edit_rect.hend = end;
}
else if (strcmp(argv[1], "y") == 0)
{
ginfo("New Y plane position: %d\n", start);
info("New Y plane position: %d\n", start);
g_edit_rect.plane = start;
}
else if (strcmp(argv[1], "z") == 0)
{
ginfo("New vertical Z coordinates: {%d,%d}\n", start, end);
info("New vertical Z coordinates: {%d,%d}\n", start, end);
g_edit_rect.vstart = start;
g_edit_rect.vend = end;
}
@ -417,19 +417,19 @@ static int tcledit_new_edit(ClientData clientData,
case EDITPLANE_Z:
if (strcmp(argv[1], "x") == 0)
{
ginfo("New horizontal X coordinates: {%d,%d}\n", start, end);
info("New horizontal X coordinates: {%d,%d}\n", start, end);
g_edit_rect.hstart = start;
g_edit_rect.hend = end;
}
else if (strcmp(argv[1], "y") == 0)
{
ginfo("New vertical Y coordinates: {%d,%d}\n", start, end);
info("New vertical Y coordinates: {%d,%d}\n", start, end);
g_edit_rect.vstart = start;
g_edit_rect.vend = end;
}
else if (strcmp(argv[1], "z") == 0)
{
ginfo("New Z plane position: %d\n", start);
info("New Z plane position: %d\n", start);
g_edit_rect.plane = start;
}
else
@ -456,7 +456,7 @@ static int tcledit_new_attributes(ClientData clientData,
const char *attributes;
int tmp;
ginfo("Processing command: %s\n", argv[0]);
info("Processing command: %s\n", argv[0]);
if (argc != 4)
{
@ -501,7 +501,7 @@ static int tcledit_new_attributes(ClientData clientData,
{
g_edit_rect.attribute &= ~DOOR_PLANE;
}
ginfo("attributes: %s->%02x\n", attributes, g_edit_rect.attribute);
info("attributes: %s->%02x\n", attributes, g_edit_rect.attribute);
tmp = atoi(argv[2]);
if ((tmp >= 0) && (tmp < 256))
@ -512,7 +512,7 @@ static int tcledit_new_attributes(ClientData clientData,
{
fprintf(stderr, "Texture index out of range: %d\n", tmp);
}
ginfo("texture: %s->%d\n", argv[2], g_edit_rect.texture);
info("texture: %s->%d\n", argv[2], g_edit_rect.texture);
tmp = atoi(argv[3]);
if ((tmp >= 0) && (tmp <= MAXX_SCALING))
@ -523,7 +523,7 @@ static int tcledit_new_attributes(ClientData clientData,
{
fprintf(stderr, "Scaling not supported: %d\n", tmp);
}
ginfo("scale: %s->%d\n", argv[3], g_edit_rect.scale);
info("scale: %s->%d\n", argv[3], g_edit_rect.scale);
}
return TCL_OK;
@ -535,7 +535,7 @@ static int tcledit_add_rectangle(ClientData clientData,
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
info("Processing command: %s\n", argv[0]);
if (argc != 1)
{
@ -582,7 +582,7 @@ static int tcledit_save_rectangles(ClientData clientData,
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
info("Processing command: %s\n", argv[0]);
if (argc != 1)
{

View File

@ -48,7 +48,7 @@
#endif
#include "trv_types.h"
#include "debug.h"
#include "wld_debug.h"
#include "wld_mem.h"
#include "wld_bitmaps.h"
#include "wld_plane.h"
@ -542,13 +542,13 @@ void tcl_paint_background(tcl_window_t *w)
int ndx = tcl_color_index(w);
int i;
ginfo("g_edit_mode=%d g_edit_plane=%d plane=%d ndx=%d\n",
info("g_edit_mode=%d g_edit_plane=%d plane=%d ndx=%d\n",
g_edit_mode, g_edit_plane, w->plane, ndx);
pixel = w->colorLookup[ndx + BKGD_COLOR];
dest = w->frameBuffer;
ginfo("ndx=%d dest=%p pixel=0x%06lx\n", ndx, dest, pixel);
info("ndx=%d dest=%p pixel=0x%06lx\n", ndx, dest, (unsigned long)pixel);
for (i = 0; i < w->width * w->height; i++)
{
@ -574,7 +574,7 @@ void tcl_paint_position(tcl_window_t *w)
int vpos;
int i;
ginfo("plane=%d ndx=%d\n", w->plane, ndx);
info("plane=%d ndx=%d\n", w->plane, ndx);
/* Horizontal and vertical positions will depend on which plane is
* selected.
@ -611,7 +611,7 @@ void tcl_paint_position(tcl_window_t *w)
pixel = w->colorLookup[ndx + HLINE_COLOR];
dest = w->frameBuffer + vpos * w->width;
ginfo("dest=%p pixel=0x%06lx\n", dest, pixel);
info("dest=%p pixel=0x%06lx\n", dest, (unsigned long)pixel);
for (i = 0; i < w->width; i++)
{
@ -623,7 +623,7 @@ void tcl_paint_position(tcl_window_t *w)
pixel = w->colorLookup[ndx + HLINE_COLOR];
dest = w->frameBuffer + hpos;
ginfo("dest=%p pixel=0x%06lx\n", dest, pixel);
info("dest=%p pixel=0x%06lx\n", dest, (unsigned long)pixel);
for (i = 0; i < w->height; i++)
{
@ -648,7 +648,7 @@ void tcl_paint_grid(tcl_window_t *w)
int gridmask;
int i;
ginfo("plane=%d ndx=%d\n", w->plane, ndx);
info("plane=%d ndx=%d\n", w->plane, ndx);
/* Horizontal and vertical positions will depend on which plane is selected. */

View File

@ -41,7 +41,6 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <debug.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -52,9 +51,10 @@
#endif
#include "trv_types.h"
#include "debug.h"
#include "wld_debug.h"
#include "wld_mem.h"
#include "wld_debug.h"
#include "wld_bitmaps.h"
#include "wld_plane.h"
#include "wld_utils.h"
@ -198,7 +198,7 @@ static bool x11_allocate_colors(tcl_window_t * w, Colormap colormap)
/* Save the RGB to pixel lookup data */
ginfo("%d.%d {%02x,%02x,%02x}->0x%06lx\n",
info("%d.%d {%02x,%02x,%02x}->0x%06lx\n",
w->plane, i,
w->palette[i].red, w->palette[i].green, w->palette[i].blue,
color.pixel);