[PATCH] Sparc fixes
Jakub Jelinek
jakub@redhat.com
Wed Apr 5 13:41:00 GMT 2000
Hi!
Below are a few fixes for sparc and sparc64.
First, inet_ntop implementation does not match the prototype.
There was a include header loop in setjmp.h, solved by declaring the
__jmp_buf structure without any reference to ucontext.
And SPARC dl-machine.h's are updated for the new init function interface.
sparc64 build is still in progress, but the compiled ld.so seem to run my
64bit binaries just fine, I have not tested sparc32 build yet, but the code
is very similar to sparc64.
2000-04-05 Jakub Jelinek <jakub@redhat.com>
* resolv/inet_ntop.c (inet_ntop4, inet_ntop6, inet_ntop): Use
socklen_t type for size.
* sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Rewrite for new
init function interface.
* sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/setjmp.h: Don't include
sys/ucontext.h.
(__jmp_buf): Declare the whole type structure here, don't use
ucontext.
--- libc/resolv/inet_ntop.c.jj Sun Oct 3 02:04:43 1999
+++ libc/resolv/inet_ntop.c Wed Apr 5 15:38:32 2000
@@ -40,9 +40,9 @@ static char rcsid[] = "$Id: inet_ntop.c,
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
-static const char *inet_ntop4 __P((const u_char *src, char *dst, size_t size))
+static const char *inet_ntop4 __P((const u_char *src, char *dst, socklen_t size))
internal_function;
-static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size))
+static const char *inet_ntop6 __P((const u_char *src, char *dst, socklen_t size))
internal_function;
/* char *
@@ -58,7 +58,7 @@ inet_ntop(af, src, dst, size)
int af;
const void *src;
char *dst;
- size_t size;
+ socklen_t size;
{
switch (af) {
case AF_INET:
@@ -88,7 +88,7 @@ internal_function
inet_ntop4(src, dst, size)
const u_char *src;
char *dst;
- size_t size;
+ socklen_t size;
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
@@ -111,7 +111,7 @@ internal_function
inet_ntop6(src, dst, size)
const u_char *src;
char *dst;
- size_t size;
+ socklen_t size;
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
@@ -189,7 +189,7 @@ inet_ntop6(src, dst, size)
/*
* Check for overflow, copy, and we're done.
*/
- if ((size_t)(tp - tmp) > size) {
+ if ((socklen_t)(tp - tmp) > size) {
__set_errno (ENOSPC);
return (NULL);
}
--- libc/sysdeps/sparc/sparc32/dl-machine.h.jj Tue Apr 4 11:56:31 2000
+++ libc/sysdeps/sparc/sparc32/dl-machine.h Wed Apr 5 22:14:17 2000
@@ -234,12 +234,11 @@ _dl_start_user:
ld [%i0], %i0
tst %i0
beq 3f
- nop
+ ld [%sp+22*4], %i5 /* load argc */
/* Find out how far to shift. */
- ld [%sp+22*4], %i1 /* load argc */
- sub %i1, %i0, %i1
+ sub %i5, %i0, %i5
sll %i0, 2, %i2
- st %i1, [%sp+22*4]
+ st %i5, [%sp+22*4]
add %sp, 23*4, %i1
add %i1, %i2, %i2
/* Copy down argv */
@@ -265,24 +264,17 @@ _dl_start_user:
st %i4, [%i1+4]
bne 23b
add %i1, 8, %i1
- /* Load searchlist of the main object to pass to _dl_init_next. */
-3: sethi %hi(_dl_main_searchlist), %g1
- or %g1, %lo(_dl_main_searchlist), %g1
- ld [%l7+%g1], %l1
- ld [%l1], %l1
- /* Call _dl_init_next to return the address of an initializer to run. */
-4: call _dl_init_next
- mov %l1, %o0
- tst %o0
- beq 5f
- nop
- jmpl %o0, %o7
- sub %o7, 28, %o7
- /* Clear the startup flag. */
-5: sethi %hi(_dl_starting_up), %g1
- or %g1, %lo(_dl_starting_up), %g1
- ld [%l7+%g1], %g1
- st %g0, [%g1]
+ /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */
+3: sethi %hi(_dl_loaded), %o0
+ add %sp, 23*4, %o2
+ orcc %o0, %lo(_dl_loaded), %o0
+ sll %i5, 2, %o3
+ ld [%l7+%o0], %o0
+ add %o3, 4, %o3
+ mov %i5, %o1
+ add %o2, %o3, %o3
+ call _dl_init
+ ld [%o0], %o0
/* Pass our finalizer function to the user in %g1. */
sethi %hi(_dl_fini), %g1
or %g1, %lo(_dl_fini), %g1
--- libc/sysdeps/sparc/sparc64/dl-machine.h.jj Tue Apr 4 11:56:31 2000
+++ libc/sysdeps/sparc/sparc64/dl-machine.h Wed Apr 5 22:14:17 2000
@@ -540,12 +540,11 @@ _dl_start_user:
ldx [%l7+%g5], %i0
ld [%i0], %i0
brz,pt %i0, 2f
- nop
+ ldx [%sp+" __S(STACK_BIAS) "+22*8], %i5
/* Find out how far to shift. */
- ldx [%sp+" __S(STACK_BIAS) "+22*8], %i1
- sub %i1, %i0, %i1
+ sub %i5, %i0, %i5
sllx %i0, 3, %i2
- stx %i1, [%sp+" __S(STACK_BIAS) "+22*8]
+ stx %i5, [%sp+" __S(STACK_BIAS) "+22*8]
add %sp, " __S(STACK_BIAS) "+23*8, %i1
add %i1, %i2, %i2
/* Copy down argv. */
@@ -568,23 +567,17 @@ _dl_start_user:
stx %i4, [%i1+8]
brnz,pt %i3, 13b
add %i1, 16, %i1
- /* Load searchlist of the main object to pass to _dl_init_next. */
-2: sethi %hi(_dl_main_searchlist), %g5
- or %g5, %lo(_dl_main_searchlist), %g5
- ldx [%l7+%g5], %g5
- ldx [%g5], %l1
- /* Call _dl_init_next to return the address of an initializer to run. */
-3: call _dl_init_next
- mov %l1, %o0
- brz,pn %o0, 4f
- nop
- jmpl %o0, %o7
- sub %o7, 24, %o7
- /* Clear the startup flag. */
-4: sethi %hi(_dl_starting_up), %g5
- or %g5, %lo(_dl_starting_up), %g5
- ldx [%l7+%g5], %g5
- st %g0, [%g5]
+ /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */
+2: sethi %hi(_dl_loaded), %o0
+ add %sp, " __S(STACK_BIAS) "+23*8, %o2
+ orcc %o0, %lo(_dl_loaded), %o0
+ sllx %i5, 3, %o3
+ ldx [%l7+%o0], %o0
+ add %o3, 8, %o3
+ mov %i5, %o1
+ add %o2, %o3, %o3
+ call _dl_init
+ ldx [%o0], %o0
/* Pass our finalizer function to the user in %g1. */
sethi %hi(_dl_fini), %g1
or %g1, %lo(_dl_fini), %g1
--- libc/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h.jj Tue May 25 13:52:02 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h Wed Mar 29 17:36:18 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997,1999 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1999,2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,9 +25,35 @@
#if __WORDSIZE == 64
-#include <sys/ucontext.h>
-
-typedef ucontext_t __jmp_buf[1];
+#ifndef _ASM
+typedef struct __sparc64_jmp_buf
+ {
+ struct __sparc64_jmp_buf *uc_link;
+ unsigned long uc_flags;
+ unsigned long uc_sigmask;
+ struct __sparc64_jmp_buf_mcontext
+ {
+ unsigned long mc_gregs[19];
+ unsigned long mc_fp;
+ unsigned long mc_i7;
+ struct __sparc64_jmp_buf_fpu
+ {
+ union
+ {
+ unsigned int sregs[32];
+ unsigned long dregs[32];
+ long double qregs[16];
+ } mcfpu_fpregs;
+ unsigned long mcfpu_fprs;
+ unsigned long mcfpu_gsr;
+ void *mcfpu_fq;
+ unsigned char mcfpu_qcnt;
+ unsigned char mcfpu_qentsz;
+ unsigned char mcfpu_enab;
+ } mc_fpregs;
+ } uc_mcontext;
+ } __jmp_buf[1];
+#endif
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
Jakub
More information about the Libc-hacker
mailing list