xref: /titanic_50/usr/src/lib/libshell/misc/ERRATA.txt (revision 5d3b8cb7141cfa596d20cdc5043b8a6df635938d)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21
22#
23# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27#
28# ERRATA.txt
29#
30# Errata/problems/notes about problems in the current sources
31#
32
33######## Errata #001: ########
34The usage of |posix_spawn()| has been manually disabled because there seems to be a
35race condition which cases sporadic failures like this:
36-- snip --
37$ builtin | fgrep sum | fgrep sum
38/usr/ast/bin/sum
39/usr/bin/sum
40$ builtin | fgrep sum | fgrep sum
41fgrep: fgrep: cannot execute [Exec format error]
42-- snip --.
43The following files have been changed:
44-- snip --
45Index: src/lib/libast/sparcv9/include/ast/ast_lib.h
46===================================================================
47--- usr/src/lib/libast/sparcv9/include/ast/ast_lib.h	(revision 888)
48+++ usr/src/lib/libast/sparcv9/include/ast/ast_lib.h	(working copy)
49@@ -160,7 +160,7 @@
50 #define _hdr_unistd	1	/* #include <unistd.h> ok */
51 #define _lib_vfork	1	/* vfork exists and it works */
52 #define _real_vfork	1	/* vfork child shares data with parent */
53-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
54+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
55 #define _stream_peek	1	/* ioctl(I_PEEK) works */
56 #define _socket_peek	1	/* recv(MSG_PEEK) works */
57 #define _hdr_string	1	/* #include <string.h> ok */
58Index: src/lib/libast/sparcv9/src/lib/libast/ast_lib.h
59===================================================================
60--- usr/src/lib/libast/sparcv9/src/lib/libast/ast_lib.h	(revision 888)
61+++ usr/src/lib/libast/sparcv9/src/lib/libast/ast_lib.h	(working copy)
62@@ -139,7 +139,7 @@
63 #define _hdr_unistd	1	/* #include <unistd.h> ok */
64 #define _lib_vfork	1	/* vfork exists and it works */
65 #define _real_vfork	1	/* vfork child shares data with parent */
66-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
67+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
68 #define _stream_peek	1	/* ioctl(I_PEEK) works */
69 #define _socket_peek	1	/* recv(MSG_PEEK) works */
70 #define _hdr_string	1	/* #include <string.h> ok */
71Index: src/lib/libast/sparcv9/src/lib/libast/FEATURE/lib
72===================================================================
73--- usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/lib	(revision 888)
74+++ usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/lib	(working copy)
75@@ -139,7 +139,7 @@
76 #define _hdr_unistd	1	/* #include <unistd.h> ok */
77 #define _lib_vfork	1	/* vfork exists and it works */
78 #define _real_vfork	1	/* vfork child shares data with parent */
79-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
80+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
81 #define _stream_peek	1	/* ioctl(I_PEEK) works */
82 #define _socket_peek	1	/* recv(MSG_PEEK) works */
83 #define _hdr_string	1	/* #include <string.h> ok */
84Index: src/lib/libast/sparc/include/ast/ast_lib.h
85===================================================================
86--- usr/src/lib/libast/sparc/include/ast/ast_lib.h	(revision 888)
87+++ usr/src/lib/libast/sparc/include/ast/ast_lib.h	(working copy)
88@@ -171,7 +171,7 @@
89 #define _hdr_unistd	1	/* #include <unistd.h> ok */
90 #define _lib_vfork	1	/* vfork exists and it works */
91 #define _real_vfork	1	/* vfork child shares data with parent */
92-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
93+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
94 #define _stream_peek	1	/* ioctl(I_PEEK) works */
95 #define _socket_peek	1	/* recv(MSG_PEEK) works */
96 #define _hdr_string	1	/* #include <string.h> ok */
97Index: src/lib/libast/sparc/src/lib/libast/ast_lib.h
98===================================================================
99--- usr/src/lib/libast/sparc/src/lib/libast/ast_lib.h	(revision 888)
100+++ usr/src/lib/libast/sparc/src/lib/libast/ast_lib.h	(working copy)
101@@ -150,7 +150,7 @@
102 #define _hdr_unistd	1	/* #include <unistd.h> ok */
103 #define _lib_vfork	1	/* vfork exists and it works */
104 #define _real_vfork	1	/* vfork child shares data with parent */
105-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
106+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
107 #define _stream_peek	1	/* ioctl(I_PEEK) works */
108 #define _socket_peek	1	/* recv(MSG_PEEK) works */
109 #define _hdr_string	1	/* #include <string.h> ok */
110Index: src/lib/libast/sparc/src/lib/libast/FEATURE/lib
111===================================================================
112--- usr/src/lib/libast/sparc/src/lib/libast/FEATURE/lib	(revision 888)
113+++ usr/src/lib/libast/sparc/src/lib/libast/FEATURE/lib	(working copy)
114@@ -150,7 +150,7 @@
115 #define _hdr_unistd	1	/* #include <unistd.h> ok */
116 #define _lib_vfork	1	/* vfork exists and it works */
117 #define _real_vfork	1	/* vfork child shares data with parent */
118-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
119+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
120 #define _stream_peek	1	/* ioctl(I_PEEK) works */
121 #define _socket_peek	1	/* recv(MSG_PEEK) works */
122 #define _hdr_string	1	/* #include <string.h> ok */
123Index: src/lib/libast/i386/include/ast/ast_lib.h
124===================================================================
125--- usr/src/lib/libast/i386/include/ast/ast_lib.h	(revision 888)
126+++ usr/src/lib/libast/i386/include/ast/ast_lib.h	(working copy)
127@@ -171,7 +171,7 @@
128 #define _hdr_unistd	1	/* #include <unistd.h> ok */
129 #define _lib_vfork	1	/* vfork exists and it works */
130 #define _real_vfork	1	/* vfork child shares data with parent */
131-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
132+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
133 #define _stream_peek	1	/* ioctl(I_PEEK) works */
134 #define _socket_peek	1	/* recv(MSG_PEEK) works */
135 #define _hdr_string	1	/* #include <string.h> ok */
136Index: src/lib/libast/i386/src/lib/libast/ast_lib.h
137===================================================================
138--- usr/src/lib/libast/i386/src/lib/libast/ast_lib.h	(revision 888)
139+++ usr/src/lib/libast/i386/src/lib/libast/ast_lib.h	(working copy)
140@@ -150,7 +150,7 @@
141 #define _hdr_unistd	1	/* #include <unistd.h> ok */
142 #define _lib_vfork	1	/* vfork exists and it works */
143 #define _real_vfork	1	/* vfork child shares data with parent */
144-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
145+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
146 #define _stream_peek	1	/* ioctl(I_PEEK) works */
147 #define _socket_peek	1	/* recv(MSG_PEEK) works */
148 #define _hdr_string	1	/* #include <string.h> ok */
149Index: src/lib/libast/i386/src/lib/libast/FEATURE/lib
150===================================================================
151--- usr/src/lib/libast/i386/src/lib/libast/FEATURE/lib	(revision 888)
152+++ usr/src/lib/libast/i386/src/lib/libast/FEATURE/lib	(working copy)
153@@ -150,7 +150,7 @@
154 #define _hdr_unistd	1	/* #include <unistd.h> ok */
155 #define _lib_vfork	1	/* vfork exists and it works */
156 #define _real_vfork	1	/* vfork child shares data with parent */
157-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
158+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
159 #define _stream_peek	1	/* ioctl(I_PEEK) works */
160 #define _socket_peek	1	/* recv(MSG_PEEK) works */
161 #define _hdr_string	1	/* #include <string.h> ok */
162Index: src/lib/libast/amd64/include/ast/ast_lib.h
163===================================================================
164--- usr/src/lib/libast/amd64/include/ast/ast_lib.h	(revision 888)
165+++ usr/src/lib/libast/amd64/include/ast/ast_lib.h	(working copy)
166@@ -160,7 +160,7 @@
167 #define _hdr_unistd	1	/* #include <unistd.h> ok */
168 #define _lib_vfork	1	/* vfork exists and it works */
169 #define _real_vfork	1	/* vfork child shares data with parent */
170-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
171+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
172 #define _stream_peek	1	/* ioctl(I_PEEK) works */
173 #define _socket_peek	1	/* recv(MSG_PEEK) works */
174 #define _hdr_string	1	/* #include <string.h> ok */
175Index: src/lib/libast/amd64/src/lib/libast/ast_lib.h
176===================================================================
177--- usr/src/lib/libast/amd64/src/lib/libast/ast_lib.h	(revision 888)
178+++ usr/src/lib/libast/amd64/src/lib/libast/ast_lib.h	(working copy)
179@@ -139,7 +139,7 @@
180 #define _hdr_unistd	1	/* #include <unistd.h> ok */
181 #define _lib_vfork	1	/* vfork exists and it works */
182 #define _real_vfork	1	/* vfork child shares data with parent */
183-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
184+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
185 #define _stream_peek	1	/* ioctl(I_PEEK) works */
186 #define _socket_peek	1	/* recv(MSG_PEEK) works */
187 #define _hdr_string	1	/* #include <string.h> ok */
188Index: src/lib/libast/amd64/src/lib/libast/FEATURE/lib
189===================================================================
190--- usr/src/lib/libast/amd64/src/lib/libast/FEATURE/lib	(revision 888)
191+++ usr/src/lib/libast/amd64/src/lib/libast/FEATURE/lib	(working copy)
192@@ -139,7 +139,7 @@
193 #define _hdr_unistd	1	/* #include <unistd.h> ok */
194 #define _lib_vfork	1	/* vfork exists and it works */
195 #define _real_vfork	1	/* vfork child shares data with parent */
196-#define _lib_posix_spawn	2	/* posix_spawn exists and it works and its worth using */
197+#define _lib_posix_spawn	1	/* posix_spawn exists and it works and its worth using */
198 #define _stream_peek	1	/* ioctl(I_PEEK) works */
199 #define _socket_peek	1	/* recv(MSG_PEEK) works */
200 #define _hdr_string	1	/* #include <string.h> ok */
201-- snip --
202
203
204######## Errata #002: ########
205The usage of |mmap()| has been manually enabled to improve I/O performance.
206The following files have been changed:
207-- snip --
208Index: usr/src/lib/libast/sparcv9/include/ast/ast_mmap.h
209===================================================================
210--- usr/src/lib/libast/sparcv9/include/ast/ast_mmap.h	(revision 1701)
211+++ usr/src/lib/libast/sparcv9/include/ast/ast_mmap.h	(working copy)
212@@ -28,6 +28,7 @@
213 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
214 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
215 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
216+#define _mmap_worthy	2	/* mmap is good */
217
218 /* some systems get it wrong but escape concise detection */
219 #ifndef _NO_MMAP
220Index: usr/src/lib/libast/sparcv9/src/lib/libast/ast_mmap.h
221===================================================================
222--- usr/src/lib/libast/sparcv9/src/lib/libast/ast_mmap.h	(revision 1701)
223+++ usr/src/lib/libast/sparcv9/src/lib/libast/ast_mmap.h	(working copy)
224@@ -7,6 +7,7 @@
225 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
226 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
227 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
228+#define _mmap_worthy	2	/* mmap is good */
229
230 /* some systems get it wrong but escape concise detection */
231 #ifndef _NO_MMAP
232Index: usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mmap
233===================================================================
234--- usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mmap	(revision 1701)
235+++ usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mmap	(working copy)
236@@ -7,6 +7,7 @@
237 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
238 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
239 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
240+#define _mmap_worthy	2	/* mmap is good */
241
242 /* some systems get it wrong but escape concise detection */
243 #ifndef _NO_MMAP
244Index: usr/src/lib/libast/sparc/include/ast/ast_mmap.h
245===================================================================
246--- usr/src/lib/libast/sparc/include/ast/ast_mmap.h	(revision 1701)
247+++ usr/src/lib/libast/sparc/include/ast/ast_mmap.h	(working copy)
248@@ -28,7 +28,7 @@
249 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
250 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
251 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
252-#define _mmap_worthy	1	/* mmap is good */
253+#define _mmap_worthy	2	/* mmap is good */
254
255 /* some systems get it wrong but escape concise detection */
256 #ifndef _NO_MMAP
257Index: usr/src/lib/libast/sparc/src/lib/libast/ast_mmap.h
258===================================================================
259--- usr/src/lib/libast/sparc/src/lib/libast/ast_mmap.h	(revision 1701)
260+++ usr/src/lib/libast/sparc/src/lib/libast/ast_mmap.h	(working copy)
261@@ -7,7 +7,7 @@
262 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
263 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
264 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
265-#define _mmap_worthy	1	/* mmap is good */
266+#define _mmap_worthy	2	/* mmap is good */
267
268 /* some systems get it wrong but escape concise detection */
269 #ifndef _NO_MMAP
270Index: usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mmap
271===================================================================
272--- usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mmap	(revision 1701)
273+++ usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mmap	(working copy)
274@@ -7,7 +7,7 @@
275 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
276 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
277 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
278-#define _mmap_worthy	1	/* mmap is good */
279+#define _mmap_worthy	2	/* mmap is good */
280
281 /* some systems get it wrong but escape concise detection */
282 #ifndef _NO_MMAP
283Index: usr/src/lib/libast/i386/include/ast/ast_mmap.h
284===================================================================
285--- usr/src/lib/libast/i386/include/ast/ast_mmap.h	(revision 1701)
286+++ usr/src/lib/libast/i386/include/ast/ast_mmap.h	(working copy)
287@@ -28,6 +28,7 @@
288 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
289 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
290 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
291+#define _mmap_worthy	2	/* mmap is good */
292
293 /* some systems get it wrong but escape concise detection */
294 #ifndef _NO_MMAP
295Index: usr/src/lib/libast/i386/src/lib/libast/ast_mmap.h
296===================================================================
297--- usr/src/lib/libast/i386/src/lib/libast/ast_mmap.h	(revision 1701)
298+++ usr/src/lib/libast/i386/src/lib/libast/ast_mmap.h	(working copy)
299@@ -7,6 +7,7 @@
300 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
301 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
302 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
303+#define _mmap_worthy	2	/* mmap is good */
304
305 /* some systems get it wrong but escape concise detection */
306 #ifndef _NO_MMAP
307Index: usr/src/lib/libast/i386/src/lib/libast/FEATURE/mmap
308===================================================================
309--- usr/src/lib/libast/i386/src/lib/libast/FEATURE/mmap	(revision 1701)
310+++ usr/src/lib/libast/i386/src/lib/libast/FEATURE/mmap	(working copy)
311@@ -7,6 +7,7 @@
312 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
313 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
314 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
315+#define _mmap_worthy	2	/* mmap is good */
316
317 /* some systems get it wrong but escape concise detection */
318 #ifndef _NO_MMAP
319Index: usr/src/lib/libast/amd64/include/ast/ast_mmap.h
320===================================================================
321--- usr/src/lib/libast/amd64/include/ast/ast_mmap.h	(revision 1701)
322+++ usr/src/lib/libast/amd64/include/ast/ast_mmap.h	(working copy)
323@@ -28,6 +28,7 @@
324 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
325 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
326 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
327+#define _mmap_worthy	2	/* mmap is good */
328
329 /* some systems get it wrong but escape concise detection */
330 #ifndef _NO_MMAP
331Index: usr/src/lib/libast/amd64/src/lib/libast/ast_mmap.h
332===================================================================
333--- usr/src/lib/libast/amd64/src/lib/libast/ast_mmap.h	(revision 1701)
334+++ usr/src/lib/libast/amd64/src/lib/libast/ast_mmap.h	(working copy)
335@@ -7,6 +7,7 @@
336 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
337 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
338 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
339+#define _mmap_worthy	2	/* mmap is good */
340
341 /* some systems get it wrong but escape concise detection */
342 #ifndef _NO_MMAP
343Index: usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mmap
344===================================================================
345--- usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mmap	(revision 1701)
346+++ usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mmap	(working copy)
347@@ -7,6 +7,7 @@
348 #define _lib_mmap64	1	/* mmap64 interface and implementation work */
349 #define _mmap_anon	1	/* use mmap MAP_ANON to get raw memory */
350 #define _mmap_devzero	1	/* use mmap on /dev/zero to get raw memory */
351+#define _mmap_worthy	2	/* mmap is good */
352
353 /* some systems get it wrong but escape concise detection */
354 #ifndef _NO_MMAP
355-- snip --
356
357
358######## Errata #003: ########
359A workaround was added for a problem with the "multiline" editor mode which
360occurs when the edit line becomes longer than the terminal's width and the
361terminal cursor is not at position 0 when PS1 is send to the terminal.
362
363For example: The user executes a $ printf "foo"<enter> # the prompt will start
364at position 3 instead of 0. If the user enters a command which is longer than
365the terminal width and then removes enougth characters that the edit line fits
366again into one line the "foo" at the beginning will be overwritten with the
367prompt.
368
369The workaround is to add $(printf "%*s\r%s" COLUMNS "") at the beginning of
370PS1 set by /etc/ksh.kshrc, this causes the shell to move to the beginning
371of the next line if the terminal cursor is not at position 0.
372
373
374######## Errata #004: ########
375A workaround has been added for a probem with the AST "tail" builtin which
376causes "tail" to sleep too long when polling for data in "follow" mode.
377The following files have been changed:
378-- snip --
379Index: src/lib/libcmd/common/tail.c
380===================================================================
381--- usr/src/lib/libcmd/common/tail.c	(revision 1701)
382+++ usr/src/lib/libcmd/common/tail.c	(working copy)
383@@ -636,7 +636,14 @@
384 		{
385 			if (sfsync(sfstdout))
386 				error(ERROR_system(1), "write error");
387+#if 0
388 			sleep(1);
389+#else
390+			{
391+				struct timespec rqt = { 0L, 1000000000L/4L };
392+				(void)nanosleep(&rqt, NULL);
393+			}
394+#endif
395 			n = 0;
396 			pp = 0;
397 			while (fp)
398-- snip --
399
400
401######## Errata #005: ########
402The POSIX "cksum"/CRC and AT&T "sum" codepaths in libsum have been reworked
403and then backpoprted to address a performance regression on some
404machine/architecture combinations.
405The following files have been changed:
406-- snip --
407Index: usr/src/lib/libsum/common/sum-crc.c
408===================================================================
409--- usr/src/lib/libsum/common/sum-crc.c	(revision 1724)
410+++ usr/src/lib/libsum/common/sum-crc.c	(working copy)
411@@ -48,7 +48,8 @@
412 	Crcnum_t		init;
413 	Crcnum_t		done;
414 	Crcnum_t		xorsize;
415-	Crcnum_t		tab[256];
416+	const Crcnum_t		*tab; /* use |const| to give the compiler a hint that the data won't change */
417+	Crcnum_t		tabdata[256];
418 	unsigned int		addsize;
419 	unsigned int		rotate;
420 } Crc_t;
421@@ -56,6 +57,62 @@
422 #define CRC(p,s,c)		(s = (s >> 8) ^ (p)->tab[(s ^ (c)) & 0xff])
423 #define CRCROTATE(p,s,c)	(s = (s << 8) ^ (p)->tab[((s >> 24) ^ (c)) & 0xff])
424
425+static const
426+Crcnum_t posix_cksum_tab[256] = {
427+	0x00000000U,
428+	0x04c11db7U, 0x09823b6eU, 0x0d4326d9U, 0x130476dcU, 0x17c56b6bU,
429+	0x1a864db2U, 0x1e475005U, 0x2608edb8U, 0x22c9f00fU, 0x2f8ad6d6U,
430+	0x2b4bcb61U, 0x350c9b64U, 0x31cd86d3U, 0x3c8ea00aU, 0x384fbdbdU,
431+	0x4c11db70U, 0x48d0c6c7U, 0x4593e01eU, 0x4152fda9U, 0x5f15adacU,
432+	0x5bd4b01bU, 0x569796c2U, 0x52568b75U, 0x6a1936c8U, 0x6ed82b7fU,
433+	0x639b0da6U, 0x675a1011U, 0x791d4014U, 0x7ddc5da3U, 0x709f7b7aU,
434+	0x745e66cdU, 0x9823b6e0U, 0x9ce2ab57U, 0x91a18d8eU, 0x95609039U,
435+	0x8b27c03cU, 0x8fe6dd8bU, 0x82a5fb52U, 0x8664e6e5U, 0xbe2b5b58U,
436+	0xbaea46efU, 0xb7a96036U, 0xb3687d81U, 0xad2f2d84U, 0xa9ee3033U,
437+	0xa4ad16eaU, 0xa06c0b5dU, 0xd4326d90U, 0xd0f37027U, 0xddb056feU,
438+	0xd9714b49U, 0xc7361b4cU, 0xc3f706fbU, 0xceb42022U, 0xca753d95U,
439+	0xf23a8028U, 0xf6fb9d9fU, 0xfbb8bb46U, 0xff79a6f1U, 0xe13ef6f4U,
440+	0xe5ffeb43U, 0xe8bccd9aU, 0xec7dd02dU, 0x34867077U, 0x30476dc0U,
441+	0x3d044b19U, 0x39c556aeU, 0x278206abU, 0x23431b1cU, 0x2e003dc5U,
442+	0x2ac12072U, 0x128e9dcfU, 0x164f8078U, 0x1b0ca6a1U, 0x1fcdbb16U,
443+	0x018aeb13U, 0x054bf6a4U, 0x0808d07dU, 0x0cc9cdcaU, 0x7897ab07U,
444+	0x7c56b6b0U, 0x71159069U, 0x75d48ddeU, 0x6b93dddbU, 0x6f52c06cU,
445+	0x6211e6b5U, 0x66d0fb02U, 0x5e9f46bfU, 0x5a5e5b08U, 0x571d7dd1U,
446+	0x53dc6066U, 0x4d9b3063U, 0x495a2dd4U, 0x44190b0dU, 0x40d816baU,
447+	0xaca5c697U, 0xa864db20U, 0xa527fdf9U, 0xa1e6e04eU, 0xbfa1b04bU,
448+	0xbb60adfcU, 0xb6238b25U, 0xb2e29692U, 0x8aad2b2fU, 0x8e6c3698U,
449+	0x832f1041U, 0x87ee0df6U, 0x99a95df3U, 0x9d684044U, 0x902b669dU,
450+	0x94ea7b2aU, 0xe0b41de7U, 0xe4750050U, 0xe9362689U, 0xedf73b3eU,
451+	0xf3b06b3bU, 0xf771768cU, 0xfa325055U, 0xfef34de2U, 0xc6bcf05fU,
452+	0xc27dede8U, 0xcf3ecb31U, 0xcbffd686U, 0xd5b88683U, 0xd1799b34U,
453+	0xdc3abdedU, 0xd8fba05aU, 0x690ce0eeU, 0x6dcdfd59U, 0x608edb80U,
454+	0x644fc637U, 0x7a089632U, 0x7ec98b85U, 0x738aad5cU, 0x774bb0ebU,
455+	0x4f040d56U, 0x4bc510e1U, 0x46863638U, 0x42472b8fU, 0x5c007b8aU,
456+	0x58c1663dU, 0x558240e4U, 0x51435d53U, 0x251d3b9eU, 0x21dc2629U,
457+	0x2c9f00f0U, 0x285e1d47U, 0x36194d42U, 0x32d850f5U, 0x3f9b762cU,
458+	0x3b5a6b9bU, 0x0315d626U, 0x07d4cb91U, 0x0a97ed48U, 0x0e56f0ffU,
459+	0x1011a0faU, 0x14d0bd4dU, 0x19939b94U, 0x1d528623U, 0xf12f560eU,
460+	0xf5ee4bb9U, 0xf8ad6d60U, 0xfc6c70d7U, 0xe22b20d2U, 0xe6ea3d65U,
461+	0xeba91bbcU, 0xef68060bU, 0xd727bbb6U, 0xd3e6a601U, 0xdea580d8U,
462+	0xda649d6fU, 0xc423cd6aU, 0xc0e2d0ddU, 0xcda1f604U, 0xc960ebb3U,
463+	0xbd3e8d7eU, 0xb9ff90c9U, 0xb4bcb610U, 0xb07daba7U, 0xae3afba2U,
464+	0xaafbe615U, 0xa7b8c0ccU, 0xa379dd7bU, 0x9b3660c6U, 0x9ff77d71U,
465+	0x92b45ba8U, 0x9675461fU, 0x8832161aU, 0x8cf30badU, 0x81b02d74U,
466+	0x857130c3U, 0x5d8a9099U, 0x594b8d2eU, 0x5408abf7U, 0x50c9b640U,
467+	0x4e8ee645U, 0x4a4ffbf2U, 0x470cdd2bU, 0x43cdc09cU, 0x7b827d21U,
468+	0x7f436096U, 0x7200464fU, 0x76c15bf8U, 0x68860bfdU, 0x6c47164aU,
469+	0x61043093U, 0x65c52d24U, 0x119b4be9U, 0x155a565eU, 0x18197087U,
470+	0x1cd86d30U, 0x029f3d35U, 0x065e2082U, 0x0b1d065bU, 0x0fdc1becU,
471+	0x3793a651U, 0x3352bbe6U, 0x3e119d3fU, 0x3ad08088U, 0x2497d08dU,
472+	0x2056cd3aU, 0x2d15ebe3U, 0x29d4f654U, 0xc5a92679U, 0xc1683bceU,
473+	0xcc2b1d17U, 0xc8ea00a0U, 0xd6ad50a5U, 0xd26c4d12U, 0xdf2f6bcbU,
474+	0xdbee767cU, 0xe3a1cbc1U, 0xe760d676U, 0xea23f0afU, 0xeee2ed18U,
475+	0xf0a5bd1dU, 0xf464a0aaU, 0xf9278673U, 0xfde69bc4U, 0x89b8fd09U,
476+	0x8d79e0beU, 0x803ac667U, 0x84fbdbd0U, 0x9abc8bd5U, 0x9e7d9662U,
477+	0x933eb0bbU, 0x97ffad0cU, 0xafb010b1U, 0xab710d06U, 0xa6322bdfU,
478+	0xa2f33668U, 0xbcb4666dU, 0xb8757bdaU, 0xb5365d03U, 0xb1f740b4U
479+};
480+
481 static Sum_t*
482 crc_open(const Method_t* method, const char* name)
483 {
484@@ -73,62 +130,80 @@
485 		sum->method = (Method_t*)method;
486 		sum->name = name;
487 	}
488-	polynomial = 0xedb88320;
489-	s = name;
490-	while (*(t = s))
491+
492+	if(!strcmp(name, "crc-0x04c11db7-rotate-done-size"))
493 	{
494-		for (t = s, v = 0; *s && *s != '-'; s++)
495-			if (*s == '=' && !v)
496-				v = s;
497-		i = (v ? v : s) - t;
498-		if (isdigit(*t) || v && i >= 4 && strneq(t, "poly", 4) && (t = v + 1))
499-			polynomial = strtoul(t, NiL, 0);
500-		else if (strneq(t, "done", i))
501-			sum->done = v ? strtoul(v + 1, NiL, 0) : ~sum->done;
502-		else if (strneq(t, "init", i))
503-			sum->init = v ? strtoul(v + 1, NiL, 0) : ~sum->init;
504-		else if (strneq(t, "rotate", i))
505-			sum->rotate = 1;
506-		else if (strneq(t, "size", i))
507-		{
508-			sum->addsize = 1;
509-			if (v)
510-				sum->xorsize = strtoul(v + 1, NiL, 0);
511-		}
512-		if (*s == '-')
513-			s++;
514+		sum->init=0;
515+		sum->done=0xffffffff;
516+		sum->xorsize=0x0;
517+		sum->addsize=0x1;
518+		sum->rotate=1;
519+
520+		/* Optimized codepath for POSIX cksum to save startup time */
521+		sum->tab=posix_cksum_tab;
522 	}
523-	if (sum->rotate)
524+	else
525 	{
526-		Crcnum_t	t;
527-		Crcnum_t	p[8];
528-
529-		p[0] = polynomial;
530-		for (i = 1; i < 8; i++)
531-			p[i] = (p[i-1] << 1) ^ ((p[i-1] & 0x80000000) ? polynomial : 0);
532-		for (i = 0; i < elementsof(sum->tab); i++)
533+		polynomial = 0xedb88320;
534+		s = name;
535+		while (*(t = s))
536 		{
537-			t = 0;
538-			x = i;
539-			for (j = 0; j < 8; j++)
540+			for (t = s, v = 0; *s && *s != '-'; s++)
541+				if (*s == '=' && !v)
542+					v = s;
543+			i = (v ? v : s) - t;
544+			if (isdigit(*t) || v && i >= 4 && strneq(t, "poly", 4) && (t = v + 1))
545+				polynomial = strtoul(t, NiL, 0);
546+			else if (strneq(t, "done", i))
547+				sum->done = v ? strtoul(v + 1, NiL, 0) : ~sum->done;
548+			else if (strneq(t, "init", i))
549+				sum->init = v ? strtoul(v + 1, NiL, 0) : ~sum->init;
550+			else if (strneq(t, "rotate", i))
551+				sum->rotate = 1;
552+			else if (strneq(t, "size", i))
553 			{
554-				if (x & 1)
555-					t ^= p[j];
556-				x >>= 1;
557+				sum->addsize = 1;
558+				if (v)
559+					sum->xorsize = strtoul(v + 1, NiL, 0);
560 			}
561-			sum->tab[i] = t;
562+			if (*s == '-')
563+				s++;
564 		}
565-	}
566-	else
567-	{
568-		for (i = 0; i < elementsof(sum->tab); i++)
569+		if (sum->rotate)
570 		{
571-			x = i;
572-			for (j = 0; j < 8; j++)
573-				x = (x>>1) ^ ((x & 1) ? polynomial : 0);
574-			sum->tab[i] = x;
575+			Crcnum_t	t;
576+			Crcnum_t	p[8];
577+
578+			p[0] = polynomial;
579+			for (i = 1; i < 8; i++)
580+				p[i] = (p[i-1] << 1) ^ ((p[i-1] & 0x80000000) ? polynomial : 0);
581+			for (i = 0; i < elementsof(sum->tabdata); i++)
582+			{
583+				t = 0;
584+				x = i;
585+				for (j = 0; j < 8; j++)
586+				{
587+					if (x & 1)
588+						t ^= p[j];
589+					x >>= 1;
590+				}
591+				sum->tabdata[i] = t;
592+			}
593 		}
594+		else
595+		{
596+			for (i = 0; i < elementsof(sum->tabdata); i++)
597+			{
598+				x = i;
599+				for (j = 0; j < 8; j++)
600+					x = (x>>1) ^ ((x & 1) ? polynomial : 0);
601+				sum->tabdata[i] = x;
602+			}
603+		}
604+
605+		sum->tab=sum->tabdata;
606 	}
607+
608 	return (Sum_t*)sum;
609 }
610
611@@ -141,11 +216,77 @@
612 	return 0;
613 }
614
615+#if defined(__SUNPRO_C) || defined(__GNUC__)
616+
617+#if defined(__SUNPRO_C)
618+#    include <sun_prefetch.h>
619+#    define sum_prefetch(addr) sun_prefetch_read_many((void *)(addr))
620+#elif defined(__GNUC__)
621+#    define sum_prefetch(addr) __builtin_prefetch((addr), 0, 3)
622+#else
623+#    error Unknown compiler
624+#endif
625+
626+#define CBLOCK_SIZE (64)
627+#pragma unroll(16)
628+
629 static int
630 crc_block(Sum_t* p, const void* s, size_t n)
631 {
632 	Crc_t*			sum = (Crc_t*)p;
633 	register Crcnum_t	c = sum->sum;
634+	register const unsigned char*	b = (const unsigned char*)s;
635+	register const unsigned char*	e = b + n;
636+	unsigned short i;
637+
638+	sum_prefetch(b);
639+
640+	if (sum->rotate)
641+	{
642+		while (n > CBLOCK_SIZE)
643+		{
644+			sum_prefetch(b+CBLOCK_SIZE);
645+			for(i=0 ; i < CBLOCK_SIZE ; i++)
646+			{
647+				CRCROTATE(sum, c, *b++);
648+			}
649+
650+			n-=CBLOCK_SIZE;
651+		}
652+
653+		while (b < e)
654+		{
655+			CRCROTATE(sum, c, *b++);
656+		}
657+	}
658+	else
659+	{
660+		while (n > CBLOCK_SIZE)
661+		{
662+			sum_prefetch(b+CBLOCK_SIZE);
663+			for(i=0 ; i < CBLOCK_SIZE ; i++)
664+			{
665+				CRC(sum, c, *b++);
666+			}
667+
668+			n-=CBLOCK_SIZE;
669+		}
670+
671+		while (b < e)
672+		{
673+			CRC(sum, c, *b++);
674+		}
675+	}
676+
677+	sum->sum = c;
678+	return 0;
679+}
680+#else
681+static int
682+crc_block(Sum_t* p, const void* s, size_t n)
683+{
684+	Crc_t*			sum = (Crc_t*)p;
685+	register Crcnum_t	c = sum->sum;
686 	register unsigned char*	b = (unsigned char*)s;
687 	register unsigned char*	e = b + n;
688
689@@ -158,6 +299,7 @@
690 	sum->sum = c;
691 	return 0;
692 }
693+#endif /* defined(__SUNPRO_C) || defined(__GNUC__) */
694
695 static int
696 crc_done(Sum_t* p)
697Index: usr/src/lib/libsum/common/sum-att.c
698===================================================================
699--- usr/src/lib/libsum/common/sum-att.c	(revision 1724)
700+++ usr/src/lib/libsum/common/sum-att.c	(working copy)
701@@ -35,10 +35,73 @@
702 #define att_data	long_data
703 #define att_scale	512
704
705+#if defined(__SUNPRO_C) || defined(__GNUC__)
706+
707+#if defined(__SUNPRO_C)
708+#    include <sun_prefetch.h>
709+#    define sum_prefetch(addr) sun_prefetch_read_many((void *)(addr))
710+#elif defined(__GNUC__)
711+#    define sum_prefetch(addr) __builtin_prefetch((addr), 0, 3)
712+#else
713+#    error Unknown compiler
714+#endif
715+
716+#define CBLOCK_SIZE (64)
717+#pragma unroll(16)
718+
719+/* Inmos transputer would love this algorithm */
720 static int
721 att_block(register Sum_t* p, const void* s, size_t n)
722 {
723 	register uint32_t	c = ((Integral_t*)p)->sum;
724+	register const unsigned char*	b = (const unsigned char*)s;
725+	register const unsigned char*	e = b + n;
726+	register uint32_t s0, s1, s2, s3, s4, s5, s6, s7;
727+	register unsigned int i;
728+
729+	s0=s1=s2=s3=s4=s5=s6=s7=0U;
730+
731+	sum_prefetch((void *)b);
732+
733+	while (n > CBLOCK_SIZE)
734+	{
735+		sum_prefetch((b+CBLOCK_SIZE));
736+
737+		/* Compiler will unroll for() loops per #pragma unroll */
738+		for (i=0 ; i < (CBLOCK_SIZE/8) ; i++)
739+		{
740+			/*
741+			 * use s0-s7 to decouple calculations (this improves pipelining)
742+			 * because each operation is completely independent from it's
743+			 * siblings
744+			 */
745+			s0+=b[0];
746+			s1+=b[1];
747+			s2+=b[2];
748+			s3+=b[3];
749+			s4+=b[4];
750+			s5+=b[5];
751+			s6+=b[6];
752+			s7+=b[7];
753+
754+			b+=8;
755+			n-=8;
756+		}
757+	}
758+
759+	c+=s0+s1+s2+s3+s4+s5+s6+s7;
760+
761+	while (b < e)
762+		c += *b++;
763+	((Integral_t*)p)->sum = c;
764+	return 0;
765+}
766+
767+#else
768+static int
769+att_block(register Sum_t* p, const void* s, size_t n)
770+{
771+	register uint32_t	c = ((Integral_t*)p)->sum;
772 	register unsigned char*	b = (unsigned char*)s;
773 	register unsigned char*	e = b + n;
774
775@@ -47,6 +110,7 @@
776 	((Integral_t*)p)->sum = c;
777 	return 0;
778 }
779+#endif /* defined(__SUNPRO_C) || defined(__GNUC__) */
780
781 static int
782 att_done(Sum_t* p)
783-- snip --
784
785# EOF.
786