History log of /freebsd-10-stable/sys/libkern/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
330512 05-Mar-2018 dab

MFC r330027

iconv uses strlen directly on user supplied memory

`iconv_sysctl_add` from `sys/libkern/iconv.c` incorrectly limits the
size of user strings, such that several out of bounds reads could have
been possible.

static int
iconv_sysctl_add(SYSCTL_HANDLER_ARGS)
{
struct iconv_converter_class *dcp;
struct iconv_cspair *csp;
struct iconv_add_in din;
struct iconv_add_out dout;
int error;

error = SYSCTL_IN(req, &din, sizeof(din));
if (error)
return error;
if (din.ia_version != ICONV_ADD_VER)
return EINVAL;
if (din.ia_datalen > ICONV_CSMAXDATALEN)
return EINVAL;
if (strlen(din.ia_from) >= ICONV_CSNMAXLEN)
return EINVAL;
if (strlen(din.ia_to) >= ICONV_CSNMAXLEN)
return EINVAL;
if (strlen(din.ia_converter) >= ICONV_CNVNMAXLEN)
return EINVAL;
...

Since the `din` struct is directly copied from userland, there is no
guarantee that the strings supplied will be NULL terminated. The
`strlen` calls could continue reading past the designated buffer
sizes.

Declaration of `struct iconv_add_in` is found in `sys/sys/iconv.h`:

struct iconv_add_in {
int ia_version;
char ia_converter[ICONV_CNVNMAXLEN];
char ia_to[ICONV_CSNMAXLEN];
char ia_from[ICONV_CSNMAXLEN];
int ia_datalen;
const void *ia_data;
};

Our strings are followed by the `ia_datalen` member, which is checked
before the `strlen` calls:

if (din.ia_datalen > ICONV_CSMAXDATALEN)

Since `ICONV_CSMAXDATALEN` has value `0x41000` (and is `unsigned`),
this ensures that `din.ia_datalen` contains at least 1 byte of 0, so
it is not possible to trigger a read out of bounds of the `struct`
however, this code is fragile and could introduce subtle bugs in the
future if the `struct` is ever modified.

PR: 207302
Submitted by: CTurt <cturt@hardenedbsd.org>
Reported by: CTurt <cturt@hardenedbsd.org>
Sponsored by: Dell EMC

319291 31-May-2017 delphij

MFC r318514-r318515, r318517, r318917

r318514:
Use size_t.

Inspired by: OpenBSD src/lib/libc/stdlib/qsort.c,v 1.11

r318515:
The current qsort(3) implementation ignores the sizes of partitions, and
always perform recursion on the left partition, then use a tail call to
handle the right partition. In the worst case this could require O(N)
levels of recursions.

Reduce the possible recursion level to log2(N) by always recursing on the
smaller partition instead.

Obtained from: PostgreSQL 9d6077abf9d6efd992a59f05ef5aba981ea32096

r318517:
Sync qsort.c with userland r318515.

(Note that MIN macro is removed in favor of sys/param.h's version).

PR: 213922

r318917:
Disconnect heimdal version of qsort.c from build because we are already
using libc's version of qsort.

PR: bin/213922

319286 31-May-2017 delphij

MFC r311989 (cem):

libkern: Remove obsolete 'register' keyword

315227 14-Mar-2017 delphij

MFC r315225:

Discard first 3072 bytes of RC4 keystream, this is a bandaid
that allows us to work on switching to a more modern PRNG.

Submitted by: Steven Chamberlain <steven pyro eu org>
Approved by: so

306536 30-Sep-2016 jkim

MFC: r284583, r285797, r285799, r287168, r298714, r298720, r298838,
r300879

Merge ACPICA up to 20160527.

Requested by: mav


/freebsd-10-stable/sys/conf/files
/freebsd-10-stable/sys/contrib/dev/acpica/acpica_prep.sh
/freebsd-10-stable/sys/contrib/dev/acpica/changes.txt
/freebsd-10-stable/sys/contrib/dev/acpica/common/acfileio.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/acgetline.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/adfile.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/adisasm.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/adwalk.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/ahids.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/ahpredef.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/ahtable.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/ahuuids.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/cmfsize.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/dmextern.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/dmrestag.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/dmtable.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/dmtables.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/dmtbdump.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/dmtbinfo.c
/freebsd-10-stable/sys/contrib/dev/acpica/common/getopt.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslanalyze.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslascii.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslbtypes.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslcodegen.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslcompile.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslcompiler.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslcompiler.l
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslcstyle.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asldebug.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asldefine.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslerror.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslexternal.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslfileio.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslfiles.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslfold.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslglobal.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslhex.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asllength.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asllisting.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asllistsup.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslload.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asllookup.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmain.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmap.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmapenter.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmapoutput.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmaputils.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmessages.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmessages.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslmethod.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslnamesp.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asloffset.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslopcodes.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asloperands.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslopt.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asloptions.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslparser.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslpld.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslpredef.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslprepkg.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslprintf.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslprune.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslresource.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslresources.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype1.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype1i.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype2.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype2d.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype2e.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype2q.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype2s.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrestype2w.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslrules.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslstartup.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslstubs.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslsupport.l
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslsupport.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asltokens.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asltransform.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asltree.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asltypes.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asltypes.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/asluuid.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslwalks.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslxref.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/aslxrefout.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtcompile.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtcompiler.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtexpress.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtfield.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtio.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtparser.l
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtparser.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtsubtable.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dttable.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dttable1.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dttable2.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dttemplate.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dttemplate.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/dtutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/preprocess.h
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/prexpress.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/prmacros.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/prparser.l
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/prparser.y
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/prscan.c
/freebsd-10-stable/sys/contrib/dev/acpica/compiler/prutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbcmds.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbconvert.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbdisply.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbexec.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbfileio.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbhistry.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbinput.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbmethod.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbnames.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbobject.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbstats.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbtest.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/debugger/dbxface.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmnames.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmobject.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmopcode.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmresrc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/disassembler/dmwalk.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsargs.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsfield.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsinit.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsobject.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dsutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dswexec.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dswload.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dswload2.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dswscope.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/dispatcher/dswstate.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evevent.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evglock.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evgpe.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evgpeblk.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evgpeinit.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evgpeutil.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evhandler.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evmisc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evregion.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evrgnini.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evsci.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evxface.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evxfevnt.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evxfgpe.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/events/evxfregn.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exconcat.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exconfig.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exconvrt.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/excreate.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exdebug.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exdump.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exfield.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exfldio.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exmisc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exmutex.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exnames.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exoparg1.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exoparg2.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exoparg3.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exoparg6.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exprep.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exregion.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exresnte.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exresolv.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exresop.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exstore.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exstoren.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exstorob.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exsystem.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/extrace.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/executer/exutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwacpi.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwesleep.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwgpe.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwpci.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwregs.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwsleep.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwtimer.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwvalid.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwxface.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsaccess.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsalloc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsarguments.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsconvert.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsdump.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nseval.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsinit.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsload.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsnames.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsobject.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsparse.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nspredef.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsprepkg.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsrepair.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsrepair2.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nssearch.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nswalk.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsxfeval.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsxfname.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/namespace/nsxfobj.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psargs.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psloop.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psobject.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psopcode.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psopinfo.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psparse.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psscope.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/pstree.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/pswalk.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/parser/psxface.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsaddr.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rscalc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rscreate.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsdump.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsinfo.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsio.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsirq.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rslist.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsmemory.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsmisc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsserial.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/resources/rsxface.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbdata.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbfadt.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbfind.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbinstal.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbprint.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbutils.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbxface.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbxfload.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/tables/tbxfroot.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utaddress.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utalloc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utascii.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utbuffer.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utcache.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utcopy.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utdebug.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utdecode.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utdelete.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/uterror.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/uteval.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utexcep.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utfileio.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utglobal.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/uthex.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utids.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utinit.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utlock.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utmath.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utmisc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utmutex.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utnonansi.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utobject.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utosi.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utownerid.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utpredef.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utprint.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utresrc.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utstate.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utstring.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/uttrack.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utuuid.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utxface.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utxferror.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utxfinit.c
/freebsd-10-stable/sys/contrib/dev/acpica/components/utilities/utxfmutex.c
/freebsd-10-stable/sys/contrib/dev/acpica/include/acapps.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acbuffer.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acclib.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/accommon.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acconfig.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acdebug.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acdisasm.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acdispat.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acevents.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acexcep.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acglobal.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/achware.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acinterp.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/aclocal.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acmacros.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acnames.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acnamesp.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acobject.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acopcode.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acoutput.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acparser.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acpi.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acpiosxf.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acpixf.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acpredef.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acresrc.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acrestyp.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acstruct.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/actables.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/actbl.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/actbl1.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/actbl2.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/actbl3.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/actypes.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acutils.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/acuuid.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/amlcode.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/amlresrc.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/platform/acenv.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/platform/acenvex.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/platform/acfreebsd.h
/freebsd-10-stable/sys/contrib/dev/acpica/include/platform/acgcc.h
/freebsd-10-stable/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c
/freebsd-10-stable/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c
/freebsd-10-stable/sys/dev/acpica/Osd/OsdDebug.c
/freebsd-10-stable/sys/dev/acpica/Osd/OsdSchedule.c
/freebsd-10-stable/sys/dev/acpica/acpi.c
strncat.c
/freebsd-10-stable/sys/sys/libkern.h
/freebsd-10-stable/sys/x86/acpica/acpi_wakeup.c
/freebsd-10-stable/usr.sbin/acpi/acpidb/Makefile
/freebsd-10-stable/usr.sbin/acpi/acpidb/acpidb.c
/freebsd-10-stable/usr.sbin/acpi/iasl/Makefile
288766 05-Oct-2015 mav

MFC r279433 (by rstone): Implement asprintf in libkern

278063 02-Feb-2015 dim

MFC r277901:

Fix a -Wcast-qual warning in libkern's strtol(), by using __DECONST. No
functional change.

MFC r277903:

Similar to r277901, fix more -Wcast-qual warnings in libkern's strtoq(),
strtoul() and strtouq(), by using __DECONST. No functional change.

275767 14-Dec-2014 andrew

Clean up our ARM assembly:

MFC 275256:

Switch to the ARM unified assembly language as the clang integrated as only
supports it. Binutils supports it when the ".syntax unified" directive
is set.

Sponsored by: ABT Systems Ltd

MFC 275264:

Update _ENTRY to use _EENTRY to reduce the common code.

MFC 275321:

Remove extra labels, ENTRY_NP already provides them.

Sponsored by: ABT Systems Ltd

MFC 275322:

Correctly a few incorrect uses of ENTRY/EENTRY and END/EEND

Sponsored by: ABT Systems Ltd

MFC 275416:

Fix the name of the coprocessor to include the "p" prefix, the clang
integrated assembler expects this.

Sponsored by: ABT Systems Ltd

MFC 275418:

Switch to unified syntax so these can be built with clang 3.5.

Sponsored by: ABT Systems Ltd

MFC 275519:

Add missing END macros to some of the xscale functions.

Sponsored by: ABT Systems Ltd

MFC 275520:

Use the unified syntax in a few more assembly files

Sponsored by: ABT Systems Ltd

MFC 275521:

Set the alignment to 4-bytes after a string as clang 3.5 can switch to
thumb mode if this is incorrect.

Sponsored by: ABT Systems Ltd

MFC 275522:

Place the literal pool after a RET otherwise clang 3.5 tries to put it too
far away from a ldr psuedo instruction. With this clang will place the
literal value here where it's close enough to be loaded.

Sponsored by: ABT Systems Ltd

MFC 275523:

Switch to an armv6k cpu, without this clang 3.5 complains "bx lr" is
unsupported as it needs a newer cpu.

Sponsored by: ABT Systems Ltd

MFC 275524:

Switch to a .cpu directive. These will work when clang 3.5 is imported
where the .arch directive is a nop.

Sponsored by: ABT Systems Ltd

275489 04-Dec-2014 delphij

MFC r274636:

Sync with userland variant.

274486 13-Nov-2014 gnn

MFC: 272906

Change the PF hash from Jenkins to Murmur3. In forwarding tests
this showed a conservative 3% incrase in PPS.

Original Differential Revision: https://reviews.freebsd.org/D461
Submitted by: des
Reviewed by: emaste

270892 31-Aug-2014 trasz

MFC r270096:

Bring in the new automounter, similar to what's provided in most other
UNIX systems, eg. MacOS X and Solaris. It uses Sun-compatible map format,
has proper kernel support, and LDAP integration.

There are still a few outstanding problems; they will be fixed shortly.

Reviewed by: allanjude@, emaste@, kib@, wblock@ (earlier versions)
Phabric: D523
Relnotes: yes
Sponsored by: The FreeBSD Foundation

269796 11-Aug-2014 ian

MFC r269390: Fix unwind info in hand-written asm (avoid nested functions).

267980 27-Jun-2014 jhb

MFC 267291:
Use strcasecmp() instead of strcmp() when checking user-supplied encoding
names so that encoding names are treated as case-insensitive. This allows
the use of 'utf-8' instead of 'UTF-8' for example and matches the behavior
of iconv(1).

PR: 167977

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


255939 29-Sep-2013 andrew

Fix ixp425 boot2 with ARM EABI:
- libkern is missing __aeabi_llsl, implement this by calling __ashldi3.
- Because of how the asm entry macros are defined the boot2 code
requires the unwind symbols to exist, include them in boot2.

Approved by: re (marius)


253719 27-Jul-2013 alfred

Fix watchdog pretimeout.

The original API calls for pow2ns, however the new APIs from
Linux call for seconds.

We need to be able to convert to/from 2^Nns to seconds in both
userland and kernel to fix this and properly compare units.


249631 19-Apr-2013 ache

Attempt to mitigate poor initialization of arc4 by one-shot
reinitialization from yarrow right after good entropy is harvested.

Approved by: secteam (delphij)
MFC after: 1 week


248395 16-Mar-2013 andrew

Add __aeabi_memset to libkern, implemented using memset, as clang may
generate calls to it.


248367 16-Mar-2013 andrew

Add END to ARM libkern assembly functions


248366 16-Mar-2013 andrew

Move the __aeabi_unwind_cpp_pr{0,1,2} functions to libkern so they can be
referenced in a non-debug kernel.


248128 10-Mar-2013 andrew

Add __aeabi_memcpy to libkern as clang may generate calls to it.


245840 23-Jan-2013 andrew

Add __aeabi_ulcmp to allow building of the LINT kernel.


245548 17-Jan-2013 andrew

Add the required __aeabi_* functions the kernel uses when built for ARM EABI


242507 03-Nov-2012 delphij

Sync strlcpy with userland version.

MFC after: 1 month


242506 03-Nov-2012 delphij

Sync strlen with userland implementation.

MFC after: 1 month


240521 14-Sep-2012 eadler

s/ is is / is /g
s/ a a / a /g

Approved by: cperciva
MFC after: 3 days


240086 04-Sep-2012 glebius

- Move jenkins.h to jenkins_hash.c
- Provide missing function that can do hashing of arbitrary sized buffer.
- Refetch lookup3.c and do only minimal edits to it, so that diff between
our jenkins_hash.c and lookup3.c is minimal.
- Add declarations for jenkins_hash(), jenkins_hash32() to sys/hash.h.
- Document these functions in hash(9)

Obtained from: http://burtleburtle.net/bob/c/lookup3.c


236899 11-Jun-2012 mjg

Fix unloading of libiconv module.

Previously it would either loop infinitely or exit with error leaking a lock.

Reported by: Will DeVries
Approved by: trasz (mentor)
MFC after: 1 week


235713 21-May-2012 kevlo

Use strcmp that I replaced by accident.


235712 21-May-2012 kevlo

Fix broken ref count

Submitted by: gcooper


235711 21-May-2012 kevlo

Fix improper handling of variadic args with ICDEBUG

PR: kern/168095
Submitted by: gcooper


235710 21-May-2012 kevlo

Remove dead code


233517 26-Mar-2012 marius

Remove second consts in r233288 in order to appease C++ compilers.
While at it, remove some style(9) bugs in libkern.h.

Submitted by: kan


233288 21-Mar-2012 marius

Declare the CRC lookup-tables const as they hardly should change at
run-time.


229366 03-Jan-2012 ed

Implement extensions on top of standards instead of the other way around.

Now that index() and rindex() have become unused, simply turn them into
wrappers around strchr() and strrchr(), respectively.


229272 02-Jan-2012 ed

Use strchr() and strrchr().

It seems strchr() and strrchr() are used more often than index() and
rindex(). Therefore, simply migrate all kernel code to use it.

For the XFS code, remove an empty line to make the code identical to
the code in the Linux kernel.


229204 01-Jan-2012 ed

Remove the now unused skpc() function.

It was only used by ufs and ext2 and I have really strong doubts that
there are other pieces of code that also use this function. If it turns
out that external drivers use this code as well, I'd be happy to migrate
or revert.

Bump __FreeBSD_version while there.


229198 01-Jan-2012 ed

Introducing memcchr(3).

It seems two of the file system drivers we have in the tree, namely ufs
and ext3, use a function called `skpc()'. The meaning of this function
does not seem to be documented in FreeBSD, but it turns out one needs to
be a VAX programmer to understand what it does.

SPKC is an instruction on the VAX that does the opposite of memchr(). It
searches for the non-equal character. Add a new function called
memcchr() to the tree that has the following advantages over skpc():

- It has a name that makes more sense than skpc(). Just like strcspn()
matches the complement of strspn(), memcchr() is the complement of
memchr().

- It is faster than skpc(). Similar to our strlen() in libc, it compares
entire words, instead of single bytes. It seems that for this routine
this yields a sixfold performance increase on amd64.

- It has a man page.


228642 17-Dec-2011 avg

retire libkern gets

Inspired by: bde
MFC after: 2 months
X-MFC-Note: if deemed a part of KPI, just call cngets internally


227650 18-Nov-2011 kevlo

Add unicode support to msdosfs and smbfs; original pathes from imura,
bug fixes by Kuan-Chung Chiu <buganini at gmail dot com>.

Tested by me in production for several days at work.


227293 07-Nov-2011 ed

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


226029 04-Oct-2011 jkim

Add strnlen() to libkern.


218965 23-Feb-2011 brucec

Fix typos - remove duplicate "is".

PR: docs/154934
Submitted by: Eitan Adler <lists at eitanadler.com>
MFC after: 3 days


215299 14-Nov-2010 ed

Add support for asterisk characters when filling in the GELI password
during boot.

Change the last argument of gets() to indicate a visibility flag and add
definitions for the numerical constants. Except for the value 2, gets()
will behave exactly the same, so existing consumers shouldn't break. We
only use it in two places, though.

Submitted by: lme (older version)


213103 24-Sep-2010 attilio

Make the RPC specific __rpc_inet_ntop() and __rpc_inet_pton() general
in the kernel (just as inet_ntoa() and inet_aton()) are and sync their
prototype accordingly with already mentioned functions.

Sponsored by: Sandvine Incorporated
Reviewed by: emaste, rstone
Approved by: dfr
MFC after: 2 weeks


208751 02-Jun-2010 raj

Provide memchr() in the libkern.

This is required by libfdt and will be compiled in conditionally only for
FDT-enabled platforms.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation


206361 07-Apr-2010 joel

Switch to our preferred 2-clause BSD license.

Approved by: bp


206360 07-Apr-2010 joel

Start copyright notice with /*-


199208 12-Nov-2009 attilio

Move inet_aton() (specular to inet_ntoa(), already present in libkern)
into libkern in order to made it usable by other modules than alias_proxy.

Obtained from: Sandvine Incorporated
Sponsored by: Sandvine Incorporated
MFC: 1 week


194665 22-Jun-2009 delphij

done method is supposed to return int.


194638 22-Jun-2009 delphij

Split tolower/toupper code from usual xlat16 kiconv table, and make it
possible to do tolower/toupper independently without code conversion.

Submitted by: imura (but bugs are mine)
Obtained from: http://people.freebsd.org/~imura/kiconv/
(1_kiconv_wctype_kern.diff, 1_kiconv_wctype_user.diff)


193860 09-Jun-2009 kmacy

add explanatory header license


193854 09-Jun-2009 kmacy

move jenkins hash to its own header in libkern


189170 28-Feb-2009 ed

Add memmove() to the kernel, making the kernel compile with Clang.

When copying big structures, LLVM generates calls to memmove(), because
it may not be able to figure out whether structures overlap. This caused
linker errors to occur. memmove() is now implemented using bcopy().
Ideally it would be the other way around, but that can be solved in the
future. On ARM we don't do add anything, because it already has
memmove().

Discussed on: arch@
Reviewed by: rdivacky


189065 26-Feb-2009 ed

Remove redundant assignment of `s'.

The variable is already initialized to `nptr'.

Found by: LLVM's scan-build


188605 14-Feb-2009 rrs

This commit fixes the issue with alias_sctp.c. No
longer do we require SCTP to be in the kernel for the
lib to be able to handle SCTP. We do this by moving
the CRC32c checksum into libkern/crc32.c and then adjusting
all routines to use the common methods. Note that this
will improve the performance of iSCSI since they were
using the old single 256 bit table lookup versus the
slicing 8 algorithm (which gives a 4x speed up in
CRC32c calculation :-D)

Reviewed by:rwatson, gnn, scottl, paolo
MFC after: 4 week? (assuming we MFC the alias_sctp changes)


185652 05-Dec-2008 jhb

Add simple locking for the in-kernel iconv code. Translation operations
do not need any locking. Opening and closing translators is serialized
using an sx lock.

Note: This depends on the earlier fix to kern_module.c to properly order
MOD_UNLOAD events.

MFC after: 2 months


183733 09-Oct-2008 thompsa

Prefix the static shl function with '__' like its parent function __qdivrem to
avoid being picked up by the DTrace fbt provider.

This is called by __udivdi3() for doing 64bit division on a 32bit arch and may
be called from within the dtrace context causing a double fault.


183299 23-Sep-2008 obrien

The kernel implemented 'memcmp' is an alias for 'bcmp'. However, memcmp
and bcmp are not the same thing. 'man bcmp' states that the return is
"non-zero" if the two byte strings are not identical. Where as,
'man memcmp' states that the return is the "difference between the
first two differing bytes (treated as unsigned char values" if the
two byte strings are not identical.

So provide a proper memcmp(9), but it is a C implementation not a tuned
assembly implementation. Therefore bcmp(9) should be preferred over memcmp(9).


181748 15-Aug-2008 kmacy

Add strcspn to libkern for use by xenbus routines. Will add to build
in separate commit.


180825 26-Jul-2008 ache

Return arc4_i = arc4_j = 0; line from previous backing out since
just found it in OpenBSD, see their sys/crypto/arc4.c, function
rc4_keysetup, line ctx->x = ctx->y = 0;

Obtained from: OpenBSD


180805 25-Jul-2008 ache

Per rwatson's request:
"If you don't get a review within a day or two, I would firmly recommend
backing out the changes"

back out all my changes as unreviewed by secteam@ yet.


180707 22-Jul-2008 ache

1) Initialize arc4_i and arc4_j to 0 after key mixing as recommended in
draft-kaukonen-cipher-arcfour-03.txt (3.1.5)

2) Drop first 768 bytes as standard RC4-drop(768)


180514 14-Jul-2008 obrien

Match the implementation of the inline function from libkern.h.


176496 23-Feb-2008 marcel

Add prototype for __cmpd2().


176492 23-Feb-2008 marcel

Bring back (without advertising clause) cmpdi2.c. It's needed on PowerPC
when the FP emulator is compiled-in.


172615 13-Oct-2007 cognet

Do not use __XSCALE__ to detect if clz is available, use _ARM_ARCH_5 instead.

MFC After: 3 days


170659 13-Jun-2007 bde

Unbreak high resolution profiling a little: use dummy asms to prevent
timing loops being optimized away.

Once apon a time, gcc promised not to optimize away timing loops, but
gcc started optimizing away the call to a null function in the timing
loop here some time between gcc-3.3.3 and gcc-3.4.6, and it started
optimizing away the timing loop itself some time between gcc-3.4.6
and gcc-4.2.


168604 10-Apr-2007 wkoszek

strchr() and strrchr() are already present in the kernel, but with less
popular names. Hence:

- comment current index() and rindex() functions, as these serve the same
functionality as, respectively, strchr() and strrchr() from userland;
- add inlined version of strchr() and strrchr(), as we tend to use them more
often;
- remove str[r]chr() definitions from ZFS code;

Reviewed by: pjd
Approved by: cognet (mentor)


168403 06-Apr-2007 kan

Add local ptototype for memset function.


168400 05-Apr-2007 kan

Add trivial MI memset function implementation. GCC mandates the
existence of this function as a linkable symbol in standalone
configurations and existing inline memcpy from libkern.h fails
this requirement.


161243 12-Aug-2006 pjd

Add strstr() function to the libkern.


158458 11-May-2006 jhb

First pass at removing Alpha kernel support.


154660 22-Jan-2006 rwatson

Convert function declarations to ANSI C.

MFC after: 1 week


154372 14-Jan-2006 ru

Ignore spurious '\0' first character read on a serial console.
This allows me to "boot -a" over a serial console. Tested on
several machines.


151897 31-Oct-2005 rwatson

Normalize a significant number of kernel malloc type names:

- Prefer '_' to ' ', as it results in more easily parsed results in
memory monitoring tools such as vmstat.

- Remove punctuation that is incompatible with using memory type names
as file names, such as '/' characters.

- Disambiguate some collisions by adding subsystem prefixes to some
memory types.

- Generally prefer lower case to upper case.

- If the same type is defined in multiple architecture directories,
attempt to use the same name in additional cases.

Not all instances were caught in this change, so more work is required to
finish this conversion. Similar changes are required for UMA zone names.


151025 06-Oct-2005 pjd

Backout strtok() addition to libkern, strsep() is enough and strtok()
is not safe.

Discussed with: stefanf, njl


150994 06-Oct-2005 pjd

Add strtok() and strtok_r() function to libkern.

MFC after: 2 weeks


149415 24-Aug-2005 imura

- Fix checking range of strings of struct iconv_add_in in libsmb and libkiconv,
- Add checking range of strings to iconv_sysctl_add().

Submitted by: Rudolf Cejka


148865 08-Aug-2005 pjd

Ha! This is a very interesting bug.
I copied strcasecmp() from userland to the kernel and it didn't worked!
I started to debug the problem and I find out that this line:

while (tolower(*us1) == tolower(*us2++)) {

was adding _3_ bytes to 'us2' pointer. Am I loosing my minds here?!...
No, in-kernel tolower() is a macro which uses its argument three times.
Bad tolower(9), no cookie.


148861 08-Aug-2005 pjd

Add strcasecmp() and strncasecmp() to libkern and connect to the build.


148342 23-Jul-2005 imura

Temporary restore a part of rev 1.6.
We must not increase a capability of buffer size here,
because codes which call these functions expect that dst and src
are the same size.
This will cause problem when someone convert a character whose
length is different between charsets on smbfs which was changed
to use xlat16 converter.


146573 24-May-2005 imura

Fix kiconv on the 64bit plathomes.

- Correct idxp pointer to point the properly address of the
each array of the kiconv character conversion tables,
so that character conversion work properly when file
systems are mounted with kiconv options.

- The definition of ICONV_CSMAXDATALEN was also bogus
because it was defined as if all machines were 32bit
computers.

Tested on: amd64
MFC after: 1 month


145611 28-Apr-2005 marcel

Update comment to direct the reader to libkern.h instead of systm.h.
The functions were moved.

Pointed out by: johan@


145604 27-Apr-2005 marcel

Refactor the CRC-32 code to enhance its usability. Move the actual
CRC logic to a new function: crc32_raw() that obtains the initial
CRC value as well as leaves any post-processing to the caller. As
such, it can be used when the initial CRC value is not ~0U or when
the final CRC value does need to be inverted (bitwise). It also
means that crc32_raw() can be called repeatedly when the data is
not available as a single block, such as for scatter/gather lists
and the likes.

Avoid the additional call overhead incured by the refactoring by
moving the implementation off crc32() to sys/systm.h and making it
inlinable. Since crc32_raw() is itself trivial and since it may
be used in loops that iterate over fragments, having it available
for inlining can be beneficial. Hence, move its implementation
to sys/systm.h as well.

Keep the original implementation of crc32() in libkern/crc32.c for
documentation purposes (as a comment of course).

Triggered by: Jose M Rodriguez (josemi at freebsd dot jazztel dot es)
Discussed on: current@
Tested on: amd64, ia64 (BVO having GPT partitions)
Jargon file candidate: BVO = By Virtue Of :-)


144545 02-Apr-2005 das

Replace the current strspn() and strcspn() with significantly faster
implementations inspired by the ones in DragonFly. Unlike the
DragonFly versions, these have a small data cache footprint, and my
tests show that they're never slower than the old code except when the
charset or the span is 0 or 1 characters. This implementation is
generally faster than DragonFly until either the charset or the span
gets in the ballpark of 32 to 64 characters.


141665 10-Feb-2005 glebius

Add strspn() to libkern.

Ok'ed by: rwatson


141209 03-Feb-2005 ru

MFlibc: Remove extra closing parenthesis.


141208 03-Feb-2005 pjd

We do want to print '\n'/'\r'.

Pointed out by: stefanf


141207 03-Feb-2005 pjd

'c' cannot be -1.

Submitted by: stefanf


141206 03-Feb-2005 pjd

- Move gets() function to libkern (I want to use it outside vfs_mount.c).
- Add buffer size limitations (overflow will not be possible anymore).
- Add 'visible' option, which will allow for passphrase reading in the
future.
- Remove special treatment of '@' and '#', those two are only confusing.

Discussed with: rwatson
MFC after: 2 weeks


140960 29-Jan-2005 rwatson

Because the argument to strvalid() is a size_t, use a size_t to iterate
over the array.

Submitted by: stefanf


140959 29-Jan-2005 rwatson

Per permission from McAfee, remove clause 3 of the BSD license on
strvalid.c.


139815 07-Jan-2005 imp

/* -> /*- for copyright notices, minor format tweaks as necessary


137463 09-Nov-2004 cognet

Use the RET macro.


137342 07-Nov-2004 cognet

Implement ffs with clz for Xscale.
Idea taken from: NetBSD


136031 01-Oct-2004 cognet

Don't attempt to profile __udivsi3() and friends, as mcount() uses them.


134398 27-Aug-2004 marcel

Move the kernel-specific logic to adjust frompc from MI to MD. For
these two reasons:
1. On ia64 a function pointer does not hold the address of the first
instruction of a functions implementation. It holds the address
of a function descriptor. Hence the user(), btrap(), eintr() and
bintr() prototypes are wrong for getting the actual code address.
2. The logic forces interrupt, trap and exception entry points to
be layed-out contiguously. This can not be achieved on ia64 and is
generally just bad programming.

The MCOUNT_FROMPC_USER macro is used to set the frompc argument to
some kernel address which represents any frompc that falls outside
the kernel text range. The macro can expand to ~0U to bail out in
that case.
The MCOUNT_FROMPC_INTR macro is used to set the frompc argument to
some kernel address to represent a call to a trap or interrupt
handler. This to avoid that the trap or interrupt handler appear to
be called from everywhere in the call graph. The macro can expand
to ~0U to prevent adjusting frompc. Note that the argument is selfpc,
not frompc.

This commit defines the macros on all architectures equivalently to
the original code in sys/libkern/mcount.c. People can take it from
here...

Compile-tested on: alpha, amd64, i386, ia64 and sparc64
Boot-tested on: i386


132710 27-Jul-2004 phk

Convert the vfsconf list to a TAILQ.

Introduce vfs_byname() function to find things on it.

Staticize vfs_nmount() function under the name vfs_donmount().

Various cleanups.


132228 15-Jul-2004 glebius

Copy qsort_r(3) from libc to libkern.

Reviewed by: phk
Approved by: julian (mentor)


129210 14-May-2004 cognet

Import libkern arm specific bits.


128965 05-May-2004 bde

Fixed some style bugs (unsorting of prototypes in previous commit, and
messes involving the idempotency guard).


128935 04-May-2004 cognet

Prototype __ashldi3(), __ashrdi3() and __lshrdi3().


128019 07-Apr-2004 imp

Remove advertising clause from University of California Regent's
license, per letter dated July 22, 1999 and email from Peter Wemm,
Alan Cox and Robert Watson.

Approved by: core, peter, alc, rwatson


127586 29-Mar-2004 robert

Bring these files closer to style(9) conformance by comparing a
dereferenced character pointer to '\0' instead of using the ! operator.


126891 12-Mar-2004 trhodes

These are changes to allow to use the Intel C/C++ compiler (lang/icc)
to build the kernel. It doesn't affect the operation if gcc.

Most of the changes are just adding __INTEL_COMPILER to #ifdef's, as
icc v8 may define __GNUC__ some parts may look strange but are
necessary.

Additional changes:
- in_cksum.[ch]:
* use a generic C version instead of the assembly version in the !gcc
case (ASM code breaks with the optimizations icc does)
-> no bad checksums with an icc compiled kernel
Help from: andre, grehan, das
Stolen from: alpha version via ppc version
The entire checksum code should IMHO be replaced with the DragonFly
version (because it isn't guaranteed future revisions of gcc will
include similar optimizations) as in:
---snip---
Revision Changes Path
1.12 +1 -0 src/sys/conf/files.i386
1.4 +142 -558 src/sys/i386/i386/in_cksum.c
1.5 +33 -69 src/sys/i386/include/in_cksum.h
1.5 +2 -0 src/sys/netinet/igmp.c
1.6 +0 -1 src/sys/netinet/in.h
1.6 +2 -0 src/sys/netinet/ip_icmp.c

1.4 +3 -4 src/contrib/ipfilter/ip_compat.h
1.3 +1 -2 src/sbin/natd/icmp.c
1.4 +0 -1 src/sbin/natd/natd.c
1.48 +1 -0 src/sys/conf/files
1.2 +0 -1 src/sys/conf/files.amd64
1.13 +0 -1 src/sys/conf/files.i386
1.5 +0 -1 src/sys/conf/files.pc98
1.7 +1 -1 src/sys/contrib/ipfilter/netinet/fil.c
1.10 +2 -3 src/sys/contrib/ipfilter/netinet/ip_compat.h
1.10 +1 -1 src/sys/contrib/ipfilter/netinet/ip_fil.c
1.7 +1 -1 src/sys/dev/netif/txp/if_txp.c
1.7 +1 -1 src/sys/net/ip_mroute/ip_mroute.c
1.7 +1 -2 src/sys/net/ipfw/ip_fw2.c
1.6 +1 -2 src/sys/netinet/igmp.c
1.4 +158 -116 src/sys/netinet/in_cksum.c
1.6 +1 -1 src/sys/netinet/ip_gre.c
1.7 +1 -2 src/sys/netinet/ip_icmp.c
1.10 +1 -1 src/sys/netinet/ip_input.c
1.10 +1 -2 src/sys/netinet/ip_output.c
1.13 +1 -2 src/sys/netinet/tcp_input.c
1.9 +1 -2 src/sys/netinet/tcp_output.c
1.10 +1 -1 src/sys/netinet/tcp_subr.c
1.10 +1 -1 src/sys/netinet/tcp_syncache.c
1.9 +1 -2 src/sys/netinet/udp_usrreq.c

1.5 +1 -2 src/sys/netinet6/ipsec.c
1.5 +1 -2 src/sys/netproto/ipsec/ipsec.c
1.5 +1 -1 src/sys/netproto/ipsec/ipsec_input.c
1.4 +1 -2 src/sys/netproto/ipsec/ipsec_output.c

and finally remove
sys/i386/i386 in_cksum.c
sys/i386/include in_cksum.h
---snip---
- endian.h:
* DTRT in C++ mode
- quad.h:
* we don't use gcc v1 anymore, remove support for it
Suggested by: bde (long ago)
- assym.h:
* avoid zero-length arrays (remove dependency on a gcc specific
feature)
This change changes the contents of the object file, but as it's
only used to generate some values for a header, and the generator
knows how to handle this, there's no impact in the gcc case.
Explained by: bde
Submitted by: Marius Strobl <marius@alchemy.franken.de>
- aicasm.c:
* minor change to teach it about the way icc spells "-nostdinc"
Not approved by: gibbs (no reply to my mail)
- bump __FreeBSD_version (lang/icc needs to know about the changes)

Incarnations of this patch survive gcc compiles since a loooong time,
I use it on my desktop. An icc compiled kernel works since Nov. 2003
(exceptions: snd_* if used as modules), it survives a build of the
entire ports collection with icc.

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by: -arch
Submitted by: netchild


125725 12-Feb-2004 grehan

Remove register keyword and constify tmp values. This fixes
PPC compile warning - PPC is the only consumer of this code
path.


124514 14-Jan-2004 des

Translate from GNU C to ISO C.


124482 13-Jan-2004 des

Cast to unsigned to avoid sign-extension problems.


124480 13-Jan-2004 des

Add C implementations of ffsl(), fls() and flsl().


124479 13-Jan-2004 des

ANSIfy, de-register, replace VAX reference with actual description.


123293 08-Dec-2003 fjoe

Make msdosfs long filenames matching case insensitive again.

PR: 59765
Submitted by: Ryuichiro Imura <imura@ryu16.org>


120492 26-Sep-2003 fjoe

- Support for multibyte charsets in LIBICONV.
- CD9660_ICONV, NTFS_ICONV and MSDOSFS_ICONV kernel options
(with corresponding modules).
- kiconv(3) for loadable charset conversion tables support.

Submitted by: Ryuichiro Imura <imura@ryu16.org>


118938 15-Aug-2003 silby

Lock down arc4random so it can be safely called w/o Giant.

Minor code reorganization was required, but the only functional
change was that the first 1024 bytes of output are thrown out
after each reseed, rather than just the initial seed.


118732 10-Aug-2003 ache

Lower initial drop value to 50, it is enough to hide linearity


118017 25-Jul-2003 bde

Backed out the micro-optimization in 1.4. It was to help gcc-2.6.3
on i486's (and probably i386's), but it has had very little effect
since gcc-2.7 or gcc-2.95. With gcc-3.3, it gave a small
pessimization for at least i386's, athlon-xp's and pentium4's, a
small optimization (I think) for pentium1's, and made no difference
for i386's. (movzbl is best for all the later processors, and the
micro-optimization was to stop it being used on i486's.)


116189 11-Jun-2003 obrien

Use __FBSDID().


114216 29-Apr-2003 kan

Deprecate machine/limits.h in favor of new sys/limits.h.
Change all in-tree consumers to include <sys/limits.h>

Discussed on: standards@
Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>


111518 26-Feb-2003 rwatson

Further GC of M_STRING, missed previously.


111517 26-Feb-2003 rwatson

Replace license with two-clause BSD; an old license template with three
clauses was used by mistake.


111506 25-Feb-2003 rwatson

Pass a malloc type into the libkern strdup() implementation explicitly,
so that callers can specify what malloc pool the resulting memory
should come from.

Requested by: phk


111317 23-Feb-2003 rwatson

Add an implementation of strdup() to libkern. Allocated memory is of
type M_STRING, now defined in malloc.h. Useful when string parsing
must occur using the kernel strsep() and we want to avoid toasting
the source string.

Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


111119 19-Feb-2003 imp

Back out M_* changes, per decision of the TRB.

Approved by: trb


110725 11-Feb-2003 schweikh

Improve a comment and undo a bogus s/a/an/ in a comment. An asm guru
should add more comments explaining which registers hold which variables.

Spotted by: bde


110605 10-Feb-2003 hsu

Add restrict keyword to string functions.

Reviewed by: bde


110422 05-Feb-2003 ache

Since we drop NSHUFF values now, set default seed to what it becomes
after srandom(1)


110322 04-Feb-2003 ache

Drop NSHUFF values right after srandom() to remove part of seed -> 1st
value correlation. Correlation still remains because of algorithm limits.


110281 03-Feb-2003 ache

Park & Miller PRNG can be safely initialized with any value but 0 and stuck
at 0 as designed. Its BSD adaptation tries to fight it by mapping 0 to
2147483647 after calculation, but this method not works since 2147483647
seed returns to 0 again on the next interation. Instead of after calculation
mapping, map 0 to another value _before_ calculation, so it never stucks.


109623 21-Jan-2003 alfred

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


108533 01-Jan-2003 schweikh

Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.


106696 09-Nov-2002 alfred

Fix instances of macros with improperly parenthasized arguments.

Verified by: md5


104900 11-Oct-2002 phk

Slight overhaul of arc4random() and friends.

One bug fixed: Use getmicrouptime() to trigger reseeds so that we
cannot be tricked by a clock being stepped backwards.

Express parameters in natural units and with natural names.

Don't use struct timeval more than we need to.

Various stylistic and readability polishing.

Introduce arc4rand(void *ptr, u_int len, int reseed) function which
returns a stream of pseudo-random bytes, observing the automatic
reseed criteria as well as allowing forced reseeds.

Rewrite arc4random() in terms of arc4rand().

Sponsored by: DARPA & NAI Labs.


104799 10-Oct-2002 rwatson

Hook up strsep(3) to libkern following a repo-copy by Peter. This will
allow us to avoid nasty by-hand string parsing stuff in a number of
places in the kernel, reducing the risk of unexpected consequences
for kernel correctness.


104667 08-Oct-2002 phk

Allow for multiple #includes of this file.


104652 08-Oct-2002 dd

Import the libc fnmatch() into the kernel. This will be used by,
among other things, the DEVFS rule subsystem to match nodes against a
path pattern supplied by the user.

fnmatch.c was repo-copied from src/lib/libc/gen/fnmatch.c, and the
only changes to it are those necessary to make it compile in the
kernel. The relevant parts of fnmatch.h were imported into libkern.h.

Approved by: -arch


104568 06-Oct-2002 mux

Fix a bunch of s/int */size_t */.


103000 06-Sep-2002 peter

Use sys/libkern.h not /usr/include/string.h


102281 22-Aug-2002 jhb

Include sys/libkern.h for the kernel prototypes of these libkern functions
instead of including the userland string.h header.

Prompted by: breakage with old string.h from recent machine/types.h fix
Approved by: peter (in principle)


100080 15-Jul-2002 markm

Convert GNU variadic macros to the ISO 9X variety.


97521 29-May-2002 phk

For some reason this didn't get added in my previous commit.


94401 11-Apr-2002 mike

Remove bogus include of <machine/ansi.h>.


92889 21-Mar-2002 obrien

Remove 'register' keyword.


92741 20-Mar-2002 alfred

Remove __P.


91826 07-Mar-2002 rwatson

DBA update: used the wrong of several NAI DBAs.


91394 27-Feb-2002 tmm

Add the following functions/macros to support byte order conversions and
device drivers for bus system with other endinesses than the CPU (using
interfaces compatible to NetBSD):

- bwap16() and bswap32(). These have optimized implementations on some
architectures; for those that don't, there exist generic implementations.
- macros to convert from a certain byte order to host byte order and vice
versa, using a naming scheme like le16toh(), htole16().
These are implemented using the bswap functions.
- stream bus space access functions, which do not perform a byte order
conversion (while the normal access functions would if the bus endianess
differs from the CPU endianess).

htons(), htonl(), ntohs() and ntohl() are implemented using the new
functions above for kernel usage. None of the above interfaces is currently
exported to user land.

Make use of the new functions in a few places where local implementations
of the same functionality existed.

Reviewed by: mike, bde
Tested on alpha by: mike


90868 18-Feb-2002 mike

o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
complexities associated with having MD (asm and inline) versions, and
having to prevent exposure of these functions in other headers that
happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on: alpha, i386
Reviewed by: bde, jake, tmm


90819 18-Feb-2002 rwatson

Add a 'strvalid()' call to libkern. Given a character pointer, and
buffer length, determine if the pointer is to a valid string. Currently,
the only check is whether a '\0' appears in the buffer. This is useful
when pulling in a structure from userland that may contain one or more
strings, and validity testing must be performed on elements of the
structure. When copying normal string arguments, copyinstr() is
expected to be used.


90045 01-Feb-2002 obrien

* Remove __P and convert to ANSI prototypes.
* Remove 'register'. (some functions had 7+ register functions...)
* Fix SCM ID's.


86170 07-Nov-2001 obrien

rcsid[]->__FBSDID


86104 05-Nov-2001 phk

Garbage call!

These files have been obsoleted by compiler technology (such as it is
for gcc) for quite some time.


84579 06-Oct-2001 dfr

Implement these using mux1 and extr.u. I'll update the userland versions
similarly. Actually, they should be inline on gcc.


83289 10-Sep-2001 peter

Fix a warning in bsearch(). Like index() etc, it de-qualifies its
arguments. Caveat Emptor. However, the only two consumer of it (cam)
deals with it correctly and preserves the constness.


82565 30-Aug-2001 bde

Fixed some typos, verboseness and misformatting in comments.


82543 30-Aug-2001 silby

Minor improvements to arc4random():

- Decrease reseeding interval from every 64 to every 16384 runs
to reduce entropy usage.
- Add time based reseeding. (Every 5 minutes.)
- Throw away the first 256 words of output as suggested in
"Weaknesses in the Key Scheduling Algorithm of RC4."

Reviewed by: Mark Murray
MFC After: jkh says ok


81264 08-Aug-2001 peter

We do not have UPAGES following the tail end of the user VM space anymore.


80274 24-Jul-2001 kris

Sync to OpenBSD (update comment and minor style change).

Obtained from: OpenBSD
MFC after: 1 week


79418 08-Jul-2001 julian

A set of changes to reduce the number of include files the kernel
takes from /usr/include. I cannot check them on alpha.. (will try beast)

Briefly looked at by: Warner Losh <imp@harmony.village.org>


77117 24-May-2001 obrien

Make the rcsid and FreeBSD IDs more sane in the wcs* and wmem* files.
Do the same for the non-wcs*/wmem* files while I'm here.


75332 09-Apr-2001 bp

Add function prototypes and base module for kernel side iconv library.
Add simple "xlat" converter which performs 8to8 table based conversion.
Unicode converter will be added in the near future.

Reviewed by: silence on arch@
Files placement reviewed by: bde
Obtained from: smbfs


74840 27-Mar-2001 ken

Rewrite of the CAM error recovery code.

Some of the major changes include:

- The SCSI error handling portion of cam_periph_error() has
been broken out into a number of subfunctions to better
modularize the code that handles the hierarchy of SCSI errors.
As a result, the code is now much easier to read.

- String handling and error printing has been significantly
revamped. We now use sbufs to do string formatting instead
of using printfs (for the kernel) and snprintf/strncat (for
userland) as before.

There is a new catchall error printing routine,
cam_error_print() and its string-based counterpart,
cam_error_string() that allow the kernel and userland
applications to pass in a CCB and have errors printed out
properly, whether or not they're SCSI errors. Among other
things, this helped eliminate a fair amount of duplicate code
in camcontrol.

We now print out more information than before, including
the CAM status and SCSI status and the error recovery action
taken to remedy the problem.

- sbufs are now available in userland, via libsbuf. This
change was necessary since most of the error printing code
is shared between libcam and the kernel.

- A new transfer settings interface is included in this checkin.
This code is #ifdef'ed out, and is primarily intended to aid
discussion with HBA driver authors on the final form the
interface should take. There is example code in the ahc(4)
driver that implements the HBA driver side of the new
interface. The new transfer settings code won't be enabled
until we're ready to switch all HBA drivers over to the new
interface.

src/Makefile.inc1,
lib/Makefile: Add libsbuf. It must be built before libcam,
since libcam uses sbuf routines.

libcam/Makefile: libcam now depends on libsbuf.

libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the
sbuf sources from sys/kern.

bsd.libnames.mk: Add LIBSBUF.

camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically
linked, we can't depend on the dynamic linker
to pull in libsbuf.

camcontrol.c: Use cam_error_print() instead of checking for
CAM_SCSI_STATUS_ERROR on every failed CCB.

sbuf.9: Change the prototypes for sbuf_cat() and
sbuf_cpy() so that the source string is now a
const char *. This is more in line wth the
standard system string functions, and helps
eliminate warnings when dealing with a const
source buffer.

Fix a typo.

cam.c: Add description strings for the various CAM
error status values, as well as routines to
look up those strings.

Add new cam_error_string() and
cam_error_print() routines for userland and
the kernel.

cam.h: Add a new CAM flag, CAM_RETRY_SELTO.

Add enumerated types for the various options
available with cam_error_print() and
cam_error_string().

cam_ccb.h: Add new transfer negotiation structures/types.

Change inq_len in the ccb_getdev structure to
be "reserved". This field has never been
filled in, and will be removed when we next
bump the CAM version.

cam_debug.h: Fix typo.

cam_periph.c: Modularize cam_periph_error(). The SCSI error
handling part of cam_periph_error() is now
in camperiphscsistatuserror() and
camperiphscsisenseerror().

In cam_periph_lock(), increase the reference
count on the periph while we wait for our lock
attempt to succeed so that the periph won't go
away while we're sleeping.

cam_xpt.c: Add new transfer negotiation code. (ifdefed
out)

Add a new function, xpt_path_string(). This
is a string/sbuf analog to xpt_print_path().

scsi_all.c: Revamp string handing and error printing code.
We now use sbufs for much of the string
formatting code. More of that code is shared
between userland the kernel.

scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly
useful in the first place.

Add a new error action, SS_REQSENSE. (Send a
request sense and then retry the command.)
This is useful when the controller hasn't
performed autosense for some reason.

Change the default actions around a bit.

scsi_cd.c,
scsi_da.c,
scsi_pt.c,
scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection
timeouts shouldn't be covered by a sense flag.

scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO.

Get rid of the last vestiges of a read/write
interface.

libkern/bsearch.c,
sys/libkern.h,
conf/files: Add bsearch.c, which is needed for some of the
new table lookup routines.

aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if
CAM_NEW_TRAN_CODE is defined.

sbuf.h,
subr_sbuf.c: Add the appropriate #ifdefs so sbufs can
compile and run in userland.

Change sbuf_printf() to use vsnprintf()
instead of kvprintf(), which is only available
in the kernel.

Change the source string for sbuf_cpy() and
sbuf_cat() to be a const char *.

Add __BEGIN_DECLS and __END_DECLS around
function prototypes since they're now exported
to userland.

kdump/mkioctls: Include stdio.h before cam.h since cam.h now
includes a function with a FILE * argument.

Submitted by: gibbs (mostly)
Reviewed by: jdp, marcel (libsbuf makefile changes)
Reviewed by: des (sbuf changes)
Reviewed by: ken


72358 11-Feb-2001 markm

RIP <machine/lock.h>.

Some things needed bits of <i386/include/lock.h> - cy.c now has its
own (only) copy of the COM_(UN)LOCK() macros, and IMASK_(UN)LOCK()
has been moved to <i386/include/apic.h> (AKA <machine/apic.h>).
Reviewed by: jhb


71191 17-Jan-2001 jedgar

- Reverse the order of two loop invariant to ensure strlcat() does not
attempt to read memory when siz is 0
- Clarify comments referring to strlcat() usage

PR: 24278, 24295
Submitted by: Tony Finch <dot@dotat.at>
Richard Kettlewell <rjk@greenend.org.uk>
Reviewed by: -audit


70949 12-Jan-2001 benno

Convert all instances of:

#include "quad.h"

to:

#include <libkern/quad.h>

as the former breaks under a kernel build.
This change had already been performed on the files that were used in other
kernel builds, however the PowerPC kernel build seems to require some that
weren't being used.

Reviewed by: obrien, peter


69727 07-Dec-2000 phk

Add __ucmpdi2 prototype to quelch a warning.


69520 02-Dec-2000 markm

Recouple arc4random(9) to the entropy device. This works whether the
entropy device is loaded or not.

If the entropy device is NOT loaded, the the quality of perturbations
supplied by this will suffer.


69134 25-Nov-2000 alfred

add threadsafe version of inet_ntoa (inet_ntoa_r takes a buffer to fill)
this is used by some debugging functions


67110 14-Oct-2000 phk

Fix compilation of profiled kernels by including <machine/lock.h>


66633 04-Oct-2000 dfr

Next round of fixes to the ia64 code. This includes simulated clock and
disk drivers along with a load of fixes to context switching, fork
handling and a load of other stuff I can't remember now. This takes us as
far as start_init() before it dies. I guess now I will have to finish off
the VM system and syscall handling :-).


65754 11-Sep-2000 jhb

Back out previous revision now that sys/random.h is properly fixed.


65724 11-Sep-2000 jhb

Add #include's of sys/proc.h and sys/param.h to silence a warning.


62072 25-Jun-2000 markm

Comment out unavailable call. This needs to be revisited when the entropy
device is complete.
Reviewed by: dfr


59874 01-May-2000 peter

Add $FreeBSD$


55206 29-Dec-1999 peter

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


54411 10-Dec-1999 peter

Zap c_index() and c_rindex(). Bruce prefers these to implicitly convert
a const into a non-const as they do in libc. I feel that defeating the
type checking like that quite evil, but that's the way it is.


54006 01-Dec-1999 archie

Eliminate compiler warning.


53893 29-Nov-1999 dan

In the extremely miniscule chance that read_random returns <= 0, don't try
and use that return code as a modulus (panics are bad, mmmkay?)


53864 28-Nov-1999 dan

Address the concerns of the ``randomness'' of the initial PRNG. Now, we
use bits from /dev/random to stir the S-box. Also add an internal counter to
keep the S-box stirred on a regular basis.

Reviewed by: msmith


53842 28-Nov-1999 dan

Introduce OpenBSD-like Random PIDs. Controlled by a sysctl knob
(kern.randompid), which is currently defaulted off. Use ARC4 (RC4) for our
random number generation, which will not get me executed for violating
crypto laws; a Good Thing(tm).

Reviewed and Approved by: bde, imp


53648 24-Nov-1999 archie

Change the prototype of the strto* routines to make the second
parameter a char ** instead of a const char **. This make these
kernel routines consistent with the corresponding libc userland
routines.

Which is actually 'correct' is debatable, but consistency and
following the spec was deemed more important in this case.

Reviewed by (in concept): phk, bde


53492 21-Nov-1999 peter

Tempt fate and stop index from converting a const char * into a char *.
I've made a seperate version (c_index() etc) that use const/const, but
I'm not sure it's worth it considering there is one file in the tree
that uses index on const strings (kern_linker.c) and it's easily adjusted
to scan the strings directly (and is perhaps more efficient that way).


52845 03-Nov-1999 phk

Move strto{u}[ql]() into their own libkern files.

Urged by: bde


50477 28-Aug-1999 peter

$Id$ -> $FreeBSD$


49594 10-Aug-1999 imp

Use the latest version of these files from OpenBSD.

1) Safty change from casper dik was added to OpenBSD's sources since I
grabbed them. milltert@openbsd.org
2) Split up strlcpy to improve efficiency of the common case.
milltert@openbsd.org
3) Cleanup of cross references for man page. {alex,aaron}@openbsd.org

Pointed out by: deraadt@openbsd.org


49593 10-Aug-1999 imp

Import strl{cat,cpy} from OpenBSD.

Obtained from: OpenBSD


48020 19-Jun-1999 dfr

Add a fast version of bcmp which compares longwords at a time.

Submitted by: Peter Jeremy <jeremyp@gsmx07.alcatel.com.au>


47698 02-Jun-1999 bde

Backed out the previous backout. We may as well have a version of ucmpdi2.c
that actually compiles, and I use it for i386's with 64 bit longs.


47193 14-May-1999 gibbs

Nuke ucmpdi2.c from i386/libkern to serve as a reminder that switch
statements on 64bit values generate poor code.

Requested by: bde


47157 14-May-1999 gibbs

Add ucmpdi2.c to i386 libkern build. Its required for some quad
manipulation in the aic7xxx driver.


43315 28-Jan-1999 dillon

Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile


41434 01-Dec-1998 nate

- Fix modulo bug.

Reminded by: bde


38409 17-Aug-1998 bde

Converted rcsid to $Id$ again. There shouldn't be any rcsids in the kernel.


37629 14-Jul-1998 bde

Changed to the C9x draft spelling of the (unsigned) integral type
suitable for holding object pointers (ptrint_t -> uintptr_t).
Added corresponding signed type (intptr_t). Changed/added
corresponding non-C9x types for function pointers to match. Don't
use nonstandard types to implement these types, and don't comment
on them in <machine/types.h>.


37289 30-Jun-1998 phk

#include sys/libkern.h instead of stdlib.h.
PR: 7105
Reviewed by: phk
Submitted by: Robert Watson <robert+freebsd@cyrus.watson.org>


36849 10-Jun-1998 dfr

Add initial support for the FreeBSD/alpha kernel. This is very much a
work in progress and has never booted a real machine. Initial
development and testing was done using SimOS (see
http://simos.stanford.edu for details). On the SimOS simulator, this
port successfully reaches single-user mode and has been tested with
loads as high as one copy of /bin/ls :-).

Obtained from: partly from NetBSD/alpha


35210 15-Apr-1998 bde

Support compiling with `gcc -ansi'.


32286 06-Jan-1998 dyson

Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.

When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.

When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.

A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.

Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.


31017 07-Nov-1997 phk

Rename some local variables to avoid shadowing other local variables.

Found by: -Wshadow


27845 02-Aug-1997 bde

Removed unused #includes.


26492 07-Jun-1997 ache

Style optimization in newly added POSIX range []] conformance, redo
'for' loop as do...while and remove variable unneded now


26486 06-Jun-1997 ache

Add missing FNM_PERIOD check for '[' range
Don't treat !^ as first characters in the range, just as negate sign
[/] never match if FNM_PATHNAME


26484 06-Jun-1997 ache

1) Now conforms POSIX.2 2.8.3.2 requirements about []] pattern
2) Treat unclosed [ range in pattern as regular characters (bash style)


25269 29-Apr-1997 jdp

Fix a bug that caused some false mismatches when both FNM_PATHNAME
and FNM_LEADING_DIR were specified and the pattern ended with "*".
Example: pattern="src/usr.sbin/w*", string="src/usr.sbin/watch/watch.8,v".
This should match, but did not.


24632 04-Apr-1997 ache

Eliminate some function calls when locale not used


24630 04-Apr-1997 ache

Speedup in case locale not used


22975 22-Feb-1997 peter

Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.


21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


19276 31-Oct-1996 ache

collate_range_cmp -> __collate_range_cmp


19169 25-Oct-1996 bde

Unremoved used #include of <sys/systm.h> for the !GUPROF case.


19132 23-Oct-1996 ache

GNU-style changes:
1) Rename FNM_ICASE to FNM_CASEFOLD
2) Add FNM_LEADING_DIR
Add proper (unsigned char) casts to tolower().
Use 'char' function argument for proper sign extension


