Skip to content

Commit 4d43293

Browse files
authored
Merge pull request #3442 from BsAtHome/fix_labs-in-rtai
RTAI build cannot use labs()
2 parents 5dadead + 2312b1c commit 4d43293

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/hal/drivers/mesa-hostmot2/sserial.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#include "hostmot2.h"
3030
#include "bitfile.h"
3131

32+
// Local definition of labs() because RTAI compile barfs on using labs(). It
33+
// could be optimized using compiler built-ins, but the single use in here is
34+
// not critical.
35+
static inline rtapi_s64 xlabs(rtapi_s64 x) { return x < 0 ? -x : x; }
3236

3337
int getbits(hm2_sserial_remote_t *chan, rtapi_u64 *val, int start, int len){
3438
//load the bits from the registers in to bit 0+ of *val
@@ -1550,7 +1554,7 @@ int hm2_sserial_register_tram(hostmot2_t *hm2, hm2_sserial_remote_t *chan){
15501554
case 64:
15511555
shift = 0;
15521556
}
1553-
if (labs((p->s64_param - p->s64_written) >> shift) > 2) break;
1557+
if (xlabs((p->s64_param - p->s64_written) >> shift) > 2) break;
15541558
*inst->state2 = 2; // increment indices
15551559
return *inst->state2;
15561560
default:

0 commit comments

Comments
 (0)