1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-15 16:20:17 +02:00

Changes from arch/CVS synchronization

This commit is contained in:
Ludovic Courtès 2007-06-12 21:55:11 +00:00
parent a1ef740636
commit 7a5fb79613
4 changed files with 46 additions and 7 deletions

View file

@ -1,3 +1,9 @@
2007-06-12 Ludovic Courtès <ludo@chbouib.org>
* socket.c (scm_inet_ntop): In the `AF_INET' case, declare `addr4'
as an `scm_t_uint32' rather than re-using `addr6'. This fixes a
bus error on SPARC (and possibly others) due to unaligned access.
2007-06-07 Ludovic Courtès <ludovic.courtes@laas.fr> 2007-06-07 Ludovic Courtès <ludovic.courtes@laas.fr>
* posix.c (scm_ttyname): Check whether RESULT is NULL before * posix.c (scm_ttyname): Check whether RESULT is NULL before

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. /* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -386,16 +386,28 @@ SCM_DEFINE (scm_inet_ntop, "inet-ntop", 2, 0, 0,
#else #else
char dst[46]; char dst[46];
#endif #endif
char addr6[16]; const char *result;
af = scm_to_int (family); af = scm_to_int (family);
SCM_ASSERT_RANGE (1, family, af == AF_INET || af == AF_INET6); SCM_ASSERT_RANGE (1, family, af == AF_INET || af == AF_INET6);
if (af == AF_INET) if (af == AF_INET)
*(scm_t_uint32 *) addr6 = htonl (SCM_NUM2ULONG (2, address)); {
scm_t_uint32 addr4;
addr4 = htonl (SCM_NUM2ULONG (2, address));
result = inet_ntop (af, &addr4, dst, sizeof (dst));
}
else else
scm_to_ipv6 ((scm_t_uint8 *) addr6, address); {
if (inet_ntop (af, &addr6, dst, sizeof dst) == NULL) char addr6[16];
scm_to_ipv6 ((scm_t_uint8 *) addr6, address);
result = inet_ntop (af, &addr6, dst, sizeof (dst));
}
if (result == NULL)
SCM_SYSERROR; SCM_SYSERROR;
return scm_from_locale_string (dst); return scm_from_locale_string (dst);
} }
#undef FUNC_NAME #undef FUNC_NAME

View file

@ -1,3 +1,8 @@
2007-06-12 Ludovic Courtès <ludo@chbouib.org>
* tests/socket.test: Renamed module to `(test-suite test-socket)'.
(inet-ntop): New test prefix.
2007-06-07 Ludovic Courtès <ludovic.courtes@laas.fr> 2007-06-07 Ludovic Courtès <ludovic.courtes@laas.fr>
* lib.scm (exception:system-error): New variable. * lib.scm (exception:system-error): New variable.

View file

@ -1,6 +1,6 @@
;;;; socket.test --- test socket functions -*- scheme -*- ;;;; socket.test --- test socket functions -*- scheme -*-
;;;; ;;;;
;;;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. ;;;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;;;; ;;;;
;;;; This library is free software; you can redistribute it and/or ;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public ;;;; modify it under the terms of the GNU Lesser General Public
@ -16,7 +16,7 @@
;;;; License along with this library; if not, write to the Free Software ;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-suite test-numbers) (define-module (test-suite test-socket)
#:use-module (test-suite lib)) #:use-module (test-suite lib))
@ -101,6 +101,22 @@
(inet-pton AF_INET6 (inet-pton AF_INET6
"0000:0000:0000:0000:0000:0000:0000:00F0")))))) "0000:0000:0000:0000:0000:0000:0000:00F0"))))))
(if (defined? 'inet-ntop)
(with-test-prefix "inet-ntop"
(with-test-prefix "ipv4"
(pass-if "127.0.0.1"
(equal? "127.0.0.1" (inet-ntop AF_INET INADDR_LOOPBACK))))
(if (defined? 'AF_INET6)
(with-test-prefix "ipv6"
(pass-if "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"
(string-ci=? "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"
(inet-ntop AF_INET6 (- (expt 2 128) 1))))
(pass-if "::1"
(equal? "::1" (inet-ntop AF_INET6 1)))))))
;;; ;;;
;;; make-socket-address ;;; make-socket-address