19059 20-Oct-1996 wosch

add flag FNM_ICASE for case insensitve search

Reviewed by: ache


19000 17-Oct-1996 bde

Improved non-statistical (GUPROF) profiling:
- use a more accurate and more efficient method of compensating for
overheads. The old method counted too much time against leaf
functions.
- normally use the Pentium timestamp counter if available.
On Pentiums, the times are now accurate to within a couple of cpu
clock cycles per function call in the (unlikely) event that there
are no cache misses in or caused by the profiling code.
- optionally use an arbitrary Pentium event counter if available.
- optionally regress to using the i8254 counter.
- scaled the i8254 counter by a factor of 128. Now the i8254 counters
overflow slightly faster than the TSC counters for a 150MHz Pentium :-)
(after about 16 seconds). This is to avoid fractional overheads.

files.i386:
permon.c temporarily has to be classified as a profiling-routine
because a couple of functions in it may be called from profiling code.

options.i386:
- I586_CTR_GUPROF is currently unused (oops).
- I586_PMC_GUPROF should be something like 0x70000 to enable (but not
use unless prof_machdep.c is changed) support for Pentium event
counters. 7 is a control mode and the counter number 0 is somewhere
in the 0000 bits (see perfmon.h for the encoding).

profile.h:
- added declarations.
- cleaned up separation of user mode declarations.

