1af69d88dSmrg/*
2af69d88dSmrg * Mesa 3-D graphics library
3af69d88dSmrg *
4af69d88dSmrg * Copyright (C) 2010 LunarG Inc.
5af69d88dSmrg *
6af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
7af69d88dSmrg * copy of this software and associated documentation files (the "Software"),
8af69d88dSmrg * to deal in the Software without restriction, including without limitation
9af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the
11af69d88dSmrg * Software is furnished to do so, subject to the following conditions:
12af69d88dSmrg *
13af69d88dSmrg * The above copyright notice and this permission notice shall be included
14af69d88dSmrg * in all copies or substantial portions of the Software.
15af69d88dSmrg *
16af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20af69d88dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21af69d88dSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22af69d88dSmrg * DEALINGS IN THE SOFTWARE.
23af69d88dSmrg *
24af69d88dSmrg * Authors:
25af69d88dSmrg *    Chia-I Wu <olv@lunarg.com>
26af69d88dSmrg */
27af69d88dSmrg
287ec681f3Smrg#include <stdbool.h>
29af69d88dSmrg#include <stdlib.h>
30af69d88dSmrg#include <stdio.h>
317ec681f3Smrg#include <string.h>
32af69d88dSmrg
337ec681f3Smrg#include "c11/threads.h"
34af69d88dSmrg#include "table.h"
35af69d88dSmrg
3601e04c3fSmrgstatic nop_handler_proc nop_handler = NULL;
3701e04c3fSmrg
3801e04c3fSmrgvoid
3901e04c3fSmrgtable_set_noop_handler(nop_handler_proc func)
4001e04c3fSmrg{
4101e04c3fSmrg   nop_handler = func;
4201e04c3fSmrg}
4301e04c3fSmrg
447ec681f3Smrgstatic bool log_noop;
457ec681f3Smrg
467ec681f3Smrgstatic void check_debug_env(void)
477ec681f3Smrg{
487ec681f3Smrg   const char *debug = getenv("MESA_DEBUG");
497ec681f3Smrg   if (!debug)
507ec681f3Smrg      debug = getenv("LIBGL_DEBUG");
517ec681f3Smrg   if (debug && strcmp(debug, "silent") != 0)
527ec681f3Smrg      log_noop = true;
537ec681f3Smrg}
547ec681f3Smrg
55af69d88dSmrgstatic void
56af69d88dSmrgnoop_warn(const char *name)
57af69d88dSmrg{
5801e04c3fSmrg   if (nop_handler) {
5901e04c3fSmrg      nop_handler(name);
6001e04c3fSmrg   }
6101e04c3fSmrg   else {
627ec681f3Smrg      static once_flag flag = ONCE_FLAG_INIT;
637ec681f3Smrg      call_once(&flag, check_debug_env);
64af69d88dSmrg
657ec681f3Smrg      if (log_noop)
6601e04c3fSmrg         fprintf(stderr, "%s is no-op\n", name);
6701e04c3fSmrg   }
68af69d88dSmrg}
69af69d88dSmrg
70af69d88dSmrgstatic int
71af69d88dSmrgnoop_generic(void)
72af69d88dSmrg{
73af69d88dSmrg   noop_warn("function");
74af69d88dSmrg   return 0;
75af69d88dSmrg}
76af69d88dSmrg
77af69d88dSmrg/* define noop_array */
78af69d88dSmrg#define MAPI_TMP_DEFINES
79af69d88dSmrg#define MAPI_TMP_NOOP_ARRAY
80af69d88dSmrg#include "mapi_tmp.h"
81