Commit Graph

12 Commits

Author SHA1 Message Date
Edwin Brady
dc277394ee Fix 'time' to return Integer rather than Int
This way, the time in seconds actually fits...
2015-07-01 13:56:57 +01:00
Edwin Brady
9150698428 Primitive type for world state
This means we can make primitives for reading/writing file handles which
are given the world state, so can be written more safely. Also, a
minimal back end can implement these rather than implementing an entire
FFI.

Updated primitive LReadStr (which can now reasonably be total, like any
foreign function, because it has a world state) and added primitive
LWriteStr.
2015-01-18 00:14:38 +00:00
Edwin Brady
d4ffc21999 Add ManagedPtr type
A ManagedPtr is just like a Ptr, except it points to memory inside
Idris' heap, so doesn't need to be freed. This is useful when you need
to create a structure C side for interacting with a C library, but don't
want to have to explicitly free it.

Also added
registerPtr : (p : Ptr) -> (n : Int) -> ManagedPtr

This moves the n bytes pointed to by p into the Idris heap.

In a non-C backend, or one where memory is managed differently, it's
entirely reasonable for this to be compiled as a no-op. The FFI treats
both Ptr and ManagedPtr as a void* in C.
2014-03-02 00:30:49 +00:00
Edwin Brady
94750e3660 Add 'time' function 2014-02-28 10:18:41 +00:00
Edwin Brady
0fa9239851 Tinker with popen/poll 2014-02-20 23:30:16 +00:00
Edwin Brady
f44fe3290f Foreign pointer equality
Can be useful when dealing with values originating in foreign functions.
Intended in particular for checking sending VM in message passing
concurrency.
2014-01-20 10:42:28 +00:00
Gabe McArthur
5e8a5973d3 Adding several functions to interact with environment variables.
In addition to removing the superfluous 'isNullString' function,
now that I understand the FFI a bit better, there is a new
'getEnvPair' function that looks into the 'const char** environ'.
Setting, unsetting, and listing all of the environment variables is
now supported.
2013-09-21 15:54:25 -10:00
Gabe McArthur
c8530b39e1 Modifying the System.getEnv function to return IO (Maybe String)
For edwinb/Idris-dev#331 , allowing a segfault on returning a
null pointer string is very bad. This requires that either the
value is present or it returns Nothing.
2013-09-21 01:09:04 -10:00
Edwin Brady
8eb2087f1f Separate IO and PrimIO
PrimIO is the internal primitive, IO is the user version which requires an
explicit World token to be passed in which programmers have no access to
directly.
Fixes #185 and fixes #325
2013-09-02 14:58:47 +01:00
David Christiansen
cf9d50faee Remove dynamically loaded RTS due to 32/64-bit issues on OS X 2013-04-08 15:19:13 +02:00
David Christiansen
1f5ff74167 Allow reading files in executor 2013-04-05 15:08:36 +02:00
Edwin Brady
0433650a62 Added some useful standard foreign functions for IO 2012-09-06 15:24:09 +01:00