util: Move os_misc to util
[mesa.git] / src / gallium / auxiliary / util / u_debug.c
index 0d63cfee5e85ab639003661fe29326e774b18357..f6ed0138c1faf94ed399ef6f90e334d61e4a2469 100644 (file)
 #include "util/u_debug.h"
 #include "pipe/p_format.h"
 #include "pipe/p_state.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_memory.h"
 #include "util/u_string.h"
 #include "util/u_math.h"
-#include "util/u_prim.h"
 #include <inttypes.h>
 
 #include <stdio.h>
@@ -203,25 +199,16 @@ debug_get_num_option(const char *name, long dfault)
    const char *str;
 
    str = os_get_option(name);
-   if (!str)
+   if (!str) {
       result = dfault;
-   else {
-      long sign;
-      char c;
-      c = *str++;
-      if (c == '-') {
-        sign = -1;
-        c = *str++;
-      }
-      else {
-        sign = 1;
-      }
-      result = 0;
-      while ('0' <= c && c <= '9') {
-        result = result*10 + (c - '0');
-        c = *str++;
+   } else {
+      char *endptr;
+
+      result = strtol(str, &endptr, 0);
+      if (str == endptr) {
+         /* Restore the default value when no digits were found. */
+         result = dfault;
       }
-      result *= sign;
    }
 
    if (debug_get_option_should_print())
@@ -412,47 +399,14 @@ debug_dump_flags(const struct debug_named_value *names, unsigned long value)
 }
 
 
-#ifdef DEBUG
-void
-debug_print_format(const char *msg, unsigned fmt )
-{
-   debug_printf("%s: %s\n", msg, util_format_name(fmt));
-}
-#endif
-
-
-/** Return string name of given primitive type */
-const char *
-u_prim_name(unsigned prim)
-{
-   static const struct debug_named_value names[] = {
-      DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_LINES),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_LINES_ADJACENCY),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP_ADJACENCY),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES_ADJACENCY),
-      DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY),
-      DEBUG_NAMED_VALUE_END
-   };
-   return debug_dump_enum(names, prim);
-}
-
-
 
 #ifdef DEBUG
 int fl_indent = 0;
 const char* fl_function[1024];
 
 int
-debug_funclog_enter(const char* f, const int line, const char* file)
+debug_funclog_enter(const char* f, UNUSED const int line,
+                    UNUSED const char* file)
 {
    int i;
 
@@ -467,7 +421,8 @@ debug_funclog_enter(const char* f, const int line, const char* file)
 }
 
 void
-debug_funclog_exit(const char* f, const int line, const char* file)
+debug_funclog_exit(const char* f, UNUSED const int line,
+                   UNUSED const char* file)
 {
    --fl_indent;
    assert(fl_indent >= 0);
@@ -475,7 +430,8 @@ debug_funclog_exit(const char* f, const int line, const char* file)
 }
 
 void
-debug_funclog_enter_exit(const char* f, const int line, const char* file)
+debug_funclog_enter_exit(const char* f, UNUSED const int line,
+                         UNUSED const char* file)
 {
    int i;
    for (i = 0; i < fl_indent; i++)
@@ -483,86 +439,3 @@ debug_funclog_enter_exit(const char* f, const int line, const char* file)
    debug_printf("%s\n", f);
 }
 #endif
-
-
-
-#ifdef DEBUG
-/**
- * Print PIPE_TRANSFER_x flags with a message.
- */
-void
-debug_print_transfer_flags(const char *msg, unsigned usage)
-{
-   static const struct debug_named_value names[] = {
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_READ),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_WRITE),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_MAP_DIRECTLY),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_RANGE),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_DONTBLOCK),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_UNSYNCHRONIZED),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_FLUSH_EXPLICIT),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_PERSISTENT),
-      DEBUG_NAMED_VALUE(PIPE_TRANSFER_COHERENT),
-      DEBUG_NAMED_VALUE_END
-   };
-
-   debug_printf("%s: %s\n", msg, debug_dump_flags(names, usage));
-}
-
-
-/**
- * Print PIPE_BIND_x flags with a message.
- */
-void
-debug_print_bind_flags(const char *msg, unsigned usage)
-{
-   static const struct debug_named_value names[] = {
-      DEBUG_NAMED_VALUE(PIPE_BIND_DEPTH_STENCIL),
-      DEBUG_NAMED_VALUE(PIPE_BIND_RENDER_TARGET),
-      DEBUG_NAMED_VALUE(PIPE_BIND_BLENDABLE),
-      DEBUG_NAMED_VALUE(PIPE_BIND_SAMPLER_VIEW),
-      DEBUG_NAMED_VALUE(PIPE_BIND_VERTEX_BUFFER),
-      DEBUG_NAMED_VALUE(PIPE_BIND_INDEX_BUFFER),
-      DEBUG_NAMED_VALUE(PIPE_BIND_CONSTANT_BUFFER),
-      DEBUG_NAMED_VALUE(PIPE_BIND_DISPLAY_TARGET),
-      DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_WRITE),
-      DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_READ),
-      DEBUG_NAMED_VALUE(PIPE_BIND_STREAM_OUTPUT),
-      DEBUG_NAMED_VALUE(PIPE_BIND_CURSOR),
-      DEBUG_NAMED_VALUE(PIPE_BIND_CUSTOM),
-      DEBUG_NAMED_VALUE(PIPE_BIND_GLOBAL),
-      DEBUG_NAMED_VALUE(PIPE_BIND_SHADER_BUFFER),
-      DEBUG_NAMED_VALUE(PIPE_BIND_SHADER_IMAGE),
-      DEBUG_NAMED_VALUE(PIPE_BIND_COMPUTE_RESOURCE),
-      DEBUG_NAMED_VALUE(PIPE_BIND_COMMAND_ARGS_BUFFER),
-      DEBUG_NAMED_VALUE(PIPE_BIND_SCANOUT),
-      DEBUG_NAMED_VALUE(PIPE_BIND_SHARED),
-      DEBUG_NAMED_VALUE(PIPE_BIND_LINEAR),
-      DEBUG_NAMED_VALUE_END
-   };
-
-   debug_printf("%s: %s\n", msg, debug_dump_flags(names, usage));
-}
-
-
-/**
- * Print PIPE_USAGE_x enum values with a message.
- */
-void
-debug_print_usage_enum(const char *msg, enum pipe_resource_usage usage)
-{
-   static const struct debug_named_value names[] = {
-      DEBUG_NAMED_VALUE(PIPE_USAGE_DEFAULT),
-      DEBUG_NAMED_VALUE(PIPE_USAGE_IMMUTABLE),
-      DEBUG_NAMED_VALUE(PIPE_USAGE_DYNAMIC),
-      DEBUG_NAMED_VALUE(PIPE_USAGE_STREAM),
-      DEBUG_NAMED_VALUE(PIPE_USAGE_STAGING),
-      DEBUG_NAMED_VALUE_END
-   };
-
-   debug_printf("%s: %s\n", msg, debug_dump_enum(names, usage));
-}
-
-
-#endif