mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 16:08:53 +08:00
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:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user