prof_machdep.c:
Mostly clock-select changes. The default clock can be changed by
editing kmem. There should be a sysctl for this.

subr_prof.c:
- added copyright.
- calibrate overheads for the new method.
- documented new method.
- fixed races and and machine dependencies in start/stop code.

mcount.c:
Use the new overhead compensation method.

gmon.h:
- changed GPROF4 counter type from unsigned to int. Oops, this should
be machine-dependent and/or int32_t.
- reorganized overhead counters.

Submitted by: Pentium event counter changes mostly by wollman


18474 23-Sep-1996 peter

add simple srandom() and prototype


18207 10-Sep-1996 bde

Updated #includes to 4.4Lite style.


17974 31-Aug-1996 bde

Fixed the easy cases of const poisoning in the kernel. Cosmetic.


17971 31-Aug-1996 bde

Don't depend in the kernel on the gcc feature of doing arithmetic on
pointers of type `void *'. Warn about this in future.


17880 28-Aug-1996 bde

Removed sccsids and rcsids and added Id$ to save space like everything
else in libkern.


17879 28-Aug-1996 bde

Cleaned up interrupt masking by declaring the state variable in a
machine-dependent macro and passing it to all machine-dependent
macros.

Eliminated the state variable for the GUPROF case.


17552 12-Aug-1996 ache

Convert to newly aded collate compare function


17533 12-Aug-1996 ache

Use collate for alpha character ranges


17141 12-Jul-1996 jkh

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


16175 07-Jun-1996 nate

Added index() which will be used shortly in some fixes to the ibcs2
emulation code.


15543 02-May-1996 phk

removed:
CLBYTES PD_SHIFT PGSHIFT NBPG PGOFSET CLSIZELOG2 CLSIZE pdei()
ptei() kvtopte() ptetov() ispt() ptetoav() &c &c
new:
NPDEPG

Major macro cleanup.


15312 19-Apr-1996 bde

Don't include <sys/types.h> when it isn't used.

This commit covers most of the ANSI library functions. Many others only
need <sys/types.h> because they use u_xxx.


15311 19-Apr-1996 bde

Don't depend on <sys/types.h> including <sys/cdefs.h>.


13617 24-Jan-1996 phk

Extend to handle all radix < 37


13459 16-Jan-1996 bde

Moved BCD declarations to the correct header (libkern.h).

Fixed BCD declarations. They didn't match their definitions...

libkern.h, bcd.c:
KNFised. `indent' worked 99% perfectly on bcd.c. It worked 99%
_imperfectly_ on subr_prf.c.


