diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-03-03 01:12:50 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-03-03 01:12:50 +0000 |
commit | fb7368e12f7e64b66185a2ca27e766e1002880c8 (patch) | |
tree | 760050b3f31e6ef2c396cf85755e34a3d9d1a660 /apps | |
parent | 7a0110eedd2b7f70fe8c95806317cddfddd0f778 (diff) | |
download | rockbox-fb7368e12f7e64b66185a2ca27e766e1002880c8.tar.gz rockbox-fb7368e12f7e64b66185a2ca27e766e1002880c8.zip |
More 64bit simulator fixes: inttypes, settings block handling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8888 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings.c | 37 | ||||
-rw-r--r-- | apps/settings.h | 3 |
2 files changed, 21 insertions, 19 deletions
diff --git a/apps/settings.c b/apps/settings.c index 5a42b17651..6fedf66669 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <stddef.h> | 21 | #include <stddef.h> |
22 | #include <limits.h> | 22 | #include <limits.h> |
23 | #include "inttypes.h" | ||
23 | #include "config.h" | 24 | #include "config.h" |
24 | #include "kernel.h" | 25 | #include "kernel.h" |
25 | #include "thread.h" | 26 | #include "thread.h" |
@@ -557,14 +558,14 @@ static const struct bit_entry hd_bits[] = | |||
557 | 558 | ||
558 | /* helper function to extract n (<=32) bits from an arbitrary position | 559 | /* helper function to extract n (<=32) bits from an arbitrary position |
559 | * counting from LSB to MSB */ | 560 | * counting from LSB to MSB */ |
560 | static unsigned long get_bits( | 561 | static uint32_t get_bits( |
561 | const unsigned long* p, /* the start of the bitfield array */ | 562 | const uint32_t *p, /* the start of the bitfield array */ |
562 | unsigned int from, /* bit no. to start reading from */ | 563 | unsigned int from, /* bit no. to start reading from */ |
563 | unsigned int size) /* how many bits to read */ | 564 | unsigned int size) /* how many bits to read */ |
564 | { | 565 | { |
565 | unsigned int long_index = from / 32; | 566 | unsigned int long_index = from / 32; |
566 | unsigned int bit_index = from % 32; | 567 | unsigned int bit_index = from % 32; |
567 | unsigned long result; | 568 | uint32_t result; |
568 | 569 | ||
569 | result = p[long_index] >> bit_index; | 570 | result = p[long_index] >> bit_index; |
570 | 571 | ||
@@ -579,14 +580,14 @@ static unsigned long get_bits( | |||
579 | /* helper function to set n (<=32) bits to an arbitrary position, | 580 | /* helper function to set n (<=32) bits to an arbitrary position, |
580 | * counting from LSB to MSB */ | 581 | * counting from LSB to MSB */ |
581 | static void set_bits( | 582 | static void set_bits( |
582 | unsigned long* p, /* the start of the bitfield array */ | 583 | uint32_t *p, /* the start of the bitfield array */ |
583 | unsigned int from, /* bit no. to start writing into */ | 584 | unsigned int from, /* bit no. to start writing into */ |
584 | unsigned int size, /* how many bits to change */ | 585 | unsigned int size, /* how many bits to change */ |
585 | unsigned long value) /* content (LSBs will be taken) */ | 586 | uint32_t value) /* content (LSBs will be taken) */ |
586 | { | 587 | { |
587 | unsigned int long_index = from / 32; | 588 | unsigned int long_index = from / 32; |
588 | unsigned int bit_index = from % 32; | 589 | unsigned int bit_index = from % 32; |
589 | unsigned long mask; | 590 | uint32_t mask; |
590 | 591 | ||
591 | mask = 0xFFFFFFFF >> (32 - size); | 592 | mask = 0xFFFFFFFF >> (32 - size); |
592 | value &= mask; | 593 | value &= mask; |
@@ -783,8 +784,8 @@ static int load_config_buffer(int which) | |||
783 | as described per table */ | 784 | as described per table */ |
784 | static void save_bit_table(const struct bit_entry* p_table, int count, int bitstart) | 785 | static void save_bit_table(const struct bit_entry* p_table, int count, int bitstart) |
785 | { | 786 | { |
786 | unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */ | 787 | uint32_t *p_bitfield = (uint32_t *)config_block; /* 32 bit addr. */ |
787 | unsigned long value; /* 32 bit content */ | 788 | uint32_t value; /* 32 bit content */ |
788 | int i; | 789 | int i; |
789 | const struct bit_entry* p_run = p_table; /* start after the size info */ | 790 | const struct bit_entry* p_run = p_table; /* start after the size info */ |
790 | int curr_bit = bitstart + p_table->bit_size; | 791 | int curr_bit = bitstart + p_table->bit_size; |
@@ -797,16 +798,16 @@ static void save_bit_table(const struct bit_entry* p_table, int count, int bitst | |||
797 | switch(p_run->byte_size) | 798 | switch(p_run->byte_size) |
798 | { | 799 | { |
799 | case 1: | 800 | case 1: |
800 | value = ((unsigned char*)&global_settings)[p_run->settings_offset]; | 801 | value = ((uint8_t *)&global_settings)[p_run->settings_offset]; |
801 | break; | 802 | break; |
802 | case 2: | 803 | case 2: |
803 | value = ((unsigned short*)&global_settings)[p_run->settings_offset/2]; | 804 | value = ((uint16_t *)&global_settings)[p_run->settings_offset/2]; |
804 | break; | 805 | break; |
805 | case 4: | 806 | case 4: |
806 | value = ((unsigned int*)&global_settings)[p_run->settings_offset/4]; | 807 | value = ((uint32_t *)&global_settings)[p_run->settings_offset/4]; |
807 | break; | 808 | break; |
808 | default: | 809 | default: |
809 | DEBUGF( "illegal size!" ); | 810 | DEBUGF( "save_bit_table: illegal size!\n" ); |
810 | continue; | 811 | continue; |
811 | } | 812 | } |
812 | set_bits(p_bitfield, curr_bit, p_run->bit_size & 0x3F, value); | 813 | set_bits(p_bitfield, curr_bit, p_run->bit_size & 0x3F, value); |
@@ -1115,8 +1116,8 @@ void settings_apply(void) | |||
1115 | /* helper to load global_settings from a bitfield, as described per table */ | 1116 | /* helper to load global_settings from a bitfield, as described per table */ |
1116 | static void load_bit_table(const struct bit_entry* p_table, int count, int bitstart) | 1117 | static void load_bit_table(const struct bit_entry* p_table, int count, int bitstart) |
1117 | { | 1118 | { |
1118 | unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */ | 1119 | uint32_t *p_bitfield = (uint32_t *)config_block; /* 32 bit addr. */ |
1119 | unsigned long value; /* 32 bit content */ | 1120 | uint32_t value; /* 32 bit content */ |
1120 | int i; | 1121 | int i; |
1121 | int maxbit; /* how many bits are valid in the saved part */ | 1122 | int maxbit; /* how many bits are valid in the saved part */ |
1122 | const struct bit_entry* p_run = p_table; /* start after the size info */ | 1123 | const struct bit_entry* p_run = p_table; /* start after the size info */ |
@@ -1146,19 +1147,19 @@ static void load_bit_table(const struct bit_entry* p_table, int count, int bitst | |||
1146 | switch(p_run->byte_size) | 1147 | switch(p_run->byte_size) |
1147 | { | 1148 | { |
1148 | case 1: | 1149 | case 1: |
1149 | ((unsigned char*)&global_settings)[p_run->settings_offset] = | 1150 | ((uint8_t *)&global_settings)[p_run->settings_offset] = |
1150 | (unsigned char)value; | 1151 | (unsigned char)value; |
1151 | break; | 1152 | break; |
1152 | case 2: | 1153 | case 2: |
1153 | ((unsigned short*)&global_settings)[p_run->settings_offset/2] = | 1154 | ((uint16_t *)&global_settings)[p_run->settings_offset/2] = |
1154 | (unsigned short)value; | 1155 | (unsigned short)value; |
1155 | break; | 1156 | break; |
1156 | case 4: | 1157 | case 4: |
1157 | ((unsigned int*)&global_settings)[p_run->settings_offset/4] = | 1158 | ((uint32_t *)&global_settings)[p_run->settings_offset/4] = |
1158 | (unsigned int)value; | 1159 | (unsigned int)value; |
1159 | break; | 1160 | break; |
1160 | default: | 1161 | default: |
1161 | DEBUGF( "illegal size!" ); | 1162 | DEBUGF( "load_bit_table: illegal size!\n" ); |
1162 | continue; | 1163 | continue; |
1163 | } | 1164 | } |
1164 | } | 1165 | } |
diff --git a/apps/settings.h b/apps/settings.h index 87020a1094..ce2a7e27cf 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define __SETTINGS_H__ | 21 | #define __SETTINGS_H__ |
22 | 22 | ||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include "inttypes.h" | ||
24 | #include "config.h" | 25 | #include "config.h" |
25 | #include "file.h" | 26 | #include "file.h" |
26 | #include "dircache.h" | 27 | #include "dircache.h" |
@@ -285,7 +286,7 @@ struct user_settings | |||
285 | bool resume; /* resume option: 0=off, 1=on */ | 286 | bool resume; /* resume option: 0=off, 1=on */ |
286 | int resume_index; /* index in playlist (-1 for no active resume) */ | 287 | int resume_index; /* index in playlist (-1 for no active resume) */ |
287 | int resume_first_index; /* index of first track in playlist */ | 288 | int resume_first_index; /* index of first track in playlist */ |
288 | unsigned long resume_offset; /* byte offset in mp3 file */ | 289 | uint32_t resume_offset; /* byte offset in mp3 file */ |
289 | int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted | 290 | int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted |
290 | >0=shuffled) */ | 291 | >0=shuffled) */ |
291 | 292 | ||