params: make param_t uint16_t on NuttX

param_t is only used as an offset and we have <1000 params, so an uint16_t
is enough.
This saves roughly 1KB of RAM. We only do that on NuttX because normal
integers have better performance in general.
Previously on amd64, this was even 64bits because it was an uintptr_t.
This commit is contained in:
Beat Küng
2017-03-14 21:30:53 +01:00
committed by Lorenz Meier
parent 45af77a543
commit b4290b6b52
8 changed files with 39 additions and 12 deletions
@@ -65,8 +65,8 @@
* Storage for modified parameters.
*/
struct param_wbuf_s {
param_t param;
union param_value_u val;
param_t param;
bool unsaved;
};
+1 -1
View File
@@ -111,8 +111,8 @@ static const struct param_info_s *param_info_base = (const struct param_info_s *
* Storage for modified parameters.
*/
struct param_wbuf_s {
param_t param;
union param_value_u val;
param_t param;
bool unsaved;
};
+31 -4
View File
@@ -69,23 +69,50 @@ typedef enum param_type_e {
PARAM_TYPE_UNKNOWN = 0xffff
} param_type_t;
#ifdef __PX4_NUTTX // on NuttX use 16 bits to save RAM
/**
* Parameter handle.
*
* Parameters are represented by parameter handles, which can
* be obtained by looking up (or creating?) parameters.
* be obtained by looking up parameters. They are an offset into a global
* constant parameter array.
*/
typedef uintptr_t param_t;
typedef uint16_t param_t;
/**
* Handle returned when a parameter cannot be found.
*/
#define PARAM_INVALID ((uintptr_t)0xffffffff)
#define PARAM_INVALID ((uint16_t)0xffff)
/**
* Magic handle for hash check param
*/
#define PARAM_HASH ((uintptr_t)INT32_MAX)
#define PARAM_HASH ((uint16_t)INT16_MAX)
#else // on other platforms use 32 bits for better performance
/**
* Parameter handle.
*
* Parameters are represented by parameter handles, which can
* be obtained by looking up parameters. They are an offset into a global
* constant parameter array.
*/
typedef uint32_t param_t;
/**
* Handle returned when a parameter cannot be found.
*/
#define PARAM_INVALID ((uint32_t)0xffffffff)
/**
* Magic handle for hash check param
*/
#define PARAM_HASH ((uint32_t)INT32_MAX)
#endif /* __PX4_NUTTX */
/**
* Initialize the param backend. Call this on startup before calling any other methods.
+1 -1
View File
@@ -96,8 +96,8 @@ static struct param_info_s *param_info_base = (struct param_info_s *) &px4_param
* Storage for modified parameters.
*/
struct param_wbuf_s {
param_t param;
union param_value_u val;
param_t param;
bool unsaved;
};