13445 15-Jan-1996 phk

My wife is busy making me a new conical hat, so you don't need to
send any to me this time. Commited an old copy of this files where
the tables were swapped. Duh!.


13436 15-Jan-1996 phk

Add the bcd <-> bin and hex -> ascii tables.


13122 30-Dec-1995 peter

recording cvs-1.6 file death


13116 30-Dec-1995 bde

Copied mcount.c from the library again. #include'ing it via a relative
path to a possibly-nonexistent place didn't work well enough. Sigh.


13107 29-Dec-1995 bde

Implemented non-statistical kernel profiling. This is based on
looking at a high resolution clock for each of the following events:
function call, function return, interrupt entry, interrupt exit,
and interesting branches. The differences between the times of
these events are added at appropriate places in a ordinary histogram
(as if very fast statistical profiling sampled the pc at those
places) so that ordinary gprof can be used to analyze the times.

gmon.h:
Histogram counters need to be 4 bytes for microsecond resolutions.
They will need to be larger for the 586 clock.
The comments were vax-centric and wrong even on vaxes. Does anyone
disagree?

gprof4.c:
The standard gprof should support counters of all integral sizes
and the size of the counter should be in the gmon header. This
hack will do until then. (Use gprof4 -u to examine the results
of non-statistical profiling.)

