File: gnu-hurd-getExecutablePath

package info (click to toggle)
ghc 9.10.3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 169,260 kB
  • sloc: haskell: 713,564; ansic: 84,184; cpp: 30,255; javascript: 9,003; sh: 7,870; fortran: 3,527; python: 3,228; asm: 2,523; makefile: 2,329; yacc: 1,570; lisp: 532; xml: 196; perl: 111; csh: 2
file content (35 lines) | stat: -rw-r--r-- 1,546 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 3939a8bf93e27d8151aa1d92bf3ce10bbbc96a72 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Sun, 15 Sep 2024 15:57:52 +0200
Subject: [PATCH] GNU/Hurd: Add getExecutablePath support

GNU/Hurd exposes it as /proc/self/exe just like on Linux.
---
 .../src/GHC/Internal/System/Environment/ExecutablePath.hsc  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: b/libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
===================================================================
--- a/libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
+++ b/libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
@@ -200,9 +200,9 @@ executablePath = Just (fmap Just getExec
       | otherwise             = throw e
 
 --------------------------------------------------------------------------------
--- Linux / Solaris
+-- Linux / Solaris / Hurd
 
-#elif defined(linux_HOST_OS) || defined(solaris2_HOST_OS)
+#elif defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(gnu_HOST_OS)
 
 foreign import ccall unsafe "readlink"
     c_readlink :: CString -> CString -> CSize -> IO CInt
@@ -219,7 +219,7 @@ readSymbolicLink file =
                    c_readlink s buf 4096
             peekFilePathLen (buf,fromIntegral len)
 
-#  if defined(linux_HOST_OS)
+#  if defined(linux_HOST_OS) || defined(gnu_HOST_OS)
 getExecutablePath = readSymbolicLink $ "/proc/self/exe"
 
 executablePath = Just (check <$> getExecutablePath) where