1*774dcce2Skamil /* $NetBSD: prog_ops.h,v 1.2 2019/08/18 04:13:24 kamil Exp $ */ 26475f125Spooka 36475f125Spooka /* 46475f125Spooka * Copyright (c) 2010 The NetBSD Foundation, Inc. 56475f125Spooka * All rights reserved. 66475f125Spooka * 76475f125Spooka * Redistribution and use in source and binary forms, with or without 86475f125Spooka * modification, are permitted provided that the following conditions 96475f125Spooka * are met: 106475f125Spooka * 1. Redistributions of source code must retain the above copyright 116475f125Spooka * notice, this list of conditions and the following disclaimer. 126475f125Spooka * 2. Redistributions in binary form must reproduce the above copyright 136475f125Spooka * notice, this list of conditions and the following disclaimer in the 146475f125Spooka * documentation and/or other materials provided with the distribution. 156475f125Spooka * 166475f125Spooka * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 176475f125Spooka * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 186475f125Spooka * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 196475f125Spooka * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 206475f125Spooka * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 216475f125Spooka * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 226475f125Spooka * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 236475f125Spooka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 246475f125Spooka * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 256475f125Spooka * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 266475f125Spooka * POSSIBILITY OF SUCH DAMAGE. 276475f125Spooka */ 286475f125Spooka 296475f125Spooka #ifndef _PROG_OPS_H_ 306475f125Spooka #define _PROG_OPS_H_ 316475f125Spooka 326475f125Spooka #include <sys/types.h> 336475f125Spooka 346475f125Spooka #ifndef CRUNCHOPS 35*774dcce2Skamil struct sysctlnode; 36*774dcce2Skamil 376475f125Spooka struct prog_ops { 386475f125Spooka int (*op_init)(void); 396475f125Spooka 406475f125Spooka int (*op_sysctl)(const int *, u_int, void *, size_t *, 416475f125Spooka const void *, size_t); 42*774dcce2Skamil 43*774dcce2Skamil /* Indirection needed for sanitizers. */ 44*774dcce2Skamil 45*774dcce2Skamil int (*op_sysctlgetmibinfo)(const char *, int *, u_int *, char *, 46*774dcce2Skamil size_t *, struct sysctlnode **, int); 47*774dcce2Skamil 48*774dcce2Skamil int (*op_sysctlnametomib)(const char *, int *, size_t *); 496475f125Spooka }; 506475f125Spooka extern const struct prog_ops prog_ops; 516475f125Spooka 526475f125Spooka #define prog_init prog_ops.op_init 536475f125Spooka #define prog_sysctl prog_ops.op_sysctl 54*774dcce2Skamil #define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo 55*774dcce2Skamil #define prog_sysctlnametomib prog_ops.op_sysctlnametomib 566475f125Spooka #else 576475f125Spooka #define prog_init ((int (*)(void))NULL) 586475f125Spooka #define prog_sysctl sysctl 59*774dcce2Skamil #define prog_sysctlgetmibinfo sysctlgetmibinfo 60*774dcce2Skamil #define prog_sysctlnametomib sysctlnametomib 616475f125Spooka #endif 626475f125Spooka 636475f125Spooka #endif /* _PROG_OPS_H_ */ 64