lib: use common stage-dependent wrapper for [oob_]ioctl() requests

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
This commit is contained in:
Philippe Gerum 2020-04-22 11:26:05 +02:00
parent 55bb9159aa
commit b2c2488dc9
4 changed files with 19 additions and 39 deletions

View File

@ -18,16 +18,6 @@
int evl_mono_clockfd = -ENXIO,
evl_real_clockfd = -ENXIO;
#define do_call(__clockfd, __args...) \
({ \
int __ret; \
if (evl_is_inband()) \
__ret = ioctl(__clockfd, ##__args); \
else \
__ret = oob_ioctl(__clockfd, ##__args); \
__ret ? -errno : 0; \
})
int evl_set_clock(int clockfd, const struct timespec *tp)
{
struct __evl_timespec kts;
@ -41,7 +31,7 @@ int evl_set_clock(int clockfd, const struct timespec *tp)
return -errno;
break;
default:
ret = do_call(clockfd, EVL_CLKIOC_SET_TIME,
ret = __evl_common_ioctl(clockfd, EVL_CLKIOC_SET_TIME,
__evl_ktimespec(tp, kts));
}
@ -60,7 +50,7 @@ int evl_get_clock_resolution(int clockfd, struct timespec *tp)
return -errno;
break;
default:
ret = do_call(clockfd, EVL_CLKIOC_GET_RES, tp);
ret = __evl_common_ioctl(clockfd, EVL_CLKIOC_GET_RES, tp);
}
return ret;

View File

@ -74,6 +74,16 @@
#define __evl_kitimerspec_ptr64(__its, __kits) \
__evl_ptr64(__evl_kitimerspec(__its, __kits))
#define __evl_common_ioctl(__efd, __args...) \
({ \
int __ret; \
if (evl_is_inband()) \
__ret = ioctl(__efd, ##__args); \
else \
__ret = oob_ioctl(__efd, ##__args); \
__ret ? -errno : 0; \
})
extern __thread __attribute__ ((tls_model (EVL_TLS_MODEL)))
fundle_t evl_current;

View File

@ -13,24 +13,14 @@
#include <uapi/evl/control.h>
#include "internal.h"
#define do_call(__fd, __args...) \
({ \
int __ret; \
if (evl_is_inband()) \
__ret = ioctl(__fd, ##__args); \
else \
__ret = oob_ioctl(__fd, ##__args); \
__ret ? -errno : 0; \
})
int evl_set_schedattr(int efd, const struct evl_sched_attrs *attrs)
{
return do_call(efd, EVL_THRIOC_SET_SCHEDPARAM, attrs);
return __evl_common_ioctl(efd, EVL_THRIOC_SET_SCHEDPARAM, attrs);
}
int evl_get_schedattr(int efd, struct evl_sched_attrs *attrs)
{
return do_call(efd, EVL_THRIOC_GET_SCHEDPARAM, attrs);
return __evl_common_ioctl(efd, EVL_THRIOC_GET_SCHEDPARAM, attrs);
}
int evl_control_sched(int policy,
@ -48,7 +38,7 @@ int evl_control_sched(int policy,
ctlreq.param_ptr = __evl_ptr64(param);
ctlreq.info_ptr = __evl_ptr64(info);
return do_call(evl_ctlfd, EVL_CTLIOC_SCHEDCTL, &ctlreq);
return __evl_common_ioctl(evl_ctlfd, EVL_CTLIOC_SCHEDCTL, &ctlreq);
}
int evl_get_cpustate(int cpu, int *state_r)
@ -63,7 +53,7 @@ int evl_get_cpustate(int cpu, int *state_r)
cpst.cpu = cpu;
cpst.state_ptr = __evl_ptr64(&state);
ret = do_call(evl_ctlfd, EVL_CTLIOC_GET_CPUSTATE, &cpst);
ret = __evl_common_ioctl(evl_ctlfd, EVL_CTLIOC_GET_CPUSTATE, &cpst);
if (ret)
return ret;

View File

@ -11,16 +11,6 @@
#include <evl/timer.h>
#include "internal.h"
#define do_call(__timerfd, __args...) \
({ \
int __ret; \
if (evl_is_inband()) \
__ret = ioctl(__timerfd, ##__args); \
else \
__ret = oob_ioctl(__timerfd, ##__args); \
__ret ? -errno : 0; \
})
int evl_new_timer(int clockfd)
{
int ret, efd;
@ -50,12 +40,12 @@ int evl_set_timer(int efd,
sreq.value_ptr = __evl_kitimerspec_ptr64(value, kits);
sreq.ovalue_ptr = __evl_kitimerspec_ptr64(ovalue, koits);
return do_call(efd, EVL_TFDIOC_SET, &sreq);
return __evl_common_ioctl(efd, EVL_TFDIOC_SET, &sreq);
}
int evl_get_timer(int efd, struct itimerspec *value)
{
struct __evl_itimerspec kits;
return do_call(efd, EVL_TFDIOC_GET, __evl_kitimerspec(value, kits));
return __evl_common_ioctl(efd, EVL_TFDIOC_GET, __evl_kitimerspec(value, kits));
}