Commit Graph

238 Commits

Author SHA1 Message Date
Olivier Houchard
def35d2ca7 Do not use __XSCALE__ to detect if clz is available, use _ARM_ARCH_5 instead.
MFC After:	3 days
2007-10-13 12:05:36 +00:00
Bruce Evans
7df7fc34a3 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.
2007-06-13 06:17:48 +00:00
Wojciech A. Koszek
f7caeade24 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)
2007-04-10 21:42:12 +00:00
Alexander Kabaev
c8c0ba192e Add local ptototype for memset function. 2007-04-06 00:06:26 +00:00
Alexander Kabaev
616db5f04c 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.
2007-04-05 22:02:39 +00:00
Pawel Jakub Dawidek
73c0c41140 Add strstr() function to the libkern. 2006-08-12 15:28:39 +00:00
John Baldwin
67ab9fd759 First pass at removing Alpha kernel support. 2006-05-11 22:25:28 +00:00
Robert Watson
b059cbd3eb Convert function declarations to ANSI C.
MFC after:	1 week
2006-01-22 00:46:40 +00:00
Ruslan Ermilov
90ee1f3a04 Ignore spurious '\0' first character read on a serial console.
This allows me to "boot -a" over a serial console.  Tested on
several machines.
2006-01-14 20:45:02 +00:00
Robert Watson
5bb84bc84b 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.
2005-10-31 15:41:29 +00:00
Pawel Jakub Dawidek
24f8c87b41 Backout strtok() addition to libkern, strsep() is enough and strtok()
is not safe.

Discussed with:	stefanf, njl
2005-10-06 19:06:07 +00:00
Pawel Jakub Dawidek
5e66cbaeaf Add strtok() and strtok_r() function to libkern.
MFC after:	2 weeks
2005-10-06 11:10:09 +00:00
R. Imura
f373a82454 - 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
2005-08-24 12:38:26 +00:00
Pawel Jakub Dawidek
57169160b0 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.
2005-08-08 19:38:00 +00:00
Pawel Jakub Dawidek
c812ca43bd Add strcasecmp() and strncasecmp() to libkern and connect to the build. 2005-08-08 18:31:13 +00:00
R. Imura
8fa523fb95 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.
2005-07-23 16:52:57 +00:00
R. Imura
bf8ba9ab3a 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
2005-05-24 15:38:08 +00:00
Marcel Moolenaar
61d596a8ff Update comment to direct the reader to libkern.h instead of systm.h.
The functions were moved.

Pointed out by: johan@
2005-04-28 05:50:18 +00:00
Marcel Moolenaar
ee6bcf1223 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 :-)
2005-04-27 22:26:45 +00:00
David Schultz
f0ceb98f93 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.
2005-04-02 18:52:44 +00:00
Gleb Smirnoff
75737f3423 Add strspn() to libkern.
Ok'ed by:	rwatson
2005-02-10 20:39:39 +00:00
Ruslan Ermilov
27667f5821 MFlibc: Remove extra closing parenthesis. 2005-02-03 15:51:39 +00:00
Pawel Jakub Dawidek
f3830f0482 We do want to print '\n'/'\r'.
Pointed out by:	stefanf
2005-02-03 15:47:30 +00:00
Pawel Jakub Dawidek
6513f57682 'c' cannot be -1.
Submitted by:	stefanf
2005-02-03 15:23:27 +00:00
Pawel Jakub Dawidek
f627315f1e - 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
2005-02-03 15:10:58 +00:00
Robert Watson
dc66c5fe6f Because the argument to strvalid() is a size_t, use a size_t to iterate
over the array.

