Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Mesa 3-D graphics library
  3.  *
  4.  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  5.  * Copyright (C) 2010  VMware, Inc.  All Rights Reserved.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the "Software"),
  9.  * to deal in the Software without restriction, including without limitation
  10.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11.  * and/or sell copies of the Software, and to permit persons to whom the
  12.  * Software is furnished to do so, subject to the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice shall be included
  15.  * in all copies or substantial portions of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23.  * OTHER DEALINGS IN THE SOFTWARE.
  24.  */
  25.  
  26.  
  27. /**
  28.  * No-op dispatch table.
  29.  *
  30.  * This file defines a special dispatch table which is loaded with no-op
  31.  * functions.
  32.  *
  33.  * Mesa can register a "no-op handler function" which will be called in
  34.  * the event that a no-op function is called.
  35.  *
  36.  * In the past, the dispatch table was loaded with pointers to a single
  37.  * no-op function.  But that broke on Windows because the GL entrypoints
  38.  * use __stdcall convention.  __stdcall means the callee cleans up the
  39.  * stack.  So one no-op function can't properly clean up the stack.  This
  40.  * would lead to crashes.
  41.  *
  42.  * Another benefit of unique no-op functions is we can accurately report
  43.  * the function's name in an error message.
  44.  */
  45.  
  46.  
  47. #include <stdlib.h>
  48. #include <string.h>
  49. #include "glapi/glapi_priv.h"
  50.  
  51.  
  52. void
  53. _glapi_noop_enable_warnings(unsigned char enable)
  54. {
  55. }
  56.  
  57. void
  58. _glapi_set_warning_func(_glapi_proc func)
  59. {
  60. }
  61.  
  62.  
  63. /**
  64.  * We'll jump though this function pointer whenever a no-op function
  65.  * is called.
  66.  */
  67. static _glapi_nop_handler_proc nop_handler = NULL;
  68.  
  69.  
  70. /**
  71.  * Register the no-op handler call-back function.
  72.  */
  73. void
  74. _glapi_set_nop_handler(_glapi_nop_handler_proc func)
  75. {
  76.    nop_handler = func;
  77. }
  78.  
  79.  
  80. /**
  81.  * Called by each of the no-op GL entrypoints.
  82.  */
  83. static void
  84. nop(const char *func)
  85. {
  86.    if (nop_handler)
  87.       nop_handler(func);
  88. }
  89.  
  90.  
  91. /**
  92.  * This is called if the user somehow calls an unassigned GL dispatch function.
  93.  */
  94. static GLint
  95. NoOpUnused(void)
  96. {
  97.    nop("unused GL entry point");
  98.    return 0;
  99. }
  100.  
  101. /*
  102.  * Defines for the glapitemp.h functions.
  103.  */
  104. #define KEYWORD1 static
  105. #define KEYWORD1_ALT static
  106. #define KEYWORD2 GLAPIENTRY
  107. #define NAME(func)  NoOp##func
  108. #define DISPATCH(func, args, msg)  nop(#func);
  109. #define RETURN_DISPATCH(func, args, msg)  nop(#func); return 0
  110.  
  111.  
  112. /*
  113.  * Defines for the table of no-op entry points.
  114.  */
  115. #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
  116. #define DISPATCH_TABLE_NAME __glapi_noop_table
  117. #define UNUSED_TABLE_NAME __unused_noop_functions
  118.  
  119. #include "glapi/glapitemp.h"
  120.  
  121.  
  122. /** Return pointer to new dispatch table filled with no-op functions */
  123. struct _glapi_table *
  124. _glapi_new_nop_table(unsigned num_entries)
  125. {
  126.    struct _glapi_table *table = malloc(num_entries * sizeof(_glapi_proc));
  127.    if (table) {
  128.       memcpy(table, __glapi_noop_table,
  129.              num_entries * sizeof(_glapi_proc));
  130.    }
  131.    return table;
  132. }
  133.