www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000005

When Created: 06/29/1995 19:48:17
Against DJGPP version: 2.00.beta1
By whom: jhunter@kendaco.telebyte.com
Abstract: inline functions in include/inlines/pc.h optimize to nothing inside loops
Inlines declared in /DJ2/include/inlines/pc.h optimize inportb()'s, etc., inside 
of a loop.  Therefore, a loop dependant on the value taken from the port
changing will loop forever, since inportb() will only be called once, outside 
the loop.
Will adding the volatile keyword to the functions fix this?

Example:

  while((inportb(0x226)&0x80)!=0);

compiles to:

  movw	$0x226, %dx
  inb	%dx, %al
  movzbl %al, %ecx
L15:
  testb	%cl, %cl
  jl	L15

Fixed in version 2.00.beta2 on 07/05/1995 22:46:23
By whom: dj@delorie.com

Note added: 07/05/1995 22:47:07
By whom: dj@delorie.com
I changed all __asm__() to __asm__ __volatile__ ().

Note that sys/farptr.h had the same problem, and was also fixed.



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010