1*4deb5931Sjoerg /* $NetBSD: prop_stack.h,v 1.2 2007/08/30 12:23:54 joerg Exp $ */ 2e835604cSjoerg 3e835604cSjoerg /*- 4e835604cSjoerg * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>. 5e835604cSjoerg * All rights reserved. 6e835604cSjoerg * 7e835604cSjoerg * Redistribution and use in source and binary forms, with or without 8e835604cSjoerg * modification, are permitted provided that the following conditions 9e835604cSjoerg * are met: 10e835604cSjoerg * 11e835604cSjoerg * 1. Redistributions of source code must retain the above copyright 12e835604cSjoerg * notice, this list of conditions and the following disclaimer. 13e835604cSjoerg * 2. Redistributions in binary form must reproduce the above copyright 14e835604cSjoerg * notice, this list of conditions and the following disclaimer in 15e835604cSjoerg * the documentation and/or other materials provided with the 16e835604cSjoerg * distribution. 17e835604cSjoerg * 18e835604cSjoerg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19e835604cSjoerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20e835604cSjoerg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21e835604cSjoerg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22e835604cSjoerg * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23e835604cSjoerg * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24e835604cSjoerg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25e835604cSjoerg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26e835604cSjoerg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27e835604cSjoerg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28e835604cSjoerg * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29e835604cSjoerg * SUCH DAMAGE. 30e835604cSjoerg */ 31e835604cSjoerg 32e835604cSjoerg #ifndef _PROP_STACK_H 33e835604cSjoerg #define _PROP_STACK_H 34e835604cSjoerg 35e835604cSjoerg #include <sys/queue.h> 36e835604cSjoerg 37e835604cSjoerg #include <prop/prop_object.h> 38e835604cSjoerg 39e835604cSjoerg struct _prop_stack_intern_elem { 40e835604cSjoerg prop_object_t object; 41*4deb5931Sjoerg void *object_data[3]; 42e835604cSjoerg }; 43e835604cSjoerg 44e835604cSjoerg struct _prop_stack_extern_elem { 45e835604cSjoerg SLIST_ENTRY(_prop_stack_extern_elem) stack_link; 46e835604cSjoerg prop_object_t object; 47*4deb5931Sjoerg void *object_data[3]; 48e835604cSjoerg }; 49e835604cSjoerg 50e835604cSjoerg #define PROP_STACK_INTERN_ELEMS 16 51e835604cSjoerg 52e835604cSjoerg struct _prop_stack { 53e835604cSjoerg struct _prop_stack_intern_elem intern_elems[PROP_STACK_INTERN_ELEMS]; 54e835604cSjoerg size_t used_intern_elems; 55e835604cSjoerg SLIST_HEAD(, _prop_stack_extern_elem) extern_elems; 56e835604cSjoerg }; 57e835604cSjoerg 58e835604cSjoerg typedef struct _prop_stack *prop_stack_t; 59e835604cSjoerg 60e835604cSjoerg void _prop_stack_init(prop_stack_t); 61*4deb5931Sjoerg bool _prop_stack_push(prop_stack_t, prop_object_t, void *, void *, void *); 62*4deb5931Sjoerg bool _prop_stack_pop(prop_stack_t, prop_object_t *, void **, void **, void **); 63e835604cSjoerg 64e835604cSjoerg #endif 65