Commit Graph

42 Commits

Author SHA1 Message Date
stefan-hoeck
8b96614454 fixed whitespace for *.c and *.h files 2021-01-22 15:08:49 +00:00
Matúš Tejiščák
1a58075a54
Merge pull request #716 from sysvinit/fix-network-constants
Retrieve network address family preprocessor constants from C runtime code
2020-10-11 08:37:44 +02:00
Molly Miller
dff0f1da43 network: Retrieve AF_* magic constants from C support code.
The Network.Socket.Data code previously used hardcoded constants manually read
from auto-generated C source code, however these constants are specific to
Linux. The original code looked like this:

    export
    ToCode SocketFamily where
      -- Don't know how to read a constant value from C code in idris2...
      -- gotta to hardcode those for now
      toCode AF_UNSPEC = 0 -- unsafePerformIO (cMacro "#AF_UNSPEC" Int)
      toCode AF_UNIX   = 1
      toCode AF_INET   = 2
      toCode AF_INET6  = 10

The AF_INET6 constant is correct on my Debian 10 laptop:

    molly on flywheel ~> grep -rE '^#define AF_INET6' /usr/include
    /usr/include/x86_64-linux-gnu/bits/socket.h:#define AF_INET6	PF_INET6
    molly on flywheel ~> grep -rE '^#define PF_INET6' /usr/include
    /usr/include/x86_64-linux-gnu/bits/socket.h:#define PF_INET6    10  /* IP version 6.  */

However, this is not the case on an OpenBSD machine:

    spanner# grep -rE '^#define[[:space:]]+AF_INET6' /usr/include
    /usr/include/sys/socket.h:#define	AF_INET6	24		/* IPv6 */

