1*175775bbSdlg.\" $OpenBSD: memcmp.9,v 1.1 2018/04/23 10:30:39 dlg Exp $ 2*175775bbSdlg.\" 3*175775bbSdlg.\" Copyright (c) 2002, 2003 CubeSoft Communications, Inc. 4*175775bbSdlg.\" <http://www.csoft.org> 5*175775bbSdlg.\" 6*175775bbSdlg.\" Redistribution and use in source and binary forms, with or without 7*175775bbSdlg.\" modification, are permitted provided that the following conditions 8*175775bbSdlg.\" are met: 9*175775bbSdlg.\" 1. Redistributions of source code must retain the above copyright 10*175775bbSdlg.\" notice, this list of conditions and the following disclaimer. 11*175775bbSdlg.\" 2. Redistributions in binary form must reproduce the above copyright 12*175775bbSdlg.\" notice, this list of conditions and the following disclaimer in the 13*175775bbSdlg.\" documentation and/or other materials provided with the distribution. 14*175775bbSdlg.\" 15*175775bbSdlg.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16*175775bbSdlg.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17*175775bbSdlg.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*175775bbSdlg.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 19*175775bbSdlg.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20*175775bbSdlg.\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21*175775bbSdlg.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*175775bbSdlg.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23*175775bbSdlg.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24*175775bbSdlg.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE 25*175775bbSdlg.\" POSSIBILITY OF SUCH DAMAGE. 26*175775bbSdlg.\" 27*175775bbSdlg.Dd $Mdocdate: April 23 2018 $ 28*175775bbSdlg.Dt MEMCMP 9 29*175775bbSdlg.Os 30*175775bbSdlg.Sh NAME 31*175775bbSdlg.Nm skpc , 32*175775bbSdlg.Nm scanc , 33*175775bbSdlg.Nm bcmp , 34*175775bbSdlg.Nm timingsafe_bcmp , 35*175775bbSdlg.Nm memchr , 36*175775bbSdlg.Nm memcmp 37*175775bbSdlg.Nd kernel library byte string routines 38*175775bbSdlg.Sh SYNOPSIS 39*175775bbSdlg.In lib/libkern/libkern.h 40*175775bbSdlg.Ft int 41*175775bbSdlg.Fn skpc "int mask" "size_t size" "u_char *cp" 42*175775bbSdlg.Ft int 43*175775bbSdlg.Fn scanc "u_int size" "const u_char *cp" "const u_char *table" "int mask" 44*175775bbSdlg.Ft int 45*175775bbSdlg.Fn bcmp "const void *b1" "const void *b2" "size_t len" 46*175775bbSdlg.Ft int 47*175775bbSdlg.Fn timingsafe_bcmp "const void *b1" "const void *b2" "size_t len" 48*175775bbSdlg.Ft void * 49*175775bbSdlg.Fn memchr "const void *b" "int c" "size_t len" 50*175775bbSdlg.Ft int 51*175775bbSdlg.Fn memcmp "const void *b1" "const void *b2" "size_t len" 52*175775bbSdlg.Sh DESCRIPTION 53*175775bbSdlgThe 54*175775bbSdlg.Fn skpc 55*175775bbSdlgfunction locates the first unsigned character of value different than 56*175775bbSdlg.Fa mask 57*175775bbSdlginside the string 58*175775bbSdlg.Fa cp . 59*175775bbSdlg.Pp 60*175775bbSdlgThe 61*175775bbSdlg.Fn scanc 62*175775bbSdlgfunction expects a string of indexes into the table 63*175775bbSdlg.Fa table . 64*175775bbSdlgEach table element is bitwise ANDed against 65*175775bbSdlg.Fa mask . 66*175775bbSdlg.Pp 67*175775bbSdlg.Fn skpc 68*175775bbSdlgand 69*175775bbSdlg.Fn scanc 70*175775bbSdlgexpect the string to be of size 71*175775bbSdlg.Fa size , 72*175775bbSdlgand return the index relative to the end of the string where the match 73*175775bbSdlgoccurred, or zero if 74*175775bbSdlg.Fa mask 75*175775bbSdlgis not present in the string. 76*175775bbSdlg.Pp 77*175775bbSdlgThe remaining functions have the same semantics as their libc counterparts, 78*175775bbSdlg.Xr bcmp 3 , 79*175775bbSdlg.Xr timingsafe_bcmp 3 , 80*175775bbSdlg.Xr memchr 3 , 81*175775bbSdlgand 82*175775bbSdlg.Xr memcmp 3 . 83*175775bbSdlg.Sh STANDARDS 84*175775bbSdlgThe 85*175775bbSdlg.Fn memchr 86*175775bbSdlgand 87*175775bbSdlg.Fn memcmp 88*175775bbSdlgfunctions conform to 89*175775bbSdlg.St -ansiC . 90*175775bbSdlg.Sh HISTORY 91*175775bbSdlgThe 92*175775bbSdlg.Fn skpc 93*175775bbSdlgand 94*175775bbSdlg.Fn scanc 95*175775bbSdlgfunctions are based on vax instructions of the same name. 96