Skip to content

Commit

Permalink
evl: sanitize uapi/ headers (enable CONFIG_UAPI_HEADER_TEST)
Browse files Browse the repository at this point in the history
Ensure that CONFIG_UAPI_HEADER_TEST passes with the EVL uapi/
headers. This involves:

- removing all direct mention of the uapi/ root in include directives
  from uapi/ headers.

- rename the header containing the ABI definitions for each
  uapi/evl/<element>.h to uapi/evl/<element>-abi.h, so that we can
  include it unambiguously from any uapi/ header as
  evl/<element>-abi.h, solving the name clash with the associated
  kernel header.

- moving a few bits to the relevant implementation file (kernel and/or
  libevl) whenever possible, dropping the requirement for maintaining
  an uapi header for it (e.g. uapi/evl/mutex.h).

At this chance, remove some unnecessary include directives from a few
implementation files as well.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
  • Loading branch information
pgerum authored and gyohng committed Jun 3, 2024
1 parent c6a3e5f commit 012eee8
Show file tree
Hide file tree
Showing 44 changed files with 110 additions and 203 deletions.
3 changes: 2 additions & 1 deletion include/evl/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <linux/cpumask.h>
#include <evl/list.h>
#include <evl/factory.h>
#include <uapi/evl/clock.h>
#include <uapi/evl/types.h>
#include <uapi/evl/clock-abi.h>

#define ONE_BILLION 1000000000

Expand Down
2 changes: 2 additions & 0 deletions include/evl/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <linux/atomic.h>
#include <linux/notifier.h>
#include <evl/factory.h>
#include <uapi/evl/sched-abi.h>
#include <uapi/evl/control-abi.h>

