summaryrefslogtreecommitdiff
path: root/libraries/base/cbits
Commit message (Collapse)AuthorAgeFilesLines
* Windows: Update tarballs to GCC 9.2 and remove MAX_PATH limit.Tamar Christina2019-10-201-1/+1
|
* Windows: make openTempFile fully atomic.Tamar Christina2019-09-111-29/+45
|
* Use C99 Fixed width types to avoid hack in base's configureJohn Ericson2019-09-011-15/+15
| | | | Define MD5Context in terms of `uint*_t` and don't use `HsFFI.h`.
* stg_floatToWord32zh: zero-extend the Word32 (#16617)Kevin Buhr2019-05-081-1/+2
| | | | | | | The primop stgFloatToWord32 was sign-extending the 32-bit word, resulting in weird negative Word32s. Zero-extend them instead. Closes #16617.
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-151-2/+2
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Update unicode tables to v. 12 of the standardArtem Pelenitsyn2018-08-232-958/+1306
| | | | | | | | | | | | Reviewers: hvr, bgamari, Azel Reviewed By: bgamari Subscribers: thomie, Azel, rwbarton, carter GHC Trac Issues: #5518, #15525 Differential Revision: https://phabricator.haskell.org/D5066
* Fixes isAlphaNum re. isAlpha/isNumber and doc fix (trac issue #10412)ARJANEN Loïc Jean David2018-04-191-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Corrects the inconsistency between Data.Char.isAlphaNum, Data.Char.isAlpha and Data.Char.isNumber. Indeed, isAlphaNum was returning True not only when isAlpha or isNumber returned True but also when isMark did. The selectors for the Mn, Mc and Me general categories where removed from the macro generating u_iswalnum in ubconfc. Also, Data.Char.isAlphaNum's documentation was changed to state that isAlphaNum returns true not only for Unicode number digits but for Unicode numbers in general in Unicode.hs. Signed-off-by: ARJANEN Loïc Jean David <arjanen.loic@gmail.com> Reviewers: hvr, ekmett, lelf, bgamari Reviewed By: bgamari Subscribers: thomie, carter GHC Trac Issues: #10412 Differential Revision: https://phabricator.haskell.org/D4593
* Various Windows / Cross Compile to Windows fixesMoritz Angermann2018-03-021-0/+2
| | | | | | | | | | | | | | | - Adds quick-cross-ncg flavour. - Fix windows wchar with `_s` for mingw - Lookup windres, dllwrap and objdump - Fix type. Reviewers: bgamari, hvr, Phyx, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, erikd, carter Differential Revision: https://phabricator.haskell.org/D4430
* Make System.IO.openTempFile thread-safe on WindowsTamar Christina2018-01-021-1/+44
| | | | | | | | | | | | | | | | | | | | | | | This calls out to the Win32 API `GetTempFileName` to generate a temporary file. Using `uUnique = 0` guarantees that the file we get back is unique and the file is "reserved" by creating it. Test Plan: ./validate I can't think of any sensible tests that shouldn't run for a while to verify. So the example in #10731 was ran for a while and no collisions in new code Reviewers: hvr, bgamari, erikd Reviewed By: bgamari Subscribers: RyanGlScott, rwbarton, thomie, carter GHC Trac Issues: #10731 Differential Revision: https://phabricator.haskell.org/D4278
* base: fdReady(): Return only after sycall returns after `msecs` have passedNiklas Hambüchen2017-12-111-10/+79
| | | | | | | | | | Reviewers: bgamari, austin, hvr, dfeuer Reviewed By: dfeuer Subscribers: syd, dfeuer, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4012
* fdReady: Use C99 bools / CBool in signatureNiklas Hambüchen2017-12-111-1/+1
| | | | | | | | | | Reviewers: bgamari, Phyx, austin, hvr, simonmar Reviewed By: bgamari Subscribers: syd, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4041
* base: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.Niklas Hambüchen2017-11-241-54/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 64-bit UNIX and Windows, Haskell `Int` has 64 bits but C `int msecs` has 32 bits, resulting in an overflow. This commit fixes it by switching fdReady() to take int64_t, into which a Haskell `Int` will always fit. (Note we could not switch to `long long` because that is 32 bit on 64-bit Windows machines.) Further, to be able to actually wait longer than ~49 days, we put loops around the waiting syscalls (they all accept only 32-bit integers). Note the timer signal would typically interrupt the syscalls before the ~49 days are over, but you can run Haskell programs without the timer signal, an we want it to be correct in all cases. Reviewers: bgamari, austin, hvr, NicolasT, Phyx Reviewed By: bgamari, Phyx Subscribers: syd, Phyx, rwbarton, thomie GHC Trac Issues: #14262 Differential Revision: https://phabricator.haskell.org/D4011
* base: fdReady(): Ensure and doc that return values are always -1/0/1Niklas Hambüchen2017-09-271-2/+5
| | | | | | | | | | Reviewers: bgamari, austin, hvr, Phyx Reviewed By: Phyx Subscribers: Phyx, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4010
* fdReady(): Fix some C -Wconversion warnings.Niklas Hambüchen2017-09-271-7/+8
| | | | | | | | | | | | | Btw, -Wconversion is off by default and not included in -Wall, -Wextra or -pedantic, so I used it temporarily with -optc-Wconversion. Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3965
* base: fdReady(): Add note about O_NONBLOCK requirementNiklas Hambüchen2017-09-261-1/+5
| | | | | | | | | | Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3962
* A bunch of typofixesGabor Greif2017-09-261-1/+1
|
* base: Add more detail to FD_SETSIZE related error messageNiklas Hambüchen2017-09-191-2/+1
| | | | | | | | | | Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3960
* base: Make it less likely for fdReady() to fail on Windows sockets.Niklas Hambüchen2017-09-191-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See the added comment for details. It's "less likely" because it can still fail if the socket happens to have an FD larger than 1023, which can happen if many files are opened. Until now, basic socket programs that use `hWaitForInput` were broken on Windows. That is because on Windows `FD_SETSIZE` defaults to 64, but pretty much all GHC programs seem to have > 64 FDs open, so you can't actually create a socket on which you can `select()`. It errors with `fdReady: fd is too big` even with an example as simple as the following (in this case, on my machine the `fd` is `284`): {-# LANGUAGE OverloadedStrings #-} import Control.Monad (forever) import Network.Socket import System.IO -- Simple echo server: Reads up to 10 chars from network, echoes them back. -- Uses the Handle API so that `hWaitForInput` can be used. main :: IO () main = do sock <- socket AF_INET Stream 0 setSocketOption sock ReuseAddr 1 bind sock (SockAddrInet 1234 0x0100007f) -- 0x0100007f == 127.0.0.1 localhost listen sock 2 forever $ do (connSock, _connAddr) <- accept sock putStrLn "Got connection" h <- socketToHandle connSock ReadWriteMode hSetBuffering h NoBuffering ready <- hWaitForInput h (5 * 1000) -- 5 seconds putStrLn $ "Ready: " ++ show ready line <- hGetLine h putStrLn "Got line" hPutStrLn h ("Got: " ++ line) hClose h I'm not sure how this was not discovered earlier; for #13525 (where `fdReady()` breaking completely was also discovered late) at least it failed only when the timeout was non-zero, which is not used in ghc beyond in `hWaitForInput`, but in this Windows socket case it breaks even on the 0-timeout. Maybe there is not actually anybody who uses sockets as handles on Windows? The workaround for now is to increase `FD_SETSIZE` on Windows; increasing it is possible on Windows and BSD, see https://stackoverflow.com/questions/7976388/increasing-limit-of-fd-setsi ze-and-select A real fix would be to move to IO Completion Ports on Windows, and thus get rid of the last uses of `select()` (the other platforms already use `poll()` but Windows doesn't have that). Reviewers: bgamari, austin, hvr, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3959
* base: Fix fdReady() returning immediately for pipes on Windows.Niklas Hambüchen2017-09-191-16/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://ghc.haskell.org/trac/ghc/ticket/13497#comment:17 Until now, the program import System.IO main = hWaitForInput stdin (5 * 1000) didn't wait 5 seconds for input on Winodws, it terminated immediately. This was because the `PeekNamedPipe()` function introduced in commit 94fee9e7 really only peeks, it doesn't block. So if there's no data, `fdReady(fd, msec)` would return immediately even when the given `msec` timeout is not zero. This commit fixes it by looping around `PeekNamedPipe()` with a `sleep(1 ms)`. Apparently there's no better way to do this on Windows without switching to IOCP. In any case, this change should be strictly better than what was there before. Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: Phyx, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3956
* base: Fix fdReady() potentially running forever for Windows Char devices.Niklas Hambüchen2017-09-191-1/+10
| | | | | | | | | | Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3955
* base: Fix fdReady() potentially running forever on Windows.Niklas Hambüchen2017-09-191-10/+20
| | | | | | | | | | | | | | | | This fixes #13497 for Windows -- at least for the `if (isSock)` part; I haven't investigated the case where it's not a socket yet. Solved by copying the new current-time based waiting logic from the non-Windows implementation above. Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3954
* base: fdReady(): Improve accuracy and simplify code.Niklas Hambüchen2017-09-191-21/+10
| | | | | | | | | | | | | | | | | | | | | | | This is done by reusing the existing cross-platform `getProcessElapsedTime()` function, which already provides nanosecond monotonic clocks, and fallback for platforms that don't have those. To do this, `getProcessElapsedTime()` had to be moved from a private RTS symbol into the public interface. Accuracy is improved in 2 ways: * Use of the monotonic clock where available * Measuring the total time spent waiting instead of a sum of intervals (between which there are small gaps) Reviewers: bgamari, austin, hvr, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3953
* base: Fix mixed tabs/spaces indentation in inputReady.cNiklas Hambüchen2017-09-151-81/+80
| | | | | | | | | | Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3952
* base/inputReady: Whitespace cleanupBen Gamari2017-06-271-84/+84
|
* Prefer #if defined to #ifdefBen Gamari2017-04-283-4/+4
| | | | Our new CPP linter enforces this.
* base: Fix hWaitForInput with timeout on POSIXBen Gamari2017-04-211-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | This was previously broken (#13252) by f46369b8a1bf90a3bdc30f2b566c3a7e03672518, which ported the fdReady function from `select` to `poll` and in so doing dropping support for timeouts. Unfortunately, while `select` tells us the amount of time not slept (on Linux anyways; it turns out this is implementation dependent), `poll` does not give us this luxury. Consequently, we manually need to track time slept in this case. Unfortunately, portably measuring time is hard. Ideally we would use `clock_gettime` with the monotonic clock here, but sadly this isn't supported on most versions of Darwin. Consequently, we instead use `gettimeofday`, running the risk of system time changes messing us up. Test Plan: Validate Reviewers: simonmar, austin, hvr Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13252 Differential Revision: https://phabricator.haskell.org/D3473
* base: Implement bit casts between word and float typesErik de Castro Lopo2017-04-121-0/+69
| | | | | | | | | | | | | Test Plan: Test on x86 and x86_64 Reviewers: duncan, trofi, simonmar, tibbe, hvr, austin, rwbarton, bgamari Reviewed By: duncan Subscribers: Phyx, DemiMarie, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3358
* fdReady: use poll() instead of select()Simon Marlow2016-12-021-9/+33
| | | | | | | | | | | | | | | | | | | | select() is limited to 1024 file descriptors. This actually blew up in a very hard-to-debug way in our production system when using the hinotify package. Test Plan: libraries/tests pass, paricularly hGetBuf001 which exercises this code. Reviewers: niteria, erikd, austin, hvr, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2785 GHC Trac Issues: #12912
* Rts flags cleanupSimon Marlow2016-06-101-42/+0
| | | | | | | | * Remove unused/old flags from the structs * Update old comments * Add missing flags to GHC.RTS * Simplify GHC.RTS, remove C code and use hsc2hs instead * Make ParFlags unconditional, and add support to GHC.RTS
* Typos in comments [skip ci]Gabor Greif2015-08-031-1/+1
|
* Delete _MSC_VER when not necessary, fix #10511Bernard Desmyter2015-06-123-4/+4
| | | | | | | Simplify some preprocessor expressions involving `_MSC_VER` because `_WIN32` is always defined when `_MSC_VER` is. Differential Revision: https://phabricator.haskell.org/D981
* Removes all occurrences of __MINGW32__ (#10485)Thomas Miedema2015-06-114-6/+6
| | | | | | | | | | In Haskell files, replace `__MINGW32__` by `mingw32_HOST_OS`. In .c and .h files, delete `__MINGW32__` when `_WIN32` is also tested because `_WIN32` is always defined when `__MINGW32__` is. Also replace `__MINGW32__` by `_WIN32` when used standalone for consistency. Differential Revision: https://phabricator.haskell.org/D971
* accessors to RTS flag values -- #5364Ömer Sinan Ağacan2014-11-241-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Implementation of #5364. Mostly boilerplate, reading FILE fields is missing. Test Plan: - Get some feedback on missing parts. (FILE fields) - Get some feedback on module name. - Get some feedback on other things. - Get code reviewed. - Make sure test suite is passing. (I haven't run it myself) Reviewers: hvr, austin, ezyang Reviewed By: ezyang Subscribers: ekmett, simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D306 GHC Trac Issues: #5364 Conflicts: includes/rts/Flags.h
* base: Mark WCsubst.c as generated for PhabricatorAustin Seipp2014-10-212-0/+2
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Update to Unicode version 7.0David Feuer2014-10-211-3468/+3817
| | | | | | | | | | | | Summary: Update Unicode data to version 7.0 Reviewers: rwbarton, austin Reviewed By: austin Subscribers: thomie, carter, ezyang, simonmar Differential Revision: https://phabricator.haskell.org/D316
* Refactor to avoid need for `Unicode.hs-boot`Herbert Valerio Riedel2014-10-112-10/+10
| | | | | | | | | | | This avoids the import-cycle caused by the import of `Foreign.C.Types` by using `Int` instead of `CInt` for the Unicode classification functions. This refactoring also allows to remove a couple of `fromIntegral`s. Reviewed By: rwbarton, ekmett Differential Revision: https://phabricator.haskell.org/D328
* Delete all /* ! __GLASGOW_HASKELL__ */ codeThomas Miedema2014-09-231-9/+2
| | | | | | | | | | | | | | | | | Summary: ``` git grep -l '\(#ifdef \|#if defined\)(\?__GLASGOW_HASKELL__)\?' ``` Test Plan: validate Reviewers: rwbarton, hvr, austin Reviewed By: rwbarton, hvr, austin Subscribers: rwbarton, simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D218
* Update a comment in base cbitsReid Barton2014-08-201-1/+1
|
* reading/writing blocking FDs over FD_SETSIZE is broken (Partially Trac #9169)Sergei Trofimovich2014-07-021-1/+5
| | | | | | | | | | | | | | | | | | Summary: libraries/base/cbits/inputReady.c had no limits on file descriptors. Add a limit as non-threaded RTS does. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: none Reviewers: austin, simonmar Reviewed By: austin, simonmar Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D28
* Add setEnv/unsetEnv to System.Environment; fixes #7427Ian Lynagh2013-06-151-0/+11
| | | | Patch from Simon Hengel.
* Add an __hsbase_ prefix to the MD5 symbols (#7914)Simon Marlow2013-05-211-13/+13
|
* Build fix for iOS; fixes #7759Ian Lynagh2013-04-211-1/+2
| | | | | | | | | Patch from Stephen Blackheath. The issue here is that the #defines EVFILT_READ and EVFILT_WRITE have the values -1 and -2. The original code translates that to filterRead = Filter -1 which is wrong Haskell and fails to compile. The modified code produces the correct code filterRead = Filter (-1)
* md5.c: fix a typo in the size argument of memsetMichal Terepeta2013-04-161-1/+1
|
* Removes the assumption that CLK_TCK is a constant (#7519)Simon Marlow2013-01-231-0/+19
| | | | | | (which is not true on QNXNTO). Submitted by: Stephen Paul Weber <singpolyma@singpolyma.net>
* GHC.Windows: more error support (guards, system error strings)Joey Adams2012-11-171-27/+42
| | | | | | | | | | | | | | | This changes the output of throwGetLastError to include the system error message, rather than the message of our fictitious errno. It also adds several definitions to GHC.Windows, mostly from the Win32 package. The exceptions are: * getErrorMessage: returns a String, unlike in System.Win32.Types, where it returns an LPWSTR. * errCodeToIOError: new * c_maperrno_func: new
* Allow openTempFile to retry when it hits a directory (#4968).Paolo Capriotti2012-06-071-0/+6
| | | | | | Windows returns an EACCES error instead of EEXIST when a call to `open` fails due to an existing directory, so add a special case for this situation.
* Use in-process file locking on Windows (#4363)Paolo Capriotti2012-05-081-0/+17
|
* Use RTS version of getMonotonicNSec on Windows (#6061)Paolo Capriotti2012-05-081-46/+0
|
* Add timer initialization for darwin.Paolo Capriotti2012-04-171-10/+10
|
* Replace getUSecOfDay with monotonic timer (#5865)Paolo Capriotti2012-04-171-10/+43
|