17ec681f3Smrg/**************************************************************************
27ec681f3Smrg *
37ec681f3Smrg * Copyright 2010 Luca Barbieri
47ec681f3Smrg *
57ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining
67ec681f3Smrg * a copy of this software and associated documentation files (the
77ec681f3Smrg * "Software"), to deal in the Software without restriction, including
87ec681f3Smrg * without limitation the rights to use, copy, modify, merge, publish,
97ec681f3Smrg * distribute, sublicense, and/or sell copies of the Software, and to
107ec681f3Smrg * permit persons to whom the Software is furnished to do so, subject to
117ec681f3Smrg * the following conditions:
127ec681f3Smrg *
137ec681f3Smrg * The above copyright notice and this permission notice (including the
147ec681f3Smrg * next paragraph) shall be included in all copies or substantial
157ec681f3Smrg * portions of the Software.
167ec681f3Smrg *
177ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
187ec681f3Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
197ec681f3Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
207ec681f3Smrg * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
217ec681f3Smrg * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
227ec681f3Smrg * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
237ec681f3Smrg * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
247ec681f3Smrg *
257ec681f3Smrg **************************************************************************/
267ec681f3Smrg
277ec681f3Smrg#ifndef U_DEBUG_REFCNT_H_
287ec681f3Smrg#define U_DEBUG_REFCNT_H_
297ec681f3Smrg
307ec681f3Smrg#include "pipe/p_config.h"
317ec681f3Smrg#include "pipe/p_state.h"
327ec681f3Smrg
337ec681f3Smrg#ifdef __cplusplus
347ec681f3Smrgextern "C" {
357ec681f3Smrg#endif
367ec681f3Smrg
377ec681f3Smrgtypedef void (*debug_reference_descriptor)(char*, const struct pipe_reference*);
387ec681f3Smrg
397ec681f3Smrg#if defined(DEBUG)
407ec681f3Smrg
417ec681f3Smrgextern int debug_refcnt_state;
427ec681f3Smrg
437ec681f3Smrgvoid
447ec681f3Smrgdebug_reference_slowpath(const struct pipe_reference* p,
457ec681f3Smrg                         debug_reference_descriptor get_desc, int change);
467ec681f3Smrg
477ec681f3Smrgstatic inline void
487ec681f3Smrgdebug_reference(const struct pipe_reference* p,
497ec681f3Smrg                debug_reference_descriptor get_desc, int change)
507ec681f3Smrg{
517ec681f3Smrg   if (debug_refcnt_state >= 0)
527ec681f3Smrg      debug_reference_slowpath(p, get_desc, change);
537ec681f3Smrg}
547ec681f3Smrg
557ec681f3Smrg#else
567ec681f3Smrg
577ec681f3Smrgstatic inline void
587ec681f3Smrgdebug_reference(UNUSED const struct pipe_reference* p,
597ec681f3Smrg                UNUSED debug_reference_descriptor get_desc, UNUSED int change)
607ec681f3Smrg{
617ec681f3Smrg}
627ec681f3Smrg
637ec681f3Smrg#endif
647ec681f3Smrg
657ec681f3Smrg#ifdef __cplusplus
667ec681f3Smrg}
677ec681f3Smrg#endif
687ec681f3Smrg
697ec681f3Smrg#endif /* U_DEBUG_REFCNT_H_ */
70