From owner-freebsd-current Fri Nov 27 16:56:52 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA16593 for freebsd-current-outgoing; Fri, 27 Nov 1998 16:56:52 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from iquest3.iquest.net (iquest3.iquest.net [209.43.20.203]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id QAA16586 for ; Fri, 27 Nov 1998 16:56:51 -0800 (PST) (envelope-from toor@y.dyson.net) Received: (qmail 6008 invoked from network); 28 Nov 1998 00:56:33 -0000 Received: from dyson.iquest.net (HELO y.dyson.net) (198.70.144.127) by iquest3.iquest.net with SMTP; 28 Nov 1998 00:56:33 -0000 Received: (from root@localhost) by y.dyson.net (8.9.1/8.9.1) id TAA03374 for current@freebsd.org; Fri, 27 Nov 1998 19:56:32 -0500 (EST) Message-Id: <199811280056.TAA03374@y.dyson.net> Subject: Fix for incorrect clobbers in asm's To: current@FreeBSD.ORG Date: Fri, 27 Nov 1998 19:56:32 -0500 (EST) From: "John S. Dyson" Reply-To: dyson@iquest.net X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM912214592-3366-0_ Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --ELM912214592-3366-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Note that the specification for clobbers in inline asm's on GCC hasn't always been clear. The attached patches correct the clobbers in the inline asms for current. Specifically, it is totally incorrect to clobber any of the input or output operands. The workaround is to indicate that the clobbered registers are output operands, with no subsequent usage. It might be counter-intuitive, but is the suggested solution to the problem. -- John | Never try to teach a pig to sing, dyson@iquest.net | it makes one look stupid jdyson@nc.com | and it irritates the pig. --ELM912214592-3366-0_ Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: attachment; filename=clobbers.diff Content-Description: clobbers.diff Content-Transfer-Encoding: 7bit Index: i386/i386/identcpu.c =================================================================== RCS file: /local/home/ncvs/src/sys/i386/i386/identcpu.c,v retrieving revision 1.52 diff -C1 -r1.52 identcpu.c *** identcpu.c 1998/10/06 13:16:23 1.52 --- identcpu.c 1998/11/28 00:49:10 *************** *** 106,107 **** --- 106,108 ---- { + int nax; __asm __volatile( *************** *** 112,116 **** "movl %%edx, (12)(%%esi);" ! : : "a" (ax), "S" (p) ! : "ax", "bx", "cx", "dx" ); --- 113,117 ---- "movl %%edx, (12)(%%esi);" ! : "=a"(nax) : "a" (ax), "S" (p) ! : "bx", "cx", "dx" ); Index: i386/include/cpufunc.h =================================================================== RCS file: /local/home/ncvs/src/sys/i386/include/cpufunc.h,v retrieving revision 1.81 diff -C1 -r1.81 cpufunc.h *** cpufunc.h 1998/08/17 08:57:05 1.81 --- cpufunc.h 1998/11/28 00:46:45 *************** *** 192,196 **** { __asm __volatile("cld; rep; insb" ! : : "d" (port), "D" (addr), "c" (cnt) ! : "di", "cx", "memory"); } --- 192,198 ---- { + int ndi, ncx; __asm __volatile("cld; rep; insb" ! : "=D"(ndi), "=c"(ncx) ! : "d" (port), "D" (addr), "c" (cnt) ! : "memory"); } *************** *** 200,204 **** { __asm __volatile("cld; rep; insw" ! : : "d" (port), "D" (addr), "c" (cnt) ! : "di", "cx", "memory"); } --- 202,208 ---- { + int ndi, ncx; __asm __volatile("cld; rep; insw" ! : "=D"(ndi), "=c"(ncx) ! : "d" (port), "D" (addr), "c" (cnt) ! : "memory"); } *************** *** 208,212 **** { __asm __volatile("cld; rep; insl" ! : : "d" (port), "D" (addr), "c" (cnt) ! : "di", "cx", "memory"); } --- 212,218 ---- { + int ndi, ncx; __asm __volatile("cld; rep; insl" ! : "=D"(ndi), "=c"(ncx) ! : "d" (port), "D" (addr), "c" (cnt) ! : "memory"); } *************** *** 323,327 **** { __asm __volatile("cld; rep; outsb" ! : : "d" (port), "S" (addr), "c" (cnt) ! : "si", "cx"); } --- 329,334 ---- { + int nsi, ncx; __asm __volatile("cld; rep; outsb" ! : "=S"(nsi), "=c"(ncx) ! : "d" (port), "S" (addr), "c" (cnt)); } *************** *** 331,335 **** { __asm __volatile("cld; rep; outsw" ! : : "d" (port), "S" (addr), "c" (cnt) ! : "si", "cx"); } --- 338,343 ---- { + int nsi, ncx; __asm __volatile("cld; rep; outsw" ! : "=S"(nsi), "=c"(ncx) ! : "d" (port), "S" (addr), "c" (cnt)); } *************** *** 339,343 **** { __asm __volatile("cld; rep; outsl" ! : : "d" (port), "S" (addr), "c" (cnt) ! : "si", "cx"); } --- 347,352 ---- { + int nsi, ncx; __asm __volatile("cld; rep; outsl" ! : "=S"(nsi), "=c"(ncx) ! : "d" (port), "S" (addr), "c" (cnt)); } Index: i386/isa/sound/audio.c =================================================================== RCS file: /local/home/ncvs/src/sys/i386/isa/sound/audio.c,v retrieving revision 1.19 diff -C1 -r1.19 audio.c *** audio.c 1998/07/15 11:47:58 1.19 --- audio.c 1998/11/28 00:50:36 *************** *** 167,168 **** --- 167,169 ---- { + int nbx, ncx, ndi, nsi; if (n > 0) { *************** *** 172,176 **** "stosb\n\t" ! "loop 1b\n\t": :"b"(table), "c"(n), "D"(buff), "S"(buff) ! :"bx", "cx", "di", "si", "ax"); } --- 173,178 ---- "stosb\n\t" ! "loop 1b\n\t" ! :"=b"(nbx), "=c"(ncx), "=D" (ndi), "=S" (nsi) :"b"(table), "c"(n), "D"(buff), "S"(buff) ! :"ax"); } --ELM912214592-3366-0_-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message