summaryrefslogtreecommitdiff
path: root/libraries/base/Foreign/Marshal
Commit message (Collapse)AuthorAgeFilesLines
* Add a few more memcpy-ish primopsMatthew Craven2023-04-041-23/+12
| | | | | | | | | | | | | | | | * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c
* base: make Foreign.Marshal.Pool use RTS internal arena for allocationCheng Shao2022-11-161-25/+23
| | | | | | | | | | | | | | | | | | `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338.
* INLINE/INLINEABLE pragmas in Foreign.Marshal.ArraySimon Peyton Jones2022-09-281-1/+31
| | | | | | | | | | | Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module.
* Revert "Data.List specialization to []"Matthew Pickering2021-12-031-1/+1
| | | | | | | | | | This reverts commit bddecda1a4c96da21e3f5211743ce5e4c78793a2. This implements the first step in the plan formulated in #20025 to improve the communication and migration strategy for the proposed changes to Data.List. Requires changing the haddock submodule to update the test output.
* Clarify that malloc, free etc. are the ones from stdlib.hOleg Grenrus2021-09-221-0/+5
|
* Data.List specialization to []Oleg Grenrus2021-04-011-1/+1
| | | | | | | - Remove GHC.OldList - Remove Data.OldList - compat-unqualified-imports is no-op - update haddock submodule
* Throw IOError when allocaBytesAligned gets non-power-of-two alignDaniel Gröber2021-02-141-2/+20
|
* Improve ByteArray# documentation regarding alignmentDaniel Gröber2021-02-141-0/+8
|
* base: Use keepAlive# in Foreign.Marshal.AllocBen Gamari2021-02-141-25/+4
|
* [skip ci] Fix typo in `callocBytes` haddock.Viktor Dukhovni2020-10-301-1/+1
|
* Remove redundant "do", "return" and language extensions from baseHécate2020-09-232-6/+2
|
* Improve few Foreign.Marshal.Utils docsÖmer Sinan Ağacan2019-11-291-11/+21
| | | | | | | | In copyBytes and moveBytes mention which argument is source and which is destination. Also fixes some of the crazy indentation in the module and cleans trailing whitespace.
* Refactor Foreign.Marshal modules for more modern styleÖmer Sinan Ağacan2018-09-082-62/+29
| | | | | | | | | | | | (use ScopedTypeVariables to remove dummy arguments) Reviewers: bgamari, RyanGlScott, dfeuer, hvr, monoidal Reviewed By: monoidal Subscribers: monoidal, rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5124
* base: Make Foreign.Marshal.Alloc.allocBytes[Aligned] NOINLINEBen Gamari2018-07-301-0/+17
| | | | | | | | | | | | | | | | | As noted in #14346, touch# may be optimized away when the simplifier can see that the continuation passed to allocaBytes will not return. Marking CPS-style functions with NOINLINE ensures that the simplier can't draw any unsound conclusions. Ultimately the right solution here will be to do away with touch# and instead introduce a scoped primitive as is suggested in #14375. Note: This was present in 8.2 but was never merged to 8.4 in hopes that we would have #14375 implemented in time. This meant that the issue regressed again in 8.4. Thankfully we caught it in time to fix it for 8.6. (cherry picked from commit 404bf05ed3193e918875cd2f6c95ae0da5989be2)
* Simplify Foreign.Marshal.Alloc functions with ScopedTypeVariablesÖmer Sinan Ağacan2018-02-101-23/+12
| | | | | | | | | | Reviewers: hvr, bgamari, RyanGlScott Reviewed By: RyanGlScott Subscribers: RyanGlScott, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4401
* Typos in commentsGabor Greif2017-01-132-2/+2
|
* Rip out __HADDOCK__ referencesBen Gamari2015-11-141-4/+0
| | | | | | | | | | | | | | | As it turns out no one actually sets this macro anyways and haddock now clearly has no trouble parsing this code. Test Plan: Validate Reviewers: hvr, goldfire, austin Reviewed By: austin Subscribers: duncan, thomie, hvr Differential Revision: https://phabricator.haskell.org/D1463
* base: Remove a redundant 'return'Simon Peyton Jones2015-08-271-2/+1
|
* Convert `/Since: .../` to new `@since ...` syntaxHerbert Valerio Riedel2014-12-161-1/+1
| | | | | | Starting with Haddock 2.16 there's a new built-in support for since-annotations Note: This exposes a bug in the `@since` implementation (see e.g. `Data.Bits`)
* Implement `calloc{,Bytes,Array,Array0}` allocatorsAlex Petrov2014-12-052-1/+36
| | | | | | | | | | | | | | | | | | | | Summary: This adds zero-initialising versions of `malloc{,Bytes,Array,Array0}` * Add `calloc` and `callocBytes` to `Foreign.Marshal.Alloc`. * Add `callocArray` and `callocArray0` to `Foreign.Marshal.Array`. Reviewers: ekmett, duncan, austin, hvr Reviewed By: austin, hvr Subscribers: ezyang, simonmar, ekmett, duncan, thomie, carter Projects: #ghc Differential Revision: https://phabricator.haskell.org/D527 GHC Trac Issues: #9859
* Be consistent with placement of Safe Haskell mode at top of fileDavid Terei2014-11-211-4/+1
|
* Update Foreign.* for Safe Haskell now that they're safe by defaultDavid Terei2014-11-211-1/+1
|
* Add 'fillBytes' to Foreign.Marshal.Utils.Alex Petrov2014-11-211-2/+17
| | | | | | | | fillBytes uses 'memset' to fill a memory area with a given byte value. Reviewed By: austin, hvr Differential Revision: https://phabricator.haskell.org/D465
* `M-x delete-trailing-whitespace` & `M-x untabify`Herbert Valerio Riedel2014-09-241-1/+1
| | | | ...several modules in `base` recently touched by me
* Simplify import-graph a bit moreHerbert Valerio Riedel2014-09-211-1/+1
| | | | | | This is preparatory refactoring for avoiding import cycles when `Data.Traversable` will be imported by `Control.Monad` and `Data.List` for implementing #9586
* Move `when` to GHC.BaseHerbert Valerio Riedel2014-09-181-2/+1
| | | | | | | | | This allows several modules to avoid importing Control.Monad and thus break import cycles that manifest themselves when implementing #9586 Reviewed By: austin, ekmett Differential Revision: https://phabricator.haskell.org/D222
* Improve Haddock markupHerbert Valerio Riedel2014-01-301-1/+1
| | | | | | | | | | | This fixes the markup at the top of `Control.Arrow`, and improves the markup inside DEPRECATED strings. (Haddock supports markup inside DEPRECATED messages, which allows to turn references to Haskell entities into hyperlinks by using the usual Haddock markup.) Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Drop redundant `{-# LANGUAGE #-}` pragmasHerbert Valerio Riedel2013-09-282-2/+1
| | | | | | | | | | | | | This removes language pragmas from Haskell modules which are implicitly active with `default-language: Haskell2010`. Specifically, the following language extension pragmas are removed by this commit: - PatternGuards - ForeignFunctionInterface - EmptyDataDecls - NoBangPatterns Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Constant-fold `__GLASGOW_HASKELL__` CPP conditionalsHerbert Valerio Riedel2013-09-177-60/+6
| | | | | | | | | | Now that HUGS and NHC specific code has been removed, this commit "folds" the now redundant `#if((n)def)`s containing `__GLASGOW_HASKELL__`. This renders `base` officially GHC only. This commit also removes redundant `{-# LANGUAGE CPP #-}`. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Remove Hugs98 specific codeHerbert Valerio Riedel2013-09-171-10/+0
| | | | | | | For rationale. see http://permalink.gmane.org/gmane.comp.lang.haskell.ghc.devel/2349 Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Re-jig SOURCE importsSimon Peyton Jones2013-06-062-2/+0
| | | | | | | | | | | | | | * Do not have have an hs-boot file for Data.Typeable * Instead make all the loops go through GHC.Err (just a couple of magic functions) GHC.Exception (some non-exceptional functions) The main idea is a) don't involve classes in the hs-boot world b) loop through error cases where performance doesn't matter c) be careful not to SOURCE import things that are bottom, unless MkCore knows about them in eRROR_IDS, so that we see their strictness
* Mark DEPRECATED pragmas with when they were addedIan Lynagh2013-02-161-1/+1
|
* Remove nhc98-specific files and contentIan Lynagh2013-02-153-11/+0
|
* Update a H98 reference to H2010Ian Lynagh2012-11-171-1/+1
|
* Remove commented types in module export listsIan Lynagh2012-10-275-64/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These comments are rather less useful now that haddock can give docs with the same informatino in the module synopsis. Having to maintain them when making changes to the library is a pain, and when people forget about doing so there is nothing that checks that the comments are right, so mistakes tend to linger. Of the comments that my script detected, 78 of 684 were already incorrect in one way or another, e.g. missing context: Text.Show.showsPrec Comment type: Int -> a -> ShowS Actual type: Show a => Int -> a -> ShowS wrong context: Numeric.readInt Comment type: Integral a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a Actual type: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a not following a class change (e.g. Num losing its Eq superclass): Text.Read.Lex.readOctP Comment type: Num a => ReadP a Actual type: (Eq a, Num a) => ReadP a not following the Exceptions change: GHC.Conc.childHandler Comment type: Exception -> IO () Actual type: SomeException -> IO () or just always been wrong: GHC.Stable.deRefStablePtr Comment type: StablePtr a -> a Actual type: StablePtr a -> IO a
* DEPRECATE Foreign.Marshal.Error.void (use Control.Monad.void instead)Simon Marlow2012-04-251-1/+1
|
* Update base for latest Safe Haskell.David Terei2011-10-255-0/+5
|
* Update base for new Safe Haskell designDavid Terei2011-10-251-1/+1
|
* Export constructors for Foreign.C.Types and System.Posix.Types newtypesIan Lynagh2011-10-212-2/+2
| | | | | Part of trac #5529. We also now import the constructors in various modules that use them in FFI decls.
* Remove the Eq superclass of NumIan Lynagh2011-10-121-1/+1
|
* Implement unsafeLocalState by unsafeDupablePerformIO, notSimon Marlow2011-07-181-1/+1
| | | | | | unsafePerformIO. The latter is more efficient, and will work correctly for clients that are using unsafeLocalState for its documented uses.
* SafeHaskell: Added SafeHaskell to baseDavid Terei2011-06-187-1/+90
|
* Tweak alloca docsIan Lynagh2011-04-031-2/+3
| | | | Based on a patch from Jason Dagit
* Generalize the type of Foreign.Marshal.Utils.maybeNew; fixes trac #5044Ian Lynagh2011-04-031-2/+2
| | | | | | | git conversion of: Tue Mar 8 22:31:07 CET 2011 Bas van Dijk <v.dijk.bas@gmail.com> * Generalize the type of Foreign.Marshal.Utils.maybeNew This makes it consistent with maybeWith
* Use explicit language extensions & remove extension fields from base.cabalsimonpj@microsoft.com2011-01-285-5/+15
| | | | | | | | | | Add explicit {-# LANGUAGE xxx #-} pragmas to each module, that say what extensions that module uses. This makes it clearer where different extensions are used in the (large, variagated) base package. Now base.cabal doesn't need any extensions field Thanks to Bas van Dijk for doing all the work.
* Remove redundant imports, now that NoImplicitPrelude does not imply ↵simonpj@microsoft.com2010-10-221-1/+0
| | | | RebindableSyntax
* export allocaBytesAligned; make allocaArray use the correct alignment (#2917)Simon Marlow2010-08-122-3/+5
|
* add module intro from Haskell 2010Simon Marlow2010-07-141-1/+23
|
* New asynchronous exception control API (base parts)Simon Marlow2010-07-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed on the libraries/haskell-cafe mailing lists http://www.haskell.org/pipermail/libraries/2010-April/013420.html This is a replacement for block/unblock in the asychronous exceptions API to fix a problem whereby a function could unblock asynchronous exceptions even if called within a blocked context. The new terminology is "mask" rather than "block" (to avoid confusion due to overloaded meanings of the latter). The following is the new API; the old API is deprecated but still available for the time being. Control.Exception ----------------- mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b mask_ :: IO a -> IO a uninterruptibleMask :: ((forall a. IO a -> IO a) -> IO b) -> IO b uninterruptibleMask_ :: IO a -> IO getMaskingState :: IO MaskingState data MaskingState = Unmasked | MaskedInterruptible | MaskedUninterruptible Control.Concurrent ------------------ forkIOUnmasked :: IO () -> IO ThreadId
* doc typoSimon Marlow2010-07-011-1/+1
|