Submitted by:	stefanf
2005-01-29 13:34:22 +00:00
Robert Watson
debb2f87b6 Per permission from McAfee, remove clause 3 of the BSD license on
strvalid.c.
2005-01-29 13:04:04 +00:00
Warner Losh
d6ea02625f /* -> /*- for copyright notices, minor format tweaks as necessary 2005-01-07 00:24:33 +00:00
Olivier Houchard
2fd21813b0 Use the RET macro. 2004-11-09 16:47:47 +00:00
Olivier Houchard
ec98ae75da Implement ffs with clz for Xscale.
Idea taken from:	NetBSD
2004-11-07 16:53:29 +00:00
Olivier Houchard
fbaa643e9a Don't attempt to profile __udivsi3() and friends, as mcount() uses them. 2004-10-01 16:44:08 +00:00
Marcel Moolenaar
0f2fe153bc 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
2004-08-27 19:42:35 +00:00
Poul-Henning Kamp
3dfe213e61 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.
2004-07-27 22:32:01 +00:00
Gleb Smirnoff
b1e34c44ef Copy qsort_r(3) from libc to libkern.
Reviewed by:	phk
Approved by:	julian (mentor)
2004-07-15 23:58:23 +00:00
Olivier Houchard
03f110294b Import libkern arm specific bits. 2004-05-14 12:28:31 +00:00
Bruce Evans
c7e459ed6c Fixed some style bugs (unsorting of prototypes in previous commit, and
messes involving the idempotency guard).
2004-05-05 15:12:55 +00:00
Olivier Houchard
967f542177 Prototype __ashldi3(), __ashrdi3() and __lshrdi3(). 2004-05-04 22:15:54 +00:00
Warner Losh
f36cfd49ad 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
2004-04-07 20:46:16 +00:00
Robert Drehmel
9fbb80baff Bring these files closer to style(9) conformance by comparing a
dereferenced character pointer to '\0' instead of using the ! operator.
2004-03-29 21:15:41 +00:00
Tom Rhodes
a122cca953 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
2004-03-12 21:45:33 +00:00
Peter Grehan
9a580b5e18 Remove register keyword and constify tmp values. This fixes
PPC compile warning - PPC is the only consumer of this code
path.
2004-02-12 03:23:13 +00:00
Dag-Erling Smørgrav
29554ea51a Translate from GNU C to ISO C. 2004-01-14 07:47:10 +00:00
Dag-Erling Smørgrav
8746a69a28 Cast to unsigned to avoid sign-extension problems. 2004-01-13 16:02:20 +00:00
Dag-Erling Smørgrav
f04ecda547 Add C implementations of ffsl(), fls() and flsl(). 2004-01-13 15:36:34 +00:00
Dag-Erling Smørgrav
53546cd058 ANSIfy, de-register, replace VAX reference with actual description. 2004-01-13 15:35:22 +00:00
Max Khon
0f4e4130e1 Make msdosfs long filenames matching case insensitive again.
PR:		59765
Submitted by:	Ryuichiro Imura <imura@ryu16.org>
2003-12-08 08:32:20 +00:00
Max Khon
c4f02a891f - 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>
2003-09-26 20:26:25 +00:00
Mike Silbersack
2f823fa326 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.
2003-08-15 06:34:47 +00:00
Andrey A. Chernov
696fe9ddcd Lower initial drop value to 50, it is enough to hide linearity 2003-08-10 17:56:58 +00:00
Bruce Evans
4066649d5a 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.)
2003-07-25 15:54:23 +00:00
David E. O'Brien
ab0de15baf Use __FBSDID(). 2003-06-11 05:37:42 +00:00
Alexander Kabaev
104a9b7e3e 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>
2003-04-29 13:36:06 +00:00
Robert Watson
05c06d15e8 Further GC of M_STRING, missed previously. 2003-02-26 01:00:29 +00:00
Robert Watson
ae4f61f0d7 Replace license with two-clause BSD; an old license template with three
clauses was used by mistake.
2003-02-26 00:59:53 +00:00
Robert Watson
354d43abf3 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
2003-02-25 22:11:39 +00:00
Robert Watson
96c4266cb3 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
2003-02-23 14:30:17 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
Jens Schweikhardt
00ad14c702 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
2003-02-11 20:15:11 +00:00
Jeffrey Hsu
93eb73aa48 Add restrict keyword to string functions.
Reviewed by:	bde
2003-02-10 00:36:27 +00:00
Andrey A. Chernov
dba8967550 Since we drop NSHUFF values now, set default seed to what it becomes
after srandom(1)
2003-02-05 21:28:52 +00:00
Andrey A. Chernov
a36d6a59f0 Drop NSHUFF values right after srandom() to remove part of seed -> 1st
value correlation. Correlation still remains because of algorithm limits.
2003-02-04 11:33:09 +00:00
Andrey A. Chernov
b413a2949e 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.
2003-02-03 10:29:47 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Alfred Perlstein
29f194457c Fix instances of macros with improperly parenthasized arguments.
Verified by: md5
2002-11-09 12:55:07 +00:00
Poul-Henning Kamp
2c38619b52 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.
2002-10-11 13:13:08 +00:00
Robert Watson
469fda7e25 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.
2002-10-10 17:02:11 +00:00
Poul-Henning Kamp
943e5db958 Allow for multiple #includes of this file. 2002-10-08 07:24:19 +00:00
Dima Dorfman
20a6cb8cb8 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
2002-10-08 04:15:55 +00:00
Maxime Henrion
5ff9562781 Fix a bunch of s/int */size_t */. 2002-10-06 12:20:09 +00:00
Peter Wemm
105d189b78 Use sys/libkern.h not /usr/include/string.h 2002-09-06 06:04:36 +00:00
John Baldwin
452bffb217 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)
2002-08-22 20:08:07 +00:00
Mark Murray
a8966f6598 Convert GNU variadic macros to the ISO 9X variety. 2002-07-15 13:34:50 +00:00
Poul-Henning Kamp
fc3f3f6575 For some reason this didn't get added in my previous commit. 2002-05-29 21:58:12 +00:00
Mike Barcroft
17dfcdfaed Remove bogus include of <machine/ansi.h>. 2002-04-11 06:53:40 +00:00
David E. O'Brien
8fb3f3f682 Remove 'register' keyword. 2002-03-21 18:49:23 +00:00
Alfred Perlstein
8febc6ba17 Remove __P. 2002-03-20 02:15:46 +00:00
Robert Watson
6e8a94b268 DBA update: used the wrong of several NAI DBAs. 2002-03-07 17:52:03 +00:00
Thomas Moestl
90ce56c287 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
2002-02-27 17:16:18 +00:00
Mike Barcroft
fd8e4ebc8c 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
2002-02-18 20:35:27 +00:00
Robert Watson
5578933d56 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.
2002-02-18 00:37:03 +00:00
David E. O'Brien
b231cb3945 * Remove __P and convert to ANSI prototypes.
* Remove 'register'.  (some functions had 7+ register functions...)
* Fix SCM ID's.
2002-02-01 01:32:19 +00:00
David E. O'Brien
de5fe5d53b rcsid[]->__FBSDID 2001-11-07 19:55:16 +00:00
Poul-Henning Kamp
c717903379 Garbage call!
These files have been obsoleted by compiler technology (such as it is
for gcc) for quite some time.
2001-11-05 21:10:09 +00:00
Doug Rabson
79b2d7690f Implement these using mux1 and extr.u. I'll update the userland versions
similarly. Actually, they should be inline on gcc.
2001-10-06 08:35:05 +00:00
Peter Wemm
531c9dd5f4 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.
2001-09-10 10:33:46 +00:00
Bruce Evans
60f8e3af92 Fixed some typos, verboseness and misformatting in comments. 2001-08-30 12:30:58 +00:00
Mike Silbersack
3a7810bc39 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
2001-08-30 01:15:25 +00:00
Peter Wemm
44c76a36f8 We do not have UPAGES following the tail end of the user VM space anymore. 2001-08-08 04:02:22 +00:00
Kris Kennaway
6979f76ff6 Sync to OpenBSD (update comment and minor style change).
Obtained from:	OpenBSD
MFC after:	1 week
2001-07-24 11:34:22 +00:00
Julian Elischer
0b1ae8097d 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>
2001-07-08 04:56:07 +00:00
David E. O'Brien
5864b79cd2 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.
2001-05-24 08:47:42 +00:00
Boris Popov
6f2d8adb12 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
2001-04-09 09:39:29 +00:00
Kenneth D. Merry
3393f8daa3 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
2001-03-27 05:45:52 +00:00
Mark Murray
d888fc4e73 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
2001-02-11 10:44:09 +00:00
Chris D. Faulhaber
420923e972 - 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
2001-01-17 20:51:16 +00:00
Benno Rice
aab719f090 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
2001-01-12 07:28:46 +00:00
Poul-Henning Kamp
aac61d609c Add __ucmpdi2 prototype to quelch a warning. 2000-12-07 22:28:20 +00:00
Mark Murray
4cb1e53914 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.
2000-12-02 16:23:54 +00:00
Alfred Perlstein
ed0fe1449c add threadsafe version of inet_ntoa (inet_ntoa_r takes a buffer to fill)
this is used by some debugging functions
2000-11-25 03:14:31 +00:00