From: Andy Wingo Date: Sat, 8 Feb 2014 13:55:16 +0000 (+0100) Subject: Merge commit 'b9b88351ea2c4b43a6f90938554dc5693b17e328' X-Git-Url: https://git.hcoop.net/bpt/guile.git/commitdiff_plain/c8b7b0dad33d6221682c5f49b7635d8de7e15bab?hp=12b8487d5d7272ae5bda62477df60d3e795aa645 Merge commit 'b9b88351ea2c4b43a6f90938554dc5693b17e328' Conflicts: libguile/deprecated.h test-suite/tests/00-socket.test --- diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index 9091d9fb7..6cd90bc6a 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -1,7 +1,7 @@ @c -*-texinfo-*- @c This is part of the GNU Guile Reference Manual. @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007, -@c 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. +@c 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. @c See the file guile.texi for copying conditions. @node POSIX @@ -3393,55 +3393,6 @@ file descriptor: any unflushed buffered port data is ignored. @end deffn -The following functions can be used to convert short and long integers -between ``host'' and ``network'' order. Although the procedures above do -this automatically for addresses, the conversion will still need to -be done when sending or receiving encoded integer data from the network. - -@deffn {Scheme Procedure} htons value -@deffnx {C Function} scm_htons (value) -Convert a 16 bit quantity from host to network byte ordering. -@var{value} is packed into 2 bytes, which are then converted -and returned as a new integer. -@end deffn - -@deffn {Scheme Procedure} ntohs value -@deffnx {C Function} scm_ntohs (value) -Convert a 16 bit quantity from network to host byte ordering. -@var{value} is packed into 2 bytes, which are then converted -and returned as a new integer. -@end deffn - -@deffn {Scheme Procedure} htonl value -@deffnx {C Function} scm_htonl (value) -Convert a 32 bit quantity from host to network byte ordering. -@var{value} is packed into 4 bytes, which are then converted -and returned as a new integer. -@end deffn - -@deffn {Scheme Procedure} ntohl value -@deffnx {C Function} scm_ntohl (value) -Convert a 32 bit quantity from network to host byte ordering. -@var{value} is packed into 4 bytes, which are then converted -and returned as a new integer. -@end deffn - -These procedures are inconvenient to use at present, but consider: - -@example -(define write-network-long - (lambda (value port) - (let ((v (make-uniform-vector 1 1 0))) - (uniform-vector-set! v 0 (htonl value)) - (uniform-vector-write v port)))) - -(define read-network-long - (lambda (port) - (let ((v (make-uniform-vector 1 1 0))) - (uniform-vector-read! v port) - (ntohl (uniform-vector-ref v 0))))) -@end example - @node Internet Socket Examples @subsubsection Network Socket Examples diff --git a/libguile/socket.c b/libguile/socket.c index 8c1326a54..0516e5267 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -1,5 +1,5 @@ /* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, - * 2006, 2007, 2009, 2011, 2012, 2013 Free Software Foundation, Inc. + * 2006, 2007, 2009, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -92,50 +92,6 @@ typedef union -SCM_DEFINE (scm_htons, "htons", 1, 0, 0, - (SCM value), - "Convert a 16 bit quantity from host to network byte ordering.\n" - "@var{value} is packed into 2 bytes, which are then converted\n" - "and returned as a new integer.") -#define FUNC_NAME s_scm_htons -{ - return scm_from_ushort (htons (scm_to_ushort (value))); -} -#undef FUNC_NAME - -SCM_DEFINE (scm_ntohs, "ntohs", 1, 0, 0, - (SCM value), - "Convert a 16 bit quantity from network to host byte ordering.\n" - "@var{value} is packed into 2 bytes, which are then converted\n" - "and returned as a new integer.") -#define FUNC_NAME s_scm_ntohs -{ - return scm_from_ushort (ntohs (scm_to_ushort (value))); -} -#undef FUNC_NAME - -SCM_DEFINE (scm_htonl, "htonl", 1, 0, 0, - (SCM value), - "Convert a 32 bit quantity from host to network byte ordering.\n" - "@var{value} is packed into 4 bytes, which are then converted\n" - "and returned as a new integer.") -#define FUNC_NAME s_scm_htonl -{ - return scm_from_ulong (htonl (scm_to_uint32 (value))); -} -#undef FUNC_NAME - -SCM_DEFINE (scm_ntohl, "ntohl", 1, 0, 0, - (SCM value), - "Convert a 32 bit quantity from network to host byte ordering.\n" - "@var{value} is packed into 4 bytes, which are then converted\n" - "and returned as a new integer.") -#define FUNC_NAME s_scm_ntohl -{ - return scm_from_ulong (ntohl (scm_to_uint32 (value))); -} -#undef FUNC_NAME - #ifdef HAVE_INET_NETOF SCM_DEFINE (scm_inet_netof, "inet-netof", 1, 0, 0, (SCM address), diff --git a/libguile/socket.h b/libguile/socket.h index fcddd780d..a211867c6 100644 --- a/libguile/socket.h +++ b/libguile/socket.h @@ -3,7 +3,7 @@ #ifndef SCM_SOCKET_H #define SCM_SOCKET_H -/* Copyright (C) 1995,1996,1997,2000,2001, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,2000,2001, 2004, 2005, 2006, 2008, 2014 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -27,10 +27,6 @@ -SCM_API SCM scm_htons (SCM in); -SCM_API SCM scm_ntohs (SCM in); -SCM_API SCM scm_htonl (SCM in); -SCM_API SCM scm_ntohl (SCM in); SCM_API SCM scm_inet_aton (SCM address); SCM_API SCM scm_inet_ntoa (SCM inetid); SCM_API SCM scm_inet_netof (SCM address); diff --git a/test-suite/tests/00-socket.test b/test-suite/tests/00-socket.test index 30a02570c..211aaaf20 100644 --- a/test-suite/tests/00-socket.test +++ b/test-suite/tests/00-socket.test @@ -1,7 +1,7 @@ ;;;; 00-socket.test --- test socket functions -*- scheme -*- ;;;; ;;;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, -;;;; 2011, 2012, 2013 Free Software Foundation, Inc. +;;;; 2011, 2012, 2013, 2014 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -27,27 +27,6 @@ -;;; -;;; htonl -;;; - -(if (defined? 'htonl) - (with-test-prefix "htonl" - - (pass-if "0" (eqv? 0 (htonl 0))) - - (pass-if-exception "-1" exception:out-of-range - (htonl -1)) - - ;; prior to guile 1.6.9 and 1.8.1, systems with 64-bit longs didn't detect - ;; an overflow for values 2^32 <= x < 2^63 - (pass-if-exception "2^32" exception:out-of-range - (htonl (ash 1 32))) - - (pass-if-exception "2^1024" exception:out-of-range - (htonl (ash 1 1024))))) - - ;;; ;;; inet-ntop ;;; @@ -154,27 +133,6 @@ (and (= (sockaddr:fam sa) AF_UNIX) (string=? (sockaddr:path sa) "/tmp/unix-socket")))))) -;;; -;;; ntohl -;;; - -(if (defined? 'ntohl) - (with-test-prefix "ntohl" - - (pass-if "0" (eqv? 0 (ntohl 0))) - - (pass-if-exception "-1" exception:out-of-range - (ntohl -1)) - - ;; prior to guile 1.6.9 and 1.8.1, systems with 64-bit longs didn't detect - ;; an overflow for values 2^32 <= x < 2^63 - (pass-if-exception "2^32" exception:out-of-range - (ntohl (ash 1 32))) - - (pass-if-exception "2^1024" exception:out-of-range - (ntohl (ash 1 1024))))) - - ;;; ;;; AF_UNIX sockets and `make-socket-address'