/[hurd]/hurd-l4/libl4/l4/schedule.h
ViewVC logotype

Diff of /hurd-l4/libl4/l4/schedule.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by jrydberg, Mon Feb 7 23:48:44 2005 UTC revision 1.7 by marcus, Tue Feb 8 01:31:34 2005 UTC
# Line 70  _L4_time_alter_exps (__L4_time_t *time1, Line 70  _L4_time_alter_exps (__L4_time_t *time1,
70    /* Before trying to level the exponents, minimize the mantisses.    /* Before trying to level the exponents, minimize the mantisses.
71       This will hopefully minimize the risk of overflow.  */       This will hopefully minimize the risk of overflow.  */
72    while (time1->period.m && !(time1->period.m & 1))    while (time1->period.m && !(time1->period.m & 1))
73      time1->period.e++, time1->period.m /= 2;      {
74          time1->period.e++;
75          time1->period.m /= 2;
76        }
77    
78    while (time2->period.m && !(time2->period.m & 1))    while (time2->period.m && !(time2->period.m & 1))
79      time2->period.e ++, time2->period.m /= 2;      {
80          time2->period.e++;
81          time2->period.m /= 2;
82        }
83        
84    if (time1->period.e < time2->period.e)    if (time1->period.e < time2->period.e)
85      {      {
86        __L4_time_t *time_tmp = time1;        __L4_time_t *time_tmp = time1;
87        time1 = time2, time2 = time_tmp;        time1 = time2;
88          time2 = time_tmp;
89      }      }
90    
91    while (time1->period.e != time2->period.e)    while (time1->period.e != time2->period.e)
92      {      {
93        time1->period.m *= 2;        time1->period.m *= 2;
94        time1->period.e --;        time1->period.e--;
95      }      }
96  }  }
97    
# Line 93  static inline _L4_time_t Line 100  static inline _L4_time_t
100  _L4_attribute_always_inline  _L4_attribute_always_inline
101  _L4_time_make (_L4_word_t val)  _L4_time_make (_L4_word_t val)
102  {  {
103    __L4_time_t t = { 0, };    __L4_time_t t = { .raw = 0 };
104    
105    if (val != 0)    if (val != 0)
106      {      {
# Line 126  _L4_time_add (_L4_time_t time1, _L4_time Line 133  _L4_time_add (_L4_time_t time1, _L4_time
133    res = _time1.period.m + _time2.period.m;    res = _time1.period.m + _time2.period.m;
134    
135    if (res > _L4_TIME_PERIOD_M_MAX)    if (res > _L4_TIME_PERIOD_M_MAX)
     /* Overflow in the mantisse, try to see if it is possible to shift  
        down the result, and increase the exponent.  */  
136      {      {
137          /* Overflow in the mantisse, try to see if it is possible to
138             shift down the result, and increase the exponent.  */
139    
140        while (!(res & 1))        while (!(res & 1))
141          {          {
142            res >>= 1;            res >>= 1;
143            _time1.period.e ++;            _time1.period.e++;
144          }          }
145      }      }
146    
# Line 158  _L4_time_sub (_L4_time_t time1, _L4_time Line 166  _L4_time_sub (_L4_time_t time1, _L4_time
166    
167    _L4_time_alter_exps (&_time1, &_time2);    _L4_time_alter_exps (&_time1, &_time2);
168    
169    /* If this underflows (b's mantisse is greater than a's) there is    /* If this underflows (time2's mantisse is greater than time1's) there
170       really nothing to do, since negative time is not supported.  */       is really nothing to do, since negative time is not supported.  */
171    _time1.period.m = _time1.period.m - _time2.period.m;    _time1.period.m = _time1.period.m - _time2.period.m;
172    return _time1.raw;    return _time1.raw;
173  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26