Compare commits

...

6 commits

Author SHA1 Message Date
William Wilgus
8a773fb29f lua -- remove strtol and strtoul replace with rb->strtol and rb->strtoul
Change-Id: Ib7ba358b6488b946404c0c4cd8773e948810a7f7
2025-12-06 18:11:13 -05:00
Solomon Peachy
dada036b10 configure: Partial revert of 6c6bdbf60e
Turns out I compile-tested stale trees instead of the broken change

Net result is just the simpler MIPS revision (32/64/"classic") lookup rather than
the sub-revision (eg mips32r2 etc).

Change-Id: Ideebe522d29132f00f3769222f3846000b3a89fd
2025-12-06 15:54:43 -05:00
Solomon Peachy
6c6bdbf60e configure: Revamp MIPS architecture version+revision detection
This allows us to easily distinguish between mips32 and mips32r2

(Works at least as far back as gcc 4.9)

Change-Id: I2bcba194fd9cbeedf76cea739252271908bf73d0
2025-12-06 14:58:40 -05:00
Solomon Peachy
5e5b434ce8 configure: Simplify the arm architecture version lookup
Going back to at least gcc 4.9, we can key off of __ARM_ARCH
which is all we care about here.

Change-Id: Ic2659db5ff55ccefe2c3f71957b967f36025f7e3
2025-12-06 14:43:03 -05:00
Solomon Peachy
1203b8657e configure: -masm-syntax-unified does not apply to aarch64
Change-Id: Ida12a60b629ccdea3980bcabc79812e3b97181e8
2025-12-06 14:24:32 -05:00
Solomon Peachy
e94a96cdcf FS#13497: '0' is sometimes a valid track number
Most notably for CD rips that use a track number of 0 for
the leadin.

Therefore change our "invalid track number" canary to -1 instead
of 0.  Additionally don't try to parse an empty string.

In the process, get rid of redudant 'discnum = 0' as well.

NOTE: While not strictly necessary, we recommend rebuilding the
      database to ensure files without track numbers are
      updated with the new canary.

Change-Id: I543f98ca49cec7b5eeffa7c14c1eca57171f345a
2025-12-06 09:20:32 -05:00
24 changed files with 124 additions and 188 deletions

View file

@ -263,7 +263,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
case SKIN_TOKEN_METADATA_TRACK_NUMBER:
if (id3->track_string)
return id3->track_string;
if (id3->tracknum) {
if (id3->tracknum >= 0) {
itoa_buf(buf, buf_size, id3->tracknum);
return buf;
}

View file

@ -173,7 +173,7 @@ void finalize_id3(struct mp3entry *id3)
id3->codectype = mul_id3.codectype;
id3->vbr = mul_id3.vbr;
id3->discnum = 0;
id3->tracknum = 0;
id3->tracknum = -1;
id3->track_level = 0;
id3->album_level = 0;
}

View file

@ -3,7 +3,4 @@ version 0.31 which is licensed under the GPL version 2:
gmtime.c
strftime.c
strpbrk.c
strtol.c
strtoul.c
strstr.c

View file

@ -33,8 +33,6 @@ rocklib_img.c
tlsf_helper.c
strftime.c
strpbrk.c
strtoul.c
strtol.c
strstr.c
rocklua.c
luadir.c

View file

@ -43,8 +43,6 @@
extern char curpath[MAX_PATH];
struct tm *gmtime(const time_t *timep);
long strtol(const char *nptr, char **endptr, int base);
unsigned long strtoul(const char *str, char **endptr, int base);
size_t strftime(char* dst, size_t max, const char* format, const struct tm* tm);
long lfloor(long x);
long lpow(long x, long y);
@ -64,6 +62,8 @@ int splash_scroller(int timeout, const char* str);
#define strcmp rb->strcmp
#define strcpy rb->strcpy
#define strlen rb->strlen
#define strtol rb->strtol
#define strtoul rb->strtoul
#define yield() rb->yield()
#endif /* _ROCKCONF_H_ */

View file

