Commit ea4c3631 authored by Luís Oliveira's avatar Luís Oliveira
Browse files

Handle the GNU strerror_r() API

Partially fixes gh issue #2.
parent 75143139
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -44,7 +44,14 @@
  (let ((errno (if (keywordp err)
                   (foreign-enum-value 'errno-values err)
                   err)))
    #-linux ; XSI-compliant strerror_r() always stores the error
            ; message in the user-supplied buffer.
    (with-foreign-pointer-as-string ((buf bufsiz) 1024)
      (strerror-r errno buf bufsiz))
    #+linux ; GNU strerror_r() doesn't always store the error message
            ; in the user-supplied buffer, but it returns a string
            ; instead of an int.
    (with-foreign-pointer (buf 1024 bufsiz)
      (strerror-r errno buf bufsiz))))

(defmethod print-object ((posix-error posix-error) stream)
+4 −1
Original line number Diff line number Diff line
@@ -157,8 +157,11 @@
  "errno = value;"
  "return errno;")

;; Note: since we define _GNU_SOURCE on Linux (to get at mremap()), we
;; get the GNU version of strerror_r() which doesn't always store the
;; result in `buf'.
#-windows
(defwrapper "strerror_r" :int
(defwrapper "strerror_r" #+linux :string #-linux :int
  (errnum :int)
  (buf :string)
  (buflen ("size_t" size)))