This commit adds accessor functions to the C runtime support library for
retrieving the values of these macros as they appear in the system libc header
files, which can then be invoked using the normal C FFI machinery.
2020-10-01 12:05:42 +01:00
Matus Tejiscak
cf45f43f4e Move the Buffer struct back into the .c file. 2020-09-20 17:49:25 +02:00
Matus Tejiscak
bdcb2551b2 Change the way of creating directories. 2020-09-19 15:09:26 +02:00
Matus Tejiscak
38a3145e8e Make the C code more explicit. 2020-09-19 14:32:45 +02:00
Matus Tejiscak
cf6530b387 Install headers for libidris2_support, use the right mode. 2020-09-19 14:11:12 +02:00
Thomas Dziedzic
5d1b937035
add prim__getNullAnyPtr and prim__castPtr (#525) 2020-08-20 11:52:51 +01:00
Giuseppe Lomurno
21524da0a0 Windows color fix 2020-08-19 11:30:12 +02:00
Giuseppe Lomurno
42404c2d9d Automatic console width detection 2020-08-18 19:25:36 +01:00
Markus Pfeiffer
0b32bf8a2f Fix forward declaration of idris_closeDir 2020-07-06 13:56:36 +01:00
Niklas Larsson
0c7fc9b73c simplify win32_modenv 2020-06-16 14:09:12 +02:00
Niklas Larsson
2e8f618f00 Apparently overwrite should report success 2020-06-16 14:02:04 +02:00
Niklas Larsson
8540728202 Handle overwrite on windows
Expand test to test overwrite
2020-06-16 13:44:10 +02:00
Niklas Larsson
8633dde240 Add stdlib include 2020-06-16 12:53:36 +02:00
Niklas Larsson
6974b318a3 Add test for setenv and unsetenv 2020-06-16 12:36:39 +02:00
Niklas Larsson
630e4219fc Fix unsetenv
implement Windows support
2020-06-16 12:09:22 +02:00
Tim Süberkrüb
e9a80891b7 Extend Control.App.FileIO 2020-06-12 17:30:54 +02:00
Niklas Larsson
aea0c1fd15 Remove unused functions from idris_buffer.c 2020-06-11 17:35:29 +02:00
Edwin Brady
0a246af449 Make Buffer more primitive
Meaning that the FFI is aware of it, so you can send arbitrary byte data
to foreign calls. Fixes #209

This means that we no longer need the hacky way of reading and writing
binary data via scheme, so can have a more general interface for reading
and writing buffer data in files.

It will also enable more interesting high level interfaces to binary
data, with C calls being used where necessary.

Note that the Buffer primitive are unsafe! They always have been, of
course... so perhaps (later) they should have 'unsafe' as part of their
name and better high level safe interfaces on top.

This requires updating the scheme to support Buffer as an FFI primitive,
but shouldn't affect Idris2-boot which loads buffers its own way.
2020-06-11 14:05:52 +01:00
Thomas Lin
fc8e6b1fef Use GetSystemTimeAsFileTime on older Windows 2020-06-02 10:30:44 +08:00
normalcoder
e001d266fe Add sys/time.h to satisfy xcode.
It seems relevant to all BSD systems.

In xcode the option -Wno-error-implicit-function-declaration is enabled. So the following error occured:
Idris2/support/c/idris_file.c:76:13: Missing '#include <sys/time.h>'; declaration of 'select' must be imported from module 'Darwin.POSIX.sys.time' before it is required

I hope it won't break anything on linux.
2020-06-01 00:48:19 +03:00
Tim Süberkrüb
46f7b78b0e Try to fix pclose for Windows
Co-authored-by: Niklas Larsson <metaniklas@gmail.com>
2020-05-28 16:12:26 +02:00
Tim Süberkrüb
c2dfe7de7f Add popen and pclose from Idris 1 2020-05-28 12:58:03 +02:00
Edwin Brady
c3d13d0854
Merge pull request #93 from ska80/better-names
Rename some file/dir manipulation functions for consistency
2020-05-24 20:16:01 +01:00
Niklas Larsson
8d16980b81 Remove dependency on pthreads on Windows 2020-05-24 19:56:26 +02:00
Kamil Shakirov
307265aaab Update C support header files 2020-05-24 00:41:53 +06:00
Kamil Shakirov
e61e44205b Merge branch 'master' into better-names 2020-05-24 00:26:52 +06:00
Tim Süberkrüb
5dde7063f8 Add popen and pclose from Idris 1 2020-05-23 18:42:05 +02:00
Niklas Larsson
81c59fd5d1
Fix Windows build 2020-05-23 18:05:55 +02:00
Edwin Brady
1857e4b3fe Add flag for windows in support Makefile 2020-05-23 16:47:10 +01:00
Edwin Brady
e17f66244a Move network support to libidris2_support
This makes the support stuff much simpler, and also makes the racket
bootstrap process easier
2020-05-23 15:52:33 +01:00
Niklas Larsson
d50bb099ea Windows support 2020-05-21 15:13:06 +02:00
Kamil Shakirov
f696335f2d Rename some file/dir manipulation functions
Renamed:

fileRemove -> removeFile

dirOpen -> openDir
dirClose -> closeDir
rmDir -> removeDir
2020-05-21 18:32:35 +06:00
Edwin Brady
8380a6fa9e
Merge pull request #4 from ska80/refactor-makefiles
Refactor makefiles
2020-05-19 16:23:06 +01:00
Edwin Brady
953e8f4913
Merge pull request #3 from ska80/ignore-files
Update .gitignore files
2020-05-19 16:22:41 +01:00
Kamil Shakirov
b801b97fcc Refactor makefiles 2020-05-19 18:50:47 +06:00
Kamil Shakirov
47e943cc7d Update .gitignore files 2020-05-19 17:49:21 +06:00
Edwin Brady
f749f3e277
Merge pull request #2 from melted/fix_win
Windows fixes
2020-05-19 12:30:54 +01:00
Niklas Larsson
1bebd7d070 Windows fixes 2020-05-19 13:13:01 +02:00
André Videla
3321dc6be3 Add rmDir to System.Directory 2020-05-18 18:28:33 +01:00
Edwin Brady
80450bbc8e Add missing C support 2020-05-18 14:51:28 +01:00