Portability fixes for Fortre C++ 5.0 (on Sun) in 32 and 64 bit modes.

This commit is contained in:
monty@butch. 2002-11-07 03:54:00 +02:00
commit a2bdf9265f
60 changed files with 486 additions and 425 deletions

View file

@ -24,11 +24,11 @@ if ASSEMBLER_x86
ASRCS = strings-x86.s longlong2str-x86.s
CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c strnlen.c
else
if ASSEMBLER_sparc
if ASSEMBLER_sparc32
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s strxmov-sparc.s
CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c strnlen.c
ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c strnlen.c strxmov.c
else
#no assembler
ASRCS =
@ -75,8 +75,11 @@ clean-local:
if ASSEMBLER
# On Linux gcc can compile the assembly files
%.o : %.s
$(AS) -o $@ $<
$(AS) $(ASFLAGS) -o $@ $<
endif
str_test: str_test.c $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN $(srcdir)/str_test.c $(LDADD) $(LIBS)
# Don't update the files from bitkeeper
%::SCCS/s.%

View file

@ -27,11 +27,11 @@ bmove_upp:
nop
.loop:
sub %o1, 1, %o1
ldub [%o1], %g2
ldub [%o1], %o3
sub %o0, 1, %o0
subcc %o2, 1, %o2
bcc .loop
stb %g2, [%o0]
stb %o3, [%o0]
.end:
retl
nop

View file

@ -130,9 +130,6 @@ int main(void)
if (errors)
fputs("--- Some functions doesn't work!! Fix them\n",stderr);
return(errors > 0);
fputs("Fatal error\n",stderr);
return(2);
} /* main */

View file

@ -22,28 +22,28 @@
.type strappend,#function
.proc 020
strappend:
add %o0, %o1, %g3 ! g3 = endpos
ldsb [%o0], %g2
add %o0, %o1, %o3 ! o3 = endpos
ldsb [%o0], %o4
.loop1:
add %o0, 1, %o0 ! find end of str
cmp %g2, 0
cmp %o4, 0
bne,a .loop1
ldsb [%o0], %g2
ldsb [%o0], %o4
sub %o0, 1, %o0
cmp %o0, %g3
cmp %o0, %o3
bgeu .end
nop
stb %o2, [%o0]
.loop2:
add %o0, 1, %o0
cmp %o0, %g3
cmp %o0, %o3
blu,a .loop2
stb %o2, [%o0]
.end:
retl
stb %g0, [%g3]
stb %g0, [%o3]
.strappend_end:
.size strappend,.strappend_end-strappend
.ident "Matt Wagner & Monty"

View file

@ -22,12 +22,12 @@
.type strend,#function
.proc 0102
strend:
ldsb [%o0], %g2 ! Handle first char differently to make
ldsb [%o0], %o3 ! Handle first char differently to make
.loop: ! a faster loop
add %o0, 1, %o0
cmp %g2, 0
cmp %o3, 0
bne,a .loop
ldsb [%o0], %g2
ldsb [%o0], %o3
retl
sub %o0,1,%o0
.strend_end:

View file

@ -25,16 +25,16 @@ strmake:
orcc %g0,%o2,%g0
be,a .end
nop
ldsb [%o1],%g2
ldsb [%o1],%o3
.loop:
stb %g2,[%o0]
cmp %g2,0
stb %o3,[%o0]
cmp %o3,0
be .end ! Jump to end on end of string
add %o1,1,%o1
add %o0,1,%o0
subcc %o2,1,%o2
bne,a .loop
ldsb [%o1],%g2
ldsb [%o1],%o3
.end:
retl
stb %g0,[%o0]

View file

@ -23,10 +23,10 @@
.proc 0102
strmov:
.loop:
ldub [%o1], %g2
stb %g2, [%o0]
ldub [%o1], %o3
stb %o3, [%o0]
add %o1, 1, %o1
cmp %g2, 0
cmp %o3, 0
bne,a .loop
add %o0, 1, %o0
retl

View file

@ -25,16 +25,16 @@ strnmov:
orcc %g0,%o2,%g0
be,a .end
nop
ldsb [%o1],%g2
ldsb [%o1],%o3
.loop:
stb %g2,[%o0]
cmp %g2,0
stb %o3,[%o0]
cmp %o3,0
be .end ! Jump to end on end of string
add %o1,1,%o1
add %o0,1,%o0
subcc %o2,1,%o2
bne,a .loop
ldsb [%o1],%g2
ldsb [%o1],%o3
.end:
retl
nop

View file

@ -33,10 +33,10 @@ strstr:
ldsb [%o1],%o2 ! o2= First char of search
.top:
ldsb [%o0],%g3 ! g3= First char of rest of str
cmp %g3,0
ldsb [%o0],%o4 ! o4= First char of rest of str
cmp %o4,0
be .abort ! Found end null ;
cmp %g3,%o2
cmp %o4,%o2
bne .top
add %o0,1,%o0
@ -45,20 +45,20 @@ strstr:
! while (*j)
! if (*i++ != *j++) goto skipp;
or %g0,%o0,%g2
add %o1,1,%g3 ! g3= search+1
or %g0,%o0,%o3
add %o1,1,%o4 ! o4= search+1
ldsb [%o0],%o5 ! o5= [current_str+1]
.loop2:
ldsb [%g3],%g4
add %g3,1,%g3
ldsb [%o4],%g4
add %o4,1,%o4
cmp %g4,0
be .end
cmp %o5,%g4
bne .top
add %g2,1,%g2
add %o3,1,%o3
ba .loop2
ldsb [%g2],%o5
ldsb [%o3],%o5
.end:
retl

View file

@ -15,12 +15,17 @@
! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
! MA 02111-1307, USA
!
! Note that this function only works on 32 bit sparc systems
! on 64 bits the offsets to %sp are different !
.file "strxmov-sparc.s"
.section ".text"
.align 4
.global strxmov
.type strxmov,#function
.proc 0102
strxmov:
st %o2, [%sp+76] ! store 3rd param before other params
st %o3, [%sp+80] ! store 4th param " "
@ -28,18 +33,18 @@ strxmov:
st %o4, [%sp+84] ! store 5th param
be .end
st %o5, [%sp+88] ! store last
add %sp, 76, %g2 ! put pointer to 3rd arg
add %sp, 76, %o4 ! put pointer to 3rd arg
.loop:
ldub [%o1], %g1 ! set values of src (o1)
ldub [%o1], %o5 ! set values of src (o1)
add %o1, 1, %o1 ! inc src
stb %g1, [%o0] ! and dst (o2) equal
cmp %g1, 0 ! second while cmp
stb %o5, [%o0] ! and dst (o2) equal
cmp %o5, 0 ! second while cmp
bne,a .loop
add %o0, 1, %o0 ! inc dst
ld [%g2], %o1 ! get next param
ld [%o4], %o1 ! get next param
cmp %o1, 0 ! check if last param
bne .loop
add %g2, 4, %g2 ! advance to next param
add %o4, 4, %o4 ! advance to next param
.end:
retl
stb %g0, [%o0]