summaryrefslogtreecommitdiff
path: root/libraries/base/System
Commit message (Collapse)AuthorAgeFilesLines
* Rename SomeExceptionWithLocation to SomeExceptionWithBacktraceSven Tennie2022-02-112-2/+2
|
* Replace SomeException with SomeExceptionWithLocation (#18159)Sven Tennie2022-02-112-2/+2
| | | | | To keep backwards compatibility, for older GHC versions SomeExceptionWithLocation is only a synonym for SomeException.
* Implement System.Environment.getExecutablePath for NetBSDPHO2022-02-091-4/+12
| | | | and also use it from GHC.BaseDir.getBaseDir
* Add the Ix class to Foreign C integral typesHécate Moonlight2022-02-041-1/+2
| | | | Related CLC proposal is here: https://github.com/haskell/core-libraries-committee/issues/30
* Fix a few Note inconsistenciesBen Gamari2022-02-011-1/+0
|
* base: Add CTYPE pragmas to all foreign typesBen Gamari2022-01-191-24/+24
| | | | | | | Fixes #15531 by ensuring that we know the corresponding C type for all marshalling wrappers. Closes #15531.
* winio: fix heap corruption and various leaks.Tamar Christina2022-01-151-12/+12
|
* base: fix clockid_t usage when it's a pointer type in CCheng Shao2021-12-141-4/+5
| | | | Closes #20607.
* Hadrian: fix windows cross-build (#20657)Sylvain Henry2021-11-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many small things to fix: * Hadrian: platform triple is "x86_64-w64-mingw32" and this wasn't recognized by Hadrian (note "w64" instead of "unknown") * Hadrian was using the build platform ("isWindowsHost") to detect the use of the Windows toolchain, which was wrong. We now use the "targetOs" setting. * Hadrian was doing the same thing for Darwin so we fixed both at once, even if cross-compilation to Darwin is unlikely to happen afaik (cf "osxHost" vs "osxTarget" changes) * Hadrian: libffi name was computed in two different places and one of them wasn't taking the different naming on Windows into account. * Hadrian was passing "-Irts/include" when building the stage1 compiler leading to the same error as in #18143 (which is using make). stage1's RTS is stage0's one so mustn't do this. * Hadrian: Windows linker doesn't seem to support "-zorigin" so we don't pass it (similarly to Darwin) * Hadrian: hsc2hs in cross-compilation mode uses a trick (taken from autoconf): it defines "static int test_array[SOME_EXPR]" where SOME_EXPR is a constant expression. However GCC reports an error because SOME_EXPR is supposedly not constant. This is fixed by using another method enabled with the `--via-asm` flag of hsc2hs. It has been fixed in `make` build system (5f6fcf7808b16d066ad0fb2068225b3f2e8363f7) but not in Hadrian. * Hadrian: some packages are specifically built only on Windows but they shouldn't be when building a cross-compiler (`touchy` and `ghci-wrapper`). We now correctly detect this case and disable these packages. * Base: we use `iNVALID_HANDLE_VALUE` in a few places. It fixed some hsc2hs issues before we switched to `--via-asm` (see above). I've kept these changes are they make the code nicer. * Base: `base`'s configure tries to detect if it is building for Windows but for some reason the `$host_alias` value is `x86_64-windows` in my case and it wasn't properly detected. * Base: libraries/base/include/winio_structs.h imported "Windows.h" with a leading uppercase. It doesn't work on case-sensitive systems when cross-compiling so we have to use "windows.h". * RTS: rts/win32/ThrIOManager.c was importin "rts\OSThreads.h" but this path isn't valid when cross-compiling. We replaced "\" with "/". * DeriveConstants: this tool derives the constants from the target RTS header files. However these header files define `StgAsyncIOResult` only when `mingw32_HOST_OS` is set hence it seems we have to set it explicitly. Note that deriveConstants is called more than once (why? there is only one target for now so it shouldn't) and in the second case this value is correctly defined (probably coming indirectly from the import of "rts/PosixSource.h"). A better fix would probably be to disable the unneeded first run of deriveconstants.
* Fix spellingSylvain Henry2021-08-021-1/+1
|
* Improve documentation of openTempFile argsJulian Ospald2021-08-021-1/+3
| | | | | | | | | | https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamew Specifically: > The null-terminated prefix string. The function uses up to the first > three characters of this string as the prefix of the file name. This > string must consist of characters in the OEM-defined character set.
* Implement improved "get executable path" queryFraser Tweedale2021-07-062-2/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | System.Environment.getExecutablePath has some problems: - Some system-specific implementations throw an exception in some scenarios, e.g. when the executable file has been deleted - The Linux implementation succeeds but returns an invalid FilePath when the file has been deleted. - The fallback implementation returns argv[0] which is not necessarily an absolute path, and is subject to manipulation. - The documentation does not explain any of this. Breaking the getExecutablePath API or changing its behaviour is not an appealing direction. So we will provide a new API. There are two facets to the problem of querying the executable path: 1. Does the platform provide a reliable way to do it? This is statically known. 2. If so, is there a valid answer, and what is it? This may vary, even over the runtime of a single process. Accordingly, the type of the new mechanism is: Maybe (IO (Maybe FilePath)) This commit implements this mechanism, defining the query action for FreeBSD, Linux, macOS and Windows. Fixes: #10957 Fixes: #12377
* Correct haddock annotations in GetOptDavid2021-06-191-3/+3
|
* Make openFile exception safeDavid Feuer2021-02-222-18/+69
| | | | | | | | | | | | | | | | | | | * `openFile` could sometimes leak file descriptors if it received an asynchronous exception (#19114, #19115). Fix this on POSIX. * `openFile` and more importantly `openFileBlocking` could not be interrupted effectively during the `open` system call (#17912). Fix this on POSIX. * Implement `readFile'` using `withFile` to ensure the file is closed promptly on exception. * Avoid `bracket` in `withFile`, reducing the duration of masking. Closes #19130. Addresses #17912, #19114, and #19115 on POSIX systems, but not on Windows.
* Correct documentation in System.Mem.WeakCheng Shao2021-01-191-17/+11
| | | | | | [ci skip] Since #13167 is closed, exceptions thrown in finalizers are ignored and doesn't affect other finalizers in the same batch. This MR updates the documentation in System.Mem.Weak to reflect that.
* Correct doctestsOleg Grenrus2021-01-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's simpler to assume that base is NoImplicitPrelude, otherwise running doctest on `GHC.*` modules would be tricky. OTOH, most `GHC.List` (where the most name clashes are) examples could be changed to use `import qualified Data.List as L`. (GHC.List examples won't show for Foldable methods...). With these changes majority of doctest examples are GHCi-"faithful", my WIP GHC-independent doctest runner reports nice summary: Examples: 582; Tried: 546; Skipped: 34; Success: 515; Errors: 33; Property Failures 2 Most error cases are *Hangs forever*. I have yet to figure out how to demonstrate that in GHCi. Some of divergences are actually stack overflows, i.e. caught by runtime. Few errorful cases are examples of infinite output, e.g. >>> cycle [42] [42,42,42,42,42,42,42,42,42,42... while correct, they confuse doctest. Another erroneous cases are where expected output has line comment, like >>> fmap show (Just 1) -- (a -> b) -> f a -> f b Just "1" -- (Int -> String) -> Maybe Int -> Maybe String I think I just have to teach doctest to strip comments from expected output. This is a first patch in a series. There is plenty of stuff already.
* Add linting of `base` to the CIHécate2020-10-091-1/+1
|
* Remove redundant "do", "return" and language extensions from baseHécate2020-09-232-10/+8
|
* Remove all the unnecessary LANGUAGE pragmasHécate2020-08-052-4/+1
|
* Implement `fullCompilerVersion`Hécate2020-07-181-10/+26
| | | | | | | | Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype.
* winio: Rename SmartHandles to StdHandlesAndreas Klebinger2020-07-151-1/+1
|
* winio: Implement new tempfile routines for winioTamar Christina2020-07-151-5/+39
|
* winio: Multiple refactorings and support changes.Tamar Christina2020-07-151-1/+1
|
* winio: Refactor Buffer structures to be able to track async operationsTamar Christina2020-07-151-4/+5
|
* Add most common return values for `os` and `arch`Hécate2020-07-011-1/+44
|
* Fix #12073: Add MonadFix Q instanceOleg Grenrus2020-06-131-1/+4
|
* Fix the changelog/@since information for hGetContents'/getContents'/readFile'Ryan Scott2020-04-011-2/+2
| | | | | | Fixes #17979. [ci skip]
* base: add strict IO functions: readFile', getContents', hGetContents'Lysxia2020-03-161-0/+21
|
* base: Make `open` calls interruptibleBen Gamari2020-03-141-1/+3
| | | | | | | As noted in #17912, `open` system calls were `safe` rather than `interruptible`. Consequently, the program could not be interrupted with SIGINT if stuck in a slow open operation. Fix this by marking `c_safe_open` as interruptible.
* base: use an explicit import list in System.Environment.ExecutablePathAlp Mestanogullari2020-02-281-1/+1
| | | | This was making -Werror builds fail on Windows (at least with Hadrian).
* Fix more typos, via an improved Levenshtein-style correctorBrian Wignall2020-01-121-1/+1
|
* Fix typos, via a Levenshtein-style correctorBrian Wignall2020-01-041-1/+1
|
* Fix typos, using Wikipedia list of common typosBrian Wignall2019-11-281-1/+1
|
* Fix @since annotations for isResourceVanishedError and friends (#17488)Ryan Scott2019-11-271-3/+3
|
* On FreeBSD 12 sys/sysctl.h requires sys/types.hViktor Dukhovni2019-11-241-0/+1
| | | | | | | | | | | | | | Else build fails with: In file included from ExecutablePath.hsc:42: /usr/include/sys/sysctl.h:1062:25: error: unknown type name 'u_int'; did you mean 'int'? int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); ^~~~~ int compiling libraries/base/dist-install/build/System/Environment/ExecutablePath_hsc_make.c failed (exit code 1) Perhaps also also other FreeBSD releases, but additional include will no harm even if not needed.
* base: add newtypes for socklen_t and ndfs_t to System.Posix.Types #16568Adam Sandberg Eriksson2019-09-231-0/+15
| | | | | | Metric Increase: haddock.base T4029
* Add predicates for testing if IOError is ResourceVanished.Andrew Martin2019-09-131-0/+26
| | | | | This adds isResourceVanished, resourceVanishedErrorType, and isResourceVanishedErrorType to System.IO.Error, resolving #14730.
* Expunge #ifdef and #ifndef from the codebaseJohn Ericson2019-07-141-3/+3
| | | | | | | | These are unexploded minds as far as the linter is concerned. I don't want to hit in my MRs by mistake! I did this with `sed`, and then rolled back some changes in the docs, config.guess, and the linter itself.
* getExecutablePath: get path from sysctl on FreeBSDFraser Tweedale2019-06-271-0/+47
|
* Typeset Big-O complexities with Tex-style notation (#16090)Sven Tennie2019-04-171-2/+2
| | | | E.g. use `\(\mathcal{O}(n^2)\)` instead of `/O(n^2)/`.
* base: Better document implementation implications of Data.TimeoutBen Gamari2019-04-131-16/+25
| | | | | | | | | | As noted in #16546 timeout uses asynchronous exceptions internally, an implementation detail which can leak out in surprising ways. Note this fact. Also expose the `Timeout` tycon. [skip ci]
* base: Remove `Monad(fail)` method and reexport `MonadFail(fail)` insteadHerbert Valerio Riedel2019-03-221-2/+2
| | | | | | As per https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail Coauthored-by: Ben Gamari <ben@well-typed.com>
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-152-2/+2
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Properly escape character literals in HaddocksAlec Theriault2019-02-151-5/+5
| | | | | | | | Character literals in Haddock should not be written as plain `'\n'` since single quotes are for linking identifiers. Besides, since we want the character literal to be monospaced, we really should use `@\'\\n\'@`. [skip ci]
* Remove OPTIONS_HADDOCK hide in favour for not-homeAdam Sandberg Eriksson2019-01-061-1/+1
| | | | GHC Trac Issues: #15447
* Fix ambiguous/out-of-scope Haddock identifiersAlec Theriault2018-08-212-5/+6
| | | | | | | | | | | | | | | | | This drastically cuts down on the number of Haddock warnings when making docs for `base`. Plus this means more actual links end up in the docs! Also fixed other small mostly markup issues in the documentation along the way. This is a docs-only change. Reviewers: hvr, bgamari, thomie Reviewed By: thomie Subscribers: thomie, rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5055
* Expose the StableName constructorDavid Feuer2018-08-201-73/+2
| | | | | | | | | | | | | | | | | | | | * Move the definition of `StableName` from `System.Mem.StableName` to a new `GHC.StableName` module. * Expose the `StableName` data constructor from `GHC.StableName`. Once we have `UnliftedArray#`, this will enable `StableName`s to be stored in `UnliftedArray`s (from `primitive`) without unsafe coercions. Reviewers: hvr, bgamari, andrewthad, osa1 Reviewed By: osa1 Subscribers: osa1, rwbarton, carter GHC Trac Issues: #15535 Differential Revision: https://phabricator.haskell.org/D5078
* base: Fix documentation of System.Environment.BlankBen Gamari2018-07-311-15/+12
| | | | | | | | | | | | | This documentation was a bit unprofessional and the markup wasn't correct. Reviewers: hvr, alpmestan Reviewed By: alpmestan Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D5026
* Replace atomicModifyMutVar#David Feuer2018-07-151-1/+1
| | | | | | | | | | | | Reviewers: simonmar, hvr, bgamari, erikd, fryguybob, rrnewton Reviewed By: simonmar Subscribers: fryguybob, rwbarton, thomie, carter GHC Trac Issues: #15364 Differential Revision: https://phabricator.haskell.org/D4884
* Fix 32 bit windows buildTamar Christina2018-05-281-1/+2
| | | | | | | | | | | | | | | | Summary: Fix a number of issues that have broken the 32 bit build. This makes it build again. Test Plan: ./validate Reviewers: hvr, goldfire, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4691