November 21, 2016
On 21/11/2016 12:46 AM, unDEFER wrote:
> On Friday, 18 November 2016 at 17:33:41 UTC, unDEFER wrote:
>> Wow, Thank you! I have bought. I'm waiting instructions for download.
>
> Google is a stranger to fear: it have sent to spam the message from
> Walter Bright himself!
> Walter prompt to me LIB.EXE utility, and I have removed from snn.lib
> "io" module.
> After it I have written short file to hide 2 undefined symbols:
> ======================================
> $ cat cygwin/snn_io.d
> module cygwin.snn_io;
>
> extern(C):
> version (Windows):
>
> ubyte[512] __fhnd_info;
>
> void _dos_sethandlecount(long count)
> {
> }
> ======================================
>
> And the result:
>
> $ ./try.exe
> -bash: ./try.exe: cannot execute binary file: Exec format error
>
> Ha-ha :-)))) LOL
>
> I don't know what to do more.. Seems I will close this theme..
> So work with cygwin under D is impossible..

Well yeah, I have never heard of anybody mixing libc's before...
They are simply not designed to do this.
November 20, 2016
On Sunday, 20 November 2016 at 11:55:49 UTC, rikki cattermole wrote:

> So work with cygwin under D is impossible..

Not impossible. It's just going to require some backend work. It's not something you can make happen from the command line.
November 20, 2016
On Sunday, 20 November 2016 at 14:39:24 UTC, Mike Parker wrote:

> Not impossible. It's just going to require some backend work. It's not something you can make happen from the command line.

Possible of course.. But looks like it needed at least snn.lib sources and maybe something more.
November 21, 2016
On 21/11/2016 4:47 AM, unDEFER wrote:
> On Sunday, 20 November 2016 at 14:39:24 UTC, Mike Parker wrote:
>
>> Not impossible. It's just going to require some backend work. It's not
>> something you can make happen from the command line.
>
> Possible of course.. But looks like it needed at least snn.lib sources
> and maybe something more.

No, snn.lib is the exact thing that you don't need.
November 21, 2016
On Monday, 21 November 2016 at 04:06:31 UTC, rikki cattermole wrote:
> No, snn.lib is the exact thing that you don't need.

I need to resolve conflict between snn.lib and cygwin1.dll.
And I can see only 2 methods:
1) recompile all dmd libraries including snn.lib with replacing open->_open, close->_close, remove->_remove.
2) substitute it in cygwin1.dll, but it is very bad method because I will need my own _cygwin1.dll instead of system cygwin1.dll (i.e. instead of system _dynamic_ library).

But the second is much easier, because cygwin has all sources.
November 22, 2016
On Monday, 21 November 2016 at 06:38:00 UTC, unDEFER wrote:
> 1) recompile all dmd libraries including snn.lib with replacing open->_open, close->_close, remove->_remove.

What if you just wrote wrapper functions or better yet, linker aliases?

November 23, 2016
On Tuesday, 22 November 2016 at 15:00:44 UTC, Adam D. Ruppe wrote:
> On Monday, 21 November 2016 at 06:38:00 UTC, unDEFER wrote:
>> 1) recompile all dmd libraries including snn.lib with replacing open->_open, close->_close, remove->_remove.
>
> What if you just wrote wrapper functions or better yet, linker aliases?

Sorry, I don't know what is linker aliases. If you suggest good method I with pleasure will use it. What I must read?
December 03, 2016
So, just another attempt..

=================================
import std.stdio;
import std.string;
import core.sys.windows.winbase;

extern(C)
{
        alias int   function(in char*, int, ...) open_t;
        open_t _my_open;
        extern uint   errno;
}

void main()
{
        writefln("Open Library");
        auto mod = LoadLibrary("C:\\cygwin\\bin\\cygwin1.dll");
        if (mod == null)
        {
                writefln("Failed load cygwin1.dll");
                return;
        }

        writefln("Get Proc");
        _my_open = cast(open_t) GetProcAddress(mod, "open");
        if (_my_open == null)
        {
                writefln("Failed open open symbol");
                return;
        }

        writefln("_open");
        int res = _my_open(toStringz("/bin/bash"), 0);
        writefln("res=%s errno=%s", res, errno);
}
=================================

The code compiles without problem, BUT without last 2 lines it runs, and with last 2 lines it said that executable is corrupted.
Why???
December 04, 2016
I have found. I have to use cygwin_dll_init
==============================
$ cat try.d
import std.stdio;
import std.string;
import core.sys.windows.windows;

extern(C)
{
        alias int   function(const (char)*, int, ...) open_t;
        alias void   function() init_t;
        alias void  function(const (char)*s) perror_t;
        alias size_t function(int fs, void *buf, size_t count) read_t;
        open_t _my_open;
        init_t  init;
        perror_t my_perror;
        read_t  my_read;
}

void main()
{
        writefln("Open Library");
        HMODULE mod = cast(HMODULE) LoadLibrary("C:\\cygwin\\bin\\cygwin1.dll");
        if (mod is null)
        {
                writefln("Failed load cygwin1.dll");
                return;
        }

        writefln("Get Proc Init");
        init = cast(init_t) GetProcAddress(mod, "cygwin_dll_init");
        if (init is null)
        {
                writefln("Failed open init symbol %s", GetLastError());
                return;
        }

        init();

        writefln("Get Proc Open");
        _my_open = cast(open_t) GetProcAddress(mod, "open");
        if (_my_open is null)
        {
                writefln("Failed open open symbol %s", GetLastError());
                return;
        }

        writefln("Get Proc read");
        my_read = cast(read_t) GetProcAddress(mod, "read");
        if (my_read is null)
        {
                writefln("Failed open read symbol %s", GetLastError());
                return;
        }

        writefln("_open");
        int res = (*_my_open)(toStringz("/proc/cpuinfo"), 0);
        writefln("res=%s", res);
        if (res < 0)
        {
                my_perror("Can't open file");
        }

        char[1024] buf;
        my_read(res, buf.ptr, buf.length);

        writefln("%s", buf);
}
========================================

$ ./try.exe
Open Library
Get Proc Init
Get Proc Open
Get Proc read
_open
res=0
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 76
model name      : Intel(R) Pentium(R) CPU  N3700  @ 1.60GHz
...


The problem of the method only errno variable which doesn't content right error number.
December 04, 2016
DONE!!!

=======================================
$ cat try.d
import std.stdio;
import std.string;
import cygwin.std.file;
import cygwin.loader;

void main()
{
        CygwinInit();

        foreach (string name; dirEntries("/", SpanMode.shallow))
        {
                writefln(name);
        }
}
=======================================

$ ./try.exe
/bin
/Cygwin-Terminal.ico
/Cygwin.bat
/Cygwin.ico
/dev
/etc
/home
/lib
/sbin
/tmp
/usr
/var
/proc
/cygdrive


The sources of "cygwin" package for D will be available as part of my unDE project soon.