config/*:
Non-statistical profiling is configured with `config -pp'.
`config -p' still gives ordinary profiling.

kgmon/*:
Non-statistical profiling is enabled with `kgmon -B'. `kgmon -b'
still enables ordinary profiling (and distables non-statistical
profiling) if non-statistical profiling is configured.


13031 26-Dec-1995 bde

Removed almost all traces of libkern.a. The objects that were in
libkern.a are now specified by listing their source files in
files.${MACHINE}. The list is machine-dependent to save space.
All the necessary object for each machine must be linked into the
kernel in case an lkm wants one.


13030 26-Dec-1995 bde

Added prototypes.


12932 19-Dec-1995 nate

Add-back strlen.c to the library in case a kernel is compiled without
optimization. Gcc only in-lines calls to strlen with optimization
turned on.


12151 08-Nov-1995 phk

Add qsort() to libkern, taken from libc.


11223 05-Oct-1995 phk

Comment out, but don't delete stuff we don't use.
Classify in "gcc stuff" and "legitimate stuff".


9485 11-Jul-1995 bde

Rearrange the inner loop of scanc() to get better code on i*86's
(on an i486, 10 cycles (+ cache misses) instead of 15). The
change should be a no-op if the compiler is any good. The best
possible i*86 code for the same algorithm is only 1 more cycle
faster on i486's so I don't want to bother implementing an
assembler version.

scanc() is a bottleneck for OPOST processing. It is naturally
about 4 times as slow as bcopy() on 32-bit systems.


8876 30-May-1995 rgrimes

Remove trailing whitespace.


8870 30-May-1995 rgrimes

Remove trailing whitespace.


7268 23-Mar-1995 rgrimes

Do not install libkern into /usr/lib, blank target install: added.


7109 17-Mar-1995 phk

<libkern/libkern.h> has moved to <sys/libkern.h> (repository copy).
Since /usr/include/libkern doesn't and shouldn't exist, this is the
least evil way to handle this.


7090 16-Mar-1995 bde

Add and move declarations to fix all of the warnings from `gcc -Wimplicit'
(except in netccitt, netiso and netns) and most of the warnings from
`gcc -Wnested-externs'. Fix all the bugs found. There were no serious
ones.


7088 16-Mar-1995 wollman

Add inet_ntoa() and replace ARP's private routine with same.


6761 27-Feb-1995 ugen

Add strncmp() function..I need it and
hope nobody will eat me alive for this..:)


5460 10-Jan-1995 bde

Always build libkern_p.a. `NOPROFILE' should only control user libraries.


4477 14-Nov-1994 bde

Hide the declaration of ffs() if an inline ffs() is implemented.

I couldn't find a better way to avoid compiler warnings about
redundant and/or inconsistent declaration of ffs(). I'd like to
be able to declare prototypes in general headers without committing
to implementing them as `static inline' or `extern', but there
seems to be no way to do this with gcc-2.6.1. E.g.,

int foo(void);
static __inline int foo(void) { return 1; }

causes a warning about the linkage mismatch, while the opposite
order causes a warning about the redundant declaration.


3891 26-Oct-1994 jkh

I'm going to nuke strtol() for now. Now I need strncmp() and rather
that add it too, and end up fighting an unwanted battle right now,
I'm just going to back away from both and start including my own private
copies of everything. I'm not going to use _anything_ from libkern
until we decide its fate.


3854 25-Oct-1994 jkh

Add strtol() to libkern in support of some other work I'm doing.
I just know I'm going to get flamed for adding for the miserable
abortion that is libkern, but what am I supposed to do? At least I
didn't drag in the ctype stuff! :-)


2872 18-Sep-1994 bde

Use new-style declarations for min/max functions so that
"gcc -Wstrict-prototypes" doesn't emit warnings about them.

Write each min/max functions on a single line so that the similarity and
triviality of the functions is more obvious.

Put the quad min/max functions in the correct place (aphabetical order).

The u_quad min/max functions are missing. Only 3 or 4 of the min/max
functions are actually used. sys/socketvar.h ``should use "lmin" but
it doesn't exist now''. lmin does exist now, but isn't used. Since we
depend on gcc for `inline', perhaps we should depend on it for __typeof
and function-expressions and use only macros min() and max() that work
for any types (I'm not sure how to handle mixed types).


2799 15-Sep-1994 paul

Added -DKERNEL and added support for kernel profiling.
Reviewed by: Bruce


2412 30-Aug-1994 dg

Added qmin and qmax functions to deal with quad_t's.


1817 02-Aug-1994 dg

Added $Id$


1573 27-May-1994 rgrimes

BSD 4.4 Lite Lib Sources


1542 24-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1541,
which included commits to RCS files with non-trunk default branches.