enum evl_run_states {
EVL_STATE_DISABLED,
Expand Down
2 changes: 1 addition & 1 deletion include/evl/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <evl/assert.h>
#include <evl/file.h>
#include <uapi/evl/types.h>
#include <uapi/evl/factory.h>
#include <uapi/evl/factory-abi.h>

#define element_of(__filp, __type) \
({ \
Expand Down
3 changes: 1 addition & 2 deletions include/evl/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#ifndef _EVL_MONITOR_H
#define _EVL_MONITOR_H

#include <evl/factory.h>
#include <evl/thread.h>
#include <evl/sched.h>
#include <uapi/evl/monitor-abi.h>

int evl_signal_monitor_targeted(struct evl_thread *target,
int monfd);
Expand Down
7 changes: 6 additions & 1 deletion include/evl/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <evl/timer.h>
#include <evl/wait.h>
#include <evl/sched.h>
#include <uapi/evl/mutex.h>

struct evl_clock;
struct evl_thread;
Expand Down Expand Up @@ -93,6 +92,12 @@ bool evl_requeue_mutex_wait(struct evl_wait_channel *wchan,

void evl_drop_current_ownership(void);

static inline bool
evl_is_mutex_owner(atomic_t *fastlock, fundle_t ownerh)
{
return evl_get_index(atomic_read(fastlock)) == ownerh;
}

struct evl_kmutex {
struct evl_mutex mutex;
atomic_t fastlock;
Expand Down
4 changes: 3 additions & 1 deletion include/evl/net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include <evl/file.h>
#include <evl/poll.h>
#include <evl/crossing.h>
#include <uapi/evl/net/socket.h>
#include <uapi/evl/types.h>
#include <uapi/evl/fcntl.h>
#include <uapi/evl/net/socket-abi.h>

struct evl_socket;
struct net;
Expand Down
3 changes: 2 additions & 1 deletion include/evl/observable.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <evl/factory.h>
#include <evl/wait.h>
#include <evl/poll.h>
#include <uapi/evl/observable.h>
#include <uapi/evl/types.h>
#include <uapi/evl/observable-abi.h>

struct file;

Expand Down
3 changes: 2 additions & 1 deletion include/evl/poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <linux/poll.h>
#include <evl/wait.h>
#include <evl/factory.h>
#include <uapi/evl/poll.h>
#include <uapi/evl/types.h>
#include <uapi/evl/poll-abi.h>

struct file;

Expand Down
4 changes: 2 additions & 2 deletions include/evl/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include <evl/sched/param.h>
#include <evl/factory.h>
#include <evl/assert.h>
#include <uapi/evl/thread.h>
#include <uapi/evl/thread-abi.h>
#include <uapi/evl/sched-abi.h>
#include <uapi/evl/signal.h>
#include <uapi/evl/sched.h>
#include <asm/evl/thread.h>

/* All bits which may cause an EVL thread to block in oob context. */
Expand Down
8 changes: 4 additions & 4 deletions include/uapi/evl/clock.h → include/uapi/evl/clock-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_CLOCK_H
#define _EVL_UAPI_CLOCK_H
#ifndef _EVL_UAPI_CLOCK_ABI_H
#define _EVL_UAPI_CLOCK_ABI_H

#include <uapi/evl/types.h>
#include <linux/types.h>

#define EVL_CLOCK_MONOTONIC_DEV "monotonic"
#define EVL_CLOCK_REALTIME_DEV "realtime"
Expand All @@ -34,4 +34,4 @@ struct evl_timerfd_setreq {
#define EVL_TFDIOC_SET _IOWR(EVL_TIMERFD_IOCBASE, 0, struct evl_timerfd_setreq)
#define EVL_TFDIOC_GET _IOR(EVL_TIMERFD_IOCBASE, 1, struct __evl_itimerspec)

#endif /* !_EVL_UAPI_CLOCK_H */
#endif /* !_EVL_UAPI_CLOCK_ABI_H */
7 changes: 3 additions & 4 deletions include/uapi/evl/control.h → include/uapi/evl/control-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_CONTROL_H
#define _EVL_UAPI_CONTROL_H
#ifndef _EVL_UAPI_CONTROL_ABI_H
#define _EVL_UAPI_CONTROL_ABI_H

#include <linux/types.h>
#include <uapi/evl/sched.h>

/* Earliest ABI level we support. */
#define EVL_ABI_BASE 23
Expand Down Expand Up @@ -40,4 +39,4 @@ struct evl_cpu_state {
#define EVL_CTLIOC_SCHEDCTL _IOWR(EVL_CONTROL_IOCBASE, 1, struct evl_sched_ctlreq)
#define EVL_CTLIOC_GET_CPUSTATE _IOR(EVL_CONTROL_IOCBASE, 2, struct evl_cpu_state)

#endif /* !_EVL_UAPI_CONTROL_H */
#endif /* !_EVL_UAPI_CONTROL_ABI_H */
6 changes: 3 additions & 3 deletions include/uapi/evl/factory.h → include/uapi/evl/factory-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_FACTORY_H
#define _EVL_UAPI_FACTORY_H
#ifndef _EVL_UAPI_FACTORY_ABI_H
#define _EVL_UAPI_FACTORY_ABI_H

#include <linux/types.h>

Expand Down Expand Up @@ -45,4 +45,4 @@ struct evl_clone_req {

#define EVL_IOC_CLONE _IOWR(EVL_FACTORY_IOCBASE, 0, struct evl_clone_req)

#endif /* !_EVL_UAPI_FACTORY_H */
#endif /* !_EVL_UAPI_FACTORY_ABI_H */
16 changes: 7 additions & 9 deletions include/uapi/evl/monitor.h → include/uapi/evl/monitor-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_MONITOR_H
#define _EVL_UAPI_MONITOR_H
#ifndef _EVL_UAPI_MONITOR_ABI_H
#define _EVL_UAPI_MONITOR_ABI_H

#include <linux/types.h>
#include <uapi/evl/types.h>
#include <uapi/evl/factory.h>
#include <evl/factory-abi.h>

#define EVL_MONITOR_DEV "monitor"

Expand Down Expand Up @@ -39,14 +37,14 @@ struct evl_monitor_state {
__u32 flags;
union {
struct {
atomic_t owner;
__u32 owner; /* atomic_t */
__u32 ceiling;
__u32 recursive: 1,
nesting : 31;
} gate;
struct {
atomic_t value;
atomic_t pollrefs;
__u32 value; /* atomic_t */
__u32 pollrefs; /* atomic_t */
__u32 gate_offset;
} event;
} u;
Expand Down Expand Up @@ -87,4 +85,4 @@ struct evl_monitor_binding {
#define EVL_MONIOC_TRYWAIT _IOWR(EVL_MONITOR_IOCBASE, 9, struct evl_monitor_trywaitreq)
#define EVL_MONIOC_TRYWAIT_EXACT _IOWR(EVL_MONITOR_IOCBASE, 10, struct evl_monitor_trywaitreq)

#endif /* !_EVL_UAPI_MONITOR_H */
#endif /* !_EVL_UAPI_MONITOR_ABI_H */
43 changes: 0 additions & 43 deletions include/uapi/evl/mutex.h

This file was deleted.

10 changes: 0 additions & 10 deletions include/uapi/evl/net/sched.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Copyright (C) 2020 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_NET_SOCKET_H
#define _EVL_UAPI_NET_SOCKET_H
#ifndef _EVL_UAPI_NET_SOCKET_ABI_H
#define _EVL_UAPI_NET_SOCKET_ABI_H

#include <uapi/evl/types.h>
#include <uapi/evl/fcntl.h>
#include <evl/types.h>

#define AF_OOB 46 /* Out-of-band domain sockets */

Expand Down Expand Up @@ -42,4 +41,4 @@ struct evl_netdev_activation {
#define EVL_SOCKIOC_SETRECVSZ _IOW(EVL_SOCKET_IOCBASE, 6, int)
#define EVL_SOCKIOC_SETSENDSZ _IOW(EVL_SOCKET_IOCBASE, 7, int)

#endif /* !_EVL_UAPI_NET_SOCKET_H */
#endif /* !_EVL_UAPI_NET_SOCKET_ABI_H */
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Copyright (C) 2020 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_OBSERVABLE_H
#define _EVL_UAPI_OBSERVABLE_H
#ifndef _EVL_UAPI_OBSERVABLE_ABI_H
#define _EVL_UAPI_OBSERVABLE_ABI_H

#include <uapi/evl/types.h>
#include <evl/types.h>

#define EVL_OBSERVABLE_DEV "observable"

Expand Down Expand Up @@ -42,4 +42,4 @@ struct __evl_notification {
#define EVL_OBSIOC_SUBSCRIBE _IOW(EVL_OBSERVABLE_IOCBASE, 0, struct evl_subscription)
#define EVL_OBSIOC_UNSUBSCRIBE _IO(EVL_OBSERVABLE_IOCBASE, 1)

#endif /* !_EVL_UAPI_OBSERVABLE_H */
#endif /* !_EVL_UAPI_OBSERVABLE_ABI_H */
8 changes: 4 additions & 4 deletions include/uapi/evl/poll.h → include/uapi/evl/poll-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_POLL_H
#define _EVL_UAPI_POLL_H
#ifndef _EVL_UAPI_POLL_ABI_H
#define _EVL_UAPI_POLL_ABI_H

#include <uapi/evl/types.h>
#include <evl/types.h>

#define EVL_POLL_DEV "poll"

Expand Down Expand Up @@ -39,4 +39,4 @@ struct evl_poll_waitreq {
#define EVL_POLIOC_CTL _IOW(EVL_POLL_IOCBASE, 0, struct evl_poll_ctlreq)
#define EVL_POLIOC_WAIT _IOWR(EVL_POLL_IOCBASE, 1, struct evl_poll_waitreq)

#endif /* !_EVL_UAPI_POLL_H */
#endif /* !_EVL_UAPI_POLL_ABI_H */
6 changes: 3 additions & 3 deletions include/uapi/evl/proxy.h → include/uapi/evl/proxy-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Copyright (C) 2019 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_PROXY_H
#define _EVL_UAPI_PROXY_H
#ifndef _EVL_UAPI_PROXY_ABI_H
#define _EVL_UAPI_PROXY_ABI_H

#include <linux/types.h>

Expand All @@ -17,4 +17,4 @@ struct evl_proxy_attrs {
__u32 granularity;
};

#endif /* !_EVL_UAPI_PROXY_H */
#endif /* !_EVL_UAPI_PROXY_ABI_H */
8 changes: 4 additions & 4 deletions include/uapi/evl/sched.h → include/uapi/evl/sched-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Copyright (C) 2005, 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_SCHED_H
#define _EVL_UAPI_SCHED_H
#ifndef _EVL_UAPI_SCHED_ABI_H
#define _EVL_UAPI_SCHED_ABI_H

#include <uapi/evl/types.h>
#include <evl/types.h>

#define EVL_CPU_OOB (1 << 0)
#define EVL_CPU_ISOL (1 << 1)
Expand Down Expand Up @@ -130,4 +130,4 @@ struct evl_sched_ctlreq {
__u64 info_ptr; /* (union evl_sched_ctlinfo __user *info) */
};

#endif /* !_EVL_UAPI_SCHED_H */
#endif /* !_EVL_UAPI_SCHED_ABI_H */
6 changes: 3 additions & 3 deletions include/uapi/evl/syscall.h → include/uapi/evl/syscall-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_SYSCALL_H
#define _EVL_UAPI_SYSCALL_H
#ifndef _EVL_UAPI_SYSCALL_ABI_H
#define _EVL_UAPI_SYSCALL_ABI_H

#define sys_evl_read 0 /* oob_read() */
#define sys_evl_write 1 /* oob_write() */
#define sys_evl_ioctl 2 /* oob_ioctl() */

#define NR_EVL_SYSCALLS 3

#endif /* !_EVL_UAPI_SYSCALL_H */
#endif /* !_EVL_UAPI_SYSCALL_ABI_H */
9 changes: 4 additions & 5 deletions include/uapi/evl/thread.h → include/uapi/evl/thread-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
* Copyright (C) 2005, 2018 Philippe Gerum <rpm@xenomai.org>
*/

#ifndef _EVL_UAPI_THREAD_H
#define _EVL_UAPI_THREAD_H
#ifndef _EVL_UAPI_THREAD_ABI_H
#define _EVL_UAPI_THREAD_ABI_H

#include <linux/types.h>
#include <uapi/evl/sched.h>
#include <evl/sched-abi.h>

#define EVL_THREAD_DEV "thread"

Expand Down Expand Up @@ -131,4 +130,4 @@ struct evl_thread_state {
#define EVL_THRIOC_DEMOTE _IO(EVL_THREAD_IOCBASE, 11)
#define EVL_THRIOC_YIELD _IO(EVL_THREAD_IOCBASE, 12)

#endif /* !_EVL_UAPI_THREAD_H */
#endif /* !_EVL_UAPI_THREAD_ABI_H */
Loading

0 comments on commit 012eee8

Please sign in to comment.