From 9d5bf66a9c38a07e3c69dc9864236cacc5b02af9 Mon Sep 17 00:00:00 2001 From: Stewart Brodie <sbrodie@gitlab.riscosopen.org> Date: Fri, 6 Apr 2001 14:29:06 +0000 Subject: [PATCH] Fix for strcmp(). Fix for RISC_OSLib res() function. Detail: Version 4.89 featured an improved strcmp() routine that didn't actually work properly (bug #4085). The return values had the wrong sign if this optimised code was used and the string contained top-bit set chars. Removed that rlib.s.asmdefs hack as the comment in the makefile suggested. Nothing needs it any more as the assembler sources that require it now get via a -PD argument. res_ prefix function was still wrong as it failed to detect valid but wrong filenames, hence the "Make$Path not defined" errors in the latest tools release. Admin: Fixes Bugzilla bug #4085 Should fix BaseSW's build problems too. Version 5.29. Tagged as 'RISC_OSLib-5_29' --- Makefile | 46 ++++++++++++++++------------------------------ VersionASM | 14 +++++++------- VersionNum | 20 ++++++++++---------- c/string | 22 ++++++++++++++++++++++ clib/s/cl_body | 1 - rlib/c/res | 6 ++++-- rlib/s/bastxt | 1 - rlib/s/defs | 18 ------------------ rlib/s/rom_defs | 18 ------------------ rlib/s/swi | 2 -- 10 files changed, 59 insertions(+), 89 deletions(-) delete mode 100644 rlib/s/defs delete mode 100644 rlib/s/rom_defs diff --git a/Makefile b/Makefile index 9d72dea..8a375c7 100644 --- a/Makefile +++ b/Makefile @@ -40,8 +40,8 @@ # Set default component and target. # Alternative possible target is RISC_OSLib -COMPONENT .= SharedCLibrary -TARGET .= CLib +COMPONENT ?= SharedCLibrary +TARGET ?= CLib # # Paths @@ -121,6 +121,12 @@ VSFLAGS =\ ASFLAGS =\ ${SCL_APCS} +# Setting UROM on the command-line for rlib +UROM_DEFS =\ + -PD "UROM SETL {FALSE}" +UROM_ROM_DEFS =\ + -PD "UROM SETL {TRUE}" + VPATH = @ kernel clib rlib .SUFFIXES: .o .o_rl .m_o_rl .rm_o .rm_o_rl @@ -440,7 +446,6 @@ clean_all: ${RM} s.abssym ${RM} s.c_abssym ${RM} s.a_abssym - ${RM} rlib.s.asmdefs ${WIPE} lib.* ${WFLAGS} @echo ${COMPONENT}: cleaned @@ -697,8 +702,7 @@ rm_o.clib: clib.s.cl_obj_r ${OBJASM} ${AFLAGS} ${ASFLAGS} ${OPTIONS} -from clib.s.cl_obj_r -to $@ rm_o.cl_modbody: clib.s.cl_mod_r - ${CP} rlib.s.rom_defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} ${AFLAGS} ${ASFLAGS} ${OPTIONS} -from clib.s.cl_mod_r -to $@ + ${OBJASM} ${AFLAGS} ${ASFLAGS} ${OPTIONS} ${UROM_ROM_DEFS} -from clib.s.cl_mod_r -to $@ rm_o_rl.rl_modbody: rlib.s.rl_mod_r ${OBJASM} ${AFLAGS} ${ASFLAGS} ${OPTIONS} -from rlib.s.rl_mod_r -to $@ @@ -739,42 +743,24 @@ rm_o.string: c.string # # Special case: use "rom_defs" for ROM library (o_rm), "defs" for the others # Note: New Assembler - could use -PreDefine "UROM SETL {FALSE}" -# + o_rl.swi: rlib.s.swi - ${CP} rlib.s.defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.swi o_rl.swi ${AFLAGS} + ${OBJASM} ${UROM_DEFS} rlib.s.swi o_rl.swi ${AFLAGS} o_rl.poll: rlib.s.poll - ${CP} rlib.s.defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.poll o_rl.poll ${AFLAGS} - -o_rl.bastxt: rlib.s.bastxt - ${CP} rlib.s.defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.bastxt o_rl.bastxt ${AFLAGS} + ${OBJASM} ${UROM_DEFS} rlib.s.poll o_rl.poll ${AFLAGS} m_o_rl.swi: rlib.s.swi - ${CP} rlib.s.defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.swi m_o_rl.swi ${AFLAGS} + ${OBJASM} ${UROM_DEFS} rlib.s.swi m_o_rl.swi ${AFLAGS} m_o_rl.poll: rlib.s.poll - ${CP} rlib.s.defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.poll m_o_rl.poll ${AFLAGS} - -m_o_rl.bastxt: rlib.s.bastxt - ${CP} rlib.s.defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.bastxt m_o_rl.bastxt ${AFLAGS} + ${OBJASM} ${UROM_DEFS} rlib.s.poll m_o_rl.poll ${AFLAGS} rm_o_rl.swi: rlib.s.swi - ${CP} rlib.s.rom_defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.swi rm_o_rl.swi ${AFLAGS} ${OPTIONS} + ${OBJASM} ${UROM_ROM_DEFS} rlib.s.swi rm_o_rl.swi ${AFLAGS} ${OPTIONS} rm_o_rl.poll: rlib.s.poll - ${CP} rlib.s.rom_defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.poll rm_o_rl.poll ${AFLAGS} ${OPTIONS} - -rm_o_rl.bastxt: rlib.s.bastxt - ${CP} rlib.s.rom_defs rlib.s.asmdefs ${CPFLAGS} - ${OBJASM} rlib.s.bastxt rm_o_rl.bastxt ${AFLAGS} ${OPTIONS} + ${OBJASM} ${UROM_ROM_DEFS} rlib.s.poll rm_o_rl.poll ${AFLAGS} ${OPTIONS} # # trace separated out to allow defining of TRACE diff --git a/VersionASM b/VersionASM index 532d2ba..fed7896 100644 --- a/VersionASM +++ b/VersionASM @@ -11,14 +11,14 @@ GBLS Module_HelpVersion GBLS Module_ComponentName GBLS Module_ComponentPath -Module_MajorVersion SETS "5.28" -Module_Version SETA 528 +Module_MajorVersion SETS "5.29" +Module_Version SETA 529 Module_MinorVersion SETS "" -Module_Date SETS "02 Mar 2001" -Module_ApplicationDate2 SETS "02-Mar-01" -Module_ApplicationDate4 SETS "02-Mar-2001" +Module_Date SETS "06 Apr 2001" +Module_ApplicationDate2 SETS "06-Apr-01" +Module_ApplicationDate4 SETS "06-Apr-2001" Module_ComponentName SETS "RISC_OSLib" Module_ComponentPath SETS "RiscOS/Sources/Lib/RISC_OSLib" -Module_FullVersion SETS "5.28" -Module_HelpVersion SETS "5.28 (02 Mar 2001)" +Module_FullVersion SETS "5.29" +Module_HelpVersion SETS "5.29 (06 Apr 2001)" END diff --git a/VersionNum b/VersionNum index 6b7b829..9e4161f 100644 --- a/VersionNum +++ b/VersionNum @@ -1,22 +1,22 @@ -/* (5.28) +/* (5.29) * * This file is automatically maintained by srccommit, do not edit manually. * */ -#define Module_MajorVersion_CMHG 5.28 +#define Module_MajorVersion_CMHG 5.29 #define Module_MinorVersion_CMHG -#define Module_Date_CMHG 02 Mar 2001 +#define Module_Date_CMHG 06 Apr 2001 -#define Module_MajorVersion "5.28" -#define Module_Version 528 +#define Module_MajorVersion "5.29" +#define Module_Version 529 #define Module_MinorVersion "" -#define Module_Date "02 Mar 2001" +#define Module_Date "06 Apr 2001" -#define Module_ApplicationDate2 "02-Mar-01" -#define Module_ApplicationDate4 "02-Mar-2001" +#define Module_ApplicationDate2 "06-Apr-01" +#define Module_ApplicationDate4 "06-Apr-2001" #define Module_ComponentName "RISC_OSLib" #define Module_ComponentPath "RiscOS/Sources/Lib/RISC_OSLib" -#define Module_FullVersion "5.28" -#define Module_HelpVersion "5.28 (02 Mar 2001)" +#define Module_FullVersion "5.29" +#define Module_HelpVersion "5.29 (06 Apr 2001)" diff --git a/c/string b/c/string index 7da4c21..3084dbd 100644 --- a/c/string +++ b/c/string @@ -226,6 +226,7 @@ int strcmp(const char *a, const char *b) /* lexical comparison on strings */ #ifdef _copywords #ifdef BYTESEX_EVEN /* Improved little-endian ARM strcmp code by Ian Rickards, ARM Ltd. */ +/* sbrodie (06/04/01): unfortunately, it breaks strcmp() semantics required by the library definition */ if ((((int)a | (int)b) & 3) == 0) { int w1, w2, res, rc; nullbyte_prologue_(); @@ -239,6 +240,7 @@ int strcmp(const char *a, const char *b) /* lexical comparison on strings */ return 0; strcmp_checkbytes: +# ifdef WANT_ARMS_BROKEN_STRCMP_FOR_TOP_BIT_SET_CHARACTERS /* carry propagation in subtract means that no subtract-per-byte is needed */ rc = res << 24; if (rc != 0) return rc; @@ -253,6 +255,23 @@ strcmp_checkbytes: if ((w1 & 0xff0000) == 0) return rc; return res; +# else /* WANT_ARMS_BROKEN_STRCMP_FOR_TOP_BIT_SET_CHARACTERS */ + /* res is guaranteed non-zero, so rc will not be zero, therefore the loop + * will find the bit eventually. The shifting is done to ensure that if it + * is the top-byte that contains the difference, we don't lose the sign bit + * on the subtraction. Right-shift on signed integers implementation defined, + * but because we mask w1 and w2 with res, whether ASL or LSL is used is irrelevant. + */ + rc = res & -res; + res = 0xFF; + for (;;) { + if (rc & res) return (w1 & res) - (w2 & res); + w1 >>= 1; + w2 >>= 1; + rc >>= 1; + res <<= 7; + } +# endif /* WANT_ARMS_BROKEN_STRCMP_FOR_TOP_BIT_SET_CHARACTERS */ #else if ((((int)a | (int)b) & 3) == 0) { int w1, w2; @@ -262,6 +281,9 @@ strcmp_checkbytes: w2 = *(int *)b, b += 4; } while (w1 == w2 && !word_has_nullbyte(w1)); + /* sbrodie added note: it gets away with these implementation-defined right + * shifts only because of the masking with 0xff. + */ for (;;) { char c1 = (w1 >> 24) & 0xff, c2 = (w2 >> 24) & 0xff; int d = c1 - c2; diff --git a/clib/s/cl_body b/clib/s/cl_body index a8fc54b..5a0f957 100644 --- a/clib/s/cl_body +++ b/clib/s/cl_body @@ -22,7 +22,6 @@ ; GET s.h_Stack - GET rlib.s.asmdefs GET Hdr:Wimp GET Hdr:TaskWindow diff --git a/rlib/c/res b/rlib/c/res index f65d979..baf4564 100644 --- a/rlib/c/res +++ b/rlib/c/res @@ -72,8 +72,10 @@ BOOL res_findname(const char *leafname, char *buf /*out*/) str.action = 5; str.name = buf; e = os_file(&str); - if (e && e->errnum == 0xCC) { - /* File name 'contents of buf' not recognised - could be illegal path */ + if (e && e->errnum == 0xCC || !e && str.action == 0) { + /* File name 'contents of buf' not recognised - could be illegal path, + * or file not found, so try using $Dir instead. + */ sprintf(buf, "<%s$Dir>.%s", progname, leafname); } diff --git a/rlib/s/bastxt b/rlib/s/bastxt index efe017f..d09fd55 100644 --- a/rlib/s/bastxt +++ b/rlib/s/bastxt @@ -24,7 +24,6 @@ GBLL ModeMayBeNonUser ModeMayBeNonUser SETL {FALSE} - GET rlib.s.asmdefs GET s.h_Brazil AREA |C$$code|, CODE, READONLY diff --git a/rlib/s/defs b/rlib/s/defs deleted file mode 100644 index 2c23dd2..0000000 --- a/rlib/s/defs +++ /dev/null @@ -1,18 +0,0 @@ -; Copyright 1996 Acorn Computers Ltd -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; - GBLL UROM -UROM SETL {FALSE} - - END diff --git a/rlib/s/rom_defs b/rlib/s/rom_defs deleted file mode 100644 index 8558034..0000000 --- a/rlib/s/rom_defs +++ /dev/null @@ -1,18 +0,0 @@ -; Copyright 1996 Acorn Computers Ltd -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; - GBLL UROM -UROM SETL {TRUE} - - END diff --git a/rlib/s/swi b/rlib/s/swi index 3c6e663..bfbf5a4 100644 --- a/rlib/s/swi +++ b/rlib/s/swi @@ -52,8 +52,6 @@ XOS_MASK * &00020000 ; mask to make a swi a RISC OS V-error SWI ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; Register names - GET rlib.s.asmdefs - ;whether to avoid dynamic code for swi veneers GBLL StaticSWIVeneer StaticSWIVeneer SETL StrongARM :LAND: {TRUE} -- GitLab