gcc-4.3.2 as of Debian Lenny throws the following internal error
on current emc2-trunk:

src/emc/motion/motion.c: In function `emcmotSetCycleTime':
src/emc/motion/motion.c:1122: internal compiler error: in 
inline_secondary_memory_needed, at config/i386/i386.c:21774

The following patch fixes the error:

Index: src/emc/motion/motion.c
===================================================================
--- src.orig/emc/motion/motion.c        2011-03-26 16:14:21.000000000 +0100
+++ src/emc/motion/motion.c     2011-03-26 16:22:59.000000000 +0100
@@ -1115,7 +1115,7 @@
 
 void emcmotSetCycleTime(unsigned long nsec ) {
     int servo_mult;
-    servo_mult = ceil(traj_period_nsec / nsec);
+    servo_mult = ceil((double)traj_period_nsec / nsec);
     if(servo_mult < 0) servo_mult = 1;
     setTrajCycleTime(nsec * 1e-9);
     setServoCycleTime(nsec * servo_mult * 1e-9);

The compiler shouldn't throw this internal error, of couse.
However, looking at the code I do think the code actually is incorrect, too.

traj_period_nsec is a long. nsec is an unsigned long.
So the devision will compile to an integer division. I don't think
that this is desired behavior here. So the double cast does actually
seem to fix the desired semantics here.

There seems to be yet another problem: double to int casting.
Depending on the actual value returned by ceil() (which is double),
servo_mult might yield to one less than desired. So the following patch
should fix both issues (division and rounding):

Index: src/emc/motion/motion.c
===================================================================
--- src.orig/emc/motion/motion.c        2011-03-26 16:14:21.000000000 +0100
+++ src/emc/motion/motion.c     2011-03-26 16:22:59.000000000 +0100
@@ -1115,7 +1115,7 @@
 
 void emcmotSetCycleTime(unsigned long nsec ) {
     int servo_mult;
-    servo_mult = ceil(traj_period_nsec / nsec);
+    servo_mult = ceil((double)traj_period_nsec / nsec) + 0.1;
     if(servo_mult < 0) servo_mult = 1;
     setTrajCycleTime(nsec * 1e-9);
     setServoCycleTime(nsec * servo_mult * 1e-9);

Please consider applying the (last) patch to fix the semantics errors
and workaround the Lenny compiler error.

-- 
Greetings Michael.


------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to