Skip to contentSkip to conversation

sound: Close holes in struct snd_pcm_hw_rule

PATCH Applied Lars-Peter Clausen 2 participants 4 messages Apr 27, 2015 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sound: Close holes in struct snd_pcm_hw_rule

On a 64-bit system there are two 32-bit holes due to the alignment of 64-bit fields. Reordering things slightly gets rid of those holes, reducing the size of the struct by 17% percent of its original size.

---
 include/sound/pcm.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/sound/pcm.h +2 -1
index 0cb7f3f..d632809 100644
@@ -224,9 +224,10 @@ typedef int (*snd_pcm_hw_rule_func_t)(struct snd_pcm_hw_params *params,
 
 struct snd_pcm_hw_rule {
 	unsigned int cond;
-	snd_pcm_hw_rule_func_t func;
 	int var;
 	int deps[4];
+
+	snd_pcm_hw_rule_func_t func;
 	void *private;
 };
 
Signature · 1 line
1.8.0
#1 lore raw

PATCH 2/2 sound: Close holes in struct snd_pcm_constraint_list

On a 64-bit system there is a 32-bit hole in struct snd_pcm_constraint_list and then 32-bit padding at the end. Reordering things slightly gets rid of the hole and padding, reducing the size of the struct by 50% from its original size.

---
 include/sound/pcm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/sound/pcm.h +1 -1
index d632809..691e7ee 100644
@@ -274,8 +274,8 @@ struct snd_pcm_hw_constraint_ratdens {
 };
 
 struct snd_pcm_hw_constraint_list {
-	unsigned int count;
 	const unsigned int *list;
+	unsigned int count;
 	unsigned int mask;
 };
 
Signature · 1 line
1.8.0
Applied
#2 lore raw

Re: [PATCH 2/2] sound: Close holes in struct snd_pcm_constraint_list

At Mon, 27 Apr 2015 12:20:29 +0200,

Quoted 7 lines · Lars-Peter Clausen

On a 64-bit system there is a 32-bit hole in struct snd_pcm_constraint_list and then 32-bit padding at the end. Reordering things slightly gets rid of the hole and padding, reducing the size of the struct by 50% from its original size.

Thanks, applied.

Takashi

Quoted 21 lines
---
 include/sound/pcm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/sound/pcm.h +1 -1
index d632809..691e7ee 100644
@@ -274,8 +274,8 @@ struct snd_pcm_hw_constraint_ratdens {
 };
 
 struct snd_pcm_hw_constraint_list {
-	unsigned int count;
 	const unsigned int *list;
+	unsigned int count;
 	unsigned int mask;
 };
 
Signature · 1 line
1.8.0
Applied
#3 lore raw
In reply to Lars-Peter Clausen

At Mon, 27 Apr 2015 12:20:28 +0200,

Quoted 6 lines · Lars-Peter Clausen

On a 64-bit system there are two 32-bit holes due to the alignment of 64-bit fields. Reordering things slightly gets rid of those holes, reducing the size of the struct by 17% percent of its original size.

Thanks, applied.

Takashi

Quoted 23 lines
---
 include/sound/pcm.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/sound/pcm.h +2 -1
index 0cb7f3f..d632809 100644
@@ -224,9 +224,10 @@ typedef int (*snd_pcm_hw_rule_func_t)(struct snd_pcm_hw_params *params,
 
 struct snd_pcm_hw_rule {
 	unsigned int cond;
-	snd_pcm_hw_rule_func_t func;
 	int var;
 	int deps[4];
+
+	snd_pcm_hw_rule_func_t func;
 	void *private;
 };
 
Signature · 1 line
1.8.0