@ -1,27 +0,0 @@
#include "rocklibc.h"
extern unsigned long int strtoul(const char *ptr, char **endptr, int base);
#define ABS_LONG_MIN LONG_MAX
long int strtol(const char *nptr, char **endptr, int base)
{
int neg=0;
unsigned long int v;
const char*orig=nptr;
while(__unlikely(isspace(*nptr))) nptr++;
if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; ++nptr; }
v=strtoul(nptr,endptr,base);
if (endptr && *endptr==nptr) *endptr=(char *)orig;
if (__unlikely(v>=ABS_LONG_MIN)) {
if (v==ABS_LONG_MIN && neg) {
errno=0;
return v;
}
errno=ERANGE;
return (neg?LONG_MIN:LONG_MAX);
}
return (neg?-v:v);
}

View file

@ -1,53 +0,0 @@
#include "rocklibc.h"
unsigned long int strtoul(const char *ptr, char **endptr, int base)
{
int neg = 0, overflow = 0;
unsigned long int v=0;
const char* orig;
const char* nptr=ptr;
while(__unlikely(isspace(*nptr))) ++nptr;
if (*nptr == '-') { neg=1; nptr++; }
else if (*nptr == '+') ++nptr;
orig=nptr;
if (base==16 && nptr[0]=='0') goto skip0x;
if (base) {
register unsigned int b=base-2;
if (__unlikely(b>34)) { errno=EINVAL; return 0; }
} else {
if (*nptr=='0') {
base=8;
skip0x:
if ((nptr[1]=='x'||nptr[1]=='X') && isxdigit(nptr[2])) {
nptr+=2;
base=16;
}
} else
base=10;
}
while(__likely(*nptr)) {
register unsigned char c=*nptr;
c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c<='9'?c-'0':0xff);
if (__unlikely(c>=base)) break; /* out of base */
{
register unsigned long x=(v&0xff)*base+c;
register unsigned long w=(v>>8)*base+(x>>8);
if (w>(ULONG_MAX>>8)) overflow=1;
v=(w<<8)+(x&0xff);
}
++nptr;
}
if (__unlikely(nptr==orig)) { /* no conversion done */
nptr=ptr;
errno=EINVAL;
v=0;
}
if (endptr) *endptr=(char *)nptr;
if (overflow) {
errno=ERANGE;
return ULONG_MAX;
}
return (neg?-v:v);
}

View file

