Commit 9d5bf66a authored by Stewart Brodie's avatar Stewart Brodie
Browse files

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'
parent 8b79f20e
......@@ -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
......
......@@ -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
/* (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)"
......@@ -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;
......
......@@ -22,7 +22,6 @@
;
GET s.h_Stack
GET rlib.s.asmdefs
GET Hdr:Wimp
GET Hdr:TaskWindow
......
......@@ -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);
}
......
......@@ -24,7 +24,6 @@
GBLL ModeMayBeNonUser
ModeMayBeNonUser SETL {FALSE}
GET rlib.s.asmdefs
GET s.h_Brazil
AREA |C$$code|, CODE, READONLY
......
; 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
; 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
......@@ -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}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment