Re: howto recompile dmd 2.053 for CentOS 5.x?
On Tue, May 24, 2011 at 5:30 PM, Nick Sabalausky a@a.a wrote: The DMD zips contain all the source code. You should be able to do this: - Unzip dmd.2.053.zip (or whatever other version you want) - Go into the 'src/dmd' directory - Compile dmd (For me, it's just make -f linux.mak, but I'm on a 32/32 system. I don't know if you'd need another switch for 64-bit...But you say you've already compiled dmd from git, so you probably already know :) ) - Copy the resulting executable to the bin directory: cp ./dmd ../../linu/bin(32|64)/ That should be all you need. I don't *think* you'd need to to recompile druntime or phobos (but then, I'm not an expert on DMD's internals). If you do end up needing to recompile them, they're right there in th zip, too, 'src/druntime' and 'src/phobos'. If you do, the just remember to copy the resulting libs from the src directory to 'linux/lib(32|64)/'. We do really need a better way to compile DMD/DRuntime/Phobos, though. I've been meaning to make unix and windows scripts for it, but haven't gotten to it yet. Thanks a lot Nick, Just recompiling dmd alone and use the rest from the zip archive worked. (had to remove L--no-warn-search-mismatch from dmd.conf which is not supported by CentOS' ancient ld). I thought I would need to recompile everything to match compiler and libraries. And it really doesn't help that the phobos src in the 2.053.zip does not compile (vs phobos on git does). When dmd goes in the next beta round this will be my first test: Can I compile everything in the zip file... But it would be great if we could convince Walter to build dmd on an older distro like CentOS 5 (or even 4?) instead. Lars
Re: Get single keystroke?
On Mon, Mar 21, 2011 at 1:33 PM, Sean Eskapp eatingstap...@gmail.com wrote: Is there a way to get a single keystroke in D2? Any method I've tried requires pushing Enter before the stroke is registered. Hi Sean, what you want to do is OS dependent. I needed something similar ('press key to continue') e.g.: for Windows import core.sys.windows.windows; bool kbHit() { // inspired by http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045691686id=1043284392 HANDLE stdIn = GetStdHandle(STD_INPUT_HANDLE); DWORD saveMode; GetConsoleMode(stdIn, saveMode); SetConsoleMode(stdIn, ENABLE_PROCESSED_INPUT); bool ret = false; if (WaitForSingleObject(stdIn, INFINITE) == WAIT_OBJECT_0) { uint num; char ch; ReadConsoleA(stdIn, ch, 1, num, cast(void *) 0L); ret = true; } SetConsoleMode(stdIn, saveMode); return ret; } void wait_for_key() { writeln(\nPress any key to continue); while (!kbHit()) {} } for Linux/Unix something like http://www.linuxquestions.org/questions/programming-9/kbhit-34027/ should work. Hope that helps, Lars
How-to manipulate a C array with D2 vector operations?
Hi I am trying to implement a D2 function that has this C signature (it gets called from a C module and I cannot change the caller): extern(C) read_into(char *buffer, size_t buf_len); I would like to use D's vector (or array-wise according to TDPL) operations on buffer but I cannot find a way, how I could initialize a (static?) D array and tell it to use buffer as its memory. Obviously I don't want to copy buffer in a regular D array to be able to do the manipulations and than having to copy everything back into buffer. Is there any way to get this accomplished? Thanks, Lars
Re: How-to manipulate a C array with D2 vector operations?
On 2/28/2011 10:15 AM, Denis Koroskin wrote: On Mon, 28 Feb 2011 19:51:28 +0300, Lars Holowko lars.holo...@gmail.com wrote: gets called from a C module and I cannot change the caller): extern(C) read_into(char *buffer, size_t buf_len); I would like to use D's vector (or array-wise according to TDPL) operations on buffer but I cannot find a way, how I could initialize a (static?) D array and tell it to use buffer as its memory. Obviously I Here you go: auto arr = buffer[0..buf_len]; Now you can operate on this array however you like. E.g. arr[] = 0; // initialize with zeros Thanks Denis and Trass3r, that was embarrasingly easy ;-)
Re: any update on large file support for linux?
On Tue, Sep 7, 2010 at 1:08 AM, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: The SVN version of std.stdio supports large files on Linux and OSX. The next release will be a nice one, I think. :) -Lars Thanks Lars, For the hint to the svn versions. Things seem to work there. What really surprised me is that dmd compiles f.seek(1024 * 1024 * 1024 * 6, SEEK_SET); but fails with std.exception.errnoexcept...@std/stdio.d(538): Could not seek in file `test.txt' (Invalid argument) whereas f.seek(1024 * 1024 * 1024 * 6L, SEEK_SET); works fine. I did not realize that 1024 * 1024 * 1024 * 6 turns negative and then gets converted to a negative long (without even a warning). Overseeing that had killed my own efforts to hack 64-bit support into phobos ;-) Thanks again, (another ;-)) Lars
Re: any update on large file support for linux?
On Tue, Sep 7, 2010 at 9:34 AM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I did not realize that 1024 * 1024 * 1024 * 6 turns negative and then gets converted to a negative long (without even a warning). Overseeing that had killed my own efforts to hack 64-bit support into phobos ;-) Hmmm... the compiler could and should warn about integer overflow in computed constant. I suggest you file this as an improvement in bugzilla. Glad to hear large files are working for you. Andrei I filed an enhancement request http://d.puremagic.com/issues/show_bug.cgi?id=4835 as Andrei had recommended. Lars
any update on large file support for linux?
Hi everybody, Are there any status updates on the large file support for dmd on Linux? I found this bug: http://d.puremagic.com/issues/show_bug.cgi?id=3409 which has not been commented on for quite a while. I was trying to dig around in druntime and phobos - a lot seems already in place so I was hoping that I could get it to work with minor hacking: - enable __USE_LARGEFILE64 for 32 bit dmd in druntime/src/core/sys/posix/config.d (no idea why this is determined by the processor's native pointer size) - change std.stdio.File.seek to call fseeko instead of fseek void seek(long offset, int origin = SEEK_SET) { enforce(p p.handle, Attempting to seek() in an unopened file); // @@@ Dubious: why is fseek in std.c.stdio taking an int??? errnoEnforce(core.sys.posix.stdio.fseeko( // errnoEnforce(core.stdc.stdio.fseek( // p.handle, to!int(offset), origin) == 0, p.handle, offset, origin) == 0, Could not seek in file `~p.name~'); } But when I run the slightly modified std.stdio sample: import std.stdio; import core.sys.posix.sys.types; void main(string args[]) { writefln(Typeof(off_t) = %s, typeid(off_t)); auto f = File(test.txt, w); // open for writing f.write(Hello); f.seek(1024 * 1024 * 1024 * 6, SEEK_SET); if (args.length 1) { auto g = f; // now g and f write to the same file // internal reference count is 2 g.write(, , args[1]); // g exits scope, reference count decreases to 1 } f.writeln(!); } I get something like this: Typeof(off_t) = long std.exception.errnoexcept...@std/stdio.d(526): Could not seek in file `test.txt' (Invalid argument) ./io_test() [0x8055833] ./io_test() [0x8054d40] ./io_test() [0x8049859] ./io_test() [0x804f6b6] ./io_test() [0x804f610] ./io_test() [0x804f6fa] ./io_test() [0x804f610] ./io_test() [0x804f5b6] /lib32/libc.so.6(__libc_start_main+0xe6) [0xf763bbd6] ./io_test() [0x8049741] nm io_test | grep -e fopen -e fseek 080552f0 T _D3std5stdio5fopenFxAaxAaZPOS4core4stdc5stdio6_iobuf U fopen64@@GLIBC_2.1 U fseeko64@@GLIBC_2.1 The 64 bit fopen and fseek calls seem to be linked, off_t is correctly aliased to long. Does anyone have an idea what else I might be missing? Thanks a lot, Lars