1.3.1
[hunchentoot.git] / compat.lisp
blob278086669f49902b26dc3f9e894da88caefb97f8
1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: HUNCHENTOOT; Base: 10 -*-
3 ;;; Copyright (c) 2004-2010, Dr. Edmund Weitz. All rights reserved.
5 ;;; Redistribution and use in source and binary forms, with or without
6 ;;; modification, are permitted provided that the following conditions
7 ;;; are met:
9 ;;; * Redistributions of source code must retain the above copyright
10 ;;; notice, this list of conditions and the following disclaimer.
12 ;;; * Redistributions in binary form must reproduce the above
13 ;;; copyright notice, this list of conditions and the following
14 ;;; disclaimer in the documentation and/or other materials
15 ;;; provided with the distribution.
17 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
18 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 (in-package :hunchentoot)
31 (defun get-peer-address-and-port (socket)
32 "Returns the peer address and port of the socket SOCKET as two
33 values. The address is returned as a string in dotted IP address
34 notation, resp. IPv6 notation."
35 (multiple-value-bind (address port) (usocket:get-peer-name socket)
36 (values (usocket:host-to-hostname address)
37 port)))
39 (defun get-local-address-and-port (socket)
40 "Returns the local address and port of the socket SOCKET as two
41 values. The address is returned as a string in dotted IP address
42 notation, resp. IPv6 notation."
43 (multiple-value-bind (address port) (usocket:get-local-name socket)
44 (values (usocket:host-to-hostname address)
45 port)))
47 (defun make-socket-stream (socket acceptor)
48 "Returns a stream for the socket SOCKET. The ACCEPTOR argument is
49 ignored."
50 (declare (ignore acceptor))
51 (usocket:socket-stream socket))
53 (defun make-lock (name)
54 "Simple wrapper to allow LispWorks and Bordeaux Threads to coexist."
55 (bt:make-lock name))
57 (defmacro with-lock-held ((lock) &body body)
58 "Simple wrapper to allow LispWorks and Bordeaux Threads to coexist."
59 `(bt:with-lock-held (,lock) ,@body))
61 (defun make-condition-variable (&key name)
62 (declare (ignore name))
63 (bt:make-condition-variable))
65 (defun condition-variable-signal (condition-variable)
66 (bt:condition-notify condition-variable))
68 (defun condition-variable-wait (condition-variable lock)
69 (bt:condition-wait condition-variable lock))