-------------------------------------------------------------------------*\ * Determines how much time we have left for the next system call, * if the previous call was successful * Input * tm: timeout control structure * Returns * the number of ms left or -1 if there is no time limit \*-------------------------------------------------------------------------*/
| 58 | * the number of ms left or -1 if there is no time limit |
| 59 | \*-------------------------------------------------------------------------*/ |
| 60 | double timeout_get(p_timeout tm) { |
| 61 | if (tm->block < 0.0 && tm->total < 0.0) { |
| 62 | return -1; |
| 63 | } else if (tm->block < 0.0) { |
| 64 | double t = tm->total - timeout_gettime() + tm->start; |
| 65 | return MAX(t, 0.0); |
| 66 | } else if (tm->total < 0.0) { |
| 67 | return tm->block; |
| 68 | } else { |
| 69 | double t = tm->total - timeout_gettime() + tm->start; |
| 70 | return MIN(tm->block, MAX(t, 0.0)); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /*-------------------------------------------------------------------------*\ |
| 75 | * Returns time since start of operation |
no test coverage detected