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