Skip to contentSkip to conversation

psos.h: remove dependency on tunables.h

PATCH Superseded Ronny Meeus 2 participants 4 messages Nov 29, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 psos.h: remove dependency on tunables.h

The psos.h file pollutes the application's namespace with defines of the boilerplate code because the tunables.h is included. In our application we already have a definition of the list_entry macro, resulting in a redefinition. The psos.h should be kept clean.

Following small test program clearly shows the issue:

#include <psos/psos.h>
#define list_entry
int main(int argc, char * const argv[])
{
return 0;
}

When compiling the code above a warning is generated:

simple_test.c:3:1: warning: "list_entry" redefined In file included from boilerplate/list.h:24,

                 from boilerplate/setup.h:21,
                 from boilerplate/tunables.h:22,
                 from psos/psos.h:28,
                 from simple_test.c:1:

boilerplate/shared-list.h:233:1: warning: this is the location of the previous definition

This patch resolves the issue by just removing the dependency
and all related functions. If the functions are actually needed, better to move them in a separate header file since they are not part of the 'official' psos interface.

include/psos/psos.h +0 -11
@@ -25,7 +25,6 @@
 #define _XENOMAI_PSOS_PSOS_H
 
 #include <sys/types.h>
-#include <boilerplate/tunables.h>
 
 #ifndef SUCCESS
 #define SUCCESS 0
@@ -372,16 +371,6 @@ u_long psos_task_denormalize_priority(in
 
 extern int psos_long_names;
 
-static inline define_config_tunable(long_names, int, on)
-{
-	psos_long_names = on;
-}
-
-static inline read_config_tunable(long_names, int)
-{
-	return psos_long_names;
-}
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
#1 lore raw
Quoted 33 lines · Ronny Meeus

The psos.h file pollutes the application's namespace with defines of the boilerplate code because the tunables.h is included. In our application we already have a definition of the list_entry macro, resulting in a redefinition. The psos.h should be kept clean.

Following small test program clearly shows the issue:

#include <psos/psos.h>
#define list_entry
int main(int argc, char * const argv[])
{
return 0;
}

When compiling the code above a warning is generated:

simple_test.c:3:1: warning: "list_entry" redefined In file included from boilerplate/list.h:24,

                 from boilerplate/setup.h:21,
                 from boilerplate/tunables.h:22,
                 from psos/psos.h:28,
                 from simple_test.c:1:

boilerplate/shared-list.h:233:1: warning: this is the location of the previous definition

This patch resolves the issue by just removing the dependency
and all related functions. If the functions are actually needed, better to move them in a separate header file since they are not part of the 'official' psos interface.

include/psos/psos.h line 26

Quoted 2 lines
include/psos/psos.h +0 -0
@@ -25,7 +25,6 @@
 #define _XENOMAI_PSOS_PSOS_H
 

Ack. But then we'd also need to introduce psos/tunables.h for defining the bits your patch removes from psos/psos.h.

Signature · 1 line
Philippe.
#2 lore raw
Quoted 30 lines · Philippe Gerum
Quoted 29 lines · Ronny Meeus

The psos.h file pollutes the application's namespace with defines of the boilerplate code because the tunables.h is included. In our application we already have a definition of the list_entry macro, resulting in a redefinition. The psos.h should be kept clean.

Following small test program clearly shows the issue:

#include <psos/psos.h>
#define list_entry
int main(int argc, char * const argv[])
{
return 0;
}

When compiling the code above a warning is generated:

simple_test.c:3:1: warning: "list_entry" redefined In file included from boilerplate/list.h:24,

                 from boilerplate/setup.h:21,
                 from boilerplate/tunables.h:22,
                 from psos/psos.h:28,
                 from simple_test.c:1:

boilerplate/shared-list.h:233:1: warning: this is the location of the previous definition

This patch resolves the issue by just removing the dependency
and all related functions. If the functions are actually needed, better to move them in a separate header file since they are not part of the 'official' psos interface.

Quoted 10 lines

include/psos/psos.h line 26

Quoted 6 lines
include/psos/psos.h +0 -0
@@ -25,7 +25,6 @@
 #define _XENOMAI_PSOS_PSOS_H
 

Ack. But then we'd also need to introduce psos/tunables.h for defining the bits your patch removes from psos/psos.h.

Philippe

I just removed the functions because I did not see a need for them.

People can just access the
extern int psos_long_names
defined in the psos.h to manipulate the behavior of the psos interface with respect
to the long names behavior.

After studying the usage of the tunables I understand the mechanism and how it can be used to allow certain configurations to be done up to a certain point (init done).
If values are changed after that point, an assert is raised.

I have created a new patch (which I will send in a separate mail) that just moves the
functionality into a separate file. But this the issue remains that the user can access
(even write) the psos_long_names flag (after init) without any assert being triggered.

Ronny

Quoted 2 lines

--
Philippe.

#3 lore raw
Quoted 57 lines · Ronny Meeus
Quoted 30 lines · Philippe Gerum
Quoted 29 lines · Ronny Meeus

The psos.h file pollutes the application's namespace with defines of the boilerplate code because the tunables.h is included. In our application we already have a definition of the list_entry macro, resulting in a redefinition. The psos.h should be kept clean.

Following small test program clearly shows the issue:

#include <psos/psos.h>
#define list_entry
int main(int argc, char * const argv[])
{
return 0;
}

When compiling the code above a warning is generated:

simple_test.c:3:1: warning: "list_entry" redefined In file included from boilerplate/list.h:24,

                 from boilerplate/setup.h:21,
                 from boilerplate/tunables.h:22,
                 from psos/psos.h:28,
                 from simple_test.c:1:

boilerplate/shared-list.h:233:1: warning: this is the location of the previous definition

This patch resolves the issue by just removing the dependency
and all related functions. If the functions are actually needed, better to move them in a separate header file since they are not part of the 'official' psos interface.

Quoted 10 lines

include/psos/psos.h line 26

Quoted 6 lines
include/psos/psos.h +0 -0
@@ -25,7 +25,6 @@
 #define _XENOMAI_PSOS_PSOS_H
 

Ack. But then we'd also need to introduce psos/tunables.h for defining the bits your patch removes from psos/psos.h.

Philippe

I just removed the functions because I did not see a need for them.

People can just access the
extern int psos_long_names
defined in the psos.h to manipulate the behavior of the psos interface with respect
to the long names behavior.

After studying the usage of the tunables I understand the mechanism and how it can be used to allow certain configurations to be done up to a certain point (init done).
If values are changed after that point, an assert is raised.

Quoted 7 lines

I have created a new patch (which I will send in a separate mail) that just moves the
functionality into a separate file. But this the issue remains that the user can access
(even write) the psos_long_names flag (after init) without any assert being triggered.

This is all about interfaces. If user decides to bypass the interfaces doing silly things, other things will invariably end up hitting the fan; and this is true for virtually any interface exposed by the system.

Having an interface in this case is merely a way to guarantee proper behavior, regardless of psos_long_names being dropped, renamed or having a different type in the future.

Signature · 1 line
Philippe.