@ -571,7 +571,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
if(say_it)
say_number_and_spell(val, true);
}
else if (id3->tracknum)
else if (id3->tracknum >= 0)
{
itoa_buf(buffer, buffer_len, id3->tracknum);
val = buffer;

View file

@ -2322,7 +2322,7 @@ static void NO_INLINE add_tagcache(char *path, unsigned long mtime)
logf("-> %s", path);
if (id3.tracknum <= 0) /* Track number missing? */
if (id3.tracknum < 0) /* Track number missing? */
{
id3.tracknum = -1;
}

View file

@ -1,4 +1,4 @@
#if CPU_MIPS == 32
#if (CPU_MIPS == 32)
#include "thread-mips32.c"
#else
#error Missing thread impl

View file

@ -1,3 +1,6 @@
/* The following file is (with slight modifications for Rockbox) from dietlibc
* version 0.31 which is licensed under the GPL version 2: */
#include <stdlib.h>
#include <errno.h>
#include <limits.h>

View file

@ -1,3 +1,6 @@
/* The following file is (with slight modifications for Rockbox) from dietlibc
* version 0.31 which is licensed under the GPL version 2: */
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>

View file

@ -70,8 +70,6 @@ bool get_aac_metadata(int fd, struct mp3entry *entry)
unsigned char buf[5];
entry->title = NULL;
entry->tracknum = 0;
entry->discnum = 0;
entry->id3v1len = 0;
entry->id3v2len = getid3v2len(fd);
entry->first_frame_offset = entry->id3v2len;

View file

@ -36,8 +36,6 @@
static void read_id3_tags(int fd, struct mp3entry* id3)
{
id3->tracknum = 0;
id3->discnum = 0;
setid3v2title(fd, id3);
}

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
#include <errno.h>
#include "platform.h"
#include "metadata.h"
@ -473,7 +474,12 @@ static int asf_parse_header(int fd, struct mp3entry* id3,
if (type == 0) {
id3->track_string = id3buf;
asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining);
id3->tracknum = atoi(id3->track_string);
if (strlen(id3->track_string)) {
char *p = NULL;
int tracknum = strtol(id3->track_string, &p, 0);
if (!(tracknum == 0 && (errno || *p)))
id3->tracknum = tracknum;
}
} else if ((type >=2) && (type <= 5)) {
id3->tracknum = asf_intdecode(fd, type, length);
} else {

View file

@ -243,7 +243,12 @@ static int skip_unsynched(int fd, int len)
/* parse numeric value from string */
static int parsetracknum( struct mp3entry* entry, char* tag, int bufferpos )
{
entry->tracknum = atoi( tag );
if (strlen(tag)) {
char *p = NULL;
int tracknum = strtol(tag, &p, 0);
if (!(tracknum == 0 && (errno || *p)))
entry->tracknum = tracknum;
}
return bufferpos;
}
@ -826,7 +831,7 @@ void setid3v2title(int fd, struct mp3entry *entry)
return;
}
entry->id3version = version;
entry->tracknum = entry->year = entry->discnum = 0;
entry->year = entry->discnum = 0;
entry->title = entry->artist = entry->album = NULL; /* FIXME incomplete */
global_flags = header[5];

View file

@ -452,6 +452,8 @@ bool get_metadata_ex(struct mp3entry* id3, int fd, const char* trackname, int fl
id3->has_embedded_cuesheet = false;
id3->embedded_cuesheet.pos = 0;
id3->tracknum = -1;
entry = &audio_formats[id3->codectype];
/* Load codec specific track tag information and confirm the codec type. */

View file

@ -23,6 +23,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
#include <errno.h>
#include "platform.h"
#include "metadata.h"
@ -315,7 +316,12 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3,
if (((item == eTRACK && (type == TAGTYPE_APE)))
|| (item == eTRACKNUMBER && (type == TAGTYPE_VORBIS)))
{
id3->tracknum = atoi(value);
if (strlen(value)) {
char *p = NULL;
int tracknum = strtol(value, &p, 0);
if (!(tracknum == 0 && (errno || *p)))
id3->tracknum = tracknum;
}
p = &(id3->track_string);
}
else if (item == eDISCNUMBER || item == eDISC)

View file

@ -166,8 +166,6 @@ bool get_mp3_metadata(int fd, struct mp3entry *entry)
entry->filesize = filesize(fd);
entry->id3v1len = getid3v1len(fd);
entry->id3v2len = getid3v2len(fd);
entry->tracknum = 0;
entry->discnum = 0;
if (entry->id3v2len)
setid3v2title(fd, entry);

View file

@ -481,10 +481,14 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3,
read_mp4_tag_i_from_n(fd, &id3->discnum, &id3->disc_string, size, &buffer_left, &buffer);
break;
case MP4_trkn:
read_mp4_tag_i_from_n(fd, &id3->tracknum, &id3->track_string, size, &buffer_left, &buffer);
case MP4_trkn: {
char *p = NULL;
int tracknum = 0;
read_mp4_tag_i_from_n(fd, &tracknum, &id3->track_string, size, &buffer_left, &buffer);
if (!(tracknum == 0 && (errno || *p)))
id3->tracknum = tracknum;
break;
}
#ifdef HAVE_ALBUMART
case MP4_covr:
{

View file

@ -56,8 +56,6 @@ static void read_id3_tags(int fd, struct mp3entry* id3)
id3->title = NULL;
id3->filesize = filesize(fd);
id3->id3v2len = getid3v2len(fd);
id3->tracknum = 0;
id3->discnum = 0;
id3->vbr = false; /* All TTA files are CBR */
/* first get id3v2 tags. if no id3v2 tags ware found, get id3v1 tags */

View file

@ -732,7 +732,7 @@ static void print_mp3entry(const struct mp3entry *id3, FILE *f)
if (id3->album) fprintf(f, "Album: %s\n", id3->album);
if (id3->genre_string) fprintf(f, "Genre: %s\n", id3->genre_string);
if (id3->disc_string || id3->discnum) fprintf(f, "Disc: %s (%d)\n", id3->disc_string, id3->discnum);
if (id3->track_string || id3->tracknum) fprintf(f, "Track: %s (%d)\n", id3->track_string, id3->tracknum);
if (id3->track_string || id3->tracknum >= 0) fprintf(f, "Track: %s (%d)\n", id3->track_string, id3->tracknum);
if (id3->year_string || id3->year) fprintf(f, "Year: %s (%d)\n", id3->year_string, id3->year);
if (id3->composer) fprintf(f, "Composer: %s\n", id3->composer);
if (id3->comment) fprintf(f, "Comment: %s\n", id3->comment);

22
tools/configure vendored
View file

@ -4727,9 +4727,9 @@ if [ -z "$arch" ]; then
arch="m68k"
elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then
arch="arm"
# cpp defines like "#define __ARM_ARCH_4TE__ 1" (where we want to extract the 4)
arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep __ARM_ARCH | sed -e 's,.*\([0-9]\).*,\1,' | grep -v __ARM_ARCH | head -1)"
arch_profile="$(echo "$cpp_defines" | grep 'define __ARM_ARCH_PROFILE' | sed -e 's,.* \([0-9]\+\)$,\1,')"
# cpp defines like "#define __ARM_ARCH 4" (where we want to extract the 4)
arch_version="$(echo "$cpp_defines" | grep 'define __ARM_ARCH ' | sed -e 's,.* \([0-9]\).*,\1,')"
arch_profile="$(echo "$cpp_defines" | grep 'define __ARM_ARCH_PROFILE ' | sed -e 's,.* \([0-9]\+\)$,\1,')"
if test "$gccnum" -ge "800"; then
# GCC8+ can natively emit unified asm syntax
GCCOPTS="$GCCOPTS -masm-syntax-unified"
@ -4770,13 +4770,9 @@ if [ -z "$arch" ]; then
esac
elif [ -n "$(echo $cpp_defines | grep -w __aarch64__)" ]; then
arch="arm64"
# cpp defines like "#define __ARM_ARCH_8A__ 1" (where we want to extract the 8)
arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep __ARM_ARCH | sed -e 's,.*\([0-9]\).*,\1,' | grep -v __ARM_ARCH | head -1)"
arch_profile="$(echo "$cpp_defines" | grep 'define __ARM_ARCH_PROFILE' | sed -e 's,.* \([0-9]\+\)$,\1,')"
if test "$gccnum" -ge "800"; then
# GCC8+ can natively emit unified asm syntax
GCCOPTS="$GCCOPTS -masm-syntax-unified"
fi
# cpp defines like "#define __ARM_ARCH 8" (where we want to extract the 8)
arch_version="$(echo "$cpp_defines" | grep 'define __ARM_ARCH ' | sed -e 's,.* \([0-9]\).*,\1,')"
arch_profile="$(echo "$cpp_defines" | grep 'define __ARM_ARCH_PROFILE ' | sed -e 's,.* \([0-9]\+\)$,\1,')"
case "$arch_profile" in
65) # Cortex-A
arch_profile=application
@ -4788,7 +4784,11 @@ if [ -z "$arch" ]; then
esac
elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then
arch="mips"
arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep _MIPS_ARCH_MIPS | sed -e 's,.*\([0-9][0-9]\).*,\1,' | grep -v _MIPS_ARCH_MIPS)"
arch_version="$(echo "$cpp_defines" | grep 'define __mips ' | sed -e 's,.* \([0-9]\+\).*,\1,')"
# arch_revision="$(echo "$cpp_defines" | grep 'define __mips_isa_rev ' | sed -e 's,.* \([0-9]\+\).*,\1,')"
# if [ -n "$arch_revision" ] ; then
# arch_version="${arch_version}r${arch_revision}"
# fi
elif [ -n "$(echo $cpp_defines | grep -w __i386__)" ]; then
arch="x86"
elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then